debug: Added debug functin switcher
authorLukas Krickl <lukas@krickl.dev>
Sun, 21 Sep 2025 10:03:10 +0000 (12:03 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sun, 21 Sep 2025 10:03:10 +0000 (12:03 +0200)
src/debug.s
src/wram.s

index 45fa78931e5648e62d42fd2333e9e877adf0a5b1..558c5b90628e78d8c85d22fd0488669a8f2ca49a 100644 (file)
@@ -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
index 6c4f9f2d491e2c1946eba2f107f590c778928888..5c054d165e43f93c3264d2c705ef36a73aec595c 100644 (file)
@@ -88,3 +88,5 @@ dbg_fn: .adv 1
 
        ; selected debug rect
 dbg_rect: .adv 2
+
+dbg_delay: .adv 1