diff options
Diffstat (limited to 'uisimulator/win32/lcd-win32.c')
-rw-r--r-- | uisimulator/win32/lcd-win32.c | 96 |
1 files changed, 87 insertions, 9 deletions
diff --git a/uisimulator/win32/lcd-win32.c b/uisimulator/win32/lcd-win32.c index 40f74ee2d6..49c490e1f4 100644 --- a/uisimulator/win32/lcd-win32.c +++ b/uisimulator/win32/lcd-win32.c | |||
@@ -23,8 +23,72 @@ | |||
23 | #include "lcd.h" | 23 | #include "lcd.h" |
24 | #include "lcd-playersim.h" | 24 | #include "lcd-playersim.h" |
25 | 25 | ||
26 | char bitmap[LCD_HEIGHT][LCD_WIDTH]; /* the ui display */ | 26 | #if LCD_DEPTH >= 16 |
27 | unsigned long bitmap[LCD_HEIGHT][LCD_WIDTH]; /* the ui display */ | ||
27 | 28 | ||
29 | BITMAPINFO256 bmi = | ||
30 | { | ||
31 | {sizeof (BITMAPINFOHEADER), | ||
32 | LCD_WIDTH, -LCD_HEIGHT, 1, 32, | ||
33 | BI_RGB, 0, 0, 0, 216, 216, | ||
34 | }, /* colour lookup table for 8bit displays (standard web palette) */ | ||
35 | {{0x00,0x00,0x00,0}, {0x33,0x00,0x00,0}, {0x66,0x00,0x00,0}, {0x99,0x00,0x00,0}, | ||
36 | {0xcc,0x00,0x00,0}, {0xff,0x00,0x00,0}, {0x00,0x33,0x00,0}, {0x33,0x33,0x00,0}, | ||
37 | {0x66,0x33,0x00,0}, {0x99,0x33,0x00,0}, {0xcc,0x33,0x00,0}, {0xff,0x33,0x00,0}, | ||
38 | {0x00,0x66,0x00,0}, {0x33,0x66,0x00,0}, {0x66,0x66,0x00,0}, {0x99,0x66,0x00,0}, | ||
39 | {0xcc,0x66,0x00,0}, {0xff,0x66,0x00,0}, {0x00,0x99,0x00,0}, {0x33,0x99,0x00,0}, | ||
40 | {0x66,0x99,0x00,0}, {0x99,0x99,0x00,0}, {0xcc,0x99,0x00,0}, {0xff,0x99,0x00,0}, | ||
41 | {0x00,0xcc,0x00,0}, {0x33,0xcc,0x00,0}, {0x66,0xcc,0x00,0}, {0x99,0xcc,0x00,0}, | ||
42 | {0xcc,0xcc,0x00,0}, {0xff,0xcc,0x00,0}, {0x00,0xff,0x00,0}, {0x33,0xff,0x00,0}, | ||
43 | {0x66,0xff,0x00,0}, {0x99,0xff,0x00,0}, {0xcc,0xff,0x00,0}, {0xff,0xff,0x00,0}, | ||
44 | {0x00,0x00,0x33,0}, {0x33,0x00,0x33,0}, {0x66,0x00,0x33,0}, {0x99,0x00,0x33,0}, | ||
45 | {0xcc,0x00,0x33,0}, {0xff,0x00,0x33,0}, {0x00,0x33,0x33,0}, {0x33,0x33,0x33,0}, | ||
46 | {0x66,0x33,0x33,0}, {0x99,0x33,0x33,0}, {0xcc,0x33,0x33,0}, {0xff,0x33,0x33,0}, | ||
47 | {0x00,0x66,0x33,0}, {0x33,0x66,0x33,0}, {0x66,0x66,0x33,0}, {0x99,0x66,0x33,0}, | ||
48 | {0xcc,0x66,0x33,0}, {0xff,0x66,0x33,0}, {0x00,0x99,0x33,0}, {0x33,0x99,0x33,0}, | ||
49 | {0x66,0x99,0x33,0}, {0x99,0x99,0x33,0}, {0xcc,0x99,0x33,0}, {0xff,0x99,0x33,0}, | ||
50 | {0x00,0xcc,0x33,0}, {0x33,0xcc,0x33,0}, {0x66,0xcc,0x33,0}, {0x99,0xcc,0x33,0}, | ||
51 | {0xcc,0xcc,0x33,0}, {0xff,0xcc,0x33,0}, {0x00,0xff,0x33,0}, {0x33,0xff,0x33,0}, | ||
52 | {0x66,0xff,0x33,0}, {0x99,0xff,0x33,0}, {0xcc,0xff,0x33,0}, {0xff,0xff,0x33,0}, | ||
53 | {0x00,0x00,0x66,0}, {0x33,0x00,0x66,0}, {0x66,0x00,0x66,0}, {0x99,0x00,0x66,0}, | ||
54 | {0xcc,0x00,0x66,0}, {0xff,0x00,0x66,0}, {0x00,0x33,0x66,0}, {0x33,0x33,0x66,0}, | ||
55 | {0x66,0x33,0x66,0}, {0x99,0x33,0x66,0}, {0xcc,0x33,0x66,0}, {0xff,0x33,0x66,0}, | ||
56 | {0x00,0x66,0x66,0}, {0x33,0x66,0x66,0}, {0x66,0x66,0x66,0}, {0x99,0x66,0x66,0}, | ||
57 | {0xcc,0x66,0x66,0}, {0xff,0x66,0x66,0}, {0x00,0x99,0x66,0}, {0x33,0x99,0x66,0}, | ||
58 | {0x66,0x99,0x66,0}, {0x99,0x99,0x66,0}, {0xcc,0x99,0x66,0}, {0xff,0x99,0x66,0}, | ||
59 | {0x00,0xcc,0x66,0}, {0x33,0xcc,0x66,0}, {0x66,0xcc,0x66,0}, {0x99,0xcc,0x66,0}, | ||
60 | {0xcc,0xcc,0x66,0}, {0xff,0xcc,0x66,0}, {0x00,0xff,0x66,0}, {0x33,0xff,0x66,0}, | ||
61 | {0x66,0xff,0x66,0}, {0x99,0xff,0x66,0}, {0xcc,0xff,0x66,0}, {0xff,0xff,0x66,0}, | ||
62 | {0x00,0x00,0x99,0}, {0x33,0x00,0x99,0}, {0x66,0x00,0x99,0}, {0x99,0x00,0x99,0}, | ||
63 | {0xcc,0x00,0x99,0}, {0xff,0x00,0x99,0}, {0x00,0x33,0x99,0}, {0x33,0x33,0x99,0}, | ||
64 | {0x66,0x33,0x99,0}, {0x99,0x33,0x99,0}, {0xcc,0x33,0x99,0}, {0xff,0x33,0x99,0}, | ||
65 | {0x00,0x66,0x99,0}, {0x33,0x66,0x99,0}, {0x66,0x66,0x99,0}, {0x99,0x66,0x99,0}, | ||
66 | {0xcc,0x66,0x99,0}, {0xff,0x66,0x99,0}, {0x00,0x99,0x99,0}, {0x33,0x99,0x99,0}, | ||
67 | {0x66,0x99,0x99,0}, {0x99,0x99,0x99,0}, {0xcc,0x99,0x99,0}, {0xff,0x99,0x99,0}, | ||
68 | {0x00,0xcc,0x99,0}, {0x33,0xcc,0x99,0}, {0x66,0xcc,0x99,0}, {0x99,0xcc,0x99,0}, | ||
69 | {0xcc,0xcc,0x99,0}, {0xff,0xcc,0x99,0}, {0x00,0xff,0x99,0}, {0x33,0xff,0x99,0}, | ||
70 | {0x66,0xff,0x99,0}, {0x99,0xff,0x99,0}, {0xcc,0xff,0x99,0}, {0xff,0xff,0x99,0}, | ||
71 | {0x00,0x00,0xcc,0}, {0x33,0x00,0xcc,0}, {0x66,0x00,0xcc,0}, {0x99,0x00,0xcc,0}, | ||
72 | {0xcc,0x00,0xcc,0}, {0xff,0x00,0xcc,0}, {0x00,0x33,0xcc,0}, {0x33,0x33,0xcc,0}, | ||
73 | {0x66,0x33,0xcc,0}, {0x99,0x33,0xcc,0}, {0xcc,0x33,0xcc,0}, {0xff,0x33,0xcc,0}, | ||
74 | {0x00,0x66,0xcc,0}, {0x33,0x66,0xcc,0}, {0x66,0x66,0xcc,0}, {0x99,0x66,0xcc,0}, | ||
75 | {0xcc,0x66,0xcc,0}, {0xff,0x66,0xcc,0}, {0x00,0x99,0xcc,0}, {0x33,0x99,0xcc,0}, | ||
76 | {0x66,0x99,0xcc,0}, {0x99,0x99,0xcc,0}, {0xcc,0x99,0xcc,0}, {0xff,0x99,0xcc,0}, | ||
77 | {0x00,0xcc,0xcc,0}, {0x33,0xcc,0xcc,0}, {0x66,0xcc,0xcc,0}, {0x99,0xcc,0xcc,0}, | ||
78 | {0xcc,0xcc,0xcc,0}, {0xff,0xcc,0xcc,0}, {0x00,0xff,0xcc,0}, {0x33,0xff,0xcc,0}, | ||
79 | {0x66,0xff,0xcc,0}, {0x99,0xff,0xcc,0}, {0xcc,0xff,0xcc,0}, {0xff,0xff,0xcc,0}, | ||
80 | {0x00,0x00,0xff,0}, {0x33,0x00,0xff,0}, {0x66,0x00,0xff,0}, {0x99,0x00,0xff,0}, | ||
81 | {0xcc,0x00,0xff,0}, {0xff,0x00,0xff,0}, {0x00,0x33,0xff,0}, {0x33,0x33,0xff,0}, | ||
82 | {0x66,0x33,0xff,0}, {0x99,0x33,0xff,0}, {0xcc,0x33,0xff,0}, {0xff,0x33,0xff,0}, | ||
83 | {0x00,0x66,0xff,0}, {0x33,0x66,0xff,0}, {0x66,0x66,0xff,0}, {0x99,0x66,0xff,0}, | ||
84 | {0xcc,0x66,0xff,0}, {0xff,0x66,0xff,0}, {0x00,0x99,0xff,0}, {0x33,0x99,0xff,0}, | ||
85 | {0x66,0x99,0xff,0}, {0x99,0x99,0xff,0}, {0xcc,0x99,0xff,0}, {0xff,0x99,0xff,0}, | ||
86 | {0x00,0xcc,0xff,0}, {0x33,0xcc,0xff,0}, {0x66,0xcc,0xff,0}, {0x99,0xcc,0xff,0}, | ||
87 | {0xcc,0xcc,0xff,0}, {0xff,0xcc,0xff,0}, {0x00,0xff,0xff,0}, {0x33,0xff,0xff,0}, | ||
88 | {0x66,0xff,0xff,0}, {0x99,0xff,0xff,0}, {0xcc,0xff,0xff,0}, {0xff,0xff,0xff,0}} | ||
89 | }; /* bitmap information */ | ||
90 | #else | ||
91 | unsigned char bitmap[LCD_HEIGHT][LCD_WIDTH]; /* the ui display */ | ||
28 | RGBQUAD color_zero = {UI_LCD_BGCOLORLIGHT, 0}; | 92 | RGBQUAD color_zero = {UI_LCD_BGCOLORLIGHT, 0}; |
29 | RGBQUAD color_max = {0, 0, 0, 0}; | 93 | RGBQUAD color_max = {0, 0, 0, 0}; |
30 | 94 | ||
@@ -36,12 +100,12 @@ BITMAPINFO256 bmi = | |||
36 | }, | 100 | }, |
37 | {} /* colour lookup table gets filled later */ | 101 | {} /* colour lookup table gets filled later */ |
38 | }; /* bitmap information */ | 102 | }; /* bitmap information */ |
103 | #endif | ||
39 | 104 | ||
40 | #ifdef HAVE_LCD_BITMAP | 105 | #ifdef HAVE_LCD_BITMAP |
41 | 106 | ||
42 | #ifdef HAVE_REMOTE_LCD | 107 | #ifdef HAVE_REMOTE_LCD |
43 | char remote_bitmap[LCD_REMOTE_HEIGHT][LCD_REMOTE_WIDTH]; | 108 | unsigned char remote_bitmap[LCD_REMOTE_HEIGHT][LCD_REMOTE_WIDTH]; |
44 | |||
45 | RGBQUAD remote_color_zero = {UI_REMOTE_BGCOLORLIGHT, 0}; | 109 | RGBQUAD remote_color_zero = {UI_REMOTE_BGCOLORLIGHT, 0}; |
46 | RGBQUAD remote_color_max = {0, 0, 0, 0}; | 110 | RGBQUAD remote_color_max = {0, 0, 0, 0}; |
47 | 111 | ||
@@ -55,12 +119,6 @@ BITMAPINFO256 remote_bmi = | |||
55 | }; | 119 | }; |
56 | #endif | 120 | #endif |
57 | 121 | ||
58 | #if LCD_DEPTH == 1 | ||
59 | extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH]; /* the display */ | ||
60 | #elif LCD_DEPTH == 2 | ||
61 | extern unsigned char lcd_framebuffer[LCD_HEIGHT/4][LCD_WIDTH]; /* the display */ | ||
62 | #endif | ||
63 | |||
64 | void lcd_update(void) | 122 | void lcd_update(void) |
65 | { | 123 | { |
66 | int x, y; | 124 | int x, y; |
@@ -71,11 +129,19 @@ void lcd_update(void) | |||
71 | 129 | ||
72 | for (x = 0; x < LCD_WIDTH; x++) | 130 | for (x = 0; x < LCD_WIDTH; x++) |
73 | for (y = 0; y < LCD_HEIGHT; y++) | 131 | for (y = 0; y < LCD_HEIGHT; y++) |
132 | { | ||
74 | #if LCD_DEPTH == 1 | 133 | #if LCD_DEPTH == 1 |
75 | bitmap[y][x] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1); | 134 | bitmap[y][x] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1); |
76 | #elif LCD_DEPTH == 2 | 135 | #elif LCD_DEPTH == 2 |
77 | bitmap[y][x] = ((lcd_framebuffer[y/4][x] >> (2 * (y & 3))) & 3); | 136 | bitmap[y][x] = ((lcd_framebuffer[y/4][x] >> (2 * (y & 3))) & 3); |
137 | #elif LCD_DEPTH == 16 | ||
138 | fb_data pixel = lcd_framebuffer[y][x]; | ||
139 | unsigned red = ((pixel >> 8) & 0xf8) | (pixel >> 13); | ||
140 | unsigned green = ((pixel >> 3) & 0xfc) | ((pixel >> 9) & 0x03); | ||
141 | unsigned blue = ((pixel << 3) & 0xf8) | ((pixel >> 2) & 0x07); | ||
142 | bitmap[y][x] = (red << 16) | (green << 8) | blue; | ||
78 | #endif | 143 | #endif |
144 | } | ||
79 | 145 | ||
80 | /* Invalidate only the window part that actually did change */ | 146 | /* Invalidate only the window part that actually did change */ |
81 | GetClientRect (hGUIWnd, &r); | 147 | GetClientRect (hGUIWnd, &r); |
@@ -106,11 +172,19 @@ void lcd_update_rect(int x_start, int y_start, | |||
106 | 172 | ||
107 | for (x = x_start; x < xmax; x++) | 173 | for (x = x_start; x < xmax; x++) |
108 | for (y = y_start; y < ymax; y++) | 174 | for (y = y_start; y < ymax; y++) |
175 | { | ||
109 | #if LCD_DEPTH == 1 | 176 | #if LCD_DEPTH == 1 |
110 | bitmap[y][x] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1); | 177 | bitmap[y][x] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1); |
111 | #elif LCD_DEPTH == 2 | 178 | #elif LCD_DEPTH == 2 |
112 | bitmap[y][x] = ((lcd_framebuffer[y/4][x] >> (2 * (y & 3))) & 3); | 179 | bitmap[y][x] = ((lcd_framebuffer[y/4][x] >> (2 * (y & 3))) & 3); |
180 | #elif LCD_DEPTH == 16 | ||
181 | fb_data pixel = lcd_framebuffer[y][x]; | ||
182 | unsigned red = ((pixel >> 8) & 0xf8) | (pixel >> 13); | ||
183 | unsigned green = ((pixel >> 3) & 0xfc) | ((pixel >> 9) & 0x03); | ||
184 | unsigned blue = ((pixel << 3) & 0xf8) | ((pixel >> 2) & 0x07); | ||
185 | bitmap[y][x] = (red << 16) | (green << 8) | blue; | ||
113 | #endif | 186 | #endif |
187 | } | ||
114 | 188 | ||
115 | /* Invalidate only the window part that actually did change */ | 189 | /* Invalidate only the window part that actually did change */ |
116 | GetClientRect (hGUIWnd, &r); | 190 | GetClientRect (hGUIWnd, &r); |
@@ -272,6 +346,7 @@ void lcd_backlight (bool on) | |||
272 | } | 346 | } |
273 | #endif | 347 | #endif |
274 | 348 | ||
349 | #if LCD_DEPTH <= 8 | ||
275 | /* set a range of bitmap indices to a gradient from startcolour to endcolour */ | 350 | /* set a range of bitmap indices to a gradient from startcolour to endcolour */ |
276 | void lcdcolors(int index, int count, RGBQUAD *start, RGBQUAD *end) | 351 | void lcdcolors(int index, int count, RGBQUAD *start, RGBQUAD *end) |
277 | { | 352 | { |
@@ -291,6 +366,7 @@ void lcdcolors(int index, int count, RGBQUAD *start, RGBQUAD *end) | |||
291 | + (end->rgbBlue - start->rgbBlue) * i / count; | 366 | + (end->rgbBlue - start->rgbBlue) * i / count; |
292 | } | 367 | } |
293 | } | 368 | } |
369 | #endif | ||
294 | 370 | ||
295 | #ifdef HAVE_REMOTE_LCD | 371 | #ifdef HAVE_REMOTE_LCD |
296 | /* set a range of bitmap indices to a gradient from startcolour to endcolour */ | 372 | /* set a range of bitmap indices to a gradient from startcolour to endcolour */ |
@@ -317,7 +393,9 @@ void lcdremotecolors(int index, int count, RGBQUAD *start, RGBQUAD *end) | |||
317 | /* initialise simulator lcd driver */ | 393 | /* initialise simulator lcd driver */ |
318 | void simlcdinit(void) | 394 | void simlcdinit(void) |
319 | { | 395 | { |
396 | #if LCD_DEPTH <= 8 | ||
320 | lcdcolors(0, (1<<LCD_DEPTH), &color_zero, &color_max); | 397 | lcdcolors(0, (1<<LCD_DEPTH), &color_zero, &color_max); |
398 | #endif | ||
321 | #ifdef HAVE_REMOTE_LCD | 399 | #ifdef HAVE_REMOTE_LCD |
322 | lcdremotecolors(0, (1<<LCD_REMOTE_DEPTH), &remote_color_zero, &remote_color_max); | 400 | lcdremotecolors(0, (1<<LCD_REMOTE_DEPTH), &remote_color_zero, &remote_color_max); |
323 | #endif | 401 | #endif |