diff options
Diffstat (limited to 'apps/plugins/demystify.c')
-rw-r--r-- | apps/plugins/demystify.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/apps/plugins/demystify.c b/apps/plugins/demystify.c index 55897441f9..44b658e878 100644 --- a/apps/plugins/demystify.c +++ b/apps/plugins/demystify.c | |||
@@ -81,6 +81,10 @@ PLUGIN_HEADER | |||
81 | #define MAX_POLYGONS 40 | 81 | #define MAX_POLYGONS 40 |
82 | #define MIN_POLYGONS 1 | 82 | #define MIN_POLYGONS 1 |
83 | 83 | ||
84 | #ifdef HAVE_LCD_COLOR | ||
85 | int r,g,b,rc,gc,bc; | ||
86 | #endif | ||
87 | |||
84 | /******************************* Globals ***********************************/ | 88 | /******************************* Globals ***********************************/ |
85 | 89 | ||
86 | static struct plugin_api* rb; /* global api struct pointer */ | 90 | static struct plugin_api* rb; /* global api struct pointer */ |
@@ -280,6 +284,34 @@ void cleanup(void *parameter) | |||
280 | #endif | 284 | #endif |
281 | } | 285 | } |
282 | 286 | ||
287 | #ifdef HAVE_LCD_COLOR | ||
288 | void new_color(void) | ||
289 | { | ||
290 | r = rb->rand()%255; | ||
291 | g = rb->rand()%255; | ||
292 | b = rb->rand()%255; | ||
293 | } | ||
294 | |||
295 | void change_color(void) | ||
296 | { | ||
297 | if(rc<r) | ||
298 | ++rc; | ||
299 | else if(rc>r) | ||
300 | --rc; | ||
301 | if(gc<g) | ||
302 | ++gc; | ||
303 | else if(gc>g) | ||
304 | --gc; | ||
305 | if(bc<b) | ||
306 | ++bc; | ||
307 | else if(bc>b) | ||
308 | --bc; | ||
309 | rb->lcd_set_foreground(LCD_RGBPACK(rc,gc,bc)); | ||
310 | if(rc==r && gc==g && bc==b) | ||
311 | new_color(); | ||
312 | } | ||
313 | #endif | ||
314 | |||
283 | /* | 315 | /* |
284 | * Main function | 316 | * Main function |
285 | */ | 317 | */ |
@@ -296,10 +328,23 @@ int plugin_main(void) | |||
296 | struct polygon leading_polygon[NB_SCREENS]; | 328 | struct polygon leading_polygon[NB_SCREENS]; |
297 | FOR_NB_SCREENS(i) | 329 | FOR_NB_SCREENS(i) |
298 | { | 330 | { |
331 | #ifdef HAVE_LCD_COLOR | ||
332 | struct screen *display = rb->screens[i]; | ||
333 | if (display->depth > 8) | ||
334 | display->set_background(LCD_BLACK); | ||
335 | #endif | ||
299 | fifo_init(&polygons[i]); | 336 | fifo_init(&polygons[i]); |
300 | polygon_move_init(&move[i]); | 337 | polygon_move_init(&move[i]); |
301 | polygon_init(&leading_polygon[i], rb->screens[i]); | 338 | polygon_init(&leading_polygon[i], rb->screens[i]); |
302 | } | 339 | } |
340 | |||
341 | #ifdef HAVE_LCD_COLOR | ||
342 | new_color(); | ||
343 | rc = r; | ||
344 | gc = g; | ||
345 | bc = b; | ||
346 | #endif | ||
347 | |||
303 | while (true) | 348 | while (true) |
304 | { | 349 | { |
305 | FOR_NB_SCREENS(i) | 350 | FOR_NB_SCREENS(i) |
@@ -325,10 +370,18 @@ int plugin_main(void) | |||
325 | 370 | ||
326 | /* Now the drawing part */ | 371 | /* Now the drawing part */ |
327 | 372 | ||
373 | #ifdef HAVE_LCD_COLOR | ||
374 | if (display->depth > 8) | ||
375 | display->set_foreground(SCREEN_COLOR_TO_NATIVE(display, | ||
376 | LCD_RGBPACK(rc, gc, bc))); | ||
377 | #endif | ||
328 | display->clear_display(); | 378 | display->clear_display(); |
329 | polygons_draw(&polygons[i], display); | 379 | polygons_draw(&polygons[i], display); |
330 | display->update(); | 380 | display->update(); |
331 | } | 381 | } |
382 | #ifdef HAVE_LCD_COLOR | ||
383 | change_color(); | ||
384 | #endif | ||
332 | /* Speed handling*/ | 385 | /* Speed handling*/ |
333 | if (sleep_time<0)/* full speed */ | 386 | if (sleep_time<0)/* full speed */ |
334 | rb->yield(); | 387 | rb->yield(); |