select menu: the menu now renders an arrow to indicate available options
authorLukas Krickl <lukas@krickl.dev>
Sun, 31 Aug 2025 15:15:10 +0000 (17:15 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sun, 31 Aug 2025 15:15:10 +0000 (17:15 +0200)
src/mainmenu.s
src/select_menu.s
src/strings.s
tiles/bank8C00.inc

index 14c1e5329d73f261d18e3ba18b09a57ec9dd0386..43da733ecc372fce82f0e8a1c1ba3cc66c48c9b2 100644 (file)
@@ -1,6 +1,7 @@
 #define MAIN_MENU_FILE_1_OFFSET 128+2
 
 #define MENU_CURSOR_TILE 0xF5 
+#define MENU_CURSOR_TILE_REVERSE 0xF5+3 
 
 
   ; location table for cursor
index b648dafb9c4a621b18ab384aeff544475ba85e4b..06ccfc24e8da268efea73a6c085be02147bd44ec 100644 (file)
@@ -45,6 +45,7 @@ select_menu_update:
 @notleft:
        
        pop bc ; get back table length  
+       ld c, b ; store table length in c
        pop af
        push af
        dec b ; length - 1
@@ -58,6 +59,7 @@ select_menu_update:
                ld [select_menu_delay], a
                pop af
                inc a
+               ld b, c ; table length = c
                call select_menu_draw_status
                ld b, BTNRIGHT
                ret
@@ -83,17 +85,31 @@ select_menu_update:
        ;       inputs:
        ;               hl: string ptr table
        ;                a: selection
+       ;                b: string table length 
        ; preserves:
        ;               af
 select_menu_draw_status:
        push af
+       push bc
 
        push hl
        push af
        call ui_clear_status_line 
+
        pop af
-       pop hl
+       push af
+       ; check if left arrow needs to be drawn (a != 0)
+       cp a, 0
+       jr z, @no_left_arrow REL
+               ; write cursor tile
+               ld de, UI_STATUS_LINE
+               ld a, MENU_CURSOR_TILE_REVERSE
+               ld [de], a
+@no_left_arrow:
 
+       pop af
+       pop hl
+       
        add a, a ; * 2 for table offset
        ld d, 0
        ld e, a
@@ -106,9 +122,24 @@ select_menu_draw_status:
        ld h, a
        ld l, d
 
-       ld de, UI_STATUS_LINE
+       ld de, UI_STATUS_LINE+1
        call puts
+       push de
        call ui_request_redraw
+       pop de
+       ; de = tile after string
        
+       pop bc
+       pop af
+
+       push af
+       ; check if right arrow needs to be drawn (a != b-1)
+       dec b
+       cp a, b
+       jr z, @no_right_arrow REL
+               ; write cursor tile
+               ld a, MENU_CURSOR_TILE
+               ld [de], a
+@no_right_arrow:
        pop af
        ret
index d3b6f656aa4303d2089f60a80789f5e2fe07a6cf..0b4bc2c6d3415ac6dfbf405521ac5727bb12898b 100644 (file)
@@ -84,6 +84,8 @@ STR_SLASH:
   ; inputs:
   ;   hl: the string
   ;   de: tile location
+       ;       returns:
+       ;               de: new tile location after string
 puts:
   ld a, [hl+]
   cp a, 0
index 1f7bd6a25d1e3451bfe76e4f4b9abf7fbe34a7ba..ace42e10edf70a0bdc79545a26bbcf16426ff64b 100644 (file)
 .chr 22332222
 .chr 22332222
 ; tile 56
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
+.chr 22223322
+.chr 22233322
+.chr 22333322
+.chr 23333322
+.chr 23333322
+.chr 22333322
+.chr 22233322
+.chr 22223322
 ; tile 57
 .chr 00000000
 .chr 00000000