Rev 487 | Rev 489 | 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]; |
487 | giacomo | 147 | grx_info->fix.visual = FB_VISUAL_DIRECTCOLOR; |
485 | giacomo | 148 | |
149 | } |
||
150 | |||
151 | void grx_putimage(WORD x1, WORD y1, WORD x2, WORD y2, BYTE *buf) |
||
152 | { |
||
153 | |||
488 | giacomo | 154 | WORD bpr; |
155 | LIN_ADDR addr, p; |
||
156 | WORD dx, y; |
||
485 | giacomo | 157 | |
158 | if (!grx_info || grx_info->var.bits_per_pixel != 16) return; |
||
159 | |||
488 | giacomo | 160 | bpr = grx_info->var.xres * 2; |
161 | p = buf; |
||
162 | addr = (LIN_ADDR)(grx_info->screen_base + x1 * 2 + bpr * y1); |
||
163 | dx = (x2 - x1 + 1) * 2; |
||
164 | |||
165 | for (y = y1; y <= y2; y++) { |
||
166 | memcpy(addr, p, dx); |
||
167 | p += dx; |
||
168 | addr += bpr; |
||
169 | } |
||
485 | giacomo | 170 | |
171 | } |
||
172 | |||
173 | void grx_getimage(WORD x1, WORD y1, WORD x2, WORD y2, BYTE *buf) |
||
174 | { |
||
175 | WORD bpr; |
||
176 | LIN_ADDR addr, p; |
||
177 | WORD dx, y; |
||
178 | |||
179 | if (!grx_info || grx_info->var.bits_per_pixel != 16) return; |
||
180 | |||
181 | bpr = grx_info->var.xres * 2; |
||
182 | p = buf; |
||
183 | addr = (LIN_ADDR)(grx_info->screen_base + x1 * 2 + bpr * y1); |
||
184 | dx = (x2 - x1 + 1) * 2; |
||
185 | |||
186 | for (y = y1; y <= y2; y++) { |
||
187 | memcpy(p, addr, dx); |
||
188 | p += dx; |
||
189 | addr += bpr; |
||
190 | } |
||
191 | |||
192 | } |
||
193 | |||
194 | void grx_box(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color) |
||
195 | { |
||
196 | |||
197 | if (!grx_info || grx_info->var.bits_per_pixel != 16) return; |
||
198 | |||
488 | giacomo | 199 | WORD bpr; |
200 | DWORD addr; |
||
201 | WORD dx, y; |
||
485 | giacomo | 202 | |
488 | giacomo | 203 | bpr = grx_info->var.xres * 2;; |
204 | addr = (DWORD)(grx_info->screen_base + x1 * 2 + bpr * y1); |
||
205 | dx = (x2 - x1 + 1) * 2; |
||
206 | |||
207 | for (y = y1; y <= y2; y++) { |
||
208 | memsetw((LIN_ADDR)addr, color, dx); |
||
209 | addr += bpr; |
||
210 | } |
||
485 | giacomo | 211 | |
212 | } |
||
213 | |||
214 | void grx_rect(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color) |
||
215 | { |
||
216 | WORD bpr; |
||
217 | DWORD addr; |
||
218 | WORD dx, y; |
||
219 | |||
220 | if (!grx_info || grx_info->var.bits_per_pixel != 16) return; |
||
221 | |||
222 | bpr = grx_info->var.xres * 2; |
||
223 | addr = (DWORD)(grx_info->screen_base + x1 * 2 + bpr * y1); |
||
224 | dx = (x2 - x1) * 2; |
||
225 | |||
226 | memsetw((LIN_ADDR)addr, color, dx+2); |
||
227 | addr += bpr; |
||
228 | |||
229 | for (y = y1 + 1; y <= y2 - 1; y++) { |
||
230 | *(WORD *)addr = color; |
||
231 | *(WORD *)(addr + dx) = color; |
||
232 | addr += bpr; |
||
233 | } |
||
234 | memsetw((LIN_ADDR)addr, color, dx+2); |
||
235 | } |
||
236 | |||
237 | void grx_text(char *text, WORD x, WORD y, DWORD fg, DWORD bg) |
||
238 | { |
||
239 | DWORD fp, addr; |
||
240 | WORD bpr; |
||
241 | int r, c, bits; |
||
242 | |||
243 | if (!grx_info || grx_info->var.bits_per_pixel != 16) return; |
||
244 | |||
245 | bpr = grx_info->var.xres * 2; |
||
246 | addr = (DWORD)(grx_info->screen_base); |
||
247 | while (*text) { |
||
248 | fp = (DWORD)&(font_table[*(BYTE *)text][0]); |
||
249 | for (r=0; r<8; r++) { |
||
250 | bits = *(BYTE *)(fp++); |
||
251 | for (c=0; c<8; c++) |
||
252 | if (bits & (0x80>>c)) |
||
253 | *(WORD *)(addr + (y + r) * bpr + ((x + c) * 2)) = fg; |
||
254 | else |
||
255 | *(WORD *)(addr + (y + r) * bpr + ((x + c) * 2)) = bg; |
||
256 | } |
||
257 | text++; |
||
258 | x += 8; |
||
259 | } |
||
260 | } |
||
261 | |||
487 | giacomo | 262 | void grx_line(WORD x1, WORD y1, WORD x2, WORD y2, DWORD color) |
485 | giacomo | 263 | { |
264 | register int t, distance; |
||
265 | register DWORD addr; |
||
266 | register WORD bpr; |
||
267 | int xerr=0, yerr=0, deltax, deltay; |
||
268 | int incx, incy; |
||
269 | |||
270 | bpr = grx_info->var.xres * 2; |
||
271 | addr = (DWORD)(grx_info->screen_base); |
||
272 | deltax = x2 - x1; /* compute both distances */ |
||
273 | deltay = y2 - y1; |
||
274 | |||
275 | if (deltax > 0) /* compute increments */ |
||
276 | incx = 1; |
||
277 | else if (deltax == 0) |
||
278 | incx = 0; |
||
279 | else |
||
280 | incx = -1; |
||
281 | |||
282 | if (deltay > 0) |
||
283 | incy = 1; |
||
284 | else if (deltay == 0) |
||
285 | incy = 0; |
||
286 | else |
||
287 | incy = -1; |
||
288 | |||
289 | deltax = abs(deltax); /* determine greater distance */ |
||
290 | deltay = abs(deltay); |
||
291 | if (deltax > deltay) |
||
292 | distance = deltax; |
||
293 | else |
||
294 | distance = deltay; |
||
295 | |||
296 | for (t=0; t<=distance+1; t++) { /* draw the line */ |
||
297 | *(WORD *)(addr + y1 * bpr + (x1 * 2)) = color; |
||
298 | xerr += deltax; |
||
299 | yerr += deltay; |
||
300 | if (xerr > distance) { |
||
301 | xerr -= distance; |
||
302 | x1 += incx; |
||
303 | } |
||
304 | if (yerr > distance) { |
||
305 | yerr -= distance; |
||
306 | y1 += incy; |
||
307 | } |
||
308 | } |
||
309 | } |
||
310 | |||
311 | void grx_plot(WORD x, WORD y, DWORD color) |
||
312 | { |
||
313 | WORD bpr; |
||
314 | |||
315 | if (!grx_info || grx_info->var.bits_per_pixel != 16) return; |
||
316 | |||
317 | bpr = grx_info->var.xres * 2; |
||
318 | *(WORD *)(grx_info->screen_base + y * bpr + (x * 2)) = color; |
||
319 | } |
||
320 | |||
321 | DWORD grx_getpixel(WORD x, WORD y) |
||
322 | { |
||
323 | WORD bpr; |
||
324 | DWORD rv; |
||
325 | |||
326 | if (!grx_info || grx_info->var.bits_per_pixel != 16) return -1; |
||
327 | |||
328 | bpr = grx_info->var.xres * 2; |
||
329 | rv = *(WORD *)(grx_info->screen_base + y * bpr + (x * 2)); |
||
330 | return rv; |
||
331 | |||
332 | } |
||
333 | |||
334 | static void circlepixels(WORD x, WORD y, WORD sx, WORD sy, DWORD c) |
||
335 | { |
||
336 | grx_plot(sx + x, sy + y, c); |
||
337 | grx_plot(sx - x, sy + y, c); |
||
338 | grx_plot(sx + x, sy - y, c); |
||
339 | grx_plot(sx - x, sy - y, c); |
||
340 | grx_plot(sx + y, sy + x, c); |
||
341 | grx_plot(sx - y, sy + x, c); |
||
342 | grx_plot(sx + y, sy - x, c); |
||
343 | grx_plot(sx - y, sy - x, c); |
||
344 | } |
||
345 | |||
346 | void grx_circle(WORD sx, WORD sy, WORD r, DWORD c) |
||
347 | { |
||
348 | int x, y, d; |
||
349 | |||
350 | if (!grx_info || grx_info->var.bits_per_pixel != 16) return; |
||
351 | |||
352 | if (r < 1) { |
||
353 | grx_plot(sx, sy, c); |
||
354 | return; |
||
355 | } |
||
356 | |||
357 | x = 0; |
||
358 | y = r; |
||
359 | d = 1 - r; |
||
360 | circlepixels(x, y, sx, sy, c); |
||
361 | while (x < y) { |
||
362 | if (d < 0) |
||
363 | d += x * 2 + 3; |
||
364 | else { |
||
365 | d += x * 2 - y * 2 + 5; |
||
366 | y--; |
||
367 | } |
||
368 | x++; |
||
369 | circlepixels(x, y, sx, sy, c); |
||
370 | } |
||
371 | } |
||
372 | |||
373 | static __inline__ void discpixels(WORD x, WORD y, WORD sx, WORD sy, DWORD c) |
||
374 | { |
||
375 | grx_line(sx + x, sy + y, sx + x, sy - y, c); |
||
376 | grx_line(sx - x, sy + y, sx - x, sy - y, c); |
||
377 | grx_line(sx + y, sy + x, sx + y, sy - x , c); |
||
378 | grx_line(sx - y, sy + x, sx - y, sy - x , c); |
||
379 | } |
||
380 | |||
381 | void grx_disc(WORD sx, WORD sy, WORD r, DWORD c) |
||
382 | { |
||
383 | int x, y, d; |
||
384 | |||
385 | if (!grx_info || grx_info->var.bits_per_pixel != 16) return; |
||
386 | |||
387 | if (r < 1) { |
||
388 | grx_plot(sx, sy, c); |
||
389 | return; |
||
390 | } |
||
391 | x = 0; |
||
392 | y = r; |
||
393 | d = 1 - r; |
||
394 | discpixels(x, y, sx, sy, c); |
||
395 | while (x < y) { |
||
396 | if (d < 0) |
||
397 | d += x * 2 + 3; |
||
398 | else { |
||
399 | d += x * 2 - y * 2 + 5; |
||
400 | y--; |
||
401 | } |
||
402 | x++; |
||
403 | discpixels(x, y, sx, sy, c); |
||
404 | } |
||
405 | } |
||
406 |