diff options
Diffstat (limited to 'apps/plugins/lib/gray.h')
-rw-r--r-- | apps/plugins/lib/gray.h | 484 |
1 files changed, 87 insertions, 397 deletions
diff --git a/apps/plugins/lib/gray.h b/apps/plugins/lib/gray.h index 52d6f6c0df..8abf7bc16d 100644 --- a/apps/plugins/lib/gray.h +++ b/apps/plugins/lib/gray.h | |||
@@ -7,12 +7,12 @@ | |||
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Grayscale framework | 10 | * Greyscale framework |
11 | * | 11 | * |
12 | * This is a generic framework to use grayscale display within Rockbox | 12 | * This is a generic framework to use greyscale display within Rockbox |
13 | * plugins. It obviously does not work for the player. | 13 | * plugins. It does not work for the player. |
14 | * | 14 | * |
15 | * Copyright (C) 2004 Jens Arnold | 15 | * Copyright (C) 2004-2005 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. |
@@ -30,401 +30,94 @@ | |||
30 | 30 | ||
31 | #ifdef HAVE_LCD_BITMAP /* and also not for the Player */ | 31 | #ifdef HAVE_LCD_BITMAP /* and also not for the Player */ |
32 | 32 | ||
33 | /*=========================================================================== | 33 | #define GRAY_MAX_LEVEL 255 /* The real value is variable, so normalise */ |
34 | Public functions and definitions, to be used within plugins | 34 | #define GRAY_BLACK 0 |
35 | ============================================================================ | 35 | #define GRAY_WHITE GRAY_MAX_LEVEL |
36 | */ | ||
37 | 36 | ||
38 | /*--------------------------------------------------------------------------- | 37 | /* Library initialisation and release */ |
39 | Initialize the framework | 38 | int gray_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, |
40 | ---------------------------------------------------------------------------- | 39 | bool buffered, int width, int bheight, int depth, long *buf_taken); |
41 | every framework needs such a function, and it has to be called as the very | 40 | void gray_release(void); |
42 | first one | ||
43 | */ | ||
44 | void gray_init(struct plugin_api* newrb); | ||
45 | 41 | ||
46 | /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 42 | /* Special functions */ |
47 | General functions | 43 | void gray_show(bool enable); |
48 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 44 | void gray_deferred_lcd_update(void); |
49 | */ | 45 | void gray_screendump(void); |
50 | |||
51 | /*--------------------------------------------------------------------------- | ||
52 | Prepare the grayscale display buffer | ||
53 | ---------------------------------------------------------------------------- | ||
54 | arguments: | ||
55 | gbuf = pointer to the memory area to use (e.g. plugin buffer) | ||
56 | gbuf_size = max usable size of the buffer | ||
57 | width = width in pixels (1..112) | ||
58 | bheight = height in 8-pixel units (1..8) | ||
59 | depth = desired number of shades - 1 (1..32) | ||
60 | |||
61 | result: | ||
62 | = depth if there was enough memory | ||
63 | < depth if there wasn't enough memory. The number of displayable | ||
64 | shades is smaller than desired, but it still works | ||
65 | = 0 if there wasn't even enough memory for 1 bitplane (black & white) | ||
66 | |||
67 | You can request any depth from 1 to 32, not just powers of 2. The routine | ||
68 | performs "graceful degradation" if the memory is not sufficient for the | ||
69 | desired depth. As long as there is at least enough memory for 1 bitplane, | ||
70 | it creates as many bitplanes as fit into memory, although 1 bitplane will | ||
71 | only deliver black & white display. | ||
72 | |||
73 | If you need info about the memory taken by the grayscale buffer, supply an | ||
74 | int* as the last parameter. This int will then contain the number of bytes | ||
75 | used. The total memory needed can be calculated as follows: | ||
76 | total_mem = | ||
77 | sizeof(_tGraybuf) (= 64 bytes currently) | ||
78 | + sizeof(long) (= 4 bytes) | ||
79 | + (width * bheight + sizeof(long)) * depth | ||
80 | + 0..3 (longword alignment of grayscale display buffer) | ||
81 | */ | ||
82 | int gray_init_buffer(unsigned char *gbuf, int gbuf_size, int width, | ||
83 | int bheight, int depth, int *buf_taken); | ||
84 | |||
85 | /*--------------------------------------------------------------------------- | ||
86 | Release the grayscale display buffer | ||
87 | ---------------------------------------------------------------------------- | ||
88 | Switches the grayscale overlay off at first if it is still running, | ||
89 | then sets the pointer to NULL. | ||
90 | DO CALL either this function or at least gray_show_display(false) | ||
91 | before you exit, otherwise nasty things may happen. | ||
92 | */ | ||
93 | void gray_release_buffer(void); | ||
94 | |||
95 | /*--------------------------------------------------------------------------- | ||
96 | Switch the grayscale overlay on or off | ||
97 | ---------------------------------------------------------------------------- | ||
98 | enable = true: the grayscale overlay is switched on if initialized | ||
99 | = false: the grayscale overlay is switched off and the regular lcd | ||
100 | content is restored | ||
101 | |||
102 | DO NOT call lcd_update() or any other api function that directly accesses | ||
103 | the lcd while the grayscale overlay is running! If you need to do | ||
104 | lcd_update() to update something outside the grayscale overlay area, use | ||
105 | gray_deferred_update() instead. | ||
106 | |||
107 | Other functions to avoid are: | ||
108 | lcd_blit() (obviously), lcd_update_rect(), lcd_set_contrast(), | ||
109 | lcd_set_invert_display(), lcd_set_flip(), lcd_roll() | ||
110 | |||
111 | The grayscale display consumes ~50 % CPU power (for a full screen overlay, | ||
112 | less if the overlay is smaller) when switched on. You can switch the overlay | ||
113 | on and off as many times as you want. | ||
114 | */ | ||
115 | void gray_show_display(bool enable); | ||
116 | |||
117 | /*--------------------------------------------------------------------------- | ||
118 | Set position of the top left corner of the grayscale overlay | ||
119 | ---------------------------------------------------------------------------- | ||
120 | x = left margin in pixels | ||
121 | by = top margin in 8-pixel units | ||
122 | |||
123 | You may set this in a way that the overlay spills across the right or | ||
124 | bottom display border. In this case it will simply be clipped by the | ||
125 | LCD controller. You can even set negative values, this will clip at the | ||
126 | left or top border. I did not test it, but the limits may be +127 / -128 | ||
127 | |||
128 | If you use this while the grayscale overlay is running, the now-freed area | ||
129 | will be restored. | ||
130 | */ | ||
131 | void gray_position_display(int x, int by); | ||
132 | |||
133 | /*--------------------------------------------------------------------------- | ||
134 | Set the draw mode for subsequent drawing operations | ||
135 | ---------------------------------------------------------------------------- | ||
136 | drawmode = | ||
137 | GRAY_DRAW_INVERSE: Foreground pixels are inverted, background pixels are | ||
138 | left untouched | ||
139 | GRAY_DRAW_FG: Only foreground pixels are drawn | ||
140 | GRAY_DRAW_BG: Only background pixels are drawn | ||
141 | GRAY_DRAW_SOLID: Foreground and background pixels are drawn | ||
142 | |||
143 | Default after initialization: GRAY_DRAW_SOLID | ||
144 | */ | ||
145 | void gray_set_drawmode(int drawmode); | ||
146 | |||
147 | /*--------------------------------------------------------------------------- | ||
148 | Draw modes, see above | ||
149 | ---------------------------------------------------------------------------- | ||
150 | */ | ||
151 | #define GRAY_DRAW_INVERSE 0 | ||
152 | #define GRAY_DRAW_FG 1 | ||
153 | #define GRAY_DRAW_BG 2 | ||
154 | #define GRAY_DRAW_SOLID 3 | ||
155 | 46 | ||
156 | /*--------------------------------------------------------------------------- | 47 | /* Update functions */ |
157 | Set the foreground shade for subsequent drawing operations | 48 | void gray_update(void); |
158 | ---------------------------------------------------------------------------- | 49 | void gray_update_rect(int x, int y, int width, int height); |
159 | brightness = 0 (black) .. 255 (white) | ||
160 | 50 | ||
161 | Default after initialization: 0 | 51 | /* Parameter handling */ |
162 | */ | 52 | void gray_set_position(int x, int by); |
53 | void gray_set_drawmode(int mode); | ||
54 | int gray_get_drawmode(void); | ||
163 | void gray_set_foreground(int brightness); | 55 | void gray_set_foreground(int brightness); |
164 | 56 | int gray_get_foreground(void); | |
165 | /*--------------------------------------------------------------------------- | ||
166 | Set the background shade for subsequent drawing operations | ||
167 | ---------------------------------------------------------------------------- | ||
168 | brightness = 0 (black) .. 255 (white) | ||
169 | |||
170 | Default after initialization: 255 | ||
171 | */ | ||
172 | void gray_set_background(int brightness); | 57 | void gray_set_background(int brightness); |
58 | int gray_get_background(void); | ||
59 | void gray_set_drawinfo(int mode, int fg_brightness, int bg_brightness); | ||
60 | void gray_setfont(int newfont); | ||
61 | int gray_getstringsize(const unsigned char *str, int *w, int *h); | ||
173 | 62 | ||
174 | /*--------------------------------------------------------------------------- | 63 | /* Whole display */ |
175 | Set draw mode, foreground and background shades at once | ||
176 | ---------------------------------------------------------------------------- | ||
177 | If you hand it -1 (or in fact any other out-of-bounds value) for a | ||
178 | parameter, that particular setting won't be changed | ||
179 | |||
180 | Default after initialization: GRAY_DRAW_SOLID, 0, 255 | ||
181 | */ | ||
182 | void gray_set_drawinfo(int drawmode, int fg_brightness, int bg_brightness); | ||
183 | |||
184 | /*--------------------------------------------------------------------------- | ||
185 | Save the current display content (b&w and grayscale overlay) to an 8-bit | ||
186 | BMP file in the root directory | ||
187 | ---------------------------------------------------------------------------- | ||
188 | * | ||
189 | * This one is rather slow if used with larger bit depths, but it's intended | ||
190 | * primary use is for documenting the grayscale plugins. A much faster version | ||
191 | * would be possible, but would take more than twice the RAM | ||
192 | */ | ||
193 | void gray_screendump(void); | ||
194 | |||
195 | /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
196 | Functions affecting the whole display | ||
197 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
198 | */ | ||
199 | |||
200 | /*--------------------------------------------------------------------------- | ||
201 | Clear the grayscale display (sets all pixels to white) | ||
202 | ---------------------------------------------------------------------------- | ||
203 | */ | ||
204 | void gray_clear_display(void); | 64 | void gray_clear_display(void); |
65 | void gray_ub_clear_display(void); | ||
205 | 66 | ||
206 | /*--------------------------------------------------------------------------- | 67 | /* Pixel */ |
207 | Set the grayscale display to all black | ||
208 | ---------------------------------------------------------------------------- | ||
209 | */ | ||
210 | void gray_black_display(void); | ||
211 | |||
212 | /*--------------------------------------------------------------------------- | ||
213 | Do an lcd_update() to show changes done by rb->lcd_xxx() functions (in areas | ||
214 | of the screen not covered by the grayscale overlay). | ||
215 | ---------------------------------------------------------------------------- | ||
216 | If the grayscale overlay is running, the update will be done in the next | ||
217 | call of the interrupt routine, otherwise it will be performed right away. | ||
218 | See also comment for the gray_show_display() function. | ||
219 | */ | ||
220 | void gray_deferred_update(void); | ||
221 | |||
222 | /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
223 | Scrolling functions | ||
224 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
225 | */ | ||
226 | |||
227 | /*--------------------------------------------------------------------------- | ||
228 | Scroll the whole grayscale buffer left by <count> pixels | ||
229 | ---------------------------------------------------------------------------- | ||
230 | black_border determines if the pixels scrolled in at the right are black | ||
231 | or white | ||
232 | |||
233 | Scrolling left/right by an even pixel count is almost twice as fast as | ||
234 | scrolling by an odd pixel count. | ||
235 | */ | ||
236 | void gray_scroll_left(int count, bool black_border); | ||
237 | |||
238 | /*--------------------------------------------------------------------------- | ||
239 | Scroll the whole grayscale buffer right by <count> pixels | ||
240 | ---------------------------------------------------------------------------- | ||
241 | black_border determines if the pixels scrolled in at the left are black | ||
242 | or white | ||
243 | |||
244 | Scrolling left/right by an even pixel count is almost twice as fast as | ||
245 | scrolling by an odd pixel count. | ||
246 | */ | ||
247 | void gray_scroll_right(int count, bool black_border); | ||
248 | |||
249 | /*--------------------------------------------------------------------------- | ||
250 | Scroll the whole grayscale buffer up by 8 pixels | ||
251 | ---------------------------------------------------------------------------- | ||
252 | black_border determines if the pixels scrolled in at the bottom are black | ||
253 | or white | ||
254 | |||
255 | Scrolling up/down by 8 pixels is very fast. | ||
256 | */ | ||
257 | void gray_scroll_up8(bool black_border); | ||
258 | |||
259 | /*--------------------------------------------------------------------------- | ||
260 | Scroll the whole grayscale buffer down by 8 pixels | ||
261 | ---------------------------------------------------------------------------- | ||
262 | black_border determines if the pixels scrolled in at the top are black | ||
263 | or white | ||
264 | |||
265 | Scrolling up/down by 8 pixels is very fast. | ||
266 | */ | ||
267 | void gray_scroll_down8(bool black_border); | ||
268 | |||
269 | /*--------------------------------------------------------------------------- | ||
270 | Scroll the whole grayscale buffer up by <count> pixels (<= 7) | ||
271 | ---------------------------------------------------------------------------- | ||
272 | black_border determines if the pixels scrolled in at the bottom are black | ||
273 | or white | ||
274 | |||
275 | Scrolling up/down pixel-wise is significantly slower than scrolling | ||
276 | left/right or scrolling up/down byte-wise because it involves bit | ||
277 | shifting. That's why it is asm optimized. | ||
278 | */ | ||
279 | void gray_scroll_up(int count, bool black_border); | ||
280 | |||
281 | /*--------------------------------------------------------------------------- | ||
282 | Scroll the whole grayscale buffer down by <count> pixels (<= 7) | ||
283 | ---------------------------------------------------------------------------- | ||
284 | black_border determines if the pixels scrolled in at the top are black | ||
285 | or white | ||
286 | |||
287 | Scrolling up/down pixel-wise is significantly slower than scrolling | ||
288 | left/right or scrolling up/down byte-wise because it involves bit | ||
289 | shifting. That's why it is asm optimized. | ||
290 | */ | ||
291 | void gray_scroll_down(int count, bool black_border); | ||
292 | |||
293 | /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
294 | Pixel and line functions | ||
295 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
296 | */ | ||
297 | |||
298 | /*--------------------------------------------------------------------------- | ||
299 | Set a pixel with the current drawinfo | ||
300 | ---------------------------------------------------------------------------- | ||
301 | If the drawmode is GRAY_DRAW_INVERSE, the pixel is inverted | ||
302 | GRAY_DRAW_FG and GRAY_DRAW_SOLID draw the pixel in the foreground shade | ||
303 | GRAY_DRAW_BG draws the pixel in the background shade | ||
304 | */ | ||
305 | void gray_drawpixel(int x, int y); | 68 | void gray_drawpixel(int x, int y); |
306 | 69 | ||
307 | /*--------------------------------------------------------------------------- | 70 | /* Lines */ |
308 | Draw a line from (x1, y1) to (x2, y2) with the current drawinfo | ||
309 | ---------------------------------------------------------------------------- | ||
310 | See gray_drawpixel() for details | ||
311 | */ | ||
312 | void gray_drawline(int x1, int y1, int x2, int y2); | 71 | void gray_drawline(int x1, int y1, int x2, int y2); |
313 | 72 | void gray_hline(int x1, int x2, int y); | |
314 | /*--------------------------------------------------------------------------- | 73 | void gray_vline(int x, int y1, int y2); |
315 | Draw a horizontal line from (x1, y) to (x2, y) with the current drawinfo | ||
316 | ---------------------------------------------------------------------------- | ||
317 | See gray_drawpixel() for details | ||
318 | */ | ||
319 | void gray_horline(int x1, int x2, int y); | ||
320 | |||
321 | /*--------------------------------------------------------------------------- | ||
322 | Draw a vertical line from (x, y1) to (x, y2) with the current drawinfo | ||
323 | ---------------------------------------------------------------------------- | ||
324 | See gray_drawpixel() for details | ||
325 | This one uses the block drawing optimization, so it is rather fast. | ||
326 | */ | ||
327 | void gray_verline(int x, int y1, int y2); | ||
328 | |||
329 | /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
330 | Rectangle functions | ||
331 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
332 | */ | ||
333 | |||
334 | /*--------------------------------------------------------------------------- | ||
335 | Draw a (hollow) rectangle with the current drawinfo | ||
336 | ---------------------------------------------------------------------------- | ||
337 | See gray_drawpixel() for details | ||
338 | */ | ||
339 | void gray_drawrect(int x, int y, int nx, int ny); | 74 | void gray_drawrect(int x, int y, int nx, int ny); |
340 | 75 | ||
341 | /*--------------------------------------------------------------------------- | 76 | /* Filled primitives */ |
342 | Draw a filled rectangle with the current drawinfo | ||
343 | ---------------------------------------------------------------------------- | ||
344 | See gray_drawpixel() for details | ||
345 | This one uses the block drawing optimization, so it is rather fast. | ||
346 | */ | ||
347 | void gray_fillrect(int x, int y, int nx, int ny); | 77 | void gray_fillrect(int x, int y, int nx, int ny); |
348 | 78 | void gray_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3); | |
349 | /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 79 | |
350 | Bitmap functions | 80 | /* Bitmaps */ |
351 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 81 | void gray_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, |
352 | */ | 82 | int stride, int x, int y, int width, int height); |
353 | 83 | void gray_mono_bitmap(const unsigned char *src, int x, int y, int width, | |
354 | /*--------------------------------------------------------------------------- | 84 | int height); |
355 | Copy a grayscale bitmap into the display | 85 | void gray_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, |
356 | ---------------------------------------------------------------------------- | 86 | int stride, int x, int y, int width, int height); |
357 | A grayscale bitmap contains one byte for every pixel that defines the | 87 | void gray_gray_bitmap(const unsigned char *src, int x, int y, int width, |
358 | brightness of the pixel (0..255). Bytes are read in row-major order. | 88 | int height); |
359 | The <stride> parameter is useful if you want to show only a part of a | 89 | void gray_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, |
360 | bitmap. It should always be set to the "row length" of the bitmap, so | 90 | int stride, int x, int y, int width, int height); |
361 | for displaying the whole bitmap, nx == stride. | 91 | void gray_ub_gray_bitmap(const unsigned char *src, int x, int y, int width, |
362 | 92 | int height); | |
363 | This is the only drawing function NOT using the drawinfo. | 93 | |
364 | */ | 94 | /* Text */ |
365 | void gray_drawgraymap(const unsigned char *src, int x, int y, int nx, int ny, | 95 | void gray_putsxyofs(int x, int y, int ofs, const unsigned char *str); |
366 | int stride); | ||
367 | |||
368 | /*--------------------------------------------------------------------------- | ||
369 | Display a bitmap with the current drawinfo | ||
370 | ---------------------------------------------------------------------------- | ||
371 | The drawmode is used as described for gray_set_drawmode() | ||
372 | |||
373 | This (now) uses the same bitmap format as the core b&w graphics routines, | ||
374 | so you can use bmp2rb to generate bitmaps for use with this function as | ||
375 | well. | ||
376 | |||
377 | A bitmap contains one bit for every pixel that defines if that pixel is | ||
378 | foreground (1) or background (0). Bits within a byte are arranged | ||
379 | vertically, LSB at top. | ||
380 | The bytes are stored in row-major order, with byte 0 being top left, | ||
381 | byte 1 2nd from left etc. The first row of bytes defines pixel rows | ||
382 | 0..7, the second row defines pixel row 8..15 etc. | ||
383 | |||
384 | The <stride> parameter is useful if you want to show only a part of a | ||
385 | bitmap. It should always be set to the "row length" of the bitmap. | ||
386 | */ | ||
387 | void gray_drawbitmap(const unsigned char *src, int x, int y, int nx, int ny, | ||
388 | int stride); | ||
389 | |||
390 | /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
391 | Font support | ||
392 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
393 | */ | ||
394 | |||
395 | /*--------------------------------------------------------------------------- | ||
396 | Set font for the font routines | ||
397 | ---------------------------------------------------------------------------- | ||
398 | newfont can be FONT_SYSFIXED or FONT_UI the same way as with the Rockbox | ||
399 | core routines | ||
400 | |||
401 | Default after initialization: FONT_SYSFIXED | ||
402 | */ | ||
403 | void gray_setfont(int newfont); | ||
404 | |||
405 | /*--------------------------------------------------------------------------- | ||
406 | Calculate width and height of the given text in pixels when rendered with | ||
407 | the currently selected font. | ||
408 | ---------------------------------------------------------------------------- | ||
409 | This works exactly the same way as the core lcd_getstringsize(), only that | ||
410 | it uses the selected font for grayscale. | ||
411 | */ | ||
412 | int gray_getstringsize(const unsigned char *str, int *w, int *h); | ||
413 | |||
414 | /*--------------------------------------------------------------------------- | ||
415 | Display text starting at (x, y) with the current font and drawinfo | ||
416 | ---------------------------------------------------------------------------- | ||
417 | The drawmode is used as described for gray_set_drawmode() | ||
418 | */ | ||
419 | void gray_putsxy(int x, int y, const unsigned char *str); | 96 | void gray_putsxy(int x, int y, const unsigned char *str); |
420 | 97 | ||
421 | /*=========================================================================== | 98 | /* Scrolling */ |
422 | Private functions and definitions, for use within the grayscale core only | 99 | void gray_scroll_left(int count); |
423 | ============================================================================ | 100 | void gray_scroll_right(int count); |
424 | */ | 101 | void gray_scroll_up(int count); |
102 | void gray_scroll_down(int count); | ||
103 | void gray_ub_scroll_left(int count); | ||
104 | void gray_ub_scroll_right(int count); | ||
105 | void gray_ub_scroll_up(int count); | ||
106 | void gray_ub_scroll_down(int count); | ||
107 | |||
108 | /*** Internal stuff ***/ | ||
109 | |||
110 | #if LCD_DEPTH == 1 | ||
111 | #define _PBLOCK_EXP 3 | ||
112 | #elif LCD_DEPTH == 2 | ||
113 | #define _PBLOCK_EXP 2 | ||
114 | #endif | ||
115 | #define _PBLOCK (1 << _PBLOCK_EXP) | ||
116 | #define _MAX_DEPTH (32 / LCD_DEPTH) | ||
117 | #define _LEVEL_FAC ((1 << LCD_DEPTH) - 1) | ||
425 | 118 | ||
426 | /* flag definitions */ | 119 | /* flag definitions */ |
427 | #define _GRAY_RUNNING 0x0001 /* grayscale overlay is running */ | 120 | #define _GRAY_RUNNING 0x0001 /* greyscale overlay is running */ |
428 | #define _GRAY_DEFERRED_UPDATE 0x0002 /* lcd_update() requested */ | 121 | #define _GRAY_DEFERRED_UPDATE 0x0002 /* lcd_update() requested */ |
429 | 122 | ||
430 | /* unsigned 16 bit multiplication (a single instruction on the SH) */ | 123 | /* unsigned 16 bit multiplication (a single instruction on the SH) */ |
@@ -432,36 +125,33 @@ void gray_putsxy(int x, int y, const unsigned char *str); | |||
432 | (((unsigned short) (a)) * ((unsigned short) (b)))) | 125 | (((unsigned short) (a)) * ((unsigned short) (b)))) |
433 | 126 | ||
434 | /* The grayscale buffer management structure */ | 127 | /* The grayscale buffer management structure */ |
435 | typedef struct | 128 | struct _gray_info |
436 | { | 129 | { |
437 | int x; | 130 | int x; |
438 | int by; /* 8-pixel units */ | 131 | int by; /* 8-pixel units */ |
439 | int width; | 132 | int width; |
440 | int height; | 133 | int height; |
441 | int bheight; /* 8-pixel units */ | 134 | int bheight; /* 8-pixel units */ |
442 | int plane_size; | ||
443 | int depth; /* number_of_bitplanes = (number_of_grayscales - 1) */ | 135 | int depth; /* number_of_bitplanes = (number_of_grayscales - 1) */ |
444 | int cur_plane; /* for the timer isr */ | 136 | int cur_plane; /* for the timer isr */ |
445 | unsigned long randmask; /* mask for random value in _writepixel() */ | ||
446 | unsigned long flags; /* various flags, see #defines */ | ||
447 | unsigned long *bitpattern; /* pointer to start of pattern table */ | ||
448 | unsigned char *data; /* pointer to start of bitplane data */ | ||
449 | unsigned long fg_pattern; /* current foreground pattern */ | ||
450 | unsigned long bg_pattern; /* current background pattern */ | ||
451 | int drawmode; /* current draw mode */ | 137 | int drawmode; /* current draw mode */ |
452 | struct font *curfont; /* current selected font */ | 138 | int fg_brightness; /* current foreground brightness */ |
453 | } _tGraybuf; | 139 | int bg_brightness; /* current background brightness */ |
140 | long plane_size; | ||
141 | unsigned long flags; /* various flags, see #defines */ | ||
142 | unsigned long randmask; /* mask for random value in _writepixel() */ | ||
143 | unsigned long *bitpattern; /* start of pattern table */ | ||
144 | unsigned char *plane_data; /* start of bitplane data */ | ||
145 | unsigned char *cur_buffer; /* start of current chunky pixel buffer */ | ||
146 | unsigned char *back_buffer;/* start of chunky pixel back buffer */ | ||
147 | int curfont; /* current selected font */ | ||
148 | }; | ||
454 | 149 | ||
455 | /* Global variables */ | 150 | /* Global variables */ |
456 | extern struct plugin_api *_gray_rb; | 151 | extern struct plugin_api *_gray_rb; |
457 | extern _tGraybuf *_graybuf; | 152 | extern struct _gray_info _gray_info; |
458 | extern short _gray_random_buffer; | 153 | extern short _gray_random_buffer; |
459 | 154 | ||
460 | /* Global function pointers */ | ||
461 | extern void (* const _gray_pixelfuncs[4])(int x, int y, unsigned long pattern); | ||
462 | extern void (* const _gray_blockfuncs[4])(unsigned char *address, unsigned mask, | ||
463 | unsigned bits); | ||
464 | |||
465 | #endif /* HAVE_LCD_BITMAP */ | 155 | #endif /* HAVE_LCD_BITMAP */ |
466 | #endif /* SIMULATOR */ | 156 | #endif /* !SIMULATOR */ |
467 | #endif /* __GRAY_H__ */ | 157 | #endif /* __GRAY_H__ */ |