From 3817b6936da77ba6b3badc08a737e4a9e4d1db3d Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sun, 21 Sep 2025 12:03:10 +0200 Subject: [PATCH] debug: Added debug functin switcher --- src/debug.s | 31 +++++++++++++++++++++++++++++++ src/wram.s | 2 ++ 2 files changed, 33 insertions(+) diff --git a/src/debug.s b/src/debug.s index 45fa789..558c5b9 100644 --- a/src/debug.s +++ b/src/debug.s @@ -1,6 +1,7 @@ debug_routines: dw dbg_nop dw dbg_rect_draw +debug_routines_end: dbg_nop: ret @@ -13,6 +14,31 @@ dbg_init: ; keys: ; down + select: cycle next debug function dbg_update: + ld a, [dbg_delay] + cp a, 0 + jp nz, @debug_delay + + ; check if dbg swap to next function is needed + ld b, BTNDOWN | BTNSELECT + input_held + cp a, BTNDOWN | BTNSELECT + jr nz, @no_switch REL + ; set a timer + ld a, 16 + ld [dbg_delay], a + + ; next function + ld a, [dbg_fn] + inc a + + ; loop around if > max functions + cp a, (debug_routines_end - debug_routines) / 2 + jr nz, @no_reset REL + xor a, a +@no_reset: + ld [dbg_fn], a +@no_switch: + ld a, [dbg_fn] add a, a ; * 2 for table offset @@ -28,6 +54,11 @@ dbg_update: ld l, d jp hl +@debug_delay: + + dec a + ld [dbg_delay], a + ret ; draws a marker obj at ; the edge of a rectangle diff --git a/src/wram.s b/src/wram.s index 6c4f9f2..5c054d1 100644 --- a/src/wram.s +++ b/src/wram.s @@ -88,3 +88,5 @@ dbg_fn: .adv 1 ; selected debug rect dbg_rect: .adv 2 + +dbg_delay: .adv 1 -- 2.30.2