debug_update:
ld a, [debug_flags]
and a, DEBUG_F_ENABLE
+ jp z, @poll_toggle_debug
+
+ ; debug mode is anebled here
+ ; TODO: implement debug code
+
+@poll_toggle_debug:
+ ; debug mode can be enabled by pressing select 4 times in a
+ ; row as the only input
+
+ ; do nothing if no inputs were made this frame
+ ld a, [curr_inputs]
+ cp a, 0
+ ret z
+
+ ; if curr inputs matches prev inputs
+ ; also do nothing
+ ld b, a
+ ld a, [prev_inputs]
+ xor a, b
ret z
+
+ ld b, BTNSELECT
+ input_just
+ jr z, @reset_enable_counter REL
+ ; if select was not the only button also reset
+ ld a, [curr_inputs]
+ and a, (~BTNSELECT) & 0xFF
+ jr nz, @reset_enable_counter REL
+
+ ; counter++
+ ld a, [debug_enable_count]
+ inc a
+ ld [debug_enable_count], a
+
+ ; if counter is at 4 toggle DEBUG flag
+ cp a, 4
+ ret nz ; do nothing if 0
+
+ ld a, [debug_flags]
+ xor a, DEBUG_F_ENABLE
+ ld [debug_flags], a
+
+ ; make sure to reset the counter :^)
+@reset_enable_counter:
+ xor a, a
+ ld [debug_enable_count], a
ret