summaryrefslogtreecommitdiff
path: root/apps/plugins/lib/gray_draw.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/lib/gray_draw.c')
-rw-r--r--apps/plugins/lib/gray_draw.c37
1 files changed, 14 insertions, 23 deletions
diff --git a/apps/plugins/lib/gray_draw.c b/apps/plugins/lib/gray_draw.c
index 6779b6eeb5..7e1197bd4b 100644
--- a/apps/plugins/lib/gray_draw.c
+++ b/apps/plugins/lib/gray_draw.c
@@ -32,12 +32,12 @@
32 32
33static void setpixel(unsigned char *address) 33static void setpixel(unsigned char *address)
34{ 34{
35 *address = _gray_info.fg_brightness; 35 *address = _gray_info.fg_index;
36} 36}
37 37
38static void clearpixel(unsigned char *address) 38static void clearpixel(unsigned char *address)
39{ 39{
40 *address = _gray_info.bg_brightness; 40 *address = _gray_info.bg_index;
41} 41}
42 42
43static void flippixel(unsigned char *address) 43static void flippixel(unsigned char *address)
@@ -61,7 +61,7 @@ void (* const _gray_pixelfuncs[8])(unsigned char *address) = {
61void gray_clear_display(void) 61void gray_clear_display(void)
62{ 62{
63 int brightness = (_gray_info.drawmode & DRMODE_INVERSEVID) ? 63 int brightness = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
64 _gray_info.fg_brightness : _gray_info.bg_brightness; 64 _gray_info.fg_index : _gray_info.bg_index;
65 65
66 _gray_rb->memset(_gray_info.cur_buffer, brightness, 66 _gray_rb->memset(_gray_info.cur_buffer, brightness,
67 MULU16(_gray_info.width, _gray_info.height)); 67 MULU16(_gray_info.width, _gray_info.height));
@@ -219,7 +219,7 @@ void gray_vline(int x, int y1, int y2)
219 if (_gray_info.drawmode & DRMODE_BG) 219 if (_gray_info.drawmode & DRMODE_BG)
220 { 220 {
221 fillopt = true; 221 fillopt = true;
222 bits = _gray_info.bg_brightness; 222 bits = _gray_info.bg_index;
223 } 223 }
224 } 224 }
225 else 225 else
@@ -227,7 +227,7 @@ void gray_vline(int x, int y1, int y2)
227 if (_gray_info.drawmode & DRMODE_FG) 227 if (_gray_info.drawmode & DRMODE_FG)
228 { 228 {
229 fillopt = true; 229 fillopt = true;
230 bits = _gray_info.fg_brightness; 230 bits = _gray_info.fg_index;
231 } 231 }
232 } 232 }
233 pfunc = _gray_pixelfuncs[_gray_info.drawmode]; 233 pfunc = _gray_pixelfuncs[_gray_info.drawmode];
@@ -293,7 +293,7 @@ void gray_fillrect(int x, int y, int width, int height)
293 if (_gray_info.drawmode & DRMODE_BG) 293 if (_gray_info.drawmode & DRMODE_BG)
294 { 294 {
295 fillopt = true; 295 fillopt = true;
296 bits = _gray_info.bg_brightness; 296 bits = _gray_info.bg_index;
297 } 297 }
298 } 298 }
299 else 299 else
@@ -301,7 +301,7 @@ void gray_fillrect(int x, int y, int width, int height)
301 if (_gray_info.drawmode & DRMODE_FG) 301 if (_gray_info.drawmode & DRMODE_FG)
302 { 302 {
303 fillopt = true; 303 fillopt = true;
304 bits = _gray_info.fg_brightness; 304 bits = _gray_info.fg_index;
305 } 305 }
306 } 306 }
307 pfunc = _gray_pixelfuncs[_gray_info.drawmode]; 307 pfunc = _gray_pixelfuncs[_gray_info.drawmode];
@@ -525,8 +525,7 @@ void gray_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
525 dst_end = dst_col + height; 525 dst_end = dst_col + height;
526 do 526 do
527 { 527 {
528 unsigned data = MULU16(_gray_info.depth, *src_col) + 127; 528 *dst_col++ = _gray_info.idxtable[*src_col];
529 *dst_col++ = (data + (data >> 8)) >> 8; /* approx. data / 255 */
530 src_col += stride; 529 src_col += stride;
531 } 530 }
532 while (dst_col < dst_end); 531 while (dst_col < dst_end);
@@ -642,13 +641,8 @@ static void _writearray(unsigned char *address, const unsigned char *src,
642 641
643 "mov.b @%[src],r0 \n" /* load src byte */ 642 "mov.b @%[src],r0 \n" /* load src byte */
644 "extu.b r0,r0 \n" /* extend unsigned */ 643 "extu.b r0,r0 \n" /* extend unsigned */
645 "mulu %[dpth],r0 \n" /* macl = byte * depth; */ 644 "mov.b @(r0,%[trns]),r0\n" /* idxtable into pattern index */
646 "sts macl,r1 \n" /* r1 = macl; */ 645 "extu.b r0,r0 \n" /* extend unsigned */
647 "add #127,r1 \n" /* byte += 127; */
648 "mov r1,r0 \n"
649 "shlr8 r1 \n"
650 "add r1,r0 \n" /* byte += byte >> 8; */
651 "shlr8 r0 \n" /* byte >>= 8; */
652 "shll2 r0 \n" 646 "shll2 r0 \n"
653 "mov.l @(r0,%[bpat]),r4\n" /* r4 = bitpattern[byte]; */ 647 "mov.l @(r0,%[bpat]),r4\n" /* r4 = bitpattern[byte]; */
654 648
@@ -693,7 +687,8 @@ static void _writearray(unsigned char *address, const unsigned char *src,
693 [stri]"r"(stride), 687 [stri]"r"(stride),
694 [dpth]"r"(_gray_info.depth), 688 [dpth]"r"(_gray_info.depth),
695 [bpat]"r"(_gray_info.bitpattern), 689 [bpat]"r"(_gray_info.bitpattern),
696 [rmsk]"r"(_gray_info.randmask) 690 [rmsk]"r"(_gray_info.randmask),
691 [trns]"r"(_gray_info.idxtable)
697 : /* clobbers */ 692 : /* clobbers */
698 "r0", "r1", "r3", "r4", "r5", "macl", "pr" 693 "r0", "r1", "r3", "r4", "r5", "macl", "pr"
699 ); 694 );
@@ -811,12 +806,7 @@ static void _writearray(unsigned char *address, const unsigned char *src,
811 806
812 "clr.l %%d0 \n" 807 "clr.l %%d0 \n"
813 "move.b (%[src]),%%d0 \n" /* load src byte */ 808 "move.b (%[src]),%%d0 \n" /* load src byte */
814 "mulu.w %[dpth],%%d0\n" /* byte = byte * depth; */ 809 "move.b (%%d0:l:1,%[trns]),%%d0\n" /* idxtable into pattern index */
815 "add.l #127,%%d0 \n" /* byte += 127; */
816 "move.l %%d0,%%d1 \n"
817 "lsr.l #8,%%d1 \n"
818 "add.l %%d1,%%d0 \n" /* byte += byte >> 8; */
819 "lsr.l #8,%%d0 \n" /* byte >>= 8; */
820 "move.l (%%d0:l:4,%[bpat]),%%d2\n" /* d2 = bitpattern[byte]; */ 810 "move.l (%%d0:l:4,%[bpat]),%%d2\n" /* d2 = bitpattern[byte]; */
821 811
822 "mulu.w #75,%[rnd] \n" /* multiply by 75 */ 812 "mulu.w #75,%[rnd] \n" /* multiply by 75 */
@@ -852,6 +842,7 @@ static void _writearray(unsigned char *address, const unsigned char *src,
852 : /* inputs */ 842 : /* inputs */
853 [stri]"r"(stride), 843 [stri]"r"(stride),
854 [bpat]"a"(_gray_info.bitpattern), 844 [bpat]"a"(_gray_info.bitpattern),
845 [trns]"a"(_gray_info.idxtable),
855 [dpth]"d"(_gray_info.depth), 846 [dpth]"d"(_gray_info.depth),
856 [rmsk]"d"(_gray_info.randmask) 847 [rmsk]"d"(_gray_info.randmask)
857 : /* clobbers */ 848 : /* clobbers */