summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorSteve Gotthardt <gotthardt@rockbox.org>2007-01-05 16:32:20 +0000
committerSteve Gotthardt <gotthardt@rockbox.org>2007-01-05 16:32:20 +0000
commitd850db102f2fb8abad0c7c318015883125aab336 (patch)
tree54384e358fef0bf6edf6d5589f4299c9c71c270f /apps/plugins
parent504c040c08af37c77f8834d88ec768cb985456e2 (diff)
downloadrockbox-d850db102f2fb8abad0c7c318015883125aab336.zip
rockbox-d850db102f2fb8abad0c7c318015883125aab336.tar.gz
rockbox-d850db102f2fb8abad0c7c318015883125aab336.tar.bz2
rockbox-d850db102f2fb8abad0c7c318015883125aab336.tar.xz
Gigabeat gets rockblox ! Thanks to the RedZZR Gary Allen.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11918 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/SOURCES2
-rw-r--r--apps/plugins/bitmaps/native/SOURCES2
-rw-r--r--apps/plugins/lib/highscore.c33
-rw-r--r--apps/plugins/lib/highscore.h1
-rw-r--r--apps/plugins/rockblox.c64
5 files changed, 97 insertions, 5 deletions
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES
index 413e521..8865a5b 100644
--- a/apps/plugins/SOURCES
+++ b/apps/plugins/SOURCES
@@ -9,7 +9,7 @@ logo.c
mosaique.c
properties.c
random_folder_advance_config.c
-#if (LCD_WIDTH != 240) && ((LCD_WIDTH != 128) || (LCD_HEIGHT != 64)) && !defined(SANSA_E200)
+#if !defined(SANSA_E200)
rockblox.c
#endif
rockbox_flash.c
diff --git a/apps/plugins/bitmaps/native/SOURCES b/apps/plugins/bitmaps/native/SOURCES
index be8f2b6..0521f72 100644
--- a/apps/plugins/bitmaps/native/SOURCES
+++ b/apps/plugins/bitmaps/native/SOURCES
@@ -312,6 +312,8 @@ brickmania_break.176x132x16.bmp
/* Rockblox */
#if (LCD_WIDTH == 320) && (LCD_HEIGHT == 240) && (LCD_DEPTH == 16)
rockblox_background.320x240x16.bmp
+#elif (LCD_WIDTH == 240) && (LCD_HEIGHT == 320) && (LCD_DEPTH == 16)
+rockblox_background.240x320x16.bmp
#elif (LCD_WIDTH >= 220) && (LCD_HEIGHT >= 176) && (LCD_DEPTH == 16)
rockblox_background.220x176x16.bmp
#elif (LCD_WIDTH == 176) && (LCD_HEIGHT == 132) && (LCD_DEPTH == 16)
diff --git a/apps/plugins/lib/highscore.c b/apps/plugins/lib/highscore.c
index 9fbcdf2..df7a71b 100644
--- a/apps/plugins/lib/highscore.c
+++ b/apps/plugins/lib/highscore.c
@@ -61,11 +61,12 @@ int highscore_load(char *filename, struct highscore *scores, int num_scores)
char *ptr;
fd = rb->open(filename, O_RDONLY);
+
+ rb->memset(scores, 0, sizeof(struct highscore)*(num_scores+1));
+
if(fd < 0)
return -1;
- rb->memset(scores, 0, sizeof(struct highscore)*num_scores);
-
i = -1;
while(rb->read_line(fd, buf, sizeof(buf)-1) && i < num_scores)
{
@@ -97,3 +98,31 @@ int highscore_load(char *filename, struct highscore *scores, int num_scores)
}
return 0;
}
+
+int highscore_update(int score, int level, struct highscore *scores, int num_scores)
+{
+ int i, j;
+ int new = 0;
+
+ /* look through the scores and see if this one is in the top ones */
+ for(i = num_scores-1;i >= 0; i--)
+ {
+ if ((score > scores[i].score))
+ {
+ /* Move the rest down one... */
+ if (i > 0)
+ {
+ for (j=1; j<=i; j++)
+ {
+ rb->memcpy((void *)&scores[j-1], (void *)&scores[j], sizeof(struct highscore));
+ }
+ }
+ scores[i].score = score;
+ scores[i].level = level;
+ /* Need to sort out entering a name... maybe old three letter arcade style */
+ new = 1;
+ break;
+ }
+ }
+ return new;
+}
diff --git a/apps/plugins/lib/highscore.h b/apps/plugins/lib/highscore.h
index ff19213..ba7da24 100644
--- a/apps/plugins/lib/highscore.h
+++ b/apps/plugins/lib/highscore.h
@@ -29,5 +29,6 @@ struct highscore
void highscore_init(struct plugin_api* newrb);
int highscore_save(char *filename, struct highscore *scores, int num_scores);
int highscore_load(char *filename, struct highscore *scores, int num_scores);
+int highscore_update(int score, int level, struct highscore *scores, int num_scores);
#endif
diff --git a/apps/plugins/rockblox.c b/apps/plugins/rockblox.c
index 6337ff4..16530ff 100644
--- a/apps/plugins/rockblox.c
+++ b/apps/plugins/rockblox.c
@@ -118,6 +118,17 @@ PLUGIN_HEADER
#define ROCKBLOX_DROP BUTTON_FF
#define ROCKBLOX_RESTART BUTTON_PLAY
+#elif CONFIG_KEYPAD == GIGABEAT_PAD
+
+#define ROCKBLOX_OFF BUTTON_A
+#define ROCKBLOX_ROTATE_RIGHT BUTTON_VOL_DOWN
+#define ROCKBLOX_ROTATE_LEFT BUTTON_VOL_UP
+#define ROCKBLOX_ROTATE BUTTON_UP
+#define ROCKBLOX_DOWN BUTTON_DOWN
+#define ROCKBLOX_LEFT BUTTON_LEFT
+#define ROCKBLOX_RIGHT BUTTON_RIGHT
+#define ROCKBLOX_DROP BUTTON_SELECT
+#define ROCKBLOX_RESTART BUTTON_MENU
#endif
#define BLOCKS_NUM 7
@@ -142,6 +153,24 @@ PLUGIN_HEADER
#define LEVEL_Y 70
#define LINES_Y 105
+#elif (LCD_WIDTH == 240) && (LCD_HEIGHT == 320)
+
+#define BLOCK_WIDTH 12
+#define BLOCK_HEIGHT 12
+#define BOARD_X 86
+#define BOARD_Y 0
+#define PREVIEW_X 12
+#define PREVIEW_Y 11
+#define LABEL_X 20
+#define SCORE_Y 80
+#define LEVEL_Y 110
+#define LEVEL_X 46
+#define LINES_X 16
+#define LINES_Y 110
+#define HIGH_SCORE_Y 184
+#define HIGH_LEVEL_Y 193
+#define HIGH_LABEL_X 7
+
#elif (LCD_WIDTH == 220) && (LCD_HEIGHT == 176)
#define BLOCK_WIDTH 8
@@ -227,6 +256,10 @@ PLUGIN_HEADER
#define LEVEL_X LABEL_X
#endif
+#ifndef LINES_X
+#define LINES_X LABEL_X
+#endif
+
#define MYLCD(fn) rb->lcd_ ## fn
extern const fb_data rockblox_background[];
@@ -282,7 +315,7 @@ static struct plugin_api *rb;
static bool gameover = false;
/* c=current f=figure o=orientation n=next */
-static int lines, level, score, cx, cy, cf, co, nf;
+static int lines = 0, level = 0, score = 0, cx, cy, cf, co, nf;
static short board[BOARD_HEIGHT][BOARD_WIDTH]; /* 20 rows of 10 blocks */
#ifdef SCROLL_WHEEL
@@ -395,6 +428,12 @@ figures[BLOCKS_NUM] = {
}
};
+/* Rockbox File System only supports full filenames inc dir */
+#define HIGH_SCORE "/.rockbox/rocks/rockblox.score"
+#define MAX_HIGH_SCORES 5
+/* Default High Scores... */
+struct highscore Highest[MAX_HIGH_SCORES];
+
/* get random number from (0) to (range-1) */
static int t_rand (int range)
{
@@ -425,7 +464,7 @@ static void show_details (void)
rb->snprintf (str, sizeof (str), "%d", level);
rb->lcd_putsxy (LEVEL_X, LEVEL_Y, str);
rb->snprintf (str, sizeof (str), "%d", lines);
- rb->lcd_putsxy (LABEL_X, LINES_Y, str);
+ rb->lcd_putsxy (LINES_X, LINES_Y, str);
#else /* HAVE_LCD_CHARCELLS */
rb->snprintf (str, sizeof (str), "L%d/%d", level, lines);
rb->lcd_puts (5, 0, str);
@@ -436,6 +475,10 @@ static void show_details (void)
static void init_rockblox (void)
{
+ int i;
+ char str[25]; /* for strings */
+ highscore_update(score, level, Highest, MAX_HIGH_SCORES);
+
level = 1;
lines = 0;
score = 0;
@@ -454,6 +497,13 @@ static void init_rockblox (void)
pgfx_update();
#endif
show_details ();
+#ifdef HIGH_SCORE_Y
+ for (i = MAX_HIGH_SCORES-1; i>=0; i--)
+ {
+ rb->snprintf (str, sizeof (str), "%06d L%1d", Highest[i].score, Highest[i].level);
+ rb->lcd_putsxy (HIGH_LABEL_X, HIGH_SCORE_Y + (10 * ((MAX_HIGH_SCORES-1) - i)), str);
+ }
+#endif
}
static inline int level_speed(int level)
@@ -781,6 +831,9 @@ static int rockblox_loop (void)
case ROCKBLOX_OFF:
return PLUGIN_OK;
+#if defined(ROCKBLOX_ROTATE)
+ case ROCKBLOX_ROTATE:
+#endif
case ROCKBLOX_ROTATE_RIGHT:
case ROCKBLOX_ROTATE_RIGHT | BUTTON_REPEAT:
#ifdef SCROLL_WHEEL
@@ -910,6 +963,11 @@ enum plugin_status plugin_start (struct plugin_api *api, void *parameter)
rb = api;
rb->srand (*rb->current_tick);
+
+ /* Load HighScore if any */
+ highscore_init(rb);
+ highscore_load(HIGH_SCORE,Highest,MAX_HIGH_SCORES);
+
#if LCD_DEPTH > 1
rb->lcd_set_backdrop(NULL);
#endif
@@ -935,6 +993,8 @@ enum plugin_status plugin_start (struct plugin_api *api, void *parameter)
#else
pgfx_release();
#endif
+ /* Save user's HighScore */
+ highscore_save(HIGH_SCORE,Highest,MAX_HIGH_SCORES);
/* Restore user's original backlight setting */
rb->backlight_set_timeout (rb->global_settings->backlight_timeout);