summaryrefslogtreecommitdiff
path: root/uisimulator/win32
diff options
context:
space:
mode:
Diffstat (limited to 'uisimulator/win32')
-rw-r--r--uisimulator/win32/lcd-win32.c161
-rw-r--r--uisimulator/win32/lcd-win32.h20
-rw-r--r--uisimulator/win32/uisw32.c2
3 files changed, 107 insertions, 76 deletions
diff --git a/uisimulator/win32/lcd-win32.c b/uisimulator/win32/lcd-win32.c
index ef85214e8f..11296884b7 100644
--- a/uisimulator/win32/lcd-win32.c
+++ b/uisimulator/win32/lcd-win32.c
@@ -23,33 +23,28 @@
23#include "lcd.h" 23#include "lcd.h"
24#include "lcd-playersim.h" 24#include "lcd-playersim.h"
25 25
26unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH]; /* the display */
27char bitmap[LCD_HEIGHT][LCD_WIDTH]; /* the ui display */ 26char bitmap[LCD_HEIGHT][LCD_WIDTH]; /* the ui display */
28 27
29BITMAPINFO2 bmi = 28RGBQUAD color_zero = {UI_LCD_BGCOLORLIGHT, 0};
29RGBQUAD color_max = {0, 0, 0, 0};
30
31BITMAPINFO256 bmi =
30{ 32{
31 {sizeof (BITMAPINFOHEADER), 33 {sizeof (BITMAPINFOHEADER),
32 LCD_WIDTH, -LCD_HEIGHT, 1, 8, 34 LCD_WIDTH, -LCD_HEIGHT, 1, 8,
33 BI_RGB, 0, 0, 0, 2, 2, 35 BI_RGB, 0, 0, 0, 2, 2,
34 }, 36 },
35 { 37 {} /* colour lookup table gets filled later */
36 //{UI_LCD_BGCOLOR, 0}, /* green background color */
37 {UI_LCD_BGCOLORLIGHT, 0}, /* green background color */
38 {UI_LCD_BLACK, 0} /* black color */
39 }
40
41}; /* bitmap information */ 38}; /* bitmap information */
42 39
43#ifdef HAVE_LCD_CHARCELLS 40#ifdef HAVE_LCD_BITMAP
44/* Defined in lcd-playersim.c */ 41
45extern void lcd_print_char(int x, int y); 42#if LCD_DEPTH == 1
46extern bool lcd_display_redraw; 43extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH]; /* the display */
47extern unsigned char hardware_buffer_lcd[11][2]; 44#elif LCD_DEPTH == 2
48static unsigned char lcd_buffer_copy[11][2]; 45extern unsigned char lcd_framebuffer[LCD_HEIGHT/4][LCD_WIDTH]; /* the display */
49#endif 46#endif
50 47
51/* lcd_update()
52 update lcd */
53void lcd_update() 48void lcd_update()
54{ 49{
55 int x, y; 50 int x, y;
@@ -58,26 +53,13 @@ void lcd_update()
58 if (hGUIWnd == NULL) 53 if (hGUIWnd == NULL)
59 _endthread (); 54 _endthread ();
60 55
61#ifdef HAVE_LCD_CHARCELLS
62 for (y = 0; y < 2; y++)
63 {
64 for (x = 0; x < 11; x++)
65 {
66 if (lcd_display_redraw ||
67 lcd_buffer_copy[x][y] != hardware_buffer_lcd[x][y])
68 {
69 lcd_buffer_copy[x][y] = hardware_buffer_lcd[x][y];
70 lcd_print_char(x, y);
71 }
72 }
73 }
74
75 lcd_display_redraw = false;
76#endif
77
78 for (x = 0; x < LCD_WIDTH; x++) 56 for (x = 0; x < LCD_WIDTH; x++)
79 for (y = 0; y < LCD_HEIGHT; y++) 57 for (y = 0; y < LCD_HEIGHT; y++)
58#if LCD_DEPTH == 1
80 bitmap[y][x] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1); 59 bitmap[y][x] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1);
60#elif LCD_DEPTH == 2
61 bitmap[y][x] = ((lcd_framebuffer[y/4][x] >> (2 * (y & 3))) & 3);
62#endif
81 63
82 /* Invalidate only the window part that actually did change */ 64 /* Invalidate only the window part that actually did change */
83 GetClientRect (hGUIWnd, &r); 65 GetClientRect (hGUIWnd, &r);
@@ -108,7 +90,11 @@ void lcd_update_rect(int x_start, int y_start,
108 90
109 for (x = x_start; x < xmax; x++) 91 for (x = x_start; x < xmax; x++)
110 for (y = y_start; y < ymax; y++) 92 for (y = y_start; y < ymax; y++)
93#if LCD_DEPTH == 1
111 bitmap[y][x] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1); 94 bitmap[y][x] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1);
95#elif LCD_DEPTH == 2
96 bitmap[y][x] = ((lcd_framebuffer[y/4][x] >> (2 * (y & 3))) & 3);
97#endif
112 98
113 /* Invalidate only the window part that actually did change */ 99 /* Invalidate only the window part that actually did change */
114 GetClientRect (hGUIWnd, &r); 100 GetClientRect (hGUIWnd, &r);
@@ -136,37 +122,55 @@ void lcd_remote_update_rect(int x_start, int y_start,
136 (void)width; 122 (void)width;
137 (void)height; 123 (void)height;
138} 124}
125#endif /* HAVE_LCD_BITMAP */
139 126
140/* lcd_backlight() 127#ifdef HAVE_LCD_CHARCELLS
141 set backlight state of lcd */ 128/* Defined in lcd-playersim.c */
142void lcd_backlight (bool on) 129extern void lcd_print_char(int x, int y);
130extern bool lcd_display_redraw;
131extern unsigned char hardware_buffer_lcd[11][2];
132static unsigned char lcd_buffer_copy[11][2];
133
134void lcd_update()
143{ 135{
144 if (on) 136 int x, y;
137 bool changed = false;
138 RECT r;
139
140 if (hGUIWnd == NULL)
141 _endthread ();
142
143 for (y = 0; y < 2; y++)
145 { 144 {
146 RGBQUAD blon = {UI_LCD_BGCOLORLIGHT, 0}; 145 for (x = 0; x < 11; x++)
147 bmi.bmiColors[0] = blon; 146 {
147 if (lcd_display_redraw ||
148 lcd_buffer_copy[x][y] != hardware_buffer_lcd[x][y])
149 {
150 lcd_buffer_copy[x][y] = hardware_buffer_lcd[x][y];
151 lcd_print_char(x, y);
152 changed = true;
153 }
154 }
148 } 155 }
149 else 156 if (changed)
150 { 157 {
151 RGBQUAD blon = {UI_LCD_BGCOLOR, 0}; 158 /* Invalidate only the window part that actually did change */
152 bmi.bmiColors[0] = blon; 159 GetClientRect (hGUIWnd, &r);
160 r.left = UI_LCD_POSX * r.right / UI_WIDTH;
161 r.top = UI_LCD_POSY * r.bottom / UI_HEIGHT;
162 r.right = (UI_LCD_POSX + UI_LCD_WIDTH) * r.right / UI_WIDTH;
163 r.bottom = (UI_LCD_POSY + UI_LCD_HEIGHT) * r.bottom / UI_HEIGHT;
164 InvalidateRect (hGUIWnd, &r, FALSE);
153 } 165 }
154 166 lcd_display_redraw = false;
155 InvalidateRect (hGUIWnd, NULL, FALSE);
156} 167}
157 168
158void drawdots(int color, struct coordinate *points, int count) 169void drawdots(int color, struct coordinate *points, int count)
159{ 170{
160 while (count--) 171 while (count--)
161 { 172 {
162 if (color) 173 bitmap[points[count].y][points[count].x] = color;
163 {
164 DRAW_PIXEL(points[count].x, points[count].y);
165 }
166 else
167 {
168 CLEAR_PIXEL(points[count].x, points[count].y);
169 }
170 } 174 }
171} 175}
172 176
@@ -181,17 +185,50 @@ void drawrectangles(int color, struct rectangle *points, int count)
181 185
182 for (x = points[count].x, ix = 0; ix < points[count].width; x++, ix++) 186 for (x = points[count].x, ix = 0; ix < points[count].width; x++, ix++)
183 { 187 {
184 for (y = points[count].y, iy = 0; iy < points[count].width; y++, iy++) 188 for (y = points[count].y, iy = 0; iy < points[count].height; y++, iy++)
185 { 189 {
186 if (color) 190 bitmap[y][x] = color;
187 {
188 DRAW_PIXEL(x, y);
189 }
190 else
191 {
192 CLEAR_PIXEL(x, y);
193 }
194 } 191 }
195 } 192 }
196 } 193 }
197} 194}
195#endif /* HAVE_LCD_CHARCELLS */
196
197#if 0
198/* set backlight state of lcd */
199void lcd_backlight (bool on)
200{
201 if (on)
202 color_zero = {UI_LCD_BGCOLORLIGHT, 0};
203 else
204 color_zero = {UI_LCD_BGCOLOR, 0};
205
206 lcdcolors(0, (1<<LCD_DEPTH), &color_zero, &color_max);
207 InvalidateRect (hGUIWnd, NULL, FALSE);
208}
209#endif
210
211/* set a range of bitmap indices to a gradient from startcolour to endcolour */
212void lcdcolors(int index, int count, RGBQUAD *start, RGBQUAD *end)
213{
214 int i;
215 count--;
216 for (i = 0; i <= count; i++)
217 {
218 bmi.bmiColors[i+index].rgbRed = start->rgbRed
219 + (end->rgbRed - start->rgbRed) * i / count;
220 bmi.bmiColors[i+index].rgbGreen = start->rgbGreen
221 + (end->rgbGreen - start->rgbGreen) * i / count;
222 bmi.bmiColors[i+index].rgbBlue = start->rgbBlue
223 + (end->rgbBlue - start->rgbBlue) * i / count;
224 }
225}
226
227/* initialise simulator lcd driver */
228void simlcdinit(void)
229{
230 bmi.bmiHeader.biClrUsed = (1<<LCD_DEPTH);
231 bmi.bmiHeader.biClrImportant = (1<<LCD_DEPTH);
232 lcdcolors(0, (1<<LCD_DEPTH), &color_zero, &color_max);
233}
234
diff --git a/uisimulator/win32/lcd-win32.h b/uisimulator/win32/lcd-win32.h
index d2627e6a53..26a47208e5 100644
--- a/uisimulator/win32/lcd-win32.h
+++ b/uisimulator/win32/lcd-win32.h
@@ -23,24 +23,16 @@
23#include "uisw32.h" 23#include "uisw32.h"
24#include "lcd.h" 24#include "lcd.h"
25 25
26// BITMAPINFO2 26// BITMAPINFO256
27typedef struct 27typedef struct
28{ 28{
29 BITMAPINFOHEADER bmiHeader; 29 BITMAPINFOHEADER bmiHeader;
30 RGBQUAD bmiColors[2]; 30 RGBQUAD bmiColors[256];
31} BITMAPINFO2; 31} BITMAPINFO256;
32 32
33#ifdef HAVE_LCD_BITMAP 33extern char bitmap[LCD_HEIGHT][LCD_WIDTH]; // the ui display
34 34extern BITMAPINFO256 bmi; // bitmap information
35extern unsigned char display[LCD_WIDTH][LCD_HEIGHT/8]; // the display
36#else
37#define DISP_X 112
38#define DISP_Y 64
39#endif
40
41
42extern char bitmap[LCD_HEIGHT][LCD_WIDTH]; // the ui display
43extern BITMAPINFO2 bmi; // bitmap information
44 35
36void simlcdinit(void);
45 37
46#endif // #ifndef __LCDWIN32_H__ 38#endif // #ifndef __LCDWIN32_H__
diff --git a/uisimulator/win32/uisw32.c b/uisimulator/win32/uisw32.c
index 9401153408..fb581c0cf1 100644
--- a/uisimulator/win32/uisw32.c
+++ b/uisimulator/win32/uisw32.c
@@ -239,6 +239,8 @@ BOOL GUIStartup ()
239 239
240 if (hGUIWnd == NULL) 240 if (hGUIWnd == NULL)
241 return FALSE; 241 return FALSE;
242
243 simlcdinit();
242 244
243 return TRUE; 245 return TRUE;
244} 246}