summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/plugins/lib/gray.h10
-rw-r--r--apps/plugins/lib/gray_core.c64
-rw-r--r--apps/plugins/lib/gray_draw.c66
-rw-r--r--apps/plugins/lib/gray_scroll.c48
4 files changed, 96 insertions, 92 deletions
diff --git a/apps/plugins/lib/gray.h b/apps/plugins/lib/gray.h
index 460aa83a82..70808945bb 100644
--- a/apps/plugins/lib/gray.h
+++ b/apps/plugins/lib/gray.h
@@ -113,9 +113,13 @@ void gray_ub_scroll_down(int count);
113#define _GRAY_RUNNING 0x0001 /* greyscale overlay is running */ 113#define _GRAY_RUNNING 0x0001 /* greyscale overlay is running */
114#define _GRAY_DEFERRED_UPDATE 0x0002 /* lcd_update() requested */ 114#define _GRAY_DEFERRED_UPDATE 0x0002 /* lcd_update() requested */
115 115
116/* unsigned 16 bit multiplication (a single instruction on the SH) */ 116/* fast unsigned multiplication (16x16bit->32bit or 32x32bit->32bit,
117#define MULU16(a, b) ((unsigned long) \ 117 * whichever is faster for the architecture) */
118 (((unsigned short) (a)) * ((unsigned short) (b)))) 118#ifdef CPU_ARM
119#define _GRAY_MULUQ(a, b) ((uint32_t) (((uint32_t) (a)) * ((uint32_t) (b))))
120#else
121#define _GRAY_MULUQ(a, b) ((uint32_t) (((uint16_t) (a)) * ((uint16_t) (b))))
122#endif
119 123
120/* The grayscale buffer management structure */ 124/* The grayscale buffer management structure */
121struct _gray_info 125struct _gray_info
diff --git a/apps/plugins/lib/gray_core.c b/apps/plugins/lib/gray_core.c
index 2f5f165fbd..b49c99144e 100644
--- a/apps/plugins/lib/gray_core.c
+++ b/apps/plugins/lib/gray_core.c
@@ -225,11 +225,11 @@ static inline void _deferred_update(void)
225static void _timer_isr(void) 225static void _timer_isr(void)
226{ 226{
227#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 227#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
228 _gray_rb->lcd_blit(_gray_info.plane_data + MULU16(_gray_info.plane_size, 228 _gray_rb->lcd_blit(_gray_info.plane_data + _GRAY_MULUQ(_gray_info.plane_size,
229 _gray_info.cur_plane), _gray_info.bx, _gray_info.y, 229 _gray_info.cur_plane), _gray_info.bx, _gray_info.y,
230 _gray_info.bwidth, _gray_info.height, _gray_info.bwidth); 230 _gray_info.bwidth, _gray_info.height, _gray_info.bwidth);
231#else 231#else
232 _gray_rb->lcd_blit(_gray_info.plane_data + MULU16(_gray_info.plane_size, 232 _gray_rb->lcd_blit(_gray_info.plane_data + _GRAY_MULUQ(_gray_info.plane_size,
233 _gray_info.cur_plane), _gray_info.x, _gray_info.by, 233 _gray_info.cur_plane), _gray_info.x, _gray_info.by,
234 _gray_info.width, _gray_info.bheight, _gray_info.width); 234 _gray_info.width, _gray_info.bheight, _gray_info.width);
235#endif 235#endif
@@ -373,7 +373,7 @@ int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
373 /* chunky front- & backbuffer */ 373 /* chunky front- & backbuffer */
374 if (buffered) 374 if (buffered)
375 { 375 {
376 plane_size = MULU16(width, height); 376 plane_size = _GRAY_MULUQ(width, height);
377 buftaken += 2 * plane_size; 377 buftaken += 2 * plane_size;
378 if (buftaken > gbuf_size) 378 if (buftaken > gbuf_size)
379 return 0; 379 return 0;
@@ -387,9 +387,9 @@ int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
387 } 387 }
388 388
389#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 389#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
390 plane_size = MULU16(bdim, height); 390 plane_size = _GRAY_MULUQ(bdim, height);
391#else 391#else
392 plane_size = MULU16(width, bdim); 392 plane_size = _GRAY_MULUQ(width, bdim);
393#endif 393#endif
394 possible_depth = (gbuf_size - buftaken - sizeof(long)) 394 possible_depth = (gbuf_size - buftaken - sizeof(long))
395 / (plane_size + sizeof(long)); 395 / (plane_size + sizeof(long));
@@ -403,9 +403,9 @@ int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
403#ifdef SIMULATOR 403#ifdef SIMULATOR
404 if (!buffered) 404 if (!buffered)
405 { 405 {
406 long orig_size = MULU16(depth, plane_size) + (depth + 1) * sizeof(long); 406 long orig_size = _GRAY_MULUQ(depth, plane_size) + (depth + 1) * sizeof(long);
407 407
408 plane_size = MULU16(width, height); 408 plane_size = _GRAY_MULUQ(width, height);
409 if (plane_size > orig_size) 409 if (plane_size > orig_size)
410 { 410 {
411 buftaken += plane_size; 411 buftaken += plane_size;
@@ -420,7 +420,7 @@ int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
420 } 420 }
421 else 421 else
422#endif 422#endif
423 buftaken += MULU16(depth, plane_size) + (depth + 1) * sizeof(long); 423 buftaken += _GRAY_MULUQ(depth, plane_size) + (depth + 1) * sizeof(long);
424 424
425 _gray_info.x = 0; 425 _gray_info.x = 0;
426 _gray_info.y = 0; 426 _gray_info.y = 0;
@@ -439,8 +439,8 @@ int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
439 _gray_info.cur_plane = 0; 439 _gray_info.cur_plane = 0;
440 _gray_info.plane_size = plane_size; 440 _gray_info.plane_size = plane_size;
441 _gray_info.plane_data = gbuf; 441 _gray_info.plane_data = gbuf;
442 _gray_rb->memset(gbuf, 0, MULU16(depth, plane_size)); 442 _gray_rb->memset(gbuf, 0, _GRAY_MULUQ(depth, plane_size));
443 gbuf += MULU16(depth, plane_size); 443 gbuf += _GRAY_MULUQ(depth, plane_size);
444 _gray_info.bitpattern = (unsigned long *)gbuf; 444 _gray_info.bitpattern = (unsigned long *)gbuf;
445 445
446 i = depth - 1; 446 i = depth - 1;
@@ -481,7 +481,7 @@ int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
481 { 481 {
482 for (i = 0; i < 256; i++) 482 for (i = 0; i < 256; i++)
483 { 483 {
484 data = MULU16(depth, i) + 127; 484 data = _GRAY_MULUQ(depth, i) + 127;
485 _gray_info.idxtable[i] = (data + (data >> 8)) >> 8; 485 _gray_info.idxtable[i] = (data + (data >> 8)) >> 8;
486 /* approx. data / 255 */ 486 /* approx. data / 255 */
487 } 487 }
@@ -492,7 +492,7 @@ int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
492 { 492 {
493 data = exp_s16p16((gamma * log_s16p16(i * 257 + 1)) >> 8) + 128; 493 data = exp_s16p16((gamma * log_s16p16(i * 257 + 1)) >> 8) + 128;
494 data = (data - (data >> 8)) >> 8; /* approx. data /= 257 */ 494 data = (data - (data >> 8)) >> 8; /* approx. data /= 257 */
495 data = MULU16(depth, lcdlinear[data]) + 127; 495 data = _GRAY_MULUQ(depth, lcdlinear[data]) + 127;
496 _gray_info.idxtable[i] = (data + (data >> 8)) >> 8; 496 _gray_info.idxtable[i] = (data + (data >> 8)) >> 8;
497 /* approx. data / 255 */ 497 /* approx. data / 255 */
498 } 498 }
@@ -577,11 +577,11 @@ void gray_show(bool enable)
577static unsigned long _gray_get_pixel(int x, int y) 577static unsigned long _gray_get_pixel(int x, int y)
578{ 578{
579#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 579#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
580 return _gray_info.cur_buffer[MULU16(y - _gray_info.y, _gray_info.width) 580 return _gray_info.cur_buffer[_GRAY_MULUQ(y - _gray_info.y, _gray_info.width)
581 + x - _gray_info.x] 581 + x - _gray_info.x]
582 + (1 << LCD_DEPTH); 582 + (1 << LCD_DEPTH);
583#else 583#else
584 return _gray_info.cur_buffer[MULU16(x - _gray_info.x, _gray_info.height) 584 return _gray_info.cur_buffer[_GRAY_MULUQ(x - _gray_info.x, _gray_info.height)
585 + y - _gray_info.y] 585 + y - _gray_info.y]
586 + (1 << LCD_DEPTH); 586 + (1 << LCD_DEPTH);
587#endif 587#endif
@@ -630,8 +630,8 @@ void gray_update_rect(int x, int y, int width, int height)
630 xmax = _gray_info.bwidth - 1; 630 xmax = _gray_info.bwidth - 1;
631 bwidth = xmax - x + 1; 631 bwidth = xmax - x + 1;
632 632
633 srcofs = MULU16(_gray_info.width, y) + (x << 3); 633 srcofs = _GRAY_MULUQ(_gray_info.width, y) + (x << 3);
634 dst = _gray_info.plane_data + MULU16(_gray_info.bwidth, y) + x; 634 dst = _gray_info.plane_data + _GRAY_MULUQ(_gray_info.bwidth, y) + x;
635 635
636 /* Copy specified rectangle bitmap to hardware */ 636 /* Copy specified rectangle bitmap to hardware */
637 for (; height > 0; height--) 637 for (; height > 0; height--)
@@ -982,7 +982,7 @@ void gray_update_rect(int x, int y, int width, int height)
982 } 982 }
983 983
984 addr = dst_row; 984 addr = dst_row;
985 end = addr + MULU16(_gray_info.depth, _gray_info.plane_size); 985 end = addr + _GRAY_MULUQ(_gray_info.depth, _gray_info.plane_size);
986 986
987 /* set the bits for all 8 pixels in all bytes according to the 987 /* set the bits for all 8 pixels in all bytes according to the
988 * precalculated patterns on the pattern stack */ 988 * precalculated patterns on the pattern stack */
@@ -1050,8 +1050,8 @@ void gray_update_rect(int x, int y, int width, int height)
1050 if (ymax >= _gray_info.bheight) 1050 if (ymax >= _gray_info.bheight)
1051 ymax = _gray_info.bheight - 1; 1051 ymax = _gray_info.bheight - 1;
1052 1052
1053 srcofs = (y << 3) + MULU16(_gray_info.height, x); 1053 srcofs = (y << 3) + _GRAY_MULUQ(_gray_info.height, x);
1054 dst = _gray_info.plane_data + MULU16(_gray_info.width, y) + x; 1054 dst = _gray_info.plane_data + _GRAY_MULUQ(_gray_info.width, y) + x;
1055 1055
1056 /* Copy specified rectangle bitmap to hardware */ 1056 /* Copy specified rectangle bitmap to hardware */
1057 for (; y <= ymax; y++) 1057 for (; y <= ymax; y++)
@@ -1879,7 +1879,7 @@ void gray_update_rect(int x, int y, int width, int height)
1879 } 1879 }
1880 1880
1881 addr = dst_row; 1881 addr = dst_row;
1882 end = addr + MULU16(_gray_info.depth, _gray_info.plane_size); 1882 end = addr + _GRAY_MULUQ(_gray_info.depth, _gray_info.plane_size);
1883 1883
1884 /* set the bits for all 8 pixels in all bytes according to the 1884 /* set the bits for all 8 pixels in all bytes according to the
1885 * precalculated patterns on the pattern stack */ 1885 * precalculated patterns on the pattern stack */
@@ -2037,9 +2037,9 @@ static void gray_screendump_hook(int fd)
2037 2037
2038 for (i = _gray_info.depth; i > 0; i--) 2038 for (i = _gray_info.depth; i > 0; i--)
2039 { 2039 {
2040 *clut_entry++ = MULU16(BMP_BLUE, i) / _gray_info.depth; 2040 *clut_entry++ = _GRAY_MULUQ(BMP_BLUE, i) / _gray_info.depth;
2041 *clut_entry++ = MULU16(BMP_GREEN, i) / _gray_info.depth; 2041 *clut_entry++ = _GRAY_MULUQ(BMP_GREEN, i) / _gray_info.depth;
2042 *clut_entry++ = MULU16(BMP_RED, i) / _gray_info.depth; 2042 *clut_entry++ = _GRAY_MULUQ(BMP_RED, i) / _gray_info.depth;
2043 clut_entry++; 2043 clut_entry++;
2044 } 2044 }
2045 _gray_rb->write(fd, linebuf, 4*BMP_VARCOLORS); 2045 _gray_rb->write(fd, linebuf, 4*BMP_VARCOLORS);
@@ -2052,14 +2052,14 @@ static void gray_screendump_hook(int fd)
2052 gy = y - _gray_info.y; 2052 gy = y - _gray_info.y;
2053#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 2053#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
2054#if LCD_DEPTH == 2 2054#if LCD_DEPTH == 2
2055 lcdptr = _gray_rb->lcd_framebuffer + MULU16(LCD_FBWIDTH, y); 2055 lcdptr = _gray_rb->lcd_framebuffer + _GRAY_MULUQ(LCD_FBWIDTH, y);
2056 2056
2057 if ((unsigned) gy < (unsigned) _gray_info.height) 2057 if ((unsigned) gy < (unsigned) _gray_info.height)
2058 { 2058 {
2059 /* line contains greyscale (and maybe b&w) graphics */ 2059 /* line contains greyscale (and maybe b&w) graphics */
2060#ifndef SIMULATOR 2060#ifndef SIMULATOR
2061 unsigned char *grayptr = _gray_info.plane_data 2061 unsigned char *grayptr = _gray_info.plane_data
2062 + MULU16(_gray_info.bwidth, gy); 2062 + _GRAY_MULUQ(_gray_info.bwidth, gy);
2063#endif 2063#endif
2064 2064
2065 for (x = 0; x < LCD_WIDTH; x += 4) 2065 for (x = 0; x < LCD_WIDTH; x += 4)
@@ -2069,7 +2069,7 @@ static void gray_screendump_hook(int fd)
2069 if ((unsigned)gx < (unsigned)_gray_info.width) 2069 if ((unsigned)gx < (unsigned)_gray_info.width)
2070 { 2070 {
2071#ifdef SIMULATOR 2071#ifdef SIMULATOR
2072 data = MULU16(gy, _gray_info.width) + gx; 2072 data = _GRAY_MULUQ(gy, _gray_info.width) + gx;
2073 2073
2074 for (i = 0; i < 4; i++) 2074 for (i = 0; i < 4; i++)
2075 linebuf[x + i] = BMP_FIXEDCOLORS + _gray_info.depth 2075 linebuf[x + i] = BMP_FIXEDCOLORS + _gray_info.depth
@@ -2122,14 +2122,14 @@ static void gray_screendump_hook(int fd)
2122#if LCD_DEPTH == 1 2122#if LCD_DEPTH == 1
2123 mask = 1 << (y & 7); 2123 mask = 1 << (y & 7);
2124 by = y >> 3; 2124 by = y >> 3;
2125 lcdptr = _gray_rb->lcd_framebuffer + MULU16(LCD_WIDTH, by); 2125 lcdptr = _gray_rb->lcd_framebuffer + _GRAY_MULUQ(LCD_WIDTH, by);
2126 2126
2127 if ((unsigned) gy < (unsigned) _gray_info.height) 2127 if ((unsigned) gy < (unsigned) _gray_info.height)
2128 { 2128 {
2129 /* line contains greyscale (and maybe b&w) graphics */ 2129 /* line contains greyscale (and maybe b&w) graphics */
2130#ifndef SIMULATOR 2130#ifndef SIMULATOR
2131 unsigned char *grayptr = _gray_info.plane_data 2131 unsigned char *grayptr = _gray_info.plane_data
2132 + MULU16(_gray_info.width, gy >> 3); 2132 + _GRAY_MULUQ(_gray_info.width, gy >> 3);
2133#endif 2133#endif
2134 2134
2135 for (x = 0; x < LCD_WIDTH; x++) 2135 for (x = 0; x < LCD_WIDTH; x++)
@@ -2140,7 +2140,7 @@ static void gray_screendump_hook(int fd)
2140 { 2140 {
2141#ifdef SIMULATOR 2141#ifdef SIMULATOR
2142 linebuf[x] = BMP_FIXEDCOLORS + _gray_info.depth 2142 linebuf[x] = BMP_FIXEDCOLORS + _gray_info.depth
2143 - _gray_info.cur_buffer[MULU16(gx, _gray_info.height) + gy]; 2143 - _gray_info.cur_buffer[_GRAY_MULUQ(gx, _gray_info.height) + gy];
2144#else 2144#else
2145 int idx = BMP_FIXEDCOLORS; 2145 int idx = BMP_FIXEDCOLORS;
2146 unsigned char *grayptr2 = grayptr + gx; 2146 unsigned char *grayptr2 = grayptr + gx;
@@ -2170,14 +2170,14 @@ static void gray_screendump_hook(int fd)
2170#elif LCD_DEPTH == 2 2170#elif LCD_DEPTH == 2
2171 shift = 2 * (y & 3); 2171 shift = 2 * (y & 3);
2172 by = y >> 2; 2172 by = y >> 2;
2173 lcdptr = _gray_rb->lcd_framebuffer + MULU16(LCD_WIDTH, by); 2173 lcdptr = _gray_rb->lcd_framebuffer + _GRAY_MULUQ(LCD_WIDTH, by);
2174 2174
2175 if ((unsigned)gy < (unsigned)_gray_info.height) 2175 if ((unsigned)gy < (unsigned)_gray_info.height)
2176 { 2176 {
2177 /* line contains greyscale (and maybe b&w) graphics */ 2177 /* line contains greyscale (and maybe b&w) graphics */
2178#ifndef SIMULATOR 2178#ifndef SIMULATOR
2179 unsigned char *grayptr = _gray_info.plane_data 2179 unsigned char *grayptr = _gray_info.plane_data
2180 + MULU16(_gray_info.width, gy >> 3); 2180 + _GRAY_MULUQ(_gray_info.width, gy >> 3);
2181 mask = 1 << (gy & 7); 2181 mask = 1 << (gy & 7);
2182#endif 2182#endif
2183 2183
@@ -2189,7 +2189,7 @@ static void gray_screendump_hook(int fd)
2189 { 2189 {
2190#ifdef SIMULATOR 2190#ifdef SIMULATOR
2191 linebuf[x] = BMP_FIXEDCOLORS + _gray_info.depth 2191 linebuf[x] = BMP_FIXEDCOLORS + _gray_info.depth
2192 - _gray_info.cur_buffer[MULU16(gx, _gray_info.height) + gy]; 2192 - _gray_info.cur_buffer[_GRAY_MULUQ(gx, _gray_info.height) + gy];
2193#else 2193#else
2194 int idx = BMP_FIXEDCOLORS; 2194 int idx = BMP_FIXEDCOLORS;
2195 unsigned char *grayptr2 = grayptr + gx; 2195 unsigned char *grayptr2 = grayptr + gx;
diff --git a/apps/plugins/lib/gray_draw.c b/apps/plugins/lib/gray_draw.c
index e501618e8d..b66b8d708a 100644
--- a/apps/plugins/lib/gray_draw.c
+++ b/apps/plugins/lib/gray_draw.c
@@ -65,7 +65,7 @@ void gray_clear_display(void)
65 _gray_info.fg_index : _gray_info.bg_index; 65 _gray_info.fg_index : _gray_info.bg_index;
66 66
67 _gray_rb->memset(_gray_info.cur_buffer, brightness, 67 _gray_rb->memset(_gray_info.cur_buffer, brightness,
68 MULU16(_gray_info.width, _gray_info.height)); 68 _GRAY_MULUQ(_gray_info.width, _gray_info.height));
69} 69}
70 70
71/* Set a single pixel */ 71/* Set a single pixel */
@@ -74,10 +74,10 @@ void gray_drawpixel(int x, int y)
74 if (((unsigned)x < (unsigned)_gray_info.width) 74 if (((unsigned)x < (unsigned)_gray_info.width)
75 && ((unsigned)y < (unsigned)_gray_info.height)) 75 && ((unsigned)y < (unsigned)_gray_info.height))
76#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 76#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
77 _gray_pixelfuncs[_gray_info.drawmode](&_gray_info.cur_buffer[MULU16(y, 77 _gray_pixelfuncs[_gray_info.drawmode](&_gray_info.cur_buffer[_GRAY_MULUQ(y,
78 _gray_info.width) + x]); 78 _gray_info.width) + x]);
79#else 79#else
80 _gray_pixelfuncs[_gray_info.drawmode](&_gray_info.cur_buffer[MULU16(x, 80 _gray_pixelfuncs[_gray_info.drawmode](&_gray_info.cur_buffer[_GRAY_MULUQ(x,
81 _gray_info.height) + y]); 81 _gray_info.height) + y]);
82#endif 82#endif
83} 83}
@@ -138,9 +138,9 @@ void gray_drawline(int x1, int y1, int x2, int y2)
138 if (((unsigned)x < (unsigned)_gray_info.width) 138 if (((unsigned)x < (unsigned)_gray_info.width)
139 && ((unsigned)y < (unsigned)_gray_info.height)) 139 && ((unsigned)y < (unsigned)_gray_info.height))
140#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 140#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
141 pfunc(&_gray_info.cur_buffer[MULU16(y, _gray_info.width) + x]); 141 pfunc(&_gray_info.cur_buffer[_GRAY_MULUQ(y, _gray_info.width) + x]);
142#else 142#else
143 pfunc(&_gray_info.cur_buffer[MULU16(x, _gray_info.height) + y]); 143 pfunc(&_gray_info.cur_buffer[_GRAY_MULUQ(x, _gray_info.height) + y]);
144#endif 144#endif
145 145
146 if (d < 0) 146 if (d < 0)
@@ -205,7 +205,7 @@ void gray_hline(int x1, int x2, int y)
205 } 205 }
206 } 206 }
207 pfunc = _gray_pixelfuncs[_gray_info.drawmode]; 207 pfunc = _gray_pixelfuncs[_gray_info.drawmode];
208 dst = &_gray_info.cur_buffer[MULU16(y, _gray_info.width) + x1]; 208 dst = &_gray_info.cur_buffer[_GRAY_MULUQ(y, _gray_info.width) + x1];
209 209
210 if (fillopt) 210 if (fillopt)
211 _gray_rb->memset(dst, bits, x2 - x1 + 1); 211 _gray_rb->memset(dst, bits, x2 - x1 + 1);
@@ -245,9 +245,9 @@ void gray_vline(int x, int y1, int y2)
245 y2 = _gray_info.height - 1; 245 y2 = _gray_info.height - 1;
246 246
247 pfunc = _gray_pixelfuncs[_gray_info.drawmode]; 247 pfunc = _gray_pixelfuncs[_gray_info.drawmode];
248 dst = &_gray_info.cur_buffer[MULU16(y1, _gray_info.width) + x]; 248 dst = &_gray_info.cur_buffer[_GRAY_MULUQ(y1, _gray_info.width) + x];
249 249
250 dst_end = dst + MULU16(y2 - y1, _gray_info.width); 250 dst_end = dst + _GRAY_MULUQ(y2 - y1, _gray_info.width);
251 do 251 do
252 { 252 {
253 pfunc(dst); 253 pfunc(dst);
@@ -354,9 +354,9 @@ void gray_hline(int x1, int x2, int y)
354 x2 = _gray_info.width - 1; 354 x2 = _gray_info.width - 1;
355 355
356 pfunc = _gray_pixelfuncs[_gray_info.drawmode]; 356 pfunc = _gray_pixelfuncs[_gray_info.drawmode];
357 dst = &_gray_info.cur_buffer[MULU16(x1, _gray_info.height) + y]; 357 dst = &_gray_info.cur_buffer[_GRAY_MULUQ(x1, _gray_info.height) + y];
358 358
359 dst_end = dst + MULU16(x2 - x1, _gray_info.height); 359 dst_end = dst + _GRAY_MULUQ(x2 - x1, _gray_info.height);
360 do 360 do
361 { 361 {
362 pfunc(dst); 362 pfunc(dst);
@@ -410,7 +410,7 @@ void gray_vline(int x, int y1, int y2)
410 } 410 }
411 } 411 }
412 pfunc = _gray_pixelfuncs[_gray_info.drawmode]; 412 pfunc = _gray_pixelfuncs[_gray_info.drawmode];
413 dst = &_gray_info.cur_buffer[MULU16(x, _gray_info.height) + y1]; 413 dst = &_gray_info.cur_buffer[_GRAY_MULUQ(x, _gray_info.height) + y1];
414 414
415 if (fillopt) 415 if (fillopt)
416 _gray_rb->memset(dst, bits, y2 - y1 + 1); 416 _gray_rb->memset(dst, bits, y2 - y1 + 1);
@@ -556,8 +556,8 @@ void gray_fillrect(int x, int y, int width, int height)
556 } 556 }
557 pfunc = _gray_pixelfuncs[_gray_info.drawmode]; 557 pfunc = _gray_pixelfuncs[_gray_info.drawmode];
558#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 558#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
559 dst = &_gray_info.cur_buffer[MULU16(y, _gray_info.width) + x]; 559 dst = &_gray_info.cur_buffer[_GRAY_MULUQ(y, _gray_info.width) + x];
560 dst_end = dst + MULU16(height, _gray_info.width); 560 dst_end = dst + _GRAY_MULUQ(height, _gray_info.width);
561 561
562 do 562 do
563 { 563 {
@@ -576,8 +576,8 @@ void gray_fillrect(int x, int y, int width, int height)
576 } 576 }
577 while (dst < dst_end); 577 while (dst < dst_end);
578#else 578#else
579 dst = &_gray_info.cur_buffer[MULU16(x, _gray_info.height) + y]; 579 dst = &_gray_info.cur_buffer[_GRAY_MULUQ(x, _gray_info.height) + y];
580 dst_end = dst + MULU16(width, _gray_info.height); 580 dst_end = dst + _GRAY_MULUQ(width, _gray_info.height);
581 581
582 do 582 do
583 { 583 {
@@ -639,14 +639,14 @@ void gray_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
639 if (y + height > _gray_info.height) 639 if (y + height > _gray_info.height)
640 height = _gray_info.height - y; 640 height = _gray_info.height - y;
641 641
642 src += MULU16(stride, src_y >> 3) + src_x; /* move starting point */ 642 src += _GRAY_MULUQ(stride, src_y >> 3) + src_x; /* move starting point */
643 src_y &= 7; 643 src_y &= 7;
644 src_end = src + width; 644 src_end = src + width;
645 645
646 fgfunc = _gray_pixelfuncs[_gray_info.drawmode]; 646 fgfunc = _gray_pixelfuncs[_gray_info.drawmode];
647 bgfunc = _gray_pixelfuncs[_gray_info.drawmode ^ DRMODE_INVERSEVID]; 647 bgfunc = _gray_pixelfuncs[_gray_info.drawmode ^ DRMODE_INVERSEVID];
648#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 648#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
649 dst = &_gray_info.cur_buffer[MULU16(y, _gray_info.width) + x]; 649 dst = &_gray_info.cur_buffer[_GRAY_MULUQ(y, _gray_info.width) + x];
650 650
651 do 651 do
652 { 652 {
@@ -655,7 +655,7 @@ void gray_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
655 unsigned data = *src_col >> src_y; 655 unsigned data = *src_col >> src_y;
656 int numbits = 8 - src_y; 656 int numbits = 8 - src_y;
657 657
658 dst_end = dst_col + MULU16(height, _gray_info.width); 658 dst_end = dst_col + _GRAY_MULUQ(height, _gray_info.width);
659 do 659 do
660 { 660 {
661 if (data & 0x01) 661 if (data & 0x01)
@@ -677,7 +677,7 @@ void gray_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
677 } 677 }
678 while (src < src_end); 678 while (src < src_end);
679#else /* LCD_PIXELFORMAT == VERTICAL_PACKING */ 679#else /* LCD_PIXELFORMAT == VERTICAL_PACKING */
680 dst = &_gray_info.cur_buffer[MULU16(x, _gray_info.height) + y]; 680 dst = &_gray_info.cur_buffer[_GRAY_MULUQ(x, _gray_info.height) + y];
681 681
682 do 682 do
683 { 683 {
@@ -745,10 +745,10 @@ void gray_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
745 if (y + height > _gray_info.height) 745 if (y + height > _gray_info.height)
746 height = _gray_info.height - y; 746 height = _gray_info.height - y;
747 747
748 src += MULU16(stride, src_y) + src_x; /* move starting point */ 748 src += _GRAY_MULUQ(stride, src_y) + src_x; /* move starting point */
749#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 749#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
750 dst = &_gray_info.cur_buffer[MULU16(y, _gray_info.width) + x]; 750 dst = &_gray_info.cur_buffer[_GRAY_MULUQ(y, _gray_info.width) + x];
751 dst_end = dst + MULU16(height, _gray_info.width); 751 dst_end = dst + _GRAY_MULUQ(height, _gray_info.width);
752 752
753 do 753 do
754 { 754 {
@@ -765,14 +765,14 @@ void gray_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
765 } 765 }
766 while (dst < dst_end); 766 while (dst < dst_end);
767#else /* LCD_PIXELFORMAT == VERTICAL_PACKING */ 767#else /* LCD_PIXELFORMAT == VERTICAL_PACKING */
768 dst = &_gray_info.cur_buffer[MULU16(x, _gray_info.height) + y]; 768 dst = &_gray_info.cur_buffer[_GRAY_MULUQ(x, _gray_info.height) + y];
769 dst_end = dst + height; 769 dst_end = dst + height;
770 770
771 do 771 do
772 { 772 {
773 const unsigned char *src_row = src; 773 const unsigned char *src_row = src;
774 unsigned char *dst_row = dst++; 774 unsigned char *dst_row = dst++;
775 unsigned char *row_end = dst_row + MULU16(width, _gray_info.height); 775 unsigned char *row_end = dst_row + _GRAY_MULUQ(width, _gray_info.height);
776 776
777 do 777 do
778 { 778 {
@@ -843,7 +843,7 @@ void gray_putsxy(int x, int y, const unsigned char *str)
843void gray_ub_clear_display(void) 843void gray_ub_clear_display(void)
844{ 844{
845 _gray_rb->memset(_gray_info.cur_buffer, _gray_info.depth, 845 _gray_rb->memset(_gray_info.cur_buffer, _gray_info.depth,
846 MULU16(_gray_info.width, _gray_info.height)); 846 _GRAY_MULUQ(_gray_info.width, _gray_info.height));
847 gray_update(); 847 gray_update();
848} 848}
849 849
@@ -860,7 +860,7 @@ void gray_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
860/* Clear the greyscale display (sets all pixels to white) */ 860/* Clear the greyscale display (sets all pixels to white) */
861void gray_ub_clear_display(void) 861void gray_ub_clear_display(void)
862{ 862{
863 _gray_rb->memset(_gray_info.plane_data, 0, MULU16(_gray_info.depth, 863 _gray_rb->memset(_gray_info.plane_data, 0, _GRAY_MULUQ(_gray_info.depth,
864 _gray_info.plane_size)); 864 _gray_info.plane_size));
865} 865}
866 866
@@ -1172,7 +1172,7 @@ static void _writearray(unsigned char *address, const unsigned char *src,
1172 } 1172 }
1173 1173
1174 addr = address; 1174 addr = address;
1175 end = addr + MULU16(_gray_info.depth, _gray_info.plane_size); 1175 end = addr + _GRAY_MULUQ(_gray_info.depth, _gray_info.plane_size);
1176 1176
1177 /* set the bits for all 8 pixels in all bytes according to the 1177 /* set the bits for all 8 pixels in all bytes according to the
1178 * precalculated patterns on the pattern stack */ 1178 * precalculated patterns on the pattern stack */
@@ -1243,14 +1243,14 @@ void gray_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
1243 height = _gray_info.height - y; 1243 height = _gray_info.height - y;
1244 1244
1245 shift = x & 7; 1245 shift = x & 7;
1246 src += MULU16(stride, src_y) + src_x - shift; 1246 src += _GRAY_MULUQ(stride, src_y) + src_x - shift;
1247 dst = _gray_info.plane_data + (x >> 3) + MULU16(_gray_info.bwidth, y); 1247 dst = _gray_info.plane_data + (x >> 3) + _GRAY_MULUQ(_gray_info.bwidth, y);
1248 nx = width - 1 + shift; 1248 nx = width - 1 + shift;
1249 1249
1250 mask = 0xFFu >> shift; 1250 mask = 0xFFu >> shift;
1251 mask_right = 0xFFu << (~nx & 7); 1251 mask_right = 0xFFu << (~nx & 7);
1252 1252
1253 dst_end = dst + MULU16(_gray_info.bwidth, height); 1253 dst_end = dst + _GRAY_MULUQ(_gray_info.bwidth, height);
1254 do 1254 do
1255 { 1255 {
1256 const unsigned char *src_row = src; 1256 const unsigned char *src_row = src;
@@ -2038,7 +2038,7 @@ static void _writearray(unsigned char *address, const unsigned char *src,
2038 } 2038 }
2039 2039
2040 addr = address; 2040 addr = address;
2041 end = addr + MULU16(_gray_info.depth, _gray_info.plane_size); 2041 end = addr + _GRAY_MULUQ(_gray_info.depth, _gray_info.plane_size);
2042 2042
2043 /* set the bits for all 8 pixels in all bytes according to the 2043 /* set the bits for all 8 pixels in all bytes according to the
2044 * precalculated patterns on the pattern stack */ 2044 * precalculated patterns on the pattern stack */
@@ -2109,9 +2109,9 @@ void gray_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
2109 height = _gray_info.height - y; 2109 height = _gray_info.height - y;
2110 2110
2111 shift = y & 7; 2111 shift = y & 7;
2112 src += MULU16(stride, src_y) + src_x - MULU16(stride, shift); 2112 src += _GRAY_MULUQ(stride, src_y) + src_x - _GRAY_MULUQ(stride, shift);
2113 dst = _gray_info.plane_data + x 2113 dst = _gray_info.plane_data + x
2114 + MULU16(_gray_info.width, y >> 3); 2114 + _GRAY_MULUQ(_gray_info.width, y >> 3);
2115 ny = height - 1 + shift; 2115 ny = height - 1 + shift;
2116 2116
2117 mask = 0xFFu << shift; 2117 mask = 0xFFu << shift;
diff --git a/apps/plugins/lib/gray_scroll.c b/apps/plugins/lib/gray_scroll.c
index 8f60e7cef1..b366e8db5d 100644
--- a/apps/plugins/lib/gray_scroll.c
+++ b/apps/plugins/lib/gray_scroll.c
@@ -43,7 +43,7 @@ void gray_scroll_left(int count)
43 return; 43 return;
44 44
45 data = _gray_info.cur_buffer; 45 data = _gray_info.cur_buffer;
46 data_end = data + MULU16(_gray_info.width, _gray_info.height); 46 data_end = data + _GRAY_MULUQ(_gray_info.width, _gray_info.height);
47 length = _gray_info.width - count; 47 length = _gray_info.width - count;
48 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ? 48 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
49 _gray_info.fg_index : _gray_info.bg_index; 49 _gray_info.fg_index : _gray_info.bg_index;
@@ -67,7 +67,7 @@ void gray_scroll_right(int count)
67 return; 67 return;
68 68
69 data = _gray_info.cur_buffer; 69 data = _gray_info.cur_buffer;
70 data_end = data + MULU16(_gray_info.width, _gray_info.height); 70 data_end = data + _GRAY_MULUQ(_gray_info.width, _gray_info.height);
71 length = _gray_info.width - count; 71 length = _gray_info.width - count;
72 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ? 72 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
73 _gray_info.fg_index : _gray_info.bg_index; 73 _gray_info.fg_index : _gray_info.bg_index;
@@ -90,8 +90,8 @@ void gray_scroll_up(int count)
90 if ((unsigned)count >= (unsigned)_gray_info.height) 90 if ((unsigned)count >= (unsigned)_gray_info.height)
91 return; 91 return;
92 92
93 shift = MULU16(_gray_info.width, count); 93 shift = _GRAY_MULUQ(_gray_info.width, count);
94 length = MULU16(_gray_info.width, _gray_info.height - count); 94 length = _GRAY_MULUQ(_gray_info.width, _gray_info.height - count);
95 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ? 95 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
96 _gray_info.fg_index : _gray_info.bg_index; 96 _gray_info.fg_index : _gray_info.bg_index;
97 97
@@ -109,8 +109,8 @@ void gray_scroll_down(int count)
109 if ((unsigned)count >= (unsigned)_gray_info.height) 109 if ((unsigned)count >= (unsigned)_gray_info.height)
110 return; 110 return;
111 111
112 shift = MULU16(_gray_info.width, count); 112 shift = _GRAY_MULUQ(_gray_info.width, count);
113 length = MULU16(_gray_info.width, _gray_info.height - count); 113 length = _GRAY_MULUQ(_gray_info.width, _gray_info.height - count);
114 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ? 114 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
115 _gray_info.fg_index : _gray_info.bg_index; 115 _gray_info.fg_index : _gray_info.bg_index;
116 116
@@ -130,8 +130,8 @@ void gray_scroll_left(int count)
130 if ((unsigned)count >= (unsigned)_gray_info.width) 130 if ((unsigned)count >= (unsigned)_gray_info.width)
131 return; 131 return;
132 132
133 shift = MULU16(_gray_info.height, count); 133 shift = _GRAY_MULUQ(_gray_info.height, count);
134 length = MULU16(_gray_info.height, _gray_info.width - count); 134 length = _GRAY_MULUQ(_gray_info.height, _gray_info.width - count);
135 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ? 135 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
136 _gray_info.fg_index : _gray_info.bg_index; 136 _gray_info.fg_index : _gray_info.bg_index;
137 137
@@ -149,8 +149,8 @@ void gray_scroll_right(int count)
149 if ((unsigned)count >= (unsigned)_gray_info.width) 149 if ((unsigned)count >= (unsigned)_gray_info.width)
150 return; 150 return;
151 151
152 shift = MULU16(_gray_info.height, count); 152 shift = _GRAY_MULUQ(_gray_info.height, count);
153 length = MULU16(_gray_info.height, _gray_info.width - count); 153 length = _GRAY_MULUQ(_gray_info.height, _gray_info.width - count);
154 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ? 154 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
155 _gray_info.fg_index : _gray_info.bg_index; 155 _gray_info.fg_index : _gray_info.bg_index;
156 156
@@ -169,7 +169,7 @@ void gray_scroll_up(int count)
169 return; 169 return;
170 170
171 data = _gray_info.cur_buffer; 171 data = _gray_info.cur_buffer;
172 data_end = data + MULU16(_gray_info.width, _gray_info.height); 172 data_end = data + _GRAY_MULUQ(_gray_info.width, _gray_info.height);
173 length = _gray_info.height - count; 173 length = _gray_info.height - count;
174 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ? 174 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
175 _gray_info.fg_index : _gray_info.bg_index; 175 _gray_info.fg_index : _gray_info.bg_index;
@@ -193,7 +193,7 @@ void gray_scroll_down(int count)
193 return; 193 return;
194 194
195 data = _gray_info.cur_buffer; 195 data = _gray_info.cur_buffer;
196 data_end = data + MULU16(_gray_info.width, _gray_info.height); 196 data_end = data + _GRAY_MULUQ(_gray_info.width, _gray_info.height);
197 length = _gray_info.height - count; 197 length = _gray_info.height - count;
198 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ? 198 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
199 _gray_info.fg_index : _gray_info.bg_index; 199 _gray_info.fg_index : _gray_info.bg_index;
@@ -267,7 +267,7 @@ void gray_ub_scroll_left(int count)
267 { 267 {
268 unsigned char *ptr_row = ptr; 268 unsigned char *ptr_row = ptr;
269 unsigned char *row_end = ptr_row 269 unsigned char *row_end = ptr_row
270 + MULU16(_gray_info.plane_size, _gray_info.depth); 270 + _GRAY_MULUQ(_gray_info.plane_size, _gray_info.depth);
271 do 271 do
272 { 272 {
273 _gray_rb->memmove(ptr_row, ptr_row + shift, length); 273 _gray_rb->memmove(ptr_row, ptr_row + shift, length);
@@ -348,7 +348,7 @@ void gray_ub_scroll_right(int count)
348 { 348 {
349 unsigned char *ptr_row = ptr; 349 unsigned char *ptr_row = ptr;
350 unsigned char *row_end = ptr_row 350 unsigned char *row_end = ptr_row
351 + MULU16(_gray_info.plane_size, _gray_info.depth); 351 + _GRAY_MULUQ(_gray_info.plane_size, _gray_info.depth);
352 do 352 do
353 { 353 {
354 _gray_rb->memmove(ptr_row + shift, ptr_row, length); 354 _gray_rb->memmove(ptr_row + shift, ptr_row, length);
@@ -415,7 +415,7 @@ void gray_ub_scroll_up(int count)
415 if ((unsigned) count >= (unsigned) _gray_info.height) 415 if ((unsigned) count >= (unsigned) _gray_info.height)
416 return; 416 return;
417 417
418 blockshift = MULU16(_gray_info.bwidth, count); 418 blockshift = _GRAY_MULUQ(_gray_info.bwidth, count);
419 ptr = _gray_info.plane_data; 419 ptr = _gray_info.plane_data;
420 ptr_end2 = ptr + _gray_info.plane_size; 420 ptr_end2 = ptr + _gray_info.plane_size;
421 ptr_end1 = ptr_end2 - blockshift; 421 ptr_end1 = ptr_end2 - blockshift;
@@ -424,7 +424,7 @@ void gray_ub_scroll_up(int count)
424 { 424 {
425 unsigned char *ptr_row = ptr; 425 unsigned char *ptr_row = ptr;
426 unsigned char *row_end = ptr_row 426 unsigned char *row_end = ptr_row
427 + MULU16(_gray_info.plane_size, _gray_info.depth); 427 + _GRAY_MULUQ(_gray_info.plane_size, _gray_info.depth);
428 if (ptr < ptr_end1) 428 if (ptr < ptr_end1)
429 { 429 {
430 do 430 do
@@ -459,7 +459,7 @@ void gray_ub_scroll_down(int count)
459 if ((unsigned) count >= (unsigned) _gray_info.height) 459 if ((unsigned) count >= (unsigned) _gray_info.height)
460 return; 460 return;
461 461
462 blockshift = MULU16(_gray_info.bwidth, count); 462 blockshift = _GRAY_MULUQ(_gray_info.bwidth, count);
463 ptr_end2 = _gray_info.plane_data; 463 ptr_end2 = _gray_info.plane_data;
464 ptr_end1 = ptr_end2 + blockshift; 464 ptr_end1 = ptr_end2 + blockshift;
465 ptr = ptr_end2 + _gray_info.plane_size; 465 ptr = ptr_end2 + _gray_info.plane_size;
@@ -470,7 +470,7 @@ void gray_ub_scroll_down(int count)
470 470
471 ptr -= _gray_info.bwidth; 471 ptr -= _gray_info.bwidth;
472 ptr_row = ptr; 472 ptr_row = ptr;
473 row_end = ptr_row + MULU16(_gray_info.plane_size, _gray_info.depth); 473 row_end = ptr_row + _GRAY_MULUQ(_gray_info.plane_size, _gray_info.depth);
474 474
475 if (ptr >= ptr_end1) 475 if (ptr >= ptr_end1)
476 { 476 {
@@ -514,7 +514,7 @@ void gray_ub_scroll_left(int count)
514 { 514 {
515 unsigned char *ptr_row = ptr; 515 unsigned char *ptr_row = ptr;
516 unsigned char *row_end = ptr_row 516 unsigned char *row_end = ptr_row
517 + MULU16(_gray_info.plane_size, _gray_info.depth); 517 + _GRAY_MULUQ(_gray_info.plane_size, _gray_info.depth);
518 do 518 do
519 { 519 {
520 _gray_rb->memmove(ptr_row, ptr_row + count, length); 520 _gray_rb->memmove(ptr_row, ptr_row + count, length);
@@ -546,7 +546,7 @@ void gray_ub_scroll_right(int count)
546 { 546 {
547 unsigned char *ptr_row = ptr; 547 unsigned char *ptr_row = ptr;
548 unsigned char *row_end = ptr_row 548 unsigned char *row_end = ptr_row
549 + MULU16(_gray_info.plane_size, _gray_info.depth); 549 + _GRAY_MULUQ(_gray_info.plane_size, _gray_info.depth);
550 do 550 do
551 { 551 {
552 _gray_rb->memmove(ptr_row + count, ptr_row, length); 552 _gray_rb->memmove(ptr_row + count, ptr_row, length);
@@ -575,7 +575,7 @@ void gray_ub_scroll_up(int count)
575 575
576 if (shift) 576 if (shift)
577 { 577 {
578 blockshift = MULU16(_gray_info.width, shift); 578 blockshift = _GRAY_MULUQ(_gray_info.width, shift);
579 ptr = _gray_info.plane_data; 579 ptr = _gray_info.plane_data;
580 ptr_end2 = ptr + _gray_info.plane_size; 580 ptr_end2 = ptr + _gray_info.plane_size;
581 ptr_end1 = ptr_end2 - blockshift; 581 ptr_end1 = ptr_end2 - blockshift;
@@ -584,7 +584,7 @@ void gray_ub_scroll_up(int count)
584 { 584 {
585 unsigned char *ptr_row = ptr; 585 unsigned char *ptr_row = ptr;
586 unsigned char *row_end = ptr_row 586 unsigned char *row_end = ptr_row
587 + MULU16(_gray_info.plane_size, _gray_info.depth); 587 + _GRAY_MULUQ(_gray_info.plane_size, _gray_info.depth);
588 if (ptr < ptr_end1) 588 if (ptr < ptr_end1)
589 { 589 {
590 do 590 do
@@ -758,7 +758,7 @@ void gray_ub_scroll_down(int count)
758 758
759 if (shift) 759 if (shift)
760 { 760 {
761 blockshift = MULU16(_gray_info.width, shift); 761 blockshift = _GRAY_MULUQ(_gray_info.width, shift);
762 ptr_end2 = _gray_info.plane_data; 762 ptr_end2 = _gray_info.plane_data;
763 ptr_end1 = ptr_end2 + blockshift; 763 ptr_end1 = ptr_end2 + blockshift;
764 ptr = ptr_end2 + _gray_info.plane_size; 764 ptr = ptr_end2 + _gray_info.plane_size;
@@ -769,7 +769,7 @@ void gray_ub_scroll_down(int count)
769 769
770 ptr -= _gray_info.width; 770 ptr -= _gray_info.width;
771 ptr_row = ptr; 771 ptr_row = ptr;
772 row_end = ptr_row + MULU16(_gray_info.plane_size, _gray_info.depth); 772 row_end = ptr_row + _GRAY_MULUQ(_gray_info.plane_size, _gray_info.depth);
773 773
774 if (ptr >= ptr_end1) 774 if (ptr >= ptr_end1)
775 { 775 {