summaryrefslogtreecommitdiff
path: root/uisimulator/sdl/lcd-sdl.c
diff options
context:
space:
mode:
Diffstat (limited to 'uisimulator/sdl/lcd-sdl.c')
-rw-r--r--uisimulator/sdl/lcd-sdl.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/uisimulator/sdl/lcd-sdl.c b/uisimulator/sdl/lcd-sdl.c
index 3327dd8350..be10b468cb 100644
--- a/uisimulator/sdl/lcd-sdl.c
+++ b/uisimulator/sdl/lcd-sdl.c
@@ -23,8 +23,8 @@
23int display_zoom = 1; 23int display_zoom = 1;
24 24
25void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width, 25void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width,
26 int height, int max_x, int max_y, int ui_x, int ui_y, 26 int height, int max_x, int max_y,
27 Uint32 (*getpixel)(int, int)) 27 unsigned long (*getpixel)(int, int))
28{ 28{
29 int x, y; 29 int x, y;
30 int xmax, ymax; 30 int xmax, ymax;
@@ -49,25 +49,39 @@ void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width,
49 for (y = y_start; y < ymax; y++) { 49 for (y = y_start; y < ymax; y++) {
50 dest.y = y * display_zoom; 50 dest.y = y * display_zoom;
51 51
52 SDL_FillRect(surface, &dest, getpixel(x, y)); 52 SDL_FillRect(surface, &dest, (Uint32)getpixel(x, y));
53 } 53 }
54 } 54 }
55 55
56 SDL_UnlockSurface(surface); 56 SDL_UnlockSurface(surface);
57}
58
59void sdl_gui_update(SDL_Surface *surface, int x_start, int y_start, int width,
60 int height, int max_x, int max_y, int ui_x, int ui_y)
61{
62 int xmax, ymax;
63
64 ymax = y_start + height;
65 xmax = x_start + width;
66
67 if(xmax > max_x)
68 xmax = max_x;
69 if(ymax >= max_y)
70 ymax = max_y;
71
72 SDL_Rect src = {x_start * display_zoom, y_start * display_zoom,
73 xmax * display_zoom, ymax * display_zoom};
74 SDL_Rect dest= {(ui_x + x_start) * display_zoom, (ui_y + y_start) * display_zoom,
75 xmax * display_zoom, ymax * display_zoom};
57 76
58 SDL_Rect src = {x_start * display_zoom, y_start * display_zoom, xmax * display_zoom, ymax * display_zoom};
59 dest.x = (ui_x + x_start) * display_zoom;
60 dest.y = (ui_y + y_start) * display_zoom;;
61 dest.w = xmax * display_zoom;
62 dest.h = ymax * display_zoom;
63
64 SDL_BlitSurface(surface, &src, gui_surface, &dest); 77 SDL_BlitSurface(surface, &src, gui_surface, &dest);
65 SDL_UpdateRect(gui_surface, dest.x, dest.y, dest.w, dest.h); 78 SDL_UpdateRect(gui_surface, dest.x, dest.y, dest.w, dest.h);
66 SDL_Flip(gui_surface); 79 SDL_Flip(gui_surface);
67} 80}
68 81
69/* set a range of bitmap indices to a gradient from startcolour to endcolour */ 82/* set a range of bitmap indices to a gradient from startcolour to endcolour */
70void sdl_set_gradient(SDL_Surface *surface, SDL_Color *start, SDL_Color *end, int steps) 83void sdl_set_gradient(SDL_Surface *surface, SDL_Color *start, SDL_Color *end,
84 int first, int steps)
71{ 85{
72 int i; 86 int i;
73 SDL_Color palette[steps]; 87 SDL_Color palette[steps];
@@ -78,6 +92,6 @@ void sdl_set_gradient(SDL_Surface *surface, SDL_Color *start, SDL_Color *end, in
78 palette[i].b = start->b + (end->b - start->b) * i / (steps - 1); 92 palette[i].b = start->b + (end->b - start->b) * i / (steps - 1);
79 } 93 }
80 94
81 SDL_SetPalette(surface, SDL_LOGPAL|SDL_PHYSPAL, palette, 0, steps); 95 SDL_SetPalette(surface, SDL_LOGPAL|SDL_PHYSPAL, palette, first, steps);
82} 96}
83 97