diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/misc.c | 84 | ||||
-rw-r--r-- | apps/misc.h | 12 | ||||
-rw-r--r-- | apps/plugin.c | 2 | ||||
-rw-r--r-- | apps/plugin.h | 6 | ||||
-rw-r--r-- | apps/plugins/lib/grey_core.c | 153 |
5 files changed, 146 insertions, 111 deletions
diff --git a/apps/misc.c b/apps/misc.c index 6e871acd3b..43dfd45e51 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -344,19 +344,20 @@ int fast_readline(int fd, char *buf, int buf_size, void *parameters, | |||
344 | #if LCD_DEPTH == 16 | 344 | #if LCD_DEPTH == 16 |
345 | #define BMP_COMPRESSION 3 /* BI_BITFIELDS */ | 345 | #define BMP_COMPRESSION 3 /* BI_BITFIELDS */ |
346 | #define BMP_NUMCOLORS 3 | 346 | #define BMP_NUMCOLORS 3 |
347 | #else | 347 | #else /* LCD_DEPTH != 16 */ |
348 | #define BMP_COMPRESSION 0 /* BI_RGB */ | 348 | #define BMP_COMPRESSION 0 /* BI_RGB */ |
349 | #if LCD_DEPTH <= 8 | 349 | #if LCD_DEPTH <= 8 |
350 | #define BMP_NUMCOLORS (1 << LCD_DEPTH) | 350 | #ifdef HAVE_LCD_SPLIT |
351 | #define BMP_NUMCOLORS (2 << LCD_DEPTH) | ||
351 | #else | 352 | #else |
352 | #define BMP_NUMCOLORS 0 | 353 | #define BMP_NUMCOLORS (1 << LCD_DEPTH) |
353 | #endif | ||
354 | #endif | 354 | #endif |
355 | #else /* LCD_DEPTH > 8 */ | ||
356 | #define BMP_NUMCOLORS 0 | ||
357 | #endif /* LCD_DEPTH > 8 */ | ||
358 | #endif /* LCD_DEPTH != 16 */ | ||
355 | 359 | ||
356 | #if LCD_DEPTH == 1 | 360 | #if LCD_DEPTH <= 4 |
357 | #define BMP_BPP 1 | ||
358 | #define BMP_LINESIZE ((LCD_WIDTH/8 + 3) & ~3) | ||
359 | #elif LCD_DEPTH <= 4 | ||
360 | #define BMP_BPP 4 | 361 | #define BMP_BPP 4 |
361 | #define BMP_LINESIZE ((LCD_WIDTH/2 + 3) & ~3) | 362 | #define BMP_LINESIZE ((LCD_WIDTH/2 + 3) & ~3) |
362 | #elif LCD_DEPTH <= 8 | 363 | #elif LCD_DEPTH <= 8 |
@@ -386,7 +387,7 @@ static const unsigned char bmpheader[] = | |||
386 | 387 | ||
387 | 0x28, 0x00, 0x00, 0x00, /* Size of (2nd) header */ | 388 | 0x28, 0x00, 0x00, 0x00, /* Size of (2nd) header */ |
388 | LE32_CONST(LCD_WIDTH), /* Width in pixels */ | 389 | LE32_CONST(LCD_WIDTH), /* Width in pixels */ |
389 | LE32_CONST(LCD_HEIGHT), /* Height in pixels */ | 390 | LE32_CONST(LCD_HEIGHT+LCD_SPLIT_LINES), /* Height in pixels */ |
390 | 0x01, 0x00, /* Number of planes (always 1) */ | 391 | 0x01, 0x00, /* Number of planes (always 1) */ |
391 | LE16_CONST(BMP_BPP), /* Bits per pixel 1/4/8/16/24 */ | 392 | LE16_CONST(BMP_BPP), /* Bits per pixel 1/4/8/16/24 */ |
392 | LE32_CONST(BMP_COMPRESSION),/* Compression mode */ | 393 | LE32_CONST(BMP_COMPRESSION),/* Compression mode */ |
@@ -397,22 +398,26 @@ static const unsigned char bmpheader[] = | |||
397 | LE32_CONST(BMP_NUMCOLORS), /* Number of important colours */ | 398 | LE32_CONST(BMP_NUMCOLORS), /* Number of important colours */ |
398 | 399 | ||
399 | #if LCD_DEPTH == 1 | 400 | #if LCD_DEPTH == 1 |
400 | #ifdef MROBE_100 | 401 | #ifdef HAVE_NEGATIVE_LCD |
401 | 2, 2, 94, 0x00, /* Colour #0 */ | 402 | BMP_COLOR(LCD_BL_DARKCOLOR), |
402 | 3, 6, 241, 0x00 /* Colour #1 */ | 403 | BMP_COLOR(LCD_BL_BRIGHTCOLOR), |
403 | #else | 404 | #ifdef HAVE_LCD_SPLIT |
404 | 0x90, 0xee, 0x90, 0x00, /* Colour #0 */ | 405 | BMP_COLOR(LCD_BL_DARKCOLOR_2), |
405 | 0x00, 0x00, 0x00, 0x00 /* Colour #1 */ | 406 | BMP_COLOR(LCD_BL_BRIGHTCOLOR_2), |
406 | #endif | 407 | #endif |
408 | #else /* positive display */ | ||
409 | BMP_COLOR(LCD_BL_BRIGHTCOLOR), | ||
410 | BMP_COLOR(LCD_BL_DARKCOLOR), | ||
411 | #endif /* positive display */ | ||
407 | #elif LCD_DEPTH == 2 | 412 | #elif LCD_DEPTH == 2 |
408 | 0xe6, 0xd8, 0xad, 0x00, /* Colour #0 */ | 413 | BMP_COLOR(LCD_BL_BRIGHTCOLOR), |
409 | 0x99, 0x90, 0x73, 0x00, /* Colour #1 */ | 414 | BMP_COLOR_MIX(LCD_BL_BRIGHTCOLOR, LCD_BL_DARKCOLOR, 1, 3), |
410 | 0x4c, 0x48, 0x39, 0x00, /* Colour #2 */ | 415 | BMP_COLOR_MIX(LCD_BL_BRIGHTCOLOR, LCD_BL_DARKCOLOR, 2, 3), |
411 | 0x00, 0x00, 0x00, 0x00 /* Colour #3 */ | 416 | BMP_COLOR(LCD_BL_DARKCOLOR), |
412 | #elif LCD_DEPTH == 16 | 417 | #elif LCD_DEPTH == 16 |
413 | 0x00, 0xf8, 0x00, 0x00, /* red bitfield mask */ | 418 | 0x00, 0xf8, 0x00, 0x00, /* red bitfield mask */ |
414 | 0xe0, 0x07, 0x00, 0x00, /* green bitfield mask */ | 419 | 0xe0, 0x07, 0x00, 0x00, /* green bitfield mask */ |
415 | 0x1f, 0x00, 0x00, 0x00 /* blue bitfield mask */ | 420 | 0x1f, 0x00, 0x00, 0x00, /* blue bitfield mask */ |
416 | #endif | 421 | #endif |
417 | }; | 422 | }; |
418 | 423 | ||
@@ -461,30 +466,33 @@ void screen_dump(void) | |||
461 | for (by = LCD_FBHEIGHT - 1; by >= 0; by--) | 466 | for (by = LCD_FBHEIGHT - 1; by >= 0; by--) |
462 | { | 467 | { |
463 | unsigned char *src = &lcd_framebuffer[by][0]; | 468 | unsigned char *src = &lcd_framebuffer[by][0]; |
464 | unsigned char *dst = &line_block[0][0]; | 469 | unsigned char *dst = &line_block[7][0]; |
465 | 470 | ||
466 | memset(line_block, 0, sizeof(line_block)); | 471 | memset(line_block, 0, sizeof(line_block)); |
467 | for (bx = LCD_WIDTH/8; bx > 0; bx--) | 472 | |
473 | #ifdef HAVE_LCD_SPLIT | ||
474 | if (by == (LCD_SPLIT_POS/8 - 1)) | ||
475 | write(fh, line_block, LCD_SPLIT_LINES * sizeof(line_block[0])); | ||
476 | #endif | ||
477 | for (bx = LCD_WIDTH/2; bx > 0; bx--) | ||
468 | { | 478 | { |
469 | unsigned dst_mask = 0x80; | 479 | unsigned char *dst_blk = dst++; |
470 | int ix; | 480 | unsigned src_byte0 = *src++ << 4; |
481 | unsigned src_byte1 = *src++; | ||
482 | int iy; | ||
471 | 483 | ||
472 | for (ix = 8; ix > 0; ix--) | 484 | for (iy = 8; iy > 0; iy--) |
473 | { | 485 | { |
474 | unsigned char *dst_blk = dst; | 486 | *dst_blk = (src_byte0 & 0x10) |
475 | unsigned src_byte = *src++; | 487 | | (src_byte1 & 0x01) |
476 | int iy; | 488 | #ifdef HAVE_LCD_SPLIT |
477 | 489 | | (by < (LCD_SPLIT_POS/8) ? 0x22 : 0) | |
478 | for (iy = 8; iy > 0; iy--) | 490 | #endif |
479 | { | 491 | ; |
480 | if (src_byte & 0x80) | 492 | src_byte0 >>= 1; |
481 | *dst_blk |= dst_mask; | 493 | src_byte1 >>= 1; |
482 | src_byte <<= 1; | 494 | dst_blk -= BMP_LINESIZE; |
483 | dst_blk += BMP_LINESIZE; | ||
484 | } | ||
485 | dst_mask >>= 1; | ||
486 | } | 495 | } |
487 | dst++; | ||
488 | } | 496 | } |
489 | 497 | ||
490 | write(fh, line_block, sizeof(line_block)); | 498 | write(fh, line_block, sizeof(line_block)); |
diff --git a/apps/misc.h b/apps/misc.h index 22ae4849a4..99e709c2c8 100644 --- a/apps/misc.h +++ b/apps/misc.h | |||
@@ -93,6 +93,18 @@ void screen_dump(void); | |||
93 | void screen_dump_set_hook(void (*hook)(int fh)); | 93 | void screen_dump_set_hook(void (*hook)(int fh)); |
94 | #endif | 94 | #endif |
95 | 95 | ||
96 | /* Make BMP colour map entries from R, G, B triples, without and with blending. | ||
97 | * Not within HAVE_LCD_BITMAP because it is also used for the Player sim */ | ||
98 | #define RED_CMP(c) (((c) >> 16) & 0xff) | ||
99 | #define GREEN_CMP(c) (((c) >> 8) & 0xff) | ||
100 | #define BLUE_CMP(c) ((c) & 0xff) | ||
101 | |||
102 | #define BMP_COLOR(c) BLUE_CMP(c), GREEN_CMP(c), RED_CMP(c), 0 | ||
103 | #define BMP_COLOR_MIX(c1, c2, num, den) \ | ||
104 | (BLUE_CMP(c2) - BLUE_CMP(c1)) * (num) / (den) + BLUE_CMP(c1), \ | ||
105 | (GREEN_CMP(c2) - GREEN_CMP(c1)) * (num) / (den) + GREEN_CMP(c1), \ | ||
106 | (RED_CMP(c2) - RED_CMP(c1)) * (num) / (den) + RED_CMP(c1), 0 | ||
107 | |||
96 | bool settings_parseline(char* line, char** name, char** value); | 108 | bool settings_parseline(char* line, char** name, char** value); |
97 | long default_event_handler_ex(long event, void (*callback)(void *), void *parameter); | 109 | long default_event_handler_ex(long event, void (*callback)(void *), void *parameter); |
98 | long default_event_handler(long event); | 110 | long default_event_handler(long event); |
diff --git a/apps/plugin.c b/apps/plugin.c index 8828d10aa7..3b14b0032f 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -61,7 +61,7 @@ | |||
61 | static unsigned char pluginbuf[PLUGIN_BUFFER_SIZE]; | 61 | static unsigned char pluginbuf[PLUGIN_BUFFER_SIZE]; |
62 | void *sim_plugin_load(char *plugin, void **pd); | 62 | void *sim_plugin_load(char *plugin, void **pd); |
63 | void sim_plugin_close(void *pd); | 63 | void sim_plugin_close(void *pd); |
64 | void sim_lcd_ex_init(int shades, unsigned long (*getpixel)(int, int)); | 64 | void sim_lcd_ex_init(unsigned long (*getpixel)(int, int)); |
65 | void sim_lcd_ex_update_rect(int x, int y, int width, int height); | 65 | void sim_lcd_ex_update_rect(int x, int y, int width, int height); |
66 | #else | 66 | #else |
67 | #define sim_plugin_close(x) | 67 | #define sim_plugin_close(x) |
diff --git a/apps/plugin.h b/apps/plugin.h index 2017bf3e5b..82ce0d6ddf 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -126,12 +126,12 @@ void* plugin_get_buffer(size_t *buffer_size); | |||
126 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ | 126 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ |
127 | 127 | ||
128 | /* increase this every time the api struct changes */ | 128 | /* increase this every time the api struct changes */ |
129 | #define PLUGIN_API_VERSION 141 | 129 | #define PLUGIN_API_VERSION 142 |
130 | 130 | ||
131 | /* update this to latest version if a change to the api struct breaks | 131 | /* update this to latest version if a change to the api struct breaks |
132 | backwards compatibility (and please take the opportunity to sort in any | 132 | backwards compatibility (and please take the opportunity to sort in any |
133 | new function which are "waiting" at the end of the function table) */ | 133 | new function which are "waiting" at the end of the function table) */ |
134 | #define PLUGIN_MIN_API_VERSION 141 | 134 | #define PLUGIN_MIN_API_VERSION 142 |
135 | 135 | ||
136 | /* plugin return codes */ | 136 | /* plugin return codes */ |
137 | enum plugin_status { | 137 | enum plugin_status { |
@@ -474,7 +474,7 @@ struct plugin_api { | |||
474 | #ifdef SIMULATOR | 474 | #ifdef SIMULATOR |
475 | /* special simulator hooks */ | 475 | /* special simulator hooks */ |
476 | #if defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8 | 476 | #if defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8 |
477 | void (*sim_lcd_ex_init)(int shades, unsigned long (*getpixel)(int, int)); | 477 | void (*sim_lcd_ex_init)(unsigned long (*getpixel)(int, int)); |
478 | void (*sim_lcd_ex_update_rect)(int x, int y, int width, int height); | 478 | void (*sim_lcd_ex_update_rect)(int x, int y, int width, int height); |
479 | #endif | 479 | #endif |
480 | #endif | 480 | #endif |
diff --git a/apps/plugins/lib/grey_core.c b/apps/plugins/lib/grey_core.c index c73f0cdf52..a7e8f2a08b 100644 --- a/apps/plugins/lib/grey_core.c +++ b/apps/plugins/lib/grey_core.c | |||
@@ -355,6 +355,7 @@ static inline void _deferred_update(void) | |||
355 | * coordinates! */ | 355 | * coordinates! */ |
356 | static unsigned long _grey_get_pixel(int x, int y) | 356 | static unsigned long _grey_get_pixel(int x, int y) |
357 | { | 357 | { |
358 | long val; | ||
358 | int xg = x - _grey_info.x; | 359 | int xg = x - _grey_info.x; |
359 | int yg = y - _grey_info.y; | 360 | int yg = y - _grey_info.y; |
360 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING | 361 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING |
@@ -364,7 +365,11 @@ static unsigned long _grey_get_pixel(int x, int y) | |||
364 | + (xg << _GREY_BSHIFT) + (~yg & _GREY_BMASK); | 365 | + (xg << _GREY_BSHIFT) + (~yg & _GREY_BMASK); |
365 | #endif | 366 | #endif |
366 | 367 | ||
367 | return _grey_info.values[idx] + (1 << LCD_DEPTH); | 368 | val = _grey_info.values[idx]; |
369 | #ifdef HAVE_LCD_SPLIT | ||
370 | val -= val >> 7; | ||
371 | #endif | ||
372 | return val; | ||
368 | } | 373 | } |
369 | 374 | ||
370 | #else /* !SIMULATOR */ | 375 | #else /* !SIMULATOR */ |
@@ -634,9 +639,9 @@ void grey_show(bool enable) | |||
634 | { | 639 | { |
635 | _grey_info.flags |= _GREY_RUNNING; | 640 | _grey_info.flags |= _GREY_RUNNING; |
636 | #ifdef SIMULATOR | 641 | #ifdef SIMULATOR |
637 | rb->sim_lcd_ex_init(129, _grey_get_pixel); | 642 | rb->sim_lcd_ex_init(_grey_get_pixel); |
638 | rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, | 643 | rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, |
639 | _grey_info.width, _grey_info.height); | 644 | _grey_info.width, _grey_info.height); |
640 | #else /* !SIMULATOR */ | 645 | #else /* !SIMULATOR */ |
641 | #ifdef NEED_BOOST | 646 | #ifdef NEED_BOOST |
642 | rb->cpu_boost(true); | 647 | rb->cpu_boost(true); |
@@ -655,7 +660,7 @@ void grey_show(bool enable) | |||
655 | else if (!enable && (_grey_info.flags & _GREY_RUNNING)) | 660 | else if (!enable && (_grey_info.flags & _GREY_RUNNING)) |
656 | { | 661 | { |
657 | #ifdef SIMULATOR | 662 | #ifdef SIMULATOR |
658 | rb->sim_lcd_ex_init(0, NULL); | 663 | rb->sim_lcd_ex_init(NULL); |
659 | #else /* !SIMULATOR */ | 664 | #else /* !SIMULATOR */ |
660 | rb->timer_unregister(); | 665 | rb->timer_unregister(); |
661 | #if NUM_CORES > 1 /* Make sure the ISR has finished before calling lcd_update() */ | 666 | #if NUM_CORES > 1 /* Make sure the ISR has finished before calling lcd_update() */ |
@@ -702,9 +707,14 @@ void grey_deferred_lcd_update(void) | |||
702 | 707 | ||
703 | /*** Screenshot ***/ | 708 | /*** Screenshot ***/ |
704 | 709 | ||
705 | #define BMP_FIXEDCOLORS (1 << LCD_DEPTH) | 710 | #ifdef HAVE_LCD_SPLIT |
706 | #define BMP_VARCOLORS 129 | 711 | #define GRADIENT_MAX 127 |
707 | #define BMP_NUMCOLORS (BMP_FIXEDCOLORS + BMP_VARCOLORS) | 712 | #define BMP_NUMCOLORS 256 |
713 | #else | ||
714 | #define GRADIENT_MAX 128 | ||
715 | #define BMP_NUMCOLORS 129 | ||
716 | #endif | ||
717 | |||
708 | #define BMP_BPP 8 | 718 | #define BMP_BPP 8 |
709 | #define BMP_LINESIZE ((LCD_WIDTH + 3) & ~3) | 719 | #define BMP_LINESIZE ((LCD_WIDTH + 3) & ~3) |
710 | #define BMP_HEADERSIZE (54 + 4 * BMP_NUMCOLORS) | 720 | #define BMP_HEADERSIZE (54 + 4 * BMP_NUMCOLORS) |
@@ -723,7 +733,7 @@ static const unsigned char bmpheader[] = | |||
723 | 733 | ||
724 | 0x28, 0x00, 0x00, 0x00, /* Size of (2nd) header */ | 734 | 0x28, 0x00, 0x00, 0x00, /* Size of (2nd) header */ |
725 | LE32_CONST(LCD_WIDTH), /* Width in pixels */ | 735 | LE32_CONST(LCD_WIDTH), /* Width in pixels */ |
726 | LE32_CONST(LCD_HEIGHT), /* Height in pixels */ | 736 | LE32_CONST(LCD_HEIGHT+LCD_SPLIT_LINES), /* Height in pixels */ |
727 | 0x01, 0x00, /* Number of planes (always 1) */ | 737 | 0x01, 0x00, /* Number of planes (always 1) */ |
728 | LE16_CONST(BMP_BPP), /* Bits per pixel 1/4/8/16/24 */ | 738 | LE16_CONST(BMP_BPP), /* Bits per pixel 1/4/8/16/24 */ |
729 | 0x00, 0x00, 0x00, 0x00, /* Compression mode, 0 = none */ | 739 | 0x00, 0x00, 0x00, 0x00, /* Compression mode, 0 = none */ |
@@ -732,36 +742,11 @@ static const unsigned char bmpheader[] = | |||
732 | 0xc4, 0x0e, 0x00, 0x00, /* Vertical resolution (pixels/meter) */ | 742 | 0xc4, 0x0e, 0x00, 0x00, /* Vertical resolution (pixels/meter) */ |
733 | LE32_CONST(BMP_NUMCOLORS), /* Number of used colours */ | 743 | LE32_CONST(BMP_NUMCOLORS), /* Number of used colours */ |
734 | LE32_CONST(BMP_NUMCOLORS), /* Number of important colours */ | 744 | LE32_CONST(BMP_NUMCOLORS), /* Number of important colours */ |
735 | |||
736 | /* Fixed colours */ | ||
737 | #if LCD_DEPTH == 1 | ||
738 | 0x90, 0xee, 0x90, 0x00, /* Colour #0 */ | ||
739 | 0x00, 0x00, 0x00, 0x00 /* Colour #1 */ | ||
740 | #elif LCD_DEPTH == 2 | ||
741 | 0xe6, 0xd8, 0xad, 0x00, /* Colour #0 */ | ||
742 | 0x99, 0x90, 0x73, 0x00, /* Colour #1 */ | ||
743 | 0x4c, 0x48, 0x39, 0x00, /* Colour #2 */ | ||
744 | 0x00, 0x00, 0x00, 0x00 /* Colour #3 */ | ||
745 | #endif | ||
746 | }; | 745 | }; |
747 | 746 | ||
748 | #if LCD_DEPTH == 1 | 747 | #if LCD_DEPTH == 2 |
749 | #ifdef MROBE_100 | 748 | /* Only defined for positive, non-split LCD for now */ |
750 | #define BMP_RED 241 | 749 | static const unsigned char colorindex[4] = {128, 85, 43, 0}; |
751 | #define BMP_GREEN 6 | ||
752 | #define BMP_BLUE 3 | ||
753 | #define BMP_RED_BASE 94 | ||
754 | #define BMP_GREEN_BASE 2 | ||
755 | #define BMP_BLUE_BASE 2 | ||
756 | #else | ||
757 | #define BMP_RED 0x90 | ||
758 | #define BMP_GREEN 0xee | ||
759 | #define BMP_BLUE 0x90 | ||
760 | #endif | ||
761 | #elif LCD_DEPTH == 2 | ||
762 | #define BMP_RED 0xad | ||
763 | #define BMP_GREEN 0xd8 | ||
764 | #define BMP_BLUE 0xe6 | ||
765 | #endif | 750 | #endif |
766 | 751 | ||
767 | /* Hook function for core screen_dump() to save the current display | 752 | /* Hook function for core screen_dump() to save the current display |
@@ -772,6 +757,7 @@ static void grey_screendump_hook(int fd) | |||
772 | int x, y, gx, gy; | 757 | int x, y, gx, gy; |
773 | #if LCD_PIXELFORMAT == VERTICAL_PACKING | 758 | #if LCD_PIXELFORMAT == VERTICAL_PACKING |
774 | #if LCD_DEPTH == 1 | 759 | #if LCD_DEPTH == 1 |
760 | unsigned val; | ||
775 | unsigned mask; | 761 | unsigned mask; |
776 | #elif LCD_DEPTH == 2 | 762 | #elif LCD_DEPTH == 2 |
777 | int shift; | 763 | int shift; |
@@ -782,37 +768,57 @@ static void grey_screendump_hook(int fd) | |||
782 | #endif /* LCD_PIXELFORMAT */ | 768 | #endif /* LCD_PIXELFORMAT */ |
783 | fb_data *lcdptr; | 769 | fb_data *lcdptr; |
784 | unsigned char *clut_entry; | 770 | unsigned char *clut_entry; |
785 | unsigned char linebuf[MAX(4*BMP_VARCOLORS,BMP_LINESIZE)]; | 771 | unsigned char linebuf[MAX(4*BMP_NUMCOLORS,BMP_LINESIZE)]; |
786 | 772 | ||
787 | rb->write(fd, bmpheader, sizeof(bmpheader)); /* write header */ | 773 | rb->write(fd, bmpheader, sizeof(bmpheader)); /* write header */ |
788 | 774 | ||
789 | /* build clut */ | 775 | /* build clut */ |
790 | rb->memset(linebuf, 0, 4*BMP_VARCOLORS); | 776 | rb->memset(linebuf, 0, 4*BMP_NUMCOLORS); |
791 | clut_entry = linebuf; | 777 | clut_entry = linebuf; |
792 | 778 | ||
793 | for (i = 0; i <= 128; i++) | 779 | for (i = 0; i <= GRADIENT_MAX; i++) |
794 | { | 780 | { |
795 | #ifdef MROBE_100 | 781 | *clut_entry++ = (_GREY_MULUQ(BLUE_CMP(LCD_BL_BRIGHTCOLOR) |
796 | *clut_entry++ = (_GREY_MULUQ(BMP_BLUE-BMP_BLUE_BASE, i) >> 7) + | 782 | -BLUE_CMP(LCD_BL_DARKCOLOR), i) >> 7) |
797 | BMP_BLUE_BASE; | 783 | + BLUE_CMP(LCD_BL_DARKCOLOR); |
798 | *clut_entry++ = (_GREY_MULUQ(BMP_GREEN-BMP_GREEN_BASE, i) >> 7) + | 784 | *clut_entry++ = (_GREY_MULUQ(GREEN_CMP(LCD_BL_BRIGHTCOLOR) |
799 | BMP_GREEN_BASE; | 785 | -GREEN_CMP(LCD_BL_DARKCOLOR), i) >> 7) |
800 | *clut_entry++ = (_GREY_MULUQ(BMP_RED-BMP_RED_BASE, i) >> 7) + | 786 | + GREEN_CMP(LCD_BL_DARKCOLOR); |
801 | BMP_RED_BASE; | 787 | *clut_entry++ = (_GREY_MULUQ(RED_CMP(LCD_BL_BRIGHTCOLOR) |
802 | #else | 788 | -RED_CMP(LCD_BL_DARKCOLOR), i) >> 7) |
803 | *clut_entry++ = _GREY_MULUQ(BMP_BLUE, i) >> 7; | 789 | + RED_CMP(LCD_BL_DARKCOLOR); |
804 | *clut_entry++ = _GREY_MULUQ(BMP_GREEN, i) >> 7; | ||
805 | *clut_entry++ = _GREY_MULUQ(BMP_RED, i) >> 7; | ||
806 | #endif | ||
807 | clut_entry++; | 790 | clut_entry++; |
808 | } | 791 | } |
809 | rb->write(fd, linebuf, 4*BMP_VARCOLORS); | 792 | #ifdef HAVE_LCD_SPLIT |
793 | for (i = 0; i <= GRADIENT_MAX; i++) | ||
794 | { | ||
795 | *clut_entry++ = (_GREY_MULUQ(BLUE_CMP(LCD_BL_BRIGHTCOLOR_2) | ||
796 | -BLUE_CMP(LCD_BL_DARKCOLOR_2), i) >> 7) | ||
797 | + BLUE_CMP(LCD_BL_DARKCOLOR_2); | ||
798 | *clut_entry++ = (_GREY_MULUQ(GREEN_CMP(LCD_BL_BRIGHTCOLOR_2) | ||
799 | -GREEN_CMP(LCD_BL_DARKCOLOR_2), i) >> 7) | ||
800 | + GREEN_CMP(LCD_BL_DARKCOLOR_2); | ||
801 | *clut_entry++ = (_GREY_MULUQ(RED_CMP(LCD_BL_BRIGHTCOLOR_2) | ||
802 | -RED_CMP(LCD_BL_DARKCOLOR_2), i) >> 7) | ||
803 | + RED_CMP(LCD_BL_DARKCOLOR_2); | ||
804 | clut_entry++; | ||
805 | } | ||
806 | #endif | ||
807 | rb->write(fd, linebuf, 4*BMP_NUMCOLORS); | ||
810 | 808 | ||
811 | /* BMP image goes bottom -> top */ | 809 | /* BMP image goes bottom -> top */ |
812 | for (y = LCD_HEIGHT - 1; y >= 0; y--) | 810 | for (y = LCD_HEIGHT - 1; y >= 0; y--) |
813 | { | 811 | { |
814 | rb->memset(linebuf, 0, BMP_LINESIZE); | 812 | rb->memset(linebuf, 0, BMP_LINESIZE); |
815 | 813 | ||
814 | #if defined(HAVE_LCD_SPLIT) && (LCD_SPLIT_LINES == 2) | ||
815 | if (y == LCD_SPLIT_POS - 1) | ||
816 | { | ||
817 | rb->write(fd, linebuf, BMP_LINESIZE); | ||
818 | rb->write(fd, linebuf, BMP_LINESIZE); | ||
819 | } | ||
820 | #endif | ||
821 | |||
816 | gy = y - _grey_info.y; | 822 | gy = y - _grey_info.y; |
817 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING | 823 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING |
818 | #if LCD_DEPTH == 2 | 824 | #if LCD_DEPTH == 2 |
@@ -828,15 +834,15 @@ static void grey_screendump_hook(int fd) | |||
828 | unsigned char *src = _grey_info.values | 834 | unsigned char *src = _grey_info.values |
829 | + _GREY_MULUQ(_grey_info.width, gy) + gx; | 835 | + _GREY_MULUQ(_grey_info.width, gy) + gx; |
830 | for (i = 0; i < 4; i++) | 836 | for (i = 0; i < 4; i++) |
831 | linebuf[x + i] = BMP_FIXEDCOLORS + *src++; | 837 | linebuf[x + i] = *src++; |
832 | } | 838 | } |
833 | else | 839 | else |
834 | { | 840 | { |
835 | unsigned data = *lcdptr; | 841 | unsigned data = *lcdptr; |
836 | linebuf[x] = (data >> 6) & 3; | 842 | linebuf[x] = colorindex[(data >> 6) & 3]; |
837 | linebuf[x + 1] = (data >> 4) & 3; | 843 | linebuf[x + 1] = colorindex[(data >> 4) & 3]; |
838 | linebuf[x + 2] = (data >> 2) & 3; | 844 | linebuf[x + 2] = colorindex[(data >> 2) & 3]; |
839 | linebuf[x + 3] = data & 3; | 845 | linebuf[x + 3] = colorindex[data & 3]; |
840 | } | 846 | } |
841 | lcdptr++; | 847 | lcdptr++; |
842 | } | 848 | } |
@@ -853,16 +859,27 @@ static void grey_screendump_hook(int fd) | |||
853 | if (((unsigned)gy < (unsigned)_grey_info.height) | 859 | if (((unsigned)gy < (unsigned)_grey_info.height) |
854 | && ((unsigned)gx < (unsigned)_grey_info.width)) | 860 | && ((unsigned)gx < (unsigned)_grey_info.width)) |
855 | { | 861 | { |
856 | linebuf[x] = BMP_FIXEDCOLORS | 862 | val = _grey_info.values[_GREY_MULUQ(_grey_info.width, |
857 | + _grey_info.values[_GREY_MULUQ(_grey_info.width, | 863 | gy & ~_GREY_BMASK) |
858 | gy & ~_GREY_BMASK) | 864 | + (gx << _GREY_BSHIFT) |
859 | + (gx << _GREY_BSHIFT) | 865 | + (~gy & _GREY_BMASK)]; |
860 | + (~gy & _GREY_BMASK)]; | 866 | #ifdef HAVE_LCD_SPLIT |
867 | val -= val >> 7; | ||
868 | #endif | ||
861 | } | 869 | } |
862 | else | 870 | else |
863 | { | 871 | { |
864 | linebuf[x] = (*lcdptr & mask) ? 1 : 0; | 872 | #ifdef HAVE_NEGATIVE_LCD |
873 | val = (*lcdptr & mask) ? GRADIENT_MAX : 0; | ||
874 | #else | ||
875 | val = (*lcdptr & mask) ? 0 : GRADIENT_MAX; | ||
876 | #endif | ||
865 | } | 877 | } |
878 | #ifdef HAVE_LCD_SPLIT | ||
879 | if (y < LCD_SPLIT_POS) | ||
880 | val |= 0x80; | ||
881 | #endif | ||
882 | linebuf[x] = val; | ||
866 | lcdptr++; | 883 | lcdptr++; |
867 | } | 884 | } |
868 | #elif LCD_DEPTH == 2 | 885 | #elif LCD_DEPTH == 2 |
@@ -876,15 +893,14 @@ static void grey_screendump_hook(int fd) | |||
876 | if (((unsigned)gy < (unsigned)_grey_info.height) | 893 | if (((unsigned)gy < (unsigned)_grey_info.height) |
877 | && ((unsigned)gx < (unsigned)_grey_info.width)) | 894 | && ((unsigned)gx < (unsigned)_grey_info.width)) |
878 | { | 895 | { |
879 | linebuf[x] = BMP_FIXEDCOLORS | 896 | linebuf[x] = _grey_info.values[_GREY_MULUQ(_grey_info.width, |
880 | + _grey_info.values[_GREY_MULUQ(_grey_info.width, | ||
881 | gy & ~_GREY_BMASK) | 897 | gy & ~_GREY_BMASK) |
882 | + (gx << _GREY_BSHIFT) | 898 | + (gx << _GREY_BSHIFT) |
883 | + (~gy & _GREY_BMASK)]; | 899 | + (~gy & _GREY_BMASK)]; |
884 | } | 900 | } |
885 | else | 901 | else |
886 | { | 902 | { |
887 | linebuf[x] = (*lcdptr >> shift) & 3; | 903 | linebuf[x] = colorindex[(*lcdptr >> shift) & 3]; |
888 | } | 904 | } |
889 | lcdptr++; | 905 | lcdptr++; |
890 | } | 906 | } |
@@ -901,8 +917,7 @@ static void grey_screendump_hook(int fd) | |||
901 | if (((unsigned)gy < (unsigned)_grey_info.height) | 917 | if (((unsigned)gy < (unsigned)_grey_info.height) |
902 | && ((unsigned)gx < (unsigned)_grey_info.width)) | 918 | && ((unsigned)gx < (unsigned)_grey_info.width)) |
903 | { | 919 | { |
904 | linebuf[x] = BMP_FIXEDCOLORS | 920 | linebuf[x] = _grey_info.values[_GREY_MULUQ(_grey_info.width, |
905 | + _grey_info.values[_GREY_MULUQ(_grey_info.width, | ||
906 | gy & ~_GREY_BMASK) | 921 | gy & ~_GREY_BMASK) |
907 | + (gx << _GREY_BSHIFT) | 922 | + (gx << _GREY_BSHIFT) |
908 | + (~gy & _GREY_BMASK)]; | 923 | + (~gy & _GREY_BMASK)]; |
@@ -910,7 +925,7 @@ static void grey_screendump_hook(int fd) | |||
910 | else | 925 | else |
911 | { | 926 | { |
912 | data = (*lcdptr >> shift) & 0x0101; | 927 | data = (*lcdptr >> shift) & 0x0101; |
913 | linebuf[x] = ((data >> 7) | data) & 3; | 928 | linebuf[x] = colorindex[((data >> 7) | data) & 3]; |
914 | } | 929 | } |
915 | lcdptr++; | 930 | lcdptr++; |
916 | } | 931 | } |