Revision 5fafdf24 hw/vga_template.h
b/hw/vga_template.h | ||
---|---|---|
1 | 1 |
/* |
2 | 2 |
* QEMU VGA Emulator templates |
3 |
*
|
|
3 |
* |
|
4 | 4 |
* Copyright (c) 2003 Fabrice Bellard |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
7 | 7 |
* of this software and associated documentation files (the "Software"), to deal |
8 | 8 |
* in the Software without restriction, including without limitation the rights |
... | ... | |
24 | 24 |
|
25 | 25 |
#if DEPTH == 8 |
26 | 26 |
#define BPP 1 |
27 |
#define PIXEL_TYPE uint8_t
|
|
27 |
#define PIXEL_TYPE uint8_t |
|
28 | 28 |
#elif DEPTH == 15 || DEPTH == 16 |
29 | 29 |
#define BPP 2 |
30 |
#define PIXEL_TYPE uint16_t
|
|
30 |
#define PIXEL_TYPE uint16_t |
|
31 | 31 |
#elif DEPTH == 32 |
32 | 32 |
#define BPP 4 |
33 |
#define PIXEL_TYPE uint32_t
|
|
33 |
#define PIXEL_TYPE uint32_t |
|
34 | 34 |
#else |
35 | 35 |
#error unsupport depth |
36 | 36 |
#endif |
... | ... | |
43 | 43 |
|
44 | 44 |
#if DEPTH != 15 && !defined(BGR_FORMAT) |
45 | 45 |
|
46 |
static inline void glue(vga_draw_glyph_line_, DEPTH)(uint8_t *d,
|
|
46 |
static inline void glue(vga_draw_glyph_line_, DEPTH)(uint8_t *d, |
|
47 | 47 |
uint32_t font_data, |
48 |
uint32_t xorcol,
|
|
48 |
uint32_t xorcol, |
|
49 | 49 |
uint32_t bgcol) |
50 | 50 |
{ |
51 | 51 |
#if BPP == 1 |
... | ... | |
73 | 73 |
uint32_t fgcol, uint32_t bgcol) |
74 | 74 |
{ |
75 | 75 |
uint32_t font_data, xorcol; |
76 |
|
|
76 |
|
|
77 | 77 |
xorcol = bgcol ^ fgcol; |
78 | 78 |
do { |
79 | 79 |
font_data = font_ptr[0]; |
... | ... | |
88 | 88 |
uint32_t fgcol, uint32_t bgcol) |
89 | 89 |
{ |
90 | 90 |
uint32_t font_data, xorcol; |
91 |
|
|
91 |
|
|
92 | 92 |
xorcol = bgcol ^ fgcol; |
93 | 93 |
do { |
94 | 94 |
font_data = font_ptr[0]; |
95 |
glue(vga_draw_glyph_line_, DEPTH)(d,
|
|
96 |
expand4to8[font_data >> 4],
|
|
95 |
glue(vga_draw_glyph_line_, DEPTH)(d, |
|
96 |
expand4to8[font_data >> 4], |
|
97 | 97 |
xorcol, bgcol); |
98 |
glue(vga_draw_glyph_line_, DEPTH)(d + 8 * BPP,
|
|
99 |
expand4to8[font_data & 0x0f],
|
|
98 |
glue(vga_draw_glyph_line_, DEPTH)(d + 8 * BPP, |
|
99 |
expand4to8[font_data & 0x0f], |
|
100 | 100 |
xorcol, bgcol); |
101 | 101 |
font_ptr += 4; |
102 | 102 |
d += linesize; |
... | ... | |
104 | 104 |
} |
105 | 105 |
|
106 | 106 |
static void glue(vga_draw_glyph9_, DEPTH)(uint8_t *d, int linesize, |
107 |
const uint8_t *font_ptr, int h,
|
|
107 |
const uint8_t *font_ptr, int h, |
|
108 | 108 |
uint32_t fgcol, uint32_t bgcol, int dup9) |
109 | 109 |
{ |
110 | 110 |
uint32_t font_data, xorcol, v; |
111 |
|
|
111 |
|
|
112 | 112 |
xorcol = bgcol ^ fgcol; |
113 | 113 |
do { |
114 | 114 |
font_data = font_ptr[0]; |
... | ... | |
120 | 120 |
((uint8_t *)d)[8] = v >> (24 * (1 - BIG)); |
121 | 121 |
else |
122 | 122 |
((uint8_t *)d)[8] = bgcol; |
123 |
|
|
123 |
|
|
124 | 124 |
#elif BPP == 2 |
125 | 125 |
cpu_to_32wu(((uint32_t *)d)+0, (dmask4[(font_data >> 6)] & xorcol) ^ bgcol); |
126 | 126 |
cpu_to_32wu(((uint32_t *)d)+1, (dmask4[(font_data >> 4) & 3] & xorcol) ^ bgcol); |
... | ... | |
151 | 151 |
} while (--h); |
152 | 152 |
} |
153 | 153 |
|
154 |
/*
|
|
154 |
/* |
|
155 | 155 |
* 4 color mode |
156 | 156 |
*/ |
157 |
static void glue(vga_draw_line2_, DEPTH)(VGAState *s1, uint8_t *d,
|
|
157 |
static void glue(vga_draw_line2_, DEPTH)(VGAState *s1, uint8_t *d, |
|
158 | 158 |
const uint8_t *s, int width) |
159 | 159 |
{ |
160 | 160 |
uint32_t plane_mask, *palette, data, v; |
... | ... | |
193 | 193 |
((uint32_t *)d)[2*(n)] = ((uint32_t *)d)[2*(n)+1] = (v) |
194 | 194 |
#endif |
195 | 195 |
|
196 |
/*
|
|
196 |
/* |
|
197 | 197 |
* 4 color mode, dup2 horizontal |
198 | 198 |
*/ |
199 |
static void glue(vga_draw_line2d2_, DEPTH)(VGAState *s1, uint8_t *d,
|
|
199 |
static void glue(vga_draw_line2d2_, DEPTH)(VGAState *s1, uint8_t *d, |
|
200 | 200 |
const uint8_t *s, int width) |
201 | 201 |
{ |
202 | 202 |
uint32_t plane_mask, *palette, data, v; |
... | ... | |
226 | 226 |
} |
227 | 227 |
} |
228 | 228 |
|
229 |
/*
|
|
229 |
/* |
|
230 | 230 |
* 16 color mode |
231 | 231 |
*/ |
232 |
static void glue(vga_draw_line4_, DEPTH)(VGAState *s1, uint8_t *d,
|
|
232 |
static void glue(vga_draw_line4_, DEPTH)(VGAState *s1, uint8_t *d, |
|
233 | 233 |
const uint8_t *s, int width) |
234 | 234 |
{ |
235 | 235 |
uint32_t plane_mask, data, v, *palette; |
... | ... | |
258 | 258 |
} |
259 | 259 |
} |
260 | 260 |
|
261 |
/*
|
|
261 |
/* |
|
262 | 262 |
* 16 color mode, dup2 horizontal |
263 | 263 |
*/ |
264 |
static void glue(vga_draw_line4d2_, DEPTH)(VGAState *s1, uint8_t *d,
|
|
264 |
static void glue(vga_draw_line4d2_, DEPTH)(VGAState *s1, uint8_t *d, |
|
265 | 265 |
const uint8_t *s, int width) |
266 | 266 |
{ |
267 | 267 |
uint32_t plane_mask, data, v, *palette; |
... | ... | |
290 | 290 |
} |
291 | 291 |
} |
292 | 292 |
|
293 |
/*
|
|
293 |
/* |
|
294 | 294 |
* 256 color mode, double pixels |
295 | 295 |
* |
296 | 296 |
* XXX: add plane_mask support (never used in standard VGA modes) |
297 | 297 |
*/ |
298 |
static void glue(vga_draw_line8d2_, DEPTH)(VGAState *s1, uint8_t *d,
|
|
298 |
static void glue(vga_draw_line8d2_, DEPTH)(VGAState *s1, uint8_t *d, |
|
299 | 299 |
const uint8_t *s, int width) |
300 | 300 |
{ |
301 | 301 |
uint32_t *palette; |
... | ... | |
313 | 313 |
} |
314 | 314 |
} |
315 | 315 |
|
316 |
/*
|
|
316 |
/* |
|
317 | 317 |
* standard 256 color mode |
318 | 318 |
* |
319 | 319 |
* XXX: add plane_mask support (never used in standard VGA modes) |
320 | 320 |
*/ |
321 |
static void glue(vga_draw_line8_, DEPTH)(VGAState *s1, uint8_t *d,
|
|
321 |
static void glue(vga_draw_line8_, DEPTH)(VGAState *s1, uint8_t *d, |
|
322 | 322 |
const uint8_t *s, int width) |
323 | 323 |
{ |
324 | 324 |
uint32_t *palette; |
... | ... | |
340 | 340 |
} |
341 | 341 |
} |
342 | 342 |
|
343 |
void glue(vga_draw_cursor_line_, DEPTH)(uint8_t *d1,
|
|
344 |
const uint8_t *src1,
|
|
343 |
void glue(vga_draw_cursor_line_, DEPTH)(uint8_t *d1, |
|
344 |
const uint8_t *src1, |
|
345 | 345 |
int poffset, int w, |
346 |
unsigned int color0,
|
|
346 |
unsigned int color0, |
|
347 | 347 |
unsigned int color1, |
348 | 348 |
unsigned int color_xor) |
349 | 349 |
{ |
... | ... | |
411 | 411 |
|
412 | 412 |
/* XXX: optimize */ |
413 | 413 |
|
414 |
/*
|
|
414 |
/* |
|
415 | 415 |
* 15 bit color |
416 | 416 |
*/ |
417 |
static void glue(vga_draw_line15_, PIXEL_NAME)(VGAState *s1, uint8_t *d,
|
|
417 |
static void glue(vga_draw_line15_, PIXEL_NAME)(VGAState *s1, uint8_t *d, |
|
418 | 418 |
const uint8_t *s, int width) |
419 | 419 |
{ |
420 | 420 |
#if DEPTH == 15 && defined(WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) |
... | ... | |
433 | 433 |
s += 2; |
434 | 434 |
d += BPP; |
435 | 435 |
} while (--w != 0); |
436 |
#endif
|
|
436 |
#endif |
|
437 | 437 |
} |
438 | 438 |
|
439 |
/*
|
|
439 |
/* |
|
440 | 440 |
* 16 bit color |
441 | 441 |
*/ |
442 |
static void glue(vga_draw_line16_, PIXEL_NAME)(VGAState *s1, uint8_t *d,
|
|
442 |
static void glue(vga_draw_line16_, PIXEL_NAME)(VGAState *s1, uint8_t *d, |
|
443 | 443 |
const uint8_t *s, int width) |
444 | 444 |
{ |
445 | 445 |
#if DEPTH == 16 && defined(WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) |
... | ... | |
458 | 458 |
s += 2; |
459 | 459 |
d += BPP; |
460 | 460 |
} while (--w != 0); |
461 |
#endif
|
|
461 |
#endif |
|
462 | 462 |
} |
463 | 463 |
|
464 |
/*
|
|
464 |
/* |
|
465 | 465 |
* 24 bit color |
466 | 466 |
*/ |
467 |
static void glue(vga_draw_line24_, PIXEL_NAME)(VGAState *s1, uint8_t *d,
|
|
467 |
static void glue(vga_draw_line24_, PIXEL_NAME)(VGAState *s1, uint8_t *d, |
|
468 | 468 |
const uint8_t *s, int width) |
469 | 469 |
{ |
470 | 470 |
int w; |
... | ... | |
487 | 487 |
} while (--w != 0); |
488 | 488 |
} |
489 | 489 |
|
490 |
/*
|
|
490 |
/* |
|
491 | 491 |
* 32 bit color |
492 | 492 |
*/ |
493 |
static void glue(vga_draw_line32_, PIXEL_NAME)(VGAState *s1, uint8_t *d,
|
|
493 |
static void glue(vga_draw_line32_, PIXEL_NAME)(VGAState *s1, uint8_t *d, |
|
494 | 494 |
const uint8_t *s, int width) |
495 | 495 |
{ |
496 | 496 |
#if DEPTH == 32 && defined(WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) && !defined(BGR_FORMAT) |
Also available in: Unified diff