From: Lukas Krickl Date: Sun, 31 Aug 2025 04:40:18 +0000 (+0200) Subject: action_menu: Added basic text menu X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=0514f79f47a66eca4106b9deca69ac2f1a4856d6;p=gbrg%2F.git action_menu: Added basic text menu --- diff --git a/src/action_menu.s b/src/action_menu.s index 4592490..a8eca0c 100644 --- a/src/action_menu.s +++ b/src/action_menu.s @@ -43,6 +43,14 @@ update_action_menu: ld bc, st_update_game ret @notb: + + ; update menu + ld a, [action_menu_cursor] + ld hl, action_menu_str_table + ld b, ACTION_MENU_STR_TABLE_LEN + call select_menu_update + + ld [action_menu_cursor], a ldnull bc diff --git a/src/select_menu.s b/src/select_menu.s index 20ab07b..8db65af 100644 --- a/src/select_menu.s +++ b/src/select_menu.s @@ -10,13 +10,55 @@ ; a: selection value ; b: button pressed select_menu_update: + push af + ; save table length + push bc + + cp a, 0 + jr z, @notleft REL + + ld b, BTNLEFT + input_just + jr z, @notleft REL + pop bc + pop af + dec a + call select_menu_draw_status + ld b, BTNLEFT + ret +@notleft: + + pop bc ; get back table length + pop af + push af + dec b ; length - 1 + cp a, b + jr z, @notright REL ; is a > b + + ld b, BTNRIGHT + input_just + jr z, @notright REL + pop af + inc a + call select_menu_draw_status + ld b, BTNRIGHT + ret +@notright: + + + ; TODO: A to confirm SELECT to assign to B + pop af ret ; draws a status text for the current selection ; inputs: ; hl: string ptr table ; a: selection + ; preserves: + ; af select_menu_draw_status: + push af + push hl push af call ui_clear_status_line @@ -38,6 +80,6 @@ select_menu_draw_status: ld de, UI_STATUS_LINE call puts call ui_request_redraw - - + + pop af ret