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 asked_insurance;
bool resume;
bool dirty;
} game_context;
/*****************************************************************************
@ -577,8 +576,8 @@ static unsigned int find_value(unsigned int number) {
/*****************************************************************************
* draw_card() draws a card to the screen.
******************************************************************************/
static void draw_card(struct card temp_card, bool shown, unsigned int x,
unsigned int y) {
static void draw_card(struct card temp_card, bool shown,
unsigned int x, unsigned int y) {
if(shown)
rb->lcd_bitmap_part(card_deck, CARD_WIDTH*temp_card.num,
CARD_HEIGHT*temp_card.suit, BMPWIDTH_card_deck,
@ -709,12 +708,11 @@ static void update_total(struct game_context* bj) {
* check_for_aces() is passed an array of cards and returns where an ace is
* located. Otherwise, returns -1.
******************************************************************************/
static signed int check_for_aces(struct card temp_cards[],
unsigned int size) {
static signed int check_for_aces(struct card temp_cards[], unsigned int size) {
unsigned int i;
for(i = 0; i < size; i++) {
if (temp_cards[i].is_soft_ace == true)
return i;
return i;
}
return -1;
}
@ -723,26 +721,26 @@ static signed int check_for_aces(struct card temp_cards[],
* check_totals() compares player and dealer totals.
* 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;
if (bj->player_total > 21)
temp = 0;
else if (bj->player_total == 21 && bj->is_blackjack)
if (bj->dealer_total == 21 && bj->num_dealer_cards == 2)
temp = 2;
else
temp = 4;
temp = 0;
else if (bj->player_total == 21 && bj->is_blackjack) {
if (bj->dealer_total == 21 && bj->num_dealer_cards == 2)
temp = 2;
else
temp = 4;
}
else if (bj->player_total == bj->dealer_total)
temp = 2;
temp = 2;
else if (bj->dealer_total > 21 && bj->player_total < 22)
temp = 3;
temp = 3;
else if (bj->dealer_total > bj->player_total)
temp = 1;
temp = 1;
else if (bj->player_total > bj->dealer_total)
temp = 3;
temp = 3;
else
temp = 5;
temp = 5;
return temp;
}
@ -757,19 +755,19 @@ static void finish_dealer(struct game_context* bj) {
return;
while (bj->dealer_total < 17) {
bj->dealer_cards[bj->num_dealer_cards] = new_card();
bj->dealer_total += bj->dealer_cards[bj->num_dealer_cards].value;
bj->num_dealer_cards++;
bj->dealer_cards[bj->num_dealer_cards] = new_card();
bj->dealer_total += bj->dealer_cards[bj->num_dealer_cards].value;
bj->num_dealer_cards++;
}
while (bj->dealer_total > 21) {
temp = check_for_aces(bj->dealer_cards, bj->num_dealer_cards);
if(temp != -1) {
bj->dealer_cards[temp].is_soft_ace = false;
bj->dealer_total -= 10;
}
else
return;
temp = check_for_aces(bj->dealer_cards, bj->num_dealer_cards);
if(temp != -1) {
bj->dealer_cards[temp].is_soft_ace = false;
bj->dealer_total -= 10;
}
else
return;
}
}
@ -788,23 +786,23 @@ static void finish_game(struct game_context* bj) {
rValue = check_totals(bj);
if (rValue == 0) {
rb->snprintf(str, sizeof(str), " Bust! ");
bj->player_money -= bj->current_bet;
rb->snprintf(str, sizeof(str), " Bust! ");
bj->player_money -= bj->current_bet;
}
else if (rValue == 1) {
rb->snprintf(str, sizeof(str), " Sorry, you lost. ");
bj->player_money -= bj->current_bet;
rb->snprintf(str, sizeof(str), " Sorry, you lost. ");
bj->player_money -= bj->current_bet;
}
else if (rValue == 2) {
rb->snprintf(str, sizeof(str), " Push ");
rb->snprintf(str, sizeof(str), " Push ");
}
else if (rValue == 3) {
rb->snprintf(str, sizeof(str), " You won! ");
bj->player_money+= bj->current_bet;
rb->snprintf(str, sizeof(str), " You won! ");
bj->player_money+= bj->current_bet;
}
else {
rb->snprintf(str, sizeof(str), " Blackjack! ");
bj->player_money += bj->current_bet * 3 / 2;
rb->snprintf(str, sizeof(str), " Blackjack! ");
bj->player_money += bj->current_bet * 3 / 2;
}
rb->lcd_getstringsize(str, &w, &h);
@ -964,7 +962,7 @@ static signed int blackjack_get_amount(char message[20], signed int lower_limit,
signed int upper_limit,
signed int start) {
int button;
char str[6];
char str[9];
bool changed = false;
unsigned int w, h;
signed int amount;
@ -995,11 +993,11 @@ static signed int blackjack_get_amount(char message[20], signed int lower_limit,
rb->lcd_update();
#else
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,
8*h -3);
rb->lcd_fillrect(LCD_WIDTH/2 - 9*w - 1, LCD_HEIGHT/2 - 4*h - 3,
37*w / 2, 8*h -3);
rb->lcd_set_drawmode(DRMODE_SOLID);
rb->lcd_drawrect(LCD_WIDTH/2 - 9*w - 1, LCD_HEIGHT/2 - 4*h - 3, 37*w / 2,
8*h -3);
rb->lcd_drawrect(LCD_WIDTH/2 - 9*w - 1, LCD_HEIGHT/2 - 4*h - 3,
37*w / 2, 8*h -3);
rb->lcd_putsxy(LCD_WIDTH/2 - 9*w, LCD_HEIGHT/2 - 4*h - 1, message);
rb->snprintf(str, 9, "$%d", amount);
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 + 2*h + 1, "DOWN: -10");
#endif
rb->lcd_update_rect(LCD_WIDTH/2 - 9*w - 2, LCD_HEIGHT/2 - 9*h/2, 37*w/2 + 1,
8*h-2);
rb->lcd_update_rect(LCD_WIDTH/2 - 9*w - 1, LCD_HEIGHT/2 - 4*h - 3,
37*w / 2, 8*h -3);
#endif
while(true) {
@ -1031,11 +1029,11 @@ static signed int blackjack_get_amount(char message[20], signed int lower_limit,
switch(button) {
case BJACK_UP:
case (BJACK_UP|BUTTON_REPEAT):
if (amount + 10 < upper_limit + 1) {
if (amount + 10 < upper_limit + 1) {
amount += 10;
changed = true;
}
break;
}
break;
case BJACK_DOWN:
case (BJACK_DOWN|BUTTON_REPEAT):
if (amount - 10 > lower_limit - 1) {
@ -1074,9 +1072,9 @@ static signed int blackjack_get_amount(char message[20], signed int lower_limit,
#endif
rb->lcd_clear_display();
return amount;
}
}
if(changed) {
if(changed) {
rb->snprintf(str, 9, "$%d", amount);
#if LCD_HEIGHT <= 64
rb->lcd_puts(0, 2, str);
@ -1153,7 +1151,10 @@ static unsigned int play_again(void) {
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*))
static char *help_text[] = {
"Blackjack", "",
@ -1184,16 +1185,16 @@ void showhelp(void) {
#endif
if (display_text(WORDS, help_text, formation, NULL))
return;
return true;
do {
button = rb->button_get(true);
if (rb->default_event_handler(button) == SYS_USB_CONNECTED) {
return;
return true;
}
} while( ( button == BUTTON_NONE )
|| ( button & (BUTTON_REL|BUTTON_REPEAT) ) );
rb->lcd_setfont(FONT_SYSFIXED);
return;
return false;
}
/*****************************************************************************
@ -1203,8 +1204,10 @@ static unsigned int blackjack_menu(struct game_context* bj) {
int selection=0;
bool breakout = false;
MENUITEM_STRINGLIST(menu,"BlackJack Menu",NULL,"Start Game","Resume Game",
"High Scores", "Help", "Playback Control", "Quit");
MENUITEM_STRINGLIST(menu, "BlackJack Menu", NULL,
"Start Game","Resume Game",
"High Scores", "Help",
"Playback Control", "Quit");
while(!breakout) {
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)) {
rb->splash(HZ*2, "Nothing to resume");
} else {
rb->splash(HZ*2, "Loading...");
breakout = true;
}
break;
@ -1223,11 +1225,12 @@ static unsigned int blackjack_menu(struct game_context* bj) {
highscore_show(NUM_SCORES, highest, NUM_SCORES, false);
break;
case 3:
showhelp();
if(blackjack_help())
return BJ_USB;
break;
case 4:
if (playback_control(NULL))
return 1;
return BJ_USB;
break;
case 5:
return BJ_QUIT;
@ -1253,6 +1256,11 @@ static int blackjack(struct game_context* bj) {
bool breakout = 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 */
bj->resume = false;
@ -1268,7 +1276,6 @@ static int blackjack(struct game_context* bj) {
* init *
********************/
blackjack_init(bj);
bj->current_bet=10;
/********************
* play *
@ -1279,21 +1286,21 @@ static int blackjack(struct game_context* bj) {
bj->resume = false;
redraw_board(bj);
if (bj->split_status == 2) {
todo=2;
player_x = bj->num_player_cards[0] * 10 + 4;
todo=2;
player_x = bj->num_player_cards[0] * 10 + 4;
}
else if (bj->split_status == 3) {
player_x = bj->num_player_cards[1] * 10 + LCD_WIDTH/2 + 4;
todo=2;
done=1;
player_x = bj->num_player_cards[1] * 10 + LCD_WIDTH/2 + 4;
todo=2;
done=1;
}
}
else {
bj->player_money = 1000;
bj->current_bet = 10;
blackjack_get_bet(bj);
if (bj->current_bet == 0)
return BJ_QUIT;
return -1;
rb->lcd_clear_display();
deal_init_cards(bj);
blackjack_drawtable(bj);
@ -1370,7 +1377,8 @@ static int blackjack(struct game_context* bj) {
bj->end_hand = true;
break;
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) {
double_down(bj);
dbl_down = true;
@ -1379,7 +1387,8 @@ static int blackjack(struct game_context* 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.");
redraw_board(bj);
rb->lcd_update();
@ -1462,7 +1471,11 @@ static int blackjack(struct game_context* bj) {
return BJ_END;
else { /* User keeps playing */
breakout = false;
temp = bj->current_bet;
bj->current_bet = 0;
redraw_board(bj);
rb->lcd_update();
bj->current_bet = temp;
if(dbl_down) {
bj->current_bet /= 2;
dbl_down = false;
@ -1509,7 +1522,7 @@ enum plugin_status plugin_start(const void* parameter)
/* fall through to 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 */
int position = highscore_update(bj.player_money, -1, "",
highest, NUM_SCORES);
@ -1518,24 +1531,17 @@ enum plugin_status plugin_start(const void* parameter)
}
if (position != -1) {
highscore_show(position, highest, NUM_SCORES, false);
bj.dirty=true;
} else {
rb->sleep(3);
}
}
break;
case BJ_USB:
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;
case BJ_QUIT:
if(bj.dirty) {
highscore_save(HIGH_SCORE,highest,NUM_SCORES);
}
highscore_save(HIGH_SCORE,highest,NUM_SCORES);
exit = true;
break;

View file

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

View file

@ -343,19 +343,9 @@ static void draw_calendar(struct shown *shown)
int x,y,pos,days_per_month,j;
char buffer[9];
const char *monthname[] = {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
};
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
if(use_system_font)
rb->lcd_setfont(FONT_SYSFIXED);
rb->lcd_getstringsize("A",&w,&h);
@ -421,7 +411,7 @@ static int memos_in_shown_memory = 0;
static void load_memo(struct shown *shown)
{
int i, k, fp;
int k, fp;
bool exit = false;
char temp_memo1[2];
char temp_memo2[3];
@ -429,18 +419,6 @@ static void load_memo(struct shown *shown)
temp_memo1[1] = 0;
temp_memo2[2] = 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++)
day_has_memo[k] = false;
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);
if (fp > -1)
{
int count = rb->filesize(fp);
rb->lseek(fp, 0, SEEK_SET);
while (!exit)
{
memos[memos_in_memory].file_pointer_start = rb->lseek(fp, 0,
SEEK_CUR);
bool load_to_memory;
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)
memos[memos_in_memory].day = rb->atoi(&temp_memo2[0]);
else
@ -472,7 +451,7 @@ static void load_memo(struct shown *shown)
if (memos[memos_in_memory].year > (shown->year * 10))
memos[memos_in_memory].year = (memos[memos_in_memory].year -
memos[memos_in_memory].month) /
100;
100;
if (rb->read(fp, temp_memo1, 1) == 1)
memos[memos_in_memory].wday = rb->atoi(&temp_memo1[0]);
else
@ -481,48 +460,16 @@ static void load_memo(struct shown *shown)
memos[memos_in_memory].type = rb->atoi(&temp_memo1[0]);
else
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 (
(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)
)
)
{
if (temp_memo1[0] == '\n')
{
if (memos[memos_in_memory].type > 0)
day_has_memo[memos[memos_in_memory].day] =
true;
else
wday_has_memo[memos[memos_in_memory].wday] =
true;
memos[memos_in_memory++].file_pointer_end =
rb->lseek(fp, 0, SEEK_CUR);
}
else if ( (temp_memo1[0] != '\r') &&
(temp_memo1[0] != '\t') &&
k < MAX_CHAR_MEMO_LEN-1 )
memos[memos_in_memory].message[k] = temp_memo1[0];
}
if (temp_memo1[0] == '\n')
break;
}
else
if (rb->read(fp, temp_memo1, 1) != 1)
{
memos[memos_in_memory].day = 0;
memos[memos_in_memory].month = 0;
@ -535,6 +482,26 @@ static void load_memo(struct shown *shown)
exit = true;
break;
}
if (load_to_memory)
{
if (temp_memo1[0] == '\n')
{
if (memos[memos_in_memory].type > 0)
day_has_memo[memos[memos_in_memory].day] =
true;
else
wday_has_memo[memos[memos_in_memory].wday] =
true;
memos[memos_in_memory++].file_pointer_end =
rb->lseek(fp, 0, SEEK_CUR);
}
else if ( (temp_memo1[0] != '\r') &&
(temp_memo1[0] != '\t') &&
k < MAX_CHAR_MEMO_LEN-1 )
memos[memos_in_memory].message[k++] = temp_memo1[0];
}
if (temp_memo1[0] == '\n')
break;
}
}
}
@ -546,7 +513,7 @@ static bool save_memo(int changed, bool new_mod, struct shown *shown)
int fp,fq;
fp = rb->open(ROCKBOX_DIR "/.memo",O_RDONLY | O_CREAT);
fq = rb->creat(ROCKBOX_DIR "/~temp");
if ( (fq != -1) && (fp != -1) )
if ( (fq > -1) && (fp > -1) )
{
int i;
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);
return true;
}
else if (fp != -1)
else if (fp > -1)
rb->close(fp);
else if (fq != -1)
else if (fq > -1)
rb->close(fq);
return false;
}
@ -746,19 +713,10 @@ static void update_memos_shown(struct shown *shown)
int i;
memos_in_shown_memory = 0;
for (i = 0; i < memos_in_memory; i++)
if (
(
(memos[i].type >= 1)
&&
(memos[i].day == shown->mday)
)
||
(
(memos[i].type < 1)
&&
(memos[i].wday == shown->wday)
)
)
if (((memos[i].type >= 1) &&
(memos[i].day == shown->mday)) ||
((memos[i].type < 1) &&
(memos[i].wday == shown->wday)))
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",
"Start New Game",
"Help",
"High Score",
"High Scores",
"Playback Control",
"Quit");

View file

@ -1323,7 +1323,7 @@ static int jewels_game_menu(struct game_context* bj, bool ingame)
"Start New Game",
"Mode",
"Help",
"High Score",
"High Scores",
"Playback Control",
"Quit without Saving",
"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_foreground(LCD_WHITE);
#endif
rb->button_clear_queue();
rb->lcd_clear_display();
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->sleep(HZ/2);
rb->button_clear_queue();
rb->button_get(true);
rb->lcd_setfont(FONT_SYSFIXED);
}

View file

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

View file

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

File diff suppressed because it is too large Load diff