debug: Added jump to debug routines
authorLukas Krickl <lukas@krickl.dev>
Sun, 14 Sep 2025 16:58:46 +0000 (18:58 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sun, 14 Sep 2025 16:58:46 +0000 (18:58 +0200)
src/debug.s

index cb60f7e03a08aec7162a03571553bb4e98cd36f6..264866431fef07d5b287d237d556551039b31a7a 100644 (file)
@@ -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