diff options
Diffstat (limited to 'uisimulator/sdl/lcd-remote-bitmap.c')
-rw-r--r-- | uisimulator/sdl/lcd-remote-bitmap.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/uisimulator/sdl/lcd-remote-bitmap.c b/uisimulator/sdl/lcd-remote-bitmap.c new file mode 100644 index 0000000000..21fa0d2ab4 --- /dev/null +++ b/uisimulator/sdl/lcd-remote-bitmap.c | |||
@@ -0,0 +1,81 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 Dan Everton | ||
11 | * | ||
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. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "uisdl.h" | ||
21 | #include "lcd-sdl.h" | ||
22 | #include "lcd-remote-bitmap.h" | ||
23 | |||
24 | SDL_Surface *remote_surface; | ||
25 | |||
26 | SDL_Color remote_color_zero = {UI_REMOTE_BGCOLOR, 0}; | ||
27 | SDL_Color remote_backlight_color_zero = {UI_REMOTE_BGCOLORLIGHT, 0}; | ||
28 | SDL_Color remote_color_max = {0, 0, 0, 0}; | ||
29 | |||
30 | static unsigned long get_lcd_remote_pixel(int x, int y) { | ||
31 | #if LCD_REMOTE_DEPTH == 1 | ||
32 | return (lcd_remote_framebuffer[y/8][x] >> (y & 7)) & 1; | ||
33 | #elif LCD_REMOTE_DEPTH == 2 | ||
34 | #if LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED | ||
35 | unsigned bits = (lcd_remote_framebuffer[y/8][x] >> (y & 7)) & 0x0101; | ||
36 | return (bits | (bits >> 7)) & 3; | ||
37 | #endif | ||
38 | #endif | ||
39 | } | ||
40 | |||
41 | void lcd_remote_update (void) | ||
42 | { | ||
43 | lcd_remote_update_rect(0, 0, LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT); | ||
44 | } | ||
45 | |||
46 | void lcd_remote_update_rect(int x_start, int y_start, int width, int height) | ||
47 | { | ||
48 | sdl_update_rect(remote_surface, x_start, y_start, width, height, | ||
49 | LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT, get_lcd_remote_pixel); | ||
50 | sdl_gui_update(remote_surface, x_start, y_start, width, height, | ||
51 | LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT, background ? UI_REMOTE_POSX : 0, | ||
52 | background ? UI_REMOTE_POSY : LCD_HEIGHT); | ||
53 | } | ||
54 | |||
55 | void sim_remote_backlight(int value) | ||
56 | { | ||
57 | if (value > 0) { | ||
58 | sdl_set_gradient(remote_surface, &remote_backlight_color_zero, | ||
59 | &remote_color_max, 0, (1<<LCD_REMOTE_DEPTH)); | ||
60 | } else { | ||
61 | sdl_set_gradient(remote_surface, &remote_color_zero, &remote_color_max, | ||
62 | 0, (1<<LCD_REMOTE_DEPTH)); | ||
63 | } | ||
64 | |||
65 | sdl_gui_update(remote_surface, 0, 0, LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT, | ||
66 | LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT, | ||
67 | background ? UI_REMOTE_POSX : 0, | ||
68 | background? UI_REMOTE_POSY : LCD_HEIGHT); | ||
69 | } | ||
70 | |||
71 | /* initialise simulator lcd remote driver */ | ||
72 | void sim_lcd_remote_init(void) | ||
73 | { | ||
74 | remote_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, | ||
75 | LCD_REMOTE_WIDTH * display_zoom, LCD_REMOTE_HEIGHT * display_zoom, | ||
76 | 8, 0, 0, 0, 0); | ||
77 | |||
78 | sdl_set_gradient(remote_surface, &remote_backlight_color_zero, | ||
79 | &remote_color_max, 0, (1<<LCD_REMOTE_DEPTH)); | ||
80 | } | ||
81 | |||