solitaire-c64/testgames.c65

249 lines
6.1 KiB
Text

#IFNDEF __lib_testgames
#DEFINE __lib_testgames 1
GOTO __skip_lib_testgames
// ============================================================================
// Test game setups for debugging specific scenarios
// To use: call setup_test_game_X() in main() instead of normal deal sequence
// ============================================================================
// ============================================================================
// FUNC setup_test_game_tall_tableau
// Sets up tableau 0 with K->3 (11 cards) and red 2 in waste
// Tests compact rendering mode and edge case of moving 2 onto 3
// ============================================================================
FUNC setup_test_game_tall_tableau
WORD ptr @ $fa
// Clear all piles
POINTER ptr -> pile_stock
POKE ptr[0] , 0
POINTER ptr -> pile_waste
POKE ptr[0] , 0
POINTER ptr -> pile_found0
POKE ptr[0] , 0
POINTER ptr -> pile_found1
POKE ptr[0] , 0
POINTER ptr -> pile_found2
POKE ptr[0] , 0
POINTER ptr -> pile_found3
POKE ptr[0] , 0
POINTER ptr -> pile_tab0
POKE ptr[0] , 0
POINTER ptr -> pile_tab1
POKE ptr[0] , 0
POINTER ptr -> pile_tab2
POKE ptr[0] , 0
POINTER ptr -> pile_tab3
POKE ptr[0] , 0
POINTER ptr -> pile_tab4
POKE ptr[0] , 0
POINTER ptr -> pile_tab5
POKE ptr[0] , 0
POINTER ptr -> pile_tab6
POKE ptr[0] , 0
// Setup tableau 0: K->3 alternating colors (all face-up)
// Spades King (38) -> Hearts Queen (11) -> Spades Jack (36) -> ...
POINTER ptr -> pile_tab0
POKE ptr[0] , 11 // Count
POKE ptr[1] , 38 // Spades King
POKE ptr[2] , 11 // Hearts Queen
POKE ptr[3] , 36 // Spades Jack
POKE ptr[4] , 9 // Hearts 10
POKE ptr[5] , 34 // Spades 9
POKE ptr[6] , 7 // Hearts 8
POKE ptr[7] , 32 // Spades 7
POKE ptr[8] , 5 // Hearts 6
POKE ptr[9] , 30 // Spades 5
POKE ptr[10] , 3 // Hearts 4
POKE ptr[11] , 28 // Spades 3
// Put red 2 (Hearts 2 = 1) in waste
POINTER ptr -> pile_waste
POKE ptr[0] , 1 // Count
POKE ptr[1] , 1 // Hearts 2
// Put some cards in stock for drawing
POINTER ptr -> pile_stock
POKE ptr[0] , 5
POKE ptr[1] , 13 // Diamonds Ace
POKE ptr[2] , 26 // Spades Ace
POKE ptr[3] , 39 // Clubs Ace
POKE ptr[4] , 0 // Hearts Ace
POKE ptr[5] , 14 // Diamonds 2
FEND
// ============================================================================
// FUNC setup_test_game_one_move_to_win
// Sets up game 1 move from victory
// 3 foundations complete, 4th has Ace->Queen, Clubs King in waste
// ============================================================================
FUNC setup_test_game_one_move_to_win
WORD ptr @ $fa
BYTE i
// Clear all piles
POINTER ptr -> pile_stock
POKE ptr[0] , 0
POINTER ptr -> pile_waste
POKE ptr[0] , 0
POINTER ptr -> pile_tab0
POKE ptr[0] , 0
POINTER ptr -> pile_tab1
POKE ptr[0] , 0
POINTER ptr -> pile_tab2
POKE ptr[0] , 0
POINTER ptr -> pile_tab3
POKE ptr[0] , 0
POINTER ptr -> pile_tab4
POKE ptr[0] , 0
POINTER ptr -> pile_tab5
POKE ptr[0] , 0
POINTER ptr -> pile_tab6
POKE ptr[0] , 0
// Foundation 0: Hearts Ace->King (complete)
POINTER ptr -> pile_found0
POKE ptr[0] , 13
POKE ptr[1] , 0
POKE ptr[2] , 1
POKE ptr[3] , 2
POKE ptr[4] , 3
POKE ptr[5] , 4
POKE ptr[6] , 5
POKE ptr[7] , 6
POKE ptr[8] , 7
POKE ptr[9] , 8
POKE ptr[10] , 9
POKE ptr[11] , 10
POKE ptr[12] , 11
POKE ptr[13] , 12
// Foundation 1: Diamonds Ace->King (complete)
POINTER ptr -> pile_found1
POKE ptr[0] , 13
POKE ptr[1] , 13
POKE ptr[2] , 14
POKE ptr[3] , 15
POKE ptr[4] , 16
POKE ptr[5] , 17
POKE ptr[6] , 18
POKE ptr[7] , 19
POKE ptr[8] , 20
POKE ptr[9] , 21
POKE ptr[10] , 22
POKE ptr[11] , 23
POKE ptr[12] , 24
POKE ptr[13] , 25
// Foundation 2: Spades Ace->King (complete)
POINTER ptr -> pile_found2
POKE ptr[0] , 13
POKE ptr[1] , 26
POKE ptr[2] , 27
POKE ptr[3] , 28
POKE ptr[4] , 29
POKE ptr[5] , 30
POKE ptr[6] , 31
POKE ptr[7] , 32
POKE ptr[8] , 33
POKE ptr[9] , 34
POKE ptr[10] , 35
POKE ptr[11] , 36
POKE ptr[12] , 37
POKE ptr[13] , 38
// Foundation 3: Clubs Ace->Queen (missing King)
POINTER ptr -> pile_found3
POKE ptr[0] , 12
POKE ptr[1] , 39
POKE ptr[2] , 40
POKE ptr[3] , 41
POKE ptr[4] , 42
POKE ptr[5] , 43
POKE ptr[6] , 44
POKE ptr[7] , 45
POKE ptr[8] , 46
POKE ptr[9] , 47
POKE ptr[10] , 48
POKE ptr[11] , 49
POKE ptr[12] , 50
// Waste: Clubs King (the winning move)
POINTER ptr -> pile_waste
POKE ptr[0] , 1
POKE ptr[1] , 51
FEND
// ============================================================================
// FUNC setup_test_game_overflow
// Sets up very tall tableau to test screen overflow bounds checking
// Tableau 3 gets King->Ace (13 cards) all face-up to trigger compact mode
// ============================================================================
FUNC setup_test_game_overflow
WORD ptr @ $fa
// Clear all piles
POINTER ptr -> pile_stock
POKE ptr[0] , 0
POINTER ptr -> pile_waste
POKE ptr[0] , 0
POINTER ptr -> pile_found0
POKE ptr[0] , 0
POINTER ptr -> pile_found1
POKE ptr[0] , 0
POINTER ptr -> pile_found2
POKE ptr[0] , 0
POINTER ptr -> pile_found3
POKE ptr[0] , 0
POINTER ptr -> pile_tab0
POKE ptr[0] , 0
POINTER ptr -> pile_tab1
POKE ptr[0] , 0
POINTER ptr -> pile_tab2
POKE ptr[0] , 0
POINTER ptr -> pile_tab3
POKE ptr[0] , 0
POINTER ptr -> pile_tab4
POKE ptr[0] , 0
POINTER ptr -> pile_tab5
POKE ptr[0] , 0
POINTER ptr -> pile_tab6
POKE ptr[0] , 0
// Setup tableau 3: King->Ace alternating colors (13 cards, all face-up)
// This will trigger compact rendering and test overflow protection
POINTER ptr -> pile_tab3
POKE ptr[0] , 13 // Count
POKE ptr[1] , 38 // Spades King
POKE ptr[2] , 11 // Hearts Queen
POKE ptr[3] , 36 // Spades Jack
POKE ptr[4] , 9 // Hearts 10
POKE ptr[5] , 34 // Spades 9
POKE ptr[6] , 7 // Hearts 8
POKE ptr[7] , 32 // Spades 7
POKE ptr[8] , 5 // Hearts 6
POKE ptr[9] , 30 // Spades 5
POKE ptr[10] , 3 // Hearts 4
POKE ptr[11] , 28 // Spades 3
POKE ptr[12] , 1 // Hearts 2
POKE ptr[13] , 26 // Spades Ace
FEND
LABEL __skip_lib_testgames
#IFEND