summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2006-09-15 06:24:36 +0000
committerJens Arnold <amiconn@rockbox.org>2006-09-15 06:24:36 +0000
commit1350d57751f30f1700912e6abaa1d845af973f75 (patch)
tree360853ac291757da82ec2fbbd9ee278ea76bc451 /apps
parent2fb102ef04f12080ed5e26f2504cd4e78b5ff33e (diff)
downloadrockbox-1350d57751f30f1700912e6abaa1d845af973f75.tar.gz
rockbox-1350d57751f30f1700912e6abaa1d845af973f75.tar.bz2
rockbox-1350d57751f30f1700912e6abaa1d845af973f75.zip
Solitaire: * Even more 'natural' bouncing cards. * Only load the config from disk once, and only save it on exit if it changed.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10949 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/solitaire.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/apps/plugins/solitaire.c b/apps/plugins/solitaire.c
index 707d9b5c00..129f5c5d3e 100644
--- a/apps/plugins/solitaire.c
+++ b/apps/plugins/solitaire.c
@@ -589,12 +589,15 @@ enum help solitaire_help( void )
*
* TODO: use rockbox api menus instead
*/
-
+
#define CFGFILE_VERSION 0
-int draw_type;
+
+/* introduce a struct if there's more than one setting */
+int draw_type_disk = 0;
+int draw_type;
static struct configdata config[] = {
- { TYPE_INT, 0, 1, &draw_type, "draw_type", NULL, NULL }
+ { TYPE_INT, 0, 1, &draw_type_disk, "draw_type", NULL, NULL }
};
/* menu return codes */
@@ -1072,7 +1075,7 @@ enum { SOLITAIRE_WIN, SOLITAIRE_QUIT, SOLITAIRE_USB };
*/
int bouncing_cards( void )
{
- int i, j, x, y, vx, vy, button;
+ int i, j, x, vx, y, fp_y, fp_vy, button;
/* flush the button queue */
while( ( button = rb->button_get( false ) ) != BUTTON_NONE )
@@ -1087,23 +1090,24 @@ int bouncing_cards( void )
for( j = 0; j < SUITS; j++ )
{
x = LCD_WIDTH-(CARD_WIDTH*4+4+MARGIN)+CARD_WIDTH*j+j+1;
- y = MARGIN;
+ fp_y = MARGIN<<8;
vx = rb->rand()%8-5;
if( !vx ) vx = -6;
- vy = -rb->rand()%(6<<8);
+ fp_vy = -rb->rand()%(6<<8);
while( x < LCD_WIDTH && x + CARD_WIDTH > 0 )
{
- vy += (1<<8);
+ fp_vy += 1<<8;
x += vx;
- y += vy >> 8;
- if( y + CARD_HEIGHT >= LCD_HEIGHT )
+ fp_y += fp_vy;
+ if( fp_y >= (LCD_HEIGHT-CARD_HEIGHT) << 8 )
{
- vy = -vy*3/4;
- y = LCD_HEIGHT - CARD_HEIGHT;
+ fp_vy = -fp_vy*3/4;
+ fp_y = (LCD_HEIGHT-CARD_HEIGHT) << 8;
}
+ y = fp_y >> 8;
draw_card( deck[j*CARDS_PER_SUIT+i], x, y,
false, false, false );
rb->lcd_update_rect( x<0?0:x, y<0?0:y,
@@ -1132,9 +1136,6 @@ int solitaire( void )
unsigned char c,h,prevcard;
int biggest_col_length;
- configfile_init(rb);
- configfile_load(CONFIG_FILENAME, config, 1, 0);
-
rb->srand( *rb->current_tick );
switch( solitaire_menu( draw_type == 0 ? MENU_BEFOREGAME
: MENU_BEFOREGAMEOP ) )
@@ -1147,7 +1148,6 @@ int solitaire( void )
case MENU_OPT:
draw_type = (draw_type+1)%2;
- configfile_save(CONFIG_FILENAME, config, 1, 0);
return 0;
}
solitaire_init();
@@ -1614,10 +1614,20 @@ enum plugin_status plugin_start( struct plugin_api* api, void* parameter )
rb->splash( HZ, true, "Welcome to Solitaire!" );
+ configfile_init(rb);
+ configfile_load(CONFIG_FILENAME, config, 1, 0);
+ draw_type = draw_type_disk;
+
/* play the game :)
* Keep playing if a game was won (that means display the menu after
* winning instead of quiting) */
while( ( result = solitaire() ) == SOLITAIRE_WIN );
+
+ if (draw_type != draw_type_disk)
+ {
+ draw_type_disk = draw_type;
+ configfile_save(CONFIG_FILENAME, config, 1, 0);
+ }
/* Exit the plugin */
return ( result == SOLITAIRE_USB ) ? PLUGIN_USB_CONNECTED : PLUGIN_OK;