summaryrefslogtreecommitdiff
path: root/firmware/drivers/lcd-h100-remote.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/lcd-h100-remote.c')
-rw-r--r--firmware/drivers/lcd-h100-remote.c34
1 files changed, 23 insertions, 11 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