summaryrefslogtreecommitdiff
path: root/apps/plugins/lib/gray_core.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/lib/gray_core.c')
-rw-r--r--apps/plugins/lib/gray_core.c64
1 files changed, 32 insertions, 32 deletions
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;