diff options
Diffstat (limited to 'uisimulator/win32/lcd-win32.c')
-rw-r--r-- | uisimulator/win32/lcd-win32.c | 101 |
1 files changed, 93 insertions, 8 deletions
diff --git a/uisimulator/win32/lcd-win32.c b/uisimulator/win32/lcd-win32.c index 11296884b7..216aa65a0e 100644 --- a/uisimulator/win32/lcd-win32.c +++ b/uisimulator/win32/lcd-win32.c | |||
@@ -39,13 +39,29 @@ BITMAPINFO256 bmi = | |||
39 | 39 | ||
40 | #ifdef HAVE_LCD_BITMAP | 40 | #ifdef HAVE_LCD_BITMAP |
41 | 41 | ||
42 | #ifdef HAVE_REMOTE_LCD | ||
43 | char remote_bitmap[LCD_REMOTE_HEIGHT][LCD_REMOTE_WIDTH]; | ||
44 | |||
45 | RGBQUAD remote_color_zero = {UI_REMOTE_BGCOLORLIGHT, 0}; | ||
46 | RGBQUAD remote_color_max = {0, 0, 0, 0}; | ||
47 | |||
48 | BITMAPINFO256 remote_bmi = | ||
49 | { | ||
50 | {sizeof (BITMAPINFOHEADER), | ||
51 | LCD_REMOTE_WIDTH, -LCD_REMOTE_HEIGHT, 1, 8, | ||
52 | BI_RGB, 0, 0, 0, 2, 2, | ||
53 | }, | ||
54 | {} /* colour lookup table gets filled later */ | ||
55 | }; | ||
56 | #endif | ||
57 | |||
42 | #if LCD_DEPTH == 1 | 58 | #if LCD_DEPTH == 1 |
43 | extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH]; /* the display */ | 59 | extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH]; /* the display */ |
44 | #elif LCD_DEPTH == 2 | 60 | #elif LCD_DEPTH == 2 |
45 | extern unsigned char lcd_framebuffer[LCD_HEIGHT/4][LCD_WIDTH]; /* the display */ | 61 | extern unsigned char lcd_framebuffer[LCD_HEIGHT/4][LCD_WIDTH]; /* the display */ |
46 | #endif | 62 | #endif |
47 | 63 | ||
48 | void lcd_update() | 64 | void lcd_update(void) |
49 | { | 65 | { |
50 | int x, y; | 66 | int x, y; |
51 | RECT r; | 67 | RECT r; |
@@ -109,19 +125,67 @@ void lcd_update_rect(int x_start, int y_start, | |||
109 | InvalidateRect (hGUIWnd, &r, FALSE); | 125 | InvalidateRect (hGUIWnd, &r, FALSE); |
110 | } | 126 | } |
111 | 127 | ||
128 | #ifdef HAVE_REMOTE_LCD | ||
129 | |||
130 | extern unsigned char lcd_remote_framebuffer[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH]; | ||
131 | |||
112 | void lcd_remote_update(void) | 132 | void lcd_remote_update(void) |
113 | { | 133 | { |
114 | 134 | int x, y; | |
135 | RECT r; | ||
136 | |||
137 | if (hGUIWnd == NULL) | ||
138 | _endthread (); | ||
139 | |||
140 | for (x = 0; x < LCD_REMOTE_WIDTH; x++) | ||
141 | for (y = 0; y < LCD_REMOTE_HEIGHT; y++) | ||
142 | remote_bitmap[y][x] = ((lcd_remote_framebuffer[y/8][x] >> (y & 7)) & 1); | ||
143 | |||
144 | /* Invalidate only the window part that actually did change */ | ||
145 | GetClientRect (hGUIWnd, &r); | ||
146 | r.left = UI_REMOTE_POSX * r.right / UI_WIDTH; | ||
147 | r.top = UI_REMOTE_POSY * r.bottom / UI_HEIGHT; | ||
148 | r.right = (UI_REMOTE_POSX + UI_REMOTE_WIDTH) * r.right / UI_WIDTH; | ||
149 | r.bottom = (UI_REMOTE_POSY + UI_REMOTE_HEIGHT) * r.bottom / UI_HEIGHT; | ||
150 | InvalidateRect (hGUIWnd, &r, FALSE); | ||
115 | } | 151 | } |
116 | 152 | ||
117 | void lcd_remote_update_rect(int x_start, int y_start, | 153 | void lcd_remote_update_rect(int x_start, int y_start, |
118 | int width, int height) | 154 | int width, int height) |
119 | { | 155 | { |
120 | (void)x_start; | 156 | int x, y; |
121 | (void)y_start; | 157 | int xmax, ymax; |
122 | (void)width; | 158 | RECT r; |
123 | (void)height; | 159 | |
160 | ymax = y_start + height; | ||
161 | xmax = x_start + width; | ||
162 | |||
163 | if (hGUIWnd == NULL) | ||
164 | _endthread (); | ||
165 | |||
166 | if(xmax > LCD_REMOTE_WIDTH) | ||
167 | xmax = LCD_REMOTE_WIDTH; | ||
168 | if(ymax >= LCD_REMOTE_HEIGHT) | ||
169 | ymax = LCD_REMOTE_HEIGHT; | ||
170 | |||
171 | for (x = x_start; x < xmax; x++) | ||
172 | for (y = y_start; y < ymax; y++) | ||
173 | remote_bitmap[y][x] = ((lcd_remote_framebuffer[y/8][x] >> (y & 7)) & 1); | ||
174 | |||
175 | /* Invalidate only the window part that actually did change */ | ||
176 | GetClientRect (hGUIWnd, &r); | ||
177 | r.left = (UI_REMOTE_POSX + (UI_REMOTE_WIDTH * x_start / LCD_REMOTE_WIDTH)) | ||
178 | * r.right / UI_WIDTH; | ||
179 | r.top = (UI_REMOTE_POSY + (UI_REMOTE_HEIGHT * y_start / LCD_REMOTE_HEIGHT)) | ||
180 | * r.bottom / UI_HEIGHT; | ||
181 | r.right = (UI_REMOTE_POSX + (UI_REMOTE_WIDTH * xmax / LCD_REMOTE_WIDTH)) | ||
182 | * r.right / UI_WIDTH; | ||
183 | r.bottom = (UI_REMOTE_POSY + (UI_REMOTE_HEIGHT * ymax / LCD_REMOTE_HEIGHT)) | ||
184 | * r.bottom / UI_HEIGHT; | ||
185 | InvalidateRect (hGUIWnd, &r, FALSE); | ||
124 | } | 186 | } |
187 | |||
188 | #endif /* HAVE_REMOTE_LCD */ | ||
125 | #endif /* HAVE_LCD_BITMAP */ | 189 | #endif /* HAVE_LCD_BITMAP */ |
126 | 190 | ||
127 | #ifdef HAVE_LCD_CHARCELLS | 191 | #ifdef HAVE_LCD_CHARCELLS |
@@ -131,7 +195,7 @@ extern bool lcd_display_redraw; | |||
131 | extern unsigned char hardware_buffer_lcd[11][2]; | 195 | extern unsigned char hardware_buffer_lcd[11][2]; |
132 | static unsigned char lcd_buffer_copy[11][2]; | 196 | static unsigned char lcd_buffer_copy[11][2]; |
133 | 197 | ||
134 | void lcd_update() | 198 | void lcd_update(void) |
135 | { | 199 | { |
136 | int x, y; | 200 | int x, y; |
137 | bool changed = false; | 201 | bool changed = false; |
@@ -224,11 +288,32 @@ void lcdcolors(int index, int count, RGBQUAD *start, RGBQUAD *end) | |||
224 | } | 288 | } |
225 | } | 289 | } |
226 | 290 | ||
291 | #ifdef HAVE_REMOTE_LCD | ||
292 | /* set a range of bitmap indices to a gradient from startcolour to endcolour */ | ||
293 | void lcdremotecolors(int index, int count, RGBQUAD *start, RGBQUAD *end) | ||
294 | { | ||
295 | int i; | ||
296 | count--; | ||
297 | for (i = 0; i <= count; i++) | ||
298 | { | ||
299 | remote_bmi.bmiColors[i+index].rgbRed = start->rgbRed | ||
300 | + (end->rgbRed - start->rgbRed) * i / count; | ||
301 | remote_bmi.bmiColors[i+index].rgbGreen = start->rgbGreen | ||
302 | + (end->rgbGreen - start->rgbGreen) * i / count; | ||
303 | remote_bmi.bmiColors[i+index].rgbBlue = start->rgbBlue | ||
304 | + (end->rgbBlue - start->rgbBlue) * i / count; | ||
305 | } | ||
306 | } | ||
307 | #endif | ||
308 | |||
227 | /* initialise simulator lcd driver */ | 309 | /* initialise simulator lcd driver */ |
228 | void simlcdinit(void) | 310 | void simlcdinit(void) |
229 | { | 311 | { |
230 | bmi.bmiHeader.biClrUsed = (1<<LCD_DEPTH); | 312 | bmi.bmiHeader.biClrUsed = (1<<LCD_DEPTH); |
231 | bmi.bmiHeader.biClrImportant = (1<<LCD_DEPTH); | 313 | bmi.bmiHeader.biClrImportant = (1<<LCD_DEPTH); |
232 | lcdcolors(0, (1<<LCD_DEPTH), &color_zero, &color_max); | 314 | lcdcolors(0, (1<<LCD_DEPTH), &color_zero, &color_max); |
315 | #ifdef HAVE_REMOTE_LCD | ||
316 | lcdremotecolors(0, (1<<LCD_REMOTE_DEPTH), &remote_color_zero, &remote_color_max); | ||
317 | #endif | ||
233 | } | 318 | } |
234 | 319 | ||