summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/plugin.h9
-rw-r--r--apps/plugins/lib/grey.h9
-rw-r--r--apps/plugins/lib/grey_core.c69
-rw-r--r--apps/plugins/lib/grey_draw.c17
-rw-r--r--apps/plugins/lib/grey_scroll.c16
5 files changed, 61 insertions, 59 deletions
diff --git a/apps/plugin.h b/apps/plugin.h
index 849c10bb89..a3ec9c3148 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -119,12 +119,12 @@
119#define PLUGIN_MAGIC 0x526F634B /* RocK */ 119#define PLUGIN_MAGIC 0x526F634B /* RocK */
120 120
121/* increase this every time the api struct changes */ 121/* increase this every time the api struct changes */
122#define PLUGIN_API_VERSION 95 122#define PLUGIN_API_VERSION 96
123 123
124/* update this to latest version if a change to the api struct breaks 124/* update this to latest version if a change to the api struct breaks
125 backwards compatibility (and please take the opportunity to sort in any 125 backwards compatibility (and please take the opportunity to sort in any
126 new function which are "waiting" at the end of the function table) */ 126 new function which are "waiting" at the end of the function table) */
127#define PLUGIN_MIN_API_VERSION 95 127#define PLUGIN_MIN_API_VERSION 96
128 128
129/* plugin return codes */ 129/* plugin return codes */
130enum plugin_status { 130enum plugin_status {
@@ -268,8 +268,9 @@ struct plugin_api {
268 int height); 268 int height);
269#endif 269#endif
270#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) && !defined(SIMULATOR) 270#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) && !defined(SIMULATOR)
271 void (*lcd_grey_phase_blit)(const struct grey_data *data, int bx, int by, 271 void (*lcd_grey_phase_blit)(unsigned char *values, unsigned char *phases,
272 int bwidth, int bheight, int stride); 272 int bx, int by, int bwidth, int bheight,
273 int stride);
273#endif 274#endif
274#if defined(HAVE_LCD_COLOR) 275#if defined(HAVE_LCD_COLOR)
275 void (*lcd_yuv_blit)(unsigned char * const src[3], 276 void (*lcd_yuv_blit)(unsigned char * const src[3],
diff --git a/apps/plugins/lib/grey.h b/apps/plugins/lib/grey.h
index 136794bd26..9a3bd7d3f8 100644
--- a/apps/plugins/lib/grey.h
+++ b/apps/plugins/lib/grey.h
@@ -121,12 +121,12 @@ void grey_ub_scroll_down(int count);
121#endif 121#endif
122 122
123#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 123#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
124#define _GREY_X_ADVANCE sizeof(struct grey_data) 124#define _GREY_X_ADVANCE 1
125#else 125#else
126#if LCD_DEPTH == 1 126#if LCD_DEPTH == 1
127#define _GREY_X_ADVANCE (8*sizeof(struct grey_data)) 127#define _GREY_X_ADVANCE 8
128#elif LCD_DEPTH == 2 128#elif LCD_DEPTH == 2
129#define _GREY_X_ADVANCE (4*sizeof(struct grey_data)) 129#define _GREY_X_ADVANCE 4
130#endif 130#endif
131#endif /* LCD_PIXELFORMAT */ 131#endif /* LCD_PIXELFORMAT */
132 132
@@ -146,7 +146,8 @@ struct _grey_info
146#endif 146#endif
147 unsigned long flags; /* various flags, see #defines */ 147 unsigned long flags; /* various flags, see #defines */
148#ifndef SIMULATOR 148#ifndef SIMULATOR
149 struct grey_data *data; /* start of greyscale display data */ 149 unsigned char *values; /* start of greyscale pixel values */
150 unsigned char *phases; /* start of greyscale pixel phases */
150#endif 151#endif
151 unsigned char *buffer; /* start of chunky pixel buffer (for buffered mode) */ 152 unsigned char *buffer; /* start of chunky pixel buffer (for buffered mode) */
152 unsigned char gvalue[256]; /* calculated brightness -> greyvalue table */ 153 unsigned char gvalue[256]; /* calculated brightness -> greyvalue table */
diff --git a/apps/plugins/lib/grey_core.c b/apps/plugins/lib/grey_core.c
index b3ab640602..43eed9b022 100644
--- a/apps/plugins/lib/grey_core.c
+++ b/apps/plugins/lib/grey_core.c
@@ -222,11 +222,13 @@ static inline void _deferred_update(void)
222static void _timer_isr(void) 222static void _timer_isr(void)
223{ 223{
224#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 224#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
225 _grey_rb->lcd_grey_phase_blit(_grey_info.data, _grey_info.bx, _grey_info.y, 225 _grey_rb->lcd_grey_phase_blit(_grey_info.values, _grey_info.phases,
226 _grey_info.bx, _grey_info.y,
226 _grey_info.bwidth, _grey_info.height, 227 _grey_info.bwidth, _grey_info.height,
227 _grey_info.width); 228 _grey_info.width);
228#else 229#else
229 _grey_rb->lcd_grey_phase_blit(_grey_info.data, _grey_info.x, _grey_info.by, 230 _grey_rb->lcd_grey_phase_blit(_grey_info.values, _grey_info.phases,
231 _grey_info.x, _grey_info.by,
230 _grey_info.width, _grey_info.bheight, 232 _grey_info.width, _grey_info.bheight,
231 _grey_info.width); 233 _grey_info.width);
232#endif 234#endif
@@ -321,7 +323,7 @@ bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
321 long plane_size, buftaken; 323 long plane_size, buftaken;
322 unsigned data; 324 unsigned data;
323#ifndef SIMULATOR 325#ifndef SIMULATOR
324 struct grey_data *grey_data, *grey_end; 326 unsigned *dst, *end;
325#endif 327#endif
326 328
327 _grey_rb = newrb; 329 _grey_rb = newrb;
@@ -343,35 +345,41 @@ bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
343#endif 345#endif
344#endif 346#endif
345 347
346 /* the buffer has to be long aligned */
347 buftaken = (-(long)gbuf) & 3;
348 gbuf += buftaken;
349
350 plane_size = _GREY_MULUQ(width, height); 348 plane_size = _GREY_MULUQ(width, height);
349#ifdef CPU_COLDFIRE
350 plane_size += (-plane_size) & 0xf; /* All buffers should be line aligned */
351 buftaken = (-(long)gbuf) & 0xf;
352#else
353 buftaken = (-(long)gbuf) & 3; /* All buffers must be long aligned. */
354#endif
355 gbuf += buftaken;
351 356
352 if (buffered) /* chunky buffer */ 357 if (buffered) /* chunky buffer */
353 { 358 {
354 buftaken += plane_size;
355 _grey_info.buffer = gbuf; 359 _grey_info.buffer = gbuf;
356 gbuf += plane_size; 360 gbuf += plane_size;
361 buftaken += plane_size;
357 } 362 }
358 buftaken += sizeof(struct grey_data) * plane_size;
359 if (buftaken > gbuf_size)
360 return false;
361
362#ifdef SIMULATOR 363#ifdef SIMULATOR
363 _grey_info.buffer = gbuf; 364 _grey_info.buffer = gbuf;
364#else 365#else
365 grey_data = (struct grey_data *)gbuf; 366 _grey_info.values = gbuf;
366 grey_end = grey_data + plane_size; 367 gbuf += plane_size;
367 _grey_info.data = grey_data; 368 _grey_info.phases = gbuf;
369#endif
370 buftaken += 2 * plane_size;
368 371
369 while (grey_data < grey_end) 372 if (buftaken > gbuf_size)
370 { 373 return false;
371 grey_data->phase = _grey_rb->rand() & 0xff; 374
372 grey_data->value = 128; /* init to white */ 375#ifndef SIMULATOR
373 grey_data++; 376 _grey_rb->memset(_grey_info.values, 0x80, plane_size);
374 } 377 dst = (unsigned*)(_grey_info.phases);
378 end = (unsigned*)(_grey_info.phases + plane_size);
379
380 do
381 *dst++ = _grey_rb->rand();
382 while (dst < end);
375#endif 383#endif
376 384
377 _grey_info.x = 0; 385 _grey_info.x = 0;
@@ -393,8 +401,7 @@ bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
393 _grey_info.drawmode = DRMODE_SOLID; 401 _grey_info.drawmode = DRMODE_SOLID;
394 _grey_info.curfont = FONT_SYSFIXED; 402 _grey_info.curfont = FONT_SYSFIXED;
395 403
396 404 /* precalculate the value -> pattern index conversion table, taking
397 /* precalculate the value -> pattern index conversion table, taking
398 linearisation and gamma correction into account */ 405 linearisation and gamma correction into account */
399 for (i = 0; i < 256; i++) 406 for (i = 0; i < 256; i++)
400 { 407 {
@@ -532,7 +539,7 @@ void grey_update_rect(int x, int y, int width, int height)
532 int idx = _GREY_MULUQ(_grey_info.width, y & ~3) + (x << 2) + (~y & 3); 539 int idx = _GREY_MULUQ(_grey_info.width, y & ~3) + (x << 2) + (~y & 3);
533#endif 540#endif
534#endif /* LCD_PIXELFORMAT */ 541#endif /* LCD_PIXELFORMAT */
535 unsigned char *dst_row = &_grey_info.data[idx].value; 542 unsigned char *dst_row = _grey_info.values + idx;
536 unsigned char *src_row = src; 543 unsigned char *src_row = src;
537 unsigned char *src_end = src + width; 544 unsigned char *src_end = src + width;
538 545
@@ -684,8 +691,8 @@ static void grey_screendump_hook(int fd)
684 for (i = 0; i < 4; i++) 691 for (i = 0; i < 4; i++)
685 linebuf[x + i] = BMP_FIXEDCOLORS + *src++; 692 linebuf[x + i] = BMP_FIXEDCOLORS + *src++;
686#else 693#else
687 unsigned char *src = &_grey_info.data[_GREY_MULUQ(_grey_info.width, 694 unsigned char *src = _grey_info.values
688 gy) + gx].value; 695 + _GREY_MULUQ(_grey_info.width, gy) + gx;
689 for (i = 0; i < 4; i++) 696 for (i = 0; i < 4; i++)
690 { 697 {
691 linebuf[x + i] = BMP_FIXEDCOLORS + *src; 698 linebuf[x + i] = BMP_FIXEDCOLORS + *src;
@@ -722,8 +729,8 @@ static void grey_screendump_hook(int fd)
722 gy) + gx]; 729 gy) + gx];
723#else 730#else
724 linebuf[x] = BMP_FIXEDCOLORS 731 linebuf[x] = BMP_FIXEDCOLORS
725 + _grey_info.data[_GREY_MULUQ(_grey_info.width, 732 + _grey_info.values[_GREY_MULUQ(_grey_info.width,
726 gy & ~7) + (gx << 3) + (~gy & 7)].value; 733 gy & ~7) + (gx << 3) + (~gy & 7)];
727#endif 734#endif
728 } 735 }
729 else 736 else
@@ -749,8 +756,8 @@ static void grey_screendump_hook(int fd)
749 gy) + gx]; 756 gy) + gx];
750#else 757#else
751 linebuf[x] = BMP_FIXEDCOLORS 758 linebuf[x] = BMP_FIXEDCOLORS
752 + _grey_info.data[_GREY_MULUQ(_grey_info.width, 759 + _grey_info.values[_GREY_MULUQ(_grey_info.width,
753 gy & ~3) + (gx << 2) + (~gy & 7)].value; 760 gy & ~3) + (gx << 2) + (~gy & 3)];
754#endif 761#endif
755 } 762 }
756 else 763 else
diff --git a/apps/plugins/lib/grey_draw.c b/apps/plugins/lib/grey_draw.c
index e243b5fbce..ccb8deae7b 100644
--- a/apps/plugins/lib/grey_draw.c
+++ b/apps/plugins/lib/grey_draw.c
@@ -601,17 +601,10 @@ void grey_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
601void grey_ub_clear_display(void) 601void grey_ub_clear_display(void)
602{ 602{
603 int value = (_grey_info.drawmode & DRMODE_INVERSEVID) ? 603 int value = (_grey_info.drawmode & DRMODE_INVERSEVID) ?
604 _grey_info.fg_val : _grey_info.bg_val; 604 _grey_info.fg_val : _grey_info.bg_val;
605 unsigned char *dst = &_grey_info.data[0].value; 605
606 unsigned char *dst_end = dst + sizeof(struct grey_data) 606 _grey_rb->memset(_grey_info.values, value,
607 * _GREY_MULUQ(_grey_info.width, _grey_info.height); 607 _GREY_MULUQ(_grey_info.width, _grey_info.height));
608
609 do
610 {
611 *dst = value;
612 dst += sizeof(struct grey_data);
613 }
614 while (dst < dst_end);
615} 608}
616 609
617/* Draw a partial greyscale bitmap, canonical format */ 610/* Draw a partial greyscale bitmap, canonical format */
@@ -654,7 +647,7 @@ void grey_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
654 int idx = _GREY_MULUQ(_grey_info.width, y & ~3) + (x << 2) + (~y & 3); 647 int idx = _GREY_MULUQ(_grey_info.width, y & ~3) + (x << 2) + (~y & 3);
655#endif 648#endif
656#endif /* LCD_PIXELFORMAT */ 649#endif /* LCD_PIXELFORMAT */
657 unsigned char *dst_row = &_grey_info.data[idx].value; 650 unsigned char *dst_row = _grey_info.values + idx;
658 const unsigned char *src_row = src; 651 const unsigned char *src_row = src;
659 const unsigned char *src_end = src + width; 652 const unsigned char *src_end = src + width;
660 653
diff --git a/apps/plugins/lib/grey_scroll.c b/apps/plugins/lib/grey_scroll.c
index 80496e7706..4a18d7d29e 100644
--- a/apps/plugins/lib/grey_scroll.c
+++ b/apps/plugins/lib/grey_scroll.c
@@ -169,7 +169,7 @@ void grey_ub_scroll_left(int count)
169 idx = _GREY_MULUQ(_grey_info.width, y & ~3) + (~y & 3); 169 idx = _GREY_MULUQ(_grey_info.width, y & ~3) + (~y & 3);
170#endif 170#endif
171#endif /* LCD_PIXELFORMAT */ 171#endif /* LCD_PIXELFORMAT */
172 dst = &_grey_info.data[idx].value; 172 dst = _grey_info.values + idx;
173 src = dst + count * _GREY_X_ADVANCE; 173 src = dst + count * _GREY_X_ADVANCE;
174 end = dst + _grey_info.width * _GREY_X_ADVANCE; 174 end = dst + _grey_info.width * _GREY_X_ADVANCE;
175 175
@@ -213,7 +213,7 @@ void grey_ub_scroll_right(int count)
213 idx = _GREY_MULUQ(_grey_info.width, y & ~3) + (~y & 3); 213 idx = _GREY_MULUQ(_grey_info.width, y & ~3) + (~y & 3);
214#endif 214#endif
215#endif /* LCD_PIXELFORMAT */ 215#endif /* LCD_PIXELFORMAT */
216 start = &_grey_info.data[idx].value; 216 start = _grey_info.values + idx;
217 dst = start + _grey_info.width * _GREY_X_ADVANCE; 217 dst = start + _grey_info.width * _GREY_X_ADVANCE;
218 src = dst - count * _GREY_X_ADVANCE; 218 src = dst - count * _GREY_X_ADVANCE;
219 219
@@ -259,8 +259,8 @@ void grey_ub_scroll_up(int count)
259 is = _GREY_MULUQ(_grey_info.width, ys & ~3) + (~ys & 3); 259 is = _GREY_MULUQ(_grey_info.width, ys & ~3) + (~ys & 3);
260#endif 260#endif
261#endif /* LCD_PIXELFORMAT */ 261#endif /* LCD_PIXELFORMAT */
262 dst = &_grey_info.data[id].value; 262 dst = _grey_info.values + id;
263 src = &_grey_info.data[is].value; 263 src = _grey_info.values + is;
264 dst_end = dst + _grey_info.width * _GREY_X_ADVANCE; 264 dst_end = dst + _grey_info.width * _GREY_X_ADVANCE;
265 265
266 do 266 do
@@ -282,7 +282,7 @@ void grey_ub_scroll_up(int count)
282 id = _GREY_MULUQ(_grey_info.width, yd & ~3) + (~yd & 3); 282 id = _GREY_MULUQ(_grey_info.width, yd & ~3) + (~yd & 3);
283#endif 283#endif
284#endif /* LCD_PIXELFORMAT */ 284#endif /* LCD_PIXELFORMAT */
285 dst = &_grey_info.data[id].value; 285 dst = _grey_info.values + id;
286 dst_end = dst + _grey_info.width * _GREY_X_ADVANCE; 286 dst_end = dst + _grey_info.width * _GREY_X_ADVANCE;
287 287
288 do 288 do
@@ -320,8 +320,8 @@ void grey_ub_scroll_down(int count)
320 is = _GREY_MULUQ(_grey_info.width, ys & ~3) + (~ys & 3); 320 is = _GREY_MULUQ(_grey_info.width, ys & ~3) + (~ys & 3);
321#endif 321#endif
322#endif /* LCD_PIXELFORMAT */ 322#endif /* LCD_PIXELFORMAT */
323 dst = &_grey_info.data[id].value; 323 dst = _grey_info.values + id;
324 src = &_grey_info.data[is].value; 324 src = _grey_info.values + is;
325 dst_end = dst + _grey_info.width * _GREY_X_ADVANCE; 325 dst_end = dst + _grey_info.width * _GREY_X_ADVANCE;
326 326
327 do 327 do
@@ -343,7 +343,7 @@ void grey_ub_scroll_down(int count)
343 id = _GREY_MULUQ(_grey_info.width, yd & ~3) + (~yd & 3); 343 id = _GREY_MULUQ(_grey_info.width, yd & ~3) + (~yd & 3);
344#endif 344#endif
345#endif /* LCD_PIXELFORMAT */ 345#endif /* LCD_PIXELFORMAT */
346 dst = &_grey_info.data[id].value; 346 dst = _grey_info.values + id;
347 dst_end = dst + _grey_info.width * _GREY_X_ADVANCE; 347 dst_end = dst + _grey_info.width * _GREY_X_ADVANCE;
348 348
349 do 349 do