From c10f1b557380e1857c0448f1ee32225aa0e7abb6 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sun, 14 Sep 2025 18:58:46 +0200 Subject: [PATCH] debug: Added jump to debug routines --- src/debug.s | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/debug.s b/src/debug.s index cb60f7e..2648664 100644 --- a/src/debug.s +++ b/src/debug.s @@ -15,7 +15,13 @@ debug_menu_str_table_end: #define DEBUG_MENU_STR_TABLE_LEN (debug_menu_str_table_end - debug_menu_str_table) / 2 +; debug routines: +; get jumped to directly +; return: +; bc: new game state debug_menu_action_table: + dw debug_fn_new_game + dw debug_fn_clear_actors debug_menu_action_table_end: ; updates the debug menu @@ -38,6 +44,30 @@ update_debug_menu: ld b, DEBUG_MENU_STR_TABLE_LEN call select_menu_update ld [debug_menu_cursor], a + + ; did the player select an action? + ld a, b + cp a, BTNA + jr nz, @no_action_selected REL + + ; load ptr from action table + ; into hl and call it + ld a, [debug_menu_cursor] + add a, a ; * 2 for offset + ld hl, debug_menu_action_table + ld d, 0 + ld e, a + add hl, de + + ld a, [hl+] + ld d, a + ld a, [hl] + ld h, a + ld l, d + + ; jp to selected routine + jp hl +@no_action_selected: ldnull bc ret @@ -58,3 +88,14 @@ debug_menu_init: ld hl, debug_menu_str_table call select_menu_draw_status ret + + ; debug new game routine + ; returns: + ; bc: new state +debug_fn_new_game: + ld bc, st_update_game + ret + +debug_fn_clear_actors: + ld bc, st_update_game + ret -- 2.30.2