summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorAntoine Cellerier <dionoea@videolan.org>2006-09-04 19:36:09 +0000
committerAntoine Cellerier <dionoea@videolan.org>2006-09-04 19:36:09 +0000
commite9bf85935b2cce1fd71b03ecf3f3b2aa663cc3b6 (patch)
tree9d49a4d3fed1143e1982779ccec2a47748e1f6e4 /apps
parent4ae9655f718ce975ac9f2c8e8f38547d65993554 (diff)
downloadrockbox-e9bf85935b2cce1fd71b03ecf3f3b2aa663cc3b6.tar.gz
rockbox-e9bf85935b2cce1fd71b03ecf3f3b2aa663cc3b6.zip
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
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/solitaire.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/apps/plugins/solitaire.c b/apps/plugins/solitaire.c
index 0d3b79ef57..2df96e7a64 100644
--- a/apps/plugins/solitaire.c
+++ b/apps/plugins/solitaire.c
@@ -759,14 +759,17 @@ unsigned char sel_card;
759card_t deck[ NUM_CARDS ]; 759card_t deck[ NUM_CARDS ];
760 760
761/* the remaining cards */ 761/* the remaining cards */
762/* first card of the remains' stack */
762unsigned char rem; 763unsigned char rem;
764/* upper visible card from the remains' stack */
763unsigned char cur_rem; 765unsigned char cur_rem;
766/* number of cards drawn from the remains stack - 1 */
764unsigned char count_rem; 767unsigned char count_rem;
768/* number of cards per draw of the remains' stack */
769int cards_per_draw;
765 770
766/* the 7 game columns */ 771/* the 7 game columns */
767unsigned char cols[COL_NUM]; 772unsigned char cols[COL_NUM];
768
769int cards_per_draw;
770/* the 4 final stacks */ 773/* the 4 final stacks */
771unsigned char stacks[SUITS]; 774unsigned char stacks[SUITS];
772 775
@@ -875,7 +878,7 @@ void solitaire_init( void )
875 /* init the remainder */ 878 /* init the remainder */
876 cur_rem = NOT_A_CARD; 879 cur_rem = NOT_A_CARD;
877 880
878 count_rem=0; 881 count_rem=-1;
879} 882}
880 883
881/* find the column number in which 'card' can be found */ 884/* 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 )
1049 if( src_card_prev == NOT_A_CARD ) 1052 if( src_card_prev == NOT_A_CARD )
1050 { 1053 {
1051 rem = deck[src_card].next; 1054 rem = deck[src_card].next;
1052 count_rem = count_rem-1; 1055 //count_rem--;
1053 } 1056 }
1054 /* if src card is not the first card from the stack */ 1057 /* if src card is not the first card from the stack */
1055 else 1058 else
@@ -1058,7 +1061,7 @@ enum move move_card( unsigned char dest_col, unsigned char src_card )
1058 } 1061 }
1059 deck[src_card].next = NOT_A_CARD; 1062 deck[src_card].next = NOT_A_CARD;
1060 cur_rem = src_card_prev; 1063 cur_rem = src_card_prev;
1061 count_rem = count_rem-1; 1064 count_rem--;
1062 } 1065 }
1063 /* if the src card is from somewhere else, just take everything */ 1066 /* if the src card is from somewhere else, just take everything */
1064 else 1067 else
@@ -1120,7 +1123,6 @@ int solitaire( void )
1120 1123
1121 while( true ) 1124 while( true )
1122 { 1125 {
1123
1124#if LCD_DEPTH>1 1126#if LCD_DEPTH>1
1125 rb->lcd_set_foreground(LCD_BLACK); 1127 rb->lcd_set_foreground(LCD_BLACK);
1126#ifdef HAVE_LCD_COLOR 1128#ifdef HAVE_LCD_COLOR
@@ -1447,9 +1449,11 @@ int solitaire( void )
1447 if( lastbutton != SOL_REM2CUR_PRE ) 1449 if( lastbutton != SOL_REM2CUR_PRE )
1448 break; 1450 break;
1449#endif 1451#endif
1450 count_rem = count_rem-1; 1452 if( move_card( cur_col, cur_rem ) == MOVE_OK )
1451 move_card( cur_col, cur_rem ); 1453 {
1452 sel_card = NOT_A_CARD; 1454 //count_rem--;
1455 sel_card = NOT_A_CARD;
1456 }
1453 break; 1457 break;
1454 1458
1455 /* If the card on top of the remains can be put on one 1459 /* If the card on top of the remains can be put on one
@@ -1461,9 +1465,12 @@ int solitaire( void )
1461#endif 1465#endif
1462 if( cur_rem != NOT_A_CARD ) 1466 if( cur_rem != NOT_A_CARD )
1463 { 1467 {
1464 move_card( deck[cur_rem].suit + COL_NUM, cur_rem ); 1468 if( move_card( deck[cur_rem].suit + COL_NUM, cur_rem )
1465 sel_card = NOT_A_CARD; 1469 == MOVE_OK )
1466 count_rem = count_rem-1; 1470 {
1471 sel_card = NOT_A_CARD;
1472 //count_rem--;
1473 }
1467 } 1474 }
1468 break; 1475 break;
1469 1476
@@ -1499,7 +1506,7 @@ int solitaire( void )
1499 if( rem != NOT_A_CARD ) 1506 if( rem != NOT_A_CARD )
1500 { 1507 {
1501 int cur_rem_old = cur_rem; 1508 int cur_rem_old = cur_rem;
1502 count_rem = 0; 1509 count_rem = -1;
1503 /* draw new cards form the remains of the deck */ 1510 /* draw new cards form the remains of the deck */
1504 if( cur_rem == NOT_A_CARD ) 1511 if( cur_rem == NOT_A_CARD )
1505 { 1512 {
@@ -1521,10 +1528,10 @@ int solitaire( void )
1521 } 1528 }
1522 /* test if any cards are really left on 1529 /* test if any cards are really left on
1523 * the remains' stack */ 1530 * the remains' stack */
1524 if( i > 0 ) 1531 if( i == cards_per_draw )
1525 { 1532 {
1526 cur_rem = NOT_A_CARD; 1533 cur_rem = NOT_A_CARD;
1527 count_rem = 0; 1534 count_rem = -1;
1528 } 1535 }
1529 /* if cursor was on remains' stack when new cards were 1536 /* if cursor was on remains' stack when new cards were
1530 * drawn, put cursor on top of remains' stack */ 1537 * drawn, put cursor on top of remains' stack */