00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #if BITS == 8
00026 # define SET_PIXEL(addr, color) *(uint8_t*)addr = color;
00027 #elif BITS == 15 || BITS == 16
00028 # define SET_PIXEL(addr, color) *(uint16_t*)addr = color;
00029 #elif BITS == 24
00030 # define SET_PIXEL(addr, color) \
00031 addr[0] = color; addr[1] = (color) >> 8; addr[2] = (color) >> 16;
00032 #elif BITS == 32
00033 # define SET_PIXEL(addr, color) *(uint32_t*)addr = color;
00034 #else
00035 # error unknown bit depth
00036 #endif
00037
00038
00039 static void glue(tc6393xb_draw_graphic, BITS)(struct tc6393xb_s *s)
00040 {
00041 int i;
00042 int w_display;
00043 uint16_t *data_buffer;
00044 uint8_t *data_display;
00045
00046 data_buffer = (uint16_t*)(phys_ram_base + s->vram_addr);
00047 w_display = s->scr_width * BITS / 8;
00048 data_display = ds_get_data(s->ds);
00049 for(i = 0; i < s->scr_height; i++) {
00050 #if (BITS == 16)
00051 memcpy(data_display, data_buffer, s->scr_width * 2);
00052 data_buffer += s->scr_width;
00053 data_display += ds_get_linesize(s->ds);
00054 #else
00055 int j;
00056 for (j = 0; j < s->scr_width; j++, data_display += BITS / 8, data_buffer++) {
00057 uint16_t color = *data_buffer;
00058 uint32_t dest_color = glue(rgb_to_pixel, BITS)(
00059 ((color & 0xf800) * 0x108) >> 11,
00060 ((color & 0x7e0) * 0x41) >> 9,
00061 ((color & 0x1f) * 0x21) >> 2
00062 );
00063 SET_PIXEL(data_display, dest_color);
00064 }
00065 #endif
00066 }
00067 }
00068
00069 #undef BITS
00070 #undef SET_PIXEL