diff options
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/lcd-16bit.c | 164 |
1 files changed, 85 insertions, 79 deletions
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c index a035ea2d3a..16037f149d 100644 --- a/firmware/drivers/lcd-16bit.c +++ b/firmware/drivers/lcd-16bit.c | |||
@@ -552,85 +552,91 @@ void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
552 | void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, | 552 | void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, |
553 | int stride, int x, int y, int width, int height) | 553 | int stride, int x, int y, int width, int height) |
554 | { | 554 | { |
555 | const unsigned char *src_end; | 555 | const unsigned char *src_end; |
556 | fb_data *dst, *dst_end; | 556 | bool has_backdrop; |
557 | 557 | fb_data *dst, *dst_end, *backdrop; | |
558 | /* nothing to draw? */ | 558 | lcd_fastpixelfunc_type *fgfunc, *bgfunc; |
559 | if ((width <= 0) || (height <= 0) || (x >= LCD_WIDTH) || (y >= LCD_HEIGHT) | 559 | |
560 | || (x + width <= 0) || (y + height <= 0)) | 560 | /* nothing to draw? */ |
561 | return; | 561 | if ((width <= 0) || (height <= 0) || (x >= LCD_WIDTH) || (y >= LCD_HEIGHT) |
562 | 562 | || (x + width <= 0) || (y + height <= 0)) | |
563 | /* clipping */ | 563 | return; |
564 | if (x < 0) | 564 | |
565 | { | 565 | /* clipping */ |
566 | width += x; | 566 | if (x < 0) |
567 | src_x -= x; | 567 | { |
568 | x = 0; | 568 | width += x; |
569 | } | 569 | src_x -= x; |
570 | if (y < 0) | 570 | x = 0; |
571 | { | 571 | } |
572 | height += y; | 572 | if (y < 0) |
573 | src_y -= y; | 573 | { |
574 | y = 0; | 574 | height += y; |
575 | } | 575 | src_y -= y; |
576 | if (x + width > LCD_WIDTH) | 576 | y = 0; |
577 | width = LCD_WIDTH - x; | 577 | } |
578 | if (y + height > LCD_HEIGHT) | 578 | if (x + width > LCD_WIDTH) |
579 | height = LCD_HEIGHT - y; | 579 | width = LCD_WIDTH - x; |
580 | 580 | if (y + height > LCD_HEIGHT) | |
581 | src += stride * (src_y >> 3) + src_x; /* move starting point */ | 581 | height = LCD_HEIGHT - y; |
582 | src_y &= 7; | 582 | |
583 | src_end = src + width; | 583 | src += stride * (src_y >> 3) + src_x; /* move starting point */ |
584 | 584 | src_y &= 7; | |
585 | dst = LCDADDR(x, y); | 585 | src_end = src + width; |
586 | int drawmode = lcd_get_drawmode(); | 586 | |
587 | fb_data *backdrop = lcd_get_backdrop(); | 587 | dst = LCDADDR(x, y); |
588 | bool has_backdrop = backdrop ? true : false; | 588 | has_backdrop = (lcd_backdrop != NULL); |
589 | backdrop = backdrop + y * LCD_WIDTH + x; | 589 | backdrop = lcd_backdrop + y * LCD_WIDTH + x; |
590 | lcd_fastpixelfunc_type *fgfunc = lcd_fastpixelfuncs[drawmode];; | 590 | fgfunc = lcd_fastpixelfuncs[drawmode]; |
591 | lcd_fastpixelfunc_type *bgfunc = lcd_fastpixelfuncs[drawmode ^ DRMODE_INVERSEVID];; | 591 | bgfunc = lcd_fastpixelfuncs[drawmode ^ DRMODE_INVERSEVID]; |
592 | do { | 592 | do |
593 | const unsigned char *src_col = src++; | 593 | { |
594 | unsigned data = *src_col >> src_y; | 594 | const unsigned char *src_col = src++; |
595 | fb_data *dst_col = dst++; | 595 | unsigned data = *src_col >> src_y; |
596 | int numbits = 8 - src_y; | 596 | fb_data *dst_col = dst++; |
597 | fb_data *backdrop_col = backdrop++; | 597 | int numbits = 8 - src_y; |
598 | dst_end = dst_col + height * LCD_WIDTH; | 598 | fb_data *backdrop_col = backdrop++; |
599 | do { | 599 | dst_end = dst_col + height * LCD_WIDTH; |
600 | switch(drawmode) { | 600 | do |
601 | case DRMODE_SOLID: | 601 | { |
602 | if (data & 0x01) | 602 | switch (drawmode) |
603 | *dst_col = fg_pattern; | 603 | { |
604 | else | 604 | case DRMODE_SOLID: |
605 | *dst_col = has_backdrop ? *backdrop_col : bg_pattern; | 605 | if (data & 0x01) |
606 | break; | 606 | *dst_col = fg_pattern; |
607 | case DRMODE_FG: | 607 | else |
608 | if (data & 0x01) | 608 | *dst_col = has_backdrop ? *backdrop_col : bg_pattern; |
609 | *dst_col = fg_pattern; | 609 | break; |
610 | break; | 610 | case DRMODE_FG: |
611 | case (DRMODE_SOLID|DRMODE_INVERSEVID): | 611 | if (data & 0x01) |
612 | if(data & 0x01) | 612 | *dst_col = fg_pattern; |
613 | *dst_col = has_backdrop ? *backdrop_col : bg_pattern; | 613 | break; |
614 | else | 614 | case (DRMODE_SOLID|DRMODE_INVERSEVID): |
615 | *dst_col = fg_pattern; | 615 | if (data & 0x01) |
616 | break; | 616 | *dst_col = has_backdrop ? *backdrop_col : bg_pattern; |
617 | default: | 617 | else |
618 | if (data & 0x01) | 618 | *dst_col = fg_pattern; |
619 | fgfunc(dst_col); | 619 | break; |
620 | else | 620 | default: |
621 | bgfunc(dst_col); | 621 | if (data & 0x01) |
622 | break; | 622 | fgfunc(dst_col); |
623 | }; | 623 | else |
624 | dst_col += LCD_WIDTH; | 624 | bgfunc(dst_col); |
625 | backdrop_col += LCD_WIDTH; | 625 | break; |
626 | data >>= 1; | 626 | } |
627 | if (--numbits == 0) { | 627 | dst_col += LCD_WIDTH; |
628 | src_col += stride; | 628 | backdrop_col += LCD_WIDTH; |
629 | data = *src_col; | 629 | data >>= 1; |
630 | numbits = 8; | 630 | if (--numbits == 0) |
631 | } | 631 | { |
632 | } while (dst_col < dst_end); | 632 | src_col += stride; |
633 | } while (src < src_end); | 633 | data = *src_col; |
634 | numbits = 8; | ||
635 | } | ||
636 | } | ||
637 | while (dst_col < dst_end); | ||
638 | } | ||
639 | while (src < src_end); | ||
634 | } | 640 | } |
635 | /* Draw a full monochrome bitmap */ | 641 | /* Draw a full monochrome bitmap */ |
636 | void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width, int height) | 642 | void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width, int height) |