action_menu: Added basic text menu
authorLukas Krickl <lukas@krickl.dev>
Sun, 31 Aug 2025 04:40:18 +0000 (06:40 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sun, 31 Aug 2025 04:40:18 +0000 (06:40 +0200)
src/action_menu.s
src/select_menu.s

index 4592490132af12df76004cbb42030fca5d68e5d7..a8eca0c00a0fa0555a43de1dbc95b6859ca9409a 100644 (file)
@@ -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
index 20ab07b475c87c95bb22c3ef0056cd7368e876f8..8db65affa9bdd9e358721cd5bf4960fe3c8083f5 100644 (file)
        ;               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