debug: wip added renderer for current tile
authorLukas Krickl <lukas@krickl.dev>
Wed, 19 Nov 2025 04:14:12 +0000 (05:14 +0100)
committerLukas Krickl <lukas@krickl.dev>
Wed, 19 Nov 2025 04:14:12 +0000 (05:14 +0100)
src/debug.s

index c3703cee4e39d4838f3863102d2e624764609a6e..416e2faaf43339fadea0421e669051a23aa5cc08 100644 (file)
@@ -40,6 +40,7 @@ debug_update:
 
        ; draw current update tile
        ; using a cursor
+       call debug_current_tile_draw
 
 @poll_toggle_debug:
        ; debug mode can be enabled by pressing select 4 times in a 
@@ -83,3 +84,39 @@ debug_update:
        xor a, a
        ld [debug_enable_count], a
        ret
+       
+       ; draws a cursor at the location
+       ; of the current update tile
+debug_current_tile_draw:
+       ld a, 1
+       call oamalloc
+       
+       ; y position
+       ld a, [scroll_y]
+       ld b, a
+
+       ld a, [current_tile_y]
+       mul16 a
+       add a, OBJ_OFF_Y
+       sub a, b ; - scroll
+       ld [hl+], a
+
+       ; x pos
+       ld a, [scroll_x]
+       ld b, a
+
+       ld a, [current_tile_x]
+       mul16 a
+       add a, OBJ_OFF_X
+       sub a, b ; - scroll x
+
+       ld [hl+], a
+
+       ; tile
+       ld a, PLAYER_CURSOR_L
+       ld [hl+], a
+
+       ; flags
+       xor a, a
+       ld [hl+], a
+       ret