Game menu working. Move from foundation working.

This commit is contained in:
Mattias Hansson 2026-01-11 09:57:04 +01:00
parent e4d8e42821
commit 263e019669
2 changed files with 91 additions and 36 deletions

View file

@ -403,6 +403,16 @@ FUNC get_selected_card_info(out:{BYTE card_id} out:{BYTE valid})
EXIT EXIT
ENDIF ENDIF
// Foundation: top card
IF game_selected_pile >= PILE_ID_FOUND0
IF game_selected_pile <= PILE_ID_FOUND3
card = PEEK pile_ptr[pile_count]
card_id = card & CARD_MASK
valid = 1
EXIT
ENDIF
ENDIF
// Tableau: bottom card of selection (the clicked card) // Tableau: bottom card of selection (the clicked card)
IF game_selected_pile >= PILE_ID_TAB0 IF game_selected_pile >= PILE_ID_TAB0
IF game_selected_pile <= PILE_ID_TAB6 IF game_selected_pile <= PILE_ID_TAB6
@ -661,7 +671,7 @@ FUNC handle_click_on_pile({BYTE clicked_pile} {BYTE click_row})
IF game_selected_pile == PILE_ID_NONE IF game_selected_pile == PILE_ID_NONE
#PRAGMA _P_USE_LONG_JUMP 0 #PRAGMA _P_USE_LONG_JUMP 0
// Can only select waste or tableau // Can only select waste, tableau, or foundation (if enabled)
IF clicked_pile == PILE_ID_WASTE IF clicked_pile == PILE_ID_WASTE
game_selected_pile = PILE_ID_WASTE game_selected_pile = PILE_ID_WASTE
game_selected_card_count = 1 game_selected_card_count = 1
@ -702,7 +712,21 @@ FUNC handle_click_on_pile({BYTE clicked_pile} {BYTE click_row})
IF game_selected_card_count > 0 IF game_selected_card_count > 0
game_selected_pile = clicked_pile game_selected_pile = clicked_pile
ENDIF ENDIF
EXIT ENDIF
// Foundation selection (if enabled)
IF game_allow_found_to_tab
IF is_foundation
// Check if foundation has cards before allowing selection
WORD found_ptr @ $e8
pile_id_to_pointer(clicked_pile, found_ptr)
BYTE found_count
found_count = PEEK found_ptr[0]
IF found_count > 0
game_selected_pile = clicked_pile
game_selected_card_count = 1
ENDIF
ENDIF
ENDIF ENDIF
EXIT EXIT

View file

