summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/lcd-h100-remote.c34
-rw-r--r--firmware/drivers/lcd-h100.c34
-rw-r--r--firmware/drivers/lcd-recorder.c36
3 files changed, 70 insertions, 34 deletions
diff --git a/firmware/drivers/lcd-h100-remote.c b/firmware/drivers/lcd-h100-remote.c
index 8112aecdb1..af6a45c2c0 100644
--- a/firmware/drivers/lcd-h100-remote.c
+++ b/firmware/drivers/lcd-h100-remote.c
@@ -653,7 +653,7 @@ void lcd_remote_drawline(int x1, int y1, int x2, int y2)
653void lcd_remote_hline(int x1, int x2, int y) 653void lcd_remote_hline(int x1, int x2, int y)
654{ 654{
655 int x; 655 int x;
656 unsigned char *dst; 656 unsigned char *dst, *dst_end;
657 unsigned mask; 657 unsigned mask;
658 lcd_blockfunc_type *bfunc; 658 lcd_blockfunc_type *bfunc;
659 659
@@ -680,8 +680,10 @@ void lcd_remote_hline(int x1, int x2, int y)
680 dst = &lcd_remote_framebuffer[y>>3][x1]; 680 dst = &lcd_remote_framebuffer[y>>3][x1];
681 mask = 1 << (y & 7); 681 mask = 1 << (y & 7);
682 682
683 for (x = x1; x <= x2; x++) 683 dst_end = dst + x2 - x1;
684 do
684 bfunc(dst++, mask, 0xFFu); 685 bfunc(dst++, mask, 0xFFu);
686 while (dst <= dst_end);
685} 687}
686 688
687/* Draw a vertical line (optimised) */ 689/* Draw a vertical line (optimised) */
@@ -745,8 +747,8 @@ void lcd_remote_drawrect(int x, int y, int width, int height)
745/* Fill a rectangular area */ 747/* Fill a rectangular area */
746void lcd_remote_fillrect(int x, int y, int width, int height) 748void lcd_remote_fillrect(int x, int y, int width, int height)
747{ 749{
748 int ny, i; 750 int ny;
749 unsigned char *dst; 751 unsigned char *dst, *dst_end;
750 unsigned mask, mask_bottom; 752 unsigned mask, mask_bottom;
751 unsigned bits = 0xFFu; 753 unsigned bits = 0xFFu;
752 lcd_blockfunc_type *bfunc; 754 lcd_blockfunc_type *bfunc;
@@ -791,8 +793,10 @@ void lcd_remote_fillrect(int x, int y, int width, int height)
791 { 793 {
792 unsigned char *dst_row = dst; 794 unsigned char *dst_row = dst;
793 795
794 for (i = width; i > 0; i--) 796 dst_end = dst_row + width;
797 do
795 bfunc(dst_row++, mask, 0xFFu); 798 bfunc(dst_row++, mask, 0xFFu);
799 while (dst_row < dst_end);
796 } 800 }
797 801
798 dst += LCD_REMOTE_WIDTH; 802 dst += LCD_REMOTE_WIDTH;
@@ -804,8 +808,10 @@ void lcd_remote_fillrect(int x, int y, int width, int height)
804 memset(dst, bits, width); 808 memset(dst, bits, width);
805 else 809 else
806 { 810 {
807 for (i = width; i > 0; i--) 811 dst_end = dst + width;
812 do
808 bfunc(dst++, mask, 0xFFu); 813 bfunc(dst++, mask, 0xFFu);
814 while (dst < dst_end);
809 } 815 }
810} 816}
811 817
@@ -827,8 +833,8 @@ void lcd_remote_bitmap_part(const unsigned char *src, int src_x, int src_y,
827void lcd_remote_bitmap_part(const unsigned char *src, int src_x, int src_y, 833void lcd_remote_bitmap_part(const unsigned char *src, int src_x, int src_y,
828 int stride, int x, int y, int width, int height) 834 int stride, int x, int y, int width, int height)
829{ 835{
830 int shift, ny, i; 836 int shift, ny;
831 unsigned char *dst; 837 unsigned char *dst, *dst_end;
832 unsigned mask, mask_bottom; 838 unsigned mask, mask_bottom;
833 lcd_blockfunc_type *bfunc; 839 lcd_blockfunc_type *bfunc;
834 840
@@ -879,8 +885,10 @@ void lcd_remote_bitmap_part(const unsigned char *src, int src_x, int src_y,
879 const unsigned char *src_row = src; 885 const unsigned char *src_row = src;
880 unsigned char *dst_row = dst; 886 unsigned char *dst_row = dst;
881 887
882 for (i = width; i > 0; i--) 888 dst_end = dst_row + width;
889 do
883 bfunc(dst_row++, mask, *src_row++); 890 bfunc(dst_row++, mask, *src_row++);
891 while (dst_row < dst_end);
884 } 892 }
885 893
886 src += stride; 894 src += stride;
@@ -893,13 +901,16 @@ void lcd_remote_bitmap_part(const unsigned char *src, int src_x, int src_y,
893 memcpy(dst, src, width); 901 memcpy(dst, src, width);
894 else 902 else
895 { 903 {
896 for (i = width; i > 0; i--) 904 dst_end = dst + width;
905 do
897 bfunc(dst++, mask, *src++); 906 bfunc(dst++, mask, *src++);
907 while (dst < dst_end);
898 } 908 }
899 } 909 }
900 else 910 else
901 { 911 {
902 for (x = 0; x < width; x++) 912 dst_end = dst + width;
913 do
903 { 914 {
904 const unsigned char *src_col = src++; 915 const unsigned char *src_col = src++;
905 unsigned char *dst_col = dst++; 916 unsigned char *dst_col = dst++;
@@ -925,6 +936,7 @@ void lcd_remote_bitmap_part(const unsigned char *src, int src_x, int src_y,
925 data |= *src_col << shift; 936 data |= *src_col << shift;
926 bfunc(dst_col, mask_col & mask_bottom, data); 937 bfunc(dst_col, mask_col & mask_bottom, data);
927 } 938 }
939 while (dst < dst_end);
928 } 940 }
929} 941}
930 942
diff --git a/firmware/drivers/lcd-h100.c b/firmware/drivers/lcd-h100.c
index 3d858e2271..379838d068 100644
--- a/firmware/drivers/lcd-h100.c
+++ b/firmware/drivers/lcd-h100.c
@@ -492,7 +492,7 @@ void lcd_drawline(int x1, int y1, int x2, int y2)
492void lcd_hline(int x1, int x2, int y) 492void lcd_hline(int x1, int x2, int y)
493{ 493{
494 int x; 494 int x;
495 unsigned char *dst; 495 unsigned char *dst, *dst_end;
496 unsigned mask; 496 unsigned mask;
497 lcd_blockfunc_type *bfunc; 497 lcd_blockfunc_type *bfunc;
498 498
@@ -518,8 +518,10 @@ void lcd_hline(int x1, int x2, int y)
518 dst = &lcd_framebuffer[y>>3][x1]; 518 dst = &lcd_framebuffer[y>>3][x1];
519 mask = 1 << (y & 7); 519 mask = 1 << (y & 7);
520 520
521 for (x = x1; x <= x2; x++) 521 dst_end = dst + x2 - x1;
522 do
522 bfunc(dst++, mask, 0xFFu); 523 bfunc(dst++, mask, 0xFFu);
524 while (dst <= dst_end);
523} 525}
524 526
525/* Draw a vertical line (optimised) */ 527/* Draw a vertical line (optimised) */
@@ -582,8 +584,8 @@ void lcd_drawrect(int x, int y, int width, int height)
582/* Fill a rectangular area */ 584/* Fill a rectangular area */
583void lcd_fillrect(int x, int y, int width, int height) 585void lcd_fillrect(int x, int y, int width, int height)
584{ 586{
585 int ny, i; 587 int ny;
586 unsigned char *dst; 588 unsigned char *dst, *dst_end;
587 unsigned mask, mask_bottom; 589 unsigned mask, mask_bottom;
588 unsigned bits = 0xFFu; 590 unsigned bits = 0xFFu;
589 lcd_blockfunc_type *bfunc; 591 lcd_blockfunc_type *bfunc;
@@ -628,8 +630,10 @@ void lcd_fillrect(int x, int y, int width, int height)
628 { 630 {
629 unsigned char *dst_row = dst; 631 unsigned char *dst_row = dst;
630 632
631 for (i = width; i > 0; i--) 633 dst_end = dst_row + width;
634 do
632 bfunc(dst_row++, mask, 0xFFu); 635 bfunc(dst_row++, mask, 0xFFu);
636 while (dst_row < dst_end);
633 } 637 }
634 638
635 dst += LCD_WIDTH; 639 dst += LCD_WIDTH;
@@ -641,8 +645,10 @@ void lcd_fillrect(int x, int y, int width, int height)
641 memset(dst, bits, width); 645 memset(dst, bits, width);
642 else 646 else
643 { 647 {
644 for (i = width; i > 0; i--) 648 dst_end = dst + width;
649 do
645 bfunc(dst++, mask, 0xFFu); 650 bfunc(dst++, mask, 0xFFu);
651 while (dst < dst_end);
646 } 652 }
647} 653}
648 654
@@ -664,8 +670,8 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
664void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y, 670void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
665 int stride, int x, int y, int width, int height) 671 int stride, int x, int y, int width, int height)
666{ 672{
667 int shift, ny, i; 673 int shift, ny;
668 unsigned char *dst; 674 unsigned char *dst, *dst_end;
669 unsigned mask, mask_bottom; 675 unsigned mask, mask_bottom;
670 lcd_blockfunc_type *bfunc; 676 lcd_blockfunc_type *bfunc;
671 677
@@ -716,8 +722,10 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
716 const unsigned char *src_row = src; 722 const unsigned char *src_row = src;
717 unsigned char *dst_row = dst; 723 unsigned char *dst_row = dst;
718 724
719 for (i = width; i > 0; i--) 725 dst_end = dst_row + width;
726 do
720 bfunc(dst_row++, mask, *src_row++); 727 bfunc(dst_row++, mask, *src_row++);
728 while (dst_row < dst_end);
721 } 729 }
722 730
723 src += stride; 731 src += stride;
@@ -730,13 +738,16 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
730 memcpy(dst, src, width); 738 memcpy(dst, src, width);
731 else 739 else
732 { 740 {
733 for (i = width; i > 0; i--) 741 dst_end = dst + width;
742 do
734 bfunc(dst++, mask, *src++); 743 bfunc(dst++, mask, *src++);
744 while (dst < dst_end);
735 } 745 }
736 } 746 }
737 else 747 else
738 { 748 {
739 for (x = 0; x < width; x++) 749 dst_end = dst + width;
750 do
740 { 751 {
741 const unsigned char *src_col = src++; 752 const unsigned char *src_col = src++;
742 unsigned char *dst_col = dst++; 753 unsigned char *dst_col = dst++;
@@ -762,6 +773,7 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
762 data |= *src_col << shift; 773 data |= *src_col << shift;
763 bfunc(dst_col, mask_col & mask_bottom, data); 774 bfunc(dst_col, mask_col & mask_bottom, data);
764 } 775 }
776 while (dst < dst_end);
765 } 777 }
766} 778}
767 779
diff --git a/firmware/drivers/lcd-recorder.c b/firmware/drivers/lcd-recorder.c
index f933e6ca5c..b857708514 100644
--- a/firmware/drivers/lcd-recorder.c
+++ b/firmware/drivers/lcd-recorder.c
@@ -549,7 +549,7 @@ void lcd_drawline(int x1, int y1, int x2, int y2)
549void lcd_hline(int x1, int x2, int y) 549void lcd_hline(int x1, int x2, int y)
550{ 550{
551 int x; 551 int x;
552 unsigned char *dst; 552 unsigned char *dst, *dst_end;
553 unsigned mask; 553 unsigned mask;
554 lcd_blockfunc_type *bfunc; 554 lcd_blockfunc_type *bfunc;
555 555
@@ -575,8 +575,10 @@ void lcd_hline(int x1, int x2, int y)
575 dst = &lcd_framebuffer[y>>3][x1]; 575 dst = &lcd_framebuffer[y>>3][x1];
576 mask = 1 << (y & 7); 576 mask = 1 << (y & 7);
577 577
578 for (x = x1; x <= x2; x++) 578 dst_end = dst + x2 - x1;
579 do
579 bfunc(dst++, mask, 0xFFu); 580 bfunc(dst++, mask, 0xFFu);
581 while (dst <= dst_end);
580} 582}
581 583
582/* Draw a vertical line (optimised) */ 584/* Draw a vertical line (optimised) */
@@ -639,8 +641,8 @@ void lcd_drawrect(int x, int y, int width, int height)
639/* Fill a rectangular area */ 641/* Fill a rectangular area */
640void lcd_fillrect(int x, int y, int width, int height) 642void lcd_fillrect(int x, int y, int width, int height)
641{ 643{
642 int ny, i; 644 int ny;
643 unsigned char *dst; 645 unsigned char *dst, *dst_end;
644 unsigned mask, mask_bottom; 646 unsigned mask, mask_bottom;
645 unsigned bits = 0xFFu; 647 unsigned bits = 0xFFu;
646 lcd_blockfunc_type *bfunc; 648 lcd_blockfunc_type *bfunc;
@@ -685,8 +687,10 @@ void lcd_fillrect(int x, int y, int width, int height)
685 { 687 {
686 unsigned char *dst_row = dst; 688 unsigned char *dst_row = dst;
687 689
688 for (i = width; i > 0; i--) 690 dst_end = dst_row + width;
691 do
689 bfunc(dst_row++, mask, 0xFFu); 692 bfunc(dst_row++, mask, 0xFFu);
693 while (dst_row < dst_end);
690 } 694 }
691 695
692 dst += LCD_WIDTH; 696 dst += LCD_WIDTH;
@@ -698,8 +702,10 @@ void lcd_fillrect(int x, int y, int width, int height)
698 memset(dst, bits, width); 702 memset(dst, bits, width);
699 else 703 else
700 { 704 {
701 for (i = width; i > 0; i--) 705 dst_end = dst + width;
706 do
702 bfunc(dst++, mask, 0xFFu); 707 bfunc(dst++, mask, 0xFFu);
708 while (dst < dst_end);
703 } 709 }
704} 710}
705 711
@@ -721,8 +727,8 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
721void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y, 727void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
722 int stride, int x, int y, int width, int height) 728 int stride, int x, int y, int width, int height)
723{ 729{
724 int shift, ny, i; 730 int shift, ny;
725 unsigned char *dst; 731 unsigned char *dst, *dst_end;
726 unsigned mask, mask_bottom; 732 unsigned mask, mask_bottom;
727 lcd_blockfunc_type *bfunc; 733 lcd_blockfunc_type *bfunc;
728 734
@@ -772,9 +778,11 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
772 { 778 {
773 const unsigned char *src_row = src; 779 const unsigned char *src_row = src;
774 unsigned char *dst_row = dst; 780 unsigned char *dst_row = dst;
775 781
776 for (i = width; i > 0; i--) 782 dst_end = dst_row + width;
783 do
777 bfunc(dst_row++, mask, *src_row++); 784 bfunc(dst_row++, mask, *src_row++);
785 while (dst_row < dst_end);
778 } 786 }
779 787
780 src += stride; 788 src += stride;
@@ -787,13 +795,16 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
787 memcpy(dst, src, width); 795 memcpy(dst, src, width);
788 else 796 else
789 { 797 {
790 for (i = width; i > 0; i--) 798 dst_end = dst + width;
799 do
791 bfunc(dst++, mask, *src++); 800 bfunc(dst++, mask, *src++);
801 while (dst < dst_end);
792 } 802 }
793 } 803 }
794 else 804 else
795 { 805 {
796 for (x = 0; x < width; x++) 806 dst_end = dst + width;
807 do
797 { 808 {
798 const unsigned char *src_col = src++; 809 const unsigned char *src_col = src++;
799 unsigned char *dst_col = dst++; 810 unsigned char *dst_col = dst++;
@@ -819,6 +830,7 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y,
819 data |= *src_col << shift; 830 data |= *src_col << shift;
820 bfunc(dst_col, mask_col & mask_bottom, data); 831 bfunc(dst_col, mask_col & mask_bottom, data);
821 } 832 }
833 while (dst < dst_end);
822 } 834 }
823} 835}
824 836