diff options
Diffstat (limited to 'uisimulator/sdl/lcd-remote-bitmap.c')
-rw-r--r-- | uisimulator/sdl/lcd-remote-bitmap.c | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/uisimulator/sdl/lcd-remote-bitmap.c b/uisimulator/sdl/lcd-remote-bitmap.c index d165534e00..f5c2225ab2 100644 --- a/uisimulator/sdl/lcd-remote-bitmap.c +++ b/uisimulator/sdl/lcd-remote-bitmap.c | |||
@@ -22,20 +22,38 @@ | |||
22 | #include "uisdl.h" | 22 | #include "uisdl.h" |
23 | #include "lcd-sdl.h" | 23 | #include "lcd-sdl.h" |
24 | #include "lcd-remote-bitmap.h" | 24 | #include "lcd-remote-bitmap.h" |
25 | #include "misc.h" | ||
25 | 26 | ||
26 | SDL_Surface *remote_surface; | 27 | SDL_Surface *remote_surface; |
27 | 28 | ||
28 | SDL_Color remote_color_zero = {UI_REMOTE_BGCOLOR, 0}; | 29 | SDL_Color remote_bl_color_dark = {RED_CMP(LCD_REMOTE_BL_DARKCOLOR), |
29 | SDL_Color remote_backlight_color_zero = {UI_REMOTE_BGCOLORLIGHT, 0}; | 30 | GREEN_CMP(LCD_REMOTE_BL_DARKCOLOR), |
30 | SDL_Color remote_color_max = {0, 0, 0, 0}; | 31 | BLUE_CMP(LCD_REMOTE_BL_DARKCOLOR), 0}; |
32 | SDL_Color remote_bl_color_bright = {RED_CMP(LCD_REMOTE_BL_BRIGHTCOLOR), | ||
33 | GREEN_CMP(LCD_REMOTE_BL_BRIGHTCOLOR), | ||
34 | BLUE_CMP(LCD_REMOTE_BL_BRIGHTCOLOR), 0}; | ||
35 | SDL_Color remote_color_dark = {RED_CMP(LCD_REMOTE_DARKCOLOR), | ||
36 | GREEN_CMP(LCD_REMOTE_DARKCOLOR), | ||
37 | BLUE_CMP(LCD_REMOTE_DARKCOLOR), 0}; | ||
38 | SDL_Color remote_color_bright = {RED_CMP(LCD_REMOTE_BRIGHTCOLOR), | ||
39 | GREEN_CMP(LCD_REMOTE_BRIGHTCOLOR), | ||
40 | BLUE_CMP(LCD_REMOTE_BRIGHTCOLOR), 0}; | ||
31 | 41 | ||
32 | static unsigned long get_lcd_remote_pixel(int x, int y) { | 42 | #define GRADIENT_MAX 128 |
43 | |||
44 | #if LCD_REMOTE_DEPTH == 2 | ||
45 | /* Only defined for positive, non-split LCD for now */ | ||
46 | static const unsigned char colorindex[4] = {128, 85, 43, 0}; | ||
47 | #endif | ||
48 | |||
49 | static unsigned long get_lcd_remote_pixel(int x, int y) | ||
50 | { | ||
33 | #if LCD_REMOTE_DEPTH == 1 | 51 | #if LCD_REMOTE_DEPTH == 1 |
34 | return (lcd_remote_framebuffer[y/8][x] >> (y & 7)) & 1; | 52 | return lcd_remote_framebuffer[y/8][x] & (1 << (y & 7)) ? 0 : GRADIENT_MAX; |
35 | #elif LCD_REMOTE_DEPTH == 2 | 53 | #elif LCD_REMOTE_DEPTH == 2 |
36 | #if LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED | 54 | #if LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED |
37 | unsigned bits = (lcd_remote_framebuffer[y/8][x] >> (y & 7)) & 0x0101; | 55 | unsigned bits = (lcd_remote_framebuffer[y/8][x] >> (y & 7)) & 0x0101; |
38 | return (bits | (bits >> 7)) & 3; | 56 | return colorindex[(bits | (bits >> 7)) & 3]; |
39 | #endif | 57 | #endif |
40 | #endif | 58 | #endif |
41 | } | 59 | } |
@@ -57,11 +75,11 @@ void lcd_remote_update_rect(int x_start, int y_start, int width, int height) | |||
57 | void sim_remote_backlight(int value) | 75 | void sim_remote_backlight(int value) |
58 | { | 76 | { |
59 | if (value > 0) { | 77 | if (value > 0) { |
60 | sdl_set_gradient(remote_surface, &remote_backlight_color_zero, | 78 | sdl_set_gradient(remote_surface, &remote_bl_color_dark, |
61 | &remote_color_max, 0, (1<<LCD_REMOTE_DEPTH)); | 79 | &remote_bl_color_bright, 0, GRADIENT_MAX+1); |
62 | } else { | 80 | } else { |
63 | sdl_set_gradient(remote_surface, &remote_color_zero, &remote_color_max, | 81 | sdl_set_gradient(remote_surface, &remote_color_dark, |
64 | 0, (1<<LCD_REMOTE_DEPTH)); | 82 | &remote_color_bright, 0, GRADIENT_MAX+1); |
65 | } | 83 | } |
66 | 84 | ||
67 | sdl_gui_update(remote_surface, 0, 0, LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT, | 85 | sdl_gui_update(remote_surface, 0, 0, LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT, |
@@ -74,10 +92,11 @@ void sim_remote_backlight(int value) | |||
74 | void sim_lcd_remote_init(void) | 92 | void sim_lcd_remote_init(void) |
75 | { | 93 | { |
76 | remote_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, | 94 | remote_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, |
77 | LCD_REMOTE_WIDTH * display_zoom, LCD_REMOTE_HEIGHT * display_zoom, | 95 | LCD_REMOTE_WIDTH * display_zoom, |
78 | 8, 0, 0, 0, 0); | 96 | LCD_REMOTE_HEIGHT * display_zoom, |
97 | 8, 0, 0, 0, 0); | ||
79 | 98 | ||
80 | sdl_set_gradient(remote_surface, &remote_backlight_color_zero, | 99 | sdl_set_gradient(remote_surface, &remote_bl_color_dark, |
81 | &remote_color_max, 0, (1<<LCD_REMOTE_DEPTH)); | 100 | &remote_bl_color_bright, 0, GRADIENT_MAX+1); |
82 | } | 101 | } |
83 | 102 | ||