From 6a972e02497d3015236189f72931c3d59fa51755 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Sun, 26 Feb 2006 13:37:42 +0000 Subject: Finally - grayscale library support for the simulators. Currently SDL only, win32 and x11 won't link anymore due to missing simulator functions. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8845 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugin.c | 6 ++ apps/plugin.h | 6 +- apps/plugins/brickmania.c | 1 - apps/plugins/cube.c | 2 +- apps/plugins/fire.c | 2 - apps/plugins/grayscale.c | 2 - apps/plugins/jpeg.c | 4 +- apps/plugins/lib/SOURCES | 3 +- apps/plugins/lib/gray.h | 18 ++-- apps/plugins/lib/gray_core.c | 206 ++++++++++++++++++++++++++++++----------- apps/plugins/lib/gray_draw.c | 32 +++++-- apps/plugins/lib/gray_parm.c | 18 ++-- apps/plugins/lib/gray_scroll.c | 43 +++++++-- apps/plugins/mandelbrot.c | 2 +- apps/plugins/plasma.c | 4 +- 15 files changed, 255 insertions(+), 94 deletions(-) (limited to 'apps') diff --git a/apps/plugin.c b/apps/plugin.c index 61396b4357..2bf6aa772d 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -72,6 +72,8 @@ static unsigned char pluginbuf[PLUGIN_BUFFER_SIZE]; void *sim_plugin_load(char *plugin, int *fd); void sim_plugin_close(int fd); +void sim_lcd_ex_init(int shades, unsigned long (*getpixel)(int, int)); +void sim_lcd_ex_update_rect(int x, int y, int width, int height); #else #define sim_plugin_close(x) extern unsigned char pluginbuf[]; @@ -401,6 +403,10 @@ static const struct plugin_api rockbox_api = { /* new stuff at the end, sort into place next time the API gets incompatible */ tree_get_context, +#if defined(SIMULATOR) && defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8 + sim_lcd_ex_init, + sim_lcd_ex_update_rect, +#endif }; int plugin_load(const char* plugin, void* parameter) diff --git a/apps/plugin.h b/apps/plugin.h index 7c35902248..6d96d36dc1 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -98,7 +98,7 @@ #define PLUGIN_MAGIC 0x526F634B /* RocK */ /* increase this every time the api struct changes */ -#define PLUGIN_API_VERSION 8 +#define PLUGIN_API_VERSION 9 /* update this to latest version if a change to the api struct breaks backwards compatibility (and please take the opportunity to sort in any @@ -469,6 +469,10 @@ struct plugin_api { the API gets incompatible */ struct tree_context* (*tree_get_context)(void); +#if defined(SIMULATOR) && defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8 + void (*sim_lcd_ex_init)(int shades, unsigned long (*getpixel)(int, int)); + void (*sim_lcd_ex_update_rect)(int x, int y, int width, int height); +#endif }; diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c index a21ba7ae5c..2b2671d6be 100644 --- a/apps/plugins/brickmania.c +++ b/apps/plugins/brickmania.c @@ -18,7 +18,6 @@ ****************************************************************************/ #include "plugin.h" -#include "gray.h" #include "configfile.h" /* Part of libplugin */ PLUGIN_HEADER diff --git a/apps/plugins/cube.c b/apps/plugins/cube.c index cbe32d14d0..854b190797 100644 --- a/apps/plugins/cube.c +++ b/apps/plugins/cube.c @@ -142,7 +142,7 @@ PLUGIN_HEADER static int x_off = LCD_WIDTH/2; static int y_off = LCD_HEIGHT/2; -#if LCD_DEPTH == 1 && !defined(SIMULATOR) +#if LCD_DEPTH == 1 #define USE_GSLIB struct my_lcd { void (*update)(void); diff --git a/apps/plugins/fire.c b/apps/plugins/fire.c index 859ba598b2..5bcf909108 100644 --- a/apps/plugins/fire.c +++ b/apps/plugins/fire.c @@ -19,7 +19,6 @@ * ****************************************************************************/ -#ifndef SIMULATOR /* not for simulator (grayscale) */ #include "plugin.h" #ifdef HAVE_LCD_BITMAP /* and also not for the Player */ @@ -305,4 +304,3 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) } #endif // #ifdef HAVE_LCD_BITMAP -#endif // #ifndef SIMULATOR diff --git a/apps/plugins/grayscale.c b/apps/plugins/grayscale.c index ff94e6ae8c..4ca2ba09b3 100644 --- a/apps/plugins/grayscale.c +++ b/apps/plugins/grayscale.c @@ -19,7 +19,6 @@ * ****************************************************************************/ -#ifndef SIMULATOR /* not for simulator by now */ #include "plugin.h" #if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) && (CONFIG_LCD != LCD_IPOD2BPP) @@ -336,5 +335,4 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) } #endif // #ifdef HAVE_LCD_BITMAP -#endif // #ifndef SIMULATOR diff --git a/apps/plugins/jpeg.c b/apps/plugins/jpeg.c index ce27d7da3f..a39e6dc933 100644 --- a/apps/plugins/jpeg.c +++ b/apps/plugins/jpeg.c @@ -26,7 +26,7 @@ #include "plugin.h" -#if defined(HAVE_LCD_BITMAP) && ((LCD_DEPTH >= 8) || !defined(SIMULATOR)) +#ifdef HAVE_LCD_BITMAP #include "gray.h" #include "xlcd.h" @@ -2713,4 +2713,4 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) return condition; } -#endif /* HAVE_LCD_BITMAP && ((LCD_DEPTH >= 8) || !defined(SIMULATOR))*/ +#endif /* HAVE_LCD_BITMAP */ diff --git a/apps/plugins/lib/SOURCES b/apps/plugins/lib/SOURCES index 291bc21a1d..6bcddbab96 100644 --- a/apps/plugins/lib/SOURCES +++ b/apps/plugins/lib/SOURCES @@ -1,6 +1,5 @@ configfile.c -#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) && !defined(SIMULATOR) && \ - (CONFIG_LCD != LCD_IPOD2BPP) +#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) && (CONFIG_LCD != LCD_IPOD2BPP) gray_core.c gray_draw.c gray_parm.c diff --git a/apps/plugins/lib/gray.h b/apps/plugins/lib/gray.h index 7092b84958..96dec346cf 100644 --- a/apps/plugins/lib/gray.h +++ b/apps/plugins/lib/gray.h @@ -9,10 +9,10 @@ * * Greyscale framework * -* This is a generic framework to use greyscale display within Rockbox -* plugins. It does not work for the player. +* This is a generic framework to display up to 33 shades of grey +* on low-depth bitmap LCDs (Archos b&w, Iriver 4-grey) within plugins. * -* Copyright (C) 2004-2005 Jens Arnold +* Copyright (C) 2004-2006 Jens Arnold * * All files in this archive are subject to the GNU General Public License. * See the file COPYING in the source tree root for full license agreement. @@ -25,7 +25,6 @@ #ifndef __GRAY_H__ #define __GRAY_H__ -#ifndef SIMULATOR /* not for simulator by now */ #include "plugin.h" #ifdef HAVE_LCD_BITMAP /* and also not for the Player */ @@ -129,17 +128,19 @@ struct _gray_info int height; int bheight; /* 8-pixel units */ int depth; /* number_of_bitplanes = (number_of_grayscales - 1) */ + unsigned long flags; /* various flags, see #defines */ +#ifndef SIMULATOR int cur_plane; /* for the timer isr */ - int drawmode; /* current draw mode */ - int fg_brightness; /* current foreground brightness */ - int bg_brightness; /* current background brightness */ long plane_size; - unsigned long flags; /* various flags, see #defines */ unsigned long randmask; /* mask for random value in _writepixel() */ unsigned long *bitpattern; /* start of pattern table */ unsigned char *plane_data; /* start of bitplane data */ +#endif unsigned char *cur_buffer; /* start of current chunky pixel buffer */ unsigned char *back_buffer;/* start of chunky pixel back buffer */ + int drawmode; /* current draw mode */ + int fg_brightness; /* current foreground brightness */ + int bg_brightness; /* current background brightness */ int curfont; /* current selected font */ }; @@ -149,5 +150,4 @@ extern struct _gray_info _gray_info; extern short _gray_random_buffer; #endif /* HAVE_LCD_BITMAP */ -#endif /* !SIMULATOR */ #endif /* __GRAY_H__ */ diff --git a/apps/plugins/lib/gray_core.c b/apps/plugins/lib/gray_core.c index d151250e69..80ce984b29 100644 --- a/apps/plugins/lib/gray_core.c +++ b/apps/plugins/lib/gray_core.c @@ -10,10 +10,10 @@ * Greyscale framework * Core & miscellaneous functions * -* This is a generic framework to use grayscale display within Rockbox -* plugins. It obviously does not work for the player. +* This is a generic framework to display up to 33 shades of grey +* on low-depth bitmap LCDs (Archos b&w, Iriver 4-grey) within plugins. * -* Copyright (C) 2004-2005 Jens Arnold +* Copyright (C) 2004-2006 Jens Arnold * * All files in this archive are subject to the GNU General Public License. * See the file COPYING in the source tree root for full license agreement. @@ -23,21 +23,49 @@ * ****************************************************************************/ -#ifndef SIMULATOR /* not for simulator by now */ #include "plugin.h" -#ifdef HAVE_LCD_BITMAP /* and also not for the Player */ +#ifdef HAVE_LCD_BITMAP #include "gray.h" /* Global variables */ struct plugin_api *_gray_rb = NULL; /* global api struct pointer */ struct _gray_info _gray_info; /* global info structure */ +#ifndef SIMULATOR short _gray_random_buffer; /* buffer for random number generator */ +#endif /* Prototypes */ +static inline void _deferred_update(void) __attribute__ ((always_inline)); +#ifdef SIMULATOR +static unsigned long _gray_get_pixel(int x, int y); +#else static void _timer_isr(void); +#endif static void gray_screendump_hook(int fd); +/* Update LCD areas not covered by the greyscale overlay */ +static inline void _deferred_update(void) +{ + int x1 = MAX(_gray_info.x, 0); + int x2 = MIN(_gray_info.x + _gray_info.width, LCD_WIDTH); + int y1 = MAX(_gray_info.by << _PBLOCK_EXP, 0); + int y2 = MIN((_gray_info.by << _PBLOCK_EXP) + _gray_info.height, LCD_HEIGHT); + + if (y1 > 0) /* refresh part above overlay, full width */ + _gray_rb->lcd_update_rect(0, 0, LCD_WIDTH, y1); + + if (y2 < LCD_HEIGHT) /* refresh part below overlay, full width */ + _gray_rb->lcd_update_rect(0, y2, LCD_WIDTH, LCD_HEIGHT - y2); + + if (x1 > 0) /* refresh part to the left of overlay */ + _gray_rb->lcd_update_rect(0, y1, x1, y2 - y1); + + if (x2 < LCD_WIDTH) /* refresh part to the right of overlay */ + _gray_rb->lcd_update_rect(x2, y1, LCD_WIDTH - x2, y2 - y1); +} + +#ifndef SIMULATOR /* Timer interrupt handler: display next bitplane */ static void _timer_isr(void) { @@ -50,26 +78,11 @@ static void _timer_isr(void) if (_gray_info.flags & _GRAY_DEFERRED_UPDATE) /* lcd_update() requested? */ { - int x1 = MAX(_gray_info.x, 0); - int x2 = MIN(_gray_info.x + _gray_info.width, LCD_WIDTH); - int y1 = MAX(_gray_info.by << _PBLOCK_EXP, 0); - int y2 = MIN((_gray_info.by << _PBLOCK_EXP) + _gray_info.height, LCD_HEIGHT); - - if (y1 > 0) /* refresh part above overlay, full width */ - _gray_rb->lcd_update_rect(0, 0, LCD_WIDTH, y1); - - if (y2 < LCD_HEIGHT) /* refresh part below overlay, full width */ - _gray_rb->lcd_update_rect(0, y2, LCD_WIDTH, LCD_HEIGHT - y2); - - if (x1 > 0) /* refresh part to the left of overlay */ - _gray_rb->lcd_update_rect(0, y1, x1, y2 - y1); - - if (x2 < LCD_WIDTH) /* refresh part to the right of overlay */ - _gray_rb->lcd_update_rect(x2, y1, LCD_WIDTH - x2, y2 - y1); - + _deferred_update(); _gray_info.flags &= ~_GRAY_DEFERRED_UPDATE; /* clear request */ } } +#endif /* !SIMULATOR */ /* Initialise the framework and prepare the greyscale display buffer @@ -108,13 +121,21 @@ static void _timer_isr(void) + (width * bheight) * depth (bitplane data) + buffered ? (chunky front- & backbuffer) (width * bheight * 8 * 2) : 0 - + 0..3 (longword alignment) */ + + 0..3 (longword alignment) + + The function tries to be as authentic as possible regarding memory usage on + the simulator, even if it doesn't use all of the allocated memory. There's + one situation where it will consume more memory on the sim than on the + target: if you're allocating a low depth (< 8) without buffering. */ int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, bool buffered, int width, int bheight, int depth, long *buf_taken) { - int possible_depth, i, j; + int possible_depth; long plane_size, buftaken; - +#ifndef SIMULATOR + int i, j; +#endif + _gray_rb = newrb; if ((unsigned) width > LCD_WIDTH @@ -152,19 +173,41 @@ int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, depth = MIN(depth, 32); depth = MIN(depth, possible_depth); +#ifdef SIMULATOR + if (!buffered) + { + long orig_size = depth * plane_size + (depth + 1) * sizeof(long); + + plane_size = MULU16(width, bheight << _PBLOCK_EXP); + if (plane_size > orig_size) + { + buftaken += plane_size; + if (buftaken > gbuf_size) + return 0; + } + else + { + buftaken += orig_size; + } + _gray_info.cur_buffer = gbuf; + } + else +#endif + buftaken += depth * plane_size + (depth + 1) * sizeof(long); + _gray_info.x = 0; _gray_info.by = 0; _gray_info.width = width; _gray_info.height = bheight << _PBLOCK_EXP; _gray_info.bheight = bheight; - _gray_info.plane_size = plane_size; _gray_info.depth = depth; - _gray_info.cur_plane = 0; _gray_info.flags = 0; +#ifndef SIMULATOR + _gray_info.cur_plane = 0; + _gray_info.plane_size = plane_size; _gray_info.plane_data = gbuf; gbuf += depth * plane_size; _gray_info.bitpattern = (unsigned long *)gbuf; - buftaken += depth * plane_size + (depth + 1) * sizeof(long); i = depth - 1; j = 8; @@ -195,6 +238,7 @@ int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, _gray_info.bitpattern[i] = pattern; } +#endif _gray_info.fg_brightness = 0; _gray_info.bg_brightness = depth; @@ -229,6 +273,10 @@ void gray_show(bool enable) if (enable && !(_gray_info.flags & _GRAY_RUNNING)) { _gray_info.flags |= _GRAY_RUNNING; +#ifdef SIMULATOR + _gray_rb->sim_lcd_ex_init(_gray_info.depth + 1, _gray_get_pixel); + gray_update(); +#else /* !SIMULATOR */ #if CONFIG_LCD == LCD_SSD1815 _gray_rb->timer_register(1, NULL, CPU_FREQ / 67, 1, _timer_isr); #elif CONFIG_LCD == LCD_S1D15E06 @@ -236,18 +284,53 @@ void gray_show(bool enable) #elif CONFIG_LCD == LCD_IFP7XX /* TODO: implement for iFP */ (void)_timer_isr; -#endif +#endif /* CONFIG_LCD */ +#endif /* !SIMULATOR */ _gray_rb->screen_dump_set_hook(gray_screendump_hook); } else if (!enable && (_gray_info.flags & _GRAY_RUNNING)) { +#ifdef SIMULATOR + _gray_rb->sim_lcd_ex_init(0, NULL); +#else _gray_rb->timer_unregister(); +#endif _gray_info.flags &= ~_GRAY_RUNNING; _gray_rb->screen_dump_set_hook(NULL); _gray_rb->lcd_update(); /* restore whatever there was before */ } } +#ifdef SIMULATOR +/* Callback function for gray_update_rect() to read a pixel from the graybuffer. + Note that x and y are in LCD coordinates, not graybuffer coordinates! */ +static unsigned long _gray_get_pixel(int x, int y) +{ + return _gray_info.cur_buffer[MULU16(x - _gray_info.x, _gray_info.height) + + y - (_gray_info.by << _PBLOCK_EXP)] + + (1 << LCD_DEPTH); +} + +/* Update a rectangular area of the greyscale overlay */ +void gray_update_rect(int x, int y, int width, int height) +{ + if (x + width > _gray_info.width) + width = _gray_info.width - x; + if (y + height > _gray_info.height) + height = _gray_info.height - y; + + x += _gray_info.x; + y += _gray_info.by << _PBLOCK_EXP; + + if (x + width > LCD_WIDTH) + width = LCD_WIDTH - x; + if (y + height > LCD_HEIGHT) + height = LCD_HEIGHT - y; + + _gray_rb->sim_lcd_ex_update_rect(x, y, width, height); +} + +#else /* !SIMULATOR */ /* Update a rectangular area of the greyscale overlay */ void gray_update_rect(int x, int y, int width, int height) { @@ -647,7 +730,7 @@ void gray_update_rect(int x, int y, int width, int height) "d0", "d1", "d2", "d3", "d4", "d5", "d6", "a0", "a1" ); } -#endif +#endif /* CONFIG_CPU, LCD_DEPTH */ srcofs_row += _gray_info.height; dst_row++; } @@ -657,7 +740,6 @@ void gray_update_rect(int x, int y, int width, int height) dst += _gray_info.width; } } - #if CONFIG_CPU == SH7034 /* References to C library routines used in gray_update_rect() */ asm ( @@ -668,7 +750,9 @@ asm ( ".long ___lshrsi3 \n" /* shift r4 right by r5, return in r0 */ /* both routines preserve r4, destroy r5 and take ~16 cycles */ ); -#endif +#endif /* CONFIG_CPU == SH7034 */ + +#endif /* !SIMULATOR */ /* Update the whole greyscale overlay */ void gray_update(void) @@ -681,7 +765,13 @@ void gray_update(void) void gray_deferred_lcd_update(void) { if (_gray_info.flags & _GRAY_RUNNING) + { +#ifdef SIMULATOR + _deferred_update(); +#else _gray_info.flags |= _GRAY_DEFERRED_UPDATE; +#endif + } else _gray_rb->lcd_update(); } @@ -745,17 +835,14 @@ static const unsigned char bmpheader[] = content (b&w and greyscale overlay) to an 8-bit BMP file. */ static void gray_screendump_hook(int fd) { - int i, idx; + int i; int x, y, by; - int gx, mask; -#if LCD_DEPTH == 1 - int gby; -#elif LCD_DEPTH == 2 - int shift, gy; + int gx, gy, mask; +#if LCD_DEPTH == 2 + int shift; #endif unsigned char *clut_entry; unsigned char *lcdptr; - unsigned char *grayptr, *grayptr2; unsigned char linebuf[MAX(4*BMP_VARCOLORS,BMP_LINESIZE)]; _gray_rb->write(fd, bmpheader, sizeof(bmpheader)); /* write header */ @@ -778,16 +865,19 @@ static void gray_screendump_hook(int fd) { _gray_rb->memset(linebuf, 0, BMP_LINESIZE); + gy = y - (_gray_info.by << _PBLOCK_EXP); #if LCD_DEPTH == 1 mask = 1 << (y & (_PBLOCK-1)); by = y >> _PBLOCK_EXP; lcdptr = _gray_rb->lcd_framebuffer + MULU16(LCD_WIDTH, by); - gby = by - _gray_info.by; - if ((unsigned) gby < (unsigned) _gray_info.bheight) + if ((unsigned) gy < (unsigned) _gray_info.height) { /* line contains greyscale (and maybe b&w) graphics */ - grayptr = _gray_info.plane_data + MULU16(_gray_info.width, gby); +#ifndef SIMULATOR + unsigned char *grayptr = _gray_info.plane_data + + MULU16(_gray_info.width, gy >> _PBLOCK_EXP); +#endif for (x = 0; x < LCD_WIDTH; x++) { @@ -795,8 +885,12 @@ static void gray_screendump_hook(int fd) if ((unsigned)gx < (unsigned)_gray_info.width) { - idx = BMP_FIXEDCOLORS; - grayptr2 = grayptr + gx; +#ifdef SIMULATOR + linebuf[x] = BMP_FIXEDCOLORS + _gray_info.depth + - _gray_info.cur_buffer[MULU16(gx, _gray_info.height) + gy]; +#else + int idx = BMP_FIXEDCOLORS; + unsigned char *grayptr2 = grayptr + gx; for (i = _gray_info.depth; i > 0; i--) { @@ -805,6 +899,7 @@ static void gray_screendump_hook(int fd) grayptr2 += _gray_info.plane_size; } linebuf[x] = idx; +#endif } else { @@ -823,14 +918,17 @@ static void gray_screendump_hook(int fd) shift = 2 * (y & 3); by = y >> 2; lcdptr = _gray_rb->lcd_framebuffer + MULU16(LCD_WIDTH, by); - gy = y - (_gray_info.by << _PBLOCK_EXP); - + if ((unsigned)gy < (unsigned)_gray_info.height) { /* line contains greyscale (and maybe b&w) graphics */ +#ifdef SIMULATOR + (void)mask; +#else + unsigned char *grayptr = _gray_info.plane_data + + MULU16(_gray_info.width, gy >> _PBLOCK_EXP); mask = 1 << (gy & (_PBLOCK-1)); - grayptr = _gray_info.plane_data - + MULU16(_gray_info.width, gy >> _PBLOCK_EXP); +#endif for (x = 0; x < LCD_WIDTH; x++) { @@ -838,8 +936,12 @@ static void gray_screendump_hook(int fd) if ((unsigned)gx < (unsigned)_gray_info.width) { - idx = BMP_FIXEDCOLORS; - grayptr2 = grayptr + gx; +#ifdef SIMULATOR + linebuf[x] = BMP_FIXEDCOLORS + _gray_info.depth + - _gray_info.cur_buffer[MULU16(gx, _gray_info.height) + gy]; +#else + int idx = BMP_FIXEDCOLORS; + unsigned char *grayptr2 = grayptr + gx; for (i = _gray_info.depth; i > 0; i--) { @@ -848,6 +950,7 @@ static void gray_screendump_hook(int fd) grayptr2 += _gray_info.plane_size; } linebuf[x] = idx; +#endif } else { @@ -862,12 +965,11 @@ static void gray_screendump_hook(int fd) for (x = 0; x < LCD_WIDTH; x++) linebuf[x] = (*lcdptr++ >> shift) & 3; } -#endif +#endif /* LCD_DEPTH */ _gray_rb->write(fd, linebuf, BMP_LINESIZE); } } #endif /* HAVE_LCD_BITMAP */ -#endif /* !SIMULATOR */ diff --git a/apps/plugins/lib/gray_draw.c b/apps/plugins/lib/gray_draw.c index 4222d80dc1..5d73f09e26 100644 --- a/apps/plugins/lib/gray_draw.c +++ b/apps/plugins/lib/gray_draw.c @@ -10,10 +10,10 @@ * Greyscale framework * Drawing functions * -* This is a generic framework to use grayscale display within Rockbox -* plugins. It obviously does not work for the player. +* This is a generic framework to display up to 33 shades of grey +* on low-depth bitmap LCDs (Archos b&w, Iriver 4-grey) within plugins. * -* Copyright (C) 2004-2005 Jens Arnold +* Copyright (C) 2004-2006 Jens Arnold * * All files in this archive are subject to the GNU General Public License. * See the file COPYING in the source tree root for full license agreement. @@ -23,10 +23,9 @@ * ****************************************************************************/ -#ifndef SIMULATOR /* not for simulator by now */ #include "plugin.h" -#ifdef HAVE_LCD_BITMAP /* and also not for the Player */ +#ifdef HAVE_LCD_BITMAP #include "gray.h" /*** low-level drawing functions ***/ @@ -587,6 +586,26 @@ void gray_putsxy(int x, int y, const unsigned char *str) /*** Unbuffered drawing functions ***/ +#ifdef SIMULATOR + +/* Clear the greyscale display (sets all pixels to white) */ +void gray_ub_clear_display(void) +{ + _gray_rb->memset(_gray_info.cur_buffer, _gray_info.depth, + MULU16(_gray_info.width, _gray_info.height)); + gray_update(); +} + +/* Draw a partial greyscale bitmap, canonical format */ +void gray_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, + int stride, int x, int y, int width, int height) +{ + gray_gray_bitmap_part(src, src_x, src_y, stride, x, y, width, height); + gray_update_rect(x, y, width, height); +} + +#else /* !SIMULATOR */ + /* Clear the greyscale display (sets all pixels to white) */ void gray_ub_clear_display(void) { @@ -1005,6 +1024,8 @@ void gray_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, while (dst < dst_end); } +#endif /* !SIMULATOR */ + /* Draw a full greyscale bitmap, canonical format */ void gray_ub_gray_bitmap(const unsigned char *src, int x, int y, int width, int height) @@ -1014,5 +1035,4 @@ void gray_ub_gray_bitmap(const unsigned char *src, int x, int y, int width, #endif /* HAVE_LCD_BITMAP */ -#endif /* !SIMULATOR */ diff --git a/apps/plugins/lib/gray_parm.c b/apps/plugins/lib/gray_parm.c index 77156852c5..c6305421c1 100644 --- a/apps/plugins/lib/gray_parm.c +++ b/apps/plugins/lib/gray_parm.c @@ -10,10 +10,10 @@ * Greyscale framework * Parameter handling * -* This is a generic framework to use grayscale display within Rockbox -* plugins. It obviously does not work for the player. +* This is a generic framework to display up to 33 shades of grey +* on low-depth bitmap LCDs (Archos b&w, Iriver 4-grey) within plugins. * -* Copyright (C) 2004-2005 Jens Arnold +* Copyright (C) 2004-2006 Jens Arnold * * All files in this archive are subject to the GNU General Public License. * See the file COPYING in the source tree root for full license agreement. @@ -23,10 +23,9 @@ * ****************************************************************************/ -#ifndef SIMULATOR /* not for simulator by now */ #include "plugin.h" -#ifdef HAVE_LCD_BITMAP /* and also not for the Player */ +#ifdef HAVE_LCD_BITMAP #include "gray.h" /* Set position of the top left corner of the greyscale overlay @@ -37,7 +36,14 @@ void gray_set_position(int x, int by) _gray_info.by = by; if (_gray_info.flags & _GRAY_RUNNING) + { +#ifdef SIMULATOR + gray_deferred_lcd_update(); + gray_update(); +#else _gray_info.flags |= _GRAY_DEFERRED_UPDATE; +#endif + } } /* Set the draw mode for subsequent drawing operations */ @@ -103,5 +109,3 @@ int gray_getstringsize(const unsigned char *str, int *w, int *h) } #endif /* HAVE_LCD_BITMAP */ -#endif /* !SIMULATOR */ - diff --git a/apps/plugins/lib/gray_scroll.c b/apps/plugins/lib/gray_scroll.c index 89ca2f37c3..bb6e0ea5bd 100644 --- a/apps/plugins/lib/gray_scroll.c +++ b/apps/plugins/lib/gray_scroll.c @@ -10,10 +10,10 @@ * Greyscale framework * Scrolling routines * -* This is a generic framework to use grayscale display within Rockbox -* plugins. It obviously does not work for the player. +* This is a generic framework to display up to 33 shades of grey +* on low-depth bitmap LCDs (Archos b&w, Iriver 4-grey) within plugins. * -* Copyright (C) 2004-2005 Jens Arnold +* Copyright (C) 2004-2006 Jens Arnold * * All files in this archive are subject to the GNU General Public License. * See the file COPYING in the source tree root for full license agreement. @@ -23,10 +23,9 @@ * ****************************************************************************/ -#ifndef SIMULATOR /* not for simulator by now */ #include "plugin.h" -#ifdef HAVE_LCD_BITMAP /* and also not for the Player */ +#ifdef HAVE_LCD_BITMAP #include "gray.h" /*** Scrolling ***/ @@ -117,6 +116,38 @@ void gray_scroll_down(int count) /*** Unbuffered scrolling functions ***/ +#ifdef SIMULATOR + +/* Scroll left */ +void gray_ub_scroll_left(int count) +{ + gray_scroll_left(count); + gray_update(); +} + +/* Scroll right */ +void gray_ub_scroll_right(int count) +{ + gray_scroll_right(count); + gray_update(); +} + +/* Scroll up */ +void gray_ub_scroll_up(int count) +{ + gray_scroll_up(count); + gray_update(); +} + +/* Scroll down */ +void gray_ub_scroll_down(int count) +{ + gray_scroll_down(count); + gray_update(); +} + +#else /* !SIMULATOR */ + /* Scroll left */ void gray_ub_scroll_left(int count) { @@ -545,7 +576,7 @@ void gray_ub_scroll_down(int count) #endif } } +#endif /* !SIMULATOR */ #endif /* HAVE_LCD_BITMAP */ -#endif /* !SIMULATOR */ diff --git a/apps/plugins/mandelbrot.c b/apps/plugins/mandelbrot.c index 2020d4dc2f..d4e399c057 100644 --- a/apps/plugins/mandelbrot.c +++ b/apps/plugins/mandelbrot.c @@ -20,7 +20,7 @@ ****************************************************************************/ #include "plugin.h" -#if defined(HAVE_LCD_BITMAP) && ((LCD_DEPTH >= 8) || !defined(SIMULATOR)) +#ifdef HAVE_LCD_BITMAP #include "gray.h" #include "xlcd.h" diff --git a/apps/plugins/plasma.c b/apps/plugins/plasma.c index ca589d77b6..934def4434 100644 --- a/apps/plugins/plasma.c +++ b/apps/plugins/plasma.c @@ -24,7 +24,7 @@ #include "plugin.h" -#if defined(HAVE_LCD_BITMAP) && (defined(HAVE_LCD_COLOR) || !defined(SIMULATOR)) +#ifdef HAVE_LCD_BITMAP #ifndef HAVE_LCD_COLOR #include "gray.h" @@ -336,4 +336,4 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) return ret; } -#endif // HAVE_LCD_BITMAP && (HAVE_LCD_COLOR || !SIMULATOR) +#endif /* HAVE_LCD_BITMAP */ -- cgit v1.2.3