diff options
Diffstat (limited to 'firmware/drivers/lcd-2bit-horz.c')
-rw-r--r-- | firmware/drivers/lcd-2bit-horz.c | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/firmware/drivers/lcd-2bit-horz.c b/firmware/drivers/lcd-2bit-horz.c index 35a2be5b2c..b2114ba830 100644 --- a/firmware/drivers/lcd-2bit-horz.c +++ b/firmware/drivers/lcd-2bit-horz.c | |||
@@ -8,7 +8,7 @@ | |||
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * LCD driver for horizontally-packed 2bpp greyscale display | 10 | * LCD driver for horizontally-packed 2bpp greyscale display |
11 | * | 11 | * |
12 | * Based on code from the rockbox lcd's driver | 12 | * Based on code from the rockbox lcd's driver |
13 | * | 13 | * |
14 | * Copyright (c) 2006 Seven Le Mesle (sevlm@free.fr) | 14 | * Copyright (c) 2006 Seven Le Mesle (sevlm@free.fr) |
@@ -199,7 +199,7 @@ static void flippixel(int x, int y) | |||
199 | { | 199 | { |
200 | unsigned mask = pixmask[x & 3]; | 200 | unsigned mask = pixmask[x & 3]; |
201 | fb_data *address = FBADDR(x>>2,y); | 201 | fb_data *address = FBADDR(x>>2,y); |
202 | 202 | ||
203 | *address ^= mask; | 203 | *address ^= mask; |
204 | } | 204 | } |
205 | 205 | ||
@@ -362,7 +362,7 @@ fb_data* lcd_get_backdrop(void) | |||
362 | static inline void setblock(fb_data *address, unsigned mask, unsigned bits) | 362 | static inline void setblock(fb_data *address, unsigned mask, unsigned bits) |
363 | { | 363 | { |
364 | unsigned data = *address; | 364 | unsigned data = *address; |
365 | 365 | ||
366 | bits ^= data; | 366 | bits ^= data; |
367 | *address = data ^ (bits & mask); | 367 | *address = data ^ (bits & mask); |
368 | } | 368 | } |
@@ -402,7 +402,7 @@ void lcd_clear_viewport(void) | |||
402 | lastmode = lcd_current_viewport->drawmode; | 402 | lastmode = lcd_current_viewport->drawmode; |
403 | 403 | ||
404 | /* Invert the INVERSEVID bit and set basic mode to SOLID */ | 404 | /* Invert the INVERSEVID bit and set basic mode to SOLID */ |
405 | lcd_current_viewport->drawmode = (~lastmode & DRMODE_INVERSEVID) | | 405 | lcd_current_viewport->drawmode = (~lastmode & DRMODE_INVERSEVID) | |
406 | DRMODE_SOLID; | 406 | DRMODE_SOLID; |
407 | 407 | ||
408 | lcd_fillrect(0, 0, lcd_current_viewport->width, lcd_current_viewport->height); | 408 | lcd_fillrect(0, 0, lcd_current_viewport->width, lcd_current_viewport->height); |
@@ -492,7 +492,7 @@ void lcd_drawline(int x1, int y1, int x2, int y2) | |||
492 | 492 | ||
493 | for (i = 0; i < numpixels; i++) | 493 | for (i = 0; i < numpixels; i++) |
494 | { | 494 | { |
495 | if ( ((unsigned)x < (unsigned)lcd_current_viewport->width) | 495 | if ( ((unsigned)x < (unsigned)lcd_current_viewport->width) |
496 | && ((unsigned)y < (unsigned)lcd_current_viewport->height) | 496 | && ((unsigned)y < (unsigned)lcd_current_viewport->height) |
497 | #if defined(HAVE_VIEWPORT_CLIP) | 497 | #if defined(HAVE_VIEWPORT_CLIP) |
498 | && ((unsigned)x < (unsigned)LCD_WIDTH) | 498 | && ((unsigned)x < (unsigned)LCD_WIDTH) |
@@ -531,13 +531,13 @@ void lcd_hline(int x1, int x2, int y) | |||
531 | x1 = x2; | 531 | x1 = x2; |
532 | x2 = nx; | 532 | x2 = nx; |
533 | } | 533 | } |
534 | 534 | ||
535 | /******************** In viewport clipping **********************/ | 535 | /******************** In viewport clipping **********************/ |
536 | /* nothing to draw? */ | 536 | /* nothing to draw? */ |
537 | if (((unsigned)y >= (unsigned)lcd_current_viewport->height) || (x1 >= lcd_current_viewport->width) | 537 | if (((unsigned)y >= (unsigned)lcd_current_viewport->height) || (x1 >= lcd_current_viewport->width) |
538 | || (x2 < 0)) | 538 | || (x2 < 0)) |
539 | return; | 539 | return; |
540 | 540 | ||
541 | if (x1 < 0) | 541 | if (x1 < 0) |
542 | x1 = 0; | 542 | x1 = 0; |
543 | if (x2 >= lcd_current_viewport->width) | 543 | if (x2 >= lcd_current_viewport->width) |
@@ -547,14 +547,14 @@ void lcd_hline(int x1, int x2, int y) | |||
547 | x1 += lcd_current_viewport->x; | 547 | x1 += lcd_current_viewport->x; |
548 | x2 += lcd_current_viewport->x; | 548 | x2 += lcd_current_viewport->x; |
549 | y += lcd_current_viewport->y; | 549 | y += lcd_current_viewport->y; |
550 | 550 | ||
551 | #if defined(HAVE_VIEWPORT_CLIP) | 551 | #if defined(HAVE_VIEWPORT_CLIP) |
552 | /********************* Viewport on screen clipping ********************/ | 552 | /********************* Viewport on screen clipping ********************/ |
553 | /* nothing to draw? */ | 553 | /* nothing to draw? */ |
554 | if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH) | 554 | if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH) |
555 | || (x2 < 0)) | 555 | || (x2 < 0)) |
556 | return; | 556 | return; |
557 | 557 | ||
558 | /* clipping */ | 558 | /* clipping */ |
559 | if (x1 < 0) | 559 | if (x1 < 0) |
560 | x1 = 0; | 560 | x1 = 0; |
@@ -567,7 +567,7 @@ void lcd_hline(int x1, int x2, int y) | |||
567 | nx = x2 - (x1 & ~3); | 567 | nx = x2 - (x1 & ~3); |
568 | mask = 0xFFu >> (2 * (x1 & 3)); | 568 | mask = 0xFFu >> (2 * (x1 & 3)); |
569 | mask_right = 0xFFu << (2 * (~nx & 3)); | 569 | mask_right = 0xFFu << (2 * (~nx & 3)); |
570 | 570 | ||
571 | for (; nx >= 4; nx -= 4) | 571 | for (; nx >= 4; nx -= 4) |
572 | { | 572 | { |
573 | bfunc(dst++, mask, 0xFFu); | 573 | bfunc(dst++, mask, 0xFFu); |
@@ -598,8 +598,8 @@ void lcd_vline(int x, int y1, int y2) | |||
598 | /* nothing to draw? */ | 598 | /* nothing to draw? */ |
599 | if (((unsigned)x >= (unsigned)lcd_current_viewport->width) || (y1 >= lcd_current_viewport->height) | 599 | if (((unsigned)x >= (unsigned)lcd_current_viewport->width) || (y1 >= lcd_current_viewport->height) |
600 | || (y2 < 0)) | 600 | || (y2 < 0)) |
601 | return; | 601 | return; |
602 | 602 | ||
603 | if (y1 < 0) | 603 | if (y1 < 0) |
604 | y1 = 0; | 604 | y1 = 0; |
605 | if (y2 >= lcd_current_viewport->height) | 605 | if (y2 >= lcd_current_viewport->height) |
@@ -609,26 +609,26 @@ void lcd_vline(int x, int y1, int y2) | |||
609 | y1 += lcd_current_viewport->y; | 609 | y1 += lcd_current_viewport->y; |
610 | y2 += lcd_current_viewport->y; | 610 | y2 += lcd_current_viewport->y; |
611 | x += lcd_current_viewport->x; | 611 | x += lcd_current_viewport->x; |
612 | 612 | ||
613 | #if defined(HAVE_VIEWPORT_CLIP) | 613 | #if defined(HAVE_VIEWPORT_CLIP) |
614 | /********************* Viewport on screen clipping ********************/ | 614 | /********************* Viewport on screen clipping ********************/ |
615 | /* nothing to draw? */ | 615 | /* nothing to draw? */ |
616 | if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) | 616 | if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) |
617 | || (y2 < 0)) | 617 | || (y2 < 0)) |
618 | return; | 618 | return; |
619 | 619 | ||
620 | /* clipping */ | 620 | /* clipping */ |
621 | if (y1 < 0) | 621 | if (y1 < 0) |
622 | y1 = 0; | 622 | y1 = 0; |
623 | if (y2 >= LCD_HEIGHT) | 623 | if (y2 >= LCD_HEIGHT) |
624 | y2 = LCD_HEIGHT-1; | 624 | y2 = LCD_HEIGHT-1; |
625 | #endif | 625 | #endif |
626 | 626 | ||
627 | bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode]; | 627 | bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode]; |
628 | dst = FBADDR(x>>2,y1); | 628 | dst = FBADDR(x>>2,y1); |
629 | stride_dst = LCD_FBSTRIDE(lcd_current_viewport->buffer->stride, 0); | 629 | stride_dst = LCD_FBSTRIDE(lcd_current_viewport->buffer->stride, 0); |
630 | mask = pixmask[x & 3]; | 630 | mask = pixmask[x & 3]; |
631 | 631 | ||
632 | dst_end = dst + (y2 - y1) * stride_dst; | 632 | dst_end = dst + (y2 - y1) * stride_dst; |
633 | do | 633 | do |
634 | { | 634 | { |
@@ -686,14 +686,14 @@ void lcd_fillrect(int x, int y, int width, int height) | |||
686 | /* adjust for viewport */ | 686 | /* adjust for viewport */ |
687 | x += lcd_current_viewport->x; | 687 | x += lcd_current_viewport->x; |
688 | y += lcd_current_viewport->y; | 688 | y += lcd_current_viewport->y; |
689 | 689 | ||
690 | #if defined(HAVE_VIEWPORT_CLIP) | 690 | #if defined(HAVE_VIEWPORT_CLIP) |
691 | /********************* Viewport on screen clipping ********************/ | 691 | /********************* Viewport on screen clipping ********************/ |
692 | /* nothing to draw? */ | 692 | /* nothing to draw? */ |
693 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) | 693 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) |
694 | || (x + width <= 0) || (y + height <= 0)) | 694 | || (x + width <= 0) || (y + height <= 0)) |
695 | return; | 695 | return; |
696 | 696 | ||
697 | /* clip image in viewport in screen */ | 697 | /* clip image in viewport in screen */ |
698 | if (x < 0) | 698 | if (x < 0) |
699 | { | 699 | { |
@@ -717,7 +717,7 @@ void lcd_fillrect(int x, int y, int width, int height) | |||
717 | nx = width - 1 + (x & 3); | 717 | nx = width - 1 + (x & 3); |
718 | mask = 0xFFu >> (2 * (x & 3)); | 718 | mask = 0xFFu >> (2 * (x & 3)); |
719 | mask_right = 0xFFu << (2 * (~nx & 3)); | 719 | mask_right = 0xFFu << (2 * (~nx & 3)); |
720 | 720 | ||
721 | for (; nx >= 4; nx -= 4) | 721 | for (; nx >= 4; nx -= 4) |
722 | { | 722 | { |
723 | unsigned char *dst_col = dst; | 723 | unsigned char *dst_col = dst; |
@@ -770,7 +770,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
770 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || | 770 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || |
771 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) | 771 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) |
772 | return; | 772 | return; |
773 | 773 | ||
774 | if (x < 0) | 774 | if (x < 0) |
775 | { | 775 | { |
776 | width += x; | 776 | width += x; |
@@ -787,17 +787,17 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
787 | width = lcd_current_viewport->width - x; | 787 | width = lcd_current_viewport->width - x; |
788 | if (y + height > lcd_current_viewport->height) | 788 | if (y + height > lcd_current_viewport->height) |
789 | height = lcd_current_viewport->height - y; | 789 | height = lcd_current_viewport->height - y; |
790 | 790 | ||
791 | x += lcd_current_viewport->x; /* adjust for viewport */ | 791 | x += lcd_current_viewport->x; /* adjust for viewport */ |
792 | y += lcd_current_viewport->y; /* adjust for viewport */ | 792 | y += lcd_current_viewport->y; /* adjust for viewport */ |
793 | 793 | ||
794 | #if defined(HAVE_VIEWPORT_CLIP) | 794 | #if defined(HAVE_VIEWPORT_CLIP) |
795 | /********************* Viewport on screen clipping ********************/ | 795 | /********************* Viewport on screen clipping ********************/ |
796 | /* nothing to draw? */ | 796 | /* nothing to draw? */ |
797 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) | 797 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) |
798 | || (x + width <= 0) || (y + height <= 0)) | 798 | || (x + width <= 0) || (y + height <= 0)) |
799 | return; | 799 | return; |
800 | 800 | ||
801 | /* clip image in viewport in screen */ | 801 | /* clip image in viewport in screen */ |
802 | if (x < 0) | 802 | if (x < 0) |
803 | { | 803 | { |
@@ -820,7 +820,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
820 | src += stride * (src_y >> 3) + src_x; /* move starting point */ | 820 | src += stride * (src_y >> 3) + src_x; /* move starting point */ |
821 | src_y &= 7; | 821 | src_y &= 7; |
822 | src_end = src + width; | 822 | src_end = src + width; |
823 | 823 | ||
824 | dst = FBADDR(x >> 2,y); | 824 | dst = FBADDR(x >> 2,y); |
825 | stride_dst = LCD_FBSTRIDE(lcd_current_viewport->buffer->stride, 0); | 825 | stride_dst = LCD_FBSTRIDE(lcd_current_viewport->buffer->stride, 0); |
826 | dst_end = dst + height * stride_dst; | 826 | dst_end = dst + height * stride_dst; |
@@ -835,7 +835,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
835 | do | 835 | do |
836 | { | 836 | { |
837 | const unsigned char *src_col = src++; | 837 | const unsigned char *src_col = src++; |
838 | unsigned data = (*src_col ^ dmask) >> src_y; | 838 | unsigned data = (*src_col ^ dmask) >> src_y; |
839 | fb_data *dst_col = dst; | 839 | fb_data *dst_col = dst; |
840 | int fg, bg; | 840 | int fg, bg; |
841 | long bo; | 841 | long bo; |
@@ -847,7 +847,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
847 | data = *src_col ^ dmask; \ | 847 | data = *src_col ^ dmask; \ |
848 | } \ | 848 | } \ |
849 | } while (0) | 849 | } while (0) |
850 | 850 | ||
851 | switch (drmode) | 851 | switch (drmode) |
852 | { | 852 | { |
853 | case DRMODE_COMPLEMENT: | 853 | case DRMODE_COMPLEMENT: |
@@ -861,7 +861,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
861 | } | 861 | } |
862 | while (dst_col < dst_end); | 862 | while (dst_col < dst_end); |
863 | break; | 863 | break; |
864 | 864 | ||
865 | case DRMODE_BG: | 865 | case DRMODE_BG: |
866 | if (lcd_backdrop) | 866 | if (lcd_backdrop) |
867 | { | 867 | { |
@@ -919,7 +919,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x, | |||
919 | do | 919 | do |
920 | { | 920 | { |
921 | unsigned block = *dst_col; | 921 | unsigned block = *dst_col; |
922 | *dst_col = block ^ ((block ^ ((data & 0x01) ? | 922 | *dst_col = block ^ ((block ^ ((data & 0x01) ? |
923 | fg : *(dst_col + bo))) & dst_mask); | 923 | fg : *(dst_col + bo))) & dst_mask); |
924 | 924 | ||
925 | dst_col += stride_dst; | 925 | dst_col += stride_dst; |
@@ -981,10 +981,10 @@ void ICODE_ATTR lcd_bitmap_part(const unsigned char *src, int src_x, | |||
981 | 981 | ||
982 | /******************** Image in viewport clipping **********************/ | 982 | /******************** Image in viewport clipping **********************/ |
983 | /* nothing to draw? */ | 983 | /* nothing to draw? */ |
984 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || | 984 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || |
985 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) | 985 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) |
986 | return; | 986 | return; |
987 | 987 | ||
988 | if (x < 0) | 988 | if (x < 0) |
989 | { | 989 | { |
990 | width += x; | 990 | width += x; |
@@ -1005,14 +1005,14 @@ void ICODE_ATTR lcd_bitmap_part(const unsigned char *src, int src_x, | |||
1005 | /* adjust for viewport */ | 1005 | /* adjust for viewport */ |
1006 | x += lcd_current_viewport->x; | 1006 | x += lcd_current_viewport->x; |
1007 | y += lcd_current_viewport->y; | 1007 | y += lcd_current_viewport->y; |
1008 | 1008 | ||
1009 | #if defined(HAVE_VIEWPORT_CLIP) | 1009 | #if defined(HAVE_VIEWPORT_CLIP) |
1010 | /********************* Viewport on screen clipping ********************/ | 1010 | /********************* Viewport on screen clipping ********************/ |
1011 | /* nothing to draw? */ | 1011 | /* nothing to draw? */ |
1012 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) | 1012 | if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) |
1013 | || (x + width <= 0) || (y + height <= 0)) | 1013 | || (x + width <= 0) || (y + height <= 0)) |
1014 | return; | 1014 | return; |
1015 | 1015 | ||
1016 | /* clip image in viewport in screen */ | 1016 | /* clip image in viewport in screen */ |
1017 | if (x < 0) | 1017 | if (x < 0) |
1018 | { | 1018 | { |
@@ -1044,7 +1044,7 @@ void ICODE_ATTR lcd_bitmap_part(const unsigned char *src, int src_x, | |||
1044 | 1044 | ||
1045 | mask = 0xFF00u >> (2 * (shift + src_x)); | 1045 | mask = 0xFF00u >> (2 * (shift + src_x)); |
1046 | mask_right = 0xFFu << (2 * (~nx & 3)); | 1046 | mask_right = 0xFFu << (2 * (~nx & 3)); |
1047 | 1047 | ||
1048 | shift *= 2; | 1048 | shift *= 2; |
1049 | dst_end = dst + height * stride_dst; | 1049 | dst_end = dst + height * stride_dst; |
1050 | do | 1050 | do |
@@ -1053,11 +1053,11 @@ void ICODE_ATTR lcd_bitmap_part(const unsigned char *src, int src_x, | |||
1053 | unsigned char *dst_row = dst; | 1053 | unsigned char *dst_row = dst; |
1054 | unsigned mask_row = mask >> 8; | 1054 | unsigned mask_row = mask >> 8; |
1055 | unsigned data = 0; | 1055 | unsigned data = 0; |
1056 | 1056 | ||
1057 | for (x = nx; x >= 4; x -= 4) | 1057 | for (x = nx; x >= 4; x -= 4) |
1058 | { | 1058 | { |
1059 | data = (data << 8) | *src_row++; | 1059 | data = (data << 8) | *src_row++; |
1060 | 1060 | ||
1061 | if (mask_row & 0xFF) | 1061 | if (mask_row & 0xFF) |
1062 | { | 1062 | { |
1063 | setblock(dst_row, mask_row, data >> shift); | 1063 | setblock(dst_row, mask_row, data >> shift); |