summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2006-11-26 14:26:08 +0000
committerJens Arnold <amiconn@rockbox.org>2006-11-26 14:26:08 +0000
commit11e2e565ca65e9555bcc19ddb256775e9e911edb (patch)
treec1b3ef99b2f79c4b5d1e1d98358c2223002148e3
parentbbef13eddfefffa1fbcf82185ed73c04a18d22eb (diff)
downloadrockbox-11e2e565ca65e9555bcc19ddb256775e9e911edb.tar.gz
rockbox-11e2e565ca65e9555bcc19ddb256775e9e911edb.zip
Backdrop support in the X5 remote LCD driver. Still needs to be wired to the UI and settings.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11601 a1c6a512-1295-4272-9138-f99709370657
-rwxr-xr-xfirmware/drivers/lcd-remote-2bit-vi.c118
-rw-r--r--firmware/export/lcd-remote.h5
2 files changed, 116 insertions, 7 deletions
diff --git a/firmware/drivers/lcd-remote-2bit-vi.c b/firmware/drivers/lcd-remote-2bit-vi.c
index 2d4d9a3ee1..3c85512bea 100755
--- a/firmware/drivers/lcd-remote-2bit-vi.c
+++ b/firmware/drivers/lcd-remote-2bit-vi.c
@@ -42,7 +42,10 @@
42fb_remote_data lcd_remote_framebuffer[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_FBWIDTH] 42fb_remote_data lcd_remote_framebuffer[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_FBWIDTH]
43 IBSS_ATTR; 43 IBSS_ATTR;
44 44
45static const fb_data patterns[4] = {0xFFFF, 0xFF00, 0x00FF, 0x0000}; 45static const fb_remote_data patterns[4] = {0xFFFF, 0xFF00, 0x00FF, 0x0000};
46
47static fb_remote_data* remote_backdrop = NULL;
48static long remote_backdrop_offset IDATA_ATTR = 0;
46 49
47static unsigned fg_pattern IDATA_ATTR = 0xFFFF; /* initially black */ 50static unsigned fg_pattern IDATA_ATTR = 0xFFFF; /* initially black */
48static unsigned bg_pattern IDATA_ATTR = 0x0000; /* initially white */ 51static unsigned bg_pattern IDATA_ATTR = 0x0000; /* initially white */
@@ -173,6 +176,16 @@ static void clearpixel(int x, int y)
173 *address = data ^ ((data ^ bg_pattern) & mask); 176 *address = data ^ ((data ^ bg_pattern) & mask);
174} 177}
175 178
179static void clearimgpixel(int x, int y)
180{
181 unsigned mask = 0x0101 << (y & 7);
182 fb_remote_data *address = &lcd_remote_framebuffer[y>>3][x];
183 unsigned data = *address;
184
185 *address = data ^ ((data ^ *(fb_remote_data *)((long)address
186 + remote_backdrop_offset)) & mask);
187}
188
176static void flippixel(int x, int y) 189static void flippixel(int x, int y)
177{ 190{
178 unsigned mask = 0x0101 << (y & 7); 191 unsigned mask = 0x0101 << (y & 7);
@@ -187,11 +200,18 @@ static void nopixel(int x, int y)
187 (void)y; 200 (void)y;
188} 201}
189 202
190lcd_remote_pixelfunc_type* const lcd_remote_pixelfuncs[8] = { 203lcd_remote_pixelfunc_type* const lcd_remote_pixelfuncs_bgcolor[8] = {
191 flippixel, nopixel, setpixel, setpixel, 204 flippixel, nopixel, setpixel, setpixel,
192 nopixel, clearpixel, nopixel, clearpixel 205 nopixel, clearpixel, nopixel, clearpixel
193}; 206};
194 207
208lcd_remote_pixelfunc_type* const lcd_remote_pixelfuncs_backdrop[8] = {
209 flippixel, nopixel, setpixel, setpixel,
210 nopixel, clearimgpixel, nopixel, clearimgpixel
211};
212
213lcd_remote_pixelfunc_type* const *lcd_remote_pixelfuncs = lcd_remote_pixelfuncs_bgcolor;
214
195/* 'mask' and 'bits' contain 2 bits per pixel */ 215/* 'mask' and 'bits' contain 2 bits per pixel */
196static void flipblock(fb_remote_data *address, unsigned mask, unsigned bits) 216static void flipblock(fb_remote_data *address, unsigned mask, unsigned bits)
197 ICODE_ATTR; 217 ICODE_ATTR;
@@ -209,6 +229,16 @@ static void bgblock(fb_remote_data *address, unsigned mask, unsigned bits)
209 *address = data ^ ((data ^ bg_pattern) & mask & ~bits); 229 *address = data ^ ((data ^ bg_pattern) & mask & ~bits);
210} 230}
211 231
232static void bgimgblock(fb_remote_data *address, unsigned mask, unsigned bits)
233 ICODE_ATTR;
234static void bgimgblock(fb_remote_data *address, unsigned mask, unsigned bits)
235{
236 unsigned data = *address;
237
238 *address = data ^ ((data ^ *(fb_remote_data *)((long)address
239 + remote_backdrop_offset)) & mask & ~bits);
240}
241
212static void fgblock(fb_remote_data *address, unsigned mask, unsigned bits) 242static void fgblock(fb_remote_data *address, unsigned mask, unsigned bits)
213 ICODE_ATTR; 243 ICODE_ATTR;
214static void fgblock(fb_remote_data *address, unsigned mask, unsigned bits) 244static void fgblock(fb_remote_data *address, unsigned mask, unsigned bits)
@@ -229,6 +259,17 @@ static void solidblock(fb_remote_data *address, unsigned mask, unsigned bits)
229 *address = data ^ ((data ^ bits) & mask); 259 *address = data ^ ((data ^ bits) & mask);
230} 260}
231 261
262static void solidimgblock(fb_remote_data *address, unsigned mask, unsigned bits)
263 ICODE_ATTR;
264static void solidimgblock(fb_remote_data *address, unsigned mask, unsigned bits)
265{
266 unsigned data = *address;
267 unsigned bgp = *(fb_remote_data *)((long)address + remote_backdrop_offset);
268
269 bits = bgp ^ ((bgp ^ fg_pattern) & bits);
270 *address = data ^ ((data ^ bits) & mask);
271}
272
232static void flipinvblock(fb_remote_data *address, unsigned mask, unsigned bits) 273static void flipinvblock(fb_remote_data *address, unsigned mask, unsigned bits)
233 ICODE_ATTR; 274 ICODE_ATTR;
234static void flipinvblock(fb_remote_data *address, unsigned mask, unsigned bits) 275static void flipinvblock(fb_remote_data *address, unsigned mask, unsigned bits)
@@ -245,6 +286,16 @@ static void bginvblock(fb_remote_data *address, unsigned mask, unsigned bits)
245 *address = data ^ ((data ^ bg_pattern) & mask & bits); 286 *address = data ^ ((data ^ bg_pattern) & mask & bits);
246} 287}
247 288
289static void bgimginvblock(fb_remote_data *address, unsigned mask, unsigned bits)
290 ICODE_ATTR;
291static void bgimginvblock(fb_remote_data *address, unsigned mask, unsigned bits)
292{
293 unsigned data = *address;
294
295 *address = data ^ ((data ^ *(fb_remote_data *)((long)address
296 + remote_backdrop_offset)) & mask & bits);
297}
298
248static void fginvblock(fb_remote_data *address, unsigned mask, unsigned bits) 299static void fginvblock(fb_remote_data *address, unsigned mask, unsigned bits)
249 ICODE_ATTR; 300 ICODE_ATTR;
250static void fginvblock(fb_remote_data *address, unsigned mask, unsigned bits) 301static void fginvblock(fb_remote_data *address, unsigned mask, unsigned bits)
@@ -265,11 +316,53 @@ static void solidinvblock(fb_remote_data *address, unsigned mask, unsigned bits)
265 *address = data ^ ((data ^ bits) & mask); 316 *address = data ^ ((data ^ bits) & mask);
266} 317}
267 318
268lcd_remote_blockfunc_type* const lcd_remote_blockfuncs[8] = { 319static void solidimginvblock(fb_remote_data *address, unsigned mask, unsigned bits)
320 ICODE_ATTR;
321static void solidimginvblock(fb_remote_data *address, unsigned mask, unsigned bits)
322{
323 unsigned data = *address;
324 unsigned fgp = fg_pattern;
325
326 bits = fgp ^ ((fgp ^ *(fb_remote_data *)((long)address
327 + remote_backdrop_offset)) & bits);
328 *address = data ^ ((data ^ bits) & mask);
329}
330
331lcd_remote_blockfunc_type* const lcd_remote_blockfuncs_bgcolor[8] = {
269 flipblock, bgblock, fgblock, solidblock, 332 flipblock, bgblock, fgblock, solidblock,
270 flipinvblock, bginvblock, fginvblock, solidinvblock 333 flipinvblock, bginvblock, fginvblock, solidinvblock
271}; 334};
272 335
336lcd_remote_blockfunc_type* const lcd_remote_blockfuncs_backdrop[8] = {
337 flipblock, bgimgblock, fgblock, solidimgblock,
338 flipinvblock, bgimginvblock, fginvblock, solidimginvblock
339};
340
341lcd_remote_blockfunc_type* const *lcd_remote_blockfuncs = lcd_remote_blockfuncs_bgcolor;
342
343
344void lcd_remote_set_backdrop(fb_remote_data* backdrop)
345{
346 remote_backdrop = backdrop;
347 if (backdrop)
348 {
349 remote_backdrop_offset = (long)backdrop - (long)lcd_remote_framebuffer;
350 lcd_remote_pixelfuncs = lcd_remote_pixelfuncs_backdrop;
351 lcd_remote_blockfuncs = lcd_remote_blockfuncs_backdrop;
352 }
353 else
354 {
355 remote_backdrop_offset = 0;
356 lcd_remote_pixelfuncs = lcd_remote_pixelfuncs_bgcolor;
357 lcd_remote_blockfuncs = lcd_remote_blockfuncs_bgcolor;
358 }
359}
360
361fb_remote_data* lcd_remote_get_backdrop(void)
362{
363 return remote_backdrop;
364}
365
273static inline void setblock(fb_remote_data *address, unsigned mask, unsigned bits) 366static inline void setblock(fb_remote_data *address, unsigned mask, unsigned bits)
274{ 367{
275 unsigned data = *address; 368 unsigned data = *address;
@@ -283,9 +376,20 @@ static inline void setblock(fb_remote_data *address, unsigned mask, unsigned bit
283/* Clear the whole display */ 376/* Clear the whole display */
284void lcd_remote_clear_display(void) 377void lcd_remote_clear_display(void)
285{ 378{
286 unsigned bits = (drawmode & DRMODE_INVERSEVID) ? fg_pattern : bg_pattern; 379 if (drawmode & DRMODE_INVERSEVID)
287 380 {
288 memset16(lcd_remote_framebuffer, bits, sizeof lcd_remote_framebuffer / 2); 381 memset(lcd_remote_framebuffer, fg_pattern,
382 sizeof lcd_remote_framebuffer);
383 }
384 else
385 {
386 if (remote_backdrop)
387 memcpy(lcd_remote_framebuffer, remote_backdrop,
388 sizeof lcd_remote_framebuffer);
389 else
390 memset(lcd_remote_framebuffer, bg_pattern,
391 sizeof lcd_remote_framebuffer);
392 }
289 scrolling_lines = 0; 393 scrolling_lines = 0;
290} 394}
291 395
@@ -497,7 +601,7 @@ void lcd_remote_fillrect(int x, int y, int width, int height)
497 601
498 if (drawmode & DRMODE_INVERSEVID) 602 if (drawmode & DRMODE_INVERSEVID)
499 { 603 {
500 if (drawmode & DRMODE_BG) 604 if ((drawmode & DRMODE_BG) && !remote_backdrop)
501 { 605 {
502 fillopt = true; 606 fillopt = true;
503 bits = bg_pattern; 607 bits = bg_pattern;
diff --git a/firmware/export/lcd-remote.h b/firmware/export/lcd-remote.h
index 9d5808b157..e4fffedac0 100644
--- a/firmware/export/lcd-remote.h
+++ b/firmware/export/lcd-remote.h
@@ -132,8 +132,13 @@ extern void lcd_remote_setfont(int font);
132extern int lcd_remote_getstringsize(const unsigned char *str, int *w, int *h); 132extern int lcd_remote_getstringsize(const unsigned char *str, int *w, int *h);
133 133
134/* low level drawing function pointer arrays */ 134/* low level drawing function pointer arrays */
135#if LCD_REMOTE_DEPTH > 1
136extern lcd_remote_pixelfunc_type* const *lcd_remote_pixelfuncs;
137extern lcd_remote_blockfunc_type* const *lcd_remote_blockfuncs;
138#else
135extern lcd_remote_pixelfunc_type* const lcd_remote_pixelfuncs[8]; 139extern lcd_remote_pixelfunc_type* const lcd_remote_pixelfuncs[8];
136extern lcd_remote_blockfunc_type* const lcd_remote_blockfuncs[8]; 140extern lcd_remote_blockfunc_type* const lcd_remote_blockfuncs[8];
141#endif
137 142
138extern void lcd_remote_drawpixel(int x, int y); 143extern void lcd_remote_drawpixel(int x, int y);
139extern void lcd_remote_drawline(int x1, int y1, int x2, int y2); 144extern void lcd_remote_drawline(int x1, int y1, int x2, int y2);