summaryrefslogtreecommitdiff
path: root/firmware/drivers/lcd-2bit-horz.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/lcd-2bit-horz.c')
-rw-r--r--firmware/drivers/lcd-2bit-horz.c71
1 files changed, 36 insertions, 35 deletions
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
149static void setpixel(int x, int y) 149static 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
156static void clearpixel(int x, int y) 158static 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
163static void flippixel(int x, int y) 167static 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
168static void nopixel(int x, int y) 175static 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 */
180static void flipblock(unsigned char *address, unsigned mask, unsigned bits) 187static void flipblock(fb_data *address, unsigned mask, unsigned bits)
181 ICODE_ATTR; 188 ICODE_ATTR;
182static void flipblock(unsigned char *address, unsigned mask, unsigned bits) 189static void flipblock(fb_data *address, unsigned mask, unsigned bits)
183{ 190{
184 *address ^= bits & mask; 191 *address ^= bits & mask;
185} 192}
186 193
187static void bgblock(unsigned char *address, unsigned mask, unsigned bits) 194static void bgblock(fb_data *address, unsigned mask, unsigned bits)
188 ICODE_ATTR; 195 ICODE_ATTR;
189static void bgblock(unsigned char *address, unsigned mask, unsigned bits) 196static 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
196static void fgblock(unsigned char *address, unsigned mask, unsigned bits) 203static void fgblock(fb_data *address, unsigned mask, unsigned bits)
197 ICODE_ATTR; 204 ICODE_ATTR;
198static void fgblock(unsigned char *address, unsigned mask, unsigned bits) 205static 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
205static void solidblock(unsigned char *address, unsigned mask, unsigned bits) 212static void solidblock(fb_data *address, unsigned mask, unsigned bits)
206 ICODE_ATTR; 213 ICODE_ATTR;
207static void solidblock(unsigned char *address, unsigned mask, unsigned bits) 214static 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
216static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits) 223static void flipinvblock(fb_data *address, unsigned mask, unsigned bits)
217 ICODE_ATTR; 224 ICODE_ATTR;
218static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits) 225static void flipinvblock(fb_data *address, unsigned mask, unsigned bits)
219{ 226{
220 *address ^= ~bits & mask; 227 *address ^= ~bits & mask;
221} 228}
222 229
223static void bginvblock(unsigned char *address, unsigned mask, unsigned bits) 230static void bginvblock(fb_data *address, unsigned mask, unsigned bits)
224 ICODE_ATTR; 231 ICODE_ATTR;
225static void bginvblock(unsigned char *address, unsigned mask, unsigned bits) 232static 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
232static void fginvblock(unsigned char *address, unsigned mask, unsigned bits) 239static void fginvblock(fb_data *address, unsigned mask, unsigned bits)
233 ICODE_ATTR; 240 ICODE_ATTR;
234static void fginvblock(unsigned char *address, unsigned mask, unsigned bits) 241static 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
241static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits) 248static void solidinvblock(fb_data *address, unsigned mask, unsigned bits)
242 ICODE_ATTR; 249 ICODE_ATTR;
243static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits) 250static 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
257static inline void setblock(unsigned char *address, unsigned mask, unsigned bits) 264static 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 */
520void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, 527void 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 }