diff options
author | Jens Arnold <amiconn@rockbox.org> | 2009-02-09 00:32:59 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2009-02-09 00:32:59 +0000 |
commit | 0d935ce75e1408dfd9832ae7dbb7d84df50a645d (patch) | |
tree | 9ddcc5d21dcd0e576d0fa824e74c58755fa9d1a0 /uisimulator/sdl/lcd-sdl.c | |
parent | 94537f954e67d44fdd9703c062c4ee53599e0e74 (diff) | |
download | rockbox-0d935ce75e1408dfd9832ae7dbb7d84df50a645d.tar.gz rockbox-0d935ce75e1408dfd9832ae7dbb7d84df50a645d.zip |
Put the display colours for monochrome and greyscale targets into the target config files, and use them both for the simulator UI and screendumps. The Clip now shows the split display properly in screendumps and simulator. A side effect is that screendumps of ordinary monochrome targets are now 4-bit BMP files (saves an alternate code path, and might be more compatible with some gfx programs). * Simplify the simulation of split display, and also simplify greylib simulation. The simulator now always calculates 129 shades (2*128 for a Clip sim), and just uses 2 (or 4) of those for native display simulation. * Centralised the simulator LCD dimension definition.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19950 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/sdl/lcd-sdl.c')
-rw-r--r-- | uisimulator/sdl/lcd-sdl.c | 90 |
1 files changed, 18 insertions, 72 deletions
diff --git a/uisimulator/sdl/lcd-sdl.c b/uisimulator/sdl/lcd-sdl.c index 6431c5f39d..373e07ffc0 100644 --- a/uisimulator/sdl/lcd-sdl.c +++ b/uisimulator/sdl/lcd-sdl.c | |||
@@ -21,11 +21,9 @@ | |||
21 | 21 | ||
22 | #include "lcd-sdl.h" | 22 | #include "lcd-sdl.h" |
23 | #include "uisdl.h" | 23 | #include "uisdl.h" |
24 | #include "system.h" /* for MIN() and MAX() */ | ||
24 | 25 | ||
25 | int display_zoom = 1; | 26 | int display_zoom = 1; |
26 | #ifdef UI_LCD_SPLIT | ||
27 | static int gradient_steps = 0; | ||
28 | #endif | ||
29 | 27 | ||
30 | void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width, | 28 | void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width, |
31 | int height, int max_x, int max_y, | 29 | int height, int max_x, int max_y, |
@@ -51,18 +49,30 @@ void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width, | |||
51 | for (x = x_start; x < xmax; x++) { | 49 | for (x = x_start; x < xmax; x++) { |
52 | dest.x = x * display_zoom; | 50 | dest.x = x * display_zoom; |
53 | 51 | ||
52 | #ifdef HAVE_LCD_SPLIT | ||
53 | for (y = y_start; y < MIN(ymax, LCD_SPLIT_POS); y++) { | ||
54 | dest.y = y * display_zoom; | ||
55 | |||
56 | SDL_FillRect(surface, &dest, (Uint32)(getpixel(x, y) | 0x80)); | ||
57 | } | ||
58 | for (y = MAX(y_start, LCD_SPLIT_POS); y < ymax; y++) { | ||
59 | dest.y = (y + LCD_SPLIT_LINES) * display_zoom ; | ||
60 | |||
61 | SDL_FillRect(surface, &dest, (Uint32)getpixel(x, y)); | ||
62 | } | ||
63 | #else | ||
54 | for (y = y_start; y < ymax; y++) { | 64 | for (y = y_start; y < ymax; y++) { |
55 | dest.y = y * display_zoom; | 65 | dest.y = y * display_zoom; |
56 | 66 | ||
57 | SDL_FillRect(surface, &dest, (Uint32)getpixel(x, y)); | 67 | SDL_FillRect(surface, &dest, (Uint32)getpixel(x, y)); |
58 | } | 68 | } |
69 | #endif | ||
59 | } | 70 | } |
60 | 71 | ||
61 | SDL_UnlockSurface(surface); | 72 | SDL_UnlockSurface(surface); |
62 | } | 73 | } |
63 | 74 | ||
64 | void sdl_gui_update(SDL_Surface *surface, IFSPLIT(SDL_Surface *real_surface,) | 75 | void sdl_gui_update(SDL_Surface *surface, int x_start, int y_start, int width, |
65 | int x_start, int y_start, int width, | ||
66 | int height, int max_x, int max_y, int ui_x, int ui_y) | 76 | int height, int max_x, int max_y, int ui_x, int ui_y) |
67 | { | 77 | { |
68 | int xmax, ymax; | 78 | int xmax, ymax; |
@@ -80,73 +90,17 @@ void sdl_gui_update(SDL_Surface *surface, IFSPLIT(SDL_Surface *real_surface,) | |||
80 | SDL_Rect dest= {(ui_x + x_start) * display_zoom, (ui_y + y_start) * display_zoom, | 90 | SDL_Rect dest= {(ui_x + x_start) * display_zoom, (ui_y + y_start) * display_zoom, |
81 | xmax * display_zoom, ymax * display_zoom}; | 91 | xmax * display_zoom, ymax * display_zoom}; |
82 | 92 | ||
83 | #ifdef UI_LCD_SPLIT | ||
84 | /* fix real screen coordinates */ | ||
85 | if(ymax >= UI_LCD_SPLIT_LINES) | ||
86 | src.h += UI_LCD_SPLIT_BLACK_LINES * display_zoom; | ||
87 | |||
88 | SDL_LockSurface(surface); | ||
89 | SDL_LockSurface(real_surface); | ||
90 | |||
91 | int pixel, npixels; | ||
92 | |||
93 | #if LCD_DEPTH != 1 | ||
94 | #error "Split screen only works for monochrome displays !" | ||
95 | #endif | ||
96 | |||
97 | npixels = display_zoom * display_zoom * UI_LCD_SPLIT_LINES * surface->pitch; | ||
98 | const unsigned char * pixels_src = (const unsigned char*)surface->pixels; | ||
99 | unsigned char * pixels_dst = (unsigned char*)real_surface->pixels; | ||
100 | const int start_pixel = UI_LCD_SPLIT_LINES * surface->pitch * display_zoom; | ||
101 | const int stop_pixel = (UI_LCD_SPLIT_LINES+UI_LCD_SPLIT_BLACK_LINES) | ||
102 | * surface->pitch * display_zoom; | ||
103 | |||
104 | /* draw top pixels, change the color */ | ||
105 | for (pixel = 0; pixel < npixels ; pixel++) | ||
106 | { | ||
107 | int pix = pixels_src[pixel] + gradient_steps; | ||
108 | if(pix > 255) pix = 255; | ||
109 | |||
110 | pixels_dst[pixel] = pix; | ||
111 | } | ||
112 | |||
113 | /* copy bottom pixels */ | ||
114 | memcpy(&pixels_dst[stop_pixel], &pixels_src[start_pixel], | ||
115 | (UI_LCD_HEIGHT - UI_LCD_SPLIT_LINES) * surface->pitch * display_zoom); | ||
116 | |||
117 | /* separation lines are off */ | ||
118 | for (pixel = start_pixel; pixel < stop_pixel ; pixel++) | ||
119 | pixels_dst[pixel] = 0; | ||
120 | |||
121 | SDL_UnlockSurface(surface); | ||
122 | SDL_UnlockSurface(real_surface); | ||
123 | |||
124 | SDL_BlitSurface(real_surface, &src, gui_surface, &dest); | ||
125 | #else | ||
126 | SDL_BlitSurface(surface, &src, gui_surface, &dest); | 93 | SDL_BlitSurface(surface, &src, gui_surface, &dest); |
127 | #endif | ||
128 | 94 | ||
129 | SDL_Flip(gui_surface); | 95 | SDL_Flip(gui_surface); |
130 | } | 96 | } |
131 | 97 | ||
132 | /* set a range of bitmap indices to a gradient from startcolour to endcolour */ | 98 | /* set a range of bitmap indices to a gradient from startcolour to endcolour */ |
133 | void sdl_set_gradient(SDL_Surface *surface, SDL_Color *start, SDL_Color *end, | 99 | void sdl_set_gradient(SDL_Surface *surface, SDL_Color *start, SDL_Color *end, |
134 | IFSPLIT(SDL_Color *split_start,) | 100 | int first, int steps) |
135 | IFSPLIT(SDL_Color *split_end ,) int first, int steps) | ||
136 | { | 101 | { |
137 | int i; | 102 | int i; |
138 | 103 | SDL_Color palette[steps]; | |
139 | #ifdef UI_LCD_SPLIT | ||
140 | int tot_steps = steps * 2; | ||
141 | if (tot_steps > 256) | ||
142 | tot_steps = 256; | ||
143 | |||
144 | gradient_steps = steps; | ||
145 | #else | ||
146 | #define tot_steps steps | ||
147 | #endif | ||
148 | |||
149 | SDL_Color palette[tot_steps]; | ||
150 | 104 | ||
151 | for (i = 0; i < steps; i++) { | 105 | for (i = 0; i < steps; i++) { |
152 | palette[i].r = start->r + (end->r - start->r) * i / (steps - 1); | 106 | palette[i].r = start->r + (end->r - start->r) * i / (steps - 1); |
@@ -154,14 +108,6 @@ void sdl_set_gradient(SDL_Surface *surface, SDL_Color *start, SDL_Color *end, | |||
154 | palette[i].b = start->b + (end->b - start->b) * i / (steps - 1); | 108 | palette[i].b = start->b + (end->b - start->b) * i / (steps - 1); |
155 | } | 109 | } |
156 | 110 | ||
157 | #ifdef UI_LCD_SPLIT /* extra color */ | 111 | SDL_SetPalette(surface, SDL_LOGPAL|SDL_PHYSPAL, palette, first, steps); |
158 | for (i = steps ; i < tot_steps; i++) { | ||
159 | palette[i].r = split_start->r + (split_end->r - split_start->r) * (i - steps) / (tot_steps - steps - 1); | ||
160 | palette[i].g = split_start->g + (split_end->g - split_start->g) * (i - steps) / (tot_steps - steps - 1); | ||
161 | palette[i].b = split_start->b + (split_end->b - split_start->b) * (i - steps) / (tot_steps - steps - 1); | ||
162 | } | ||
163 | #endif | ||
164 | |||
165 | SDL_SetPalette(surface, SDL_LOGPAL|SDL_PHYSPAL, palette, first, tot_steps); | ||
166 | } | 112 | } |
167 | 113 | ||