diff options
Diffstat (limited to 'apps/plugins/lib/grey_core.c')
-rw-r--r-- | apps/plugins/lib/grey_core.c | 69 |
1 files changed, 38 insertions, 31 deletions
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) | |||
222 | static void _timer_isr(void) | 222 | static 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 |