debug: Added debug collision display
authorLukas Krickl <lukas@krickl.dev>
Tue, 9 Dec 2025 04:24:29 +0000 (05:24 +0100)
committerLukas Krickl <lukas@krickl.dev>
Tue, 9 Dec 2025 04:24:29 +0000 (05:24 +0100)
maps/spawn.inc
src/config.s [new file with mode: 0644]
src/debug.s
src/main.s
src/update.s
tiles/bank8800.inc

index 37ff478d337ad93a23e000bb1d6d427b89d4a9dd..c0186aabb27440df31aa7c16122485644da19e54 100644 (file)
@@ -25,7 +25,7 @@
 .db 0x0, 0x0, 0x0, 0x3, 0x4, 0x0, 0x0, 0x0
 .db 0x0, 0x0, 0x0, 0x3, 0x4, 0x0, 0x0, 0x0
 .db 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1
-.db 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
+.db 0x5, 0x0, 0x0, 0x0, 0x0, 0x5, 0x5, 0x0
 .db 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
 .db 0x0, 0x0, 0x0, 0x3, 0x2, 0x0, 0x0, 0x0
 .db 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
diff --git a/src/config.s b/src/config.s
new file mode 100644 (file)
index 0000000..d3cfc84
--- /dev/null
@@ -0,0 +1 @@
+#define DEBUG_COLLISION
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..6539673fb40a461fab6b1d8869cc270872129902 100644 (file)
@@ -0,0 +1,52 @@
+
+#define DEBUG_COLLISION_MARKER 0x9E
+       
+       ; draws a point in debug mode
+       ; inputs:
+       ;               $1: point ptr name
+       ;               hl: oam ptr
+       ;       returns:
+       ;               hl: next oam
+#macro debug_draw_point
+       ; y pos
+       ld a, [scroll_y]
+       ld b, a
+       ld a, [$1] ; y
+
+       add a, OBJ_OFF_Y
+       sub a, b
+       ld [hl+], a
+
+       ; x pos
+       ld a, [scroll_x]
+       ld b, a
+       ld a, [$1+1] ; x
+
+       add a, OBJ_OFF_X
+       sub a, b
+       ld [hl+], a
+
+       ; tile
+       ld a, DEBUG_COLLISION_MARKER
+       ld [hl+], a
+       
+       ; flags
+       xor a, a
+       ld [hl+], a
+#endmacro
+
+       ; draws col_point_nn
+       ; using the debug sprite
+       ; if enabled
+debug_draw_collision:
+       ld a, 5
+       call oamalloc
+
+       ; draw each point
+       debug_draw_point col_point_tl
+       debug_draw_point col_point_bl
+       debug_draw_point col_point_tr
+       debug_draw_point col_point_br
+       debug_draw_point col_point_ct
+
+       ret
index f63d46f38215a2ddf3fed834d5e073596c9d85da..9adf896623f61c4ed6645d1b5e5052571c597f65 100644 (file)
@@ -1,4 +1,5 @@
 #include "hw.inc"
+#include "config.s"
 #include "macros.inc"
 #include "oam.s"
 #include "defs.s"
index 97cf79b7f56c147f5256c7aa0066b647d7d4fc3b..67fe3d6c262bca639ed112bb096e4def82a0bc54 100644 (file)
@@ -15,6 +15,10 @@ update_game:
 
 
        call ui_update
+
+#ifdef DEBUG_COLLISION
+       call debug_draw_collision
+#endif
        
 
        ; TODO: update map routine
index 5d921c7b6dfb9ac3c9a83542f7f5452e68439e3e..321d471c568a5b9e51ec760c6480535a96b729f8 100644 (file)
 .chr 00000000
 .chr 00000000
 ; tile 15
-.chr 00000000
-.chr 00000000
+.chr 23000000
+.chr 32000000
 .chr 00000000
 .chr 00000000
 .chr 00000000