summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/plugins/lib/gray.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/apps/plugins/lib/gray.c b/apps/plugins/lib/gray.c
index 1b197c0eeb..e68e5eef7b 100644
--- a/apps/plugins/lib/gray.c
+++ b/apps/plugins/lib/gray.c
@@ -665,6 +665,10 @@ asm (
665 * _writeblock) */ 665 * _writeblock) */
666static void _invertblock(unsigned char *address, unsigned mask, unsigned bits) 666static void _invertblock(unsigned char *address, unsigned mask, unsigned bits)
667{ 667{
668 bits &= mask;
669 if (!bits)
670 return;
671
668 asm volatile ( 672 asm volatile (
669 "mov #0,r1 \n" /* current_plane = 0 */ 673 "mov #0,r1 \n" /* current_plane = 0 */
670 674
@@ -680,7 +684,7 @@ static void _invertblock(unsigned char *address, unsigned mask, unsigned bits)
680 : /* inputs */ 684 : /* inputs */
681 /* %0 */ "r"(graybuf->depth), 685 /* %0 */ "r"(graybuf->depth),
682 /* %1 */ "r"(address), 686 /* %1 */ "r"(address),
683 /* %2 */ "r"(mask & bits), 687 /* %2 */ "r"(bits),
684 /* %3 */ "r"(graybuf->plane_size) 688 /* %3 */ "r"(graybuf->plane_size)
685 : /* clobbers */ 689 : /* clobbers */
686 "r1", "r2", "macl" 690 "r1", "r2", "macl"
@@ -690,13 +694,17 @@ static void _invertblock(unsigned char *address, unsigned mask, unsigned bits)
690/* Call _writeblock with the mask modified to draw foreground pixels only */ 694/* Call _writeblock with the mask modified to draw foreground pixels only */
691static void _writeblockfg(unsigned char *address, unsigned mask, unsigned bits) 695static void _writeblockfg(unsigned char *address, unsigned mask, unsigned bits)
692{ 696{
693 _writeblock(address, mask & bits, bits); 697 mask &= bits;
698 if (mask)
699 _writeblock(address, mask, bits);
694} 700}
695 701
696/* Call _writeblock with the mask modified to draw background pixels only */ 702/* Call _writeblock with the mask modified to draw background pixels only */
697static void _writeblockbg(unsigned char *address, unsigned mask, unsigned bits) 703static void _writeblockbg(unsigned char *address, unsigned mask, unsigned bits)
698{ 704{
699 _writeblock(address, mask & ~bits, bits); 705 mask &= ~bits;
706 if (mask)
707 _writeblock(address, mask, bits);
700} 708}
701 709
702/**** public functions ****/ 710/**** public functions ****/