Some more remains' stack bug fixes. I must've been drunk when i wrote the original code...

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10881 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Antoine Cellerier 2006-09-04 19:36:09 +00:00
parent 4ae9655f71
commit e9bf85935b

View file

@ -759,14 +759,17 @@ unsigned char sel_card;
card_t deck[ NUM_CARDS ]; card_t deck[ NUM_CARDS ];
/* the remaining cards */ /* the remaining cards */
/* first card of the remains' stack */
unsigned char rem; unsigned char rem;
/* upper visible card from the remains' stack */
unsigned char cur_rem; unsigned char cur_rem;
/* number of cards drawn from the remains stack - 1 */
unsigned char count_rem; unsigned char count_rem;
/* number of cards per draw of the remains' stack */
int cards_per_draw;
/* the 7 game columns */ /* the 7 game columns */
unsigned char cols[COL_NUM]; unsigned char cols[COL_NUM];
int cards_per_draw;
/* the 4 final stacks */ /* the 4 final stacks */
unsigned char stacks[SUITS]; unsigned char stacks[SUITS];
@ -875,7 +878,7 @@ void solitaire_init( void )
/* init the remainder */ /* init the remainder */
cur_rem = NOT_A_CARD; cur_rem = NOT_A_CARD;
count_rem=0; count_rem=-1;
} }
/* find the column number in which 'card' can be found */ /* find the column number in which 'card' can be found */
@ -1049,7 +1052,7 @@ enum move move_card( unsigned char dest_col, unsigned char src_card )
if( src_card_prev == NOT_A_CARD ) if( src_card_prev == NOT_A_CARD )
{ {
rem = deck[src_card].next; rem = deck[src_card].next;
count_rem = count_rem-1; //count_rem--;
} }
/* if src card is not the first card from the stack */ /* if src card is not the first card from the stack */
else else
@ -1058,7 +1061,7 @@ enum move move_card( unsigned char dest_col, unsigned char src_card )
} }
deck[src_card].next = NOT_A_CARD; deck[src_card].next = NOT_A_CARD;
cur_rem = src_card_prev; cur_rem = src_card_prev;
count_rem = count_rem-1; count_rem--;
} }
/* if the src card is from somewhere else, just take everything */ /* if the src card is from somewhere else, just take everything */
else else
@ -1120,7 +1123,6 @@ int solitaire( void )
while( true ) while( true )
{ {
#if LCD_DEPTH>1 #if LCD_DEPTH>1
rb->lcd_set_foreground(LCD_BLACK); rb->lcd_set_foreground(LCD_BLACK);
#ifdef HAVE_LCD_COLOR #ifdef HAVE_LCD_COLOR
@ -1447,9 +1449,11 @@ int solitaire( void )
if( lastbutton != SOL_REM2CUR_PRE ) if( lastbutton != SOL_REM2CUR_PRE )
break; break;
#endif #endif
count_rem = count_rem-1; if( move_card( cur_col, cur_rem ) == MOVE_OK )
move_card( cur_col, cur_rem ); {
sel_card = NOT_A_CARD; //count_rem--;
sel_card = NOT_A_CARD;
}
break; break;
/* If the card on top of the remains can be put on one /* If the card on top of the remains can be put on one
@ -1461,9 +1465,12 @@ int solitaire( void )
#endif #endif
if( cur_rem != NOT_A_CARD ) if( cur_rem != NOT_A_CARD )
{ {
move_card( deck[cur_rem].suit + COL_NUM, cur_rem ); if( move_card( deck[cur_rem].suit + COL_NUM, cur_rem )
sel_card = NOT_A_CARD; == MOVE_OK )
count_rem = count_rem-1; {
sel_card = NOT_A_CARD;
//count_rem--;
}
} }
break; break;
@ -1499,7 +1506,7 @@ int solitaire( void )
if( rem != NOT_A_CARD ) if( rem != NOT_A_CARD )
{ {
int cur_rem_old = cur_rem; int cur_rem_old = cur_rem;
count_rem = 0; count_rem = -1;
/* draw new cards form the remains of the deck */ /* draw new cards form the remains of the deck */
if( cur_rem == NOT_A_CARD ) if( cur_rem == NOT_A_CARD )
{ {
@ -1521,10 +1528,10 @@ int solitaire( void )
} }
/* test if any cards are really left on /* test if any cards are really left on
* the remains' stack */ * the remains' stack */
if( i > 0 ) if( i == cards_per_draw )
{ {
cur_rem = NOT_A_CARD; cur_rem = NOT_A_CARD;
count_rem = 0; count_rem = -1;
} }
/* if cursor was on remains' stack when new cards were /* if cursor was on remains' stack when new cards were
* drawn, put cursor on top of remains' stack */ * drawn, put cursor on top of remains' stack */