summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/drivers/lcd-16bit.c93
-rw-r--r--firmware/export/lcd.h2
2 files changed, 44 insertions, 51 deletions
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c
index aaf7bde1aa..414cb877b6 100644
--- a/firmware/drivers/lcd-16bit.c
+++ b/firmware/drivers/lcd-16bit.c
@@ -38,8 +38,8 @@
38/*** globals ***/ 38/*** globals ***/
39fb_data lcd_framebuffer[LCD_HEIGHT][LCD_WIDTH] __attribute__ ((aligned (16))); 39fb_data lcd_framebuffer[LCD_HEIGHT][LCD_WIDTH] __attribute__ ((aligned (16)));
40 40
41fb_data* lcd_backdrop IDATA_ATTR = NULL; 41static fb_data* lcd_backdrop = NULL;
42int lcd_backdrop_offset = NULL; 42static int lcd_backdrop_offset IDATA_ATTR = 0;
43 43
44static unsigned fg_pattern IDATA_ATTR = LCD_DEFAULT_FG; 44static unsigned fg_pattern IDATA_ATTR = LCD_DEFAULT_FG;
45static unsigned bg_pattern IDATA_ATTR = LCD_DEFAULT_BG; 45static unsigned bg_pattern IDATA_ATTR = LCD_DEFAULT_BG;
@@ -108,18 +108,6 @@ void lcd_set_background(unsigned color)
108 bg_pattern = color; 108 bg_pattern = color;
109} 109}
110 110
111void lcd_set_backdrop(fb_data* backdrop)
112{
113 lcd_backdrop = backdrop;
114 if (backdrop)
115 lcd_backdrop_offset = (int)backdrop - (int)&lcd_framebuffer[0][0];
116}
117
118fb_data* lcd_get_backdrop(void)
119{
120 return lcd_backdrop;
121}
122
123unsigned lcd_get_background(void) 111unsigned lcd_get_background(void)
124{ 112{
125 return bg_pattern; 113 return bg_pattern;
@@ -192,46 +180,65 @@ static void nopixel(fb_data *address)
192 (void)address; 180 (void)address;
193} 181}
194 182
195lcd_fastpixelfunc_type* const lcd_fastpixelfuncs[8] = { 183lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_bgcolor[8] = {
196 flippixel, nopixel, setpixel, setpixel, 184 flippixel, nopixel, setpixel, setpixel,
197 nopixel, clearpixel, nopixel, clearpixel 185 nopixel, clearpixel, nopixel, clearpixel
198}; 186};
199 187
200lcd_fastpixelfunc_type* const lcd_fastimgpixelfuncs[8] = { 188lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_backdrop[8] = {
201 flippixel, nopixel, setpixel, setpixel, 189 flippixel, nopixel, setpixel, setpixel,
202 nopixel, clearimgpixel, nopixel, clearimgpixel 190 nopixel, clearimgpixel, nopixel, clearimgpixel
203}; 191};
204 192
193lcd_fastpixelfunc_type* const * lcd_fastpixelfuncs = lcd_fastpixelfuncs_bgcolor;
194
195void lcd_set_backdrop(fb_data* backdrop)
196{
197 lcd_backdrop = backdrop;
198 if (backdrop)
199 {
200 lcd_backdrop_offset = (int)backdrop - (int)&lcd_framebuffer[0][0];
201 lcd_fastpixelfuncs = lcd_fastpixelfuncs_backdrop;
202 }
203 else
204 {
205 lcd_backdrop_offset = 0;
206 lcd_fastpixelfuncs = lcd_fastpixelfuncs_bgcolor;
207 }
208}
209
210fb_data* lcd_get_backdrop(void)
211{
212 return lcd_backdrop;
213}
214
205/*** drawing functions ***/ 215/*** drawing functions ***/
206 216
207/* Clear the whole display */ 217/* Clear the whole display */
208void lcd_clear_display(void) 218void lcd_clear_display(void)
209{ 219{
210 fb_data *dst = LCDADDR(0, 0); 220 fb_data *dst = LCDADDR(0, 0);
211 fb_data *dst_end = dst + LCD_HEIGHT*LCD_WIDTH;
212 221
213 if (lcd_backdrop) { 222 if (!lcd_backdrop || (drawmode & DRMODE_INVERSEVID))
214 do 223 {
215 clearimgpixel(dst++); 224 fb_data bits = (drawmode & DRMODE_INVERSEVID) ? fg_pattern : bg_pattern;
216 while (dst < dst_end); 225 fb_data *dst_end = dst + LCD_HEIGHT*LCD_WIDTH;
217 } else {
218 do 226 do
219 clearpixel(dst++); 227 *dst++ = bits;
220 while (dst < dst_end); 228 while (dst < dst_end);
221 } 229 }
230 else
231 {
232 memcpy(dst, lcd_backdrop, sizeof(lcd_framebuffer));
233 }
222 scrolling_lines = 0; 234 scrolling_lines = 0;
223} 235}
224 236
225/* Set a single pixel */ 237/* Set a single pixel */
226void lcd_drawpixel(int x, int y) 238void lcd_drawpixel(int x, int y)
227{ 239{
228 if (((unsigned)x < LCD_WIDTH) && ((unsigned)y < LCD_HEIGHT)) { 240 if (((unsigned)x < LCD_WIDTH) && ((unsigned)y < LCD_HEIGHT))
229 if (lcd_backdrop) { 241 lcd_fastpixelfuncs[drawmode](LCDADDR(x, y));
230 lcd_fastimgpixelfuncs[drawmode](LCDADDR(x, y));
231 } else {
232 lcd_fastpixelfuncs[drawmode](LCDADDR(x, y));
233 }
234 }
235} 242}
236 243
237/* Draw a line */ 244/* Draw a line */
@@ -243,10 +250,7 @@ void lcd_drawline(int x1, int y1, int x2, int y2)
243 int d, dinc1, dinc2; 250 int d, dinc1, dinc2;
244 int x, xinc1, xinc2; 251 int x, xinc1, xinc2;
245 int y, yinc1, yinc2; 252 int y, yinc1, yinc2;
246 lcd_fastpixelfunc_type *pfunc = (lcd_backdrop ? 253 lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[drawmode];
247 lcd_fastimgpixelfuncs[drawmode] :
248 lcd_fastpixelfuncs[drawmode]);
249
250 254
251 deltax = abs(x2 - x1); 255 deltax = abs(x2 - x1);
252 deltay = abs(y2 - y1); 256 deltay = abs(y2 - y1);
@@ -313,9 +317,7 @@ void lcd_hline(int x1, int x2, int y)
313{ 317{
314 int x; 318 int x;
315 fb_data *dst, *dst_end; 319 fb_data *dst, *dst_end;
316 lcd_fastpixelfunc_type *pfunc = (lcd_backdrop ? 320 lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[drawmode];
317 lcd_fastimgpixelfuncs[drawmode] :
318 lcd_fastpixelfuncs[drawmode]);
319 321
320 /* direction flip */ 322 /* direction flip */
321 if (x2 < x1) 323 if (x2 < x1)
@@ -348,9 +350,7 @@ void lcd_vline(int x, int y1, int y2)
348{ 350{
349 int y; 351 int y;
350 fb_data *dst, *dst_end; 352 fb_data *dst, *dst_end;
351 lcd_fastpixelfunc_type *pfunc = (lcd_backdrop ? 353 lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[drawmode];
352 lcd_fastimgpixelfuncs[drawmode] :
353 lcd_fastpixelfuncs[drawmode]);
354 354
355 /* direction flip */ 355 /* direction flip */
356 if (y2 < y1) 356 if (y2 < y1)
@@ -400,9 +400,7 @@ void lcd_drawrect(int x, int y, int width, int height)
400void lcd_fillrect(int x, int y, int width, int height) 400void lcd_fillrect(int x, int y, int width, int height)
401{ 401{
402 fb_data *dst, *dst_end; 402 fb_data *dst, *dst_end;
403 lcd_fastpixelfunc_type *pfunc = (lcd_backdrop ? 403 lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[drawmode];
404 lcd_fastimgpixelfuncs[drawmode] :
405 lcd_fastpixelfuncs[drawmode]);
406 404
407 /* nothing to draw? */ 405 /* nothing to draw? */
408 if ((width <= 0) || (height <= 0) || (x >= LCD_WIDTH) || (y >= LCD_HEIGHT) 406 if ((width <= 0) || (height <= 0) || (x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
@@ -494,13 +492,8 @@ void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
494 src_end = src + width; 492 src_end = src + width;
495 493
496 dst = LCDADDR(x, y); 494 dst = LCDADDR(x, y);
497 if (lcd_backdrop) { 495 fgfunc = lcd_fastpixelfuncs[drawmode];
498 fgfunc = lcd_fastimgpixelfuncs[drawmode]; 496 bgfunc = lcd_fastpixelfuncs[drawmode ^ DRMODE_INVERSEVID];
499 bgfunc = lcd_fastimgpixelfuncs[drawmode ^ DRMODE_INVERSEVID];
500 } else {
501 fgfunc = lcd_fastpixelfuncs[drawmode];
502 bgfunc = lcd_fastpixelfuncs[drawmode ^ DRMODE_INVERSEVID];
503 }
504 497
505 do 498 do
506 { 499 {
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h
index 55a51b3176..6375031594 100644
--- a/firmware/export/lcd.h
+++ b/firmware/export/lcd.h
@@ -239,7 +239,7 @@ extern void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *stri
239extern lcd_pixelfunc_type* const lcd_pixelfuncs[8]; 239extern lcd_pixelfunc_type* const lcd_pixelfuncs[8];
240extern lcd_blockfunc_type* const lcd_blockfuncs[8]; 240extern lcd_blockfunc_type* const lcd_blockfuncs[8];
241#if LCD_DEPTH >= 8 241#if LCD_DEPTH >= 8
242extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs[8]; 242extern lcd_fastpixelfunc_type* const * lcd_fastpixelfuncs;
243#endif 243#endif
244 244
245extern void lcd_drawpixel(int x, int y); 245extern void lcd_drawpixel(int x, int y);