diff --git a/uisimulator/sdl/lcd-bitmap.c b/uisimulator/sdl/lcd-bitmap.c index 9248039..e05201a 100644 --- a/uisimulator/sdl/lcd-bitmap.c +++ b/uisimulator/sdl/lcd-bitmap.c @@ -30,9 +30,15 @@ int lcd_backlight_val; #ifdef HAVE_BACKLIGHT SDL_Color lcd_backlight_color_zero = {UI_LCD_BGCOLORLIGHT, 0}; SDL_Color lcd_backlight_color_max = {UI_LCD_FGCOLORLIGHT, 0}; +#ifdef UI_LCD_SPLIT +SDL_Color lcd_backlight_color_split= {UI_LCD_SPLIT_FGCOLORLIGHT, 0}; +#endif #endif SDL_Color lcd_color_zero = {UI_LCD_BGCOLOR, 0}; SDL_Color lcd_color_max = {UI_LCD_FGCOLOR, 0}; +#ifdef UI_LCD_SPLIT +SDL_Color lcd_color_split= {UI_LCD_SPLIT_FGCOLOR, 0}; +#endif #endif #if LCD_DEPTH < 8 @@ -85,20 +91,20 @@ void sim_backlight(int value) #if LCD_DEPTH <= 8 if (value > 0) { sdl_set_gradient(lcd_surface, &lcd_backlight_color_zero, - &lcd_backlight_color_max, 0, (1< 0) { sdl_set_gradient(lcd_surface, &lcd_backlight_color_max, - &lcd_backlight_color_zero, (1< 0) { sdl_set_gradient(lcd_surface, &lcd_color_max, - &lcd_backlight_color_zero, (1<> 9, g >> 8, b >> 9); #if LCD_WIDTH >= LCD_HEIGHT - dst++; + dst++; #else dst += LCD_WIDTH; #endif @@ -276,7 +283,7 @@ void lcd_blit_yuv(unsigned char * const src[3], *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); #if LCD_WIDTH >= LCD_HEIGHT - dst++; + dst++; #else dst += LCD_WIDTH; #endif @@ -321,7 +328,7 @@ void lcd_blit_yuv(unsigned char * const src[3], *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); #if LCD_WIDTH >= LCD_HEIGHT - dst++; + dst++; #else dst += LCD_WIDTH; #endif @@ -341,7 +348,7 @@ void lcd_blit_yuv(unsigned char * const src[3], *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); #if LCD_WIDTH >= LCD_HEIGHT - dst++; + dst++; #else dst += LCD_WIDTH; #endif diff --git a/uisimulator/sdl/lcd-sdl.c b/uisimulator/sdl/lcd-sdl.c index 1014a37..9b3d722 100644 --- a/uisimulator/sdl/lcd-sdl.c +++ b/uisimulator/sdl/lcd-sdl.c @@ -44,13 +44,13 @@ void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width, dest.w = display_zoom; dest.h = display_zoom; - + for (x = x_start; x < xmax; x++) { dest.x = x * display_zoom; for (y = y_start; y < ymax; y++) { dest.y = y * display_zoom; - + SDL_FillRect(surface, &dest, (Uint32)getpixel(x, y)); } } @@ -76,16 +76,42 @@ void sdl_gui_update(SDL_Surface *surface, int x_start, int y_start, int width, SDL_Rect dest= {(ui_x + x_start) * display_zoom, (ui_y + y_start) * display_zoom, xmax * display_zoom, ymax * display_zoom}; +#ifdef UI_LCD_SPLIT + SDL_LockSurface(surface); + + int pixel, npixels; + npixels = display_zoom * display_zoom * UI_LCD_SPLIT_LINES * surface->pitch; + +#if LCD_DEPTH == 1 +#define SPLIT_COLOR 2 /* 0 == off, 1 == color */ +#else +#error "Split screen only works for monochrome !" +#endif + + if (surface->format->BytesPerPixel == 1) /* safety check */ + for (pixel = 0; pixel < npixels ; pixel++) + if (((unsigned char *)surface->pixels)[pixel]) + ((unsigned char *)surface->pixels)[pixel] = SPLIT_COLOR; + + SDL_UnlockSurface(surface); +#endif + SDL_BlitSurface(surface, &src, gui_surface, &dest); SDL_Flip(gui_surface); } /* set a range of bitmap indices to a gradient from startcolour to endcolour */ void sdl_set_gradient(SDL_Surface *surface, SDL_Color *start, SDL_Color *end, - int first, int steps) + IFSPLIT(SDL_Color *split,) int first, int steps) { int i; - SDL_Color palette[steps]; +#ifdef UI_LCD_SPLIT + int tot_steps = steps + 1; +#else +#define tot_steps steps +#endif + + SDL_Color palette[tot_steps]; for (i = 0; i < steps; i++) { palette[i].r = start->r + (end->r - start->r) * i / (steps - 1); @@ -93,6 +119,12 @@ void sdl_set_gradient(SDL_Surface *surface, SDL_Color *start, SDL_Color *end, palette[i].b = start->b + (end->b - start->b) * i / (steps - 1); } - SDL_SetPalette(surface, SDL_LOGPAL|SDL_PHYSPAL, palette, first, steps); +#ifdef UI_LCD_SPLIT /* extra color */ + palette[i].r = split->r; + palette[i].g = split->g; + palette[i].b = split->b; +#endif + + SDL_SetPalette(surface, SDL_LOGPAL|SDL_PHYSPAL, palette, first, tot_steps); } diff --git a/uisimulator/sdl/lcd-sdl.h b/uisimulator/sdl/lcd-sdl.h index 9ffa524..36ee1ff 100644 --- a/uisimulator/sdl/lcd-sdl.h +++ b/uisimulator/sdl/lcd-sdl.h @@ -25,6 +25,13 @@ #include "lcd.h" #include "SDL.h" +#include "uisdl.h" +#ifdef UI_LCD_SPLIT +#define IFSPLIT(x,y) x,y +#else +#define IFSPLIT(x,y) +#endif + /* Default display zoom level */ extern int display_zoom; @@ -36,7 +43,7 @@ void sdl_gui_update(SDL_Surface *surface, int x_start, int y_start, int width, int height, int max_x, int max_y, int ui_x, int ui_y); void sdl_set_gradient(SDL_Surface *surface, SDL_Color *start, SDL_Color *end, - int first, int steps); + IFSPLIT( SDL_Color *split ,) int first, int steps); #endif /* #ifndef __LCDSDL_H__ */ diff --git a/uisimulator/sdl/uisdl.h b/uisimulator/sdl/uisdl.h index 4332426..a027491 100644 --- a/uisimulator/sdl/uisdl.h +++ b/uisimulator/sdl/uisdl.h @@ -449,6 +449,12 @@ #define UI_LCD_FGCOLOR 0, 0, 0 /* foreground color of LCD (no backlight) */ #define UI_LCD_FGCOLORLIGHT 13, 226, 229 /* foreground color of LCD (backlight) */ +#define UI_LCD_SPLIT /* The screen is split in 2 parts */ +#define UI_LCD_SPLIT_LINES 16 /* the top 16 lines have a different color */ +/* Colors for the top part of the screen */ +#define UI_LCD_SPLIT_FGCOLOR 0, 0, 0 /* foreground color of LCD (no backlight) */ +#define UI_LCD_SPLIT_FGCOLORLIGHT 255, 230, 15 /* foreground color of LCD (backlight) */ + #endif extern SDL_Surface *gui_surface; extern bool background; /* True if the background image is enabled */