1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 Dan Everton
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
24 SDL_Surface
* lcd_surface
;
25 int lcd_backlight_val
;
29 SDL_Color lcd_backlight_color_zero
= {UI_LCD_BGCOLORLIGHT
, 0};
31 SDL_Color lcd_color_zero
= {UI_LCD_BGCOLOR
, 0};
32 SDL_Color lcd_color_max
= {0, 0, 0, 0};
36 int lcd_ex_shades
= 0;
37 unsigned long (*lcd_ex_getpixel
)(int, int) = NULL
;
40 static unsigned long get_lcd_pixel(int x
, int y
)
43 return ((lcd_framebuffer
[y
/8][x
] >> (y
& 7)) & 1);
45 #if LCD_PIXELFORMAT == HORIZONTAL_PACKING
46 return ((lcd_framebuffer
[y
][x
/4] >> (2 * (~x
& 3))) & 3);
48 return ((lcd_framebuffer
[y
/4][x
] >> (2 * (y
& 3))) & 3);
51 #if LCD_PIXELFORMAT == RGB565SWAPPED
52 unsigned bits
= lcd_framebuffer
[y
][x
];
53 return (bits
>> 8) | (bits
<< 8);
55 return lcd_framebuffer
[y
][x
];
62 /* update a full screen rect */
63 lcd_update_rect(0, 0, LCD_WIDTH
, LCD_HEIGHT
);
66 void lcd_update_rect(int x_start
, int y_start
, int width
, int height
)
68 sdl_update_rect(lcd_surface
, x_start
, y_start
, width
, height
, LCD_WIDTH
,
69 LCD_HEIGHT
, get_lcd_pixel
);
70 sdl_gui_update(lcd_surface
, x_start
, y_start
, width
, height
, LCD_WIDTH
,
71 LCD_HEIGHT
, background
? UI_LCD_POSX
: 0, background
? UI_LCD_POSY
: 0);
75 void sim_backlight(int value
)
77 lcd_backlight_val
= value
;
81 sdl_set_gradient(lcd_surface
, &lcd_backlight_color_zero
,
82 &lcd_color_max
, 0, (1<<LCD_DEPTH
));
84 sdl_set_gradient(lcd_surface
, &lcd_color_zero
, &lcd_color_max
,
90 sdl_set_gradient(lcd_surface
, &lcd_color_max
,
91 &lcd_backlight_color_zero
, (1<<LCD_DEPTH
),
94 sdl_set_gradient(lcd_surface
, &lcd_color_max
, &lcd_color_zero
,
95 (1<<LCD_DEPTH
), lcd_ex_shades
);
100 sdl_gui_update(lcd_surface
, 0, 0, LCD_WIDTH
, LCD_HEIGHT
, LCD_WIDTH
,
101 LCD_HEIGHT
, background
? UI_LCD_POSX
: 0, background
? UI_LCD_POSY
: 0);
107 /* initialise simulator lcd driver */
108 void sim_lcd_init(void)
111 lcd_surface
= SDL_CreateRGBSurface(SDL_SWSURFACE
, LCD_WIDTH
* display_zoom
,
112 LCD_HEIGHT
* display_zoom
, LCD_DEPTH
, 0, 0, 0, 0);
114 lcd_surface
= SDL_CreateRGBSurface(SDL_SWSURFACE
, LCD_WIDTH
* display_zoom
,
115 LCD_HEIGHT
* display_zoom
, 8, 0, 0, 0, 0);
119 #ifdef HAVE_BACKLIGHT
120 sdl_set_gradient(lcd_surface
, &lcd_backlight_color_zero
, &lcd_color_max
,
123 sdl_set_gradient(lcd_surface
, &lcd_color_zero
, &lcd_color_max
, 0,
130 void sim_lcd_ex_init(int shades
, unsigned long (*getpixel
)(int, int))
132 lcd_ex_shades
= shades
;
133 lcd_ex_getpixel
= getpixel
;
135 #ifdef HAVE_BACKLIGHT
136 if (lcd_backlight_val
> 0) {
137 sdl_set_gradient(lcd_surface
, &lcd_color_max
,
138 &lcd_backlight_color_zero
, (1<<LCD_DEPTH
),
144 sdl_set_gradient(lcd_surface
, &lcd_color_max
, &lcd_color_zero
,
145 (1<<LCD_DEPTH
), shades
);
150 void sim_lcd_ex_update_rect(int x_start
, int y_start
, int width
, int height
)
152 if (lcd_ex_getpixel
) {
153 sdl_update_rect(lcd_surface
, x_start
, y_start
, width
, height
,
154 LCD_WIDTH
, LCD_HEIGHT
, lcd_ex_getpixel
);
155 sdl_gui_update(lcd_surface
, x_start
, y_start
, width
, height
, LCD_WIDTH
,
156 LCD_HEIGHT
, background
? UI_LCD_POSX
: 0,
157 background
? UI_LCD_POSY
: 0);