diff options
author | Jens Arnold <amiconn@rockbox.org> | 2006-07-28 07:17:00 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2006-07-28 07:17:00 +0000 |
commit | cb36fec3922cb1317bdb06a6497370f188694d4e (patch) | |
tree | 5dfe6aa35f8e55485e18de4c5bdac0ed54e8d80c /firmware/drivers | |
parent | 2d4cfa8738abc42603de8f90e715433bb4345dd7 (diff) | |
download | rockbox-cb36fec3922cb1317bdb06a6497370f188694d4e.tar.gz rockbox-cb36fec3922cb1317bdb06a6497370f188694d4e.zip |
LCD drivers: * Slight speedup for 2bit greyscale drivers. Use the same scrolltext drawing anywhere. * Cleanup, fixes and definitions in preparation for X5 remote.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10346 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/lcd-16bit.c | 3 | ||||
-rw-r--r-- | firmware/drivers/lcd-2bit-horz.c | 71 | ||||
-rw-r--r-- | firmware/drivers/lcd-h100-remote.c | 70 | ||||
-rw-r--r-- | firmware/drivers/lcd-h100.c | 91 |
4 files changed, 120 insertions, 115 deletions
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c index d237dac858..fd95f2aa16 100644 --- a/firmware/drivers/lcd-16bit.c +++ b/firmware/drivers/lcd-16bit.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #include "rbunicode.h" | 34 | #include "rbunicode.h" |
35 | #include "bidi.h" | 35 | #include "bidi.h" |
36 | 36 | ||
37 | #define SCROLLABLE_LINES 26 | 37 | #define SCROLLABLE_LINES ((LCD_HEIGHT+4)/5 < 32 ? (LCD_HEIGHT+4)/5 : 32) |
38 | 38 | ||
39 | enum fill_opt { | 39 | enum fill_opt { |
40 | OPT_NONE = 0, | 40 | OPT_NONE = 0, |
@@ -972,4 +972,3 @@ static void scroll_thread(void) | |||
972 | sleep(scroll_ticks); | 972 | sleep(scroll_ticks); |
973 | } | 973 | } |
974 | } | 974 | } |
975 | |||
diff --git a/firmware/drivers/lcd-2bit-horz.c b/firmware/drivers/lcd-2bit-horz.c index 4ee2e2ea28..68074e36e8 100644 --- a/firmware/drivers/lcd-2bit-horz.c +++ b/firmware/drivers/lcd-2bit-horz.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #include "rbunicode.h" | 34 | #include "rbunicode.h" |
35 | #include "bidi.h" | 35 | #include "bidi.h" |
36 | 36 | ||
37 | #define SCROLLABLE_LINES 26 | 37 | #define SCROLLABLE_LINES (((LCD_HEIGHT+4)/5 < 32) ? (LCD_HEIGHT+4)/5 : 32) |
38 | 38 | ||
39 | /*** globals ***/ | 39 | /*** globals ***/ |
40 | 40 | ||
@@ -148,21 +148,28 @@ int lcd_getstringsize(const unsigned char *str, int *w, int *h) | |||
148 | 148 | ||
149 | static void setpixel(int x, int y) | 149 | static void setpixel(int x, int y) |
150 | { | 150 | { |
151 | unsigned char *data = &lcd_framebuffer[y][x>>2]; | ||
152 | unsigned mask = pixmask[x & 3]; | 151 | unsigned mask = pixmask[x & 3]; |
153 | *data = (*data & ~mask) | (fg_pattern & mask); | 152 | fb_data *address = &lcd_framebuffer[y][x>>2]; |
153 | unsigned data = *address; | ||
154 | |||
155 | *address = data ^ ((data ^ fg_pattern) & mask); | ||
154 | } | 156 | } |
155 | 157 | ||
156 | static void clearpixel(int x, int y) | 158 | static void clearpixel(int x, int y) |
157 | { | 159 | { |
158 | unsigned char *data = &lcd_framebuffer[y][x>>2]; | ||
159 | unsigned mask = pixmask[x & 3]; | 160 | unsigned mask = pixmask[x & 3]; |
160 | *data = (*data & ~mask) | (bg_pattern & mask); | 161 | fb_data *address = &lcd_framebuffer[y][x>>2]; |
162 | unsigned data = *address; | ||
163 | |||
164 | *address = data ^ ((data ^ bg_pattern) & mask); | ||
161 | } | 165 | } |
162 | 166 | ||
163 | static void flippixel(int x, int y) | 167 | static void flippixel(int x, int y) |
164 | { | 168 | { |
165 | lcd_framebuffer[y][x>>2] ^= pixmask[x & 3]; | 169 | unsigned mask = pixmask[x & 3]; |
170 | fb_data *address = &lcd_framebuffer[y][x>>2]; | ||
171 | |||
172 | *address ^= mask; | ||
166 | } | 173 | } |
167 | 174 | ||
168 | static void nopixel(int x, int y) | 175 | static void nopixel(int x, int y) |
@@ -177,34 +184,34 @@ lcd_pixelfunc_type* const lcd_pixelfuncs[8] = { | |||
177 | }; | 184 | }; |
178 | 185 | ||
179 | /* 'mask' and 'bits' contain 2 bits per pixel */ | 186 | /* 'mask' and 'bits' contain 2 bits per pixel */ |
180 | static void flipblock(unsigned char *address, unsigned mask, unsigned bits) | 187 | static void flipblock(fb_data *address, unsigned mask, unsigned bits) |
181 | ICODE_ATTR; | 188 | ICODE_ATTR; |
182 | static void flipblock(unsigned char *address, unsigned mask, unsigned bits) | 189 | static void flipblock(fb_data *address, unsigned mask, unsigned bits) |
183 | { | 190 | { |
184 | *address ^= bits & mask; | 191 | *address ^= bits & mask; |
185 | } | 192 | } |
186 | 193 | ||
187 | static void bgblock(unsigned char *address, unsigned mask, unsigned bits) | 194 | static void bgblock(fb_data *address, unsigned mask, unsigned bits) |
188 | ICODE_ATTR; | 195 | ICODE_ATTR; |
189 | static void bgblock(unsigned char *address, unsigned mask, unsigned bits) | 196 | static void bgblock(fb_data *address, unsigned mask, unsigned bits) |
190 | { | 197 | { |
191 | unsigned data = *address; | 198 | unsigned data = *address; |
192 | 199 | ||
193 | *address = data ^ ((data ^ bg_pattern) & mask & ~bits); | 200 | *address = data ^ ((data ^ bg_pattern) & mask & ~bits); |
194 | } | 201 | } |
195 | 202 | ||
196 | static void fgblock(unsigned char *address, unsigned mask, unsigned bits) | 203 | static void fgblock(fb_data *address, unsigned mask, unsigned bits) |
197 | ICODE_ATTR; | 204 | ICODE_ATTR; |
198 | static void fgblock(unsigned char *address, unsigned mask, unsigned bits) | 205 | static void fgblock(fb_data *address, unsigned mask, unsigned bits) |
199 | { | 206 | { |
200 | unsigned data = *address; | 207 | unsigned data = *address; |
201 | 208 | ||
202 | *address = data ^ ((data ^ fg_pattern) & mask & bits); | 209 | *address = data ^ ((data ^ fg_pattern) & mask & bits); |
203 | } | 210 | } |
204 | 211 | ||
205 | static void solidblock(unsigned char *address, unsigned mask, unsigned bits) | 212 | static void solidblock(fb_data *address, unsigned mask, unsigned bits) |
206 | ICODE_ATTR; | 213 | ICODE_ATTR; |
207 | static void solidblock(unsigned char *address, unsigned mask, unsigned bits) | 214 | static void solidblock(fb_data *address, unsigned mask, unsigned bits) |
208 | { | 215 | { |
209 | unsigned data = *address; | 216 | unsigned data = *address; |
210 | unsigned bgp = bg_pattern; | 217 | unsigned bgp = bg_pattern; |
@@ -213,34 +220,34 @@ static void solidblock(unsigned char *address, unsigned mask, unsigned bits) | |||
213 | *address = data ^ ((data ^ bits) & mask); | 220 | *address = data ^ ((data ^ bits) & mask); |
214 | } | 221 | } |
215 | 222 | ||
216 | static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits) | 223 | static void flipinvblock(fb_data *address, unsigned mask, unsigned bits) |
217 | ICODE_ATTR; | 224 | ICODE_ATTR; |
218 | static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits) | 225 | static void flipinvblock(fb_data *address, unsigned mask, unsigned bits) |
219 | { | 226 | { |
220 | *address ^= ~bits & mask; | 227 | *address ^= ~bits & mask; |
221 | } | 228 | } |
222 | 229 | ||
223 | static void bginvblock(unsigned char *address, unsigned mask, unsigned bits) | 230 | static void bginvblock(fb_data *address, unsigned mask, unsigned bits) |
224 | ICODE_ATTR; | 231 | ICODE_ATTR; |
225 | static void bginvblock(unsigned char *address, unsigned mask, unsigned bits) | 232 | static void bginvblock(fb_data *address, unsigned mask, unsigned bits) |
226 | { | 233 | { |
227 | unsigned data = *address; | 234 | unsigned data = *address; |
228 | 235 | ||
229 | *address = data ^ ((data ^ bg_pattern) & mask & bits); | 236 | *address = data ^ ((data ^ bg_pattern) & mask & bits); |
230 | } | 237 | } |
231 | 238 | ||
232 | static void fginvblock(unsigned char *address, unsigned mask, unsigned bits) | 239 | static void fginvblock(fb_data *address, unsigned mask, unsigned bits) |
233 | ICODE_ATTR; | 240 | ICODE_ATTR; |
234 | static void fginvblock(unsigned char *address, unsigned mask, unsigned bits) | 241 | static void fginvblock(fb_data *address, unsigned mask, unsigned bits) |
235 | { | 242 | { |
236 | unsigned data = *address; | 243 | unsigned data = *address; |
237 | 244 | ||
238 | *address = data ^ ((data ^ fg_pattern) & mask & ~bits); | 245 | *address = data ^ ((data ^ fg_pattern) & mask & ~bits); |
239 | } | 246 | } |
240 | 247 | ||
241 | static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits) | 248 | static void solidinvblock(fb_data *address, unsigned mask, unsigned bits) |
242 | ICODE_ATTR; | 249 | ICODE_ATTR; |
243 | static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits) | 250 | static void solidinvblock(fb_data *address, unsigned mask, unsigned bits) |
244 | { | 251 | { |
245 | unsigned data = *address; | 252 | unsigned data = *address; |
246 | unsigned fgp = fg_pattern; | 253 | unsigned fgp = fg_pattern; |
@@ -254,7 +261,7 @@ lcd_blockfunc_type* const lcd_blockfuncs[8] = { | |||
254 | flipinvblock, bginvblock, fginvblock, solidinvblock | 261 | flipinvblock, bginvblock, fginvblock, solidinvblock |
255 | }; | 262 | }; |
256 | 263 | ||
257 | static inline void setblock(unsigned char *address, unsigned mask, unsigned bits) | 264 | static inline void setblock(fb_data *address, unsigned mask, unsigned bits) |
258 | { | 265 | { |
259 | unsigned data = *address; | 266 | unsigned data = *address; |
260 | 267 | ||
@@ -510,11 +517,11 @@ void lcd_fillrect(int x, int y, int width, int height) | |||
510 | /* About Rockbox' internal monochrome bitmap format: | 517 | /* About Rockbox' internal monochrome bitmap format: |
511 | * | 518 | * |
512 | * A bitmap contains one bit for every pixel that defines if that pixel is | 519 | * A bitmap contains one bit for every pixel that defines if that pixel is |
513 | * black (1) or white (0). Bits within a byte are arranged horizontally, LSB | 520 | * black (1) or white (0). Bits within a byte are arranged vertically, LSB |
514 | * at top. | 521 | * at top. |
515 | * The bytes are stored in row-major order, with byte 0 being top left, | 522 | * The bytes are stored in row-major order, with byte 0 being top left, |
516 | * byte 1 2nd from left etc. The first row of bytes defines pixel row | 523 | * byte 1 2nd from left etc. The first row of bytes defines pixel rows |
517 | * 0, the second row defines pixel row 1 etc. */ | 524 | * 0..7, the second row defines pixel row 8..15 etc. */ |
518 | 525 | ||
519 | /* Draw a partial monochrome bitmap */ | 526 | /* Draw a partial monochrome bitmap */ |
520 | void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, | 527 | void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, |
@@ -937,15 +944,9 @@ static void scroll_thread(void) | |||
937 | } | 944 | } |
938 | 945 | ||
939 | lastmode = drawmode; | 946 | lastmode = drawmode; |
940 | drawmode = (DRMODE_SOLID|DRMODE_INVERSEVID); | 947 | drawmode = s->invert ? |
941 | lcd_fillrect(xpos, ypos, LCD_WIDTH - xpos, pf->height); | 948 | (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; |
942 | drawmode = DRMODE_SOLID; | 949 | lcd_putsxyofs(xpos, ypos, s->offset, s->line); |
943 | lcd_putsxyofs(xpos, ypos, s->offset, (unsigned char *)s->line); | ||
944 | if (s->invert) | ||
945 | { | ||
946 | drawmode = DRMODE_COMPLEMENT; | ||
947 | lcd_fillrect(xpos, ypos, LCD_WIDTH - xpos, pf->height); | ||
948 | } | ||
949 | drawmode = lastmode; | 950 | drawmode = lastmode; |
950 | lcd_update_rect(xpos, ypos, LCD_WIDTH - xpos, pf->height); | 951 | lcd_update_rect(xpos, ypos, LCD_WIDTH - xpos, pf->height); |
951 | } | 952 | } |
diff --git a/firmware/drivers/lcd-h100-remote.c b/firmware/drivers/lcd-h100-remote.c index f7b3c21f48..0c71f0b168 100644 --- a/firmware/drivers/lcd-h100-remote.c +++ b/firmware/drivers/lcd-h100-remote.c | |||
@@ -65,8 +65,8 @@ | |||
65 | 65 | ||
66 | /*** globals ***/ | 66 | /*** globals ***/ |
67 | 67 | ||
68 | unsigned char lcd_remote_framebuffer[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH] | 68 | fb_remote_data lcd_remote_framebuffer[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH] |
69 | IBSS_ATTR; | 69 | IBSS_ATTR; |
70 | 70 | ||
71 | static int drawmode = DRMODE_SOLID; | 71 | static int drawmode = DRMODE_SOLID; |
72 | static int xmargin = 0; | 72 | static int xmargin = 0; |
@@ -686,35 +686,35 @@ static void nopixel(int x, int y) | |||
686 | (void)y; | 686 | (void)y; |
687 | } | 687 | } |
688 | 688 | ||
689 | lcd_pixelfunc_type* const lcd_remote_pixelfuncs[8] = { | 689 | lcd_remote_pixelfunc_type* const lcd_remote_pixelfuncs[8] = { |
690 | flippixel, nopixel, setpixel, setpixel, | 690 | flippixel, nopixel, setpixel, setpixel, |
691 | nopixel, clearpixel, nopixel, clearpixel | 691 | nopixel, clearpixel, nopixel, clearpixel |
692 | }; | 692 | }; |
693 | 693 | ||
694 | static void flipblock(unsigned char *address, unsigned mask, unsigned bits) | 694 | static void flipblock(fb_remote_data *address, unsigned mask, unsigned bits) |
695 | ICODE_ATTR; | 695 | ICODE_ATTR; |
696 | static void flipblock(unsigned char *address, unsigned mask, unsigned bits) | 696 | static void flipblock(fb_remote_data *address, unsigned mask, unsigned bits) |
697 | { | 697 | { |
698 | *address ^= bits & mask; | 698 | *address ^= bits & mask; |
699 | } | 699 | } |
700 | 700 | ||
701 | static void bgblock(unsigned char *address, unsigned mask, unsigned bits) | 701 | static void bgblock(fb_remote_data *address, unsigned mask, unsigned bits) |
702 | ICODE_ATTR; | 702 | ICODE_ATTR; |
703 | static void bgblock(unsigned char *address, unsigned mask, unsigned bits) | 703 | static void bgblock(fb_remote_data *address, unsigned mask, unsigned bits) |
704 | { | 704 | { |
705 | *address &= bits | ~mask; | 705 | *address &= bits | ~mask; |
706 | } | 706 | } |
707 | 707 | ||
708 | static void fgblock(unsigned char *address, unsigned mask, unsigned bits) | 708 | static void fgblock(fb_remote_data *address, unsigned mask, unsigned bits) |
709 | ICODE_ATTR; | 709 | ICODE_ATTR; |
710 | static void fgblock(unsigned char *address, unsigned mask, unsigned bits) | 710 | static void fgblock(fb_remote_data *address, unsigned mask, unsigned bits) |
711 | { | 711 | { |
712 | *address |= bits & mask; | 712 | *address |= bits & mask; |
713 | } | 713 | } |
714 | 714 | ||
715 | static void solidblock(unsigned char *address, unsigned mask, unsigned bits) | 715 | static void solidblock(fb_remote_data *address, unsigned mask, unsigned bits) |
716 | ICODE_ATTR; | 716 | ICODE_ATTR; |
717 | static void solidblock(unsigned char *address, unsigned mask, unsigned bits) | 717 | static void solidblock(fb_remote_data *address, unsigned mask, unsigned bits) |
718 | { | 718 | { |
719 | unsigned data = *address; | 719 | unsigned data = *address; |
720 | 720 | ||
@@ -722,30 +722,30 @@ static void solidblock(unsigned char *address, unsigned mask, unsigned bits) | |||
722 | *address = data ^ (bits & mask); | 722 | *address = data ^ (bits & mask); |
723 | } | 723 | } |
724 | 724 | ||
725 | static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits) | 725 | static void flipinvblock(fb_remote_data *address, unsigned mask, unsigned bits) |
726 | ICODE_ATTR; | 726 | ICODE_ATTR; |
727 | static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits) | 727 | static void flipinvblock(fb_remote_data *address, unsigned mask, unsigned bits) |
728 | { | 728 | { |
729 | *address ^= ~bits & mask; | 729 | *address ^= ~bits & mask; |
730 | } | 730 | } |
731 | 731 | ||
732 | static void bginvblock(unsigned char *address, unsigned mask, unsigned bits) | 732 | static void bginvblock(fb_remote_data *address, unsigned mask, unsigned bits) |
733 | ICODE_ATTR; | 733 | ICODE_ATTR; |
734 | static void bginvblock(unsigned char *address, unsigned mask, unsigned bits) | 734 | static void bginvblock(fb_remote_data *address, unsigned mask, unsigned bits) |
735 | { | 735 | { |
736 | *address &= ~(bits & mask); | 736 | *address &= ~(bits & mask); |
737 | } | 737 | } |
738 | 738 | ||
739 | static void fginvblock(unsigned char *address, unsigned mask, unsigned bits) | 739 | static void fginvblock(fb_remote_data *address, unsigned mask, unsigned bits) |
740 | ICODE_ATTR; | 740 | ICODE_ATTR; |
741 | static void fginvblock(unsigned char *address, unsigned mask, unsigned bits) | 741 | static void fginvblock(fb_remote_data *address, unsigned mask, unsigned bits) |
742 | { | 742 | { |
743 | *address |= ~bits & mask; | 743 | *address |= ~bits & mask; |
744 | } | 744 | } |
745 | 745 | ||
746 | static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits) | 746 | static void solidinvblock(fb_remote_data *address, unsigned mask, unsigned bits) |
747 | ICODE_ATTR; | 747 | ICODE_ATTR; |
748 | static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits) | 748 | static void solidinvblock(fb_remote_data *address, unsigned mask, unsigned bits) |
749 | { | 749 | { |
750 | unsigned data = *address; | 750 | unsigned data = *address; |
751 | 751 | ||
@@ -753,7 +753,7 @@ static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits) | |||
753 | *address = data ^ (bits & mask); | 753 | *address = data ^ (bits & mask); |
754 | } | 754 | } |
755 | 755 | ||
756 | lcd_blockfunc_type* const lcd_remote_blockfuncs[8] = { | 756 | lcd_remote_blockfunc_type* const lcd_remote_blockfuncs[8] = { |
757 | flipblock, bgblock, fgblock, solidblock, | 757 | flipblock, bgblock, fgblock, solidblock, |
758 | flipinvblock, bginvblock, fginvblock, solidinvblock | 758 | flipinvblock, bginvblock, fginvblock, solidinvblock |
759 | }; | 759 | }; |
@@ -785,7 +785,7 @@ void lcd_remote_drawline(int x1, int y1, int x2, int y2) | |||
785 | int d, dinc1, dinc2; | 785 | int d, dinc1, dinc2; |
786 | int x, xinc1, xinc2; | 786 | int x, xinc1, xinc2; |
787 | int y, yinc1, yinc2; | 787 | int y, yinc1, yinc2; |
788 | lcd_pixelfunc_type *pfunc = lcd_remote_pixelfuncs[drawmode]; | 788 | lcd_remote_pixelfunc_type *pfunc = lcd_remote_pixelfuncs[drawmode]; |
789 | 789 | ||
790 | deltax = abs(x2 - x1); | 790 | deltax = abs(x2 - x1); |
791 | deltay = abs(y2 - y1); | 791 | deltay = abs(y2 - y1); |
@@ -851,9 +851,9 @@ void lcd_remote_drawline(int x1, int y1, int x2, int y2) | |||
851 | void lcd_remote_hline(int x1, int x2, int y) | 851 | void lcd_remote_hline(int x1, int x2, int y) |
852 | { | 852 | { |
853 | int x; | 853 | int x; |
854 | unsigned char *dst, *dst_end; | 854 | fb_remote_data *dst, *dst_end; |
855 | unsigned mask; | 855 | unsigned mask; |
856 | lcd_blockfunc_type *bfunc; | 856 | lcd_remote_blockfunc_type *bfunc; |
857 | 857 | ||
858 | /* direction flip */ | 858 | /* direction flip */ |
859 | if (x2 < x1) | 859 | if (x2 < x1) |
@@ -888,9 +888,9 @@ void lcd_remote_hline(int x1, int x2, int y) | |||
888 | void lcd_remote_vline(int x, int y1, int y2) | 888 | void lcd_remote_vline(int x, int y1, int y2) |
889 | { | 889 | { |
890 | int ny; | 890 | int ny; |
891 | unsigned char *dst; | 891 | fb_remote_data *dst; |
892 | unsigned mask, mask_bottom; | 892 | unsigned mask, mask_bottom; |
893 | lcd_blockfunc_type *bfunc; | 893 | lcd_remote_blockfunc_type *bfunc; |
894 | 894 | ||
895 | /* direction flip */ | 895 | /* direction flip */ |
896 | if (y2 < y1) | 896 | if (y2 < y1) |
@@ -946,10 +946,10 @@ void lcd_remote_drawrect(int x, int y, int width, int height) | |||
946 | void lcd_remote_fillrect(int x, int y, int width, int height) | 946 | void lcd_remote_fillrect(int x, int y, int width, int height) |
947 | { | 947 | { |
948 | int ny; | 948 | int ny; |
949 | unsigned char *dst, *dst_end; | 949 | fb_remote_data *dst, *dst_end; |
950 | unsigned mask, mask_bottom; | 950 | unsigned mask, mask_bottom; |
951 | unsigned bits = 0; | 951 | unsigned bits = 0; |
952 | lcd_blockfunc_type *bfunc; | 952 | lcd_remote_blockfunc_type *bfunc; |
953 | bool fillopt = false; | 953 | bool fillopt = false; |
954 | 954 | ||
955 | /* nothing to draw? */ | 955 | /* nothing to draw? */ |
@@ -1000,7 +1000,7 @@ void lcd_remote_fillrect(int x, int y, int width, int height) | |||
1000 | memset(dst, bits, width); | 1000 | memset(dst, bits, width); |
1001 | else | 1001 | else |
1002 | { | 1002 | { |
1003 | unsigned char *dst_row = dst; | 1003 | fb_remote_data *dst_row = dst; |
1004 | 1004 | ||
1005 | dst_end = dst_row + width; | 1005 | dst_end = dst_row + width; |
1006 | do | 1006 | do |
@@ -1043,9 +1043,9 @@ void lcd_remote_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
1043 | int stride, int x, int y, int width, int height) | 1043 | int stride, int x, int y, int width, int height) |
1044 | { | 1044 | { |
1045 | int shift, ny; | 1045 | int shift, ny; |
1046 | unsigned char *dst, *dst_end; | 1046 | fb_remote_data *dst, *dst_end; |
1047 | unsigned mask, mask_bottom; | 1047 | unsigned mask, mask_bottom; |
1048 | lcd_blockfunc_type *bfunc; | 1048 | lcd_remote_blockfunc_type *bfunc; |
1049 | 1049 | ||
1050 | /* nothing to draw? */ | 1050 | /* nothing to draw? */ |
1051 | if ((width <= 0) || (height <= 0) || (x >= LCD_REMOTE_WIDTH) | 1051 | if ((width <= 0) || (height <= 0) || (x >= LCD_REMOTE_WIDTH) |
@@ -1070,9 +1070,9 @@ void lcd_remote_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
1070 | if (y + height > LCD_REMOTE_HEIGHT) | 1070 | if (y + height > LCD_REMOTE_HEIGHT) |
1071 | height = LCD_REMOTE_HEIGHT - y; | 1071 | height = LCD_REMOTE_HEIGHT - y; |
1072 | 1072 | ||
1073 | src += stride * (src_y >> 3) + src_x; /* move starting point */ | 1073 | src += stride * (src_y >> 3) + src_x; /* move starting point */ |
1074 | src_y &= 7; | 1074 | src_y &= 7; |
1075 | y -= src_y; | 1075 | y -= src_y; |
1076 | dst = &lcd_remote_framebuffer[y>>3][x]; | 1076 | dst = &lcd_remote_framebuffer[y>>3][x]; |
1077 | shift = y & 7; | 1077 | shift = y & 7; |
1078 | ny = height - 1 + shift + src_y; | 1078 | ny = height - 1 + shift + src_y; |
@@ -1092,7 +1092,7 @@ void lcd_remote_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
1092 | else | 1092 | else |
1093 | { | 1093 | { |
1094 | const unsigned char *src_row = src; | 1094 | const unsigned char *src_row = src; |
1095 | unsigned char *dst_row = dst; | 1095 | fb_remote_data *dst_row = dst; |
1096 | 1096 | ||
1097 | dst_end = dst_row + width; | 1097 | dst_end = dst_row + width; |
1098 | do | 1098 | do |
@@ -1122,7 +1122,7 @@ void lcd_remote_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
1122 | do | 1122 | do |
1123 | { | 1123 | { |
1124 | const unsigned char *src_col = src++; | 1124 | const unsigned char *src_col = src++; |
1125 | unsigned char *dst_col = dst++; | 1125 | fb_remote_data *dst_col = dst++; |
1126 | unsigned mask_col = mask; | 1126 | unsigned mask_col = mask; |
1127 | unsigned data = 0; | 1127 | unsigned data = 0; |
1128 | 1128 | ||
diff --git a/firmware/drivers/lcd-h100.c b/firmware/drivers/lcd-h100.c index 369833944f..39497cc2ec 100644 --- a/firmware/drivers/lcd-h100.c +++ b/firmware/drivers/lcd-h100.c | |||
@@ -63,7 +63,7 @@ | |||
63 | 63 | ||
64 | /*** globals ***/ | 64 | /*** globals ***/ |
65 | 65 | ||
66 | unsigned char lcd_framebuffer[LCD_HEIGHT/4][LCD_WIDTH] IBSS_ATTR; | 66 | fb_data lcd_framebuffer[LCD_HEIGHT/4][LCD_WIDTH] IBSS_ATTR; |
67 | 67 | ||
68 | static const unsigned char dibits[16] ICONST_ATTR = { | 68 | static const unsigned char dibits[16] ICONST_ATTR = { |
69 | 0x00, 0x03, 0x0C, 0x0F, 0x30, 0x33, 0x3C, 0x3F, | 69 | 0x00, 0x03, 0x0C, 0x0F, 0x30, 0x33, 0x3C, 0x3F, |
@@ -357,21 +357,28 @@ int lcd_getstringsize(const unsigned char *str, int *w, int *h) | |||
357 | 357 | ||
358 | static void setpixel(int x, int y) | 358 | static void setpixel(int x, int y) |
359 | { | 359 | { |
360 | unsigned char *data = &lcd_framebuffer[y>>2][x]; | ||
361 | unsigned mask = pixmask[y & 3]; | 360 | unsigned mask = pixmask[y & 3]; |
362 | *data = (*data & ~mask) | (fg_pattern & mask); | 361 | fb_data *address = &lcd_framebuffer[y>>2][x]; |
362 | unsigned data = *address; | ||
363 | |||
364 | *address = data ^ ((data ^ fg_pattern) & mask); | ||
363 | } | 365 | } |
364 | 366 | ||
365 | static void clearpixel(int x, int y) | 367 | static void clearpixel(int x, int y) |
366 | { | 368 | { |
367 | unsigned char *data = &lcd_framebuffer[y>>2][x]; | ||
368 | unsigned mask = pixmask[y & 3]; | 369 | unsigned mask = pixmask[y & 3]; |
369 | *data = (*data & ~mask) | (bg_pattern & mask); | 370 | fb_data *address = &lcd_framebuffer[y>>2][x]; |
371 | unsigned data = *address; | ||
372 | |||
373 | *address = data ^ ((data ^ bg_pattern) & mask); | ||
370 | } | 374 | } |
371 | 375 | ||
372 | static void flippixel(int x, int y) | 376 | static void flippixel(int x, int y) |
373 | { | 377 | { |
374 | lcd_framebuffer[y>>2][x] ^= pixmask[y & 3]; | 378 | unsigned mask = pixmask[y & 3]; |
379 | fb_data *address = &lcd_framebuffer[y>>2][x]; | ||
380 | |||
381 | *address ^= mask; | ||
375 | } | 382 | } |
376 | 383 | ||
377 | static void nopixel(int x, int y) | 384 | static void nopixel(int x, int y) |
@@ -386,34 +393,34 @@ lcd_pixelfunc_type* const lcd_pixelfuncs[8] = { | |||
386 | }; | 393 | }; |
387 | 394 | ||
388 | /* 'mask' and 'bits' contain 2 bits per pixel */ | 395 | /* 'mask' and 'bits' contain 2 bits per pixel */ |
389 | static void flipblock(unsigned char *address, unsigned mask, unsigned bits) | 396 | static void flipblock(fb_data *address, unsigned mask, unsigned bits) |
390 | ICODE_ATTR; | 397 | ICODE_ATTR; |
391 | static void flipblock(unsigned char *address, unsigned mask, unsigned bits) | 398 | static void flipblock(fb_data *address, unsigned mask, unsigned bits) |
392 | { | 399 | { |
393 | *address ^= bits & mask; | 400 | *address ^= bits & mask; |
394 | } | 401 | } |
395 | 402 | ||
396 | static void bgblock(unsigned char *address, unsigned mask, unsigned bits) | 403 | static void bgblock(fb_data *address, unsigned mask, unsigned bits) |
397 | ICODE_ATTR; | 404 | ICODE_ATTR; |
398 | static void bgblock(unsigned char *address, unsigned mask, unsigned bits) | 405 | static void bgblock(fb_data *address, unsigned mask, unsigned bits) |
399 | { | 406 | { |
400 | unsigned data = *address; | 407 | unsigned data = *address; |
401 | 408 | ||
402 | *address = data ^ ((data ^ bg_pattern) & mask & ~bits); | 409 | *address = data ^ ((data ^ bg_pattern) & mask & ~bits); |
403 | } | 410 | } |
404 | 411 | ||
405 | static void fgblock(unsigned char *address, unsigned mask, unsigned bits) | 412 | static void fgblock(fb_data *address, unsigned mask, unsigned bits) |
406 | ICODE_ATTR; | 413 | ICODE_ATTR; |
407 | static void fgblock(unsigned char *address, unsigned mask, unsigned bits) | 414 | static void fgblock(fb_data *address, unsigned mask, unsigned bits) |
408 | { | 415 | { |
409 | unsigned data = *address; | 416 | unsigned data = *address; |
410 | 417 | ||
411 | *address = data ^ ((data ^ fg_pattern) & mask & bits); | 418 | *address = data ^ ((data ^ fg_pattern) & mask & bits); |
412 | } | 419 | } |
413 | 420 | ||
414 | static void solidblock(unsigned char *address, unsigned mask, unsigned bits) | 421 | static void solidblock(fb_data *address, unsigned mask, unsigned bits) |
415 | ICODE_ATTR; | 422 | ICODE_ATTR; |
416 | static void solidblock(unsigned char *address, unsigned mask, unsigned bits) | 423 | static void solidblock(fb_data *address, unsigned mask, unsigned bits) |
417 | { | 424 | { |
418 | unsigned data = *address; | 425 | unsigned data = *address; |
419 | unsigned bgp = bg_pattern; | 426 | unsigned bgp = bg_pattern; |
@@ -422,34 +429,34 @@ static void solidblock(unsigned char *address, unsigned mask, unsigned bits) | |||
422 | *address = data ^ ((data ^ bits) & mask); | 429 | *address = data ^ ((data ^ bits) & mask); |
423 | } | 430 | } |
424 | 431 | ||
425 | static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits) | 432 | static void flipinvblock(fb_data *address, unsigned mask, unsigned bits) |
426 | ICODE_ATTR; | 433 | ICODE_ATTR; |
427 | static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits) | 434 | static void flipinvblock(fb_data *address, unsigned mask, unsigned bits) |
428 | { | 435 | { |
429 | *address ^= ~bits & mask; | 436 | *address ^= ~bits & mask; |
430 | } | 437 | } |
431 | 438 | ||
432 | static void bginvblock(unsigned char *address, unsigned mask, unsigned bits) | 439 | static void bginvblock(fb_data *address, unsigned mask, unsigned bits) |
433 | ICODE_ATTR; | 440 | ICODE_ATTR; |
434 | static void bginvblock(unsigned char *address, unsigned mask, unsigned bits) | 441 | static void bginvblock(fb_data *address, unsigned mask, unsigned bits) |
435 | { | 442 | { |
436 | unsigned data = *address; | 443 | unsigned data = *address; |
437 | 444 | ||
438 | *address = data ^ ((data ^ bg_pattern) & mask & bits); | 445 | *address = data ^ ((data ^ bg_pattern) & mask & bits); |
439 | } | 446 | } |
440 | 447 | ||
441 | static void fginvblock(unsigned char *address, unsigned mask, unsigned bits) | 448 | static void fginvblock(fb_data *address, unsigned mask, unsigned bits) |
442 | ICODE_ATTR; | 449 | ICODE_ATTR; |
443 | static void fginvblock(unsigned char *address, unsigned mask, unsigned bits) | 450 | static void fginvblock(fb_data *address, unsigned mask, unsigned bits) |
444 | { | 451 | { |
445 | unsigned data = *address; | 452 | unsigned data = *address; |
446 | 453 | ||
447 | *address = data ^ ((data ^ fg_pattern) & mask & ~bits); | 454 | *address = data ^ ((data ^ fg_pattern) & mask & ~bits); |
448 | } | 455 | } |
449 | 456 | ||
450 | static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits) | 457 | static void solidinvblock(fb_data *address, unsigned mask, unsigned bits) |
451 | ICODE_ATTR; | 458 | ICODE_ATTR; |
452 | static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits) | 459 | static void solidinvblock(fb_data *address, unsigned mask, unsigned bits) |
453 | { | 460 | { |
454 | unsigned data = *address; | 461 | unsigned data = *address; |
455 | unsigned fgp = fg_pattern; | 462 | unsigned fgp = fg_pattern; |
@@ -463,7 +470,7 @@ lcd_blockfunc_type* const lcd_blockfuncs[8] = { | |||
463 | flipinvblock, bginvblock, fginvblock, solidinvblock | 470 | flipinvblock, bginvblock, fginvblock, solidinvblock |
464 | }; | 471 | }; |
465 | 472 | ||
466 | static inline void setblock(unsigned char *address, unsigned mask, unsigned bits) | 473 | static inline void setblock(fb_data *address, unsigned mask, unsigned bits) |
467 | { | 474 | { |
468 | unsigned data = *address; | 475 | unsigned data = *address; |
469 | 476 | ||
@@ -564,7 +571,7 @@ void lcd_drawline(int x1, int y1, int x2, int y2) | |||
564 | void lcd_hline(int x1, int x2, int y) | 571 | void lcd_hline(int x1, int x2, int y) |
565 | { | 572 | { |
566 | int x; | 573 | int x; |
567 | unsigned char *dst, *dst_end; | 574 | fb_data *dst, *dst_end; |
568 | unsigned mask; | 575 | unsigned mask; |
569 | lcd_blockfunc_type *bfunc; | 576 | lcd_blockfunc_type *bfunc; |
570 | 577 | ||
@@ -600,7 +607,7 @@ void lcd_hline(int x1, int x2, int y) | |||
600 | void lcd_vline(int x, int y1, int y2) | 607 | void lcd_vline(int x, int y1, int y2) |
601 | { | 608 | { |
602 | int ny; | 609 | int ny; |
603 | unsigned char *dst; | 610 | fb_data *dst; |
604 | unsigned mask, mask_bottom; | 611 | unsigned mask, mask_bottom; |
605 | lcd_blockfunc_type *bfunc; | 612 | lcd_blockfunc_type *bfunc; |
606 | 613 | ||
@@ -657,7 +664,7 @@ void lcd_drawrect(int x, int y, int width, int height) | |||
657 | void lcd_fillrect(int x, int y, int width, int height) | 664 | void lcd_fillrect(int x, int y, int width, int height) |
658 | { | 665 | { |
659 | int ny; | 666 | int ny; |
660 | unsigned char *dst, *dst_end; | 667 | fb_data *dst, *dst_end; |
661 | unsigned mask, mask_bottom; | 668 | unsigned mask, mask_bottom; |
662 | unsigned bits = 0; | 669 | unsigned bits = 0; |
663 | lcd_blockfunc_type *bfunc; | 670 | lcd_blockfunc_type *bfunc; |
@@ -712,7 +719,7 @@ void lcd_fillrect(int x, int y, int width, int height) | |||
712 | memset(dst, bits, width); | 719 | memset(dst, bits, width); |
713 | else | 720 | else |
714 | { | 721 | { |
715 | unsigned char *dst_row = dst; | 722 | fb_data *dst_row = dst; |
716 | 723 | ||
717 | dst_end = dst_row + width; | 724 | dst_end = dst_row + width; |
718 | do | 725 | do |
@@ -755,7 +762,7 @@ void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
755 | int stride, int x, int y, int width, int height) | 762 | int stride, int x, int y, int width, int height) |
756 | { | 763 | { |
757 | int shift, ny; | 764 | int shift, ny; |
758 | unsigned char *dst, *dst_end; | 765 | fb_data *dst, *dst_end; |
759 | unsigned mask, mask_bottom; | 766 | unsigned mask, mask_bottom; |
760 | lcd_blockfunc_type *bfunc; | 767 | lcd_blockfunc_type *bfunc; |
761 | 768 | ||
@@ -800,7 +807,7 @@ void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
800 | for (; ny >= 8; ny -= 8) | 807 | for (; ny >= 8; ny -= 8) |
801 | { | 808 | { |
802 | const unsigned char *src_row = src; | 809 | const unsigned char *src_row = src; |
803 | unsigned char *dst_row = dst + LCD_WIDTH; | 810 | fb_data *dst_row = dst + LCD_WIDTH; |
804 | 811 | ||
805 | dmask1 = dibits[mask&0x0F]; | 812 | dmask1 = dibits[mask&0x0F]; |
806 | dmask2 = dibits[(mask>>4)&0x0F]; | 813 | dmask2 = dibits[(mask>>4)&0x0F]; |
@@ -863,7 +870,7 @@ void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
863 | do | 870 | do |
864 | { | 871 | { |
865 | const unsigned char *src_col = src++; | 872 | const unsigned char *src_col = src++; |
866 | unsigned char *dst_col = dst++; | 873 | fb_data *dst_col = dst++; |
867 | unsigned mask_col = mask; | 874 | unsigned mask_col = mask; |
868 | unsigned data = 0; | 875 | unsigned data = 0; |
869 | 876 | ||
@@ -916,14 +923,14 @@ void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width, int heig | |||
916 | * This is the same as the internal lcd hw format. */ | 923 | * This is the same as the internal lcd hw format. */ |
917 | 924 | ||
918 | /* Draw a partial native bitmap */ | 925 | /* Draw a partial native bitmap */ |
919 | void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y, | 926 | void lcd_bitmap_part(const fb_data *src, int src_x, int src_y, |
920 | int stride, int x, int y, int width, int height) | 927 | int stride, int x, int y, int width, int height) |
921 | ICODE_ATTR; | 928 | ICODE_ATTR; |
922 | void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y, | 929 | void lcd_bitmap_part(const fb_data *src, int src_x, int src_y, |
923 | int stride, int x, int y, int width, int height) | 930 | int stride, int x, int y, int width, int height) |
924 | { | 931 | { |
925 | int shift, ny; | 932 | int shift, ny; |
926 | unsigned char *dst, *dst_end; | 933 | fb_data *dst, *dst_end; |
927 | unsigned mask, mask_bottom; | 934 | unsigned mask, mask_bottom; |
928 | 935 | ||
929 | /* nothing to draw? */ | 936 | /* nothing to draw? */ |
@@ -949,9 +956,9 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
949 | if (y + height > LCD_HEIGHT) | 956 | if (y + height > LCD_HEIGHT) |
950 | height = LCD_HEIGHT - y; | 957 | height = LCD_HEIGHT - y; |
951 | 958 | ||
952 | src += stride * (src_y >> 2) + src_x; /* move starting point */ | 959 | src += stride * (src_y >> 2) + src_x; /* move starting point */ |
953 | src_y &= 3; | 960 | src_y &= 3; |
954 | y -= src_y; | 961 | y -= src_y; |
955 | dst = &lcd_framebuffer[y>>2][x]; | 962 | dst = &lcd_framebuffer[y>>2][x]; |
956 | shift = y & 3; | 963 | shift = y & 3; |
957 | ny = height - 1 + shift + src_y; | 964 | ny = height - 1 + shift + src_y; |
@@ -967,15 +974,14 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
967 | memcpy(dst, src, width); | 974 | memcpy(dst, src, width); |
968 | else | 975 | else |
969 | { | 976 | { |
970 | const unsigned char *src_row = src; | 977 | const fb_data *src_row = src; |
971 | unsigned char *dst_row = dst; | 978 | fb_data *dst_row = dst; |
972 | 979 | ||
973 | dst_end = dst_row + width; | 980 | dst_end = dst_row + width; |
974 | do | 981 | do |
975 | setblock(dst_row++, mask, *src_row++); | 982 | setblock(dst_row++, mask, *src_row++); |
976 | while (dst_row < dst_end); | 983 | while (dst_row < dst_end); |
977 | } | 984 | } |
978 | |||
979 | src += stride; | 985 | src += stride; |
980 | dst += LCD_WIDTH; | 986 | dst += LCD_WIDTH; |
981 | mask = 0xFFu; | 987 | mask = 0xFFu; |
@@ -998,8 +1004,8 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
998 | dst_end = dst + width; | 1004 | dst_end = dst + width; |
999 | do | 1005 | do |
1000 | { | 1006 | { |
1001 | const unsigned char *src_col = src++; | 1007 | const fb_data *src_col = src++; |
1002 | unsigned char *dst_col = dst++; | 1008 | fb_data *dst_col = dst++; |
1003 | unsigned mask_col = mask; | 1009 | unsigned mask_col = mask; |
1004 | unsigned data = 0; | 1010 | unsigned data = 0; |
1005 | 1011 | ||
@@ -1027,7 +1033,7 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
1027 | } | 1033 | } |
1028 | 1034 | ||
1029 | /* Draw a full native bitmap */ | 1035 | /* Draw a full native bitmap */ |
1030 | void lcd_bitmap(const unsigned char *src, int x, int y, int width, int height) | 1036 | void lcd_bitmap(const fb_data *src, int x, int y, int width, int height) |
1031 | { | 1037 | { |
1032 | lcd_bitmap_part(src, 0, 0, width, x, y, width, height); | 1038 | lcd_bitmap_part(src, 0, 0, width, x, y, width, height); |
1033 | } | 1039 | } |
@@ -1290,4 +1296,3 @@ static void scroll_thread(void) | |||
1290 | sleep(scroll_ticks); | 1296 | sleep(scroll_ticks); |
1291 | } | 1297 | } |
1292 | } | 1298 | } |
1293 | |||