action menu: it is now possible to select an action
authorLukas Krickl <lukas@krickl.dev>
Sun, 31 Aug 2025 06:53:31 +0000 (08:53 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sun, 31 Aug 2025 06:53:31 +0000 (08:53 +0200)
The player then gets forced into the action state upon confirmation

src/action_menu.s
src/select_menu.s

index a8eca0c00a0fa0555a43de1dbc95b6859ca9409a..abacdc90c80d36bf27cc48b681573d7473c35672 100644 (file)
@@ -49,8 +49,37 @@ update_action_menu:
        ld hl, action_menu_str_table
        ld b, ACTION_MENU_STR_TABLE_LEN
        call select_menu_update
-
        ld [action_menu_cursor], a
+       
+       ; did the player select an action?
+       ld a, b 
+       cp a, BTNA 
+       jr nz, @no_action_selected REL
+               ; if selection was made
+               ; return to game state
+               ; and run action for player
+               
+               ; load action into player
+               ld a, [action_menu_cursor]
+               add a, a
+               ld d, 0
+               ld e, a
+               ld hl, action_menu_action_table
+               add hl, de ; hl = action selected
+
+               ld a, [hl+]
+               ld e, a
+               ld a, [hl]
+               ld d, a
+
+               ; de = action state ptr
+               ld hl, player_unit
+               ld bc, st_size
+               call memcpy
+
+               ld bc, st_update_game
+               ret
+@no_action_selected:
 
 
        ldnull bc
index 9c6c32a1f95584ea9311d8aac5cd959419492129..b648dafb9c4a621b18ab384aeff544475ba85e4b 100644 (file)
@@ -64,8 +64,19 @@ select_menu_update:
 @notright:
 
 @no_select:    
-       ; TODO: A to confirm SELECT to assign to B 
-       pop af
+
+       ; A button to select action
+       ld b, BTNA
+       input_just
+       jr z, @nota REL
+               pop af
+               ld b, BTNA
+               ret
+@nota: 
+
+       ; TODO: SELECT to assign to B 
+       pop af ; pop original input for a
+       ld b, 0 ; clear b return value
        ret
        
        ; draws a status text for the current selection