symbian-qemu-0.9.1-12/qemu-symbian-svp/hw/tc6393xb_template.h
changeset 1 2fb8b9db1c86
equal deleted inserted replaced
0:ffa851df0825 1:2fb8b9db1c86
       
     1 /*
       
     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  *
       
    20  * You should have received a copy of the GNU General Public License
       
    21  * along with this program; if not, write to the Free Software
       
    22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
       
    23  * MA 02111-1307 USA
       
    24  */
       
    25 
       
    26 #if BITS == 8
       
    27 # define SET_PIXEL(addr, color)	*(uint8_t*)addr = color;
       
    28 #elif BITS == 15 || BITS == 16
       
    29 # define SET_PIXEL(addr, color)	*(uint16_t*)addr = color;
       
    30 #elif BITS == 24
       
    31 # define SET_PIXEL(addr, color)	\
       
    32     addr[0] = color; addr[1] = (color) >> 8; addr[2] = (color) >> 16;
       
    33 #elif BITS == 32
       
    34 # define SET_PIXEL(addr, color)	*(uint32_t*)addr = color;
       
    35 #else
       
    36 # error unknown bit depth
       
    37 #endif
       
    38 
       
    39 
       
    40 static void glue(tc6393xb_draw_graphic, BITS)(struct tc6393xb_s *s)
       
    41 {
       
    42     int i;
       
    43     int w_display;
       
    44     uint16_t *data_buffer;
       
    45     uint8_t *data_display;
       
    46 
       
    47     /* FIXME: This is broken if it spans multiple regions.  */
       
    48     data_buffer = (uint16_t*)host_ram_addr(s->vram_addr);
       
    49     w_display = s->scr_width * BITS / 8;
       
    50     data_display = ds_get_data(s->ds);
       
    51     for(i = 0; i < s->scr_height; i++) {
       
    52 #if (BITS == 16)
       
    53         memcpy(data_display, data_buffer, s->scr_width * 2);
       
    54         data_buffer += s->scr_width;
       
    55         data_display += ds_get_linesize(s->ds);
       
    56 #else
       
    57         int j;
       
    58         for (j = 0; j < s->scr_width; j++, data_display += BITS / 8, data_buffer++) {
       
    59             uint16_t color = *data_buffer;
       
    60             uint32_t dest_color = glue(rgb_to_pixel, BITS)(
       
    61                            ((color & 0xf800) * 0x108) >> 11,
       
    62                            ((color & 0x7e0) * 0x41) >> 9,
       
    63                            ((color & 0x1f) * 0x21) >> 2
       
    64                            );
       
    65             SET_PIXEL(data_display, dest_color);
       
    66         }
       
    67 #endif
       
    68     }
       
    69 }
       
    70 
       
    71 #undef BITS
       
    72 #undef SET_PIXEL