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