summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-09-30 20:10:27 +0000
committerJens Arnold <amiconn@rockbox.org>2005-09-30 20:10:27 +0000
commit1a40e109333b8206140594fce746f7972a4d0d86 (patch)
treea4f0589682ae4f8c894222b7691efebd989d763f
parent8b9c64f19db3abf8872b8dd85ea8ee1343f322e3 (diff)
downloadrockbox-1a40e109333b8206140594fce746f7972a4d0d86.tar.gz
rockbox-1a40e109333b8206140594fce746f7972a4d0d86.zip
H1x0: Changed lcd_blit() and the grayscale library to use the same internal format as on archos (1bpp). While the slowdown of the ISR is minimal (the intermediate buffers are in IRAM), the planar grayscale buffer takes only half the space for a given depth, and gray_update[_rect]() and unbuffered drawing/scrolling are faster because less data needs to be moved. It should also make porting of video.rock somewhat easier. * Archos recorders, Ondios: Some slight optimisations of the grayscale library.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7571 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/grayscale.c6
-rw-r--r--apps/plugins/jpeg.c4
-rw-r--r--apps/plugins/lib/gray.h4
-rw-r--r--apps/plugins/lib/gray_core.c132
-rw-r--r--apps/plugins/lib/gray_draw.c58
-rw-r--r--apps/plugins/lib/gray_scroll.c12
-rw-r--r--apps/plugins/mandelbrot.c4
-rw-r--r--firmware/drivers/lcd-h100.c31
8 files changed, 155 insertions, 96 deletions
diff --git a/apps/plugins/grayscale.c b/apps/plugins/grayscale.c
index 3b86304123..cdb3f880e5 100644
--- a/apps/plugins/grayscale.c
+++ b/apps/plugins/grayscale.c
@@ -154,11 +154,11 @@ int main(void)
32 bitplanes for 33 shades of grey.
H1x0: 160 pixels wide, 30 rows (120 pixels) high, (try to) reserve
32 bitplanes for 33 shades of grey. */
- shades = gray_init(rb, gbuf, gbuf_size, true, LCD_WIDTH,
- (GFX_HEIGHT*LCD_DEPTH/8), 32, NULL) + 1;
+ shades = gray_init(rb, gbuf, gbuf_size, true, LCD_WIDTH, GFX_HEIGHT/8,
+ 32, NULL) + 1;
/* place greyscale overlay 1 row down */
- gray_set_position(0, LCD_DEPTH);
+ gray_set_position(0, 1);
rb->snprintf(pbuf, sizeof(pbuf), "Shades: %d", shades);
rb->lcd_puts(0, 0, pbuf);
diff --git a/apps/plugins/jpeg.c b/apps/plugins/jpeg.c
index 1aac438e51..f9dcf2a63d 100644
--- a/apps/plugins/jpeg.c
+++ b/apps/plugins/jpeg.c
@@ -1822,8 +1822,8 @@ int main(char* filename)
/* initialize the grayscale buffer: 32 bitplanes for 33 shades of gray. */
- grayscales = gray_init(rb, buf, buf_size, false, LCD_WIDTH,
- (LCD_HEIGHT*LCD_DEPTH/8), 32, &graysize) + 1;
+ grayscales = gray_init(rb, buf, buf_size, false, LCD_WIDTH, LCD_HEIGHT/8,
+ 32, &graysize) + 1;
buf += graysize;
buf_size -= graysize;
if (grayscales < 33 || buf_size <= 0)
diff --git a/apps/plugins/lib/gray.h b/apps/plugins/lib/gray.h
index 09ae73b8a6..f1007984b5 100644
--- a/apps/plugins/lib/gray.h
+++ b/apps/plugins/lib/gray.h
@@ -107,11 +107,7 @@ void gray_ub_scroll_down(int count);
/*** Internal stuff ***/
-#if LCD_DEPTH == 1
#define _PBLOCK_EXP 3
-#elif LCD_DEPTH == 2
-#define _PBLOCK_EXP 2
-#endif
#define _PBLOCK (1 << _PBLOCK_EXP)
/* flag definitions */
diff --git a/apps/plugins/lib/gray_core.c b/apps/plugins/lib/gray_core.c
index a4ef45d8c1..ecff53f1c5 100644
--- a/apps/plugins/lib/gray_core.c
+++ b/apps/plugins/lib/gray_core.c
@@ -81,10 +81,8 @@ static void _timer_isr(void)
memory. Unbuffered operation provides only a subset of
drawing functions. (only gray_bitmap drawing and scrolling)
width = width in pixels (1..LCD_WIDTH)
- bheight = height in LCD pixel-block units (8 pixels for b&w LCD,
- 4 pixels for 4-grey LCD) (1..LCD_HEIGHT/block_size)
- depth = number of bitplanes to use (1..32 for b&w LCD, 1..16 for
- 4-grey LCD).
+ bheight = height in LCD pixel-block units (8 pixels) (1..LCD_HEIGHT/8)
+ depth = number of bitplanes to use (1..32).
result:
= depth if there was enough memory
@@ -99,8 +97,7 @@ static void _timer_isr(void)
deliver an enhancement over the native display.
The number of displayable shades is calculated as follows:
- b&w LCD: shades = depth + 1
- 4-grey LCD: shades = 3 * depth + 1
+ shades = depth + 1
If you need info about the memory taken by the greyscale buffer, supply a
long* as the last parameter. This long will then contain the number of bytes
@@ -109,7 +106,7 @@ static void _timer_isr(void)
shades * sizeof(long) (bitpatterns)
+ (width * bheight) * depth (bitplane data)
+ buffered ? (chunky front- & backbuffer)
- (width * bheight * 8(4) * 2) : 0
+ (width * bheight * 8 * 2) : 0
+ 0..3 (longword alignment) */
int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
bool buffered, int width, int bheight, int depth, long *buf_taken)
@@ -292,42 +289,41 @@ void gray_update_rect(int x, int y, int width, int height)
#if (CONFIG_CPU == SH7034) && (LCD_DEPTH == 1)
unsigned long pat_stack[8];
unsigned long *pat_ptr;
- unsigned change, ofs;
+ unsigned char *cbuf, *bbuf;
+ unsigned change;
+
+ cbuf = _gray_info.cur_buffer + srcofs_row;
+ bbuf = _gray_info.back_buffer + srcofs_row;
- ofs = srcofs_row;
asm volatile (
- "mov.l @(%[ofs],%[cbuf]),r1\n"
- "mov.l @(%[ofs],%[bbuf]),r2\n"
+ "mov.l @%[cbuf]+,r1 \n"
+ "mov.l @%[bbuf]+,r2 \n"
"xor r1,r2 \n"
- "add #4,%[ofs] \n"
- "mov.l @(%[ofs],%[cbuf]),r1\n"
- "mov.l @(%[ofs],%[bbuf]),%[chg]\n"
+ "mov.l @%[cbuf],r1 \n"
+ "mov.l @%[bbuf],%[chg] \n"
"xor r1,%[chg] \n"
"or r2,%[chg] \n"
: /* outputs */
- [ofs] "+z"(ofs),
+ [cbuf]"+r"(cbuf),
+ [bbuf]"+r"(bbuf),
[chg] "=r"(change)
: /* inputs */
- [cbuf]"r"(_gray_info.cur_buffer),
- [bbuf]"r"(_gray_info.back_buffer)
: /* clobbers */
"r1", "r2"
);
if (change != 0)
{
- unsigned char *cbuf, *bbuf, *addr, *end;
+ unsigned char *addr, *end;
unsigned mask;
pat_ptr = &pat_stack[8];
- cbuf = _gray_info.cur_buffer;
- bbuf = _gray_info.back_buffer;
+ cbuf = _gray_info.cur_buffer + srcofs_row;
+ bbuf = _gray_info.back_buffer + srcofs_row;
/* precalculate the bit patterns with random shifts
* for all 8 pixels and put them on an extra "stack" */
asm volatile (
- "add %[ofs],%[cbuf] \n"
- "add %[ofs],%[bbuf] \n"
"mov #8,r3 \n" /* loop count in r3: 8 pixels */
".ur_pre_loop: \n"
@@ -384,7 +380,6 @@ void gray_update_rect(int x, int y, int width, int height)
[patp]"+r"(pat_ptr),
[mask]"=&r"(mask)
: /* inputs */
- [ofs] "[mask]"(srcofs_row),
[dpth]"r"(_gray_info.depth),
[bpat]"r"(_gray_info.bitpattern),
[rmsk]"r"(_gray_info.randmask)
@@ -473,36 +468,44 @@ void gray_update_rect(int x, int y, int width, int height)
);
}
#elif defined(CPU_COLDFIRE) && (LCD_DEPTH == 2)
- unsigned long pat_stack[4];
+ unsigned long pat_stack[8];
unsigned long *pat_ptr;
+ unsigned char *cbuf, *bbuf;
unsigned change;
+ cbuf = _gray_info.cur_buffer + srcofs_row;
+ bbuf = _gray_info.back_buffer + srcofs_row;
+
asm volatile (
- "move.l (%[ofs]:l:1,%[cbuf]),%[chg] \n"
- "sub.l (%[ofs]:l:1,%[bbuf]),%[chg] \n"
+ "move.l (%[cbuf])+,%%d0 \n"
+ "move.l (%[bbuf])+,%%d1 \n"
+ "eor.l %%d0,%%d1 \n"
+ "move.l (%[cbuf]),%%d0 \n"
+ "move.l (%[bbuf]),%[chg]\n"
+ "eor.l %%d0,%[chg] \n"
+ "or.l %%d1,%[chg] \n"
: /* outputs */
+ [cbuf]"+a"(cbuf),
+ [bbuf]"+a"(bbuf),
[chg] "=&d"(change)
: /* inputs */
- [cbuf]"a"(_gray_info.cur_buffer),
- [bbuf]"a"(_gray_info.back_buffer),
- [ofs] "d"(srcofs_row)
+ : /* clobbers */
+ "d0", "d1"
);
if (change != 0)
{
- unsigned char *cbuf, *bbuf, *addr, *end;
+ unsigned char *addr, *end;
unsigned mask;
- pat_ptr = &pat_stack[4];
- cbuf = _gray_info.cur_buffer;
- bbuf = _gray_info.back_buffer;
+ pat_ptr = &pat_stack[8];
+ cbuf = _gray_info.cur_buffer + srcofs_row;
+ bbuf = _gray_info.back_buffer + srcofs_row;
/* precalculate the bit patterns with random shifts
- * for all 4 pixels and put them on an extra "stack" */
+ * for all 8 pixels and put them on an extra "stack" */
asm volatile (
- "add.l %[ofs],%[cbuf] \n"
- "add.l %[ofs],%[bbuf] \n"
- "moveq.l #4,%%d3 \n" /* loop count in d3: 4 pixels */
+ "moveq.l #8,%%d3 \n" /* loop count in d3: 8 pixels */
"clr.l %[mask] \n"
".ur_pre_loop: \n"
@@ -536,10 +539,10 @@ void gray_update_rect(int x, int y, int width, int height)
"lsr.l %%d1,%%d2 \n"
"or.l %%d0,%%d2 \n" /* rotated_pattern = d2 | d0 */
- "or.l #0x0300,%[mask] \n" /* set mask bit */
+ "or.l #0x0100,%[mask] \n" /* set mask bit */
".ur_skip: \n"
- "lsr.l #2,%[mask] \n" /* shift mask */
+ "lsr.l #1,%[mask] \n" /* shift mask */
"move.l %%d2,-(%[patp]) \n" /* push on pattern stack */
"subq.l #1,%%d3 \n" /* decrease loop count */
@@ -551,7 +554,6 @@ void gray_update_rect(int x, int y, int width, int height)
[rnd] "+d"(_gray_random_buffer),
[mask]"=&d"(mask)
: /* inputs */
- [ofs] "[mask]"(srcofs_row),
[bpat]"a"(_gray_info.bitpattern),
[dpth]"d"(_gray_info.depth),
[rmsk]"d"(_gray_info.randmask)
@@ -562,11 +564,11 @@ void gray_update_rect(int x, int y, int width, int height)
addr = dst_row;
end = addr + MULU16(_gray_info.depth, _gray_info.plane_size);
- /* set the bits for all 4 pixels in all bytes according to the
+ /* set the bits for all 8 pixels in all bytes according to the
* precalculated patterns on the pattern stack */
asm volatile (
- "movem.l (%[patp]),%%d2-%%d5 \n" /* pop all 4 patterns */
-
+ "movem.l (%[patp]),%%d2-%%d6/%%a0-%%a2 \n"
+ /* pop all 8 patterns */
"not.l %[mask] \n" /* set mask -> keep mask */
"and.l #0xFF,%[mask] \n"
"beq.b .ur_sloop \n" /* yes: jump to short loop */
@@ -575,18 +577,26 @@ void gray_update_rect(int x, int y, int width, int height)
"clr.l %%d0 \n"
"lsr.l #1,%%d2 \n" /* shift out mask bit */
"addx.l %%d0,%%d0 \n" /* puts bit into LSB, shifts left by 1 */
- "lsl.l #1,%%d0 \n" /* shift by another 1 for a total of 2 */
"lsr.l #1,%%d3 \n"
"addx.l %%d0,%%d0 \n"
- "lsl.l #1,%%d0 \n"
"lsr.l #1,%%d4 \n"
"addx.l %%d0,%%d0 \n"
- "lsl.l #1,%%d0 \n"
"lsr.l #1,%%d5 \n"
"addx.l %%d0,%%d0 \n"
- "move.l %%d0,%%d1 \n" /* duplicate bits 0, 2, 4, 6, ... */
- "lsl.l #1,%%d1 \n" /* to 1, 3, 5, 7, ... */
- "or.l %%d1,%%d0 \n"
+ "lsr.l #1,%%d6 \n"
+ "addx.l %%d0,%%d0 \n"
+ "move.l %%a0,%%d1 \n"
+ "lsr.l #1,%%d1 \n"
+ "addx.l %%d0,%%d0 \n"
+ "move.l %%d1,%%a0 \n"
+ "move.l %%a1,%%d1 \n"
+ "lsr.l #1,%%d1 \n"
+ "addx.l %%d0,%%d0 \n"
+ "move.l %%d1,%%a1 \n"
+ "move.l %%a2,%%d1 \n"
+ "lsr.l #1,%%d1 \n"
+ "addx.l %%d0,%%d0 \n"
+ "move.l %%d1,%%a2 \n"
"move.b (%[addr]),%%d1 \n" /* read old value */
"and.l %[mask],%%d1 \n" /* mask out unneeded bits */
@@ -603,18 +613,26 @@ void gray_update_rect(int x, int y, int width, int height)
"clr.l %%d0 \n"
"lsr.l #1,%%d2 \n" /* shift out mask bit */
"addx.l %%d0,%%d0 \n" /* puts bit into LSB, shifts left by 1 */
- "lsl.l #1,%%d0 \n" /* shift by another 1 for a total of 2 */
"lsr.l #1,%%d3 \n"
"addx.l %%d0,%%d0 \n"
- "lsl.l #1,%%d0 \n"
"lsr.l #1,%%d4 \n"
"addx.l %%d0,%%d0 \n"
- "lsl.l #1,%%d0 \n"
"lsr.l #1,%%d5 \n"
"addx.l %%d0,%%d0 \n"
- "move.l %%d0,%%d1 \n" /* duplicate bits 0, 2, 4, 6, ... */
- "lsl.l #1,%%d1 \n" /* to 1, 3, 5, 7, ... */
- "or.l %%d1,%%d0 \n"
+ "lsr.l #1,%%d6 \n"
+ "addx.l %%d0,%%d0 \n"
+ "move.l %%a0,%%d1 \n"
+ "lsr.l #1,%%d1 \n"
+ "addx.l %%d0,%%d0 \n"
+ "move.l %%d1,%%a0 \n"
+ "move.l %%a1,%%d1 \n"
+ "lsr.l #1,%%d1 \n"
+ "addx.l %%d0,%%d0 \n"
+ "move.l %%d1,%%a1 \n"
+ "move.l %%a2,%%d1 \n"
+ "lsr.l #1,%%d1 \n"
+ "addx.l %%d0,%%d0 \n"
+ "move.l %%d1,%%a2 \n"
"move.b %%d0,(%[addr]) \n" /* store byte to bitplane */
"add.l %[psiz],%[addr] \n" /* advance to next bitplane */
@@ -626,11 +644,11 @@ void gray_update_rect(int x, int y, int width, int height)
[addr]"+a"(addr),
[mask]"+d"(mask)
: /* inputs */
- [psiz]"r"(_gray_info.plane_size),
+ [psiz]"a"(_gray_info.plane_size),
[end] "a"(end),
[patp]"a"(pat_ptr)
: /* clobbers */
- "d0", "d1", "d2", "d3", "d4", "d5"
+ "d0", "d1", "d2", "d3", "d4", "d5", "d6", "a0", "a1", "a2"
);
}
#endif
diff --git a/apps/plugins/lib/gray_draw.c b/apps/plugins/lib/gray_draw.c
index ab1b286137..4b2237197c 100644
--- a/apps/plugins/lib/gray_draw.c
+++ b/apps/plugins/lib/gray_draw.c
@@ -754,13 +754,13 @@ static void _writearray(unsigned char *address, const unsigned char *src,
_src = src;
/* precalculate the bit patterns with random shifts
- for all 4 pixels and put them on an extra "stack" */
+ for all 8 pixels and put them on an extra "stack" */
asm volatile (
- "moveq.l #4,%%d3 \n" /* loop count in d3: 4 pixels */
+ "moveq.l #8,%%d3 \n" /* loop count in d3: 4 pixels */
".wa_loop: \n" /** load pattern for pixel **/
"clr.l %%d2 \n" /* pattern for skipped pixel must be 0 */
- "lsr.l #2,%[mask] \n" /* shift out 2 lsbs of mask */
+ "lsr.l #1,%[mask] \n" /* shift out 2 lsbs of mask */
"bcc.b .wa_skip \n" /* skip this pixel */
"clr.l %%d0 \n"
@@ -816,10 +816,10 @@ static void _writearray(unsigned char *address, const unsigned char *src,
end = addr + MULU16(_gray_info.depth, _gray_info.plane_size);
_mask = mask;
- /* set the bits for all 4 pixels in all bytes according to the
+ /* set the bits for all 8 pixels in all bytes according to the
* precalculated patterns on the pattern stack */
asm volatile (
- "movem.l (%[patp]),%%d2-%%d5 \n" /* pop all 4 patterns */
+ "movem.l (%[patp]),%%d2-%%d6/%%a0-%%a2 \n" /* pop all 8 patterns */
"not.l %[mask] \n" /* "set" mask -> "keep" mask */
"and.l #0xFF,%[mask] \n"
@@ -829,18 +829,26 @@ static void _writearray(unsigned char *address, const unsigned char *src,
"clr.l %%d0 \n"
"lsr.l #1,%%d2 \n" /* shift out mask bit */
"addx.l %%d0,%%d0 \n" /* puts bit into LSB, shifts left by 1 */
- "lsl.l #1,%%d0 \n" /* shift by another 1 for a total of 2 */
"lsr.l #1,%%d3 \n"
"addx.l %%d0,%%d0 \n"
- "lsl.l #1,%%d0 \n"
"lsr.l #1,%%d4 \n"
"addx.l %%d0,%%d0 \n"
- "lsl.l #1,%%d0 \n"
"lsr.l #1,%%d5 \n"
"addx.l %%d0,%%d0 \n"
- "move.l %%d0,%%d1 \n" /* duplicate bits 0, 2, 4, 6, ... */
- "lsl.l #1,%%d1 \n" /* to 1, 3, 5, 7, ... */
- "or.l %%d1,%%d0 \n"
+ "lsr.l #1,%%d6 \n"
+ "addx.l %%d0,%%d0 \n"
+ "move.l %%a0,%%d1 \n"
+ "lsr.l #1,%%d1 \n"
+ "addx.l %%d0,%%d0 \n"
+ "move.l %%d1,%%a0 \n"
+ "move.l %%a1,%%d1 \n"
+ "lsr.l #1,%%d1 \n"
+ "addx.l %%d0,%%d0 \n"
+ "move.l %%d1,%%a1 \n"
+ "move.l %%a2,%%d1 \n"
+ "lsr.l #1,%%d1 \n"
+ "addx.l %%d0,%%d0 \n"
+ "move.l %%d1,%%a2 \n"
"move.b (%[addr]),%%d1 \n" /* read old value */
"and.l %[mask],%%d1 \n" /* mask out unneeded bits */
@@ -857,18 +865,26 @@ static void _writearray(unsigned char *address, const unsigned char *src,
"clr.l %%d0 \n"
"lsr.l #1,%%d2 \n" /* shift out mask bit */
"addx.l %%d0,%%d0 \n" /* puts bit into LSB, shifts left by 1 */
- "lsl.l #1,%%d0 \n" /* shift by another 1 for a total of 2 */
"lsr.l #1,%%d3 \n"
"addx.l %%d0,%%d0 \n"
- "lsl.l #1,%%d0 \n"
"lsr.l #1,%%d4 \n"
"addx.l %%d0,%%d0 \n"
- "lsl.l #1,%%d0 \n"
"lsr.l #1,%%d5 \n"
"addx.l %%d0,%%d0 \n"
- "move.l %%d0,%%d1 \n" /* duplicate bits 0, 2, 4, 6, ... */
- "lsl.l #1,%%d1 \n" /* to 1, 3, 5, 7, ... */
- "or.l %%d1,%%d0 \n"
+ "lsr.l #1,%%d6 \n"
+ "addx.l %%d0,%%d0 \n"
+ "move.l %%a0,%%d1 \n"
+ "lsr.l #1,%%d1 \n"
+ "addx.l %%d0,%%d0 \n"
+ "move.l %%d1,%%a0 \n"
+ "move.l %%a1,%%d1 \n"
+ "lsr.l #1,%%d1 \n"
+ "addx.l %%d0,%%d0 \n"
+ "move.l %%d1,%%a1 \n"
+ "move.l %%a2,%%d1 \n"
+ "lsr.l #1,%%d1 \n"
+ "addx.l %%d0,%%d0 \n"
+ "move.l %%d1,%%a2 \n"
"move.b %%d0,(%[addr]) \n" /* store byte to bitplane */
"add.l %[psiz],%[addr] \n" /* advance to next bitplane */
@@ -880,11 +896,11 @@ static void _writearray(unsigned char *address, const unsigned char *src,
[addr]"+a"(addr),
[mask]"+d"(_mask)
: /* inputs */
- [psiz]"r"(_gray_info.plane_size),
+ [psiz]"a"(_gray_info.plane_size),
[end] "a"(end),
[patp]"a"(pat_ptr)
: /* clobbers */
- "d0", "d1", "d2", "d3", "d4", "d5"
+ "d0", "d1", "d2", "d3", "d4", "d5", "d6", "a0", "a1", "a2"
);
#endif
}
@@ -938,8 +954,8 @@ void gray_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
+ MULU16(_gray_info.width, y >> _PBLOCK_EXP);
ny = height - 1 + shift;
- mask = 0xFFu << (LCD_DEPTH * shift);
- mask_bottom = 0xFFu >> (LCD_DEPTH * (~ny & (_PBLOCK-1)));
+ mask = 0xFFu << shift;
+ mask_bottom = 0xFFu >> (~ny & (_PBLOCK-1));
for (; ny >= _PBLOCK; ny -= _PBLOCK)
{
diff --git a/apps/plugins/lib/gray_scroll.c b/apps/plugins/lib/gray_scroll.c
index f7ace0e47c..341024a67e 100644
--- a/apps/plugins/lib/gray_scroll.c
+++ b/apps/plugins/lib/gray_scroll.c
@@ -294,7 +294,9 @@ void gray_ub_scroll_up(int count)
"extu.b r0,r1 \n" /* store data for next round */
".su_shift6: \n" /* shift right by 0..7 bits */
- "shlr2 r0 \n"
+ "shll2 r0 \n"
+ "bra .su_shift0 \n"
+ "shlr8 r0 \n"
".su_shift4: \n"
"shlr2 r0 \n"
".su_shift2: \n"
@@ -378,7 +380,7 @@ void gray_ub_scroll_up(int count)
[wide]"r"(_gray_info.width),
[rows]"r"(_gray_info.bheight - shift),
[addr]"a"(_gray_info.plane_data + _gray_info.plane_size - blockshift),
- [cnt] "d"(2 * count)
+ [cnt] "d"(count)
: /* clobbers */
"a0", "a1", "d0", "d1", "d2", "d3", "d4"
);
@@ -474,7 +476,9 @@ void gray_ub_scroll_down(int count)
"extu.b r0,r0 \n" /* extend unsigned */
".sd_shift6: \n" /* shift left by 0..7 bits */
- "shll2 r0 \n"
+ "shll8 r0 \n"
+ "bra .sd_shift0 \n"
+ "shlr2 r0 \n"
".sd_shift4: \n"
"shll2 r0 \n"
".sd_shift2: \n"
@@ -557,7 +561,7 @@ void gray_ub_scroll_down(int count)
[rows]"r"(_gray_info.bheight - shift),
[psiz]"r"(_gray_info.plane_size),
[addr]"a"(_gray_info.plane_data + blockshift),
- [cnt] "d"(2 * count)
+ [cnt] "d"(count)
: /* clobbers */
"a0", "a1", "d0", "d1", "d2", "d3", "d4"
);
diff --git a/apps/plugins/mandelbrot.c b/apps/plugins/mandelbrot.c
index d5fb0f2b04..88f48d3f2b 100644
--- a/apps/plugins/mandelbrot.c
+++ b/apps/plugins/mandelbrot.c
@@ -353,8 +353,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
/* initialize the grayscale buffer:
* 8 bitplanes for 9 shades of gray.*/
- grayscales = gray_init(rb, gbuf, gbuf_size, false, LCD_WIDTH,
- (LCD_HEIGHT*LCD_DEPTH/8), 8, NULL) + 1;
+ grayscales = gray_init(rb, gbuf, gbuf_size, false, LCD_WIDTH, LCD_HEIGHT/8,
+ 8, NULL) + 1;
if (grayscales != 9) {
rb->snprintf(buff, sizeof(buff), "%d", grayscales);
rb->lcd_puts(0, 1, buff);
diff --git a/firmware/drivers/lcd-h100.c b/firmware/drivers/lcd-h100.c
index bfdceedc35..df08dde6fb 100644
--- a/firmware/drivers/lcd-h100.c
+++ b/firmware/drivers/lcd-h100.c
@@ -211,16 +211,41 @@ void lcd_init(void)
void lcd_blit(const unsigned char* data, int x, int by, int width,
int bheight, int stride)
{
- /* Copy display bitmap to hardware */
+ const unsigned char *src, *src_end;
+ unsigned char *dst_u, *dst_l;
+ unsigned char upper[LCD_WIDTH];
+ unsigned char lower[LCD_WIDTH];
+ unsigned int byte;
+
+ by *= 2;
+
while (bheight--)
{
+ src = data;
+ src_end = data + width;
+ dst_u = upper;
+ dst_l = lower;
+ do
+ {
+ byte = *src++;
+ *dst_u++ = dibits[byte & 0x0F];
+ byte >>= 4;
+ *dst_l++ = dibits[byte & 0x0F];
+ }
+ while (src < src_end);
+
lcd_write_command_ex(LCD_CNTL_PAGE, by++, -1);
lcd_write_command_ex(LCD_CNTL_COLUMN, x, -1);
+ lcd_write_command(LCD_CNTL_DATA_WRITE);
+ lcd_write_data(upper, width);
+ lcd_write_command_ex(LCD_CNTL_PAGE, by++, -1);
+ lcd_write_command_ex(LCD_CNTL_COLUMN, x, -1);
lcd_write_command(LCD_CNTL_DATA_WRITE);
- lcd_write_data(data, width);
+ lcd_write_data(lower, width);
+
data += stride;
- }
+ }
}