blob: 1ccf6e8dfe95958573a9f25987e9343a41107a5f [file] [log] [blame]
balrog64b40bc2008-11-04 09:04:41 +00001/*
2 * Toshiba TC6393XB I/O Controller.
3 * Found in Sharp Zaurus SL-6000 (tosa) or some
4 * Toshiba e-Series PDAs.
5 *
6 * FB support code. Based on G364 fb emulator
7 *
8 * Copyright (c) 2007 Hervé Poussineau
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
aurel32fad6cb12009-01-04 22:05:52 +000020 * You should have received a copy of the GNU General Public License along
Blue Swirl8167ee82009-07-16 20:47:01 +000021 * with this program; if not, see <http://www.gnu.org/licenses/>.
balrog64b40bc2008-11-04 09:04:41 +000022 */
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
Paul Brookbc24a222009-05-10 01:44:56 +010038static void glue(tc6393xb_draw_graphic, BITS)(TC6393xbState *s)
balrog64b40bc2008-11-04 09:04:41 +000039{
40 int i;
balrog64b40bc2008-11-04 09:04:41 +000041 uint16_t *data_buffer;
42 uint8_t *data_display;
43
pbrook44654492009-04-10 00:26:15 +000044 data_buffer = s->vram_ptr;
aliguori0e1f5a02008-11-24 19:29:13 +000045 data_display = ds_get_data(s->ds);
balrog64b40bc2008-11-04 09:04:41 +000046 for(i = 0; i < s->scr_height; i++) {
47#if (BITS == 16)
48 memcpy(data_display, data_buffer, s->scr_width * 2);
49 data_buffer += s->scr_width;
aliguori0e1f5a02008-11-24 19:29:13 +000050 data_display += ds_get_linesize(s->ds);
balrog64b40bc2008-11-04 09:04:41 +000051#else
52 int j;
53 for (j = 0; j < s->scr_width; j++, data_display += BITS / 8, data_buffer++) {
54 uint16_t color = *data_buffer;
55 uint32_t dest_color = glue(rgb_to_pixel, BITS)(
56 ((color & 0xf800) * 0x108) >> 11,
57 ((color & 0x7e0) * 0x41) >> 9,
58 ((color & 0x1f) * 0x21) >> 2
59 );
60 SET_PIXEL(data_display, dest_color);
61 }
62#endif
63 }
64}
65
66#undef BITS
67#undef SET_PIXEL