1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Felix Arends
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
24 #include "lcd-playersim.h"
27 unsigned short bitmap
[LCD_HEIGHT
][LCD_WIDTH
]; /* the ui display */
31 {sizeof (BITMAPINFOHEADER
),
32 LCD_WIDTH
, -LCD_HEIGHT
, 1, 16,
33 BI_BITFIELDS
, 0, 0, 0, 3, 3,
34 }, /* bitfield masks (RGB565) */
35 {{0x00, 0xf8, 0, 0}, {0xe0, 0x07, 0, 0}, {0x1f, 0x00, 0, 0}}
36 }; /* bitmap information */
38 unsigned char bitmap
[LCD_HEIGHT
][LCD_WIDTH
]; /* the ui display */
39 RGBQUAD color_zero
= {UI_LCD_BGCOLORLIGHT
, 0};
40 RGBQUAD color_max
= {0, 0, 0, 0};
44 {sizeof (BITMAPINFOHEADER
),
45 LCD_WIDTH
, -LCD_HEIGHT
, 1, 8,
46 BI_RGB
, 0, 0, 0, 2, 2,
48 {} /* colour lookup table gets filled later */
49 }; /* bitmap information */
52 #ifdef HAVE_LCD_BITMAP
54 #ifdef HAVE_REMOTE_LCD
55 unsigned char remote_bitmap
[LCD_REMOTE_HEIGHT
][LCD_REMOTE_WIDTH
];
56 RGBQUAD remote_color_zero
= {UI_REMOTE_BGCOLORLIGHT
, 0};
57 RGBQUAD remote_color_max
= {0, 0, 0, 0};
59 BITMAPINFO256 remote_bmi
=
61 {sizeof (BITMAPINFOHEADER
),
62 LCD_REMOTE_WIDTH
, -LCD_REMOTE_HEIGHT
, 1, 8,
63 BI_RGB
, 0, 0, 0, 2, 2,
65 {} /* colour lookup table gets filled later */
71 lcd_update_rect(0, 0, LCD_WIDTH
, LCD_HEIGHT
);
74 void lcd_update_rect(int x_start
, int y_start
,
75 int width
, int height
)
81 ymax
= y_start
+ height
;
82 xmax
= x_start
+ width
;
89 if(ymax
>= LCD_HEIGHT
)
92 for (x
= x_start
; x
< xmax
; x
++)
93 for (y
= y_start
; y
< ymax
; y
++)
96 bitmap
[y
][x
] = ((lcd_framebuffer
[y
/8][x
] >> (y
& 7)) & 1);
98 #if LCD_PIXELFORMAT == HORIZONTAL_PACKING
99 bitmap
[y
][x
] = ((lcd_framebuffer
[y
][x
/4] >> (2 * (x
& 3))) & 3);
101 bitmap
[y
][x
] = ((lcd_framebuffer
[y
/4][x
] >> (2 * (y
& 3))) & 3);
103 #elif LCD_DEPTH == 16
104 #if LCD_PIXELFORMAT == RGB565SWAPPED
105 unsigned bits
= lcd_framebuffer
[y
][x
];
106 bitmap
[y
][x
] = (bits
>> 8) | (bits
<< 8);
108 bitmap
[y
][x
] = lcd_framebuffer
[y
][x
];
113 /* Invalidate only the window part that actually did change */
114 GetClientRect (hGUIWnd
, &r
);
115 r
.left
= (UI_LCD_POSX
+ (UI_LCD_WIDTH
* x_start
/ LCD_WIDTH
))
116 * r
.right
/ UI_WIDTH
;
117 r
.top
= (UI_LCD_POSY
+ (UI_LCD_HEIGHT
* y_start
/ LCD_HEIGHT
))
118 * r
.bottom
/ UI_HEIGHT
;
119 r
.right
= (UI_LCD_POSX
+ (UI_LCD_WIDTH
* xmax
/ LCD_WIDTH
))
120 * r
.right
/ UI_WIDTH
;
121 r
.bottom
= (UI_LCD_POSY
+ (UI_LCD_HEIGHT
* ymax
/ LCD_HEIGHT
))
122 * r
.bottom
/ UI_HEIGHT
;
123 InvalidateRect (hGUIWnd
, &r
, FALSE
);
126 #ifdef HAVE_REMOTE_LCD
128 extern unsigned char lcd_remote_framebuffer
[LCD_REMOTE_HEIGHT
/8][LCD_REMOTE_WIDTH
];
130 void lcd_remote_update (void)
132 lcd_remote_update_rect(0, 0, LCD_REMOTE_WIDTH
, LCD_REMOTE_HEIGHT
);
135 void lcd_remote_update_rect(int x_start
, int y_start
,
136 int width
, int height
)
142 ymax
= y_start
+ height
;
143 xmax
= x_start
+ width
;
148 if(xmax
> LCD_REMOTE_WIDTH
)
149 xmax
= LCD_REMOTE_WIDTH
;
150 if(ymax
>= LCD_REMOTE_HEIGHT
)
151 ymax
= LCD_REMOTE_HEIGHT
;
153 for (x
= x_start
; x
< xmax
; x
++)
154 for (y
= y_start
; y
< ymax
; y
++)
155 remote_bitmap
[y
][x
] = ((lcd_remote_framebuffer
[y
/8][x
] >> (y
& 7)) & 1);
157 /* Invalidate only the window part that actually did change */
158 GetClientRect (hGUIWnd
, &r
);
159 r
.left
= (UI_REMOTE_POSX
+ (UI_REMOTE_WIDTH
* x_start
/ LCD_REMOTE_WIDTH
))
160 * r
.right
/ UI_WIDTH
;
161 r
.top
= (UI_REMOTE_POSY
+ (UI_REMOTE_HEIGHT
* y_start
/ LCD_REMOTE_HEIGHT
))
162 * r
.bottom
/ UI_HEIGHT
;
163 r
.right
= (UI_REMOTE_POSX
+ (UI_REMOTE_WIDTH
* xmax
/ LCD_REMOTE_WIDTH
))
164 * r
.right
/ UI_WIDTH
;
165 r
.bottom
= (UI_REMOTE_POSY
+ (UI_REMOTE_HEIGHT
* ymax
/ LCD_REMOTE_HEIGHT
))
166 * r
.bottom
/ UI_HEIGHT
;
167 InvalidateRect (hGUIWnd
, &r
, FALSE
);
170 #endif /* HAVE_REMOTE_LCD */
171 #endif /* HAVE_LCD_BITMAP */
173 #ifdef HAVE_LCD_CHARCELLS
174 /* Defined in lcd-playersim.c */
175 extern void lcd_print_char(int x
, int y
);
176 extern bool lcd_display_redraw
;
177 extern unsigned char hardware_buffer_lcd
[11][2];
178 static unsigned char lcd_buffer_copy
[11][2];
180 void lcd_update(void)
183 bool changed
= false;
189 for (y
= 0; y
< 2; y
++)
191 for (x
= 0; x
< 11; x
++)
193 if (lcd_display_redraw
||
194 lcd_buffer_copy
[x
][y
] != hardware_buffer_lcd
[x
][y
])
196 lcd_buffer_copy
[x
][y
] = hardware_buffer_lcd
[x
][y
];
197 lcd_print_char(x
, y
);
204 /* Invalidate only the window part that actually did change */
205 GetClientRect (hGUIWnd
, &r
);
206 r
.left
= UI_LCD_POSX
* r
.right
/ UI_WIDTH
;
207 r
.top
= UI_LCD_POSY
* r
.bottom
/ UI_HEIGHT
;
208 r
.right
= (UI_LCD_POSX
+ UI_LCD_WIDTH
) * r
.right
/ UI_WIDTH
;
209 r
.bottom
= (UI_LCD_POSY
+ UI_LCD_HEIGHT
) * r
.bottom
/ UI_HEIGHT
;
210 InvalidateRect (hGUIWnd
, &r
, FALSE
);
212 lcd_display_redraw
= false;
215 void drawdots(int color
, struct coordinate
*points
, int count
)
219 bitmap
[points
[count
].y
][points
[count
].x
] = color
;
223 void drawrectangles(int color
, struct rectangle
*points
, int count
)
232 for (x
= points
[count
].x
, ix
= 0; ix
< points
[count
].width
; x
++, ix
++)
234 for (y
= points
[count
].y
, iy
= 0; iy
< points
[count
].height
; y
++, iy
++)
236 bitmap
[y
][x
] = color
;
241 #endif /* HAVE_LCD_CHARCELLS */
244 /* set backlight state of lcd */
245 void lcd_backlight (bool on
)
248 color_zero
= {UI_LCD_BGCOLORLIGHT
, 0};
250 color_zero
= {UI_LCD_BGCOLOR
, 0};
252 lcdcolors(0, (1<<LCD_DEPTH
), &color_zero
, &color_max
);
253 InvalidateRect (hGUIWnd
, NULL
, FALSE
);
258 /* set a range of bitmap indices to a gradient from startcolour to endcolour */
259 void lcdcolors(int index
, int count
, RGBQUAD
*start
, RGBQUAD
*end
)
263 bmi
.bmiHeader
.biClrUsed
= index
+ count
;
264 bmi
.bmiHeader
.biClrImportant
= index
+ count
;
267 for (i
= 0; i
<= count
; i
++)
269 bmi
.bmiColors
[i
+index
].rgbRed
= start
->rgbRed
270 + (end
->rgbRed
- start
->rgbRed
) * i
/ count
;
271 bmi
.bmiColors
[i
+index
].rgbGreen
= start
->rgbGreen
272 + (end
->rgbGreen
- start
->rgbGreen
) * i
/ count
;
273 bmi
.bmiColors
[i
+index
].rgbBlue
= start
->rgbBlue
274 + (end
->rgbBlue
- start
->rgbBlue
) * i
/ count
;
279 #ifdef HAVE_REMOTE_LCD
280 /* set a range of bitmap indices to a gradient from startcolour to endcolour */
281 void lcdremotecolors(int index
, int count
, RGBQUAD
*start
, RGBQUAD
*end
)
285 remote_bmi
.bmiHeader
.biClrUsed
= index
+ count
;
286 remote_bmi
.bmiHeader
.biClrImportant
= index
+ count
;
289 for (i
= 0; i
<= count
; i
++)
291 remote_bmi
.bmiColors
[i
+index
].rgbRed
= start
->rgbRed
292 + (end
->rgbRed
- start
->rgbRed
) * i
/ count
;
293 remote_bmi
.bmiColors
[i
+index
].rgbGreen
= start
->rgbGreen
294 + (end
->rgbGreen
- start
->rgbGreen
) * i
/ count
;
295 remote_bmi
.bmiColors
[i
+index
].rgbBlue
= start
->rgbBlue
296 + (end
->rgbBlue
- start
->rgbBlue
) * i
/ count
;
301 /* initialise simulator lcd driver */
302 void simlcdinit(void)
305 lcdcolors(0, (1<<LCD_DEPTH
), &color_zero
, &color_max
);
307 #ifdef HAVE_REMOTE_LCD
308 lcdremotecolors(0, (1<<LCD_REMOTE_DEPTH
), &remote_color_zero
, &remote_color_max
);