Revision 17b0018b hw/vga_template.h
b/hw/vga_template.h | ||
---|---|---|
37 | 37 |
|
38 | 38 |
#if DEPTH != 15 |
39 | 39 |
|
40 |
static void glue(vga_draw_glyph8_, DEPTH)(uint8_t *d, int linesize, |
|
41 |
const uint8_t *font_ptr, int h, |
|
42 |
uint32_t fgcol, uint32_t bgcol) |
|
40 |
static inline void glue(vga_draw_glyph_line_, DEPTH)(uint8_t *d, |
|
41 |
uint32_t font_data, |
|
42 |
uint32_t xorcol, |
|
43 |
uint32_t bgcol) |
|
43 | 44 |
{ |
44 |
uint32_t font_data, xorcol; |
|
45 |
|
|
46 |
xorcol = bgcol ^ fgcol; |
|
47 |
do { |
|
48 |
font_data = font_ptr[0]; |
|
49 | 45 |
#if BPP == 1 |
50 | 46 |
((uint32_t *)d)[0] = (dmask16[(font_data >> 4)] & xorcol) ^ bgcol; |
51 | 47 |
((uint32_t *)d)[3] = (dmask16[(font_data >> 0) & 0xf] & xorcol) ^ bgcol; |
... | ... | |
64 | 60 |
((uint32_t *)d)[6] = ((-(font_data >> 1) & 1) & xorcol) ^ bgcol; |
65 | 61 |
((uint32_t *)d)[7] = ((-(font_data >> 0) & 1) & xorcol) ^ bgcol; |
66 | 62 |
#endif |
63 |
} |
|
64 |
|
|
65 |
static void glue(vga_draw_glyph8_, DEPTH)(uint8_t *d, int linesize, |
|
66 |
const uint8_t *font_ptr, int h, |
|
67 |
uint32_t fgcol, uint32_t bgcol) |
|
68 |
{ |
|
69 |
uint32_t font_data, xorcol; |
|
70 |
|
|
71 |
xorcol = bgcol ^ fgcol; |
|
72 |
do { |
|
73 |
font_data = font_ptr[0]; |
|
74 |
glue(vga_draw_glyph_line_, DEPTH)(d, font_data, xorcol, bgcol); |
|
75 |
font_ptr += 4; |
|
76 |
d += linesize; |
|
77 |
} while (--h); |
|
78 |
} |
|
79 |
|
|
80 |
static void glue(vga_draw_glyph16_, DEPTH)(uint8_t *d, int linesize, |
|
81 |
const uint8_t *font_ptr, int h, |
|
82 |
uint32_t fgcol, uint32_t bgcol) |
|
83 |
{ |
|
84 |
uint32_t font_data, xorcol; |
|
85 |
|
|
86 |
xorcol = bgcol ^ fgcol; |
|
87 |
do { |
|
88 |
font_data = font_ptr[0]; |
|
89 |
glue(vga_draw_glyph_line_, DEPTH)(d, |
|
90 |
expand4to8[font_data >> 4], |
|
91 |
xorcol, bgcol); |
|
92 |
glue(vga_draw_glyph_line_, DEPTH)(d + 8 * BPP, |
|
93 |
expand4to8[font_data & 0x0f], |
|
94 |
xorcol, bgcol); |
|
67 | 95 |
font_ptr += 4; |
68 | 96 |
d += linesize; |
69 | 97 |
} while (--h); |
... | ... | |
151 | 179 |
} |
152 | 180 |
} |
153 | 181 |
|
182 |
#if BPP == 1 |
|
183 |
#define PUT_PIXEL2(d, n, v) ((uint16_t *)d)[(n)] = (v) |
|
184 |
#elif BPP == 2 |
|
185 |
#define PUT_PIXEL2(d, n, v) ((uint32_t *)d)[(n)] = (v) |
|
186 |
#else |
|
187 |
#define PUT_PIXEL2(d, n, v) \ |
|
188 |
((uint32_t *)d)[2*(n)] = ((uint32_t *)d)[2*(n)+1] = (v) |
|
189 |
#endif |
|
190 |
|
|
191 |
/* |
|
192 |
* 4 color mode, dup2 horizontal |
|
193 |
*/ |
|
194 |
static void glue(vga_draw_line2d2_, DEPTH)(VGAState *s1, uint8_t *d, |
|
195 |
const uint8_t *s, int width) |
|
196 |
{ |
|
197 |
uint32_t plane_mask, *palette, data, v; |
|
198 |
int x; |
|
199 |
|
|
200 |
palette = s1->last_palette; |
|
201 |
plane_mask = mask16[s1->ar[0x12] & 0xf]; |
|
202 |
width >>= 3; |
|
203 |
for(x = 0; x < width; x++) { |
|
204 |
data = ((uint32_t *)s)[0]; |
|
205 |
data &= plane_mask; |
|
206 |
v = expand2[GET_PLANE(data, 0)]; |
|
207 |
v |= expand2[GET_PLANE(data, 2)] << 2; |
|
208 |
PUT_PIXEL2(d, 0, palette[v >> 12]); |
|
209 |
PUT_PIXEL2(d, 1, palette[(v >> 8) & 0xf]); |
|
210 |
PUT_PIXEL2(d, 2, palette[(v >> 4) & 0xf]); |
|
211 |
PUT_PIXEL2(d, 3, palette[(v >> 0) & 0xf]); |
|
212 |
|
|
213 |
v = expand2[GET_PLANE(data, 1)]; |
|
214 |
v |= expand2[GET_PLANE(data, 3)] << 2; |
|
215 |
PUT_PIXEL2(d, 4, palette[v >> 12]); |
|
216 |
PUT_PIXEL2(d, 5, palette[(v >> 8) & 0xf]); |
|
217 |
PUT_PIXEL2(d, 6, palette[(v >> 4) & 0xf]); |
|
218 |
PUT_PIXEL2(d, 7, palette[(v >> 0) & 0xf]); |
|
219 |
d += BPP * 16; |
|
220 |
s += 4; |
|
221 |
} |
|
222 |
} |
|
223 |
|
|
154 | 224 |
/* |
155 | 225 |
* 16 color mode |
156 | 226 |
*/ |
... | ... | |
184 | 254 |
} |
185 | 255 |
|
186 | 256 |
/* |
187 |
* 256 color mode |
|
257 |
* 16 color mode, dup2 horizontal |
|
258 |
*/ |
|
259 |
static void glue(vga_draw_line4d2_, DEPTH)(VGAState *s1, uint8_t *d, |
|
260 |
const uint8_t *s, int width) |
|
261 |
{ |
|
262 |
uint32_t plane_mask, data, v, *palette; |
|
263 |
int x; |
|
264 |
|
|
265 |
palette = s1->last_palette; |
|
266 |
plane_mask = mask16[s1->ar[0x12] & 0xf]; |
|
267 |
width >>= 3; |
|
268 |
for(x = 0; x < width; x++) { |
|
269 |
data = ((uint32_t *)s)[0]; |
|
270 |
data &= plane_mask; |
|
271 |
v = expand4[GET_PLANE(data, 0)]; |
|
272 |
v |= expand4[GET_PLANE(data, 1)] << 1; |
|
273 |
v |= expand4[GET_PLANE(data, 2)] << 2; |
|
274 |
v |= expand4[GET_PLANE(data, 3)] << 3; |
|
275 |
PUT_PIXEL2(d, 0, palette[v >> 28]); |
|
276 |
PUT_PIXEL2(d, 1, palette[(v >> 24) & 0xf]); |
|
277 |
PUT_PIXEL2(d, 2, palette[(v >> 20) & 0xf]); |
|
278 |
PUT_PIXEL2(d, 3, palette[(v >> 16) & 0xf]); |
|
279 |
PUT_PIXEL2(d, 4, palette[(v >> 12) & 0xf]); |
|
280 |
PUT_PIXEL2(d, 5, palette[(v >> 8) & 0xf]); |
|
281 |
PUT_PIXEL2(d, 6, palette[(v >> 4) & 0xf]); |
|
282 |
PUT_PIXEL2(d, 7, palette[(v >> 0) & 0xf]); |
|
283 |
d += BPP * 16; |
|
284 |
s += 4; |
|
285 |
} |
|
286 |
} |
|
287 |
|
|
288 |
/* |
|
289 |
* 256 color mode, double pixels |
|
290 |
* |
|
291 |
* XXX: add plane_mask support (never used in standard VGA modes) |
|
292 |
*/ |
|
293 |
static void glue(vga_draw_line8d2_, DEPTH)(VGAState *s1, uint8_t *d, |
|
294 |
const uint8_t *s, int width) |
|
295 |
{ |
|
296 |
uint32_t *palette; |
|
297 |
int x; |
|
298 |
|
|
299 |
palette = s1->last_palette; |
|
300 |
width >>= 3; |
|
301 |
for(x = 0; x < width; x++) { |
|
302 |
PUT_PIXEL2(d, 0, palette[s[0]]); |
|
303 |
PUT_PIXEL2(d, 1, palette[s[1]]); |
|
304 |
PUT_PIXEL2(d, 2, palette[s[2]]); |
|
305 |
PUT_PIXEL2(d, 3, palette[s[3]]); |
|
306 |
d += BPP * 8; |
|
307 |
s += 4; |
|
308 |
} |
|
309 |
} |
|
310 |
|
|
311 |
/* |
|
312 |
* standard 256 color mode |
|
188 | 313 |
* |
189 | 314 |
* XXX: add plane_mask support (never used in standard VGA modes) |
190 | 315 |
*/ |
... | ... | |
289 | 414 |
#endif |
290 | 415 |
} |
291 | 416 |
|
417 |
#undef PUT_PIXEL2 |
|
292 | 418 |
#undef DEPTH |
293 | 419 |
#undef BPP |
294 | 420 |
#undef PIXEL_TYPE |
Also available in: Unified diff