From 9d7efc082771bb1335a16437da8fc0d6bd4841f1 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sun, 31 Aug 2025 08:53:31 +0200 Subject: [PATCH] action menu: it is now possible to select an action The player then gets forced into the action state upon confirmation --- src/action_menu.s | 31 ++++++++++++++++++++++++++++++- src/select_menu.s | 15 +++++++++++++-- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/action_menu.s b/src/action_menu.s index a8eca0c..abacdc9 100644 --- a/src/action_menu.s +++ b/src/action_menu.s @@ -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 diff --git a/src/select_menu.s b/src/select_menu.s index 9c6c32a..b648daf 100644 --- a/src/select_menu.s +++ b/src/select_menu.s @@ -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 -- 2.30.2