Statistics
| Branch: | Revision:

root / hw / tc6393xb_template.h @ 49a2942d

History | View | Annotate | Download (2.1 kB)

1 64b40bc5 balrog
/*
2 64b40bc5 balrog
 * Toshiba TC6393XB I/O Controller.
3 64b40bc5 balrog
 * Found in Sharp Zaurus SL-6000 (tosa) or some
4 64b40bc5 balrog
 * Toshiba e-Series PDAs.
5 64b40bc5 balrog
 *
6 64b40bc5 balrog
 * FB support code. Based on G364 fb emulator
7 64b40bc5 balrog
 *
8 64b40bc5 balrog
 * Copyright (c) 2007 Herv? Poussineau
9 64b40bc5 balrog
 *
10 64b40bc5 balrog
 * This program is free software; you can redistribute it and/or
11 64b40bc5 balrog
 * modify it under the terms of the GNU General Public License as
12 64b40bc5 balrog
 * published by the Free Software Foundation; either version 2 of
13 64b40bc5 balrog
 * the License, or (at your option) any later version.
14 64b40bc5 balrog
 *
15 64b40bc5 balrog
 * This program is distributed in the hope that it will be useful,
16 64b40bc5 balrog
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 64b40bc5 balrog
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 64b40bc5 balrog
 * GNU General Public License for more details.
19 64b40bc5 balrog
 *
20 fad6cb1a aurel32
 * You should have received a copy of the GNU General Public License along
21 8167ee88 Blue Swirl
 * with this program; if not, see <http://www.gnu.org/licenses/>.
22 64b40bc5 balrog
 */
23 64b40bc5 balrog
24 64b40bc5 balrog
#if BITS == 8
25 64b40bc5 balrog
# define SET_PIXEL(addr, color)        *(uint8_t*)addr = color;
26 64b40bc5 balrog
#elif BITS == 15 || BITS == 16
27 64b40bc5 balrog
# define SET_PIXEL(addr, color)        *(uint16_t*)addr = color;
28 64b40bc5 balrog
#elif BITS == 24
29 64b40bc5 balrog
# define SET_PIXEL(addr, color)        \
30 64b40bc5 balrog
    addr[0] = color; addr[1] = (color) >> 8; addr[2] = (color) >> 16;
31 64b40bc5 balrog
#elif BITS == 32
32 64b40bc5 balrog
# define SET_PIXEL(addr, color)        *(uint32_t*)addr = color;
33 64b40bc5 balrog
#else
34 64b40bc5 balrog
# error unknown bit depth
35 64b40bc5 balrog
#endif
36 64b40bc5 balrog
37 64b40bc5 balrog
38 bc24a225 Paul Brook
static void glue(tc6393xb_draw_graphic, BITS)(TC6393xbState *s)
39 64b40bc5 balrog
{
40 64b40bc5 balrog
    int i;
41 64b40bc5 balrog
    uint16_t *data_buffer;
42 64b40bc5 balrog
    uint8_t *data_display;
43 64b40bc5 balrog
44 44654490 pbrook
    data_buffer = s->vram_ptr;
45 0e1f5a0c aliguori
    data_display = ds_get_data(s->ds);
46 64b40bc5 balrog
    for(i = 0; i < s->scr_height; i++) {
47 64b40bc5 balrog
#if (BITS == 16)
48 64b40bc5 balrog
        memcpy(data_display, data_buffer, s->scr_width * 2);
49 64b40bc5 balrog
        data_buffer += s->scr_width;
50 0e1f5a0c aliguori
        data_display += ds_get_linesize(s->ds);
51 64b40bc5 balrog
#else
52 64b40bc5 balrog
        int j;
53 64b40bc5 balrog
        for (j = 0; j < s->scr_width; j++, data_display += BITS / 8, data_buffer++) {
54 64b40bc5 balrog
            uint16_t color = *data_buffer;
55 64b40bc5 balrog
            uint32_t dest_color = glue(rgb_to_pixel, BITS)(
56 64b40bc5 balrog
                           ((color & 0xf800) * 0x108) >> 11,
57 64b40bc5 balrog
                           ((color & 0x7e0) * 0x41) >> 9,
58 64b40bc5 balrog
                           ((color & 0x1f) * 0x21) >> 2
59 64b40bc5 balrog
                           );
60 64b40bc5 balrog
            SET_PIXEL(data_display, dest_color);
61 64b40bc5 balrog
        }
62 64b40bc5 balrog
#endif
63 64b40bc5 balrog
    }
64 64b40bc5 balrog
}
65 64b40bc5 balrog
66 64b40bc5 balrog
#undef BITS
67 64b40bc5 balrog
#undef SET_PIXEL