@ -85,15 +85,72 @@ FUNC menu_print_string({WORD screen_pos @ $e0} {WORD str_ptr @ $e2})
FEND FEND
// ============================================================================
// FUNC menu_update_draw_mode
// Update only the draw mode display (row 6) - no screen clear
// ============================================================================
FUNC menu_update_draw_mode
WORD screen_pos @ $e0
// Clear the value area (cols 19-23)
screen_pos = 6*40+$0400+19
POKE screen_pos[0] , 32 // space
POKE screen_pos[1] , 32
POKE screen_pos[2] , 32
POKE screen_pos[3] , 32
POKE screen_pos[4] , 32
// Draw mode value - both values at same position (col 19)
// Show both [1] [3] with brackets around the selected one
screen_pos = 6*40+$0400+19
IF game_draw_mode == 1
POKE screen_pos[0] , 27 // '[' screen code
POKE screen_pos[1] , 49 // '1'
POKE screen_pos[2] , 29 // ']' screen code
POKE screen_pos[3] , 32 // space
POKE screen_pos[4] , 51 // '3'
ELSE
POKE screen_pos[0] , 49 // '1'
POKE screen_pos[1] , 32 // space
POKE screen_pos[2] , 27 // '[' screen code
POKE screen_pos[3] , 51 // '3'
POKE screen_pos[4] , 29 // ']' screen code
ENDIF
FEND
// ============================================================================
// FUNC menu_update_found_to_tab
// Update only the foundation to tableau display (row 9) - no screen clear
// ============================================================================
FUNC menu_update_found_to_tab
WORD screen_pos @ $e4
WORD str_ptr @ $e6
// Clear the value area (cols 28-30)
screen_pos = 9*40+$0400+28
POKE screen_pos[0] , 32 // space
POKE screen_pos[1] , 32
POKE screen_pos[2] , 32
// Foundation to Tableau value
screen_pos = 9*40+$0400+28
IF game_allow_found_to_tab == 0
POINTER str_ptr -> str_off
ELSE
POINTER str_ptr -> str_on
ENDIF
menu_print_string(screen_pos, str_ptr)
FEND
// ============================================================================ // ============================================================================
// FUNC menu_render // FUNC menu_render
// Render the menu screen with current settings // Render the full menu screen with current settings
// ============================================================================ // ============================================================================
FUNC menu_render FUNC menu_render
WORD screen_pos @ $f0 WORD screen_pos @ $f0
WORD str_ptr @ $f2 WORD str_ptr @ $f2
BYTE draw_indicator
BYTE found_to_tab_indicator
// Clear screen // Clear screen
fill_mem($0400, $0400+999, 32) // 32 = space character fill_mem($0400, $0400+999, 32) // 32 = space character
@ -109,28 +166,8 @@ FUNC menu_render
POINTER str_ptr -> str_draw_mode POINTER str_ptr -> str_draw_mode
menu_print_string(screen_pos, str_ptr) menu_print_string(screen_pos, str_ptr)
// Draw mode value // Draw mode value and indicators
screen_pos = 6*40+$0400+24 menu_update_draw_mode()
IF game_draw_mode == 1
POKE screen_pos[0] , 49 // '1'
ELSE
POKE screen_pos[0] , 51 // '3'
ENDIF
// Draw mode indicator
IF game_draw_mode == 1
draw_indicator = 91 // '['
screen_pos = 6*40+$0400+23
POKE screen_pos[0] , draw_indicator
screen_pos = 6*40+$0400+25
POKE screen_pos[0] , 93 // ']'
ELSE
draw_indicator = 91 // '['
screen_pos = 6*40+$0400+26
POKE screen_pos[0] , draw_indicator
screen_pos = 6*40+$0400+28
POKE screen_pos[0] , 93 // ']'
ENDIF
// Foundation to Tableau option (row 9) // Foundation to Tableau option (row 9)
screen_pos = 9*40+$0400+4 screen_pos = 9*40+$0400+4
@ -138,13 +175,7 @@ FUNC menu_render
menu_print_string(screen_pos, str_ptr) menu_print_string(screen_pos, str_ptr)
// Foundation to Tableau value // Foundation to Tableau value
screen_pos = 9*40+$0400+28 menu_update_found_to_tab()
IF game_allow_found_to_tab == 0
POINTER str_ptr -> str_off
ELSE
POINTER str_ptr -> str_on
ENDIF
menu_print_string(screen_pos, str_ptr)
// Instructions for resume/restart (row 14+) // Instructions for resume/restart (row 14+)
screen_pos = 14*40+$0400+4 screen_pos = 14*40+$0400+4
@ -209,7 +240,7 @@ FUNC menu_show(out:{BYTE action})
ELSE ELSE
game_draw_mode = 1 game_draw_mode = 1
ENDIF ENDIF
menu_render() menu_update_draw_mode()
CASE KEY_F3 CASE KEY_F3
// Toggle foundation to tableau // Toggle foundation to tableau
@ -218,7 +249,7 @@ FUNC menu_show(out:{BYTE action})
ELSE ELSE
game_allow_found_to_tab = 0 game_allow_found_to_tab = 0
ENDIF ENDIF
menu_render() menu_update_found_to_tab()
CASE KEY_F7 CASE KEY_F7
// Resume game // Resume game