summaryrefslogtreecommitdiff
path: root/apps/plugins/cube.c
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-02-10 21:28:21 +0000
committerJens Arnold <amiconn@rockbox.org>2005-02-10 21:28:21 +0000
commit54828b7717a61e101764742c82bb61b7fd914bb5 (patch)
treefae77185e42d80beed1b56a6a4e6044fef15f1cd /apps/plugins/cube.c
parentc552e03c90859d476a5fbfe03b17e40ce21ef2fc (diff)
downloadrockbox-54828b7717a61e101764742c82bb61b7fd914bb5.tar.gz
rockbox-54828b7717a61e101764742c82bb61b7fd914bb5.zip
Cube now working on the player, using the new player graphics library.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5883 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/cube.c')
-rw-r--r--apps/plugins/cube.c61
1 files changed, 55 insertions, 6 deletions
diff --git a/apps/plugins/cube.c b/apps/plugins/cube.c
index 905d8a582e..52edf3375f 100644
--- a/apps/plugins/cube.c
+++ b/apps/plugins/cube.c
@@ -19,7 +19,9 @@
19***************************************************************************/ 19***************************************************************************/
20#include "plugin.h" 20#include "plugin.h"
21 21
22#ifdef HAVE_LCD_BITMAP 22#ifdef HAVE_LCD_CHARCELLS
23#include "playergfx.h"
24#endif
23 25
24/* Loops that the values are displayed */ 26/* Loops that the values are displayed */
25#define DISP_TIME 30 27#define DISP_TIME 30
@@ -35,6 +37,16 @@
35#define CUBE_Z_DEC BUTTON_F1 37#define CUBE_Z_DEC BUTTON_F1
36#define CUBE_HIGHSPEED BUTTON_PLAY 38#define CUBE_HIGHSPEED BUTTON_PLAY
37 39
40#elif CONFIG_KEYPAD == PLAYER_PAD
41#define CUBE_QUIT (BUTTON_STOP | BUTTON_REL)
42#define CUBE_X_INC BUTTON_RIGHT
43#define CUBE_X_DEC BUTTON_LEFT
44#define CUBE_Y_INC (BUTTON_ON | BUTTON_RIGHT)
45#define CUBE_Y_DEC (BUTTON_ON | BUTTON_LEFT)
46#define CUBE_Z_INC (BUTTON_MENU | BUTTON_RIGHT)
47#define CUBE_Z_DEC (BUTTON_MENU | BUTTON_LEFT)
48#define CUBE_HIGHSPEED BUTTON_PLAY
49
38#elif CONFIG_KEYPAD == ONDIO_PAD 50#elif CONFIG_KEYPAD == ONDIO_PAD
39#define CUBE_QUIT (BUTTON_OFF | BUTTON_REL) 51#define CUBE_QUIT (BUTTON_OFF | BUTTON_REL)
40#define CUBE_X_INC BUTTON_RIGHT 52#define CUBE_X_INC BUTTON_RIGHT
@@ -75,8 +87,13 @@ static long matrice[3][3];
75 87
76static int nb_points = 8; 88static int nb_points = 8;
77 89
90#ifdef HAVE_LCD_BITMAP
78static int x_off = LCD_WIDTH/2; 91static int x_off = LCD_WIDTH/2;
79static int y_off = LCD_HEIGHT/2; 92static int y_off = LCD_HEIGHT/2;
93#else
94static int x_off = 10;
95static int y_off = 7;
96#endif
80static int z_off = 600; 97static int z_off = 600;
81 98
82/* Precalculated sine and cosine * 10000 (four digit fixed point math) */ 99/* Precalculated sine and cosine * 10000 (four digit fixed point math) */
@@ -224,10 +241,10 @@ static void cube_viewport(void)
224 } 241 }
225} 242}
226 243
227#if LCD_HEIGHT > 100 244#ifdef HAVE_LCD_BITMAP
228#define DIST 80 245#define DIST (10*LCD_HEIGHT/16)
229#else 246#else
230#define DIST 40 247#define DIST 9
231#endif 248#endif
232 249
233static void cube_init(void) 250static void cube_init(void)
@@ -245,7 +262,11 @@ static void cube_init(void)
245 262
246static void line(int a, int b) 263static void line(int a, int b)
247{ 264{
265#ifdef HAVE_LCD_BITMAP
248 rb->lcd_drawline(point2D[a].x, point2D[a].y, point2D[b].x, point2D[b].y); 266 rb->lcd_drawline(point2D[a].x, point2D[a].y, point2D[b].x, point2D[b].y);
267#else
268 pgfx_drawline(point2D[a].x, point2D[a].y, point2D[b].x, point2D[b].y);
269#endif
249} 270}
250 271
251static void cube_draw(void) 272static void cube_draw(void)
@@ -286,7 +307,15 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
286 (void)(parameter); 307 (void)(parameter);
287 rb = api; 308 rb = api;
288 309
310#ifdef HAVE_LCD_BITMAP
289 rb->lcd_setfont(FONT_SYSFIXED); 311 rb->lcd_setfont(FONT_SYSFIXED);
312#else
313 if (!pgfx_init(rb, 4, 2))
314 {
315 rb->splash(HZ*2, true, "Old LCD :(");
316 return PLUGIN_OK;
317 }
318#endif
290 319
291 cube_init(); 320 cube_init();
292 321
@@ -296,11 +325,16 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
296 rb->yield(); 325 rb->yield();
297 else 326 else
298 rb->sleep(4); 327 rb->sleep(4);
299 328
329#ifdef HAVE_LCD_BITMAP
300 rb->lcd_clear_display(); 330 rb->lcd_clear_display();
331#else
332 pgfx_clear_display();
333#endif
301 cube_rotate(xa,ya,za); 334 cube_rotate(xa,ya,za);
302 cube_viewport(); 335 cube_viewport();
303 cube_draw(); 336 cube_draw();
337#ifdef HAVE_LCD_BITMAP
304 if (t_disp>0) 338 if (t_disp>0)
305 { 339 {
306 t_disp--; 340 t_disp--;
@@ -308,6 +342,18 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
308 rb->lcd_putsxy(0, LCD_HEIGHT-8, buffer); 342 rb->lcd_putsxy(0, LCD_HEIGHT-8, buffer);
309 } 343 }
310 rb->lcd_update(); 344 rb->lcd_update();
345#else
346 rb->lcd_clear_display();
347 if (t_disp>0)
348 {
349 t_disp--;
350 rb->snprintf(buffer, 30, "x%d y%d", xs, ys);
351 rb->lcd_puts(0, 0, buffer);
352 rb->snprintf(buffer, 30, "z%d h%d", zs, highspeed);
353 rb->lcd_puts(0, 1, buffer);
354 }
355 pgfx_display(3, 0);
356#endif
311 357
312 xa+=xs; 358 xa+=xs;
313 if (xa>359) 359 if (xa>359)
@@ -384,8 +430,11 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
384 if (button!=BUTTON_NONE) 430 if (button!=BUTTON_NONE)
385 lastbutton=button; 431 lastbutton=button;
386 } 432 }
433
434#ifdef HAVE_LCD_CHARCELLS
435 pgfx_release();
436#endif
387 437
388 return PLUGIN_OK; 438 return PLUGIN_OK;
389} 439}
390 440
391#endif