From fddb0c8c0bb5bfc5719a7efe8161adab315d3f84 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sat, 30 Aug 2025 08:44:45 +0200 Subject: [PATCH] select menu: added stub for select menu --- src/action_menu.s | 26 ++++++++++++++++++++++++++ src/main.s | 2 ++ src/select_menu.s | 13 +++++++++++++ src/unit.s | 8 ++++++++ src/update.s | 3 +++ 5 files changed, 52 insertions(+) create mode 100644 src/action_menu.s create mode 100644 src/select_menu.s diff --git a/src/action_menu.s b/src/action_menu.s new file mode 100644 index 0000000..4340b34 --- /dev/null +++ b/src/action_menu.s @@ -0,0 +1,26 @@ + ; game state for action menu selector + ; the action menu allows the player to select + ; any action the character can perform + ; it also allows binding an action to the B button + ; by pressing select + ; inputs: + ; de: state + ; returns: + ; bc: next state +update_action_menu: + ldnull bc + ret + + ; transitions from the current state + ; to action menu +action_menu_init: + ld hl, game_mode + ld de, st_next + add hl, de + ; write st_update_action_menu to st_next + ld a, st_update_action_menu LO + ld [hl+], a + ld a, st_update_action_menu HI + ld [hl], a + + ret diff --git a/src/main.s b/src/main.s index fd06531..1b45af6 100644 --- a/src/main.s +++ b/src/main.s @@ -79,6 +79,8 @@ main: #include "objanim.s" #include "battle.s" #include "action.s" +#include "action_menu.s" +#include "select_menu.s" ; fill bank .fill 0xFF, 0x4000 - $ diff --git a/src/select_menu.s b/src/select_menu.s new file mode 100644 index 0000000..8ce9184 --- /dev/null +++ b/src/select_menu.s @@ -0,0 +1,13 @@ + ; a select menu is any menu that allows the player to select + ; a range of values + ; writes current string to status line and requests an update + ; if the direction keys are pressed + ; inputs: + ; hl: string ptr table + ; b: table length + ; a: current slection value + ; returns: + ; a: selection value + ; b: button pressed +select_menu_update: + ret diff --git a/src/unit.s b/src/unit.s index d1fb5f7..1561458 100644 --- a/src/unit.s +++ b/src/unit.s @@ -302,6 +302,14 @@ unit_handle_inputs: call unit_handle_assigned_action push bc ; bc = next state @nota: + + ld b, BTNSELECT + input_just + jr z, @notselect REL + pop bc + call action_menu_init + push bc ; bc = next state +@notselect: ld b, BTNUP input_held diff --git a/src/update.s b/src/update.s index 37e862f..7b4e66e 100644 --- a/src/update.s +++ b/src/update.s @@ -107,3 +107,6 @@ st_update_pause: st_def 0x00, update_pause, st_update_pause st_update_game_over: st_def 0x00, update_game_over, st_update_game_over + +st_update_action_menu: + st_def 0x00, update_action_menu, st_update_action_menu -- 2.30.2