1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#if BITS == 8
25# define SET_PIXEL(addr, color) *(uint8_t*)addr = color;
26#elif BITS == 15 || BITS == 16
27# define SET_PIXEL(addr, color) *(uint16_t*)addr = color;
28#elif BITS == 24
29# define SET_PIXEL(addr, color) \
30 addr[0] = color; addr[1] = (color) >> 8; addr[2] = (color) >> 16;
31#elif BITS == 32
32# define SET_PIXEL(addr, color) *(uint32_t*)addr = color;
33#else
34# error unknown bit depth
35#endif
36
37
38static void glue(tc6393xb_draw_graphic, BITS)(TC6393xbState *s)
39{
40 DisplaySurface *surface = qemu_console_surface(s->con);
41 int i;
42 uint16_t *data_buffer;
43 uint8_t *data_display;
44
45 data_buffer = s->vram_ptr;
46 data_display = surface_data(surface);
47 for(i = 0; i < s->scr_height; i++) {
48#if (BITS == 16)
49 memcpy(data_display, data_buffer, s->scr_width * 2);
50 data_buffer += s->scr_width;
51 data_display += surface_stride(surface);
52#else
53 int j;
54 for (j = 0; j < s->scr_width; j++, data_display += BITS / 8, data_buffer++) {
55 uint16_t color = *data_buffer;
56 uint32_t dest_color = glue(rgb_to_pixel, BITS)(
57 ((color & 0xf800) * 0x108) >> 11,
58 ((color & 0x7e0) * 0x41) >> 9,
59 ((color & 0x1f) * 0x21) >> 2
60 );
61 SET_PIXEL(data_display, dest_color);
62 }
63#endif
64 }
65}
66
67#undef BITS
68#undef SET_PIXEL
69