diff options
author | Jens Arnold <amiconn@rockbox.org> | 2006-02-26 13:37:42 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2006-02-26 13:37:42 +0000 |
commit | 6a972e02497d3015236189f72931c3d59fa51755 (patch) | |
tree | 0c0185dd66b47d7d1ee2d91e4a3ffb6dbabcc7d1 | |
parent | 14fe89aa8d2ef05595bdba0e0b78f021f3e8d087 (diff) | |
download | rockbox-6a972e02497d3015236189f72931c3d59fa51755.tar.gz rockbox-6a972e02497d3015236189f72931c3d59fa51755.zip |
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
-rw-r--r-- | apps/plugin.c | 6 | ||||
-rw-r--r-- | apps/plugin.h | 6 | ||||
-rw-r--r-- | apps/plugins/brickmania.c | 1 | ||||
-rw-r--r-- | apps/plugins/cube.c | 2 | ||||
-rw-r--r-- | apps/plugins/fire.c | 2 | ||||
-rw-r--r-- | apps/plugins/grayscale.c | 2 | ||||
-rw-r--r-- | apps/plugins/jpeg.c | 4 | ||||
-rw-r--r-- | apps/plugins/lib/SOURCES | 3 | ||||
-rw-r--r-- | apps/plugins/lib/gray.h | 18 | ||||
-rw-r--r-- | apps/plugins/lib/gray_core.c | 206 | ||||
-rw-r--r-- | apps/plugins/lib/gray_draw.c | 32 | ||||
-rw-r--r-- | apps/plugins/lib/gray_parm.c | 18 | ||||
-rw-r--r-- | apps/plugins/lib/gray_scroll.c | 43 | ||||
-rw-r--r-- | apps/plugins/mandelbrot.c | 2 | ||||
-rw-r--r-- | apps/plugins/plasma.c | 4 | ||||
-rw-r--r-- | uisimulator/sdl/lcd-bitmap.c | 89 | ||||
-rw-r--r-- | uisimulator/sdl/lcd-bitmap.h | 4 | ||||
-rw-r--r-- | uisimulator/sdl/lcd-charcell.c | 9 | ||||
-rw-r--r-- | uisimulator/sdl/lcd-remote.c | 19 | ||||
-rw-r--r-- | uisimulator/sdl/lcd-sdl.c | 36 | ||||
-rw-r--r-- | uisimulator/sdl/lcd-sdl.h | 9 |
21 files changed, 383 insertions, 132 deletions
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 @@ | |||
72 | static unsigned char pluginbuf[PLUGIN_BUFFER_SIZE]; | 72 | static unsigned char pluginbuf[PLUGIN_BUFFER_SIZE]; |
73 | void *sim_plugin_load(char *plugin, int *fd); | 73 | void *sim_plugin_load(char *plugin, int *fd); |
74 | void sim_plugin_close(int fd); | 74 | void sim_plugin_close(int fd); |
75 | void sim_lcd_ex_init(int shades, unsigned long (*getpixel)(int, int)); | ||
76 | void sim_lcd_ex_update_rect(int x, int y, int width, int height); | ||
75 | #else | 77 | #else |
76 | #define sim_plugin_close(x) | 78 | #define sim_plugin_close(x) |
77 | extern unsigned char pluginbuf[]; | 79 | extern unsigned char pluginbuf[]; |
@@ -401,6 +403,10 @@ static const struct plugin_api rockbox_api = { | |||
401 | /* new stuff at the end, sort into place next time | 403 | /* new stuff at the end, sort into place next time |
402 | the API gets incompatible */ | 404 | the API gets incompatible */ |
403 | tree_get_context, | 405 | tree_get_context, |
406 | #if defined(SIMULATOR) && defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8 | ||
407 | sim_lcd_ex_init, | ||
408 | sim_lcd_ex_update_rect, | ||
409 | #endif | ||
404 | }; | 410 | }; |
405 | 411 | ||
406 | int plugin_load(const char* plugin, void* parameter) | 412 | 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 @@ | |||
98 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ | 98 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ |
99 | 99 | ||
100 | /* increase this every time the api struct changes */ | 100 | /* increase this every time the api struct changes */ |
101 | #define PLUGIN_API_VERSION 8 | 101 | #define PLUGIN_API_VERSION 9 |
102 | 102 | ||
103 | /* update this to latest version if a change to the api struct breaks | 103 | /* update this to latest version if a change to the api struct breaks |
104 | backwards compatibility (and please take the opportunity to sort in any | 104 | backwards compatibility (and please take the opportunity to sort in any |
@@ -469,6 +469,10 @@ struct plugin_api { | |||
469 | the API gets incompatible */ | 469 | the API gets incompatible */ |
470 | 470 | ||
471 | struct tree_context* (*tree_get_context)(void); | 471 | struct tree_context* (*tree_get_context)(void); |
472 | #if defined(SIMULATOR) && defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8 | ||
473 | void (*sim_lcd_ex_init)(int shades, unsigned long (*getpixel)(int, int)); | ||
474 | void (*sim_lcd_ex_update_rect)(int x, int y, int width, int height); | ||
475 | #endif | ||
472 | 476 | ||
473 | }; | 477 | }; |
474 | 478 | ||
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 @@ | |||
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | 19 | ||
20 | #include "plugin.h" | 20 | #include "plugin.h" |
21 | #include "gray.h" | ||
22 | #include "configfile.h" /* Part of libplugin */ | 21 | #include "configfile.h" /* Part of libplugin */ |
23 | 22 | ||
24 | PLUGIN_HEADER | 23 | 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 | |||
142 | static int x_off = LCD_WIDTH/2; | 142 | static int x_off = LCD_WIDTH/2; |
143 | static int y_off = LCD_HEIGHT/2; | 143 | static int y_off = LCD_HEIGHT/2; |
144 | 144 | ||
145 | #if LCD_DEPTH == 1 && !defined(SIMULATOR) | 145 | #if LCD_DEPTH == 1 |
146 | #define USE_GSLIB | 146 | #define USE_GSLIB |
147 | struct my_lcd { | 147 | struct my_lcd { |
148 | void (*update)(void); | 148 | 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 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #ifndef SIMULATOR /* not for simulator (grayscale) */ | ||
23 | #include "plugin.h" | 22 | #include "plugin.h" |
24 | 23 | ||
25 | #ifdef HAVE_LCD_BITMAP /* and also not for the Player */ | 24 | #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) | |||
305 | } | 304 | } |
306 | 305 | ||
307 | #endif // #ifdef HAVE_LCD_BITMAP | 306 | #endif // #ifdef HAVE_LCD_BITMAP |
308 | #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 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #ifndef SIMULATOR /* not for simulator by now */ | ||
23 | #include "plugin.h" | 22 | #include "plugin.h" |
24 | 23 | ||
25 | #if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) && (CONFIG_LCD != LCD_IPOD2BPP) | 24 | #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) | |||
336 | } | 335 | } |
337 | 336 | ||
338 | #endif // #ifdef HAVE_LCD_BITMAP | 337 | #endif // #ifdef HAVE_LCD_BITMAP |
339 | #endif // #ifndef SIMULATOR | ||
340 | 338 | ||
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 @@ | |||
26 | 26 | ||
27 | #include "plugin.h" | 27 | #include "plugin.h" |
28 | 28 | ||
29 | #if defined(HAVE_LCD_BITMAP) && ((LCD_DEPTH >= 8) || !defined(SIMULATOR)) | 29 | #ifdef HAVE_LCD_BITMAP |
30 | #include "gray.h" | 30 | #include "gray.h" |
31 | #include "xlcd.h" | 31 | #include "xlcd.h" |
32 | 32 | ||
@@ -2713,4 +2713,4 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
2713 | return condition; | 2713 | return condition; |
2714 | } | 2714 | } |
2715 | 2715 | ||
2716 | #endif /* HAVE_LCD_BITMAP && ((LCD_DEPTH >= 8) || !defined(SIMULATOR))*/ | 2716 | #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 @@ | |||
1 | configfile.c | 1 | configfile.c |
2 | #if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) && !defined(SIMULATOR) && \ | 2 | #if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) && (CONFIG_LCD != LCD_IPOD2BPP) |
3 | (CONFIG_LCD != LCD_IPOD2BPP) | ||
4 | gray_core.c | 3 | gray_core.c |
5 | gray_draw.c | 4 | gray_draw.c |
6 | gray_parm.c | 5 | 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 @@ | |||
9 | * | 9 | * |
10 | * Greyscale framework | 10 | * Greyscale framework |
11 | * | 11 | * |
12 | * This is a generic framework to use greyscale display within Rockbox | 12 | * This is a generic framework to display up to 33 shades of grey |
13 | * plugins. It does not work for the player. | 13 | * on low-depth bitmap LCDs (Archos b&w, Iriver 4-grey) within plugins. |
14 | * | 14 | * |
15 | * Copyright (C) 2004-2005 Jens Arnold | 15 | * Copyright (C) 2004-2006 Jens Arnold |
16 | * | 16 | * |
17 | * All files in this archive are subject to the GNU General Public License. | 17 | * All files in this archive are subject to the GNU General Public License. |
18 | * See the file COPYING in the source tree root for full license agreement. | 18 | * See the file COPYING in the source tree root for full license agreement. |
@@ -25,7 +25,6 @@ | |||
25 | #ifndef __GRAY_H__ | 25 | #ifndef __GRAY_H__ |
26 | #define __GRAY_H__ | 26 | #define __GRAY_H__ |
27 | 27 | ||
28 | #ifndef SIMULATOR /* not for simulator by now */ | ||
29 | #include "plugin.h" | 28 | #include "plugin.h" |
30 | 29 | ||
31 | #ifdef HAVE_LCD_BITMAP /* and also not for the Player */ | 30 | #ifdef HAVE_LCD_BITMAP /* and also not for the Player */ |
@@ -129,17 +128,19 @@ struct _gray_info | |||
129 | int height; | 128 | int height; |
130 | int bheight; /* 8-pixel units */ | 129 | int bheight; /* 8-pixel units */ |
131 | int depth; /* number_of_bitplanes = (number_of_grayscales - 1) */ | 130 | int depth; /* number_of_bitplanes = (number_of_grayscales - 1) */ |
131 | unsigned long flags; /* various flags, see #defines */ | ||
132 | #ifndef SIMULATOR | ||
132 | int cur_plane; /* for the timer isr */ | 133 | int cur_plane; /* for the timer isr */ |
133 | int drawmode; /* current draw mode */ | ||
134 | int fg_brightness; /* current foreground brightness */ | ||
135 | int bg_brightness; /* current background brightness */ | ||
136 | long plane_size; | 134 | long plane_size; |
137 | unsigned long flags; /* various flags, see #defines */ | ||
138 | unsigned long randmask; /* mask for random value in _writepixel() */ | 135 | unsigned long randmask; /* mask for random value in _writepixel() */ |
139 | unsigned long *bitpattern; /* start of pattern table */ | 136 | unsigned long *bitpattern; /* start of pattern table */ |
140 | unsigned char *plane_data; /* start of bitplane data */ | 137 | unsigned char *plane_data; /* start of bitplane data */ |
138 | #endif | ||
141 | unsigned char *cur_buffer; /* start of current chunky pixel buffer */ | 139 | unsigned char *cur_buffer; /* start of current chunky pixel buffer */ |
142 | unsigned char *back_buffer;/* start of chunky pixel back buffer */ | 140 | unsigned char *back_buffer;/* start of chunky pixel back buffer */ |
141 | int drawmode; /* current draw mode */ | ||
142 | int fg_brightness; /* current foreground brightness */ | ||
143 | int bg_brightness; /* current background brightness */ | ||
143 | int curfont; /* current selected font */ | 144 | int curfont; /* current selected font */ |
144 | }; | 145 | }; |
145 | 146 | ||
@@ -149,5 +150,4 @@ extern struct _gray_info _gray_info; | |||
149 | extern short _gray_random_buffer; | 150 | extern short _gray_random_buffer; |
150 | 151 | ||
151 | #endif /* HAVE_LCD_BITMAP */ | 152 | #endif /* HAVE_LCD_BITMAP */ |
152 | #endif /* !SIMULATOR */ | ||
153 | #endif /* __GRAY_H__ */ | 153 | #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 @@ | |||
10 | * Greyscale framework | 10 | * Greyscale framework |
11 | * Core & miscellaneous functions | 11 | * Core & miscellaneous functions |
12 | * | 12 | * |
13 | * This is a generic framework to use grayscale display within Rockbox | 13 | * This is a generic framework to display up to 33 shades of grey |
14 | * plugins. It obviously does not work for the player. | 14 | * on low-depth bitmap LCDs (Archos b&w, Iriver 4-grey) within plugins. |
15 | * | 15 | * |
16 | * Copyright (C) 2004-2005 Jens Arnold | 16 | * Copyright (C) 2004-2006 Jens Arnold |
17 | * | 17 | * |
18 | * All files in this archive are subject to the GNU General Public License. | 18 | * All files in this archive are subject to the GNU General Public License. |
19 | * See the file COPYING in the source tree root for full license agreement. | 19 | * See the file COPYING in the source tree root for full license agreement. |
@@ -23,21 +23,49 @@ | |||
23 | * | 23 | * |
24 | ****************************************************************************/ | 24 | ****************************************************************************/ |
25 | 25 | ||
26 | #ifndef SIMULATOR /* not for simulator by now */ | ||
27 | #include "plugin.h" | 26 | #include "plugin.h" |
28 | 27 | ||
29 | #ifdef HAVE_LCD_BITMAP /* and also not for the Player */ | 28 | #ifdef HAVE_LCD_BITMAP |
30 | #include "gray.h" | 29 | #include "gray.h" |
31 | 30 | ||
32 | /* Global variables */ | 31 | /* Global variables */ |
33 | struct plugin_api *_gray_rb = NULL; /* global api struct pointer */ | 32 | struct plugin_api *_gray_rb = NULL; /* global api struct pointer */ |
34 | struct _gray_info _gray_info; /* global info structure */ | 33 | struct _gray_info _gray_info; /* global info structure */ |
34 | #ifndef SIMULATOR | ||
35 | short _gray_random_buffer; /* buffer for random number generator */ | 35 | short _gray_random_buffer; /* buffer for random number generator */ |
36 | #endif | ||
36 | 37 | ||
37 | /* Prototypes */ | 38 | /* Prototypes */ |
39 | static inline void _deferred_update(void) __attribute__ ((always_inline)); | ||
40 | #ifdef SIMULATOR | ||
41 | static unsigned long _gray_get_pixel(int x, int y); | ||
42 | #else | ||
38 | static void _timer_isr(void); | 43 | static void _timer_isr(void); |
44 | #endif | ||
39 | static void gray_screendump_hook(int fd); | 45 | static void gray_screendump_hook(int fd); |
40 | 46 | ||
47 | /* Update LCD areas not covered by the greyscale overlay */ | ||
48 | static inline void _deferred_update(void) | ||
49 | { | ||
50 | int x1 = MAX(_gray_info.x, 0); | ||
51 | int x2 = MIN(_gray_info.x + _gray_info.width, LCD_WIDTH); | ||
52 | int y1 = MAX(_gray_info.by << _PBLOCK_EXP, 0); | ||
53 | int y2 = MIN((_gray_info.by << _PBLOCK_EXP) + _gray_info.height, LCD_HEIGHT); | ||
54 | |||
55 | if (y1 > 0) /* refresh part above overlay, full width */ | ||
56 | _gray_rb->lcd_update_rect(0, 0, LCD_WIDTH, y1); | ||
57 | |||
58 | if (y2 < LCD_HEIGHT) /* refresh part below overlay, full width */ | ||
59 | _gray_rb->lcd_update_rect(0, y2, LCD_WIDTH, LCD_HEIGHT - y2); | ||
60 | |||
61 | if (x1 > 0) /* refresh part to the left of overlay */ | ||
62 | _gray_rb->lcd_update_rect(0, y1, x1, y2 - y1); | ||
63 | |||
64 | if (x2 < LCD_WIDTH) /* refresh part to the right of overlay */ | ||
65 | _gray_rb->lcd_update_rect(x2, y1, LCD_WIDTH - x2, y2 - y1); | ||
66 | } | ||
67 | |||
68 | #ifndef SIMULATOR | ||
41 | /* Timer interrupt handler: display next bitplane */ | 69 | /* Timer interrupt handler: display next bitplane */ |
42 | static void _timer_isr(void) | 70 | static void _timer_isr(void) |
43 | { | 71 | { |
@@ -50,26 +78,11 @@ static void _timer_isr(void) | |||
50 | 78 | ||
51 | if (_gray_info.flags & _GRAY_DEFERRED_UPDATE) /* lcd_update() requested? */ | 79 | if (_gray_info.flags & _GRAY_DEFERRED_UPDATE) /* lcd_update() requested? */ |
52 | { | 80 | { |
53 | int x1 = MAX(_gray_info.x, 0); | 81 | _deferred_update(); |
54 | int x2 = MIN(_gray_info.x + _gray_info.width, LCD_WIDTH); | ||
55 | int y1 = MAX(_gray_info.by << _PBLOCK_EXP, 0); | ||
56 | int y2 = MIN((_gray_info.by << _PBLOCK_EXP) + _gray_info.height, LCD_HEIGHT); | ||
57 | |||
58 | if (y1 > 0) /* refresh part above overlay, full width */ | ||
59 | _gray_rb->lcd_update_rect(0, 0, LCD_WIDTH, y1); | ||
60 | |||
61 | if (y2 < LCD_HEIGHT) /* refresh part below overlay, full width */ | ||
62 | _gray_rb->lcd_update_rect(0, y2, LCD_WIDTH, LCD_HEIGHT - y2); | ||
63 | |||
64 | if (x1 > 0) /* refresh part to the left of overlay */ | ||
65 | _gray_rb->lcd_update_rect(0, y1, x1, y2 - y1); | ||
66 | |||
67 | if (x2 < LCD_WIDTH) /* refresh part to the right of overlay */ | ||
68 | _gray_rb->lcd_update_rect(x2, y1, LCD_WIDTH - x2, y2 - y1); | ||
69 | |||
70 | _gray_info.flags &= ~_GRAY_DEFERRED_UPDATE; /* clear request */ | 82 | _gray_info.flags &= ~_GRAY_DEFERRED_UPDATE; /* clear request */ |
71 | } | 83 | } |
72 | } | 84 | } |
85 | #endif /* !SIMULATOR */ | ||
73 | 86 | ||
74 | /* Initialise the framework and prepare the greyscale display buffer | 87 | /* Initialise the framework and prepare the greyscale display buffer |
75 | 88 | ||
@@ -108,13 +121,21 @@ static void _timer_isr(void) | |||
108 | + (width * bheight) * depth (bitplane data) | 121 | + (width * bheight) * depth (bitplane data) |
109 | + buffered ? (chunky front- & backbuffer) | 122 | + buffered ? (chunky front- & backbuffer) |
110 | (width * bheight * 8 * 2) : 0 | 123 | (width * bheight * 8 * 2) : 0 |
111 | + 0..3 (longword alignment) */ | 124 | + 0..3 (longword alignment) |
125 | |||
126 | The function tries to be as authentic as possible regarding memory usage on | ||
127 | the simulator, even if it doesn't use all of the allocated memory. There's | ||
128 | one situation where it will consume more memory on the sim than on the | ||
129 | target: if you're allocating a low depth (< 8) without buffering. */ | ||
112 | int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, | 130 | int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, |
113 | bool buffered, int width, int bheight, int depth, long *buf_taken) | 131 | bool buffered, int width, int bheight, int depth, long *buf_taken) |
114 | { | 132 | { |
115 | int possible_depth, i, j; | 133 | int possible_depth; |
116 | long plane_size, buftaken; | 134 | long plane_size, buftaken; |
117 | 135 | #ifndef SIMULATOR | |
136 | int i, j; | ||
137 | #endif | ||
138 | |||
118 | _gray_rb = newrb; | 139 | _gray_rb = newrb; |
119 | 140 | ||
120 | if ((unsigned) width > LCD_WIDTH | 141 | if ((unsigned) width > LCD_WIDTH |
@@ -152,19 +173,41 @@ int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, | |||
152 | depth = MIN(depth, 32); | 173 | depth = MIN(depth, 32); |
153 | depth = MIN(depth, possible_depth); | 174 | depth = MIN(depth, possible_depth); |
154 | 175 | ||
176 | #ifdef SIMULATOR | ||
177 | if (!buffered) | ||
178 | { | ||
179 | long orig_size = depth * plane_size + (depth + 1) * sizeof(long); | ||
180 | |||
181 | plane_size = MULU16(width, bheight << _PBLOCK_EXP); | ||
182 | if (plane_size > orig_size) | ||
183 | { | ||
184 | buftaken += plane_size; | ||
185 | if (buftaken > gbuf_size) | ||
186 | return 0; | ||
187 | } | ||
188 | else | ||
189 | { | ||
190 | buftaken += orig_size; | ||
191 | } | ||
192 | _gray_info.cur_buffer = gbuf; | ||
193 | } | ||
194 | else | ||
195 | #endif | ||
196 | buftaken += depth * plane_size + (depth + 1) * sizeof(long); | ||
197 | |||
155 | _gray_info.x = 0; | 198 | _gray_info.x = 0; |
156 | _gray_info.by = 0; | 199 | _gray_info.by = 0; |
157 | _gray_info.width = width; | 200 | _gray_info.width = width; |
158 | _gray_info.height = bheight << _PBLOCK_EXP; | 201 | _gray_info.height = bheight << _PBLOCK_EXP; |
159 | _gray_info.bheight = bheight; | 202 | _gray_info.bheight = bheight; |
160 | _gray_info.plane_size = plane_size; | ||
161 | _gray_info.depth = depth; | 203 | _gray_info.depth = depth; |
162 | _gray_info.cur_plane = 0; | ||
163 | _gray_info.flags = 0; | 204 | _gray_info.flags = 0; |
205 | #ifndef SIMULATOR | ||
206 | _gray_info.cur_plane = 0; | ||
207 | _gray_info.plane_size = plane_size; | ||
164 | _gray_info.plane_data = gbuf; | 208 | _gray_info.plane_data = gbuf; |
165 | gbuf += depth * plane_size; | 209 | gbuf += depth * plane_size; |
166 | _gray_info.bitpattern = (unsigned long *)gbuf; | 210 | _gray_info.bitpattern = (unsigned long *)gbuf; |
167 | buftaken += depth * plane_size + (depth + 1) * sizeof(long); | ||
168 | 211 | ||
169 | i = depth - 1; | 212 | i = depth - 1; |
170 | j = 8; | 213 | j = 8; |
@@ -195,6 +238,7 @@ int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, | |||
195 | 238 | ||
196 | _gray_info.bitpattern[i] = pattern; | 239 | _gray_info.bitpattern[i] = pattern; |
197 | } | 240 | } |
241 | #endif | ||
198 | 242 | ||
199 | _gray_info.fg_brightness = 0; | 243 | _gray_info.fg_brightness = 0; |
200 | _gray_info.bg_brightness = depth; | 244 | _gray_info.bg_brightness = depth; |
@@ -229,6 +273,10 @@ void gray_show(bool enable) | |||
229 | if (enable && !(_gray_info.flags & _GRAY_RUNNING)) | 273 | if (enable && !(_gray_info.flags & _GRAY_RUNNING)) |
230 | { | 274 | { |
231 | _gray_info.flags |= _GRAY_RUNNING; | 275 | _gray_info.flags |= _GRAY_RUNNING; |
276 | #ifdef SIMULATOR | ||
277 | _gray_rb->sim_lcd_ex_init(_gray_info.depth + 1, _gray_get_pixel); | ||
278 | gray_update(); | ||
279 | #else /* !SIMULATOR */ | ||
232 | #if CONFIG_LCD == LCD_SSD1815 | 280 | #if CONFIG_LCD == LCD_SSD1815 |
233 | _gray_rb->timer_register(1, NULL, CPU_FREQ / 67, 1, _timer_isr); | 281 | _gray_rb->timer_register(1, NULL, CPU_FREQ / 67, 1, _timer_isr); |
234 | #elif CONFIG_LCD == LCD_S1D15E06 | 282 | #elif CONFIG_LCD == LCD_S1D15E06 |
@@ -236,18 +284,53 @@ void gray_show(bool enable) | |||
236 | #elif CONFIG_LCD == LCD_IFP7XX | 284 | #elif CONFIG_LCD == LCD_IFP7XX |
237 | /* TODO: implement for iFP */ | 285 | /* TODO: implement for iFP */ |
238 | (void)_timer_isr; | 286 | (void)_timer_isr; |
239 | #endif | 287 | #endif /* CONFIG_LCD */ |
288 | #endif /* !SIMULATOR */ | ||
240 | _gray_rb->screen_dump_set_hook(gray_screendump_hook); | 289 | _gray_rb->screen_dump_set_hook(gray_screendump_hook); |
241 | } | 290 | } |
242 | else if (!enable && (_gray_info.flags & _GRAY_RUNNING)) | 291 | else if (!enable && (_gray_info.flags & _GRAY_RUNNING)) |
243 | { | 292 | { |
293 | #ifdef SIMULATOR | ||
294 | _gray_rb->sim_lcd_ex_init(0, NULL); | ||
295 | #else | ||
244 | _gray_rb->timer_unregister(); | 296 | _gray_rb->timer_unregister(); |
297 | #endif | ||
245 | _gray_info.flags &= ~_GRAY_RUNNING; | 298 | _gray_info.flags &= ~_GRAY_RUNNING; |
246 | _gray_rb->screen_dump_set_hook(NULL); | 299 | _gray_rb->screen_dump_set_hook(NULL); |
247 | _gray_rb->lcd_update(); /* restore whatever there was before */ | 300 | _gray_rb->lcd_update(); /* restore whatever there was before */ |
248 | } | 301 | } |
249 | } | 302 | } |
250 | 303 | ||
304 | #ifdef SIMULATOR | ||
305 | /* Callback function for gray_update_rect() to read a pixel from the graybuffer. | ||
306 | Note that x and y are in LCD coordinates, not graybuffer coordinates! */ | ||
307 | static unsigned long _gray_get_pixel(int x, int y) | ||
308 | { | ||
309 | return _gray_info.cur_buffer[MULU16(x - _gray_info.x, _gray_info.height) | ||
310 | + y - (_gray_info.by << _PBLOCK_EXP)] | ||
311 | + (1 << LCD_DEPTH); | ||
312 | } | ||
313 | |||
314 | /* Update a rectangular area of the greyscale overlay */ | ||
315 | void gray_update_rect(int x, int y, int width, int height) | ||
316 | { | ||
317 | if (x + width > _gray_info.width) | ||
318 | width = _gray_info.width - x; | ||
319 | if (y + height > _gray_info.height) | ||
320 | height = _gray_info.height - y; | ||
321 | |||
322 | x += _gray_info.x; | ||
323 | y += _gray_info.by << _PBLOCK_EXP; | ||
324 | |||
325 | if (x + width > LCD_WIDTH) | ||
326 | width = LCD_WIDTH - x; | ||
327 | if (y + height > LCD_HEIGHT) | ||
328 | height = LCD_HEIGHT - y; | ||
329 | |||
330 | _gray_rb->sim_lcd_ex_update_rect(x, y, width, height); | ||
331 | } | ||
332 | |||
333 | #else /* !SIMULATOR */ | ||
251 | /* Update a rectangular area of the greyscale overlay */ | 334 | /* Update a rectangular area of the greyscale overlay */ |
252 | void gray_update_rect(int x, int y, int width, int height) | 335 | void gray_update_rect(int x, int y, int width, int height) |
253 | { | 336 | { |
@@ -647,7 +730,7 @@ void gray_update_rect(int x, int y, int width, int height) | |||
647 | "d0", "d1", "d2", "d3", "d4", "d5", "d6", "a0", "a1" | 730 | "d0", "d1", "d2", "d3", "d4", "d5", "d6", "a0", "a1" |
648 | ); | 731 | ); |
649 | } | 732 | } |
650 | #endif | 733 | #endif /* CONFIG_CPU, LCD_DEPTH */ |
651 | srcofs_row += _gray_info.height; | 734 | srcofs_row += _gray_info.height; |
652 | dst_row++; | 735 | dst_row++; |
653 | } | 736 | } |
@@ -657,7 +740,6 @@ void gray_update_rect(int x, int y, int width, int height) | |||
657 | dst += _gray_info.width; | 740 | dst += _gray_info.width; |
658 | } | 741 | } |
659 | } | 742 | } |
660 | |||
661 | #if CONFIG_CPU == SH7034 | 743 | #if CONFIG_CPU == SH7034 |
662 | /* References to C library routines used in gray_update_rect() */ | 744 | /* References to C library routines used in gray_update_rect() */ |
663 | asm ( | 745 | asm ( |
@@ -668,7 +750,9 @@ asm ( | |||
668 | ".long ___lshrsi3 \n" /* shift r4 right by r5, return in r0 */ | 750 | ".long ___lshrsi3 \n" /* shift r4 right by r5, return in r0 */ |
669 | /* both routines preserve r4, destroy r5 and take ~16 cycles */ | 751 | /* both routines preserve r4, destroy r5 and take ~16 cycles */ |
670 | ); | 752 | ); |
671 | #endif | 753 | #endif /* CONFIG_CPU == SH7034 */ |
754 | |||
755 | #endif /* !SIMULATOR */ | ||
672 | 756 | ||
673 | /* Update the whole greyscale overlay */ | 757 | /* Update the whole greyscale overlay */ |
674 | void gray_update(void) | 758 | void gray_update(void) |
@@ -681,7 +765,13 @@ void gray_update(void) | |||
681 | void gray_deferred_lcd_update(void) | 765 | void gray_deferred_lcd_update(void) |
682 | { | 766 | { |
683 | if (_gray_info.flags & _GRAY_RUNNING) | 767 | if (_gray_info.flags & _GRAY_RUNNING) |
768 | { | ||
769 | #ifdef SIMULATOR | ||
770 | _deferred_update(); | ||
771 | #else | ||
684 | _gray_info.flags |= _GRAY_DEFERRED_UPDATE; | 772 | _gray_info.flags |= _GRAY_DEFERRED_UPDATE; |
773 | #endif | ||
774 | } | ||
685 | else | 775 | else |
686 | _gray_rb->lcd_update(); | 776 | _gray_rb->lcd_update(); |
687 | } | 777 | } |
@@ -745,17 +835,14 @@ static const unsigned char bmpheader[] = | |||
745 | content (b&w and greyscale overlay) to an 8-bit BMP file. */ | 835 | content (b&w and greyscale overlay) to an 8-bit BMP file. */ |
746 | static void gray_screendump_hook(int fd) | 836 | static void gray_screendump_hook(int fd) |
747 | { | 837 | { |
748 | int i, idx; | 838 | int i; |
749 | int x, y, by; | 839 | int x, y, by; |
750 | int gx, mask; | 840 | int gx, gy, mask; |
751 | #if LCD_DEPTH == 1 | 841 | #if LCD_DEPTH == 2 |
752 | int gby; | 842 | int shift; |
753 | #elif LCD_DEPTH == 2 | ||
754 | int shift, gy; | ||
755 | #endif | 843 | #endif |
756 | unsigned char *clut_entry; | 844 | unsigned char *clut_entry; |
757 | unsigned char *lcdptr; | 845 | unsigned char *lcdptr; |
758 | unsigned char *grayptr, *grayptr2; | ||
759 | unsigned char linebuf[MAX(4*BMP_VARCOLORS,BMP_LINESIZE)]; | 846 | unsigned char linebuf[MAX(4*BMP_VARCOLORS,BMP_LINESIZE)]; |
760 | 847 | ||
761 | _gray_rb->write(fd, bmpheader, sizeof(bmpheader)); /* write header */ | 848 | _gray_rb->write(fd, bmpheader, sizeof(bmpheader)); /* write header */ |
@@ -778,16 +865,19 @@ static void gray_screendump_hook(int fd) | |||
778 | { | 865 | { |
779 | _gray_rb->memset(linebuf, 0, BMP_LINESIZE); | 866 | _gray_rb->memset(linebuf, 0, BMP_LINESIZE); |
780 | 867 | ||
868 | gy = y - (_gray_info.by << _PBLOCK_EXP); | ||
781 | #if LCD_DEPTH == 1 | 869 | #if LCD_DEPTH == 1 |
782 | mask = 1 << (y & (_PBLOCK-1)); | 870 | mask = 1 << (y & (_PBLOCK-1)); |
783 | by = y >> _PBLOCK_EXP; | 871 | by = y >> _PBLOCK_EXP; |
784 | lcdptr = _gray_rb->lcd_framebuffer + MULU16(LCD_WIDTH, by); | 872 | lcdptr = _gray_rb->lcd_framebuffer + MULU16(LCD_WIDTH, by); |
785 | gby = by - _gray_info.by; | ||
786 | 873 | ||
787 | if ((unsigned) gby < (unsigned) _gray_info.bheight) | 874 | if ((unsigned) gy < (unsigned) _gray_info.height) |
788 | { | 875 | { |
789 | /* line contains greyscale (and maybe b&w) graphics */ | 876 | /* line contains greyscale (and maybe b&w) graphics */ |
790 | grayptr = _gray_info.plane_data + MULU16(_gray_info.width, gby); | 877 | #ifndef SIMULATOR |
878 | unsigned char *grayptr = _gray_info.plane_data | ||
879 | + MULU16(_gray_info.width, gy >> _PBLOCK_EXP); | ||
880 | #endif | ||
791 | 881 | ||
792 | for (x = 0; x < LCD_WIDTH; x++) | 882 | for (x = 0; x < LCD_WIDTH; x++) |
793 | { | 883 | { |
@@ -795,8 +885,12 @@ static void gray_screendump_hook(int fd) | |||
795 | 885 | ||
796 | if ((unsigned)gx < (unsigned)_gray_info.width) | 886 | if ((unsigned)gx < (unsigned)_gray_info.width) |
797 | { | 887 | { |
798 | idx = BMP_FIXEDCOLORS; | 888 | #ifdef SIMULATOR |
799 | grayptr2 = grayptr + gx; | 889 | linebuf[x] = BMP_FIXEDCOLORS + _gray_info.depth |
890 | - _gray_info.cur_buffer[MULU16(gx, _gray_info.height) + gy]; | ||
891 | #else | ||
892 | int idx = BMP_FIXEDCOLORS; | ||
893 | unsigned char *grayptr2 = grayptr + gx; | ||
800 | 894 | ||
801 | for (i = _gray_info.depth; i > 0; i--) | 895 | for (i = _gray_info.depth; i > 0; i--) |
802 | { | 896 | { |
@@ -805,6 +899,7 @@ static void gray_screendump_hook(int fd) | |||
805 | grayptr2 += _gray_info.plane_size; | 899 | grayptr2 += _gray_info.plane_size; |
806 | } | 900 | } |
807 | linebuf[x] = idx; | 901 | linebuf[x] = idx; |
902 | #endif | ||
808 | } | 903 | } |
809 | else | 904 | else |
810 | { | 905 | { |
@@ -823,14 +918,17 @@ static void gray_screendump_hook(int fd) | |||
823 | shift = 2 * (y & 3); | 918 | shift = 2 * (y & 3); |
824 | by = y >> 2; | 919 | by = y >> 2; |
825 | lcdptr = _gray_rb->lcd_framebuffer + MULU16(LCD_WIDTH, by); | 920 | lcdptr = _gray_rb->lcd_framebuffer + MULU16(LCD_WIDTH, by); |
826 | gy = y - (_gray_info.by << _PBLOCK_EXP); | 921 | |
827 | |||
828 | if ((unsigned)gy < (unsigned)_gray_info.height) | 922 | if ((unsigned)gy < (unsigned)_gray_info.height) |
829 | { | 923 | { |
830 | /* line contains greyscale (and maybe b&w) graphics */ | 924 | /* line contains greyscale (and maybe b&w) graphics */ |
925 | #ifdef SIMULATOR | ||
926 | (void)mask; | ||
927 | #else | ||
928 | unsigned char *grayptr = _gray_info.plane_data | ||
929 | + MULU16(_gray_info.width, gy >> _PBLOCK_EXP); | ||
831 | mask = 1 << (gy & (_PBLOCK-1)); | 930 | mask = 1 << (gy & (_PBLOCK-1)); |
832 | grayptr = _gray_info.plane_data | 931 | #endif |
833 | + MULU16(_gray_info.width, gy >> _PBLOCK_EXP); | ||
834 | 932 | ||
835 | for (x = 0; x < LCD_WIDTH; x++) | 933 | for (x = 0; x < LCD_WIDTH; x++) |
836 | { | 934 | { |
@@ -838,8 +936,12 @@ static void gray_screendump_hook(int fd) | |||
838 | 936 | ||
839 | if ((unsigned)gx < (unsigned)_gray_info.width) | 937 | if ((unsigned)gx < (unsigned)_gray_info.width) |
840 | { | 938 | { |
841 | idx = BMP_FIXEDCOLORS; | 939 | #ifdef SIMULATOR |
842 | grayptr2 = grayptr + gx; | 940 | linebuf[x] = BMP_FIXEDCOLORS + _gray_info.depth |
941 | - _gray_info.cur_buffer[MULU16(gx, _gray_info.height) + gy]; | ||
942 | #else | ||
943 | int idx = BMP_FIXEDCOLORS; | ||
944 | unsigned char *grayptr2 = grayptr + gx; | ||
843 | 945 | ||
844 | for (i = _gray_info.depth; i > 0; i--) | 946 | for (i = _gray_info.depth; i > 0; i--) |
845 | { | 947 | { |
@@ -848,6 +950,7 @@ static void gray_screendump_hook(int fd) | |||
848 | grayptr2 += _gray_info.plane_size; | 950 | grayptr2 += _gray_info.plane_size; |
849 | } | 951 | } |
850 | linebuf[x] = idx; | 952 | linebuf[x] = idx; |
953 | #endif | ||
851 | } | 954 | } |
852 | else | 955 | else |
853 | { | 956 | { |
@@ -862,12 +965,11 @@ static void gray_screendump_hook(int fd) | |||
862 | for (x = 0; x < LCD_WIDTH; x++) | 965 | for (x = 0; x < LCD_WIDTH; x++) |
863 | linebuf[x] = (*lcdptr++ >> shift) & 3; | 966 | linebuf[x] = (*lcdptr++ >> shift) & 3; |
864 | } | 967 | } |
865 | #endif | 968 | #endif /* LCD_DEPTH */ |
866 | 969 | ||
867 | _gray_rb->write(fd, linebuf, BMP_LINESIZE); | 970 | _gray_rb->write(fd, linebuf, BMP_LINESIZE); |
868 | } | 971 | } |
869 | } | 972 | } |
870 | 973 | ||
871 | #endif /* HAVE_LCD_BITMAP */ | 974 | #endif /* HAVE_LCD_BITMAP */ |
872 | #endif /* !SIMULATOR */ | ||
873 | 975 | ||
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 @@ | |||
10 | * Greyscale framework | 10 | * Greyscale framework |
11 | * Drawing functions | 11 | * Drawing functions |
12 | * | 12 | * |
13 | * This is a generic framework to use grayscale display within Rockbox | 13 | * This is a generic framework to display up to 33 shades of grey |
14 | * plugins. It obviously does not work for the player. | 14 | * on low-depth bitmap LCDs (Archos b&w, Iriver 4-grey) within plugins. |
15 | * | 15 | * |
16 | * Copyright (C) 2004-2005 Jens Arnold | 16 | * Copyright (C) 2004-2006 Jens Arnold |
17 | * | 17 | * |
18 | * All files in this archive are subject to the GNU General Public License. | 18 | * All files in this archive are subject to the GNU General Public License. |
19 | * See the file COPYING in the source tree root for full license agreement. | 19 | * See the file COPYING in the source tree root for full license agreement. |
@@ -23,10 +23,9 @@ | |||
23 | * | 23 | * |
24 | ****************************************************************************/ | 24 | ****************************************************************************/ |
25 | 25 | ||
26 | #ifndef SIMULATOR /* not for simulator by now */ | ||
27 | #include "plugin.h" | 26 | #include "plugin.h" |
28 | 27 | ||
29 | #ifdef HAVE_LCD_BITMAP /* and also not for the Player */ | 28 | #ifdef HAVE_LCD_BITMAP |
30 | #include "gray.h" | 29 | #include "gray.h" |
31 | 30 | ||
32 | /*** low-level drawing functions ***/ | 31 | /*** low-level drawing functions ***/ |
@@ -587,6 +586,26 @@ void gray_putsxy(int x, int y, const unsigned char *str) | |||
587 | 586 | ||
588 | /*** Unbuffered drawing functions ***/ | 587 | /*** Unbuffered drawing functions ***/ |
589 | 588 | ||
589 | #ifdef SIMULATOR | ||
590 | |||
591 | /* Clear the greyscale display (sets all pixels to white) */ | ||
592 | void gray_ub_clear_display(void) | ||
593 | { | ||
594 | _gray_rb->memset(_gray_info.cur_buffer, _gray_info.depth, | ||
595 | MULU16(_gray_info.width, _gray_info.height)); | ||
596 | gray_update(); | ||
597 | } | ||
598 | |||
599 | /* Draw a partial greyscale bitmap, canonical format */ | ||
600 | void gray_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | ||
601 | int stride, int x, int y, int width, int height) | ||
602 | { | ||
603 | gray_gray_bitmap_part(src, src_x, src_y, stride, x, y, width, height); | ||
604 | gray_update_rect(x, y, width, height); | ||
605 | } | ||
606 | |||
607 | #else /* !SIMULATOR */ | ||
608 | |||
590 | /* Clear the greyscale display (sets all pixels to white) */ | 609 | /* Clear the greyscale display (sets all pixels to white) */ |
591 | void gray_ub_clear_display(void) | 610 | void gray_ub_clear_display(void) |
592 | { | 611 | { |
@@ -1005,6 +1024,8 @@ void gray_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
1005 | while (dst < dst_end); | 1024 | while (dst < dst_end); |
1006 | } | 1025 | } |
1007 | 1026 | ||
1027 | #endif /* !SIMULATOR */ | ||
1028 | |||
1008 | /* Draw a full greyscale bitmap, canonical format */ | 1029 | /* Draw a full greyscale bitmap, canonical format */ |
1009 | void gray_ub_gray_bitmap(const unsigned char *src, int x, int y, int width, | 1030 | void gray_ub_gray_bitmap(const unsigned char *src, int x, int y, int width, |
1010 | int height) | 1031 | int height) |
@@ -1014,5 +1035,4 @@ void gray_ub_gray_bitmap(const unsigned char *src, int x, int y, int width, | |||
1014 | 1035 | ||
1015 | 1036 | ||
1016 | #endif /* HAVE_LCD_BITMAP */ | 1037 | #endif /* HAVE_LCD_BITMAP */ |
1017 | #endif /* !SIMULATOR */ | ||
1018 | 1038 | ||
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 @@ | |||
10 | * Greyscale framework | 10 | * Greyscale framework |
11 | * Parameter handling | 11 | * Parameter handling |
12 | * | 12 | * |
13 | * This is a generic framework to use grayscale display within Rockbox | 13 | * This is a generic framework to display up to 33 shades of grey |
14 | * plugins. It obviously does not work for the player. | 14 | * on low-depth bitmap LCDs (Archos b&w, Iriver 4-grey) within plugins. |
15 | * | 15 | * |
16 | * Copyright (C) 2004-2005 Jens Arnold | 16 | * Copyright (C) 2004-2006 Jens Arnold |
17 | * | 17 | * |
18 | * All files in this archive are subject to the GNU General Public License. | 18 | * All files in this archive are subject to the GNU General Public License. |
19 | * See the file COPYING in the source tree root for full license agreement. | 19 | * See the file COPYING in the source tree root for full license agreement. |
@@ -23,10 +23,9 @@ | |||
23 | * | 23 | * |
24 | ****************************************************************************/ | 24 | ****************************************************************************/ |
25 | 25 | ||
26 | #ifndef SIMULATOR /* not for simulator by now */ | ||
27 | #include "plugin.h" | 26 | #include "plugin.h" |
28 | 27 | ||
29 | #ifdef HAVE_LCD_BITMAP /* and also not for the Player */ | 28 | #ifdef HAVE_LCD_BITMAP |
30 | #include "gray.h" | 29 | #include "gray.h" |
31 | 30 | ||
32 | /* Set position of the top left corner of the greyscale overlay | 31 | /* Set position of the top left corner of the greyscale overlay |
@@ -37,7 +36,14 @@ void gray_set_position(int x, int by) | |||
37 | _gray_info.by = by; | 36 | _gray_info.by = by; |
38 | 37 | ||
39 | if (_gray_info.flags & _GRAY_RUNNING) | 38 | if (_gray_info.flags & _GRAY_RUNNING) |
39 | { | ||
40 | #ifdef SIMULATOR | ||
41 | gray_deferred_lcd_update(); | ||
42 | gray_update(); | ||
43 | #else | ||
40 | _gray_info.flags |= _GRAY_DEFERRED_UPDATE; | 44 | _gray_info.flags |= _GRAY_DEFERRED_UPDATE; |
45 | #endif | ||
46 | } | ||
41 | } | 47 | } |
42 | 48 | ||
43 | /* Set the draw mode for subsequent drawing operations */ | 49 | /* Set the draw mode for subsequent drawing operations */ |
@@ -103,5 +109,3 @@ int gray_getstringsize(const unsigned char *str, int *w, int *h) | |||
103 | } | 109 | } |
104 | 110 | ||
105 | #endif /* HAVE_LCD_BITMAP */ | 111 | #endif /* HAVE_LCD_BITMAP */ |
106 | #endif /* !SIMULATOR */ | ||
107 | |||
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 @@ | |||
10 | * Greyscale framework | 10 | * Greyscale framework |
11 | * Scrolling routines | 11 | * Scrolling routines |
12 | * | 12 | * |
13 | * This is a generic framework to use grayscale display within Rockbox | 13 | * This is a generic framework to display up to 33 shades of grey |
14 | * plugins. It obviously does not work for the player. | 14 | * on low-depth bitmap LCDs (Archos b&w, Iriver 4-grey) within plugins. |
15 | * | 15 | * |
16 | * Copyright (C) 2004-2005 Jens Arnold | 16 | * Copyright (C) 2004-2006 Jens Arnold |
17 | * | 17 | * |
18 | * All files in this archive are subject to the GNU General Public License. | 18 | * All files in this archive are subject to the GNU General Public License. |
19 | * See the file COPYING in the source tree root for full license agreement. | 19 | * See the file COPYING in the source tree root for full license agreement. |
@@ -23,10 +23,9 @@ | |||
23 | * | 23 | * |
24 | ****************************************************************************/ | 24 | ****************************************************************************/ |
25 | 25 | ||
26 | #ifndef SIMULATOR /* not for simulator by now */ | ||
27 | #include "plugin.h" | 26 | #include "plugin.h" |
28 | 27 | ||
29 | #ifdef HAVE_LCD_BITMAP /* and also not for the Player */ | 28 | #ifdef HAVE_LCD_BITMAP |
30 | #include "gray.h" | 29 | #include "gray.h" |
31 | 30 | ||
32 | /*** Scrolling ***/ | 31 | /*** Scrolling ***/ |
@@ -117,6 +116,38 @@ void gray_scroll_down(int count) | |||
117 | 116 | ||
118 | /*** Unbuffered scrolling functions ***/ | 117 | /*** Unbuffered scrolling functions ***/ |
119 | 118 | ||
119 | #ifdef SIMULATOR | ||
120 | |||
121 | /* Scroll left */ | ||
122 | void gray_ub_scroll_left(int count) | ||
123 | { | ||
124 | gray_scroll_left(count); | ||
125 | gray_update(); | ||
126 | } | ||
127 | |||
128 | /* Scroll right */ | ||
129 | void gray_ub_scroll_right(int count) | ||
130 | { | ||
131 | gray_scroll_right(count); | ||
132 | gray_update(); | ||
133 | } | ||
134 | |||
135 | /* Scroll up */ | ||
136 | void gray_ub_scroll_up(int count) | ||
137 | { | ||
138 | gray_scroll_up(count); | ||
139 | gray_update(); | ||
140 | } | ||
141 | |||
142 | /* Scroll down */ | ||
143 | void gray_ub_scroll_down(int count) | ||
144 | { | ||
145 | gray_scroll_down(count); | ||
146 | gray_update(); | ||
147 | } | ||
148 | |||
149 | #else /* !SIMULATOR */ | ||
150 | |||
120 | /* Scroll left */ | 151 | /* Scroll left */ |
121 | void gray_ub_scroll_left(int count) | 152 | void gray_ub_scroll_left(int count) |
122 | { | 153 | { |
@@ -545,7 +576,7 @@ void gray_ub_scroll_down(int count) | |||
545 | #endif | 576 | #endif |
546 | } | 577 | } |
547 | } | 578 | } |
579 | #endif /* !SIMULATOR */ | ||
548 | 580 | ||
549 | #endif /* HAVE_LCD_BITMAP */ | 581 | #endif /* HAVE_LCD_BITMAP */ |
550 | #endif /* !SIMULATOR */ | ||
551 | 582 | ||
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 @@ | |||
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include "plugin.h" | 21 | #include "plugin.h" |
22 | 22 | ||
23 | #if defined(HAVE_LCD_BITMAP) && ((LCD_DEPTH >= 8) || !defined(SIMULATOR)) | 23 | #ifdef HAVE_LCD_BITMAP |
24 | #include "gray.h" | 24 | #include "gray.h" |
25 | #include "xlcd.h" | 25 | #include "xlcd.h" |
26 | 26 | ||
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 @@ | |||
24 | 24 | ||
25 | #include "plugin.h" | 25 | #include "plugin.h" |
26 | 26 | ||
27 | #if defined(HAVE_LCD_BITMAP) && (defined(HAVE_LCD_COLOR) || !defined(SIMULATOR)) | 27 | #ifdef HAVE_LCD_BITMAP |
28 | 28 | ||
29 | #ifndef HAVE_LCD_COLOR | 29 | #ifndef HAVE_LCD_COLOR |
30 | #include "gray.h" | 30 | #include "gray.h" |
@@ -336,4 +336,4 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
336 | return ret; | 336 | return ret; |
337 | } | 337 | } |
338 | 338 | ||
339 | #endif // HAVE_LCD_BITMAP && (HAVE_LCD_COLOR || !SIMULATOR) | 339 | #endif /* HAVE_LCD_BITMAP */ |
diff --git a/uisimulator/sdl/lcd-bitmap.c b/uisimulator/sdl/lcd-bitmap.c index 2fd7576ecc..788a5f662d 100644 --- a/uisimulator/sdl/lcd-bitmap.c +++ b/uisimulator/sdl/lcd-bitmap.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include "lcd-sdl.h" | 22 | #include "lcd-sdl.h" |
23 | 23 | ||
24 | SDL_Surface* lcd_surface; | 24 | SDL_Surface* lcd_surface; |
25 | int lcd_backlight_val; | ||
25 | 26 | ||
26 | #if LCD_DEPTH <= 8 | 27 | #if LCD_DEPTH <= 8 |
27 | SDL_Color lcd_color_zero = {UI_LCD_BGCOLOR, 0}; | 28 | SDL_Color lcd_color_zero = {UI_LCD_BGCOLOR, 0}; |
@@ -29,22 +30,27 @@ SDL_Color lcd_backlight_color_zero = {UI_LCD_BGCOLORLIGHT, 0}; | |||
29 | SDL_Color lcd_color_max = {0, 0, 0, 0}; | 30 | SDL_Color lcd_color_max = {0, 0, 0, 0}; |
30 | #endif | 31 | #endif |
31 | 32 | ||
32 | static inline Uint32 get_lcd_pixel(int x, int y) | 33 | #if LCD_DEPTH < 8 |
34 | int lcd_ex_shades = 0; | ||
35 | unsigned long (*lcd_ex_getpixel)(int, int) = NULL; | ||
36 | #endif | ||
37 | |||
38 | static unsigned long get_lcd_pixel(int x, int y) | ||
33 | { | 39 | { |
34 | #if LCD_DEPTH == 1 | 40 | #if LCD_DEPTH == 1 |
35 | return ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1); | 41 | return ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1); |
36 | #elif LCD_DEPTH == 2 | 42 | #elif LCD_DEPTH == 2 |
37 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING | 43 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING |
38 | return ((lcd_framebuffer[y][x/4] >> (2 * (x & 3))) & 3); | 44 | return ((lcd_framebuffer[y][x/4] >> (2 * (x & 3))) & 3); |
39 | #else | 45 | #else |
40 | return ((lcd_framebuffer[y/4][x] >> (2 * (y & 3))) & 3); | 46 | return ((lcd_framebuffer[y/4][x] >> (2 * (y & 3))) & 3); |
41 | #endif | 47 | #endif |
42 | #elif LCD_DEPTH == 16 | 48 | #elif LCD_DEPTH == 16 |
43 | #if LCD_PIXELFORMAT == RGB565SWAPPED | 49 | #if LCD_PIXELFORMAT == RGB565SWAPPED |
44 | unsigned bits = lcd_framebuffer[y][x]; | 50 | unsigned bits = lcd_framebuffer[y][x]; |
45 | return (bits >> 8) | (bits << 8); | 51 | return (bits >> 8) | (bits << 8); |
46 | #else | 52 | #else |
47 | return lcd_framebuffer[y][x]; | 53 | return lcd_framebuffer[y][x]; |
48 | #endif | 54 | #endif |
49 | #endif | 55 | #endif |
50 | } | 56 | } |
@@ -57,22 +63,41 @@ void lcd_update(void) | |||
57 | 63 | ||
58 | void lcd_update_rect(int x_start, int y_start, int width, int height) | 64 | void lcd_update_rect(int x_start, int y_start, int width, int height) |
59 | { | 65 | { |
60 | sdl_update_rect(lcd_surface, x_start, y_start, width, height, LCD_WIDTH, LCD_HEIGHT, | 66 | sdl_update_rect(lcd_surface, x_start, y_start, width, height, LCD_WIDTH, |
61 | background ? UI_LCD_POSX : 0, background? UI_LCD_POSY : 0, | 67 | LCD_HEIGHT, get_lcd_pixel); |
62 | get_lcd_pixel); | 68 | sdl_gui_update(lcd_surface, x_start, y_start, width, height, LCD_WIDTH, |
69 | LCD_HEIGHT, background ? UI_LCD_POSX : 0, background? UI_LCD_POSY : 0); | ||
63 | } | 70 | } |
64 | 71 | ||
65 | #ifdef CONFIG_BACKLIGHT | 72 | #ifdef CONFIG_BACKLIGHT |
66 | void sim_backlight(int value) | 73 | void sim_backlight(int value) |
67 | { | 74 | { |
75 | lcd_backlight_val = value; | ||
76 | |||
68 | #if LCD_DEPTH <= 8 | 77 | #if LCD_DEPTH <= 8 |
69 | if (value > 0) { | 78 | if (value > 0) { |
70 | sdl_set_gradient(lcd_surface, &lcd_backlight_color_zero, &lcd_color_max, (1<<LCD_DEPTH)); | 79 | sdl_set_gradient(lcd_surface, &lcd_backlight_color_zero, |
80 | &lcd_color_max, 0, (1<<LCD_DEPTH)); | ||
71 | } else { | 81 | } else { |
72 | sdl_set_gradient(lcd_surface, &lcd_color_zero, &lcd_color_max, (1<<LCD_DEPTH)); | 82 | sdl_set_gradient(lcd_surface, &lcd_color_zero, &lcd_color_max, |
83 | 0, (1<<LCD_DEPTH)); | ||
73 | } | 84 | } |
74 | 85 | #if LCD_DEPTH < 8 | |
75 | lcd_update(); | 86 | if (lcd_ex_shades) { |
87 | if (value > 0) { | ||
88 | sdl_set_gradient(lcd_surface, &lcd_color_max, | ||
89 | &lcd_backlight_color_zero, (1<<LCD_DEPTH), | ||
90 | lcd_ex_shades); | ||
91 | } else { | ||
92 | sdl_set_gradient(lcd_surface, &lcd_color_max, &lcd_color_zero, | ||
93 | (1<<LCD_DEPTH), lcd_ex_shades); | ||
94 | } | ||
95 | } | ||
96 | #endif | ||
97 | |||
98 | sdl_gui_update(lcd_surface, 0, 0, LCD_WIDTH, LCD_HEIGHT, LCD_WIDTH, | ||
99 | LCD_HEIGHT, background ? UI_LCD_POSX : 0, background? UI_LCD_POSY : 0); | ||
100 | |||
76 | #else | 101 | #else |
77 | DEBUGF("backlight: %s\n", (value > 0) ? "on" : "off"); | 102 | DEBUGF("backlight: %s\n", (value > 0) ? "on" : "off"); |
78 | #endif | 103 | #endif |
@@ -91,7 +116,41 @@ void sim_lcd_init(void) | |||
91 | #endif | 116 | #endif |
92 | 117 | ||
93 | #if LCD_DEPTH <= 8 | 118 | #if LCD_DEPTH <= 8 |
94 | sdl_set_gradient(lcd_surface, &lcd_color_zero, &lcd_color_max, (1<<LCD_DEPTH)); | 119 | sdl_set_gradient(lcd_surface, &lcd_backlight_color_zero, &lcd_color_max, |
120 | 0, (1<<LCD_DEPTH)); | ||
121 | #endif | ||
122 | } | ||
123 | |||
124 | #if LCD_DEPTH < 8 | ||
125 | void sim_lcd_ex_init(int shades, unsigned long (*getpixel)(int, int)) | ||
126 | { | ||
127 | lcd_ex_shades = shades; | ||
128 | lcd_ex_getpixel = getpixel; | ||
129 | if (shades) { | ||
130 | #ifdef CONFIG_BACKLIGHT | ||
131 | if (lcd_backlight_val > 0) { | ||
132 | sdl_set_gradient(lcd_surface, &lcd_color_max, | ||
133 | &lcd_backlight_color_zero, (1<<LCD_DEPTH), | ||
134 | shades); | ||
135 | } | ||
136 | else | ||
95 | #endif | 137 | #endif |
138 | { | ||
139 | sdl_set_gradient(lcd_surface, &lcd_color_max, &lcd_color_zero, | ||
140 | (1<<LCD_DEPTH), shades); | ||
141 | } | ||
142 | } | ||
96 | } | 143 | } |
97 | 144 | ||
145 | void sim_lcd_ex_update_rect(int x_start, int y_start, int width, int height) | ||
146 | { | ||
147 | if (lcd_ex_getpixel) { | ||
148 | sdl_update_rect(lcd_surface, x_start, y_start, width, height, | ||
149 | LCD_WIDTH, LCD_HEIGHT, lcd_ex_getpixel); | ||
150 | sdl_gui_update(lcd_surface, x_start, y_start, width, height, LCD_WIDTH, | ||
151 | LCD_HEIGHT, background ? UI_LCD_POSX : 0, | ||
152 | background? UI_LCD_POSY : 0); | ||
153 | } | ||
154 | } | ||
155 | #endif | ||
156 | |||
diff --git a/uisimulator/sdl/lcd-bitmap.h b/uisimulator/sdl/lcd-bitmap.h index 514c4d3ffb..31403385b9 100644 --- a/uisimulator/sdl/lcd-bitmap.h +++ b/uisimulator/sdl/lcd-bitmap.h | |||
@@ -24,6 +24,10 @@ | |||
24 | #include "SDL.h" | 24 | #include "SDL.h" |
25 | 25 | ||
26 | void sim_lcd_init(void); | 26 | void sim_lcd_init(void); |
27 | #if LCD_DEPTH < 8 | ||
28 | void sim_lcd_ex_init(int shades, unsigned long (*getpixel)(int, int)); | ||
29 | void sim_lcd_ex_update_rect(int x, int y, int width, int height); | ||
30 | #endif | ||
27 | 31 | ||
28 | #endif // #ifndef __LCDBITMAP_H__ | 32 | #endif // #ifndef __LCDBITMAP_H__ |
29 | 33 | ||
diff --git a/uisimulator/sdl/lcd-charcell.c b/uisimulator/sdl/lcd-charcell.c index 2ef86d0baf..89c46f7738 100644 --- a/uisimulator/sdl/lcd-charcell.c +++ b/uisimulator/sdl/lcd-charcell.c | |||
@@ -109,9 +109,11 @@ void drawrectangles(int color, struct rectangle *points, int count) | |||
109 | void sim_backlight(int value) | 109 | void sim_backlight(int value) |
110 | { | 110 | { |
111 | if (value > 0) { | 111 | if (value > 0) { |
112 | sdl_set_gradient(lcd_surface, &lcd_backlight_color_zero, &lcd_color_max, (1<<LCD_DEPTH)); | 112 | sdl_set_gradient(lcd_surface, &lcd_backlight_color_zero, &lcd_color_max, |
113 | 0, (1<<LCD_DEPTH)); | ||
113 | } else { | 114 | } else { |
114 | sdl_set_gradient(lcd_surface, &lcd_color_zero, &lcd_color_max, (1<<LCD_DEPTH)); | 115 | sdl_set_gradient(lcd_surface, &lcd_color_zero, &lcd_color_max, |
116 | 0, (1<<LCD_DEPTH)); | ||
115 | } | 117 | } |
116 | 118 | ||
117 | lcd_update(); | 119 | lcd_update(); |
@@ -124,6 +126,7 @@ void sim_lcd_init(void) | |||
124 | lcd_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, LCD_WIDTH * display_zoom, | 126 | lcd_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, LCD_WIDTH * display_zoom, |
125 | LCD_HEIGHT * display_zoom, 8, 0, 0, 0, 0); | 127 | LCD_HEIGHT * display_zoom, 8, 0, 0, 0, 0); |
126 | 128 | ||
127 | sdl_set_gradient(lcd_surface, &lcd_color_zero, &lcd_color_max, (1<<LCD_DEPTH)); | 129 | sdl_set_gradient(lcd_surface, &lcd_backlight_color_zero, &lcd_color_max, |
130 | 0, (1<<LCD_DEPTH)); | ||
128 | } | 131 | } |
129 | 132 | ||
diff --git a/uisimulator/sdl/lcd-remote.c b/uisimulator/sdl/lcd-remote.c index 64b641ad6d..f1d04b33f8 100644 --- a/uisimulator/sdl/lcd-remote.c +++ b/uisimulator/sdl/lcd-remote.c | |||
@@ -41,19 +41,26 @@ void lcd_remote_update (void) | |||
41 | void lcd_remote_update_rect(int x_start, int y_start, int width, int height) | 41 | void lcd_remote_update_rect(int x_start, int y_start, int width, int height) |
42 | { | 42 | { |
43 | sdl_update_rect(remote_surface, x_start, y_start, width, height, | 43 | sdl_update_rect(remote_surface, x_start, y_start, width, height, |
44 | LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT, get_lcd_remote_pixel); | ||
45 | sdl_gui_update(remote_surface, x_start, y_start, width, height, | ||
44 | LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT, background ? UI_REMOTE_POSX : 0, | 46 | LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT, background ? UI_REMOTE_POSX : 0, |
45 | (background ? UI_REMOTE_POSY : LCD_HEIGHT), get_lcd_remote_pixel); | 47 | background ? UI_REMOTE_POSY : LCD_HEIGHT); |
46 | } | 48 | } |
47 | 49 | ||
48 | void sim_remote_backlight(int value) | 50 | void sim_remote_backlight(int value) |
49 | { | 51 | { |
50 | if (value > 0) { | 52 | if (value > 0) { |
51 | sdl_set_gradient(remote_surface, &remote_backlight_color_zero, &remote_color_max, (1<<LCD_REMOTE_DEPTH)); | 53 | sdl_set_gradient(remote_surface, &remote_backlight_color_zero, |
54 | &remote_color_max, 0, (1<<LCD_REMOTE_DEPTH)); | ||
52 | } else { | 55 | } else { |
53 | sdl_set_gradient(remote_surface, &remote_color_zero, &remote_color_max, (1<<LCD_REMOTE_DEPTH)); | 56 | sdl_set_gradient(remote_surface, &remote_color_zero, &remote_color_max, |
57 | 0, (1<<LCD_REMOTE_DEPTH)); | ||
54 | } | 58 | } |
55 | 59 | ||
56 | lcd_remote_update(); | 60 | sdl_gui_update(remote_surface, 0, 0, LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT, |
61 | LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT, | ||
62 | background ? UI_REMOTE_POSX : 0, | ||
63 | background? UI_REMOTE_POSY : LCD_HEIGHT); | ||
57 | } | 64 | } |
58 | 65 | ||
59 | /* initialise simulator lcd remote driver */ | 66 | /* initialise simulator lcd remote driver */ |
@@ -63,7 +70,7 @@ void sim_lcd_remote_init(void) | |||
63 | LCD_REMOTE_WIDTH * display_zoom, LCD_REMOTE_HEIGHT * display_zoom, | 70 | LCD_REMOTE_WIDTH * display_zoom, LCD_REMOTE_HEIGHT * display_zoom, |
64 | 8, 0, 0, 0, 0); | 71 | 8, 0, 0, 0, 0); |
65 | 72 | ||
66 | sdl_set_gradient(remote_surface, &remote_color_zero, &remote_color_max, | 73 | sdl_set_gradient(remote_surface, &remote_backlight_color_zero, |
67 | (1<<LCD_REMOTE_DEPTH)); | 74 | &remote_color_max, 0, (1<<LCD_REMOTE_DEPTH)); |
68 | } | 75 | } |
69 | 76 | ||
diff --git a/uisimulator/sdl/lcd-sdl.c b/uisimulator/sdl/lcd-sdl.c index 3327dd8350..be10b468cb 100644 --- a/uisimulator/sdl/lcd-sdl.c +++ b/uisimulator/sdl/lcd-sdl.c | |||
@@ -23,8 +23,8 @@ | |||
23 | int display_zoom = 1; | 23 | int display_zoom = 1; |
24 | 24 | ||
25 | void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width, | 25 | void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width, |
26 | int height, int max_x, int max_y, int ui_x, int ui_y, | 26 | int height, int max_x, int max_y, |
27 | Uint32 (*getpixel)(int, int)) | 27 | unsigned long (*getpixel)(int, int)) |
28 | { | 28 | { |
29 | int x, y; | 29 | int x, y; |
30 | int xmax, ymax; | 30 | int xmax, ymax; |
@@ -49,25 +49,39 @@ void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width, | |||
49 | for (y = y_start; y < ymax; y++) { | 49 | for (y = y_start; y < ymax; y++) { |
50 | dest.y = y * display_zoom; | 50 | dest.y = y * display_zoom; |
51 | 51 | ||
52 | SDL_FillRect(surface, &dest, getpixel(x, y)); | 52 | SDL_FillRect(surface, &dest, (Uint32)getpixel(x, y)); |
53 | } | 53 | } |
54 | } | 54 | } |
55 | 55 | ||
56 | SDL_UnlockSurface(surface); | 56 | SDL_UnlockSurface(surface); |
57 | } | ||
58 | |||
59 | void sdl_gui_update(SDL_Surface *surface, int x_start, int y_start, int width, | ||
60 | int height, int max_x, int max_y, int ui_x, int ui_y) | ||
61 | { | ||
62 | int xmax, ymax; | ||
63 | |||
64 | ymax = y_start + height; | ||
65 | xmax = x_start + width; | ||
66 | |||
67 | if(xmax > max_x) | ||
68 | xmax = max_x; | ||
69 | if(ymax >= max_y) | ||
70 | ymax = max_y; | ||
71 | |||
72 | SDL_Rect src = {x_start * display_zoom, y_start * display_zoom, | ||
73 | xmax * display_zoom, ymax * display_zoom}; | ||
74 | SDL_Rect dest= {(ui_x + x_start) * display_zoom, (ui_y + y_start) * display_zoom, | ||
75 | xmax * display_zoom, ymax * display_zoom}; | ||
57 | 76 | ||
58 | SDL_Rect src = {x_start * display_zoom, y_start * display_zoom, xmax * display_zoom, ymax * display_zoom}; | ||
59 | dest.x = (ui_x + x_start) * display_zoom; | ||
60 | dest.y = (ui_y + y_start) * display_zoom;; | ||
61 | dest.w = xmax * display_zoom; | ||
62 | dest.h = ymax * display_zoom; | ||
63 | |||
64 | SDL_BlitSurface(surface, &src, gui_surface, &dest); | 77 | SDL_BlitSurface(surface, &src, gui_surface, &dest); |
65 | SDL_UpdateRect(gui_surface, dest.x, dest.y, dest.w, dest.h); | 78 | SDL_UpdateRect(gui_surface, dest.x, dest.y, dest.w, dest.h); |
66 | SDL_Flip(gui_surface); | 79 | SDL_Flip(gui_surface); |
67 | } | 80 | } |
68 | 81 | ||
69 | /* set a range of bitmap indices to a gradient from startcolour to endcolour */ | 82 | /* set a range of bitmap indices to a gradient from startcolour to endcolour */ |
70 | void sdl_set_gradient(SDL_Surface *surface, SDL_Color *start, SDL_Color *end, int steps) | 83 | void sdl_set_gradient(SDL_Surface *surface, SDL_Color *start, SDL_Color *end, |
84 | int first, int steps) | ||
71 | { | 85 | { |
72 | int i; | 86 | int i; |
73 | SDL_Color palette[steps]; | 87 | SDL_Color palette[steps]; |
@@ -78,6 +92,6 @@ void sdl_set_gradient(SDL_Surface *surface, SDL_Color *start, SDL_Color *end, in | |||
78 | palette[i].b = start->b + (end->b - start->b) * i / (steps - 1); | 92 | palette[i].b = start->b + (end->b - start->b) * i / (steps - 1); |
79 | } | 93 | } |
80 | 94 | ||
81 | SDL_SetPalette(surface, SDL_LOGPAL|SDL_PHYSPAL, palette, 0, steps); | 95 | SDL_SetPalette(surface, SDL_LOGPAL|SDL_PHYSPAL, palette, first, steps); |
82 | } | 96 | } |
83 | 97 | ||
diff --git a/uisimulator/sdl/lcd-sdl.h b/uisimulator/sdl/lcd-sdl.h index d371639a64..10c2ea74b5 100644 --- a/uisimulator/sdl/lcd-sdl.h +++ b/uisimulator/sdl/lcd-sdl.h | |||
@@ -27,11 +27,14 @@ | |||
27 | extern int display_zoom; | 27 | extern int display_zoom; |
28 | 28 | ||
29 | void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width, | 29 | void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width, |
30 | int height, int max_x, int max_y, int ui_x, int ui_y, | 30 | int height, int max_x, int max_y, |
31 | Uint32 (*getpixel)(int, int)); | 31 | unsigned long (*getpixel)(int, int)); |
32 | |||
33 | void sdl_gui_update(SDL_Surface *surface, int x_start, int y_start, int width, | ||
34 | int height, int max_x, int max_y, int ui_x, int ui_y); | ||
32 | 35 | ||
33 | void sdl_set_gradient(SDL_Surface *surface, SDL_Color *start, SDL_Color *end, | 36 | void sdl_set_gradient(SDL_Surface *surface, SDL_Color *start, SDL_Color *end, |
34 | int steps); | 37 | int first, int steps); |
35 | 38 | ||
36 | #endif // #ifndef __LCDSDL_H__ | 39 | #endif // #ifndef __LCDSDL_H__ |
37 | 40 | ||