diff options
author | Rafaël Carré <rafael.carre@gmail.com> | 2008-12-04 23:24:45 +0000 |
---|---|---|
committer | Rafaël Carré <rafael.carre@gmail.com> | 2008-12-04 23:24:45 +0000 |
commit | bba06cfd551c7d34308ef7ea52455f07a5e2cfee (patch) | |
tree | 47a70eb6c2e63c71345dcf700bc0f88d4c33ac09 | |
parent | e3a970f4eb3068055f806a3194883eb157f8b1ed (diff) | |
download | rockbox-bba06cfd551c7d34308ef7ea52455f07a5e2cfee.tar.gz rockbox-bba06cfd551c7d34308ef7ea52455f07a5e2cfee.zip |
Sansa Clip Simulator: emulate the real screen at the price of some CPU (FS#9521)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19347 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | uisimulator/sdl/lcd-bitmap.c | 104 | ||||
-rw-r--r-- | uisimulator/sdl/lcd-sdl.c | 82 | ||||
-rw-r--r-- | uisimulator/sdl/lcd-sdl.h | 13 | ||||
-rw-r--r-- | uisimulator/sdl/uisdl.c | 6 | ||||
-rw-r--r-- | uisimulator/sdl/uisdl.h | 7 |
5 files changed, 179 insertions, 33 deletions
diff --git a/uisimulator/sdl/lcd-bitmap.c b/uisimulator/sdl/lcd-bitmap.c index 92480396bc..b9f5732dc7 100644 --- a/uisimulator/sdl/lcd-bitmap.c +++ b/uisimulator/sdl/lcd-bitmap.c | |||
@@ -24,15 +24,24 @@ | |||
24 | #include "lcd-sdl.h" | 24 | #include "lcd-sdl.h" |
25 | 25 | ||
26 | SDL_Surface* lcd_surface; | 26 | SDL_Surface* lcd_surface; |
27 | #ifdef UI_LCD_SPLIT | ||
28 | SDL_Surface* lcd_real_surface; /* the surface which represents the real screen */ | ||
29 | #endif | ||
27 | int lcd_backlight_val; | 30 | int lcd_backlight_val; |
28 | 31 | ||
29 | #if LCD_DEPTH <= 8 | 32 | #if LCD_DEPTH <= 8 |
30 | #ifdef HAVE_BACKLIGHT | 33 | #ifdef HAVE_BACKLIGHT |
31 | SDL_Color lcd_backlight_color_zero = {UI_LCD_BGCOLORLIGHT, 0}; | 34 | SDL_Color lcd_backlight_color_zero = {UI_LCD_BGCOLORLIGHT, 0}; |
32 | SDL_Color lcd_backlight_color_max = {UI_LCD_FGCOLORLIGHT, 0}; | 35 | SDL_Color lcd_backlight_color_max = {UI_LCD_FGCOLORLIGHT, 0}; |
36 | #ifdef UI_LCD_SPLIT | ||
37 | SDL_Color lcd_backlight_color_split= {UI_LCD_SPLIT_FGCOLORLIGHT, 0}; | ||
38 | #endif | ||
33 | #endif | 39 | #endif |
34 | SDL_Color lcd_color_zero = {UI_LCD_BGCOLOR, 0}; | 40 | SDL_Color lcd_color_zero = {UI_LCD_BGCOLOR, 0}; |
35 | SDL_Color lcd_color_max = {UI_LCD_FGCOLOR, 0}; | 41 | SDL_Color lcd_color_max = {UI_LCD_FGCOLOR, 0}; |
42 | #ifdef UI_LCD_SPLIT | ||
43 | SDL_Color lcd_color_split= {UI_LCD_SPLIT_FGCOLOR, 0}; | ||
44 | #endif | ||
36 | #endif | 45 | #endif |
37 | 46 | ||
38 | #if LCD_DEPTH < 8 | 47 | #if LCD_DEPTH < 8 |
@@ -73,8 +82,9 @@ void lcd_update_rect(int x_start, int y_start, int width, int height) | |||
73 | { | 82 | { |
74 | sdl_update_rect(lcd_surface, x_start, y_start, width, height, LCD_WIDTH, | 83 | sdl_update_rect(lcd_surface, x_start, y_start, width, height, LCD_WIDTH, |
75 | LCD_HEIGHT, get_lcd_pixel); | 84 | LCD_HEIGHT, get_lcd_pixel); |
76 | sdl_gui_update(lcd_surface, x_start, y_start, width, height, LCD_WIDTH, | 85 | sdl_gui_update(lcd_surface, IFSPLIT(lcd_real_surface,) x_start, y_start, |
77 | LCD_HEIGHT, background ? UI_LCD_POSX : 0, background? UI_LCD_POSY : 0); | 86 | width, height, LCD_WIDTH, LCD_HEIGHT, |
87 | background ? UI_LCD_POSX : 0, background? UI_LCD_POSY : 0); | ||
78 | } | 88 | } |
79 | 89 | ||
80 | #ifdef HAVE_BACKLIGHT | 90 | #ifdef HAVE_BACKLIGHT |
@@ -84,27 +94,51 @@ void sim_backlight(int value) | |||
84 | 94 | ||
85 | #if LCD_DEPTH <= 8 | 95 | #if LCD_DEPTH <= 8 |
86 | if (value > 0) { | 96 | if (value > 0) { |
97 | #ifdef UI_LCD_SPLIT | ||
98 | sdl_set_gradient(lcd_real_surface, &lcd_backlight_color_zero, | ||
99 | &lcd_backlight_color_max, &lcd_backlight_color_zero, | ||
100 | &lcd_backlight_color_split, 0, (1<<LCD_DEPTH)); | ||
101 | #else | ||
87 | sdl_set_gradient(lcd_surface, &lcd_backlight_color_zero, | 102 | sdl_set_gradient(lcd_surface, &lcd_backlight_color_zero, |
88 | &lcd_backlight_color_max, 0, (1<<LCD_DEPTH)); | 103 | &lcd_backlight_color_max, 0, (1<<LCD_DEPTH)); |
104 | #endif | ||
89 | } else { | 105 | } else { |
90 | sdl_set_gradient(lcd_surface, &lcd_color_zero, &lcd_color_max, | 106 | #ifdef UI_LCD_SPLIT |
91 | 0, (1<<LCD_DEPTH)); | 107 | sdl_set_gradient(lcd_real_surface, &lcd_color_zero, &lcd_color_max, |
108 | &lcd_color_zero, &lcd_color_split, 0, (1<<LCD_DEPTH)); | ||
109 | #else | ||
110 | sdl_set_gradient(lcd_surface, &lcd_color_zero, &lcd_color_max, 0, | ||
111 | (1<<LCD_DEPTH)); | ||
112 | #endif | ||
92 | } | 113 | } |
93 | #if LCD_DEPTH < 8 | 114 | #if LCD_DEPTH < 8 |
94 | if (lcd_ex_shades) { | 115 | if (lcd_ex_shades) { |
95 | if (value > 0) { | 116 | if (value > 0) { |
117 | #ifdef UI_LCD_SPLIT | ||
118 | sdl_set_gradient(lcd_real_surface, &lcd_backlight_color_max, | ||
119 | &lcd_backlight_color_zero, &lcd_backlight_color_split, | ||
120 | &lcd_backlight_color_zero, | ||
121 | (1<<LCD_DEPTH), lcd_ex_shades); | ||
122 | #else | ||
96 | sdl_set_gradient(lcd_surface, &lcd_backlight_color_max, | 123 | sdl_set_gradient(lcd_surface, &lcd_backlight_color_max, |
97 | &lcd_backlight_color_zero, (1<<LCD_DEPTH), | 124 | &lcd_backlight_color_zero, (1<<LCD_DEPTH), lcd_ex_shades); |
98 | lcd_ex_shades); | 125 | #endif |
99 | } else { | 126 | } else { |
127 | #ifdef UI_LCD_SPLIT | ||
128 | sdl_set_gradient(lcd_real_surface, &lcd_color_max, &lcd_color_zero, | ||
129 | &lcd_color_split, &lcd_color_zero, (1<<LCD_DEPTH), | ||
130 | lcd_ex_shades); | ||
131 | #else | ||
100 | sdl_set_gradient(lcd_surface, &lcd_color_max, &lcd_color_zero, | 132 | sdl_set_gradient(lcd_surface, &lcd_color_max, &lcd_color_zero, |
101 | (1<<LCD_DEPTH), lcd_ex_shades); | 133 | (1<<LCD_DEPTH), lcd_ex_shades); |
134 | #endif | ||
102 | } | 135 | } |
103 | } | 136 | } |
104 | #endif | 137 | #endif |
105 | 138 | ||
106 | sdl_gui_update(lcd_surface, 0, 0, LCD_WIDTH, LCD_HEIGHT, LCD_WIDTH, | 139 | sdl_gui_update(lcd_surface, IFSPLIT(lcd_real_surface,) 0, 0, LCD_WIDTH, |
107 | LCD_HEIGHT, background ? UI_LCD_POSX : 0, background? UI_LCD_POSY : 0); | 140 | LCD_HEIGHT, LCD_WIDTH, LCD_HEIGHT, |
141 | background ? UI_LCD_POSX : 0, background? UI_LCD_POSY : 0); | ||
108 | 142 | ||
109 | #endif | 143 | #endif |
110 | } | 144 | } |
@@ -119,15 +153,26 @@ void sim_lcd_init(void) | |||
119 | #else | 153 | #else |
120 | lcd_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, LCD_WIDTH * display_zoom, | 154 | lcd_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, LCD_WIDTH * display_zoom, |
121 | LCD_HEIGHT * display_zoom, 8, 0, 0, 0, 0); | 155 | LCD_HEIGHT * display_zoom, 8, 0, 0, 0, 0); |
156 | #ifdef UI_LCD_SPLIT | ||
157 | lcd_real_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, | ||
158 | LCD_WIDTH * display_zoom, | ||
159 | (LCD_HEIGHT+UI_LCD_SPLIT_BLACK_LINES) * display_zoom, 8, 0, 0, 0, 0); | ||
160 | #endif | ||
122 | #endif | 161 | #endif |
123 | 162 | ||
124 | #if LCD_DEPTH <= 8 | 163 | #if LCD_DEPTH <= 8 |
125 | #ifdef HAVE_BACKLIGHT | 164 | #ifdef HAVE_BACKLIGHT |
126 | sdl_set_gradient(lcd_surface, &lcd_backlight_color_zero, &lcd_color_max, | 165 | #ifdef UI_LCD_SPLIT |
127 | 0, (1<<LCD_DEPTH)); | 166 | sdl_set_gradient(lcd_real_surface, &lcd_backlight_color_zero, |
167 | &lcd_color_max, &lcd_backlight_color_zero, | ||
168 | &lcd_color_split, 0, (1<<LCD_DEPTH)); | ||
169 | #else | ||
170 | sdl_set_gradient(lcd_surface, &lcd_backlight_color_zero, &lcd_color_max, 0, | ||
171 | (1<<LCD_DEPTH)); | ||
172 | #endif | ||
128 | #else | 173 | #else |
129 | sdl_set_gradient(lcd_surface, &lcd_color_zero, &lcd_color_max, 0, | 174 | sdl_set_gradient(lcd_surface, &lcd_color_zero, &lcd_color_max, 0, |
130 | (1<<LCD_DEPTH)); | 175 | (1<<LCD_DEPTH)); |
131 | #endif | 176 | #endif |
132 | #endif | 177 | #endif |
133 | } | 178 | } |
@@ -140,15 +185,25 @@ void sim_lcd_ex_init(int shades, unsigned long (*getpixel)(int, int)) | |||
140 | if (shades) { | 185 | if (shades) { |
141 | #ifdef HAVE_BACKLIGHT | 186 | #ifdef HAVE_BACKLIGHT |
142 | if (lcd_backlight_val > 0) { | 187 | if (lcd_backlight_val > 0) { |
188 | #ifdef UI_LCD_SPLIT | ||
189 | sdl_set_gradient(lcd_real_surface, &lcd_color_max, | ||
190 | &lcd_backlight_color_zero, &lcd_color_split, | ||
191 | &lcd_backlight_color_zero, (1<<LCD_DEPTH), shades); | ||
192 | #else | ||
143 | sdl_set_gradient(lcd_surface, &lcd_color_max, | 193 | sdl_set_gradient(lcd_surface, &lcd_color_max, |
144 | &lcd_backlight_color_zero, (1<<LCD_DEPTH), | 194 | &lcd_backlight_color_zero, (1<<LCD_DEPTH), shades); |
145 | shades); | 195 | #endif |
146 | } | 196 | } |
147 | else | 197 | else |
148 | #endif | 198 | #endif |
149 | { | 199 | { |
200 | #ifdef UI_LCD_SPLIT | ||
201 | sdl_set_gradient(lcd_real_surface, &lcd_color_max, &lcd_color_zero, | ||
202 | &lcd_color_split, &lcd_color_zero, (1<<LCD_DEPTH), shades); | ||
203 | #else | ||
150 | sdl_set_gradient(lcd_surface, &lcd_color_max, &lcd_color_zero, | 204 | sdl_set_gradient(lcd_surface, &lcd_color_max, &lcd_color_zero, |
151 | (1<<LCD_DEPTH), shades); | 205 | (1<<LCD_DEPTH), shades); |
206 | #endif | ||
152 | } | 207 | } |
153 | } | 208 | } |
154 | } | 209 | } |
@@ -158,8 +213,9 @@ void sim_lcd_ex_update_rect(int x_start, int y_start, int width, int height) | |||
158 | if (lcd_ex_getpixel) { | 213 | if (lcd_ex_getpixel) { |
159 | sdl_update_rect(lcd_surface, x_start, y_start, width, height, | 214 | sdl_update_rect(lcd_surface, x_start, y_start, width, height, |
160 | LCD_WIDTH, LCD_HEIGHT, lcd_ex_getpixel); | 215 | LCD_WIDTH, LCD_HEIGHT, lcd_ex_getpixel); |
161 | sdl_gui_update(lcd_surface, x_start, y_start, width, height, LCD_WIDTH, | 216 | sdl_gui_update(lcd_surface, IFSPLIT(lcd_real_surface,) x_start, y_start, |
162 | LCD_HEIGHT, background ? UI_LCD_POSX : 0, | 217 | width, height, LCD_WIDTH, LCD_HEIGHT, |
218 | background ? UI_LCD_POSX : 0, | ||
163 | background? UI_LCD_POSY : 0); | 219 | background? UI_LCD_POSY : 0); |
164 | } | 220 | } |
165 | } | 221 | } |
@@ -256,7 +312,7 @@ void lcd_blit_yuv(unsigned char * const src[3], | |||
256 | *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); | 312 | *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); |
257 | 313 | ||
258 | #if LCD_WIDTH >= LCD_HEIGHT | 314 | #if LCD_WIDTH >= LCD_HEIGHT |
259 | dst++; | 315 | dst++; |
260 | #else | 316 | #else |
261 | dst += LCD_WIDTH; | 317 | dst += LCD_WIDTH; |
262 | #endif | 318 | #endif |
@@ -276,7 +332,7 @@ void lcd_blit_yuv(unsigned char * const src[3], | |||
276 | *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); | 332 | *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); |
277 | 333 | ||
278 | #if LCD_WIDTH >= LCD_HEIGHT | 334 | #if LCD_WIDTH >= LCD_HEIGHT |
279 | dst++; | 335 | dst++; |
280 | #else | 336 | #else |
281 | dst += LCD_WIDTH; | 337 | dst += LCD_WIDTH; |
282 | #endif | 338 | #endif |
@@ -321,7 +377,7 @@ void lcd_blit_yuv(unsigned char * const src[3], | |||
321 | *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); | 377 | *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); |
322 | 378 | ||
323 | #if LCD_WIDTH >= LCD_HEIGHT | 379 | #if LCD_WIDTH >= LCD_HEIGHT |
324 | dst++; | 380 | dst++; |
325 | #else | 381 | #else |
326 | dst += LCD_WIDTH; | 382 | dst += LCD_WIDTH; |
327 | #endif | 383 | #endif |
@@ -341,7 +397,7 @@ void lcd_blit_yuv(unsigned char * const src[3], | |||
341 | *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); | 397 | *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); |
342 | 398 | ||
343 | #if LCD_WIDTH >= LCD_HEIGHT | 399 | #if LCD_WIDTH >= LCD_HEIGHT |
344 | dst++; | 400 | dst++; |
345 | #else | 401 | #else |
346 | dst += LCD_WIDTH; | 402 | dst += LCD_WIDTH; |
347 | #endif | 403 | #endif |
diff --git a/uisimulator/sdl/lcd-sdl.c b/uisimulator/sdl/lcd-sdl.c index 1014a371c0..a3dc87fed0 100644 --- a/uisimulator/sdl/lcd-sdl.c +++ b/uisimulator/sdl/lcd-sdl.c | |||
@@ -23,6 +23,9 @@ | |||
23 | #include "uisdl.h" | 23 | #include "uisdl.h" |
24 | 24 | ||
25 | int display_zoom = 1; | 25 | int display_zoom = 1; |
26 | #ifdef UI_LCD_SPLIT | ||
27 | static int gradient_steps = 0; | ||
28 | #endif | ||
26 | 29 | ||
27 | void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width, | 30 | void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width, |
28 | int height, int max_x, int max_y, | 31 | int height, int max_x, int max_y, |
@@ -44,13 +47,13 @@ void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width, | |||
44 | 47 | ||
45 | dest.w = display_zoom; | 48 | dest.w = display_zoom; |
46 | dest.h = display_zoom; | 49 | dest.h = display_zoom; |
47 | 50 | ||
48 | for (x = x_start; x < xmax; x++) { | 51 | for (x = x_start; x < xmax; x++) { |
49 | dest.x = x * display_zoom; | 52 | dest.x = x * display_zoom; |
50 | 53 | ||
51 | for (y = y_start; y < ymax; y++) { | 54 | for (y = y_start; y < ymax; y++) { |
52 | dest.y = y * display_zoom; | 55 | dest.y = y * display_zoom; |
53 | 56 | ||
54 | SDL_FillRect(surface, &dest, (Uint32)getpixel(x, y)); | 57 | SDL_FillRect(surface, &dest, (Uint32)getpixel(x, y)); |
55 | } | 58 | } |
56 | } | 59 | } |
@@ -58,9 +61,11 @@ void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width, | |||
58 | SDL_UnlockSurface(surface); | 61 | SDL_UnlockSurface(surface); |
59 | } | 62 | } |
60 | 63 | ||
61 | void sdl_gui_update(SDL_Surface *surface, int x_start, int y_start, int width, | 64 | void sdl_gui_update(SDL_Surface *surface, IFSPLIT(SDL_Surface *real_surface,) |
65 | int x_start, int y_start, int width, | ||
62 | int height, int max_x, int max_y, int ui_x, int ui_y) | 66 | int height, int max_x, int max_y, int ui_x, int ui_y) |
63 | { | 67 | { |
68 | printf("(%d, %d, %d, %d);\n", x_start, y_start, width, height); | ||
64 | int xmax, ymax; | 69 | int xmax, ymax; |
65 | 70 | ||
66 | ymax = y_start + height; | 71 | ymax = y_start + height; |
@@ -76,16 +81,73 @@ void sdl_gui_update(SDL_Surface *surface, int x_start, int y_start, int width, | |||
76 | SDL_Rect dest= {(ui_x + x_start) * display_zoom, (ui_y + y_start) * display_zoom, | 81 | SDL_Rect dest= {(ui_x + x_start) * display_zoom, (ui_y + y_start) * display_zoom, |
77 | xmax * display_zoom, ymax * display_zoom}; | 82 | xmax * display_zoom, ymax * display_zoom}; |
78 | 83 | ||
84 | #ifdef UI_LCD_SPLIT | ||
85 | /* fix real screen coordinates */ | ||
86 | if(ymax >= UI_LCD_SPLIT_LINES) | ||
87 | src.h += UI_LCD_SPLIT_BLACK_LINES * display_zoom; | ||
88 | |||
89 | SDL_LockSurface(surface); | ||
90 | SDL_LockSurface(real_surface); | ||
91 | |||
92 | int pixel, npixels; | ||
93 | |||
94 | #if LCD_DEPTH != 1 | ||
95 | #error "Split screen only works for monochrome displays !" | ||
96 | #endif | ||
97 | |||
98 | npixels = display_zoom * display_zoom * UI_LCD_SPLIT_LINES * surface->pitch; | ||
99 | const unsigned char * pixels_src = (const unsigned char*)surface->pixels; | ||
100 | unsigned char * pixels_dst = (unsigned char*)real_surface->pixels; | ||
101 | const int start_pixel = UI_LCD_SPLIT_LINES * surface->pitch * display_zoom; | ||
102 | const int stop_pixel = (UI_LCD_SPLIT_LINES+UI_LCD_SPLIT_BLACK_LINES) | ||
103 | * surface->pitch * display_zoom; | ||
104 | |||
105 | /* draw top pixels, change the color */ | ||
106 | for (pixel = 0; pixel < npixels ; pixel++) | ||
107 | { | ||
108 | int pix = pixels_src[pixel] + gradient_steps; | ||
109 | if(pix > 255) pix = 255; | ||
110 | |||
111 | pixels_dst[pixel] = pix; | ||
112 | } | ||
113 | |||
114 | /* copy bottom pixels */ | ||
115 | memcpy(&pixels_dst[stop_pixel], &pixels_src[start_pixel], | ||
116 | (UI_LCD_HEIGHT - UI_LCD_SPLIT_LINES) * surface->pitch * display_zoom); | ||
117 | |||
118 | /* separation lines are off */ | ||
119 | for (pixel = start_pixel; pixel < stop_pixel ; pixel++) | ||
120 | pixels_dst[pixel] = 0; | ||
121 | |||
122 | SDL_UnlockSurface(surface); | ||
123 | SDL_UnlockSurface(real_surface); | ||
124 | |||
125 | SDL_BlitSurface(real_surface, &src, gui_surface, &dest); | ||
126 | #else | ||
79 | SDL_BlitSurface(surface, &src, gui_surface, &dest); | 127 | SDL_BlitSurface(surface, &src, gui_surface, &dest); |
128 | #endif | ||
129 | |||
80 | SDL_Flip(gui_surface); | 130 | SDL_Flip(gui_surface); |
81 | } | 131 | } |
82 | 132 | ||
83 | /* set a range of bitmap indices to a gradient from startcolour to endcolour */ | 133 | /* set a range of bitmap indices to a gradient from startcolour to endcolour */ |
84 | void sdl_set_gradient(SDL_Surface *surface, SDL_Color *start, SDL_Color *end, | 134 | void sdl_set_gradient(SDL_Surface *surface, SDL_Color *start, SDL_Color *end, |
85 | int first, int steps) | 135 | IFSPLIT(SDL_Color *split_start,) |
136 | IFSPLIT(SDL_Color *split_end ,) int first, int steps) | ||
86 | { | 137 | { |
87 | int i; | 138 | int i; |
88 | SDL_Color palette[steps]; | 139 | |
140 | #ifdef UI_LCD_SPLIT | ||
141 | int tot_steps = steps * 2; | ||
142 | if (tot_steps > 256) | ||
143 | tot_steps = 256; | ||
144 | |||
145 | gradient_steps = steps; | ||
146 | #else | ||
147 | #define tot_steps steps | ||
148 | #endif | ||
149 | |||
150 | SDL_Color palette[tot_steps]; | ||
89 | 151 | ||
90 | for (i = 0; i < steps; i++) { | 152 | for (i = 0; i < steps; i++) { |
91 | palette[i].r = start->r + (end->r - start->r) * i / (steps - 1); | 153 | palette[i].r = start->r + (end->r - start->r) * i / (steps - 1); |
@@ -93,6 +155,14 @@ void sdl_set_gradient(SDL_Surface *surface, SDL_Color *start, SDL_Color *end, | |||
93 | palette[i].b = start->b + (end->b - start->b) * i / (steps - 1); | 155 | palette[i].b = start->b + (end->b - start->b) * i / (steps - 1); |
94 | } | 156 | } |
95 | 157 | ||
96 | SDL_SetPalette(surface, SDL_LOGPAL|SDL_PHYSPAL, palette, first, steps); | 158 | #ifdef UI_LCD_SPLIT /* extra color */ |
159 | for (i = steps ; i < tot_steps; i++) { | ||
160 | palette[i].r = split_start->r + (split_end->r - split_start->r) * (i - steps) / (tot_steps - steps - 1); | ||
161 | palette[i].g = split_start->g + (split_end->g - split_start->g) * (i - steps) / (tot_steps - steps - 1); | ||
162 | palette[i].b = split_start->b + (split_end->b - split_start->b) * (i - steps) / (tot_steps - steps - 1); | ||
163 | } | ||
164 | #endif | ||
165 | |||
166 | SDL_SetPalette(surface, SDL_LOGPAL|SDL_PHYSPAL, palette, first, tot_steps); | ||
97 | } | 167 | } |
98 | 168 | ||
diff --git a/uisimulator/sdl/lcd-sdl.h b/uisimulator/sdl/lcd-sdl.h index 9ffa5246cf..b177eb14c9 100644 --- a/uisimulator/sdl/lcd-sdl.h +++ b/uisimulator/sdl/lcd-sdl.h | |||
@@ -25,6 +25,13 @@ | |||
25 | #include "lcd.h" | 25 | #include "lcd.h" |
26 | #include "SDL.h" | 26 | #include "SDL.h" |
27 | 27 | ||
28 | #include "uisdl.h" | ||
29 | #ifdef UI_LCD_SPLIT | ||
30 | #define IFSPLIT(x,y) x,y | ||
31 | #else | ||
32 | #define IFSPLIT(x,y) | ||
33 | #endif | ||
34 | |||
28 | /* Default display zoom level */ | 35 | /* Default display zoom level */ |
29 | extern int display_zoom; | 36 | extern int display_zoom; |
30 | 37 | ||
@@ -32,11 +39,13 @@ void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width, | |||
32 | int height, int max_x, int max_y, | 39 | int height, int max_x, int max_y, |
33 | unsigned long (*getpixel)(int, int)); | 40 | unsigned long (*getpixel)(int, int)); |
34 | 41 | ||
35 | void sdl_gui_update(SDL_Surface *surface, int x_start, int y_start, int width, | 42 | void sdl_gui_update(SDL_Surface *surface, IFSPLIT(SDL_Surface *real_surface,) |
43 | int x_start, int y_start, int width, | ||
36 | int height, int max_x, int max_y, int ui_x, int ui_y); | 44 | int height, int max_x, int max_y, int ui_x, int ui_y); |
37 | 45 | ||
38 | void sdl_set_gradient(SDL_Surface *surface, SDL_Color *start, SDL_Color *end, | 46 | void sdl_set_gradient(SDL_Surface *surface, SDL_Color *start, SDL_Color *end, |
39 | int first, int steps); | 47 | IFSPLIT( SDL_Color *split_start ,) |
48 | IFSPLIT( SDL_Color *split_end ,) int first, int steps); | ||
40 | 49 | ||
41 | #endif /* #ifndef __LCDSDL_H__ */ | 50 | #endif /* #ifndef __LCDSDL_H__ */ |
42 | 51 | ||
diff --git a/uisimulator/sdl/uisdl.c b/uisimulator/sdl/uisdl.c index 156e4203f6..f161d40567 100644 --- a/uisimulator/sdl/uisdl.c +++ b/uisimulator/sdl/uisdl.c | |||
@@ -134,7 +134,11 @@ bool gui_startup(void) | |||
134 | height = UI_LCD_HEIGHT + UI_REMOTE_HEIGHT; | 134 | height = UI_LCD_HEIGHT + UI_REMOTE_HEIGHT; |
135 | #else | 135 | #else |
136 | width = UI_LCD_WIDTH; | 136 | width = UI_LCD_WIDTH; |
137 | height = UI_LCD_HEIGHT; | 137 | height = UI_LCD_HEIGHT |
138 | #ifdef UI_LCD_SPLIT | ||
139 | + UI_LCD_SPLIT_BLACK_LINES | ||
140 | #endif | ||
141 | ; | ||
138 | #endif | 142 | #endif |
139 | } | 143 | } |
140 | 144 | ||
diff --git a/uisimulator/sdl/uisdl.h b/uisimulator/sdl/uisdl.h index 0a97df56fa..cb4158500c 100644 --- a/uisimulator/sdl/uisdl.h +++ b/uisimulator/sdl/uisdl.h | |||
@@ -459,6 +459,13 @@ | |||
459 | #define UI_LCD_FGCOLOR 0, 0, 0 /* foreground color of LCD (no backlight) */ | 459 | #define UI_LCD_FGCOLOR 0, 0, 0 /* foreground color of LCD (no backlight) */ |
460 | #define UI_LCD_FGCOLORLIGHT 13, 226, 229 /* foreground color of LCD (backlight) */ | 460 | #define UI_LCD_FGCOLORLIGHT 13, 226, 229 /* foreground color of LCD (backlight) */ |
461 | 461 | ||
462 | #define UI_LCD_SPLIT /* The screen is split in 2 areas */ | ||
463 | #define UI_LCD_SPLIT_LINES 16 /* the top 16 lines have a different color */ | ||
464 | #define UI_LCD_SPLIT_BLACK_LINES 2 /* The 2 areas are separated by 2 empty lines */ | ||
465 | /* Colors for the top part of the screen */ | ||
466 | #define UI_LCD_SPLIT_FGCOLOR 0, 0, 0 /* foreground color of LCD (no backlight) */ | ||
467 | #define UI_LCD_SPLIT_FGCOLORLIGHT 255, 230, 15 /* foreground color of LCD (backlight) */ | ||
468 | |||
462 | #endif | 469 | #endif |
463 | extern SDL_Surface *gui_surface; | 470 | extern SDL_Surface *gui_surface; |
464 | extern bool background; /* True if the background image is enabled */ | 471 | extern bool background; /* True if the background image is enabled */ |