calendar: fix bug when add new event text longer than last entry.

blackjack: fix bug that bet becomes 10 when resume saved game.
bubbles: save high level to sparate file.
clix, spacerocks, jewels, bubbles: correct text of menu item.
wormlet: clean up code: removed unused defines and functions.
pluginlib display_text: insert sleep so that the screen doesn't quit immediately.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22143 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Teruaki Kawashima 2009-08-03 16:30:08 +00:00
parent 3228756324
commit 2357ec4178
9 changed files with 410 additions and 743 deletions

View file

@ -489,7 +489,6 @@ typedef struct game_context {
bool end_hand; bool end_hand;
bool asked_insurance; bool asked_insurance;
bool resume; bool resume;
bool dirty;
} game_context; } game_context;
/***************************************************************************** /*****************************************************************************
@ -577,8 +576,8 @@ static unsigned int find_value(unsigned int number) {
/***************************************************************************** /*****************************************************************************
* draw_card() draws a card to the screen. * draw_card() draws a card to the screen.
******************************************************************************/ ******************************************************************************/
static void draw_card(struct card temp_card, bool shown, unsigned int x, static void draw_card(struct card temp_card, bool shown,
unsigned int y) { unsigned int x, unsigned int y) {
if(shown) if(shown)
rb->lcd_bitmap_part(card_deck, CARD_WIDTH*temp_card.num, rb->lcd_bitmap_part(card_deck, CARD_WIDTH*temp_card.num,
CARD_HEIGHT*temp_card.suit, BMPWIDTH_card_deck, CARD_HEIGHT*temp_card.suit, BMPWIDTH_card_deck,
@ -709,8 +708,7 @@ static void update_total(struct game_context* bj) {
* check_for_aces() is passed an array of cards and returns where an ace is * check_for_aces() is passed an array of cards and returns where an ace is
* located. Otherwise, returns -1. * located. Otherwise, returns -1.
******************************************************************************/ ******************************************************************************/
static signed int check_for_aces(struct card temp_cards[], static signed int check_for_aces(struct card temp_cards[], unsigned int size) {
unsigned int size) {
unsigned int i; unsigned int i;
for(i = 0; i < size; i++) { for(i = 0; i < size; i++) {
if (temp_cards[i].is_soft_ace == true) if (temp_cards[i].is_soft_ace == true)
@ -723,16 +721,16 @@ static signed int check_for_aces(struct card temp_cards[],
* check_totals() compares player and dealer totals. * check_totals() compares player and dealer totals.
* 0: bust 1: loss, 2: push, 3: win, 4: blackjack, 5: something's not right... * 0: bust 1: loss, 2: push, 3: win, 4: blackjack, 5: something's not right...
******************************************************************************/ ******************************************************************************/
static unsigned int check_totals(struct game_context* bj) static unsigned int check_totals(struct game_context* bj) {
{
unsigned int temp; unsigned int temp;
if (bj->player_total > 21) if (bj->player_total > 21)
temp = 0; temp = 0;
else if (bj->player_total == 21 && bj->is_blackjack) else if (bj->player_total == 21 && bj->is_blackjack) {
if (bj->dealer_total == 21 && bj->num_dealer_cards == 2) if (bj->dealer_total == 21 && bj->num_dealer_cards == 2)
temp = 2; temp = 2;
else else
temp = 4; temp = 4;
}
else if (bj->player_total == bj->dealer_total) else if (bj->player_total == bj->dealer_total)
temp = 2; temp = 2;
else if (bj->dealer_total > 21 && bj->player_total < 22) else if (bj->dealer_total > 21 && bj->player_total < 22)
@ -964,7 +962,7 @@ static signed int blackjack_get_amount(char message[20], signed int lower_limit,
signed int upper_limit, signed int upper_limit,
signed int start) { signed int start) {
int button; int button;
char str[6]; char str[9];
bool changed = false; bool changed = false;
unsigned int w, h; unsigned int w, h;
signed int amount; signed int amount;
@ -995,11 +993,11 @@ static signed int blackjack_get_amount(char message[20], signed int lower_limit,
rb->lcd_update(); rb->lcd_update();
#else #else
rb->lcd_set_drawmode(DRMODE_BG+DRMODE_INVERSEVID); rb->lcd_set_drawmode(DRMODE_BG+DRMODE_INVERSEVID);
rb->lcd_fillrect(LCD_WIDTH/2 - 9*w - 1, LCD_HEIGHT/2 - 4*h - 3, 37*w / 2, rb->lcd_fillrect(LCD_WIDTH/2 - 9*w - 1, LCD_HEIGHT/2 - 4*h - 3,
8*h -3); 37*w / 2, 8*h -3);
rb->lcd_set_drawmode(DRMODE_SOLID); rb->lcd_set_drawmode(DRMODE_SOLID);
rb->lcd_drawrect(LCD_WIDTH/2 - 9*w - 1, LCD_HEIGHT/2 - 4*h - 3, 37*w / 2, rb->lcd_drawrect(LCD_WIDTH/2 - 9*w - 1, LCD_HEIGHT/2 - 4*h - 3,
8*h -3); 37*w / 2, 8*h -3);
rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 4*h - 1, message); rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 4*h - 1, message);
rb->snprintf(str, 9, "$%d", amount); rb->snprintf(str, 9, "$%d", amount);
rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 3*h, str); rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 3*h, str);
@ -1021,8 +1019,8 @@ static signed int blackjack_get_amount(char message[20], signed int lower_limit,
rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 + h, "UP: +10"); rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 + h, "UP: +10");
rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 + 2*h + 1, "DOWN: -10"); rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 + 2*h + 1, "DOWN: -10");
#endif #endif
rb->lcd_update_rect(LCD_WIDTH/2 - 9*w - 2, LCD_HEIGHT/2 - 9*h/2, 37*w/2 + 1, rb->lcd_update_rect(LCD_WIDTH/2 - 9*w - 1, LCD_HEIGHT/2 - 4*h - 3,
8*h-2); 37*w / 2, 8*h -3);
#endif #endif
while(true) { while(true) {
@ -1153,7 +1151,10 @@ static unsigned int play_again(void) {
return blackjack_get_yes_no("Play Again?"); return blackjack_get_yes_no("Play Again?");
} }
void showhelp(void) { /*****************************************************************************
* blackjack_help() displays help text.
******************************************************************************/
static bool blackjack_help(void) {
#define WORDS (sizeof help_text / sizeof (char*)) #define WORDS (sizeof help_text / sizeof (char*))
static char *help_text[] = { static char *help_text[] = {
"Blackjack", "", "Blackjack", "",
@ -1184,16 +1185,16 @@ void showhelp(void) {
#endif #endif
if (display_text(WORDS, help_text, formation, NULL)) if (display_text(WORDS, help_text, formation, NULL))
return; return true;
do { do {
button = rb->button_get(true); button = rb->button_get(true);
if (rb->default_event_handler(button) == SYS_USB_CONNECTED) { if (rb->default_event_handler(button) == SYS_USB_CONNECTED) {
return; return true;
} }
} while( ( button == BUTTON_NONE ) } while( ( button == BUTTON_NONE )
|| ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); || ( button & (BUTTON_REL|BUTTON_REPEAT) ) );
rb->lcd_setfont(FONT_SYSFIXED); rb->lcd_setfont(FONT_SYSFIXED);
return; return false;
} }
/***************************************************************************** /*****************************************************************************
@ -1203,8 +1204,10 @@ static unsigned int blackjack_menu(struct game_context* bj) {
int selection=0; int selection=0;
bool breakout = false; bool breakout = false;
MENUITEM_STRINGLIST(menu,"BlackJack Menu",NULL,"Start Game","Resume Game", MENUITEM_STRINGLIST(menu, "BlackJack Menu", NULL,
"High Scores", "Help", "Playback Control", "Quit"); "Start Game","Resume Game",
"High Scores", "Help",
"Playback Control", "Quit");
while(!breakout) { while(!breakout) {
switch(rb->do_menu(&menu, &selection, NULL, false)) { switch(rb->do_menu(&menu, &selection, NULL, false)) {
@ -1215,7 +1218,6 @@ static unsigned int blackjack_menu(struct game_context* bj) {
if(!blackjack_loadgame(bj)) { if(!blackjack_loadgame(bj)) {
rb->splash(HZ*2, "Nothing to resume"); rb->splash(HZ*2, "Nothing to resume");
} else { } else {
rb->splash(HZ*2, "Loading...");
breakout = true; breakout = true;
} }
break; break;
@ -1223,11 +1225,12 @@ static unsigned int blackjack_menu(struct game_context* bj) {
highscore_show(NUM_SCORES, highest, NUM_SCORES, false); highscore_show(NUM_SCORES, highest, NUM_SCORES, false);
break; break;
case 3: case 3:
showhelp(); if(blackjack_help())
return BJ_USB;
break; break;
case 4: case 4:
if (playback_control(NULL)) if (playback_control(NULL))
return 1; return BJ_USB;
break; break;
case 5: case 5:
return BJ_QUIT; return BJ_QUIT;
@ -1253,6 +1256,11 @@ static int blackjack(struct game_context* bj) {
bool breakout = false; bool breakout = false;
bool dbl_down = false; bool dbl_down = false;
#if LCD_DEPTH > 1
rb->lcd_set_background(BG_COLOR);
rb->lcd_set_foreground(FG_COLOR);
#endif
/* don't resume by default */ /* don't resume by default */
bj->resume = false; bj->resume = false;
@ -1268,7 +1276,6 @@ static int blackjack(struct game_context* bj) {
* init * * init *
********************/ ********************/
blackjack_init(bj); blackjack_init(bj);
bj->current_bet=10;
/******************** /********************
* play * * play *
@ -1287,13 +1294,13 @@ static int blackjack(struct game_context* bj) {
todo=2; todo=2;
done=1; done=1;
} }
} }
else { else {
bj->player_money = 1000; bj->player_money = 1000;
bj->current_bet = 10;
blackjack_get_bet(bj); blackjack_get_bet(bj);
if (bj->current_bet == 0) if (bj->current_bet == 0)
return BJ_QUIT; return -1;
rb->lcd_clear_display(); rb->lcd_clear_display();
deal_init_cards(bj); deal_init_cards(bj);
blackjack_drawtable(bj); blackjack_drawtable(bj);
@ -1370,7 +1377,8 @@ static int blackjack(struct game_context* bj) {
bj->end_hand = true; bj->end_hand = true;
break; break;
case BJACK_DOUBLEDOWN: case BJACK_DOUBLEDOWN:
if ((signed int)bj->current_bet * 2 < bj->player_money + 1&& if ((signed int)bj->current_bet * 2 <
bj->player_money + 1 &&
bj->num_player_cards[0]==2 && todo==1) { bj->num_player_cards[0]==2 && todo==1) {
double_down(bj); double_down(bj);
dbl_down = true; dbl_down = true;
@ -1379,7 +1387,8 @@ static int blackjack(struct game_context* bj) {
finish_game(bj); finish_game(bj);
} }
} }
else if((signed int)bj->current_bet * 2 > bj->player_money){ else if((signed int)bj->current_bet * 2 >
bj->player_money){
rb->splash(HZ, "Not enough money to double down."); rb->splash(HZ, "Not enough money to double down.");
redraw_board(bj); redraw_board(bj);
rb->lcd_update(); rb->lcd_update();
@ -1462,7 +1471,11 @@ static int blackjack(struct game_context* bj) {
return BJ_END; return BJ_END;
else { /* User keeps playing */ else { /* User keeps playing */
breakout = false; breakout = false;
temp = bj->current_bet;
bj->current_bet = 0;
redraw_board(bj); redraw_board(bj);
rb->lcd_update();
bj->current_bet = temp;
if(dbl_down) { if(dbl_down) {
bj->current_bet /= 2; bj->current_bet /= 2;
dbl_down = false; dbl_down = false;
@ -1509,7 +1522,7 @@ enum plugin_status plugin_start(const void* parameter)
/* fall through to BJ_END */ /* fall through to BJ_END */
case BJ_END: case BJ_END:
if(!bj.resume) { if(!bj.resume && bj.player_money > 10) {
/* There is no level, so store -1 to blank column */ /* There is no level, so store -1 to blank column */
int position = highscore_update(bj.player_money, -1, "", int position = highscore_update(bj.player_money, -1, "",
highest, NUM_SCORES); highest, NUM_SCORES);
@ -1518,24 +1531,17 @@ enum plugin_status plugin_start(const void* parameter)
} }
if (position != -1) { if (position != -1) {
highscore_show(position, highest, NUM_SCORES, false); highscore_show(position, highest, NUM_SCORES, false);
bj.dirty=true;
} else {
rb->sleep(3);
} }
} }
break; break;
case BJ_USB: case BJ_USB:
rb->lcd_setfont(FONT_UI); rb->lcd_setfont(FONT_UI);
if(bj.dirty) {
highscore_save(HIGH_SCORE,highest,NUM_SCORES); highscore_save(HIGH_SCORE,highest,NUM_SCORES);
}
return PLUGIN_USB_CONNECTED; return PLUGIN_USB_CONNECTED;
case BJ_QUIT: case BJ_QUIT:
if(bj.dirty) {
highscore_save(HIGH_SCORE,highest,NUM_SCORES); highscore_save(HIGH_SCORE,highest,NUM_SCORES);
}
exit = true; exit = true;
break; break;

View file

@ -36,12 +36,13 @@ PLUGIN_HEADER
/* files */ /* files */
#define SCORE_FILE PLUGIN_GAMES_DIR "/bubbles.score" #define SCORE_FILE PLUGIN_GAMES_DIR "/bubbles.score"
#define SAVE_FILE PLUGIN_GAMES_DIR "/bubbles.save" #define SAVE_FILE PLUGIN_GAMES_DIR "/bubbles.save"
#define DATA_FILE PLUGIN_GAMES_DIR "/bubbles.data"
/* final game return status */ /* final game return status */
enum { enum {
BB_LOSE, BB_LOSE,
BB_QUIT, BB_QUIT,
BB_QUIT_AND_SAVE, BB_SAVE_AND_QUIT,
BB_USB, BB_USB,
BB_END, BB_END,
BB_WIN, BB_WIN,
@ -1241,7 +1242,6 @@ struct tile {
/* the game context struct /* the game context struct
* score is the current score * score is the current score
* level is the current level * level is the current level
* highlevel is the highest level beaten
* angle is the current cannon direction * angle is the current cannon direction
* shots is the number of shots fired since last compression * shots is the number of shots fired since last compression
* compress is the height of the compressor * compress is the height of the compressor
@ -1252,13 +1252,11 @@ struct tile {
* elapsedlvl is level elapsed time in 1/100s of seconds * elapsedlvl is level elapsed time in 1/100s of seconds
* elapsedshot is the shot elapsed time in 1/100s of seconds * elapsedshot is the shot elapsed time in 1/100s of seconds
* startedshot is when the current shot began * startedshot is when the current shot began
* resume denotes whether to resume the currently loaded game
* playboard is the game playing board * playboard is the game playing board
*/ */
struct game_context { struct game_context {
unsigned int score; unsigned int score;
unsigned int level; unsigned int level;
unsigned int highlevel;
int angle; int angle;
int shots; int shots;
int compress; int compress;
@ -1276,6 +1274,8 @@ struct highscore highscores[NUM_SCORES];
/* used to denote available resume info */ /* used to denote available resume info */
static bool resume = false; static bool resume = false;
static unsigned int highlevel = 0; /* the highest level beaten */
static unsigned int last_highlevel = 0;
static void bubbles_init(struct game_context* bb); static void bubbles_init(struct game_context* bb);
static bool bubbles_nextlevel(struct game_context* bb); static bool bubbles_nextlevel(struct game_context* bb);
@ -1291,7 +1291,6 @@ static void bubbles_anchored(struct game_context* bb, int row, int col);
static int bubbles_fall(struct game_context* bb); static int bubbles_fall(struct game_context* bb);
static int bubbles_checklevel(struct game_context* bb); static int bubbles_checklevel(struct game_context* bb);
static void bubbles_recordscore(struct game_context* bb); static void bubbles_recordscore(struct game_context* bb);
static void bubbles_savescores(struct game_context* bb);
static bool bubbles_loadgame(struct game_context* bb); static bool bubbles_loadgame(struct game_context* bb);
static void bubbles_savegame(struct game_context* bb); static void bubbles_savegame(struct game_context* bb);
static inline void bubbles_setcolors(void); static inline void bubbles_setcolors(void);
@ -1326,15 +1325,14 @@ static void bubbles_init(struct game_context* bb) {
static bool bubbles_nextlevel(struct game_context* bb) { static bool bubbles_nextlevel(struct game_context* bb) {
int i, j, pos; int i, j, pos;
/* save highest level */
if (bb->level > bb->highlevel)
bb->highlevel = bb->level;
bb->level++; bb->level++;
/* check if there are no more levels */ /* check if there are no more levels */
if(bb->level > NUM_LEVELS) return false; if(bb->level > NUM_LEVELS) return false;
/* save highest level */
if (bb->level-1 > highlevel)
highlevel = bb->level-1;
/* set up the play board */ /* set up the play board */
rb->memset(bb->playboard, 0, sizeof(bb->playboard)); rb->memset(bb->playboard, 0, sizeof(bb->playboard));
@ -2165,7 +2163,7 @@ static void bubbles_recordscore(struct game_context* bb) {
int position; int position;
position = highscore_update(bb->score, bb->level, "", position = highscore_update(bb->score, bb->level-1, "",
highscores, NUM_SCORES); highscores, NUM_SCORES);
if (position==0) if (position==0)
rb->splash(HZ*2, "New High Score"); rb->splash(HZ*2, "New High Score");
@ -2174,36 +2172,43 @@ static void bubbles_recordscore(struct game_context* bb) {
} }
/***************************************************************************** /*****************************************************************************
* bubbles_loadscores() loads the high scores saved file. * bubbles_loaddata() loads highest level beaten.
******************************************************************************/ ******************************************************************************/
static void bubbles_loadscores(struct game_context* bb) { static void bubbles_loaddata(void) {
int fd;
int i; last_highlevel = highlevel = 0;
int highlevel = 0; /* open data file */
/* highlevel and highscores */ fd = rb->open(DATA_FILE, O_RDONLY);
highscore_load(SCORE_FILE, highscores, NUM_SCORES); if (fd < 0) return;
/* level X in the high scores means one succeeded the level before (X-1) */ /* read in saved game */
for (i = 0; i < NUM_SCORES; i++) if (rb->read(fd, &highlevel, sizeof(highlevel)) < (long)sizeof(highlevel))
{ {
if (highscores[i].level-1 > highlevel) highlevel = 0;
{
highlevel = highscores[i].level-1;
}
} }
if (highlevel >= NUM_LEVELS)
highlevel = NUM_LEVELS-1;
last_highlevel = highlevel;
if (bb->highlevel < (unsigned)highlevel) rb->close(fd);
bb->highlevel = highlevel;
} }
/***************************************************************************** /*****************************************************************************
* bubbles_savescores() saves the high scores saved file. * bubbles_savedata() saves the current game state.
******************************************************************************/ ******************************************************************************/
static void bubbles_savescores(struct game_context* bb) { static void bubbles_savedata(void) {
int fd;
/* highscores */ if (last_highlevel >= highlevel) /* no need to save */
(void)bb; return;
highscore_save(SCORE_FILE, highscores, NUM_SCORES+1);
fd = rb->open(DATA_FILE, O_WRONLY|O_CREAT);
if (fd < 0) return;
rb->write(fd, &highlevel, sizeof(highlevel));
rb->close(fd);
} }
/***************************************************************************** /*****************************************************************************
@ -2225,6 +2230,9 @@ static bool bubbles_loadgame(struct game_context* bb) {
} }
rb->close(fd); rb->close(fd);
/* delete saved file */
rb->remove(SAVE_FILE);
return ret; return ret;
} }
@ -2266,8 +2274,8 @@ static inline void bubbles_setcolors(void) {
* on usb connect and shutdown. * on usb connect and shutdown.
******************************************************************************/ ******************************************************************************/
static void bubbles_callback(void* param) { static void bubbles_callback(void* param) {
struct game_context* bb = (struct game_context*) param; (void) param;
bubbles_savescores(bb); highscore_save(SCORE_FILE, highscores, NUM_SCORES);
} }
/***************************************************************************** /*****************************************************************************
@ -2353,23 +2361,20 @@ static int bubbles_handlebuttons(struct game_context* bb, bool animblock,
} }
/***************************************************************************** /*****************************************************************************
* bubbles() is the main game subroutine, it returns the final game status. * bubbles_menu() is the initial menu at the start of the game.
******************************************************************************/ ******************************************************************************/
static int bubbles(struct game_context* bb) { static int bubbles_menu(struct game_context* bb) {
int buttonres; static unsigned int startlevel = 0;
unsigned int startlevel = 0; int selected = resume?0:1;
bool startgame = false; bool startgame = false;
long timeout;
/********************
* menu *
********************/
MENUITEM_STRINGLIST(menu,"Bubbles Menu",NULL, MENUITEM_STRINGLIST(menu,"Bubbles Menu",NULL,
"Resume Game", "Start New Game", "Resume Game", "Start New Game",
"Level", "High Scores", "Playback Control", "Level", "High Scores", "Playback Control",
"Quit", "Quit and Save"); "Quit", "Save and Quit");
while(!startgame){ while(!startgame){
switch (rb->do_menu(&menu, NULL, NULL, false)) switch (rb->do_menu(&menu, &selected, NULL, false))
{ {
case 0: /* resume game */ case 0: /* resume game */
if (!resume) if (!resume)
@ -2379,11 +2384,8 @@ static int bubbles(struct game_context* bb) {
} }
else else
{ {
startlevel = bb->level - 1;
startgame = true; startgame = true;
} }
/* delete saved file */
rb->remove(SAVE_FILE);
break; break;
case 1: /* new game */ case 1: /* new game */
bb->level = startlevel; bb->level = startlevel;
@ -2393,7 +2395,7 @@ static int bubbles(struct game_context* bb) {
case 2: /* choose level */ case 2: /* choose level */
startlevel++; startlevel++;
rb->set_int("Choose start level", "", UNIT_INT, &startlevel, rb->set_int("Choose start level", "", UNIT_INT, &startlevel,
NULL, 1, 1, MIN(NUM_LEVELS,bb->highlevel+1), NULL); NULL, 1, 1, highlevel+1, NULL);
startlevel--; startlevel--;
break; break;
case 3: /* High scores */ case 3: /* High scores */
@ -2404,13 +2406,30 @@ static int bubbles(struct game_context* bb) {
break; break;
case 5: /* quit */ case 5: /* quit */
return BB_QUIT; return BB_QUIT;
case 6: /* quit and save */ case 6: /* save and quit */
return BB_QUIT_AND_SAVE; return BB_SAVE_AND_QUIT;
case MENU_ATTACHED_USB: case MENU_ATTACHED_USB:
bubbles_callback(bb); bubbles_callback(bb);
return BB_USB; return BB_USB;
} }
} }
return 0;
}
/*****************************************************************************
* bubbles() is the main game subroutine, it returns the final game status.
******************************************************************************/
static int bubbles(struct game_context* bb) {
int buttonres;
long timeout;
/********************
* menu *
********************/
buttonres = bubbles_menu(bb);
if(buttonres != 0)
return buttonres;
/******************** /********************
* init * * init *
********************/ ********************/
@ -2464,13 +2483,12 @@ enum plugin_status plugin_start(const void* parameter) {
bool exit = false; bool exit = false;
enum plugin_status ret = PLUGIN_OK; enum plugin_status ret = PLUGIN_OK;
/* plugin init */
(void)parameter; (void)parameter;
/* end of plugin init */
/* load files */ /* load files */
resume = bubbles_loadgame(&bb); resume = bubbles_loadgame(&bb);
bubbles_loadscores(&bb); bubbles_loaddata();
highscore_load(SCORE_FILE, highscores, NUM_SCORES);
rb->lcd_clear_display(); rb->lcd_clear_display();
/* start app */ /* start app */
@ -2484,7 +2502,7 @@ enum plugin_status plugin_start(const void* parameter) {
case BB_WIN: case BB_WIN:
rb->splash(HZ*2, "You Win!"); rb->splash(HZ*2, "You Win!");
/* record high level */ /* record high level */
bb.highlevel = NUM_LEVELS; highlevel = NUM_LEVELS-1;
/* record high score */ /* record high score */
bubbles_recordscore(&bb); bubbles_recordscore(&bb);
break; break;
@ -2501,15 +2519,17 @@ enum plugin_status plugin_start(const void* parameter) {
case BB_USB: case BB_USB:
ret = PLUGIN_USB_CONNECTED; ret = PLUGIN_USB_CONNECTED;
exit = true;
break; break;
case BB_QUIT_AND_SAVE: case BB_SAVE_AND_QUIT:
rb->splash(HZ/2, "Saving Game and Scors"); rb->splash(HZ/2, "Saving Game ...");
bubbles_savescores(&bb);
bubbles_savegame(&bb); bubbles_savegame(&bb);
/* fall through */ /* fall through */
case BB_QUIT: case BB_QUIT:
bubbles_savedata();
highscore_save(SCORE_FILE, highscores, NUM_SCORES);
exit = true; exit = true;
break; break;

View file

@ -343,18 +343,8 @@ static void draw_calendar(struct shown *shown)
int x,y,pos,days_per_month,j; int x,y,pos,days_per_month,j;
char buffer[9]; char buffer[9];
const char *monthname[] = { const char *monthname[] = {
"Jan", "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Feb", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
}; };
if(use_system_font) if(use_system_font)
rb->lcd_setfont(FONT_SYSFIXED); rb->lcd_setfont(FONT_SYSFIXED);
@ -421,7 +411,7 @@ static int memos_in_shown_memory = 0;
static void load_memo(struct shown *shown) static void load_memo(struct shown *shown)
{ {
int i, k, fp; int k, fp;
bool exit = false; bool exit = false;
char temp_memo1[2]; char temp_memo1[2];
char temp_memo2[3]; char temp_memo2[3];
@ -429,18 +419,6 @@ static void load_memo(struct shown *shown)
temp_memo1[1] = 0; temp_memo1[1] = 0;
temp_memo2[2] = 0; temp_memo2[2] = 0;
temp_memo4[4] = 0; temp_memo4[4] = 0;
for (k = 0; k < memos_in_memory; k++)
{
memos[k].day = 0;
memos[k].month = 0;
memos[k].file_pointer_start = 0;
memos[k].file_pointer_end = 0;
memos[k].year = 0;
memos[k].type = 0;
memos[k].wday = 0;
for (i = 0; i < MAX_CHAR_MEMO_LEN; i++)
memos[k].message[i] = 0;
}
for (k = 1; k < 32; k++) for (k = 1; k < 32; k++)
day_has_memo[k] = false; day_has_memo[k] = false;
for (k = 0; k < 7; k++) for (k = 0; k < 7; k++)
@ -449,12 +427,13 @@ static void load_memo(struct shown *shown)
fp = rb->open(ROCKBOX_DIR "/.memo",O_RDONLY); fp = rb->open(ROCKBOX_DIR "/.memo",O_RDONLY);
if (fp > -1) if (fp > -1)
{ {
int count = rb->filesize(fp);
rb->lseek(fp, 0, SEEK_SET); rb->lseek(fp, 0, SEEK_SET);
while (!exit) while (!exit)
{ {
memos[memos_in_memory].file_pointer_start = rb->lseek(fp, 0, bool load_to_memory;
SEEK_CUR); rb->memset(&memos[memos_in_memory].message, 0, MAX_CHAR_MEMO_LEN);
memos[memos_in_memory].file_pointer_start =
rb->lseek(fp, 0, SEEK_CUR);
if (rb->read(fp, temp_memo2, 2) == 2) if (rb->read(fp, temp_memo2, 2) == 2)
memos[memos_in_memory].day = rb->atoi(&temp_memo2[0]); memos[memos_in_memory].day = rb->atoi(&temp_memo2[0]);
else else
@ -481,27 +460,29 @@ static void load_memo(struct shown *shown)
memos[memos_in_memory].type = rb->atoi(&temp_memo1[0]); memos[memos_in_memory].type = rb->atoi(&temp_memo1[0]);
else else
memos[memos_in_memory].type = 0; memos[memos_in_memory].type = 0;
for (k = 0; k <= count; k++) load_to_memory = ((memos[memos_in_memory].type < 2) ||
((memos[memos_in_memory].type == 2) &&
(memos[memos_in_memory].month == shown->mon)) ||
((memos[memos_in_memory].type > 2) &&
(memos[memos_in_memory].month == shown->mon) &&
(memos[memos_in_memory].year == shown->year)));
k = 0;
while (1)
{ {
if (rb->read(fp, temp_memo1, 1) == 1) if (rb->read(fp, temp_memo1, 1) != 1)
{ {
if ( memos[memos_in_memory].day = 0;
(memos[memos_in_memory].type < 2) memos[memos_in_memory].month = 0;
|| memos[memos_in_memory].file_pointer_start = 0;
( memos[memos_in_memory].file_pointer_end = 0;
(memos[memos_in_memory].type == 2) memos[memos_in_memory].year = 0;
&& memos[memos_in_memory].type = 0;
(memos[memos_in_memory].month == shown->mon) memos[memos_in_memory].wday = 0;
) memos[memos_in_memory].message[0] = 0;
|| exit = true;
( break;
(memos[memos_in_memory].type > 2) }
&& if (load_to_memory)
(memos[memos_in_memory].month == shown->mon)
&&
(memos[memos_in_memory].year == shown->year)
)
)
{ {
if (temp_memo1[0] == '\n') if (temp_memo1[0] == '\n')
{ {
@ -517,25 +498,11 @@ static void load_memo(struct shown *shown)
else if ( (temp_memo1[0] != '\r') && else if ( (temp_memo1[0] != '\r') &&
(temp_memo1[0] != '\t') && (temp_memo1[0] != '\t') &&
k < MAX_CHAR_MEMO_LEN-1 ) k < MAX_CHAR_MEMO_LEN-1 )
memos[memos_in_memory].message[k] = temp_memo1[0]; memos[memos_in_memory].message[k++] = temp_memo1[0];
} }
if (temp_memo1[0] == '\n') if (temp_memo1[0] == '\n')
break; break;
} }
else
{
memos[memos_in_memory].day = 0;
memos[memos_in_memory].month = 0;
memos[memos_in_memory].file_pointer_start = 0;
memos[memos_in_memory].file_pointer_end = 0;
memos[memos_in_memory].year = 0;
memos[memos_in_memory].type = 0;
memos[memos_in_memory].wday = 0;
memos[memos_in_memory].message[0] = 0;
exit = true;
break;
}
}
} }
} }
rb->close(fp); rb->close(fp);
@ -546,7 +513,7 @@ static bool save_memo(int changed, bool new_mod, struct shown *shown)
int fp,fq; int fp,fq;
fp = rb->open(ROCKBOX_DIR "/.memo",O_RDONLY | O_CREAT); fp = rb->open(ROCKBOX_DIR "/.memo",O_RDONLY | O_CREAT);
fq = rb->creat(ROCKBOX_DIR "/~temp"); fq = rb->creat(ROCKBOX_DIR "/~temp");
if ( (fq != -1) && (fp != -1) ) if ( (fq > -1) && (fp > -1) )
{ {
int i; int i;
char temp[MAX_CHAR_MEMO_LEN]; char temp[MAX_CHAR_MEMO_LEN];
@ -578,9 +545,9 @@ static bool save_memo(int changed, bool new_mod, struct shown *shown)
load_memo(shown); load_memo(shown);
return true; return true;
} }
else if (fp != -1) else if (fp > -1)
rb->close(fp); rb->close(fp);
else if (fq != -1) else if (fq > -1)
rb->close(fq); rb->close(fq);
return false; return false;
} }
@ -746,19 +713,10 @@ static void update_memos_shown(struct shown *shown)
int i; int i;
memos_in_shown_memory = 0; memos_in_shown_memory = 0;
for (i = 0; i < memos_in_memory; i++) for (i = 0; i < memos_in_memory; i++)
if ( if (((memos[i].type >= 1) &&
( (memos[i].day == shown->mday)) ||
(memos[i].type >= 1) ((memos[i].type < 1) &&
&& (memos[i].wday == shown->wday)))
(memos[i].day == shown->mday)
)
||
(
(memos[i].type < 1)
&&
(memos[i].wday == shown->wday)
)
)
pointer_array[memos_in_shown_memory++] = i; pointer_array[memos_in_shown_memory++] = i;
} }

View file

@ -605,7 +605,7 @@ static int clix_menu(struct clix_game_state_t* state, bool ingame)
"Resume Game", "Resume Game",
"Start New Game", "Start New Game",
"Help", "Help",
"High Score", "High Scores",
"Playback Control", "Playback Control",
"Quit"); "Quit");

View file

@ -1323,7 +1323,7 @@ static int jewels_game_menu(struct game_context* bj, bool ingame)
"Start New Game", "Start New Game",
"Mode", "Mode",
"Help", "Help",
"High Score", "High Scores",
"Playback Control", "Playback Control",
"Quit without Saving", "Quit without Saving",
"Quit"); "Quit");

View file

@ -129,7 +129,6 @@ void highscore_show(int position, struct highscore *scores, int num_scores, bool
rb->lcd_set_background(LCD_BLACK); rb->lcd_set_background(LCD_BLACK);
rb->lcd_set_foreground(LCD_WHITE); rb->lcd_set_foreground(LCD_WHITE);
#endif #endif
rb->button_clear_queue();
rb->lcd_clear_display(); rb->lcd_clear_display();
rb->lcd_setfont(FONT_UI); rb->lcd_setfont(FONT_UI);
@ -174,6 +173,8 @@ void highscore_show(int position, struct highscore *scores, int num_scores, bool
} }
} }
rb->lcd_update(); rb->lcd_update();
rb->sleep(HZ/2);
rb->button_clear_queue();
rb->button_get(true); rb->button_get(true);
rb->lcd_setfont(FONT_SYSFIXED); rb->lcd_setfont(FONT_SYSFIXED);
} }

View file

@ -77,7 +77,7 @@ PLUGIN_HEADER
#define PATTERN_GROWTH_1 1 #define PATTERN_GROWTH_1 1
#define PATTERN_GROWTH_2 2 #define PATTERN_GROWTH_2 2
#define PATTERN_ACORN 3 #define PATTERN_ACORN 3
#define PATTERN_GLIDER_GUN 4 /* not yet implemented */ #define PATTERN_GLIDER_GUN 4
const struct button_mapping *plugin_contexts[] const struct button_mapping *plugin_contexts[]
= {generic_directions, generic_actions}; = {generic_directions, generic_actions};

View file

@ -644,7 +644,7 @@ static int spacerocks_menu(bool ingame)
"Resume Game", "Resume Game",
"Start New Game", "Start New Game",
"Help", "Help",
"High Score", "High Scores",
"Playback Control", "Playback Control",
"Quit"); "Quit");

View file

@ -63,10 +63,6 @@ PLUGIN_HEADER
#define MULTIPLAYER #define MULTIPLAYER
#endif #endif
#define PLAYERS_TEXT "UP/DN"
#define WORMS_TEXT "L/R"
#define KEY_CONTROL_TEXT "F1"
#elif (CONFIG_KEYPAD == ARCHOS_AV300_PAD) #elif (CONFIG_KEYPAD == ARCHOS_AV300_PAD)
#define BTN_DIR_UP BUTTON_UP #define BTN_DIR_UP BUTTON_UP
#define BTN_DIR_DOWN BUTTON_DOWN #define BTN_DIR_DOWN BUTTON_DOWN
@ -79,10 +75,6 @@ PLUGIN_HEADER
#define BTN_STOPRESET BUTTON_ON #define BTN_STOPRESET BUTTON_ON
#define BTN_TOGGLE_KEYS BUTTON_F1 #define BTN_TOGGLE_KEYS BUTTON_F1
#define PLAYERS_TEXT "UP/DN"
#define WORMS_TEXT "L/R"
#define KEY_CONTROL_TEXT "F1"
#elif (CONFIG_KEYPAD == ONDIO_PAD) #elif (CONFIG_KEYPAD == ONDIO_PAD)
#define BTN_DIR_UP BUTTON_UP #define BTN_DIR_UP BUTTON_UP
#define BTN_DIR_DOWN BUTTON_DOWN #define BTN_DIR_DOWN BUTTON_DOWN
@ -92,9 +84,6 @@ PLUGIN_HEADER
#define BTN_QUIT (BUTTON_OFF|BUTTON_REL) #define BTN_QUIT (BUTTON_OFF|BUTTON_REL)
#define BTN_STOPRESET (BUTTON_OFF|BUTTON_MENU) #define BTN_STOPRESET (BUTTON_OFF|BUTTON_MENU)
#define PLAYERS_TEXT "UP/DN"
#define WORMS_TEXT "L/R"
#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \ #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \
(CONFIG_KEYPAD == IPOD_1G2G_PAD) (CONFIG_KEYPAD == IPOD_1G2G_PAD)
@ -106,9 +95,6 @@ PLUGIN_HEADER
#define BTN_QUIT (BUTTON_SELECT|BUTTON_MENU) #define BTN_QUIT (BUTTON_SELECT|BUTTON_MENU)
#define BTN_STOPRESET (BUTTON_SELECT|BUTTON_PLAY) #define BTN_STOPRESET (BUTTON_SELECT|BUTTON_PLAY)
#define PLAYERS_TEXT "Menu/Play"
#define WORMS_TEXT "Left/Right"
#elif (CONFIG_KEYPAD == IRIVER_H300_PAD) || (CONFIG_KEYPAD == IRIVER_H100_PAD) #elif (CONFIG_KEYPAD == IRIVER_H300_PAD) || (CONFIG_KEYPAD == IRIVER_H100_PAD)
#define BTN_DIR_UP BUTTON_UP #define BTN_DIR_UP BUTTON_UP
@ -121,9 +107,6 @@ PLUGIN_HEADER
#define BTN_RC_QUIT BUTTON_RC_STOP #define BTN_RC_QUIT BUTTON_RC_STOP
#define PLAYERS_TEXT "Up/Down"
#define WORMS_TEXT "Left/Right"
#elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD) #elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD)
#define BTN_DIR_UP BUTTON_UP #define BTN_DIR_UP BUTTON_UP
@ -134,9 +117,6 @@ PLUGIN_HEADER
#define BTN_QUIT BUTTON_POWER #define BTN_QUIT BUTTON_POWER
#define BTN_STOPRESET BUTTON_REC #define BTN_STOPRESET BUTTON_REC
#define PLAYERS_TEXT "Up/Down"
#define WORMS_TEXT "Left/Right"
#elif (CONFIG_KEYPAD == GIGABEAT_PAD) #elif (CONFIG_KEYPAD == GIGABEAT_PAD)
#define BTN_DIR_UP BUTTON_UP #define BTN_DIR_UP BUTTON_UP
@ -147,10 +127,6 @@ PLUGIN_HEADER
#define BTN_QUIT BUTTON_POWER #define BTN_QUIT BUTTON_POWER
#define BTN_STOPRESET BUTTON_A #define BTN_STOPRESET BUTTON_A
#define PLAYERS_TEXT "Up/Down"
#define WORMS_TEXT "Left/Right"
#elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \ #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
(CONFIG_KEYPAD == SANSA_C200_PAD) (CONFIG_KEYPAD == SANSA_C200_PAD)
@ -162,9 +138,6 @@ PLUGIN_HEADER
#define BTN_QUIT BUTTON_POWER #define BTN_QUIT BUTTON_POWER
#define BTN_STOPRESET BUTTON_REC #define BTN_STOPRESET BUTTON_REC
#define PLAYERS_TEXT "Up/Down"
#define WORMS_TEXT "Left/Right"
#elif (CONFIG_KEYPAD == SANSA_CLIP_PAD) #elif (CONFIG_KEYPAD == SANSA_CLIP_PAD)
#define BTN_DIR_UP BUTTON_UP #define BTN_DIR_UP BUTTON_UP
@ -175,9 +148,6 @@ PLUGIN_HEADER
#define BTN_QUIT BUTTON_POWER #define BTN_QUIT BUTTON_POWER
#define BTN_STOPRESET BUTTON_HOME #define BTN_STOPRESET BUTTON_HOME
#define PLAYERS_TEXT "Up/Down"
#define WORMS_TEXT "Left/Right"
#elif (CONFIG_KEYPAD == SANSA_FUZE_PAD) #elif (CONFIG_KEYPAD == SANSA_FUZE_PAD)
#define BTN_DIR_UP BUTTON_UP #define BTN_DIR_UP BUTTON_UP
@ -188,9 +158,6 @@ PLUGIN_HEADER
#define BTN_QUIT (BUTTON_HOME|BUTTON_REPEAT) #define BTN_QUIT (BUTTON_HOME|BUTTON_REPEAT)
#define BTN_STOPRESET (BUTTON_SELECT | BUTTON_UP) #define BTN_STOPRESET (BUTTON_SELECT | BUTTON_UP)
#define PLAYERS_TEXT "Up/Down"
#define WORMS_TEXT "Left/Right"
#elif (CONFIG_KEYPAD == SANSA_M200_PAD) #elif (CONFIG_KEYPAD == SANSA_M200_PAD)
#define BTN_DIR_UP BUTTON_UP #define BTN_DIR_UP BUTTON_UP
@ -201,9 +168,6 @@ PLUGIN_HEADER
#define BTN_QUIT BUTTON_POWER #define BTN_QUIT BUTTON_POWER
#define BTN_STOPRESET (BUTTON_SELECT | BUTTON_UP) #define BTN_STOPRESET (BUTTON_SELECT | BUTTON_UP)
#define PLAYERS_TEXT "Up/Down"
#define WORMS_TEXT "Left/Right"
#elif (CONFIG_KEYPAD == IRIVER_H10_PAD) #elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
#define BTN_DIR_UP BUTTON_SCROLL_UP #define BTN_DIR_UP BUTTON_SCROLL_UP
@ -214,9 +178,6 @@ PLUGIN_HEADER
#define BTN_QUIT BUTTON_POWER #define BTN_QUIT BUTTON_POWER
#define BTN_STOPRESET BUTTON_REW #define BTN_STOPRESET BUTTON_REW
#define PLAYERS_TEXT "Up/Down"
#define WORMS_TEXT "Left/Right"
#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) #elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
#define BTN_DIR_UP BUTTON_UP #define BTN_DIR_UP BUTTON_UP
@ -227,9 +188,6 @@ PLUGIN_HEADER
#define BTN_QUIT BUTTON_BACK #define BTN_QUIT BUTTON_BACK
#define BTN_STOPRESET BUTTON_MENU #define BTN_STOPRESET BUTTON_MENU
#define PLAYERS_TEXT "Up/Down"
#define WORMS_TEXT "Left/Right"
#elif (CONFIG_KEYPAD == MROBE100_PAD) #elif (CONFIG_KEYPAD == MROBE100_PAD)
#define BTN_DIR_UP BUTTON_UP #define BTN_DIR_UP BUTTON_UP
@ -240,9 +198,6 @@ PLUGIN_HEADER
#define BTN_QUIT BUTTON_POWER #define BTN_QUIT BUTTON_POWER
#define BTN_STOPRESET BUTTON_DISPLAY #define BTN_STOPRESET BUTTON_DISPLAY
#define PLAYERS_TEXT "Up/Down"
#define WORMS_TEXT "Left/Right"
#elif CONFIG_KEYPAD == IAUDIO_M3_PAD #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
#define BTN_DIR_UP BUTTON_RC_VOL_UP #define BTN_DIR_UP BUTTON_RC_VOL_UP
@ -253,9 +208,6 @@ PLUGIN_HEADER
#define BTN_QUIT BUTTON_RC_REC #define BTN_QUIT BUTTON_RC_REC
#define BTN_STOPRESET BUTTON_RC_MODE #define BTN_STOPRESET BUTTON_RC_MODE
#define PLAYERS_TEXT "VOL UP/DN"
#define WORMS_TEXT "REW/FF"
#elif (CONFIG_KEYPAD == COWOND2_PAD) #elif (CONFIG_KEYPAD == COWOND2_PAD)
#define BTN_QUIT BUTTON_POWER #define BTN_QUIT BUTTON_POWER
@ -270,9 +222,6 @@ PLUGIN_HEADER
#define BTN_QUIT BUTTON_BACK #define BTN_QUIT BUTTON_BACK
#define BTN_STOPRESET BUTTON_MENU #define BTN_STOPRESET BUTTON_MENU
#define PLAYERS_TEXT "Up/Down"
#define WORMS_TEXT "Left/Right"
#elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
#define BTN_DIR_UP BUTTON_UP #define BTN_DIR_UP BUTTON_UP
@ -283,9 +232,6 @@ PLUGIN_HEADER
#define BTN_QUIT BUTTON_POWER #define BTN_QUIT BUTTON_POWER
#define BTN_STOPRESET BUTTON_VIEW #define BTN_STOPRESET BUTTON_VIEW
#define PLAYERS_TEXT "Up/Down"
#define WORMS_TEXT "Left/Right"
#elif (CONFIG_KEYPAD == ONDAVX747_PAD) || CONFIG_KEYPAD == MROBE500_PAD #elif (CONFIG_KEYPAD == ONDAVX747_PAD) || CONFIG_KEYPAD == MROBE500_PAD
#define BTN_QUIT BUTTON_POWER #define BTN_QUIT BUTTON_POWER
@ -315,17 +261,9 @@ PLUGIN_HEADER
#endif #endif
#ifndef BTN_STOPRESET #ifndef BTN_STOPRESET
#define BTN_STOPRESET BUTTON_TOPRIGHT #define BTN_STOPRESET BUTTON_TOPRIGHT
#endif
#ifndef PLAYERS_TEXT
#define PLAYERS_TEXT "Up/Down"
#endif
#ifndef WORMS_TEXT
#define WORMS_TEXT "Left/Right"
#endif #endif
#endif #endif
#if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64) #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
#define FOOD_SIZE 3 #define FOOD_SIZE 3
#define ARGH_SIZE 4 #define ARGH_SIZE 4
@ -524,7 +462,8 @@ static void set_debug_out(char *str){
* @return int A value 0 <= value < 4 * @return int A value 0 <= value < 4
* Note the predefined constants NORTH, SOUTH, EAST, WEST * Note the predefined constants NORTH, SOUTH, EAST, WEST
*/ */
static int get_worm_dir(struct worm *w) { static int get_worm_dir(struct worm *w)
{
int retVal ; int retVal ;
if (w->dirx == 0) { if (w->dirx == 0) {
if (w->diry == 1) { if (w->diry == 1) {
@ -551,7 +490,8 @@ static int get_worm_dir(struct worm *w) {
* dir must be 0 <= dir < 4. Use predefined constants * dir must be 0 <= dir < 4. Use predefined constants
* NORTH, SOUTH, EAST, WEST * NORTH, SOUTH, EAST, WEST
*/ */
static void set_worm_dir(struct worm *w, int dir) { static void set_worm_dir(struct worm *w, int dir)
{
switch (dir) { switch (dir) {
case WEST: case WEST:
w->dirx = -1; w->dirx = -1;
@ -577,7 +517,8 @@ static void set_worm_dir(struct worm *w, int dir) {
* is also a value for the number of bends that are in the worm. * is also a value for the number of bends that are in the worm.
* @return int a positive value with 0 <= value < MAX_WORM_SEGMENTS * @return int a positive value with 0 <= value < MAX_WORM_SEGMENTS
*/ */
static int get_worm_array_length(struct worm *w) { static int get_worm_array_length(struct worm *w)
{
/* initial simple calculation will be overwritten if wrong. */ /* initial simple calculation will be overwritten if wrong. */
int retVal = w->head - w->tail; int retVal = w->head - w->tail;
@ -596,7 +537,8 @@ static int get_worm_array_length(struct worm *w) {
* w must not be null. * w must not be null.
* @return int The length of the worm (>= 0). * @return int The length of the worm (>= 0).
*/ */
static int get_score(struct worm *w) { static int get_score(struct worm *w)
{
int retval = 0; int retval = 0;
int length = get_worm_array_length(w); int length = get_worm_array_length(w);
int i; int i;
@ -639,7 +581,9 @@ static int get_score(struct worm *w) {
* @param int height The height of the rectangle. * @param int height The height of the rectangle.
* @return bool Returns true if the specified line intersects with the recangle. * @return bool Returns true if the specified line intersects with the recangle.
*/ */
static bool line_in_rect(int startx, int starty, int endx, int endy, int x, int y, int width, int height) { static bool line_in_rect(int startx, int starty, int endx, int endy,
int x, int y, int width, int height)
{
bool retval = false; bool retval = false;
int simple, simplemin, simplemax; int simple, simplemin, simplemax;
int compa, compb, compmin, compmax; int compa, compb, compmin, compmax;
@ -687,7 +631,8 @@ static bool line_in_rect(int startx, int starty, int endx, int endy, int x, int
* @param int height The height of the rect * @param int height The height of the rect
* @return bool Returns true if the worm intersects with the rect * @return bool Returns true if the worm intersects with the rect
*/ */
static bool worm_in_rect(struct worm *w, int x, int y, int width, int height) { static bool worm_in_rect(struct worm *w, int x, int y, int width, int height)
{
bool retval = false; bool retval = false;
@ -722,7 +667,8 @@ static bool worm_in_rect(struct worm *w, int x, int y, int width, int height) {
* @return Returns true if the coordinate hits the food specified by * @return Returns true if the coordinate hits the food specified by
* foodIndex. * foodIndex.
*/ */
static bool specific_food_collision(int foodIndex, int x, int y) { static bool specific_food_collision(int foodIndex, int x, int y)
{
bool retVal = false; bool retVal = false;
if (x >= foodx[foodIndex] && if (x >= foodx[foodIndex] &&
x < foodx[foodIndex] + food_size && x < foodx[foodIndex] + food_size &&
@ -740,7 +686,8 @@ static bool specific_food_collision(int foodIndex, int x, int y) {
* -1 is returned. * -1 is returned.
* @return int -1 <= value < MAX_FOOD * @return int -1 <= value < MAX_FOOD
*/ */
static int food_collision(int x, int y) { static int food_collision(int x, int y)
{
int i = 0; int i = 0;
int retVal = -1; int retVal = -1;
for (i = 0; i < MAX_FOOD; i++) { for (i = 0; i < MAX_FOOD; i++) {
@ -761,8 +708,8 @@ static int food_collision(int x, int y) {
* @return Returns true if the coordinate hits the argh specified by * @return Returns true if the coordinate hits the argh specified by
* arghIndex. * arghIndex.
*/ */
static bool specific_argh_collision(int arghIndex, int x, int y) { static bool specific_argh_collision(int arghIndex, int x, int y)
{
if ( x >= arghx[arghIndex] && if ( x >= arghx[arghIndex] &&
y >= arghy[arghIndex] && y >= arghy[arghIndex] &&
x < arghx[arghIndex] + argh_size && x < arghx[arghIndex] + argh_size &&
@ -782,7 +729,8 @@ static bool specific_argh_collision(int arghIndex, int x, int y) {
* @param int y The y coordinate. * @param int y The y coordinate.
* @return int -1 <= value < argh_count <= MAX_ARGH * @return int -1 <= value < argh_count <= MAX_ARGH
*/ */
static int argh_collision(int x, int y) { static int argh_collision(int x, int y)
{
int i = 0; int i = 0;
int retVal = -1; int retVal = -1;
@ -821,7 +769,8 @@ static bool worm_food_collision(struct worm *w, int foodIndex)
* @return Returns false if the specified argh is not hit within the next * @return Returns false if the specified argh is not hit within the next
* moves. * moves.
*/ */
static bool worm_argh_collision_in_moves(struct worm *w, int argh_idx, int moves){ static bool worm_argh_collision_in_moves(struct worm *w, int argh_idx, int moves)
{
bool retVal = false; bool retVal = false;
int x1, y1, x2, y2; int x1, y1, x2, y2;
x1 = w->x[w->head]; x1 = w->x[w->head];
@ -857,8 +806,8 @@ static bool worm_argh_collision(struct worm *w, int arghIndex)
* @param int index * @param int index
* Ensure that 0 <= index < MAX_FOOD. * Ensure that 0 <= index < MAX_FOOD.
*/ */
static void make_food(int index) { static void make_food(int index)
{
int x = 0; int x = 0;
int y = 0; int y = 0;
bool collisionDetected = false; bool collisionDetected = false;
@ -1020,7 +969,8 @@ static void virtual_player(struct worm *w);
* @param int y The y coordinate at which the tail of the worm starts * @param int y The y coordinate at which the tail of the worm starts
* y must be 0 <= y < FIELD_RECT_WIDTH. * y must be 0 <= y < FIELD_RECT_WIDTH.
*/ */
static void init_worm(struct worm *w, int x, int y){ static void init_worm(struct worm *w, int x, int y)
{
/* initialize the worm size */ /* initialize the worm size */
w->head = 1; w->head = 1;
w->tail = 0; w->tail = 0;
@ -1223,12 +1173,12 @@ static void move_worm(struct worm *w)
*/ */
static void draw_worm(struct worm *w) static void draw_worm(struct worm *w)
{ {
#ifdef HAVE_LCD_COLOR
rb->lcd_set_foreground(COLOR_WORM);
#endif
/* draw the new head */ /* draw the new head */
int x = w->x[w->head]; int x = w->x[w->head];
int y = w->y[w->head]; int y = w->y[w->head];
#ifdef HAVE_LCD_COLOR
rb->lcd_set_foreground(COLOR_WORM);
#endif
if (x >= 0 && x < FIELD_RECT_WIDTH && y >= 0 && y < FIELD_RECT_HEIGHT) { if (x >= 0 && x < FIELD_RECT_WIDTH && y >= 0 && y < FIELD_RECT_HEIGHT) {
rb->lcd_drawpixel(x + FIELD_RECT_X, y + FIELD_RECT_Y); rb->lcd_drawpixel(x + FIELD_RECT_X, y + FIELD_RECT_Y);
} }
@ -1325,7 +1275,8 @@ static void add_growing(struct worm *w, int len) {
* @return struct worm* The worm that has been hit by x,y. If no worm * @return struct worm* The worm that has been hit by x,y. If no worm
* was at the position NULL is returned. * was at the position NULL is returned.
*/ */
static struct worm* worm_collision(struct worm *w, int x, int y){ static struct worm* worm_collision(struct worm *w, int x, int y)
{
struct worm *retVal = NULL; struct worm *retVal = NULL;
int i; int i;
for (i = 0; (i < worm_count) && (retVal == NULL); i++) { for (i = 0; (i < worm_count) && (retVal == NULL); i++) {
@ -1366,7 +1317,8 @@ static bool field_collision(struct worm *w)
* @return bool Returns false if x,y specifies a point outside the * @return bool Returns false if x,y specifies a point outside the
* field of worms. * field of worms.
*/ */
static bool is_in_field_rect(int x, int y) { static bool is_in_field_rect(int x, int y)
{
bool retVal = false; bool retVal = false;
retVal = (x >= 0 && x < FIELD_RECT_WIDTH && retVal = (x >= 0 && x < FIELD_RECT_WIDTH &&
y >= 0 && y < FIELD_RECT_HEIGHT); y >= 0 && y < FIELD_RECT_HEIGHT);
@ -1410,7 +1362,8 @@ static int check_collision(struct worm *w)
* @param int y The y coordinate of the point * @param int y The y coordinate of the point
* @return int A value usable as index in foodx and foody. * @return int A value usable as index in foodx and foody.
*/ */
static int get_nearest_food(int x, int y){ static int get_nearest_food(int x, int y)
{
int nearestfood = 0; int nearestfood = 0;
int olddistance = FIELD_RECT_WIDTH + FIELD_RECT_HEIGHT; int olddistance = FIELD_RECT_WIDTH + FIELD_RECT_HEIGHT;
int deltax = 0; int deltax = 0;
@ -1443,7 +1396,8 @@ static int get_nearest_food(int x, int y){
* @return Returns true if the worm will hit the position unless * @return Returns true if the worm will hit the position unless
* it change its direction before the next move. * it change its direction before the next move.
*/ */
static bool is_in_front_of_worm(struct worm *w, int x, int y) { static bool is_in_front_of_worm(struct worm *w, int x, int y)
{
bool infront = false; bool infront = false;
int deltax = x - w->x[w->head]; int deltax = x - w->x[w->head];
int deltay = y - w->y[w->head]; int deltay = y - w->y[w->head];
@ -1463,7 +1417,8 @@ static bool is_in_front_of_worm(struct worm *w, int x, int y) {
* @return Returns true if the worm will collide with the next move * @return Returns true if the worm will collide with the next move
* unless it changes its direction. * unless it changes its direction.
*/ */
static bool will_worm_collide(struct worm *w) { static bool will_worm_collide(struct worm *w)
{
int x = w->x[w->head] + w->dirx; int x = w->x[w->head] + w->dirx;
int y = w->y[w->head] + w->diry; int y = w->y[w->head] + w->diry;
bool retVal = !is_in_field_rect(x, y); bool retVal = !is_in_field_rect(x, y);
@ -1487,7 +1442,8 @@ static bool will_worm_collide(struct worm *w) {
* @param struct worm *w - The worm of which the direction * @param struct worm *w - The worm of which the direction
* is altered. * is altered.
*/ */
static void virtual_player(struct worm *w) { static void virtual_player(struct worm *w)
{
bool isright; bool isright;
int plana, planb, planc; int plana, planb, planc;
/* find the next lunch */ /* find the next lunch */
@ -1554,7 +1510,8 @@ static void score_board(void)
int i; int i;
int y = 0; int y = 0;
rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
rb->lcd_fillrect(FIELD_RECT_WIDTH + 2, 0, LCD_WIDTH - FIELD_RECT_WIDTH - 2, LCD_HEIGHT); rb->lcd_fillrect(FIELD_RECT_WIDTH + 2, 0,
LCD_WIDTH - FIELD_RECT_WIDTH - 2, LCD_HEIGHT);
rb->lcd_set_drawmode(DRMODE_SOLID); rb->lcd_set_drawmode(DRMODE_SOLID);
for (i = 0; i < worm_count; i++) { for (i = 0; i < worm_count; i++) {
int score = get_score(&worms[i]); int score = get_score(&worms[i]);
@ -1834,7 +1791,8 @@ static int run(void)
* Just a test routine that checks that worm_food_collision works * Just a test routine that checks that worm_food_collision works
* in some typical situations. * in some typical situations.
*/ */
static void test_worm_food_collision(void) { static void test_worm_food_collision(void)
{
int collision_count = 0; int collision_count = 0;
int i; int i;
rb->lcd_clear_display(); rb->lcd_clear_display();
@ -1892,7 +1850,8 @@ static void test_worm_food_collision(void) {
} }
static bool expensive_worm_in_rect(struct worm *w, int rx, int ry, int rw, int rh){ static bool expensive_worm_in_rect(struct worm *w, int rx, int ry, int rw, int rh)
{
int x, y; int x, y;
bool retVal = false; bool retVal = false;
for (x = rx; x < rx + rw; x++){ for (x = rx; x < rx + rw; x++){
@ -1905,7 +1864,8 @@ static bool expensive_worm_in_rect(struct worm *w, int rx, int ry, int rw, int r
return retVal; return retVal;
} }
static void test_worm_argh_collision(void) { static void test_worm_argh_collision(void)
{
int i; int i;
int dir; int dir;
int collision_count = 0; int collision_count = 0;
@ -1955,7 +1915,8 @@ static void test_worm_argh_collision(void) {
} }
} }
static int testline_in_rect(void) { static int testline_in_rect(void)
{
int testfailed = -1; int testfailed = -1;
int rx = 10; int rx = 10;
@ -2164,7 +2125,8 @@ static int testline_in_rect(void) {
/** /**
* Just a test routine to test wether specific_worm_collision might work properly * Just a test routine to test wether specific_worm_collision might work properly
*/ */
static int test_specific_worm_collision(void) { static int test_specific_worm_collision(void)
{
int collisions = 0; int collisions = 0;
int dir; int dir;
int x = 0; int x = 0;
@ -2202,7 +2164,8 @@ static int test_specific_worm_collision(void) {
return collisions; return collisions;
} }
static void test_make_argh(void){ static void test_make_argh(void)
{
int dir; int dir;
int seed = 0; int seed = 0;
int hit = 0; int hit = 0;
@ -2248,15 +2211,19 @@ static void test_make_argh(void){
failures ++; failures ++;
} }
rb->snprintf(buf, sizeof buf, "(%d;%d) fail%d try%d", x, y, failures, tries); rb->snprintf(buf, sizeof buf, "(%d;%d) fail%d try%d",
x, y, failures, tries);
rb->lcd_putsxy(0, LCD_HEIGHT - 8, buf); rb->lcd_putsxy(0, LCD_HEIGHT - 8, buf);
rb->lcd_update(); rb->lcd_update();
rb->lcd_invertrect(x + FIELD_RECT_X, y+ FIELD_RECT_Y, argh_size, argh_size); rb->lcd_invertrect(x + FIELD_RECT_X, y+ FIELD_RECT_Y,
argh_size, argh_size);
rb->lcd_update(); rb->lcd_update();
draw_argh(0); draw_argh(0);
rb->lcd_update(); rb->lcd_update();
rb->lcd_invertrect(x + FIELD_RECT_X, y + FIELD_RECT_Y, argh_size, argh_size); rb->lcd_invertrect(x + FIELD_RECT_X, y + FIELD_RECT_Y,
rb->lcd_clearrect(arghx[0] + FIELD_RECT_X, arghy[0] + FIELD_RECT_Y, argh_size, argh_size); argh_size, argh_size);
rb->lcd_clearrect(arghx[0] + FIELD_RECT_X, arghy[0] + FIELD_RECT_Y,
argh_size, argh_size);
if (failures > last_failures) { if (failures > last_failures) {
rb->button_get(true); rb->button_get(true);
@ -2296,184 +2263,10 @@ static void test_worm_argh_collision_in_moves(void) {
} }
#endif /* DEBUG_WORMLET */ #endif /* DEBUG_WORMLET */
extern bool use_old_rect; /*
* Reverts default settings
/**
* These are additional functions required to set various wormlet settings
* and to enable saving of settings and high score
*/ */
static void default_settings(void)
/*
Sets the total number of worms, both human and machine
*/
bool set_worm_num_worms(void)
{
bool ret;
static const struct opt_items num_worms_option[3] = {
{ "1", -1 },
{ "2", -1 },
{ "3", -1 },
};
ret = rb->set_option("Number Of Worms", &worm_count,INT, num_worms_option, 3, NULL);
if (worm_count < players) {
worm_count=players;
}
return ret;
}
/*
Sets the number of human players
*/
bool set_worm_num_players(void)
{
bool ret;
static const struct opt_items num_players_option[4] = {
{ "0", -1 },
{ "1", -1 },
{ "2", -1 },
{ "3", -1 }
};
ret = rb->set_option("Number of Players", &players, INT,num_players_option , 4, NULL);
if (players > worm_count) {
worm_count = players;
}
if (players > 2) {
use_remote = true;
}
return ret;
}
/*
Sets the size of each argh block created
*/
bool set_worm_argh_size(void)
{
static const struct opt_items argh_size_option[11] = {
{ "0", -1 },
{ "1", -1 },
{ "2", -1 },
{ "3", -1 },
{ "4", -1 },
{ "5", -1 },
{ "6", -1 },
{ "7", -1 },
{ "8", -1 },
{ "9", -1 },
{ "10", -1 }
};
return rb->set_option("Argh Size", &argh_size,INT,argh_size_option , 11, NULL);
}
/*
Sets the amount a worm grows per food
*/
bool set_worm_food(void)
{
static const struct opt_items worm_food_option[11] = {
{ "0", -1 },
{ "1", -1 },
{ "2", -1 },
{ "3", -1 },
{ "4", -1 },
{ "5", -1 },
{ "6", -1 },
{ "7", -1 },
{ "8", -1 },
{ "9", -1 },
{ "10", -1 }
};
return rb->set_option("Worm Growth Per Food", &worm_food,INT,worm_food_option , 11, NULL);
}
/*
Sets the number of arghs created per food
*/
bool set_argh_per_food(void)
{
static const struct opt_items argh_food_option[5] = {
{ "0", -1 },
{ "1", -1 },
{ "2", -1 },
{ "3", -1 },
{ "4", -1 },
};
return rb->set_option("Arghs Per Food", &arghs_per_food,INT,argh_food_option , 5, NULL);
}
/*
Sets the number of ticks per move
*/
bool set_worm_speed(void)
{
bool ret;
static const struct opt_items speed_option[19] = {
{ "0", -1 },
{ "1", -1 },
{ "2", -1 },
{ "3", -1 },
{ "4", -1 },
{ "5", -1 },
{ "6", -1 },
{ "7", -1 },
{ "8", -1 },
{ "9", -1 },
{ "10", -1 },
{ "11", -1 },
{ "12", -1 },
{ "13", -1 },
{ "14", -1 },
{ "15", -1 },
{ "16", -1 },
{ "17", -1 },
{ "18", -1 },
};
speed = 20 - speed;
ret = rb->set_option("Worm Speed", &speed,INT,speed_option , 19, NULL);
speed = 20 - speed;
return ret;
}
/*
Sets the control style, which depends on the number of players,
remote control existing, etc
bool set_bool_options(char* string, bool* variable,
char* yes_str, char* no_str, void (*function)(bool))
*/
bool set_worm_control_style(void)
{
static const struct opt_items key1_option[2] = {
{ "Remote Control", -1 },
{ "No Rem. Control", -1 },
};
static const struct opt_items key2_option[2] = {
{ "2 Key Control", -1 },
{ "4 Key COntrol", -1 },
};
static const struct opt_items key3_option[1] = {
{ "Out of Control", -1 },
};
if (players > 1) {
rb->set_option("Control Style",&use_remote,INT, key1_option, 2, NULL);
} else {
if (players > 0) {
rb->set_option("Control Style",&use_remote,INT, key2_option, 2, NULL);
}
else {
rb->set_option("Control Style",&use_remote,INT, key3_option, 1, NULL);
}
}
return false;
}
void default_settings(void)
{ {
arghs_per_food = ARGHS_PER_FOOD; arghs_per_food = ARGHS_PER_FOOD;
argh_size = ARGH_SIZE; argh_size = ARGH_SIZE;
@ -2487,9 +2280,9 @@ void default_settings(void)
} }
/* /*
Launches the wormlet game * Launches the wormlet game
*/ */
bool launch_wormlet(void) static bool launch_wormlet(void)
{ {
int game_result = 1; int game_result = 1;
@ -2513,8 +2306,6 @@ bool launch_wormlet(void)
return false; return false;
} }
/* End of settings/changes etc */
/** /**
* Main entry point * Main entry point
*/ */
@ -2563,104 +2354,6 @@ enum plugin_status plugin_start(const void* parameter)
{ "Yes", -1 }, { "Yes", -1 },
}; };
static const struct opt_items num_worms_option[3] = {
{ "1", -1 },
{ "2", -1 },
{ "3", -1 }
};
#ifdef MULTIPLAYER
static const struct opt_items num_players_option[4] = {
#else
static const struct opt_items num_players_option[2] = {
#endif
{ "0", -1 },
{ "1", -1 }
#ifdef MULTIPLAYER
,{ "2", -1 },
{ "3", -1 }
#endif
};
static const struct opt_items argh_size_option[9] = {
{ "2", -1 },
{ "3", -1 },
{ "4", -1 },
{ "5", -1 },
{ "6", -1 },
{ "7", -1 },
{ "8", -1 },
{ "9", -1 },
{ "10", -1 }
};
static const struct opt_items food_size_option[9] = {
{ "2", -1 },
{ "3", -1 },
{ "4", -1 },
{ "5", -1 },
{ "6", -1 },
{ "7", -1 },
{ "8", -1 },
{ "9", -1 },
{ "10", -1 }
};
static const struct opt_items worm_food_option[16] = {
{ "0", -1 },
{ "1", -1 },
{ "2", -1 },
{ "3", -1 },
{ "4", -1 },
{ "5", -1 },
{ "6", -1 },
{ "7", -1 },
{ "8", -1 },
{ "9", -1 },
{ "10", -1 },
{ "11", -1 },
{ "12", -1 },
{ "13", -1 },
{ "14", -1 },
{ "15", -1 }
};
static const struct opt_items argh_food_option[9] = {
{ "0", -1 },
{ "1", -1 },
{ "2", -1 },
{ "3", -1 },
{ "4", -1 },
{ "5", -1 },
{ "6", -1 },
{ "7", -1 },
{ "8", -1 }
};
static const struct opt_items speed_option[21] = {
{ "0", -1 },
{ "1", -1 },
{ "2", -1 },
{ "3", -1 },
{ "4", -1 },
{ "5", -1 },
{ "6", -1 },
{ "7", -1 },
{ "8", -1 },
{ "9", -1 },
{ "10", -1 },
{ "11", -1 },
{ "12", -1 },
{ "13", -1 },
{ "14", -1 },
{ "15", -1 },
{ "16", -1 },
{ "17", -1 },
{ "18", -1 },
{ "19", -1 },
{ "20", -1 }
};
static const struct opt_items remoteonly_option[1] = { static const struct opt_items remoteonly_option[1] = {
{ "Remote Control", -1 } { "Remote Control", -1 }
}; };
@ -2701,23 +2394,20 @@ enum plugin_status plugin_start(const void* parameter)
launch_wormlet(); launch_wormlet();
break; break;
case 1: case 1:
new_setting = worm_count - 1; rb->set_int("Number of Worms", "", UNIT_INT, &worm_count, NULL,
rb->set_option("Number of Worms", &new_setting, INT, num_worms_option, 3, NULL); 1, 1, 3, NULL);
if (new_setting != worm_count)
worm_count = new_setting + 1;
if (worm_count < players) { if (worm_count < players) {
worm_count = players; worm_count = players;
} }
break; break;
case 2: case 2:
new_setting = players;
#ifdef MULTIPLAYER #ifdef MULTIPLAYER
rb->set_option("Number of Players", &new_setting, INT, num_players_option , 4, NULL); rb->set_int("Number of Players", "", UNIT_INT, &players, NULL,
1, 0, 4, NULL);
#else #else
rb->set_option("Number of Players", &new_setting, INT, num_players_option , 2, NULL); rb->set_int("Number of Players", "", UNIT_INT, &players, NULL,
1, 0, 2, NULL);
#endif #endif
if (new_setting != players)
players = new_setting;
if (players > worm_count) { if (players > worm_count) {
worm_count = players; worm_count = players;
} }
@ -2726,63 +2416,55 @@ enum plugin_status plugin_start(const void* parameter)
} }
break; break;
case 3: case 3:
new_setting = use_remote;
switch(players) { switch(players) {
case 0: case 0:
rb->set_option("Control Style",&new_setting,INT, nokey_option, 1, NULL); rb->set_option("Control Style",&use_remote,INT,
nokey_option, 1, NULL);
break; break;
case 1: case 1:
rb->set_option("Control Style",&new_setting,INT, key24_option, 2, NULL); rb->set_option("Control Style",&use_remote,INT,
key24_option, 2, NULL);
break; break;
case 2: case 2:
#ifdef REMOTE #ifdef REMOTE
rb->set_option("Control Style",&new_setting,INT, remote_option, 2, NULL); rb->set_option("Control Style",&use_remote,INT,
remote_option, 2, NULL);
#else #else
rb->set_option("Control Style",&new_setting,INT, key2_option, 1, NULL); rb->set_option("Control Style",&use_remote,INT,
key2_option, 1, NULL);
#endif #endif
break; break;
case 3: case 3:
rb->set_option("Control Style",&new_setting,INT, remoteonly_option, 1, NULL); rb->set_option("Control Style",&use_remote,INT,
remoteonly_option, 1, NULL);
break; break;
} }
if (new_setting != use_remote)
use_remote = new_setting;
break; break;
case 4: case 4:
new_setting = worm_food; rb->set_int("Worm Growth Per Food", "", UNIT_INT, &worm_food,
rb->set_option("Worm Growth Per Food", &new_setting,INT,worm_food_option , 16, NULL); NULL, 1, 0, 15, NULL);
if (new_setting != worm_food)
worm_food = new_setting;
break; break;
case 5: case 5:
new_setting = speed; new_setting = 20 - speed;
new_setting = 20 - new_setting; rb->set_int("Worm Speed", "", UNIT_INT, &new_setting,
rb->set_option("Worm Speed", &new_setting,INT,speed_option , 21, NULL); NULL, 1, 0, 20, NULL);
new_setting = 20 - new_setting; speed = 20 - new_setting;
if (new_setting != speed)
speed = new_setting;
break; break;
case 6: case 6:
new_setting = arghs_per_food; rb->set_int("Arghs Per Food", "", UNIT_INT, &arghs_per_food,
rb->set_option("Arghs Per Food", &new_setting,INT,argh_food_option , 9, NULL); NULL, 1, 0, 8, NULL);
if (new_setting != arghs_per_food)
arghs_per_food = new_setting;
break; break;
case 7: case 7:
new_setting = argh_size-2; rb->set_int("Argh Size", "", UNIT_INT, &argh_size,
rb->set_option("Argh Size", &new_setting,INT,argh_size_option , 9, NULL); NULL, 1, 2, 10, NULL);
if (new_setting != argh_size)
argh_size = new_setting+2;
break; break;
case 8: case 8:
new_setting = food_size-2; rb->set_int("Food Size", "", UNIT_INT, &food_size,
rb->set_option("Food Size", &new_setting,INT,food_size_option, 9, NULL); NULL, 1, 2, 10, NULL);
if (new_setting != food_size)
food_size = new_setting+2;
break; break;
case 9: case 9:
new_setting = 0; new_setting = 0;
rb->set_option("Reset Settings?", &new_setting,INT, noyes , 2, NULL); rb->set_option("Reset Settings?", &new_setting, INT, noyes , 2, NULL);
if (new_setting == 1) if (new_setting == 1)
default_settings(); default_settings();
break; break;