summaryrefslogtreecommitdiff
path: root/uisimulator/win32/lcd-win32.c
diff options
context:
space:
mode:
Diffstat (limited to 'uisimulator/win32/lcd-win32.c')
-rw-r--r--uisimulator/win32/lcd-win32.c326
1 files changed, 0 insertions, 326 deletions
diff --git a/uisimulator/win32/lcd-win32.c b/uisimulator/win32/lcd-win32.c
deleted file mode 100644
index 8afd025a16..0000000000
--- a/uisimulator/win32/lcd-win32.c
+++ /dev/null
@@ -1,326 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Felix Arends
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include <windows.h>
21#include <process.h>
22#include "uisw32.h"
23#include "lcd.h"
24#include "lcd-playersim.h"
25#include "debug.h"
26
27#if LCD_DEPTH == 16
28unsigned short bitmap[LCD_HEIGHT][LCD_WIDTH]; /* the ui display */
29
30BITMAPINFO256 bmi =
31{
32 {sizeof (BITMAPINFOHEADER),
33 LCD_WIDTH, -LCD_HEIGHT, 1, 16,
34 BI_BITFIELDS, 0, 0, 0, 3, 3,
35 }, /* bitfield masks (RGB565) */
36 {{0x00, 0xf8, 0, 0}, {0xe0, 0x07, 0, 0}, {0x1f, 0x00, 0, 0}}
37}; /* bitmap information */
38#else
39unsigned char bitmap[LCD_HEIGHT][LCD_WIDTH]; /* the ui display */
40RGBQUAD color_zero = {UI_LCD_BGCOLORLIGHT, 0};
41RGBQUAD color_max = {0, 0, 0, 0};
42
43BITMAPINFO256 bmi =
44{
45 {sizeof (BITMAPINFOHEADER),
46 LCD_WIDTH, -LCD_HEIGHT, 1, 8,
47 BI_RGB, 0, 0, 0, 2, 2,
48 },
49 {} /* colour lookup table gets filled later */
50}; /* bitmap information */
51#endif
52
53#ifdef HAVE_LCD_BITMAP
54
55#ifdef HAVE_REMOTE_LCD
56unsigned char remote_bitmap[LCD_REMOTE_HEIGHT][LCD_REMOTE_WIDTH];
57RGBQUAD remote_color_zero = {UI_REMOTE_BGCOLORLIGHT, 0};
58RGBQUAD remote_color_max = {0, 0, 0, 0};
59
60BITMAPINFO256 remote_bmi =
61{
62 {sizeof (BITMAPINFOHEADER),
63 LCD_REMOTE_WIDTH, -LCD_REMOTE_HEIGHT, 1, 8,
64 BI_RGB, 0, 0, 0, 2, 2,
65 },
66 {} /* colour lookup table gets filled later */
67};
68#endif
69
70void lcd_update(void)
71{
72 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
73}
74
75void lcd_update_rect(int x_start, int y_start,
76 int width, int height)
77{
78 int x, y;
79 int xmax, ymax;
80 RECT r;
81
82 ymax = y_start + height;
83 xmax = x_start + width;
84
85 if (hGUIWnd == NULL)
86 _endthread ();
87
88 if(xmax > LCD_WIDTH)
89 xmax = LCD_WIDTH;
90 if(ymax >= LCD_HEIGHT)
91 ymax = LCD_HEIGHT;
92
93 for (x = x_start; x < xmax; x++)
94 for (y = y_start; y < ymax; y++)
95 {
96#if LCD_DEPTH == 1
97 bitmap[y][x] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1);
98#elif LCD_DEPTH == 2
99#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
100 bitmap[y][x] = ((lcd_framebuffer[y][x/4] >> (2 * (x & 3))) & 3);
101#else
102 bitmap[y][x] = ((lcd_framebuffer[y/4][x] >> (2 * (y & 3))) & 3);
103#endif
104#elif LCD_DEPTH == 16
105#if LCD_PIXELFORMAT == RGB565SWAPPED
106 unsigned bits = lcd_framebuffer[y][x];
107 bitmap[y][x] = (bits >> 8) | (bits << 8);
108#else
109 bitmap[y][x] = lcd_framebuffer[y][x];
110#endif
111#endif
112 }
113
114 /* Invalidate only the window part that actually did change */
115 GetClientRect (hGUIWnd, &r);
116 r.left = (UI_LCD_POSX + (UI_LCD_WIDTH * x_start / LCD_WIDTH))
117 * r.right / UI_WIDTH;
118 r.top = (UI_LCD_POSY + (UI_LCD_HEIGHT * y_start / LCD_HEIGHT))
119 * r.bottom / UI_HEIGHT;
120 r.right = (UI_LCD_POSX + (UI_LCD_WIDTH * xmax / LCD_WIDTH))
121 * r.right / UI_WIDTH;
122 r.bottom = (UI_LCD_POSY + (UI_LCD_HEIGHT * ymax / LCD_HEIGHT))
123 * r.bottom / UI_HEIGHT;
124 InvalidateRect (hGUIWnd, &r, FALSE);
125}
126
127#ifdef HAVE_REMOTE_LCD
128
129extern unsigned char lcd_remote_framebuffer[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH];
130
131void lcd_remote_update (void)
132{
133 lcd_remote_update_rect(0, 0, LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT);
134}
135
136void lcd_remote_update_rect(int x_start, int y_start,
137 int width, int height)
138{
139 int x, y;
140 int xmax, ymax;
141 RECT r;
142
143 ymax = y_start + height;
144 xmax = x_start + width;
145
146 if (hGUIWnd == NULL)
147 _endthread ();
148
149 if(xmax > LCD_REMOTE_WIDTH)
150 xmax = LCD_REMOTE_WIDTH;
151 if(ymax >= LCD_REMOTE_HEIGHT)
152 ymax = LCD_REMOTE_HEIGHT;
153
154 for (x = x_start; x < xmax; x++)
155 for (y = y_start; y < ymax; y++)
156 remote_bitmap[y][x] = ((lcd_remote_framebuffer[y/8][x] >> (y & 7)) & 1);
157
158 /* Invalidate only the window part that actually did change */
159 GetClientRect (hGUIWnd, &r);
160 r.left = (UI_REMOTE_POSX + (UI_REMOTE_WIDTH * x_start / LCD_REMOTE_WIDTH))
161 * r.right / UI_WIDTH;
162 r.top = (UI_REMOTE_POSY + (UI_REMOTE_HEIGHT * y_start / LCD_REMOTE_HEIGHT))
163 * r.bottom / UI_HEIGHT;
164 r.right = (UI_REMOTE_POSX + (UI_REMOTE_WIDTH * xmax / LCD_REMOTE_WIDTH))
165 * r.right / UI_WIDTH;
166 r.bottom = (UI_REMOTE_POSY + (UI_REMOTE_HEIGHT * ymax / LCD_REMOTE_HEIGHT))
167 * r.bottom / UI_HEIGHT;
168 InvalidateRect (hGUIWnd, &r, FALSE);
169}
170
171#endif /* HAVE_REMOTE_LCD */
172#endif /* HAVE_LCD_BITMAP */
173
174#ifdef HAVE_LCD_CHARCELLS
175/* Defined in lcd-playersim.c */
176extern void lcd_print_char(int x, int y);
177extern bool lcd_display_redraw;
178extern unsigned char hardware_buffer_lcd[11][2];
179static unsigned char lcd_buffer_copy[11][2];
180
181void lcd_update(void)
182{
183 int x, y;
184 bool changed = false;
185 RECT r;
186
187 if (hGUIWnd == NULL)
188 _endthread ();
189
190 for (y = 0; y < 2; y++)
191 {
192 for (x = 0; x < 11; x++)
193 {
194 if (lcd_display_redraw ||
195 lcd_buffer_copy[x][y] != hardware_buffer_lcd[x][y])
196 {
197 lcd_buffer_copy[x][y] = hardware_buffer_lcd[x][y];
198 lcd_print_char(x, y);
199 changed = true;
200 }
201 }
202 }
203 if (changed)
204 {
205 /* Invalidate only the window part that actually did change */
206 GetClientRect (hGUIWnd, &r);
207 r.left = UI_LCD_POSX * r.right / UI_WIDTH;
208 r.top = UI_LCD_POSY * r.bottom / UI_HEIGHT;
209 r.right = (UI_LCD_POSX + UI_LCD_WIDTH) * r.right / UI_WIDTH;
210 r.bottom = (UI_LCD_POSY + UI_LCD_HEIGHT) * r.bottom / UI_HEIGHT;
211 InvalidateRect (hGUIWnd, &r, FALSE);
212 }
213 lcd_display_redraw = false;
214}
215
216void drawdots(int color, struct coordinate *points, int count)
217{
218 while (count--)
219 {
220 bitmap[points[count].y][points[count].x] = color;
221 }
222}
223
224void drawrectangles(int color, struct rectangle *points, int count)
225{
226 while (count--)
227 {
228 int x;
229 int y;
230 int ix;
231 int iy;
232
233 for (x = points[count].x, ix = 0; ix < points[count].width; x++, ix++)
234 {
235 for (y = points[count].y, iy = 0; iy < points[count].height; y++, iy++)
236 {
237 bitmap[y][x] = color;
238 }
239 }
240 }
241}
242#endif /* HAVE_LCD_CHARCELLS */
243
244#if 0
245/* set backlight state of lcd */
246void lcd_backlight (bool on)
247{
248 if (on)
249 color_zero = {UI_LCD_BGCOLORLIGHT, 0};
250 else
251 color_zero = {UI_LCD_BGCOLOR, 0};
252
253 lcdcolors(0, (1<<LCD_DEPTH), &color_zero, &color_max);
254 InvalidateRect (hGUIWnd, NULL, FALSE);
255}
256#endif
257
258#if LCD_DEPTH <= 8
259/* set a range of bitmap indices to a gradient from startcolour to endcolour */
260void lcdcolors(int index, int count, RGBQUAD *start, RGBQUAD *end)
261{
262 int i;
263
264 bmi.bmiHeader.biClrUsed = index + count;
265 bmi.bmiHeader.biClrImportant = index + count;
266
267 count--;
268 for (i = 0; i <= count; i++)
269 {
270 bmi.bmiColors[i+index].rgbRed = start->rgbRed
271 + (end->rgbRed - start->rgbRed) * i / count;
272 bmi.bmiColors[i+index].rgbGreen = start->rgbGreen
273 + (end->rgbGreen - start->rgbGreen) * i / count;
274 bmi.bmiColors[i+index].rgbBlue = start->rgbBlue
275 + (end->rgbBlue - start->rgbBlue) * i / count;
276 }
277}
278#endif
279
280#ifdef HAVE_REMOTE_LCD
281/* set a range of bitmap indices to a gradient from startcolour to endcolour */
282void lcdremotecolors(int index, int count, RGBQUAD *start, RGBQUAD *end)
283{
284 int i;
285
286 remote_bmi.bmiHeader.biClrUsed = index + count;
287 remote_bmi.bmiHeader.biClrImportant = index + count;
288
289 count--;
290 for (i = 0; i <= count; i++)
291 {
292 remote_bmi.bmiColors[i+index].rgbRed = start->rgbRed
293 + (end->rgbRed - start->rgbRed) * i / count;
294 remote_bmi.bmiColors[i+index].rgbGreen = start->rgbGreen
295 + (end->rgbGreen - start->rgbGreen) * i / count;
296 remote_bmi.bmiColors[i+index].rgbBlue = start->rgbBlue
297 + (end->rgbBlue - start->rgbBlue) * i / count;
298 }
299}
300#endif
301
302/* initialise simulator lcd driver */
303void simlcdinit(void)
304{
305#if LCD_DEPTH <= 8
306 lcdcolors(0, (1<<LCD_DEPTH), &color_zero, &color_max);
307#endif
308#ifdef HAVE_REMOTE_LCD
309 lcdremotecolors(0, (1<<LCD_REMOTE_DEPTH), &remote_color_zero, &remote_color_max);
310#endif
311}
312
313#ifdef CONFIG_BACKLIGHT
314void sim_backlight(int value)
315{
316 DEBUGF("backlight: %s\n", (value > 0) ? "on" : "off");
317}
318#endif
319
320#ifdef HAVE_REMOTE_LCD
321void sim_remote_backlight(int value)
322{
323 DEBUGF("remote backlight: %s\n", (value > 0) ? "on" : "off");
324}
325#endif
326