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