1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c
index d1b417a..6a43fd2 100644
--- a/firmware/drivers/lcd-16bit.c
+++ b/firmware/drivers/lcd-16bit.c
@@ -839,7 +839,7 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x,
                                             int src_y, int stride, int x,
                                             int y, int width, int height)
 {
-    fb_data *dst, *dst_end;
+    fb_data *dst;

     /* nothing to draw? */
     if ((width <= 0) || (height <= 0) || (x >= current_vp->width) || 
@@ -866,22 +866,23 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x,

     src += stride * src_y + src_x; /* move starting point */
     dst = LCDADDR(current_vp->x + x, current_vp->y + y);
-    dst_end = dst + height * LCD_WIDTH;
+    int fg = current_vp->fg_pattern;

     do
     {
-        int i;
-        for(i = 0;i < width;i++)
+        int i = 0;
+        do
         {
             if (src[i] == REPLACEWITHFG_COLOR)
-                dst[i] = current_vp->fg_pattern;
+                dst[i] = fg;
             else if(src[i] != TRANSPARENT_COLOR)
                 dst[i] = src[i];
         }
+        while (++i < width);
         src += stride;
         dst += LCD_WIDTH;
     }
-    while (dst < dst_end);
+    while (--height);
 }
 #endif /* !defined(TOSHIBA_GIGABEAT_F) || defined(SIMULATOR) */