Rev 489 | Rev 531 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
485 | giacomo | 1 | #include <ll/i386/hw-data.h> |
2 | #include <ll/i386/mem.h> |
||
3 | #include <linux/fb.h> |
||
4 | |||
5 | static unsigned char font_table[127][8] = |
||
6 | { |
||
7 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, |
||
8 | {0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e}, |
||
9 | {0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e}, |
||
10 | {0x6c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00}, |
||
11 | {0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00}, |
||
12 | {0x38, 0x7c, 0x38, 0xfe, 0xfe, 0x7c, 0x38, 0x7c}, |
||
13 | {0x10, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x7c}, |
||
14 | {0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00}, |
||
15 | {0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff}, |
||
16 | {0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00}, |
||
17 | {0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff}, |
||
18 | {0x0f, 0x07, 0x0f, 0x7d, 0xcc, 0xcc, 0xcc, 0x78}, |
||
19 | {0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18}, |
||
20 | {0x3f, 0x33, 0x3f, 0x30, 0x30, 0x70, 0xf0, 0xe0}, |
||
21 | {0x7f, 0x63, 0x7f, 0x63, 0x63, 0x67, 0xe6, 0xc0}, |
||
22 | {0x99, 0x5a, 0x3c, 0xe7, 0xe7, 0x3c, 0x5a, 0x99}, |
||
23 | {0x80, 0xe0, 0xf8, 0xfe, 0xf8, 0xe0, 0x80, 0x00}, |
||
24 | {0x02, 0x0e, 0x3e, 0xfe, 0x3e, 0x0e, 0x02, 0x00}, |
||
25 | {0x18, 0x3c, 0x7e, 0x18, 0x18, 0x7e, 0x3c, 0x18}, |
||
26 | {0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00}, |
||
27 | {0x7f, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x00}, |
||
28 | {0x3e, 0x63, 0x38, 0x6c, 0x6c, 0x38, 0xcc, 0x78}, |
||
29 | {0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x7e, 0x00}, |
||
30 | {0x18, 0x3c, 0x7e, 0x18, 0x7e, 0x3c, 0x18, 0xff}, |
||
31 | {0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x00}, |
||
32 | {0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00}, |
||
33 | {0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00}, |
||
34 | {0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00}, |
||
35 | {0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00}, |
||
36 | {0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00}, |
||
37 | {0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0x00}, |
||
38 | {0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00, 0x00}, |
||
39 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, |
||
40 | {0x30, 0x78, 0x78, 0x30, 0x30, 0x00, 0x30, 0x00}, |
||
41 | {0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00}, |
||
42 | {0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0x6c, 0x00}, |
||
43 | {0x30, 0x7c, 0xc0, 0x78, 0x0c, 0xf8, 0x30, 0x00}, |
||
44 | {0x00, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xc6, 0x00}, |
||
45 | {0x38, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0x76, 0x00}, |
||
46 | {0x60, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00}, |
||
47 | {0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, 0x00}, |
||
48 | {0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00}, |
||
49 | {0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00}, |
||
50 | {0x00, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x00, 0x00}, |
||
51 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x60}, |
||
52 | {0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00}, |
||
53 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00}, |
||
54 | {0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00}, |
||
55 | {0x7c, 0xc6, 0xce, 0xde, 0xf6, 0xe6, 0x7c, 0x00}, |
||
56 | {0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0xfc, 0x00}, |
||
57 | {0x78, 0xcc, 0x0c, 0x38, 0x60, 0xcc, 0xfc, 0x00}, |
||
58 | {0x78, 0xcc, 0x0c, 0x38, 0x0c, 0xcc, 0x78, 0x00}, |
||
59 | {0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x1e, 0x00}, |
||
60 | {0xfc, 0xc0, 0xf8, 0x0c, 0x0c, 0xcc, 0x78, 0x00}, |
||
61 | {0x38, 0x60, 0xc0, 0xf8, 0xcc, 0xcc, 0x78, 0x00}, |
||
62 | {0xfc, 0xcc, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x00}, |
||
63 | {0x78, 0xcc, 0xcc, 0x78, 0xcc, 0xcc, 0x78, 0x00}, |
||
64 | {0x78, 0xcc, 0xcc, 0x7c, 0x0c, 0x18, 0x70, 0x00}, |
||
65 | {0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x00}, |
||
66 | {0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x60}, |
||
67 | {0x18, 0x30, 0x60, 0xc0, 0x60, 0x30, 0x18, 0x00}, |
||
68 | {0x00, 0x00, 0xfc, 0x00, 0x00, 0xfc, 0x00, 0x00}, |
||
69 | {0x60, 0x30, 0x18, 0x0c, 0x18, 0x30, 0x60, 0x00}, |
||
70 | {0x78, 0xcc, 0x0c, 0x18, 0x30, 0x00, 0x30, 0x00}, |
||
71 | {0x7c, 0xc6, 0xde, 0xde, 0xde, 0xc0, 0x78, 0x00}, |
||
72 | {0x30, 0x78, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0x00}, |
||
73 | {0xfc, 0x66, 0x66, 0x7c, 0x66, 0x66, 0xfc, 0x00}, |
||
74 | {0x3c, 0x66, 0xc0, 0xc0, 0xc0, 0x66, 0x3c, 0x00}, |
||
75 | {0xf8, 0x6c, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00}, |
||
76 | {0xfe, 0x62, 0x68, 0x78, 0x68, 0x62, 0xfe, 0x00}, |
||
77 | {0xfe, 0x62, 0x68, 0x78, 0x68, 0x60, 0xf0, 0x00}, |
||
78 | {0x3c, 0x66, 0xc0, 0xc0, 0xce, 0x66, 0x3e, 0x00}, |
||
79 | {0xcc, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0xcc, 0x00}, |
||
80 | {0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00}, |
||
81 | {0x1e, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, 0x00}, |
||
82 | {0xe6, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0xe6, 0x00}, |
||
83 | {0xf0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00}, |
||
84 | {0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0x00}, |
||
85 | {0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0xc6, 0x00}, |
||
86 | {0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00}, |
||
87 | {0xfc, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00}, |
||
88 | {0x78, 0xcc, 0xcc, 0xcc, 0xdc, 0x78, 0x1c, 0x00}, |
||
89 | {0xfc, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0xe6, 0x00}, |
||
90 | {0x78, 0xcc, 0xe0, 0x70, 0x1c, 0xcc, 0x78, 0x00}, |
||
91 | {0xfc, 0xb4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00}, |
||
92 | {0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xfc, 0x00}, |
||
93 | {0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x00}, |
||
94 | {0xc6, 0xc6, 0xc6, 0xd6, 0xfe, 0xee, 0xc6, 0x00}, |
||
95 | {0xc6, 0xc6, 0x6c, 0x38, 0x38, 0x6c, 0xc6, 0x00}, |
||
96 | {0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x30, 0x78, 0x00}, |
||
97 | {0xfe, 0xc6, 0x8c, 0x18, 0x32, 0x66, 0xfe, 0x00}, |
||
98 | {0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, 0x00}, |
||
99 | {0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x02, 0x00}, |
||
100 | {0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00}, |
||
101 | {0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00}, |
||
102 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff}, |
||
103 | {0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}, |
||
104 | {0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00}, |
||
105 | {0xe0, 0x60, 0x60, 0x7c, 0x66, 0x66, 0xdc, 0x00}, |
||
106 | {0x00, 0x00, 0x78, 0xcc, 0xc0, 0xcc, 0x78, 0x00}, |
||
107 | {0x1c, 0x0c, 0x0c, 0x7c, 0xcc, 0xcc, 0x76, 0x00}, |
||
108 | {0x00, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00}, |
||
109 | {0x38, 0x6c, 0x60, 0xf0, 0x60, 0x60, 0xf0, 0x00}, |
||
110 | {0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8}, |
||
111 | {0xe0, 0x60, 0x6c, 0x76, 0x66, 0x66, 0xe6, 0x00}, |
||
112 | {0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00}, |
||
113 | {0x0c, 0x00, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78}, |
||
114 | {0xe0, 0x60, 0x66, 0x6c, 0x78, 0x6c, 0xe6, 0x00}, |
||
115 | {0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00}, |
||
116 | {0x00, 0x00, 0xcc, 0xfe, 0xfe, 0xd6, 0xc6, 0x00}, |
||
117 | {0x00, 0x00, 0xf8, 0xcc, 0xcc, 0xcc, 0xcc, 0x00}, |
||
118 | {0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0x78, 0x00}, |
||
119 | {0x00, 0x00, 0xdc, 0x66, 0x66, 0x7c, 0x60, 0xf0}, |
||
120 | {0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0x1e}, |
||
121 | {0x00, 0x00, 0xdc, 0x76, 0x66, 0x60, 0xf0, 0x00}, |
||
122 | {0x00, 0x00, 0x7c, 0xc0, 0x78, 0x0c, 0xf8, 0x00}, |
||
123 | {0x10, 0x30, 0x7c, 0x30, 0x30, 0x34, 0x18, 0x00}, |
||
124 | {0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00}, |
||
125 | {0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x00}, |
||
126 | {0x00, 0x00, 0xc6, 0xd6, 0xfe, 0xfe, 0x6c, 0x00}, |
||
127 | {0x00, 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00}, |
||
128 | {0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8}, |
||
129 | {0x00, 0x00, 0xfc, 0x98, 0x30, 0x64, 0xfc, 0x00}, |
||
130 | {0x1c, 0x30, 0x30, 0xe0, 0x30, 0x30, 0x1c, 0x00}, |
||
131 | {0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, |
||
132 | {0xe0, 0x30, 0x30, 0x1c, 0x30, 0x30, 0xe0, 0x00}, |
||
133 | {0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, |
||
134 | }; |
||
135 | |||
136 | #define memsetw(addr, val, n) {LIN_ADDR i; for(i = addr; i < addr + n; i += 2) *(WORD *)i = val;} |
||
137 | |||
138 | struct fb_info *grx_info = NULL; |
||
486 | giacomo | 139 | extern struct fb_info *registered_fb[FB_MAX]; |
485 | giacomo | 140 | |
529 | giacomo | 141 | void FB26_use_grx(int num) |
485 | giacomo | 142 | { |
143 | |||
486 | giacomo | 144 | grx_info = registered_fb[num]; |
485 | giacomo | 145 | |
146 | } |
||
147 | |||
148 | void grx_putimage(WORD x1, WORD y1, WORD x2, WORD y2, BYTE *buf) |
||
149 | { |
||
150 | |||
488 | giacomo | 151 | WORD bpr; |
152 | LIN_ADDR addr, p; |
||
153 | WORD dx, y; |
||
485 | giacomo | 154 | |
155 | if (!grx_info || grx_info->var.bits_per_pixel != 16) return; |
||
156 | |||
488 | giacomo | 157 | bpr = grx_info->var.xres * 2; |
158 | p = buf; |
||
159 | addr = (LIN_ADDR)(grx_info->screen_base + x1 * 2 + bpr * y1); |
||
160 | dx = (x2 - x1 + 1) * 2; |
||
161 | |||
162 | for (y = y1; y <= y2; y++) { |
||
163 | memcpy(addr, p, dx); |
||
164 | p += dx; |
||
165 | addr += bpr; |
||
166 | } |
||
485 | giacomo | 167 | |
168 | } |
||
169 | |||
170 | void grx_getimage(WORD x1, WORD y1, WORD x2, WORD y2, BYTE *buf) |
||
171 | { |
||
172 | WORD bpr; |
||
173 | LIN_ADDR addr, p; |
||
174 | WORD dx, y; |
||
175 | |||
176 | if (!grx_info || grx_info->var.bits_per_pixel != 16) return; |
||
177 | |||
178 | bpr = grx_info->var.xres * 2; |
||
179 | p = buf; |
||
180 | addr = (LIN_ADDR)(grx_info->screen_base + x1 * 2 + bpr * y1); |
||
181 | dx = (x2 - x1 + 1) * 2; |
||
182 | |||
183 | for (y = y1; y <= y2; y++) { |
||
184 | memcpy(p, addr, dx); |
||
185 | p += dx; |
||
186 | addr += bpr; |
||
187 | } |
||
188 | |||
189 | } |
||
190 | |||
191 | void grx_box(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color) |
||
192 | { |
||
193 | |||
194 | if (!grx_info || grx_info->var.bits_per_pixel != 16) return; |
||
195 | |||
488 | giacomo | 196 | WORD bpr; |
197 | DWORD addr; |
||
198 | WORD dx, y; |
||
485 | giacomo | 199 | |
488 | giacomo | 200 | bpr = grx_info->var.xres * 2;; |
201 | addr = (DWORD)(grx_info->screen_base + x1 * 2 + bpr * y1); |
||
202 | dx = (x2 - x1 + 1) * 2; |
||
203 | |||
204 | for (y = y1; y <= y2; y++) { |
||
205 | memsetw((LIN_ADDR)addr, color, dx); |
||
206 | addr += bpr; |
||
207 | } |
||
485 | giacomo | 208 | |
209 | } |
||
210 | |||
211 | void grx_rect(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color) |
||
212 | { |
||
213 | WORD bpr; |
||
214 | DWORD addr; |
||
215 | WORD dx, y; |
||
216 | |||
217 | if (!grx_info || grx_info->var.bits_per_pixel != 16) return; |
||
218 | |||
219 | bpr = grx_info->var.xres * 2; |
||
220 | addr = (DWORD)(grx_info->screen_base + x1 * 2 + bpr * y1); |
||
221 | dx = (x2 - x1) * 2; |
||
222 | |||
223 | memsetw((LIN_ADDR)addr, color, dx+2); |
||
224 | addr += bpr; |
||
225 | |||
226 | for (y = y1 + 1; y <= y2 - 1; y++) { |
||
227 | *(WORD *)addr = color; |
||
228 | *(WORD *)(addr + dx) = color; |
||
229 | addr += bpr; |
||
230 | } |
||
231 | memsetw((LIN_ADDR)addr, color, dx+2); |
||
232 | } |
||
233 | |||
234 | void grx_text(char *text, WORD x, WORD y, DWORD fg, DWORD bg) |
||
235 | { |
||
236 | DWORD fp, addr; |
||
237 | WORD bpr; |
||
238 | int r, c, bits; |
||
239 | |||
240 | if (!grx_info || grx_info->var.bits_per_pixel != 16) return; |
||
241 | |||
242 | bpr = grx_info->var.xres * 2; |
||
243 | addr = (DWORD)(grx_info->screen_base); |
||
244 | while (*text) { |
||
245 | fp = (DWORD)&(font_table[*(BYTE *)text][0]); |
||
246 | for (r=0; r<8; r++) { |
||
247 | bits = *(BYTE *)(fp++); |
||
248 | for (c=0; c<8; c++) |
||
249 | if (bits & (0x80>>c)) |
||
250 | *(WORD *)(addr + (y + r) * bpr + ((x + c) * 2)) = fg; |
||
251 | else |
||
252 | *(WORD *)(addr + (y + r) * bpr + ((x + c) * 2)) = bg; |
||
253 | } |
||
254 | text++; |
||
255 | x += 8; |
||
256 | } |
||
257 | } |
||
258 | |||
487 | giacomo | 259 | void grx_line(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color) |
485 | giacomo | 260 | { |
261 | register int t, distance; |
||
262 | register DWORD addr; |
||
263 | register WORD bpr; |
||
264 | int xerr=0, yerr=0, deltax, deltay; |
||
265 | int incx, incy; |
||
266 | |||
267 | bpr = grx_info->var.xres * 2; |
||
268 | addr = (DWORD)(grx_info->screen_base); |
||
269 | deltax = x2 - x1; /* compute both distances */ |
||
270 | deltay = y2 - y1; |
||
271 | |||
272 | if (deltax > 0) /* compute increments */ |
||
273 | incx = 1; |
||
274 | else if (deltax == 0) |
||
275 | incx = 0; |
||
276 | else |
||
277 | incx = -1; |
||
278 | |||
279 | if (deltay > 0) |
||
280 | incy = 1; |
||
281 | else if (deltay == 0) |
||
282 | incy = 0; |
||
283 | else |
||
284 | incy = -1; |
||
285 | |||
286 | deltax = abs(deltax); /* determine greater distance */ |
||
287 | deltay = abs(deltay); |
||
288 | if (deltax > deltay) |
||
289 | distance = deltax; |
||
290 | else |
||
291 | distance = deltay; |
||
292 | |||
293 | for (t=0; t<=distance+1; t++) { /* draw the line */ |
||
294 | *(WORD *)(addr + y1 * bpr + (x1 * 2)) = color; |
||
295 | xerr += deltax; |
||
296 | yerr += deltay; |
||
297 | if (xerr > distance) { |
||
298 | xerr -= distance; |
||
299 | x1 += incx; |
||
300 | } |
||
301 | if (yerr > distance) { |
||
302 | yerr -= distance; |
||
303 | y1 += incy; |
||
304 | } |
||
305 | } |
||
306 | } |
||
307 | |||
308 | void grx_plot(WORD x, WORD y, DWORD color) |
||
309 | { |
||
310 | WORD bpr; |
||
311 | |||
312 | if (!grx_info || grx_info->var.bits_per_pixel != 16) return; |
||
313 | |||
314 | bpr = grx_info->var.xres * 2; |
||
315 | *(WORD *)(grx_info->screen_base + y * bpr + (x * 2)) = color; |
||
316 | } |
||
317 | |||
318 | DWORD grx_getpixel(WORD x, WORD y) |
||
319 | { |
||
320 | WORD bpr; |
||
321 | DWORD rv; |
||
322 | |||
323 | if (!grx_info || grx_info->var.bits_per_pixel != 16) return -1; |
||
324 | |||
325 | bpr = grx_info->var.xres * 2; |
||
326 | rv = *(WORD *)(grx_info->screen_base + y * bpr + (x * 2)); |
||
327 | return rv; |
||
328 | |||
329 | } |
||
330 | |||
331 | static void circlepixels(WORD x, WORD y, WORD sx, WORD sy, DWORD c) |
||
332 | { |
||
333 | grx_plot(sx + x, sy + y, c); |
||
334 | grx_plot(sx - x, sy + y, c); |
||
335 | grx_plot(sx + x, sy - y, c); |
||
336 | grx_plot(sx - x, sy - y, c); |
||
337 | grx_plot(sx + y, sy + x, c); |
||
338 | grx_plot(sx - y, sy + x, c); |
||
339 | grx_plot(sx + y, sy - x, c); |
||
340 | grx_plot(sx - y, sy - x, c); |
||
341 | } |
||
342 | |||
343 | void grx_circle(WORD sx, WORD sy, WORD r, DWORD c) |
||
344 | { |
||
345 | int x, y, d; |
||
346 | |||
347 | if (!grx_info || grx_info->var.bits_per_pixel != 16) return; |
||
348 | |||
349 | if (r < 1) { |
||
350 | grx_plot(sx, sy, c); |
||
351 | return; |
||
352 | } |
||
353 | |||
354 | x = 0; |
||
355 | y = r; |
||
356 | d = 1 - r; |
||
357 | circlepixels(x, y, sx, sy, c); |
||
358 | while (x < y) { |
||
359 | if (d < 0) |
||
360 | d += x * 2 + 3; |
||
361 | else { |
||
362 | d += x * 2 - y * 2 + 5; |
||
363 | y--; |
||
364 | } |
||
365 | x++; |
||
366 | circlepixels(x, y, sx, sy, c); |
||
367 | } |
||
368 | } |
||
369 | |||
370 | static __inline__ void discpixels(WORD x, WORD y, WORD sx, WORD sy, DWORD c) |
||
371 | { |
||
372 | grx_line(sx + x, sy + y, sx + x, sy - y, c); |
||
373 | grx_line(sx - x, sy + y, sx - x, sy - y, c); |
||
374 | grx_line(sx + y, sy + x, sx + y, sy - x , c); |
||
375 | grx_line(sx - y, sy + x, sx - y, sy - x , c); |
||
376 | } |
||
377 | |||
378 | void grx_disc(WORD sx, WORD sy, WORD r, DWORD c) |
||
379 | { |
||
380 | int x, y, d; |
||
381 | |||
382 | if (!grx_info || grx_info->var.bits_per_pixel != 16) return; |
||
383 | |||
384 | if (r < 1) { |
||
385 | grx_plot(sx, sy, c); |
||
386 | return; |
||
387 | } |
||
388 | x = 0; |
||
389 | y = r; |
||
390 | d = 1 - r; |
||
391 | discpixels(x, y, sx, sy, c); |
||
392 | while (x < y) { |
||
393 | if (d < 0) |
||
394 | d += x * 2 + 3; |
||
395 | else { |
||
396 | d += x * 2 - y * 2 + 5; |
||
397 | y--; |
||
398 | } |
||
399 | x++; |
||
400 | discpixels(x, y, sx, sy, c); |
||
401 | } |
||
402 | } |
||
403 |