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