Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5730 | pavelyakov | 1 | #ifndef INCLUDE_FONT_H |
2 | #define INCLUDE_FONT_H |
||
3 | |||
4 | #ifndef INCLUDE_MATH_H |
||
5 | #include "../lib/math.h" |
||
6 | #endif |
||
7 | |||
8 | #ifndef INCLUDE_IO_H |
||
9 | #include "../lib/io.h" |
||
10 | #endif |
||
11 | |||
12 | :struct FONT |
||
13 | { |
||
14 | byte width,height,offsetLine; |
||
15 | word block; |
||
16 | dword data; |
||
17 | dword size_file; |
||
18 | byte load(...); |
||
19 | byte symbol(word x,y;byte s;dword c); |
||
20 | dword text(word x,y;dword text,c); |
||
21 | dword textarea(word x,y;dword text,c); |
||
22 | }; |
||
23 | FONT font = 0; |
||
24 | :dword FONT::text(word x,y;dword text1,c) |
||
25 | { |
||
26 | dword len=0; |
||
27 | WHILE(DSBYTE[text1]) |
||
28 | { |
||
29 | len += symbol(x+len,y,DSBYTE[text1],c); |
||
30 | text1++; |
||
31 | } |
||
32 | return len; |
||
33 | } |
||
34 | :dword FONT::textarea(word x,y;dword text1,c) |
||
35 | { |
||
36 | dword len=0; |
||
37 | WHILE(DSBYTE[text1]) |
||
38 | { |
||
39 | IF(DSBYTE[text1]=='\r'){ y+=height; len=0;} |
||
40 | ELSE len += symbol(x+len,y,DSBYTE[text1],c); |
||
41 | text1++; |
||
42 | } |
||
43 | return len; |
||
44 | } |
||
45 | :byte FONT::symbol(signed x,y;byte s;dword c) |
||
46 | { |
||
47 | dword xi,yi; |
||
48 | dword tmp,_; |
||
49 | dword iii; |
||
50 | byte rw=0; |
||
51 | IF(offsetLine)y+=offsetLine; |
||
52 | IF(s==32)return width/4; |
||
53 | yi = 0; |
||
54 | iii = 0; |
||
55 | tmp = 4*block*s; |
||
56 | tmp +=data; |
||
57 | while(yi |
||
58 | { |
||
59 | xi = 0; |
||
60 | WHILE(xi |
||
61 | { |
||
62 | IF(!(iii%32)) |
||
63 | { |
||
64 | tmp += 4; |
||
65 | _ = DSDWORD[tmp]; |
||
66 | } |
||
67 | ELSE _ >>= 1; |
||
68 | IF(_&1) |
||
69 | { |
||
70 | IF(xi>rw)rw=xi; |
||
71 | PutPixel(x+xi,y+yi,c); |
||
72 | } |
||
73 | xi++; |
||
74 | iii++; |
||
75 | } |
||
76 | yi++; |
||
77 | } |
||
78 | return rw; |
||
79 | } |
||
80 | :byte FONT::load(dword path) |
||
81 | { |
||
82 | dword tmp; |
||
83 | IF(data)free(data); |
||
84 | tmp = io.read(path); |
||
85 | data = tmp; |
||
86 | size_file = io.FILES_SIZE; |
||
87 | tmp +=size_file; |
||
88 | tmp--; |
||
89 | height = DSBYTE[tmp]; |
||
90 | tmp--; |
||
91 | width = DSBYTE[tmp]; |
||
92 | block = math.ceil(height*width/32); |
||
93 | } |
||
94 | |||
95 | #endif |