From: Lukas Krickl Date: Sun, 31 Aug 2025 15:15:10 +0000 (+0200) Subject: select menu: the menu now renders an arrow to indicate available options X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=e78378a1212dd0384b436ac0cb96903b4361ea33;p=gbrg%2F.git select menu: the menu now renders an arrow to indicate available options --- diff --git a/src/mainmenu.s b/src/mainmenu.s index 14c1e53..43da733 100644 --- a/src/mainmenu.s +++ b/src/mainmenu.s @@ -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 diff --git a/src/select_menu.s b/src/select_menu.s index b648daf..06ccfc2 100644 --- a/src/select_menu.s +++ b/src/select_menu.s @@ -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 diff --git a/src/strings.s b/src/strings.s index d3b6f65..0b4bc2c 100644 --- a/src/strings.s +++ b/src/strings.s @@ -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 diff --git a/tiles/bank8C00.inc b/tiles/bank8C00.inc index 1f7bd6a..ace42e1 100644 --- a/tiles/bank8C00.inc +++ b/tiles/bank8C00.inc @@ -503,14 +503,14 @@ .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