summaryrefslogtreecommitdiff
path: root/apps/plugins/rockblox.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/rockblox.c')
-rw-r--r--apps/plugins/rockblox.c64
1 files changed, 62 insertions, 2 deletions
diff --git a/apps/plugins/rockblox.c b/apps/plugins/rockblox.c
index 6337ff4acb..16530ff337 100644
--- a/apps/plugins/rockblox.c
+++ b/apps/plugins/rockblox.c
@@ -118,6 +118,17 @@ PLUGIN_HEADER
118#define ROCKBLOX_DROP BUTTON_FF 118#define ROCKBLOX_DROP BUTTON_FF
119#define ROCKBLOX_RESTART BUTTON_PLAY 119#define ROCKBLOX_RESTART BUTTON_PLAY
120 120
121#elif CONFIG_KEYPAD == GIGABEAT_PAD
122
123#define ROCKBLOX_OFF BUTTON_A
124#define ROCKBLOX_ROTATE_RIGHT BUTTON_VOL_DOWN
125#define ROCKBLOX_ROTATE_LEFT BUTTON_VOL_UP
126#define ROCKBLOX_ROTATE BUTTON_UP
127#define ROCKBLOX_DOWN BUTTON_DOWN
128#define ROCKBLOX_LEFT BUTTON_LEFT
129#define ROCKBLOX_RIGHT BUTTON_RIGHT
130#define ROCKBLOX_DROP BUTTON_SELECT
131#define ROCKBLOX_RESTART BUTTON_MENU
121#endif 132#endif
122 133
123#define BLOCKS_NUM 7 134#define BLOCKS_NUM 7
@@ -142,6 +153,24 @@ PLUGIN_HEADER
142#define LEVEL_Y 70 153#define LEVEL_Y 70
143#define LINES_Y 105 154#define LINES_Y 105
144 155
156#elif (LCD_WIDTH == 240) && (LCD_HEIGHT == 320)
157
158#define BLOCK_WIDTH 12
159#define BLOCK_HEIGHT 12
160#define BOARD_X 86
161#define BOARD_Y 0
162#define PREVIEW_X 12
163#define PREVIEW_Y 11
164#define LABEL_X 20
165#define SCORE_Y 80
166#define LEVEL_Y 110
167#define LEVEL_X 46
168#define LINES_X 16
169#define LINES_Y 110
170#define HIGH_SCORE_Y 184
171#define HIGH_LEVEL_Y 193
172#define HIGH_LABEL_X 7
173
145#elif (LCD_WIDTH == 220) && (LCD_HEIGHT == 176) 174#elif (LCD_WIDTH == 220) && (LCD_HEIGHT == 176)
146 175
147#define BLOCK_WIDTH 8 176#define BLOCK_WIDTH 8
@@ -227,6 +256,10 @@ PLUGIN_HEADER
227#define LEVEL_X LABEL_X 256#define LEVEL_X LABEL_X
228#endif 257#endif
229 258
259#ifndef LINES_X
260#define LINES_X LABEL_X
261#endif
262
230#define MYLCD(fn) rb->lcd_ ## fn 263#define MYLCD(fn) rb->lcd_ ## fn
231 264
232extern const fb_data rockblox_background[]; 265extern const fb_data rockblox_background[];
@@ -282,7 +315,7 @@ static struct plugin_api *rb;
282 315
283static bool gameover = false; 316static bool gameover = false;
284/* c=current f=figure o=orientation n=next */ 317/* c=current f=figure o=orientation n=next */
285static int lines, level, score, cx, cy, cf, co, nf; 318static int lines = 0, level = 0, score = 0, cx, cy, cf, co, nf;
286static short board[BOARD_HEIGHT][BOARD_WIDTH]; /* 20 rows of 10 blocks */ 319static short board[BOARD_HEIGHT][BOARD_WIDTH]; /* 20 rows of 10 blocks */
287 320
288#ifdef SCROLL_WHEEL 321#ifdef SCROLL_WHEEL
@@ -395,6 +428,12 @@ figures[BLOCKS_NUM] = {
395 } 428 }
396}; 429};
397 430
431/* Rockbox File System only supports full filenames inc dir */
432#define HIGH_SCORE "/.rockbox/rocks/rockblox.score"
433#define MAX_HIGH_SCORES 5
434/* Default High Scores... */
435struct highscore Highest[MAX_HIGH_SCORES];
436
398/* get random number from (0) to (range-1) */ 437/* get random number from (0) to (range-1) */
399static int t_rand (int range) 438static int t_rand (int range)
400{ 439{
@@ -425,7 +464,7 @@ static void show_details (void)
425 rb->snprintf (str, sizeof (str), "%d", level); 464 rb->snprintf (str, sizeof (str), "%d", level);
426 rb->lcd_putsxy (LEVEL_X, LEVEL_Y, str); 465 rb->lcd_putsxy (LEVEL_X, LEVEL_Y, str);
427 rb->snprintf (str, sizeof (str), "%d", lines); 466 rb->snprintf (str, sizeof (str), "%d", lines);
428 rb->lcd_putsxy (LABEL_X, LINES_Y, str); 467 rb->lcd_putsxy (LINES_X, LINES_Y, str);
429#else /* HAVE_LCD_CHARCELLS */ 468#else /* HAVE_LCD_CHARCELLS */
430 rb->snprintf (str, sizeof (str), "L%d/%d", level, lines); 469 rb->snprintf (str, sizeof (str), "L%d/%d", level, lines);
431 rb->lcd_puts (5, 0, str); 470 rb->lcd_puts (5, 0, str);
@@ -436,6 +475,10 @@ static void show_details (void)
436 475
437static void init_rockblox (void) 476static void init_rockblox (void)
438{ 477{
478 int i;
479 char str[25]; /* for strings */
480 highscore_update(score, level, Highest, MAX_HIGH_SCORES);
481
439 level = 1; 482 level = 1;
440 lines = 0; 483 lines = 0;
441 score = 0; 484 score = 0;
@@ -454,6 +497,13 @@ static void init_rockblox (void)
454 pgfx_update(); 497 pgfx_update();
455#endif 498#endif
456 show_details (); 499 show_details ();
500#ifdef HIGH_SCORE_Y
501 for (i = MAX_HIGH_SCORES-1; i>=0; i--)
502 {
503 rb->snprintf (str, sizeof (str), "%06d L%1d", Highest[i].score, Highest[i].level);
504 rb->lcd_putsxy (HIGH_LABEL_X, HIGH_SCORE_Y + (10 * ((MAX_HIGH_SCORES-1) - i)), str);
505 }
506#endif
457} 507}
458 508
459static inline int level_speed(int level) 509static inline int level_speed(int level)
@@ -781,6 +831,9 @@ static int rockblox_loop (void)
781 case ROCKBLOX_OFF: 831 case ROCKBLOX_OFF:
782 return PLUGIN_OK; 832 return PLUGIN_OK;
783 833
834#if defined(ROCKBLOX_ROTATE)
835 case ROCKBLOX_ROTATE:
836#endif
784 case ROCKBLOX_ROTATE_RIGHT: 837 case ROCKBLOX_ROTATE_RIGHT:
785 case ROCKBLOX_ROTATE_RIGHT | BUTTON_REPEAT: 838 case ROCKBLOX_ROTATE_RIGHT | BUTTON_REPEAT:
786#ifdef SCROLL_WHEEL 839#ifdef SCROLL_WHEEL
@@ -910,6 +963,11 @@ enum plugin_status plugin_start (struct plugin_api *api, void *parameter)
910 rb = api; 963 rb = api;
911 964
912 rb->srand (*rb->current_tick); 965 rb->srand (*rb->current_tick);
966
967 /* Load HighScore if any */
968 highscore_init(rb);
969 highscore_load(HIGH_SCORE,Highest,MAX_HIGH_SCORES);
970
913#if LCD_DEPTH > 1 971#if LCD_DEPTH > 1
914 rb->lcd_set_backdrop(NULL); 972 rb->lcd_set_backdrop(NULL);
915#endif 973#endif
@@ -935,6 +993,8 @@ enum plugin_status plugin_start (struct plugin_api *api, void *parameter)
935#else 993#else
936 pgfx_release(); 994 pgfx_release();
937#endif 995#endif
996 /* Save user's HighScore */
997 highscore_save(HIGH_SCORE,Highest,MAX_HIGH_SCORES);
938 /* Restore user's original backlight setting */ 998 /* Restore user's original backlight setting */
939 rb->backlight_set_timeout (rb->global_settings->backlight_timeout); 999 rb->backlight_set_timeout (rb->global_settings->backlight_timeout);
940 1000