diff options
Diffstat (limited to 'apps/plugins/lib')
| -rw-r--r-- | apps/plugins/lib/grey.h | 9 | ||||
| -rw-r--r-- | apps/plugins/lib/grey_core.c | 69 | ||||
| -rw-r--r-- | apps/plugins/lib/grey_draw.c | 17 | ||||
| -rw-r--r-- | apps/plugins/lib/grey_scroll.c | 16 |
4 files changed, 56 insertions, 55 deletions
diff --git a/apps/plugins/lib/grey.h b/apps/plugins/lib/grey.h index 136794b..9a3bd7d 100644 --- a/apps/plugins/lib/grey.h +++ b/apps/plugins/lib/grey.h @@ -121,12 +121,12 @@ void grey_ub_scroll_down(int count); #endif #if LCD_PIXELFORMAT == HORIZONTAL_PACKING -#define _GREY_X_ADVANCE sizeof(struct grey_data) +#define _GREY_X_ADVANCE 1 #else #if LCD_DEPTH == 1 -#define _GREY_X_ADVANCE (8*sizeof(struct grey_data)) +#define _GREY_X_ADVANCE 8 #elif LCD_DEPTH == 2 -#define _GREY_X_ADVANCE (4*sizeof(struct grey_data)) +#define _GREY_X_ADVANCE 4 #endif #endif /* LCD_PIXELFORMAT */ @@ -146,7 +146,8 @@ struct _grey_info #endif unsigned long flags; /* various flags, see #defines */ #ifndef SIMULATOR - struct grey_data *data; /* start of greyscale display data */ + unsigned char *values; /* start of greyscale pixel values */ + unsigned char *phases; /* start of greyscale pixel phases */ #endif unsigned char *buffer; /* start of chunky pixel buffer (for buffered mode) */ 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 b3ab640..43eed9b 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) static void _timer_isr(void) { #if LCD_PIXELFORMAT == HORIZONTAL_PACKING - _grey_rb->lcd_grey_phase_blit(_grey_info.data, _grey_info.bx, _grey_info.y, + _grey_rb->lcd_grey_phase_blit(_grey_info.values, _grey_info.phases, + _grey_info.bx, _grey_info.y, _grey_info.bwidth, _grey_info.height, _grey_info.width); #else - _grey_rb->lcd_grey_phase_blit(_grey_info.data, _grey_info.x, _grey_info.by, + _grey_rb->lcd_grey_phase_blit(_grey_info.values, _grey_info.phases, + _grey_info.x, _grey_info.by, _grey_info.width, _grey_info.bheight, _grey_info.width); #endif @@ -321,7 +323,7 @@ bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, long plane_size, buftaken; unsigned data; #ifndef SIMULATOR - struct grey_data *grey_data, *grey_end; + unsigned *dst, *end; #endif _grey_rb = newrb; @@ -343,35 +345,41 @@ bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, #endif #endif - /* the buffer has to be long aligned */ - buftaken = (-(long)gbuf) & 3; - gbuf += buftaken; - plane_size = _GREY_MULUQ(width, height); +#ifdef CPU_COLDFIRE + plane_size += (-plane_size) & 0xf; /* All buffers should be line aligned */ + buftaken = (-(long)gbuf) & 0xf; +#else + buftaken = (-(long)gbuf) & 3; /* All buffers must be long aligned. */ +#endif + gbuf += buftaken; if (buffered) /* chunky buffer */ { - buftaken += plane_size; _grey_info.buffer = gbuf; - gbuf += plane_size; + gbuf += plane_size; + buftaken += plane_size; } - buftaken += sizeof(struct grey_data) * plane_size; - if (buftaken > gbuf_size) - return false; - #ifdef SIMULATOR _grey_info.buffer = gbuf; #else - grey_data = (struct grey_data *)gbuf; - grey_end = grey_data + plane_size; - _grey_info.data = grey_data; + _grey_info.values = gbuf; + gbuf += plane_size; + _grey_info.phases = gbuf; +#endif + buftaken += 2 * plane_size; - while (grey_data < grey_end) - { - grey_data->phase = _grey_rb->rand() & 0xff; - grey_data->value = 128; /* init to white */ - grey_data++; - } + if (buftaken > gbuf_size) + return false; + +#ifndef SIMULATOR + _grey_rb->memset(_grey_info.values, 0x80, plane_size); + dst = (unsigned*)(_grey_info.phases); + end = (unsigned*)(_grey_info.phases + plane_size); + + do + *dst++ = _grey_rb->rand(); + while (dst < end); #endif _grey_info.x = 0; @@ -393,8 +401,7 @@ bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, _grey_info.drawmode = DRMODE_SOLID; _grey_info.curfont = FONT_SYSFIXED; - - /* precalculate the value -> pattern index conversion table, taking + /* precalculate the value -> pattern index conversion table, taking linearisation and gamma correction into account */ for (i = 0; i < 256; i++) { @@ -532,7 +539,7 @@ void grey_update_rect(int x, int y, int width, int height) int idx = _GREY_MULUQ(_grey_info.width, y & ~3) + (x << 2) + (~y & 3); #endif #endif /* LCD_PIXELFORMAT */ - unsigned char *dst_row = &_grey_info.data[idx].value; + unsigned char *dst_row = _grey_info.values + idx; unsigned char *src_row = src; unsigned char *src_end = src + width; @@ -684,8 +691,8 @@ static void grey_screendump_hook(int fd) for (i = 0; i < 4; i++) linebuf[x + i] = BMP_FIXEDCOLORS + *src++; #else - unsigned char *src = &_grey_info.data[_GREY_MULUQ(_grey_info.width, - gy) + gx].value; + unsigned char *src = _grey_info.values + + _GREY_MULUQ(_grey_info.width, gy) + gx; for (i = 0; i < 4; i++) { linebuf[x + i] = BMP_FIXEDCOLORS + *src; @@ -722,8 +729,8 @@ static void grey_screendump_hook(int fd) gy) + gx]; #else linebuf[x] = BMP_FIXEDCOLORS - + _grey_info.data[_GREY_MULUQ(_grey_info.width, - gy & ~7) + (gx << 3) + (~gy & 7)].value; + + _grey_info.values[_GREY_MULUQ(_grey_info.width, + gy & ~7) + (gx << 3) + (~gy & 7)]; #endif } else @@ -749,8 +756,8 @@ static void grey_screendump_hook(int fd) gy) + gx]; #else linebuf[x] = BMP_FIXEDCOLORS - + _grey_info.data[_GREY_MULUQ(_grey_info.width, - gy & ~3) + (gx << 2) + (~gy & 7)].value; + + _grey_info.values[_GREY_MULUQ(_grey_info.width, + gy & ~3) + (gx << 2) + (~gy & 3)]; #endif } else diff --git a/apps/plugins/lib/grey_draw.c b/apps/plugins/lib/grey_draw.c index e243b5f..ccb8dea 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, void grey_ub_clear_display(void) { int value = (_grey_info.drawmode & DRMODE_INVERSEVID) ? - _grey_info.fg_val : _grey_info.bg_val; - unsigned char *dst = &_grey_info.data[0].value; - unsigned char *dst_end = dst + sizeof(struct grey_data) - * _GREY_MULUQ(_grey_info.width, _grey_info.height); - - do - { - *dst = value; - dst += sizeof(struct grey_data); - } - while (dst < dst_end); + _grey_info.fg_val : _grey_info.bg_val; + + _grey_rb->memset(_grey_info.values, value, + _GREY_MULUQ(_grey_info.width, _grey_info.height)); } /* 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, int idx = _GREY_MULUQ(_grey_info.width, y & ~3) + (x << 2) + (~y & 3); #endif #endif /* LCD_PIXELFORMAT */ - unsigned char *dst_row = &_grey_info.data[idx].value; + unsigned char *dst_row = _grey_info.values + idx; const unsigned char *src_row = src; const unsigned char *src_end = src + width; diff --git a/apps/plugins/lib/grey_scroll.c b/apps/plugins/lib/grey_scroll.c index 80496e7..4a18d7d 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) idx = _GREY_MULUQ(_grey_info.width, y & ~3) + (~y & 3); #endif #endif /* LCD_PIXELFORMAT */ - dst = &_grey_info.data[idx].value; + dst = _grey_info.values + idx; src = dst + count * _GREY_X_ADVANCE; end = dst + _grey_info.width * _GREY_X_ADVANCE; @@ -213,7 +213,7 @@ void grey_ub_scroll_right(int count) idx = _GREY_MULUQ(_grey_info.width, y & ~3) + (~y & 3); #endif #endif /* LCD_PIXELFORMAT */ - start = &_grey_info.data[idx].value; + start = _grey_info.values + idx; dst = start + _grey_info.width * _GREY_X_ADVANCE; src = dst - count * _GREY_X_ADVANCE; @@ -259,8 +259,8 @@ void grey_ub_scroll_up(int count) is = _GREY_MULUQ(_grey_info.width, ys & ~3) + (~ys & 3); #endif #endif /* LCD_PIXELFORMAT */ - dst = &_grey_info.data[id].value; - src = &_grey_info.data[is].value; + dst = _grey_info.values + id; + src = _grey_info.values + is; dst_end = dst + _grey_info.width * _GREY_X_ADVANCE; do @@ -282,7 +282,7 @@ void grey_ub_scroll_up(int count) id = _GREY_MULUQ(_grey_info.width, yd & ~3) + (~yd & 3); #endif #endif /* LCD_PIXELFORMAT */ - dst = &_grey_info.data[id].value; + dst = _grey_info.values + id; dst_end = dst + _grey_info.width * _GREY_X_ADVANCE; do @@ -320,8 +320,8 @@ void grey_ub_scroll_down(int count) is = _GREY_MULUQ(_grey_info.width, ys & ~3) + (~ys & 3); #endif #endif /* LCD_PIXELFORMAT */ - dst = &_grey_info.data[id].value; - src = &_grey_info.data[is].value; + dst = _grey_info.values + id; + src = _grey_info.values + is; dst_end = dst + _grey_info.width * _GREY_X_ADVANCE; do @@ -343,7 +343,7 @@ void grey_ub_scroll_down(int count) id = _GREY_MULUQ(_grey_info.width, yd & ~3) + (~yd & 3); #endif #endif /* LCD_PIXELFORMAT */ - dst = &_grey_info.data[id].value; + dst = _grey_info.values + id; dst_end = dst + _grey_info.width * _GREY_X_ADVANCE; do |