summaryrefslogtreecommitdiff
path: root/firmware/drivers/lcd-16bit-common.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/lcd-16bit-common.c')
-rw-r--r--firmware/drivers/lcd-16bit-common.c112
1 files changed, 57 insertions, 55 deletions
diff --git a/firmware/drivers/lcd-16bit-common.c b/firmware/drivers/lcd-16bit-common.c
index a7e80c7244..7c766dab8a 100644
--- a/firmware/drivers/lcd-16bit-common.c
+++ b/firmware/drivers/lcd-16bit-common.c
@@ -35,10 +35,10 @@ void lcd_clear_viewport(void)
35 int x, y, width, height; 35 int x, y, width, height;
36 int len, step; 36 int len, step;
37 37
38 x = current_vp->x; 38 x = lcd_current_viewport->x;
39 y = current_vp->y; 39 y = lcd_current_viewport->y;
40 width = current_vp->width; 40 width = lcd_current_viewport->width;
41 height = current_vp->height; 41 height = lcd_current_viewport->height;
42 42
43#if defined(HAVE_VIEWPORT_CLIP) 43#if defined(HAVE_VIEWPORT_CLIP)
44 /********************* Viewport on screen clipping ********************/ 44 /********************* Viewport on screen clipping ********************/
@@ -70,11 +70,11 @@ void lcd_clear_viewport(void)
70 dst = FBADDR(x, y); 70 dst = FBADDR(x, y);
71 dst_end = FBADDR(x + width - 1 , y + height - 1); 71 dst_end = FBADDR(x + width - 1 , y + height - 1);
72 72
73 if (current_vp->drawmode & DRMODE_INVERSEVID) 73 if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID)
74 { 74 {
75 do 75 do
76 { 76 {
77 memset16(dst, current_vp->fg_pattern, len); 77 memset16(dst, lcd_current_viewport->fg_pattern, len);
78 dst += step; 78 dst += step;
79 } 79 }
80 while (dst <= dst_end); 80 while (dst <= dst_end);
@@ -85,7 +85,7 @@ void lcd_clear_viewport(void)
85 { 85 {
86 do 86 do
87 { 87 {
88 memset16(dst, current_vp->bg_pattern, len); 88 memset16(dst, lcd_current_viewport->bg_pattern, len);
89 dst += step; 89 dst += step;
90 } 90 }
91 while (dst <= dst_end); 91 while (dst <= dst_end);
@@ -102,22 +102,24 @@ void lcd_clear_viewport(void)
102 } 102 }
103 } 103 }
104 104
105 if (current_vp == &default_vp) 105 if (lcd_current_viewport == &default_vp)
106 lcd_scroll_stop(); 106 lcd_scroll_stop();
107 else 107 else
108 lcd_scroll_stop_viewport(current_vp); 108 lcd_scroll_stop_viewport(lcd_current_viewport);
109
110 lcd_current_viewport->flags &= ~(VP_FLAG_VP_SET_CLEAN);
109} 111}
110 112
111/*** low-level drawing functions ***/ 113/*** low-level drawing functions ***/
112 114
113static void ICODE_ATTR setpixel(fb_data *address) 115static void ICODE_ATTR setpixel(fb_data *address)
114{ 116{
115 *address = current_vp->fg_pattern; 117 *address = lcd_current_viewport->fg_pattern;
116} 118}
117 119
118static void ICODE_ATTR clearpixel(fb_data *address) 120static void ICODE_ATTR clearpixel(fb_data *address)
119{ 121{
120 *address = current_vp->bg_pattern; 122 *address = lcd_current_viewport->bg_pattern;
121} 123}
122 124
123static void ICODE_ATTR clearimgpixel(fb_data *address) 125static void ICODE_ATTR clearimgpixel(fb_data *address)
@@ -157,8 +159,8 @@ void lcd_fillrect(int x, int y, int width, int height)
157 159
158 /******************** In viewport clipping **********************/ 160 /******************** In viewport clipping **********************/
159 /* nothing to draw? */ 161 /* nothing to draw? */
160 if ((width <= 0) || (height <= 0) || (x >= current_vp->width) || 162 if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) ||
161 (y >= current_vp->height) || (x + width <= 0) || (y + height <= 0)) 163 (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0))
162 return; 164 return;
163 165
164 if (x < 0) 166 if (x < 0)
@@ -171,14 +173,14 @@ void lcd_fillrect(int x, int y, int width, int height)
171 height += y; 173 height += y;
172 y = 0; 174 y = 0;
173 } 175 }
174 if (x + width > current_vp->width) 176 if (x + width > lcd_current_viewport->width)
175 width = current_vp->width - x; 177 width = lcd_current_viewport->width - x;
176 if (y + height > current_vp->height) 178 if (y + height > lcd_current_viewport->height)
177 height = current_vp->height - y; 179 height = lcd_current_viewport->height - y;
178 180
179 /* adjust for viewport */ 181 /* adjust for viewport */
180 x += current_vp->x; 182 x += lcd_current_viewport->x;
181 y += current_vp->y; 183 y += lcd_current_viewport->y;
182 184
183#if defined(HAVE_VIEWPORT_CLIP) 185#if defined(HAVE_VIEWPORT_CLIP)
184 /********************* Viewport on screen clipping ********************/ 186 /********************* Viewport on screen clipping ********************/
@@ -205,14 +207,14 @@ void lcd_fillrect(int x, int y, int width, int height)
205#endif 207#endif
206 208
207 /* drawmode and optimisation */ 209 /* drawmode and optimisation */
208 if (current_vp->drawmode & DRMODE_INVERSEVID) 210 if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID)
209 { 211 {
210 if (current_vp->drawmode & DRMODE_BG) 212 if (lcd_current_viewport->drawmode & DRMODE_BG)
211 { 213 {
212 if (!lcd_backdrop) 214 if (!lcd_backdrop)
213 { 215 {
214 fillopt = OPT_SET; 216 fillopt = OPT_SET;
215 bits = current_vp->bg_pattern; 217 bits = lcd_current_viewport->bg_pattern;
216 } 218 }
217 else 219 else
218 fillopt = OPT_COPY; 220 fillopt = OPT_COPY;
@@ -220,13 +222,13 @@ void lcd_fillrect(int x, int y, int width, int height)
220 } 222 }
221 else 223 else
222 { 224 {
223 if (current_vp->drawmode & DRMODE_FG) 225 if (lcd_current_viewport->drawmode & DRMODE_FG)
224 { 226 {
225 fillopt = OPT_SET; 227 fillopt = OPT_SET;
226 bits = current_vp->fg_pattern; 228 bits = lcd_current_viewport->fg_pattern;
227 } 229 }
228 } 230 }
229 if (fillopt == OPT_NONE && current_vp->drawmode != DRMODE_COMPLEMENT) 231 if (fillopt == OPT_NONE && lcd_current_viewport->drawmode != DRMODE_COMPLEMENT)
230 return; 232 return;
231 233
232 dst = FBADDR(x, y); 234 dst = FBADDR(x, y);
@@ -284,13 +286,13 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
284 const unsigned char *src_end; 286 const unsigned char *src_end;
285 fb_data *dst, *dst_col; 287 fb_data *dst, *dst_col;
286 unsigned dmask = 0x100; /* bit 8 == sentinel */ 288 unsigned dmask = 0x100; /* bit 8 == sentinel */
287 int drmode = current_vp->drawmode; 289 int drmode = lcd_current_viewport->drawmode;
288 int row; 290 int row;
289 291
290 /******************** Image in viewport clipping **********************/ 292 /******************** Image in viewport clipping **********************/
291 /* nothing to draw? */ 293 /* nothing to draw? */
292 if ((width <= 0) || (height <= 0) || (x >= current_vp->width) || 294 if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) ||
293 (y >= current_vp->height) || (x + width <= 0) || (y + height <= 0)) 295 (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0))
294 return; 296 return;
295 297
296 if (x < 0) 298 if (x < 0)
@@ -305,14 +307,14 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
305 src_y -= y; 307 src_y -= y;
306 y = 0; 308 y = 0;
307 } 309 }
308 if (x + width > current_vp->width) 310 if (x + width > lcd_current_viewport->width)
309 width = current_vp->width - x; 311 width = lcd_current_viewport->width - x;
310 if (y + height > current_vp->height) 312 if (y + height > lcd_current_viewport->height)
311 height = current_vp->height - y; 313 height = lcd_current_viewport->height - y;
312 314
313 /* adjust for viewport */ 315 /* adjust for viewport */
314 x += current_vp->x; 316 x += lcd_current_viewport->x;
315 y += current_vp->y; 317 y += lcd_current_viewport->y;
316 318
317#if defined(HAVE_VIEWPORT_CLIP) 319#if defined(HAVE_VIEWPORT_CLIP)
318 /********************* Viewport on screen clipping ********************/ 320 /********************* Viewport on screen clipping ********************/
@@ -404,7 +406,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
404 break; 406 break;
405 407
406 case DRMODE_BG: 408 case DRMODE_BG:
407 bg = current_vp->bg_pattern; 409 bg = lcd_current_viewport->bg_pattern;
408 do 410 do
409 { 411 {
410 if (!(data & 0x01)) 412 if (!(data & 0x01))
@@ -417,7 +419,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
417 break; 419 break;
418 420
419 case DRMODE_FG: 421 case DRMODE_FG:
420 fg = current_vp->fg_pattern; 422 fg = lcd_current_viewport->fg_pattern;
421 do 423 do
422 { 424 {
423 if (data & 0x01) 425 if (data & 0x01)
@@ -430,7 +432,7 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
430 break; 432 break;
431 433
432 case DRMODE_SOLID|DRMODE_INT_BD: 434 case DRMODE_SOLID|DRMODE_INT_BD:
433 fg = current_vp->fg_pattern; 435 fg = lcd_current_viewport->fg_pattern;
434 bo = lcd_backdrop_offset; 436 bo = lcd_backdrop_offset;
435 do 437 do
436 { 438 {
@@ -443,8 +445,8 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
443 break; 445 break;
444 446
445 case DRMODE_SOLID: 447 case DRMODE_SOLID:
446 fg = current_vp->fg_pattern; 448 fg = lcd_current_viewport->fg_pattern;
447 bg = current_vp->bg_pattern; 449 bg = lcd_current_viewport->bg_pattern;
448 do 450 do
449 { 451 {
450 *dst = (data & 0x01) ? fg : bg; 452 *dst = (data & 0x01) ? fg : bg;
@@ -549,10 +551,10 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
549{ 551{
550 fb_data *dst, *dst_row; 552 fb_data *dst, *dst_row;
551 unsigned dmask = 0x00000000; 553 unsigned dmask = 0x00000000;
552 int drmode = current_vp->drawmode; 554 int drmode = lcd_current_viewport->drawmode;
553 /* nothing to draw? */ 555 /* nothing to draw? */
554 if ((width <= 0) || (height <= 0) || (x >= current_vp->width) || 556 if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) ||
555 (y >= current_vp->height) || (x + width <= 0) || (y + height <= 0)) 557 (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0))
556 return; 558 return;
557 /* initialize blending */ 559 /* initialize blending */
558 BLEND_INIT; 560 BLEND_INIT;
@@ -570,14 +572,14 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
570 src_y -= y; 572 src_y -= y;
571 y = 0; 573 y = 0;
572 } 574 }
573 if (x + width > current_vp->width) 575 if (x + width > lcd_current_viewport->width)
574 width = current_vp->width - x; 576 width = lcd_current_viewport->width - x;
575 if (y + height > current_vp->height) 577 if (y + height > lcd_current_viewport->height)
576 height = current_vp->height - y; 578 height = lcd_current_viewport->height - y;
577 579
578 /* adjust for viewport */ 580 /* adjust for viewport */
579 x += current_vp->x; 581 x += lcd_current_viewport->x;
580 y += current_vp->y; 582 y += lcd_current_viewport->y;
581 583
582#if defined(HAVE_VIEWPORT_CLIP) 584#if defined(HAVE_VIEWPORT_CLIP)
583 /********************* Viewport on screen clipping ********************/ 585 /********************* Viewport on screen clipping ********************/
@@ -668,7 +670,7 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
668 /* go through the rows and update each pixel */ 670 /* go through the rows and update each pixel */
669 do 671 do
670 { 672 {
671 /* saving current_vp->fg/bg_pattern and lcd_backdrop_offset into these 673 /* saving lcd_current_viewport->fg/bg_pattern and lcd_backdrop_offset into these
672 * temp vars just before the loop helps gcc to opimize the loop better 674 * temp vars just before the loop helps gcc to opimize the loop better
673 * (testing showed ~15% speedup) */ 675 * (testing showed ~15% speedup) */
674 unsigned fg, bg; 676 unsigned fg, bg;
@@ -727,7 +729,7 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
727 while (--col); 729 while (--col);
728 break; 730 break;
729 case DRMODE_BG: 731 case DRMODE_BG:
730 bg = current_vp->bg_pattern; 732 bg = lcd_current_viewport->bg_pattern;
731 do 733 do
732 { 734 {
733 *dst = blend_two_colors(bg, *dst, data & ALPHA_COLOR_LOOKUP_SIZE ); 735 *dst = blend_two_colors(bg, *dst, data & ALPHA_COLOR_LOOKUP_SIZE );
@@ -747,7 +749,7 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
747 while (--col); 749 while (--col);
748 break; 750 break;
749 case DRMODE_FG: 751 case DRMODE_FG:
750 fg = current_vp->fg_pattern; 752 fg = lcd_current_viewport->fg_pattern;
751 do 753 do
752 { 754 {
753 *dst = blend_two_colors(*dst, fg, data & ALPHA_COLOR_LOOKUP_SIZE ); 755 *dst = blend_two_colors(*dst, fg, data & ALPHA_COLOR_LOOKUP_SIZE );
@@ -758,7 +760,7 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
758 break; 760 break;
759 case DRMODE_SOLID|DRMODE_INT_BD: 761 case DRMODE_SOLID|DRMODE_INT_BD:
760 bo = lcd_backdrop_offset; 762 bo = lcd_backdrop_offset;
761 fg = current_vp->fg_pattern; 763 fg = lcd_current_viewport->fg_pattern;
762 do 764 do
763 { 765 {
764 fb_data *c = (fb_data *)((uintptr_t)dst + bo); 766 fb_data *c = (fb_data *)((uintptr_t)dst + bo);
@@ -769,7 +771,7 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
769 while (--col); 771 while (--col);
770 break; 772 break;
771 case DRMODE_SOLID|DRMODE_INT_IMG: 773 case DRMODE_SOLID|DRMODE_INT_IMG:
772 bg = current_vp->bg_pattern; 774 bg = lcd_current_viewport->bg_pattern;
773 img_offset = image - dst; 775 img_offset = image - dst;
774 do 776 do
775 { 777 {
@@ -792,8 +794,8 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
792 while (--col); 794 while (--col);
793 break; 795 break;
794 case DRMODE_SOLID: 796 case DRMODE_SOLID:
795 bg = current_vp->bg_pattern; 797 bg = lcd_current_viewport->bg_pattern;
796 fg = current_vp->fg_pattern; 798 fg = lcd_current_viewport->fg_pattern;
797 do 799 do
798 { 800 {
799 *dst = blend_two_colors(bg, fg, data & ALPHA_COLOR_LOOKUP_SIZE ); 801 *dst = blend_two_colors(bg, fg, data & ALPHA_COLOR_LOOKUP_SIZE );