summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2006-10-30 01:31:32 +0000
committerJens Arnold <amiconn@rockbox.org>2006-10-30 01:31:32 +0000
commit5421e8696906cda6416d089d5f387bb38a147ee2 (patch)
tree484625d1093bdb2f6af5466a07c1e014c2047a44 /apps/plugins
parentc1767ddf4a0cc91dcea1222eff0a60ac431714f2 (diff)
downloadrockbox-5421e8696906cda6416d089d5f387bb38a147ee2.tar.gz
rockbox-5421e8696906cda6416d089d5f387bb38a147ee2.zip
Colorised demystify. Based on patch #5856 by Travis Hyyppa, adapted to properly work with the multi-screen API.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11389 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/demystify.c53
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
85int r,g,b,rc,gc,bc;
86#endif
87
84/******************************* Globals ***********************************/ 88/******************************* Globals ***********************************/
85 89
86static struct plugin_api* rb; /* global api struct pointer */ 90static 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
288void new_color(void)
289{
290 r = rb->rand()%255;
291 g = rb->rand()%255;
292 b = rb->rand()%255;
293}
294
295void 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();