mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 10:37:38 -04:00
Adjust plugins to use the new menu API. Int settings still use the old API. Remove a nasty global in Star and add some error checking. Add a work-around for the gigabeat so that Star doesn't crash on target. The transition works fine on the sim and I see nothing obviously wrong with the code but it manages to crash on target everytime.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12946 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
a289324e30
commit
c7f5cccd3e
5 changed files with 241 additions and 562 deletions
|
@ -28,129 +28,80 @@ use stop to exit
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
#include "button.h"
|
|
||||||
#include "lcd.h"
|
|
||||||
|
|
||||||
#define MAX_DICE 12
|
#define MAX_DICE 12
|
||||||
#define NUM_SIDE_CHOICES 8
|
#define NUM_SIDE_CHOICES 8
|
||||||
#if (CONFIG_KEYPAD == PLAYER_PAD)
|
#if (CONFIG_KEYPAD == PLAYER_PAD)
|
||||||
#define SELECTIONS_SIZE 9
|
|
||||||
#define START_DICE_ROW 1
|
#define START_DICE_ROW 1
|
||||||
#define ROWS 1
|
#define ROWS 1
|
||||||
#define LINE_LENGTH 50
|
#define LINE_LENGTH 50
|
||||||
#define SELECTIONS_ROW 0
|
#define SELECTIONS_ROW 0
|
||||||
#else
|
#else
|
||||||
#define SELECTIONS_SIZE 7
|
|
||||||
#define SELECTIONS_ROW 4
|
|
||||||
#if (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == ONDIO_PAD)
|
#if (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == ONDIO_PAD)
|
||||||
#define START_DICE_ROW 0
|
#define START_DICE_ROW 0
|
||||||
#define ROWS 3
|
#define ROWS 3
|
||||||
#define LINE_LENGTH 18
|
#define LINE_LENGTH 18
|
||||||
#else
|
#else
|
||||||
#define START_DICE_ROW 7
|
#define START_DICE_ROW 0
|
||||||
#define ROWS 2
|
#define ROWS 2
|
||||||
#define LINE_LENGTH 26
|
#define LINE_LENGTH 26
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Values for selected */
|
#define min(x,y) (x<y?x:y)
|
||||||
#define CHANGE_DICE 0
|
#define max(x,y) (x>y?x:y)
|
||||||
#define CHANGE_SIDES 1
|
|
||||||
#define EXIT 2
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if CONFIG_KEYPAD == RECORDER_PAD
|
#if CONFIG_KEYPAD == RECORDER_PAD
|
||||||
#define DICE_BUTTON_UP BUTTON_UP
|
|
||||||
#define DICE_BUTTON_DOWN BUTTON_DOWN
|
|
||||||
#define DICE_BUTTON_LEFT BUTTON_LEFT
|
|
||||||
#define DICE_BUTTON_RIGHT BUTTON_RIGHT
|
|
||||||
#define DICE_BUTTON_OFF BUTTON_OFF
|
|
||||||
#define DICE_BUTTON_ON BUTTON_ON
|
#define DICE_BUTTON_ON BUTTON_ON
|
||||||
|
#define DICE_BUTTON_OFF BUTTON_OFF
|
||||||
#define DICE_BUTTON_SELECT BUTTON_PLAY
|
#define DICE_BUTTON_SELECT BUTTON_PLAY
|
||||||
|
|
||||||
#elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
|
#elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
|
||||||
#define DICE_BUTTON_UP BUTTON_UP
|
|
||||||
#define DICE_BUTTON_DOWN BUTTON_DOWN
|
|
||||||
#define DICE_BUTTON_LEFT BUTTON_LEFT
|
|
||||||
#define DICE_BUTTON_RIGHT BUTTON_RIGHT
|
|
||||||
#define DICE_BUTTON_OFF BUTTON_OFF
|
|
||||||
#define DICE_BUTTON_ON BUTTON_ON
|
#define DICE_BUTTON_ON BUTTON_ON
|
||||||
|
#define DICE_BUTTON_OFF BUTTON_OFF
|
||||||
#define DICE_BUTTON_SELECT BUTTON_SELECT
|
#define DICE_BUTTON_SELECT BUTTON_SELECT
|
||||||
|
|
||||||
#elif CONFIG_KEYPAD == ONDIO_PAD
|
#elif CONFIG_KEYPAD == ONDIO_PAD
|
||||||
#define DICE_BUTTON_UP BUTTON_UP
|
#define DICE_BUTTON_ON (BUTTON_MENU|BUTTON_OFF)
|
||||||
#define DICE_BUTTON_DOWN BUTTON_DOWN
|
|
||||||
#define DICE_BUTTON_LEFT BUTTON_LEFT
|
|
||||||
#define DICE_BUTTON_RIGHT BUTTON_RIGHT
|
|
||||||
#define DICE_BUTTON_OFF BUTTON_OFF
|
#define DICE_BUTTON_OFF BUTTON_OFF
|
||||||
#define DICE_BUTTON_SELECT (BUTTON_MENU|BUTTON_REL)
|
#define DICE_BUTTON_SELECT (BUTTON_MENU|BUTTON_REL)
|
||||||
#define DICE_BUTTON_ON (BUTTON_MENU|BUTTON_OFF)
|
|
||||||
|
|
||||||
#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
|
#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
|
||||||
#define DICE_BUTTON_UP BUTTON_UP
|
|
||||||
#define DICE_BUTTON_DOWN BUTTON_DOWN
|
|
||||||
#define DICE_BUTTON_OFF BUTTON_OFF
|
|
||||||
#define DICE_BUTTON_ON BUTTON_ON
|
#define DICE_BUTTON_ON BUTTON_ON
|
||||||
|
#define DICE_BUTTON_OFF BUTTON_OFF
|
||||||
#define DICE_BUTTON_SELECT BUTTON_SELECT
|
#define DICE_BUTTON_SELECT BUTTON_SELECT
|
||||||
#define DICE_BUTTON_LEFT BUTTON_LEFT
|
|
||||||
#define DICE_BUTTON_RIGHT BUTTON_RIGHT
|
|
||||||
|
|
||||||
#define DICE_BUTTON_RC_OFF BUTTON_RC_STOP
|
#define DICE_BUTTON_RC_OFF BUTTON_RC_STOP
|
||||||
|
|
||||||
#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD)
|
#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD)
|
||||||
#define DICE_BUTTON_UP BUTTON_SCROLL_FWD
|
|
||||||
#define DICE_BUTTON_DOWN BUTTON_SCROLL_BACK
|
|
||||||
#define DICE_BUTTON_OFF (BUTTON_PLAY|BUTTON_REPEAT)
|
|
||||||
#define DICE_BUTTON_ON (BUTTON_SELECT|BUTTON_PLAY)
|
#define DICE_BUTTON_ON (BUTTON_SELECT|BUTTON_PLAY)
|
||||||
|
#define DICE_BUTTON_OFF (BUTTON_PLAY|BUTTON_REPEAT)
|
||||||
#define DICE_BUTTON_SELECT BUTTON_SELECT
|
#define DICE_BUTTON_SELECT BUTTON_SELECT
|
||||||
#define DICE_BUTTON_LEFT BUTTON_LEFT
|
|
||||||
#define DICE_BUTTON_RIGHT BUTTON_RIGHT
|
|
||||||
|
|
||||||
#elif (CONFIG_KEYPAD == PLAYER_PAD)
|
#elif CONFIG_KEYPAD == PLAYER_PAD
|
||||||
#define DICE_BUTTON_UP BUTTON_PLAY
|
|
||||||
#define DICE_BUTTON_DOWN BUTTON_STOP
|
|
||||||
#define DICE_BUTTON_LEFT BUTTON_LEFT
|
|
||||||
#define DICE_BUTTON_RIGHT BUTTON_RIGHT
|
|
||||||
#define DICE_BUTTON_SELECT BUTTON_ON
|
|
||||||
#define DICE_BUTTON_ON (BUTTON_ON|BUTTON_REPEAT)
|
#define DICE_BUTTON_ON (BUTTON_ON|BUTTON_REPEAT)
|
||||||
#define DICE_BUTTON_OFF BUTTON_MENU
|
#define DICE_BUTTON_OFF BUTTON_MENU
|
||||||
|
#define DICE_BUTTON_SELECT BUTTON_ON
|
||||||
|
|
||||||
#elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD)
|
#elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
|
||||||
#define DICE_BUTTON_UP BUTTON_UP
|
|
||||||
#define DICE_BUTTON_DOWN BUTTON_DOWN
|
|
||||||
#define DICE_BUTTON_LEFT BUTTON_LEFT
|
|
||||||
#define DICE_BUTTON_RIGHT BUTTON_RIGHT
|
|
||||||
#define DICE_BUTTON_SELECT BUTTON_SELECT
|
|
||||||
#define DICE_BUTTON_ON BUTTON_PLAY
|
#define DICE_BUTTON_ON BUTTON_PLAY
|
||||||
#define DICE_BUTTON_OFF BUTTON_POWER
|
#define DICE_BUTTON_OFF BUTTON_POWER
|
||||||
|
|
||||||
#elif (CONFIG_KEYPAD == GIGABEAT_PAD)
|
|
||||||
#define DICE_BUTTON_UP BUTTON_UP
|
|
||||||
#define DICE_BUTTON_DOWN BUTTON_DOWN
|
|
||||||
#define DICE_BUTTON_LEFT BUTTON_LEFT
|
|
||||||
#define DICE_BUTTON_RIGHT BUTTON_RIGHT
|
|
||||||
#define DICE_BUTTON_SELECT BUTTON_SELECT
|
#define DICE_BUTTON_SELECT BUTTON_SELECT
|
||||||
|
|
||||||
|
#elif CONFIG_KEYPAD == GIGABEAT_PAD
|
||||||
#define DICE_BUTTON_ON BUTTON_POWER
|
#define DICE_BUTTON_ON BUTTON_POWER
|
||||||
#define DICE_BUTTON_OFF BUTTON_A
|
#define DICE_BUTTON_OFF BUTTON_A
|
||||||
|
|
||||||
#elif (CONFIG_KEYPAD == SANSA_E200_PAD)
|
|
||||||
#define DICE_BUTTON_UP BUTTON_SCROLL_UP
|
|
||||||
#define DICE_BUTTON_DOWN BUTTON_SCROLL_DOWN
|
|
||||||
#define DICE_BUTTON_LEFT BUTTON_LEFT
|
|
||||||
#define DICE_BUTTON_RIGHT BUTTON_RIGHT
|
|
||||||
#define DICE_BUTTON_SELECT BUTTON_SELECT
|
#define DICE_BUTTON_SELECT BUTTON_SELECT
|
||||||
|
|
||||||
|
#elif CONFIG_KEYPAD == SANSA_E200_PAD
|
||||||
#define DICE_BUTTON_ON BUTTON_UP
|
#define DICE_BUTTON_ON BUTTON_UP
|
||||||
#define DICE_BUTTON_OFF BUTTON_POWER
|
#define DICE_BUTTON_OFF BUTTON_POWER
|
||||||
|
#define DICE_BUTTON_SELECT BUTTON_SELECT
|
||||||
|
|
||||||
#elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
|
#elif CONFIG_KEYPAD == IRIVER_H10_PAD
|
||||||
#define DICE_BUTTON_UP BUTTON_SCROLL_UP
|
|
||||||
#define DICE_BUTTON_DOWN BUTTON_SCROLL_DOWN
|
|
||||||
#define DICE_BUTTON_LEFT BUTTON_LEFT
|
|
||||||
#define DICE_BUTTON_RIGHT BUTTON_RIGHT
|
|
||||||
#define DICE_BUTTON_SELECT BUTTON_REW
|
|
||||||
#define DICE_BUTTON_ON BUTTON_PLAY
|
#define DICE_BUTTON_ON BUTTON_PLAY
|
||||||
#define DICE_BUTTON_OFF BUTTON_POWER
|
#define DICE_BUTTON_OFF BUTTON_POWER
|
||||||
|
#define DICE_BUTTON_SELECT BUTTON_REW
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error DICE: Unsupported keypad
|
#error DICE: Unsupported keypad
|
||||||
|
@ -167,16 +118,15 @@ static struct plugin_api* rb;
|
||||||
|
|
||||||
static int roll_dice(int dice[], const int num_dice, const int side_index);
|
static int roll_dice(int dice[], const int num_dice, const int side_index);
|
||||||
static void print_dice(const int dice[], const int total);
|
static void print_dice(const int dice[], const int total);
|
||||||
static void print_selections(const int selected,
|
static bool dice_menu(int *num_dice, int *side_index);
|
||||||
const int num_dice,
|
|
||||||
const int side_index);
|
|
||||||
static void print_help(void);
|
|
||||||
|
|
||||||
/* plugin entry point */
|
/* plugin entry point */
|
||||||
enum plugin_status plugin_start(struct plugin_api* api, void* parameter) {
|
enum plugin_status plugin_start(struct plugin_api* api, void* parameter) {
|
||||||
int side_index = 6;
|
int side_index = 6;
|
||||||
int num_dice = 1;
|
int num_dice = 1;
|
||||||
int selected = CHANGE_DICE;
|
bool exit = false;
|
||||||
|
int dice[MAX_DICE];
|
||||||
|
int total;
|
||||||
|
|
||||||
/* plugin init */
|
/* plugin init */
|
||||||
(void)parameter;
|
(void)parameter;
|
||||||
|
@ -186,59 +136,24 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) {
|
||||||
rb->srand(*rb->current_tick);
|
rb->srand(*rb->current_tick);
|
||||||
/* end of plugin init */
|
/* end of plugin init */
|
||||||
|
|
||||||
print_selections(selected, num_dice, side_index);
|
if(!dice_menu(&num_dice, &side_index))
|
||||||
print_help();
|
exit = true;
|
||||||
while(selected!=EXIT) {
|
else {
|
||||||
switch(rb->button_get(true)) {
|
total = roll_dice(dice, num_dice, side_index);
|
||||||
case DICE_BUTTON_UP:
|
|
||||||
if (selected==CHANGE_DICE) {
|
|
||||||
num_dice%=MAX_DICE;
|
|
||||||
num_dice++;
|
|
||||||
} else if (selected==CHANGE_SIDES) {
|
|
||||||
side_index++;
|
|
||||||
side_index%=NUM_SIDE_CHOICES;
|
|
||||||
}
|
|
||||||
print_selections(selected, num_dice, side_index);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DICE_BUTTON_DOWN:
|
|
||||||
if (selected==CHANGE_DICE) {
|
|
||||||
num_dice--;
|
|
||||||
if (num_dice==0) {
|
|
||||||
num_dice=MAX_DICE;
|
|
||||||
}
|
|
||||||
} else if (selected==CHANGE_SIDES) {
|
|
||||||
if (side_index==0) {
|
|
||||||
side_index=NUM_SIDE_CHOICES;
|
|
||||||
}
|
|
||||||
side_index--;
|
|
||||||
}
|
|
||||||
print_selections(selected, num_dice, side_index);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DICE_BUTTON_LEFT:
|
|
||||||
selected = CHANGE_DICE;
|
|
||||||
print_selections(selected, num_dice, side_index);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DICE_BUTTON_RIGHT:
|
|
||||||
selected = CHANGE_SIDES;
|
|
||||||
print_selections(selected, num_dice, side_index);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DICE_BUTTON_ON:
|
|
||||||
case DICE_BUTTON_SELECT:
|
|
||||||
{
|
|
||||||
int dice[MAX_DICE];
|
|
||||||
int total = roll_dice(dice, num_dice, side_index);
|
|
||||||
print_dice(dice, total);
|
print_dice(dice, total);
|
||||||
}
|
}
|
||||||
|
while(!exit) {
|
||||||
|
switch(rb->button_get(true)) {
|
||||||
|
case DICE_BUTTON_ON:
|
||||||
|
case DICE_BUTTON_SELECT:
|
||||||
|
total = roll_dice(dice, num_dice, side_index);
|
||||||
|
print_dice(dice, total);
|
||||||
break;
|
break;
|
||||||
#ifdef DICE_BUTTON_RC_OFF
|
#ifdef DICE_BUTTON_RC_OFF
|
||||||
case DICE_BUTTON_RC_OFF:
|
case DICE_BUTTON_RC_OFF:
|
||||||
#endif
|
#endif
|
||||||
case DICE_BUTTON_OFF:
|
case DICE_BUTTON_OFF:
|
||||||
selected = EXIT;
|
exit=true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -261,14 +176,12 @@ static int roll_dice(int dice[], const int num_dice, const int side_index) {
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define min(x,y) (x<y?x:y)
|
|
||||||
#define max(x,y) (x>y?x:y)
|
|
||||||
|
|
||||||
/* Prints the dice, and the sum of the dice values */
|
/* Prints the dice, and the sum of the dice values */
|
||||||
static void print_dice(const int dice[], const int total) {
|
static void print_dice(const int dice[], const int total) {
|
||||||
const int dice_per_row = MAX_DICE/ROWS + (MAX_DICE%ROWS?1:0);
|
const int dice_per_row = MAX_DICE/ROWS + (MAX_DICE%ROWS?1:0);
|
||||||
char showdice[LINE_LENGTH];
|
char showdice[LINE_LENGTH];
|
||||||
int row;
|
int row;
|
||||||
|
rb->lcd_clear_display();
|
||||||
for (row=0; /*break;*/; row++) {
|
for (row=0; /*break;*/; row++) {
|
||||||
const int start = row*dice_per_row;
|
const int start = row*dice_per_row;
|
||||||
const int end = min(MAX_DICE,start+dice_per_row);
|
const int end = min(MAX_DICE,start+dice_per_row);
|
||||||
|
@ -305,43 +218,49 @@ static void print_dice(const int dice[], const int total) {
|
||||||
rb->lcd_update();
|
rb->lcd_update();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
static bool dice_menu(int *num_dice, int *side_index) {
|
||||||
|
int selection;
|
||||||
|
bool menu_quit = false, result = false;
|
||||||
|
|
||||||
/* Print the current user input choices */
|
MENUITEM_STRINGLIST(menu,"Dice Menu",NULL,"Roll Dice","Number of Dice",
|
||||||
static void print_selections(const int selected,
|
"Number of Sides","Quit");
|
||||||
const int num_dice,
|
|
||||||
const int side_index) {
|
static const struct opt_items num_sides_option[8] = {
|
||||||
char buffer[SELECTIONS_SIZE];
|
{ "3", -1 },
|
||||||
#if (CONFIG_KEYPAD == PLAYER_PAD)
|
{ "4", -1 },
|
||||||
rb->snprintf(buffer, SELECTIONS_SIZE, "%c%2dd%c%3d",
|
{ "6", -1 },
|
||||||
selected==CHANGE_DICE?'*':' ', num_dice,
|
{ "8", -1 },
|
||||||
selected==CHANGE_SIDES?'*':' ', SIDES[side_index]);
|
{ "10", -1 },
|
||||||
rb->lcd_puts(1,SELECTIONS_ROW,buffer);
|
{ "12", -1 },
|
||||||
#else
|
{ "20", -1 },
|
||||||
rb->snprintf(
|
{ "100", -1 }
|
||||||
buffer,SELECTIONS_SIZE,"%2dd%3d",num_dice,SIDES[side_index]);
|
};
|
||||||
rb->lcd_puts(1,SELECTIONS_ROW,buffer);
|
|
||||||
if (selected==CHANGE_DICE) {
|
while (!menu_quit) {
|
||||||
rb->lcd_puts(1,SELECTIONS_ROW+1,"--");
|
selection = rb->do_menu(&menu, &selection);
|
||||||
} else if (selected==CHANGE_SIDES) {
|
switch(selection)
|
||||||
rb->lcd_puts(1,SELECTIONS_ROW+1," ---");
|
{
|
||||||
|
case 0:
|
||||||
|
menu_quit = true;
|
||||||
|
result = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
rb->set_int("Number of Dice", "", UNIT_INT, num_dice, NULL,
|
||||||
|
1, 1, MAX_DICE, NULL );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
rb->set_option("Number of Sides", side_index, INT,
|
||||||
|
num_sides_option, 8, NULL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
menu_quit = true;
|
||||||
|
result = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
|
||||||
rb->lcd_update();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static void print_help() {
|
return result;
|
||||||
#if (CONFIG_KEYPAD == PLAYER_PAD)
|
|
||||||
rb->lcd_puts_scroll(1,SELECTIONS_ROW, "</>, +/- setup");
|
|
||||||
rb->lcd_puts_scroll(1,SELECTIONS_ROW+1, "on roll, menu exit");
|
|
||||||
#else
|
|
||||||
rb->lcd_puts(1,START_DICE_ROW,"</> pick dice/sides");
|
|
||||||
rb->lcd_puts(1,START_DICE_ROW+1,"+/- change");
|
|
||||||
rb->lcd_puts(1,START_DICE_ROW+2,"on/select roll");
|
|
||||||
rb->lcd_puts(1,START_DICE_ROW+3,"off exit");
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
|
||||||
rb->lcd_update();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -340,15 +340,11 @@ enum plugin_status tidy_do(enum tidy_system system)
|
||||||
|
|
||||||
int tidy_lcd_menu(void)
|
int tidy_lcd_menu(void)
|
||||||
{
|
{
|
||||||
int loc, ret = 2;
|
int selection, ret = 2;
|
||||||
bool menu_quit = false;
|
bool menu_quit = false;
|
||||||
|
|
||||||
static const struct menu_item items[] =
|
MENUITEM_STRINGLIST(menu,"Disktidy Menu",NULL,"Start Cleaning",
|
||||||
{
|
"Files to Clean","Quit");
|
||||||
{ "Start Cleaning", NULL },
|
|
||||||
{ "Files to Clean", NULL },
|
|
||||||
{ "Quit", NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct opt_items system_option[3] =
|
static const struct opt_items system_option[3] =
|
||||||
{
|
{
|
||||||
|
@ -357,12 +353,10 @@ int tidy_lcd_menu(void)
|
||||||
{ "Both", -1 }
|
{ "Both", -1 }
|
||||||
};
|
};
|
||||||
|
|
||||||
loc = rb->menu_init(items, sizeof(items) / sizeof(*items),
|
|
||||||
NULL, NULL, NULL, NULL);
|
|
||||||
|
|
||||||
while (!menu_quit)
|
while (!menu_quit)
|
||||||
{
|
{
|
||||||
switch(rb->menu_show(loc))
|
selection = rb->do_menu(&menu,&selection);
|
||||||
|
switch(selection)
|
||||||
{
|
{
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -373,13 +367,12 @@ int tidy_lcd_menu(void)
|
||||||
rb->set_option("Files to Clean", &ret, INT, system_option, 3, NULL);
|
rb->set_option("Files to Clean", &ret, INT, system_option, 3, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
default:
|
||||||
ret = 99; /* exit plugin */
|
ret = 99; /* exit plugin */
|
||||||
menu_quit = true;
|
menu_quit = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rb->menu_exit(loc);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -415,99 +415,50 @@ int count_tiles_left( void )
|
||||||
/* welcome screen where player can chose mine percentage */
|
/* welcome screen where player can chose mine percentage */
|
||||||
enum minesweeper_status menu( void )
|
enum minesweeper_status menu( void )
|
||||||
{
|
{
|
||||||
int button;
|
int selection, result = MINESWEEPER_QUIT;
|
||||||
|
bool menu_quit = false;
|
||||||
|
|
||||||
|
MENUITEM_STRINGLIST(menu, "Minesweeper Menu",NULL,"Play Minesweeper",
|
||||||
|
"Mine Percentage", "Number of Rows", "Number of Columns",
|
||||||
|
"Quit");
|
||||||
|
|
||||||
while( true )
|
|
||||||
{
|
|
||||||
#ifdef HAVE_LCD_COLOR
|
#ifdef HAVE_LCD_COLOR
|
||||||
rb->lcd_set_background( LCD_WHITE );
|
rb->lcd_set_foreground(rb->global_settings->fg_color);
|
||||||
rb->lcd_set_foreground( LCD_BLACK );
|
rb->lcd_set_background(rb->global_settings->bg_color);
|
||||||
#endif
|
#endif
|
||||||
rb->lcd_clear_display();
|
|
||||||
|
|
||||||
rb->lcd_puts( 0, 0, "Mine Sweeper" );
|
while (!menu_quit) {
|
||||||
|
selection=rb->do_menu(&menu,&selection);
|
||||||
rb->snprintf( str, 20, "%d%% mines", p );
|
switch(selection)
|
||||||
rb->lcd_puts( 0, 2, str );
|
|
||||||
rb->lcd_puts( 0, 3, "down / up" );
|
|
||||||
rb->snprintf( str, 20, "%d cols x %d rows", width, height );
|
|
||||||
rb->lcd_puts( 0, 4, str );
|
|
||||||
rb->lcd_puts( 0, 5, "left x right" );
|
|
||||||
rb->lcd_puts( 0, 6,
|
|
||||||
#if CONFIG_KEYPAD == RECORDER_PAD
|
|
||||||
"ON to start"
|
|
||||||
#elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
|
|
||||||
"ON to start"
|
|
||||||
#elif CONFIG_KEYPAD == ONDIO_PAD
|
|
||||||
"MODE to start"
|
|
||||||
#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) \
|
|
||||||
|| (CONFIG_KEYPAD == IRIVER_H300_PAD ) \
|
|
||||||
|| (CONFIG_KEYPAD == IPOD_4G_PAD) \
|
|
||||||
|| (CONFIG_KEYPAD == IPOD_3G_PAD) \
|
|
||||||
|| (CONFIG_KEYPAD == GIGABEAT_PAD)
|
|
||||||
"SELECT to start"
|
|
||||||
#elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
|
|
||||||
"REC to start"
|
|
||||||
#elif CONFIG_KEYPAD == IRIVER_H10_PAD
|
|
||||||
"FF to start"
|
|
||||||
#elif CONFIG_KEYPAD == SANSA_E200_PAD
|
|
||||||
"SELECT to start"
|
|
||||||
#else
|
|
||||||
""
|
|
||||||
# warning Please define help string for this keypad.
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
rb->lcd_update();
|
|
||||||
|
|
||||||
switch( button = rb->button_get( true ) )
|
|
||||||
{
|
{
|
||||||
case MINESWP_DOWN:
|
case 0:
|
||||||
case MINESWP_DOWN|BUTTON_REPEAT:
|
result = MINESWEEPER_WIN; /* start playing */
|
||||||
p = (p + 94)%98 + 2;
|
menu_quit = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MINESWP_UP:
|
case 1:
|
||||||
case MINESWP_UP|BUTTON_REPEAT:
|
rb->set_int("Mine Percentage", "%", UNIT_INT, &p, NULL, 1, 2,
|
||||||
p = p%98 + 2;
|
98, NULL );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BUTTON_RIGHT:
|
case 2:
|
||||||
case BUTTON_RIGHT|BUTTON_REPEAT:
|
rb->set_int("Number of Rows", "", UNIT_INT, &height, NULL, 1, 1,
|
||||||
height = height%MAX_HEIGHT + 1;
|
MAX_HEIGHT, NULL );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BUTTON_LEFT:
|
case 3:
|
||||||
case BUTTON_LEFT|BUTTON_REPEAT:
|
rb->set_int("Number of Columns", "", UNIT_INT, &width, NULL, 1, 1,
|
||||||
width = width%MAX_WIDTH + 1;
|
MAX_WIDTH, NULL );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MINESWP_RIGHT:
|
|
||||||
case MINESWP_RIGHT|BUTTON_REPEAT:
|
|
||||||
height--;
|
|
||||||
if( height < 1 ) height = MAX_HEIGHT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MINESWP_LEFT:
|
|
||||||
case MINESWP_LEFT|BUTTON_REPEAT:
|
|
||||||
width--;
|
|
||||||
if( width < 1 ) width = MAX_WIDTH;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MINESWP_START:/* start playing */
|
|
||||||
return MINESWEEPER_WIN;
|
|
||||||
|
|
||||||
#ifdef MINESWP_RC_QUIT
|
|
||||||
case MINESWP_RC_QUIT:
|
|
||||||
#endif
|
|
||||||
case MINESWP_QUIT:/* quit program */
|
|
||||||
return MINESWEEPER_QUIT;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if( rb->default_event_handler(button) == SYS_USB_CONNECTED )
|
result = MINESWEEPER_QUIT; /* quit program */
|
||||||
return MINESWEEPER_USB;
|
menu_quit = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the big and ugly game function */
|
/* the big and ugly game function */
|
||||||
|
|
|
@ -102,25 +102,24 @@ PLUGIN_HEADER
|
||||||
#define BOARD_HEIGHT (LCD_HEIGHT/4)
|
#define BOARD_HEIGHT (LCD_HEIGHT/4)
|
||||||
|
|
||||||
static int board[BOARD_WIDTH][BOARD_HEIGHT],snakelength;
|
static int board[BOARD_WIDTH][BOARD_HEIGHT],snakelength;
|
||||||
static unsigned int score,hiscore=0;
|
static unsigned int score,hiscore=0,level=1;
|
||||||
static short dir,frames,apple,level=1,dead=0;
|
static short dir,frames,apple,dead=0;
|
||||||
static struct plugin_api* rb;
|
static struct plugin_api* rb;
|
||||||
|
|
||||||
void die (void)
|
void die (void)
|
||||||
{
|
{
|
||||||
char pscore[5],hscore[17];
|
char pscore[17];
|
||||||
rb->lcd_clear_display();
|
rb->lcd_clear_display();
|
||||||
rb->snprintf(pscore,sizeof(pscore),"%d",score);
|
rb->snprintf(pscore,sizeof(pscore),"Your score: %d",score);
|
||||||
rb->lcd_putsxy(3,12,"oops...");
|
rb->lcd_puts(0,0,"Oops...");
|
||||||
rb->lcd_putsxy(3,22,"Your score :");
|
rb->lcd_puts(0,1, pscore);
|
||||||
rb->lcd_putsxy(3,32, pscore);
|
|
||||||
if (score>hiscore) {
|
if (score>hiscore) {
|
||||||
hiscore=score;
|
hiscore=score;
|
||||||
rb->lcd_putsxy(3,42,"New High Score!");
|
rb->lcd_puts(0,2,"New High Score!");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rb->snprintf(hscore,sizeof(hscore),"High Score: %d",hiscore);
|
rb->snprintf(pscore,sizeof(pscore),"High Score: %d",hiscore);
|
||||||
rb->lcd_putsxy(3,42,hscore);
|
rb->lcd_puts(0,2,pscore);
|
||||||
}
|
}
|
||||||
rb->lcd_update();
|
rb->lcd_update();
|
||||||
rb->sleep(3*HZ);
|
rb->sleep(3*HZ);
|
||||||
|
@ -324,9 +323,9 @@ void game (void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void game_init(void) {
|
void game_init(void) {
|
||||||
int button;
|
int selection=0;
|
||||||
short x,y;
|
short x,y;
|
||||||
char plevel[10],phscore[20];
|
bool menu_quit = false;
|
||||||
|
|
||||||
for (x=0; x<BOARD_WIDTH; x++) {
|
for (x=0; x<BOARD_WIDTH; x++) {
|
||||||
for (y=0; y<BOARD_HEIGHT; y++) {
|
for (y=0; y<BOARD_HEIGHT; y++) {
|
||||||
|
@ -339,57 +338,29 @@ void game_init(void) {
|
||||||
score=0;
|
score=0;
|
||||||
board[11][7]=1;
|
board[11][7]=1;
|
||||||
|
|
||||||
|
MENUITEM_STRINGLIST(menu,"Snake Menu",NULL,"Start New Game","Starting Level",
|
||||||
|
"Quit");
|
||||||
|
|
||||||
rb->lcd_clear_display();
|
while (!menu_quit) {
|
||||||
rb->lcd_setfont(FONT_SYSFIXED);
|
selection = rb->do_menu(&menu, &selection);
|
||||||
rb->snprintf(plevel,sizeof(plevel),"Level - %d",level);
|
switch(selection)
|
||||||
rb->snprintf(phscore,sizeof(phscore),"High Score: %d",hiscore);
|
{
|
||||||
rb->lcd_puts(0,0, plevel);
|
case 0:
|
||||||
rb->lcd_puts(0,1, "(1-slow, 9-fast)");
|
menu_quit = true; /* start playing */
|
||||||
rb->lcd_puts(0,2, "OFF - quit");
|
break;
|
||||||
#if CONFIG_KEYPAD == RECORDER_PAD
|
|
||||||
rb->lcd_puts(0,3, "PLAY - start/pause");
|
|
||||||
#elif CONFIG_KEYPAD == ONDIO_PAD
|
|
||||||
rb->lcd_puts(0,3, "MODE - start/pause");
|
|
||||||
#endif
|
|
||||||
rb->lcd_puts(0,4, phscore);
|
|
||||||
rb->lcd_update();
|
|
||||||
|
|
||||||
while (1) {
|
case 1:
|
||||||
button=rb->button_get(true);
|
rb->set_int("Starting Level", "", UNIT_INT, &level, NULL,
|
||||||
switch (button) {
|
1, 1, 9, NULL );
|
||||||
case BUTTON_RIGHT:
|
|
||||||
case SNAKE_UP:
|
|
||||||
if (level<9)
|
|
||||||
level++;
|
|
||||||
break;
|
|
||||||
case BUTTON_LEFT:
|
|
||||||
case SNAKE_DOWN:
|
|
||||||
if (level>1)
|
|
||||||
level--;
|
|
||||||
break;
|
|
||||||
#ifdef SNAKE_RC_QUIT
|
|
||||||
case SNAKE_RC_QUIT:
|
|
||||||
#endif
|
|
||||||
case SNAKE_QUIT:
|
|
||||||
dead=1;
|
|
||||||
return;
|
|
||||||
break;
|
|
||||||
case SNAKE_PLAYPAUSE:
|
|
||||||
return;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (rb->default_event_handler(button)==SYS_USB_CONNECTED) {
|
dead=1; /* quit program */
|
||||||
dead=2;
|
menu_quit = true;
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
rb->snprintf(plevel,sizeof(plevel),"Level - %d",level);
|
|
||||||
rb->lcd_puts(0,0, plevel);
|
|
||||||
rb->lcd_update();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
|
|
|
@ -21,12 +21,6 @@
|
||||||
|
|
||||||
PLUGIN_HEADER
|
PLUGIN_HEADER
|
||||||
|
|
||||||
/* title of the game */
|
|
||||||
#define STAR_TITLE "Star"
|
|
||||||
|
|
||||||
/* font used to display title */
|
|
||||||
#define STAR_TITLE_FONT 2
|
|
||||||
|
|
||||||
/* size of a level in file */
|
/* size of a level in file */
|
||||||
#define STAR_LEVEL_SIZE ((STAR_WIDTH + 1) * STAR_HEIGHT + 1)
|
#define STAR_LEVEL_SIZE ((STAR_WIDTH + 1) * STAR_HEIGHT + 1)
|
||||||
|
|
||||||
|
@ -45,7 +39,8 @@ PLUGIN_HEADER
|
||||||
#define STAR_BLOCK 'x'
|
#define STAR_BLOCK 'x'
|
||||||
|
|
||||||
/* sleep time between two frames */
|
/* sleep time between two frames */
|
||||||
#if (LCD_HEIGHT * LCD_WIDTH >= 70000) /* iPod 5G LCD is *slow* */
|
#if (LCD_HEIGHT * LCD_WIDTH >= 70000) && defined(IPOD_ARCH)
|
||||||
|
/* iPod 5G LCD is *slow* */
|
||||||
#define STAR_SLEEP rb->yield();
|
#define STAR_SLEEP rb->yield();
|
||||||
#elif (LCD_HEIGHT * LCD_WIDTH >= 30000)
|
#elif (LCD_HEIGHT * LCD_WIDTH >= 30000)
|
||||||
#define STAR_SLEEP rb->sleep(0);
|
#define STAR_SLEEP rb->sleep(0);
|
||||||
|
@ -204,20 +199,7 @@ static char board[STAR_HEIGHT][STAR_WIDTH];
|
||||||
#define STAR 3
|
#define STAR 3
|
||||||
#define BALL 4
|
#define BALL 4
|
||||||
|
|
||||||
/* bitmap of the arrow animation */
|
#define MENU_START 0
|
||||||
static unsigned char arrow_bmp[4][7] =
|
|
||||||
{
|
|
||||||
{0x7f, 0x7f, 0x3e, 0x3e, 0x1c, 0x1c, 0x08},
|
|
||||||
{0x3e, 0x3e, 0x1c, 0x1c, 0x08, 0x08, 0x08},
|
|
||||||
{0x1c, 0x1c, 0x1c, 0x1c, 0x08, 0x08, 0x08},
|
|
||||||
{0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* sequence of the bitmap arrow to follow to do one turn */
|
|
||||||
static unsigned char anim_arrow[8] = {0, 1, 2, 3, 2, 1, 0};
|
|
||||||
|
|
||||||
/* current_level */
|
|
||||||
static int current_level = 0;
|
|
||||||
|
|
||||||
/* char font size */
|
/* char font size */
|
||||||
static int char_width = -1;
|
static int char_width = -1;
|
||||||
|
@ -528,6 +510,8 @@ void star_display_text(char *str, bool waitkey)
|
||||||
/**
|
/**
|
||||||
* Do a pretty transition from one level to another.
|
* Do a pretty transition from one level to another.
|
||||||
*/
|
*/
|
||||||
|
#if !defined(GIGABEAT_F) || defined(SIMULATOR)
|
||||||
|
/* FIXME: this crashes on the Gigabeat but not in the sim */
|
||||||
static void star_transition_update(void)
|
static void star_transition_update(void)
|
||||||
{
|
{
|
||||||
int center_x = LCD_WIDTH / 2;
|
int center_x = LCD_WIDTH / 2;
|
||||||
|
@ -573,11 +557,12 @@ static void star_transition_update(void)
|
||||||
#endif
|
#endif
|
||||||
rb->lcd_update();
|
rb->lcd_update();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display information board of the current level.
|
* Display information board of the current level.
|
||||||
*/
|
*/
|
||||||
static void star_display_board_info(void)
|
static void star_display_board_info(int current_level)
|
||||||
{
|
{
|
||||||
int label_pos_y, tile_pos_y;
|
int label_pos_y, tile_pos_y;
|
||||||
char str_info[32];
|
char str_info[32];
|
||||||
|
@ -618,6 +603,12 @@ static int star_load_level(int current_level)
|
||||||
int x, y;
|
int x, y;
|
||||||
char *ptr_tab;
|
char *ptr_tab;
|
||||||
|
|
||||||
|
if (current_level < 0)
|
||||||
|
current_level = 0;
|
||||||
|
else if (current_level > STAR_LEVEL_COUNT-1)
|
||||||
|
current_level = STAR_LEVEL_COUNT-1;
|
||||||
|
|
||||||
|
|
||||||
ptr_tab = levels + current_level * STAR_LEVEL_SIZE;
|
ptr_tab = levels + current_level * STAR_LEVEL_SIZE;
|
||||||
control = STAR_CONTROL_BALL;
|
control = STAR_CONTROL_BALL;
|
||||||
star_count = 0;
|
star_count = 0;
|
||||||
|
@ -667,8 +658,12 @@ static int star_load_level(int current_level)
|
||||||
}
|
}
|
||||||
ptr_tab++;
|
ptr_tab++;
|
||||||
}
|
}
|
||||||
star_display_board_info();
|
star_display_board_info(current_level);
|
||||||
|
#if !defined(GIGABEAT_F) || defined(SIMULATOR)
|
||||||
star_transition_update();
|
star_transition_update();
|
||||||
|
#else
|
||||||
|
rb->lcd_update();
|
||||||
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -708,7 +703,7 @@ static void star_animate_tile(int tile_no, int start_x, int start_y,
|
||||||
/**
|
/**
|
||||||
* Run the game.
|
* Run the game.
|
||||||
*/
|
*/
|
||||||
static int star_run_game(void)
|
static int star_run_game(int current_level)
|
||||||
{
|
{
|
||||||
int move_x = 0;
|
int move_x = 0;
|
||||||
int move_y = 0;
|
int move_y = 0;
|
||||||
|
@ -794,7 +789,7 @@ static int star_run_game(void)
|
||||||
control = STAR_CONTROL_BLOCK;
|
control = STAR_CONTROL_BLOCK;
|
||||||
else
|
else
|
||||||
control = STAR_CONTROL_BALL;
|
control = STAR_CONTROL_BALL;
|
||||||
star_display_board_info();
|
star_display_board_info(current_level);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -827,7 +822,7 @@ static int star_run_game(void)
|
||||||
board[ball_y][ball_x] = STAR_VOID;
|
board[ball_y][ball_x] = STAR_VOID;
|
||||||
star_count--;
|
star_count--;
|
||||||
|
|
||||||
star_display_board_info();
|
star_display_board_info(current_level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
board[ball_y][ball_x] = STAR_BALL;
|
board[ball_y][ball_x] = STAR_BALL;
|
||||||
|
@ -865,164 +860,31 @@ static int star_run_game(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Display the choose level screen.
|
|
||||||
*/
|
|
||||||
static int star_choose_level(void)
|
|
||||||
{
|
|
||||||
int level = current_level;
|
|
||||||
int key = BUTTON_NONE;
|
|
||||||
char str_info[32];
|
|
||||||
int lastkey = BUTTON_NONE;
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
rb->lcd_clear_display();
|
|
||||||
/* levels are numbered 0 to (STAR_LEVEL_COUNT-1) internally, but
|
|
||||||
* displayed as 1 to STAR_LEVEL_COUNT because it looks nicer */
|
|
||||||
rb->snprintf(str_info, sizeof(str_info), "Level:%02d / %02d",
|
|
||||||
level+1, STAR_LEVEL_COUNT );
|
|
||||||
rb->lcd_putsxy(0, 0, str_info);
|
|
||||||
rb->lcd_update();
|
|
||||||
key = rb->button_get(true);
|
|
||||||
switch (key)
|
|
||||||
{
|
|
||||||
case STAR_QUIT:
|
|
||||||
case BUTTON_LEFT:
|
|
||||||
return -1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case STAR_MENU_RUN:
|
|
||||||
#ifdef STAR_MENU_RUN2
|
|
||||||
case STAR_MENU_RUN2:
|
|
||||||
#endif
|
|
||||||
#ifdef STAR_MENU_RUN3
|
|
||||||
case STAR_MENU_RUN3:
|
|
||||||
#endif
|
|
||||||
current_level=level;
|
|
||||||
return star_run_game();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case STAR_UP:
|
|
||||||
case BUTTON_REPEAT | STAR_UP:
|
|
||||||
if(level< STAR_LEVEL_COUNT - 1)
|
|
||||||
level++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case STAR_DOWN:
|
|
||||||
case BUTTON_REPEAT | STAR_DOWN:
|
|
||||||
if(level> 0)
|
|
||||||
level--;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if (rb->default_event_handler(key) == SYS_USB_CONNECTED)
|
|
||||||
{
|
|
||||||
usb_detected = true;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key != BUTTON_NONE)
|
|
||||||
lastkey = key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the choice menu.
|
* Display the choice menu.
|
||||||
*/
|
*/
|
||||||
static int star_menu(void)
|
static int star_menu(void)
|
||||||
{
|
{
|
||||||
int move_y;
|
int selection, level=1;
|
||||||
int menu_y = 0;
|
bool menu_quit = false;
|
||||||
int i = 0;
|
|
||||||
bool refresh = true;
|
|
||||||
char anim_state = 0;
|
|
||||||
unsigned char *menu[5] = {"Play", "Choose Level", "Information",
|
|
||||||
"Keys", "Exit"};
|
|
||||||
int menu_count = sizeof(menu) / sizeof(unsigned char *);
|
|
||||||
int menu_offset_y;
|
|
||||||
int key;
|
|
||||||
|
|
||||||
menu_offset_y = LCD_HEIGHT - char_height * menu_count;
|
/* get the size of char */
|
||||||
|
rb->lcd_getstringsize("a", &char_width, &char_height);
|
||||||
|
|
||||||
while (true)
|
MENUITEM_STRINGLIST(menu,"Star Menu",NULL,"Play","Choose Level",
|
||||||
|
"Information","Keys","Quit");
|
||||||
|
|
||||||
|
while(!menu_quit)
|
||||||
{
|
{
|
||||||
if (refresh)
|
selection = rb->do_menu(&menu, &selection);
|
||||||
{
|
switch(selection)
|
||||||
rb->lcd_clear_display();
|
|
||||||
rb->lcd_putsxy((LCD_WIDTH - char_width *
|
|
||||||
rb->strlen(STAR_TITLE)) / 2,
|
|
||||||
0, STAR_TITLE);
|
|
||||||
for (i = 0 ; i < menu_count ; i++)
|
|
||||||
{
|
|
||||||
rb->lcd_putsxy(15, menu_offset_y + char_height * i, menu[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
rb->lcd_update();
|
|
||||||
refresh = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
move_y = 0;
|
|
||||||
rb->lcd_mono_bitmap(arrow_bmp[anim_arrow[(anim_state & 0x38) >> 3]],
|
|
||||||
2, menu_offset_y + menu_y * char_height, 7, 8);
|
|
||||||
rb->lcd_update_rect (2, menu_offset_y + menu_y * 8, 8, 8);
|
|
||||||
STAR_SLEEP
|
|
||||||
anim_state++;
|
|
||||||
|
|
||||||
key = rb->button_get(false);
|
|
||||||
switch (key)
|
|
||||||
{
|
|
||||||
#ifdef STAR_RC_QUIT
|
|
||||||
case STAR_RC_QUIT:
|
|
||||||
#endif
|
|
||||||
case STAR_QUIT:
|
|
||||||
return PLUGIN_OK;
|
|
||||||
case STAR_UP:
|
|
||||||
if (menu_y > 0) {
|
|
||||||
move_y = -1;
|
|
||||||
#if LCD_DEPTH > 1
|
|
||||||
int oldforeground = rb->lcd_get_foreground();
|
|
||||||
rb->lcd_set_foreground(LCD_BLACK);
|
|
||||||
#endif
|
|
||||||
rb->lcd_fillrect(0,menu_offset_y + char_height * menu_y - 2,
|
|
||||||
15, char_height + 3);
|
|
||||||
#if LCD_DEPTH > 1
|
|
||||||
rb->lcd_set_foreground(oldforeground);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case STAR_DOWN:
|
|
||||||
if (menu_y < menu_count-1) {
|
|
||||||
move_y = 1;
|
|
||||||
#if LCD_DEPTH > 1
|
|
||||||
int oldforeground = rb->lcd_get_foreground();
|
|
||||||
rb->lcd_set_foreground(LCD_BLACK);
|
|
||||||
#endif
|
|
||||||
rb->lcd_fillrect(0,menu_offset_y + char_height * menu_y - 1,
|
|
||||||
15, char_height + 2);
|
|
||||||
#if LCD_DEPTH > 1
|
|
||||||
rb->lcd_set_foreground(oldforeground);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case STAR_MENU_RUN:
|
|
||||||
#ifdef STAR_MENU_RUN2
|
|
||||||
case STAR_MENU_RUN2:
|
|
||||||
#endif
|
|
||||||
#ifdef STAR_MENU_RUN3
|
|
||||||
case STAR_MENU_RUN3:
|
|
||||||
#endif
|
|
||||||
refresh = true;
|
|
||||||
switch (menu_y)
|
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
star_run_game();
|
menu_quit = true;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
star_choose_level();
|
rb->set_int("Level", "", UNIT_INT, &level,
|
||||||
|
NULL, 1, 1, STAR_LEVEL_COUNT, NULL );
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
star_display_text(
|
star_display_text(
|
||||||
|
@ -1070,7 +932,7 @@ static int star_menu(void)
|
||||||
"[REC] Next level", true);
|
"[REC] Next level", true);
|
||||||
#elif CONFIG_KEYPAD == GIGABEAT_PAD
|
#elif CONFIG_KEYPAD == GIGABEAT_PAD
|
||||||
star_display_text("KEYS\n\n"
|
star_display_text("KEYS\n\n"
|
||||||
"[MENU] Toggle Ctl\n"
|
"[MENU] Toggle Control\n"
|
||||||
"[A] Exit\n"
|
"[A] Exit\n"
|
||||||
"[PWR+DOWN] Prev. level\n"
|
"[PWR+DOWN] Prev. level\n"
|
||||||
"[PWR+RIGHT] Reset level\n"
|
"[PWR+RIGHT] Reset level\n"
|
||||||
|
@ -1084,33 +946,21 @@ static int star_menu(void)
|
||||||
"[PLAY+UP] Next level", true);
|
"[PLAY+UP] Next level", true);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case 4:
|
|
||||||
return PLUGIN_OK;
|
|
||||||
}
|
|
||||||
if (usb_detected)
|
|
||||||
return PLUGIN_USB_CONNECTED;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (rb->default_event_handler(key) == SYS_USB_CONNECTED)
|
menu_quit = true;
|
||||||
return PLUGIN_USB_CONNECTED;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0 ; i < char_height ; i++)
|
if (selection == MENU_START)
|
||||||
{
|
{
|
||||||
rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
|
rb->lcd_setfont(FONT_SYSFIXED);
|
||||||
rb->lcd_fillrect (2, menu_offset_y, 8, menu_count * 8);
|
rb->lcd_getstringsize("a", &char_width, &char_height);
|
||||||
rb->lcd_set_drawmode(DRMODE_FG);
|
level--;
|
||||||
rb->lcd_mono_bitmap(arrow_bmp[anim_arrow[(anim_state & 0x38) >> 3]],
|
star_run_game(level);
|
||||||
2, menu_offset_y + menu_y * 8 + move_y * i, 7, 8);
|
|
||||||
rb->lcd_update_rect(2, menu_offset_y, 8, menu_count * 8);
|
|
||||||
anim_state++;
|
|
||||||
STAR_SLEEP
|
|
||||||
}
|
|
||||||
rb->lcd_set_drawmode(DRMODE_SOLID);
|
|
||||||
menu_y += move_y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return PLUGIN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1121,11 +971,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
(void)parameter;
|
(void)parameter;
|
||||||
rb = api;
|
rb = api;
|
||||||
|
|
||||||
/* get the size of char */
|
|
||||||
rb->lcd_setfont(FONT_SYSFIXED);
|
|
||||||
if (char_width == -1)
|
|
||||||
rb->lcd_getstringsize("a", &char_width, &char_height);
|
|
||||||
|
|
||||||
#if LCD_DEPTH > 1
|
#if LCD_DEPTH > 1
|
||||||
rb->lcd_set_backdrop(NULL);
|
rb->lcd_set_backdrop(NULL);
|
||||||
rb->lcd_set_background( LCD_BLACK );
|
rb->lcd_set_background( LCD_BLACK );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue