From 1fa5adbaf60244856448df5e38eeddbebe897570 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Tue, 9 Dec 2025 05:24:29 +0100 Subject: [PATCH] debug: Added debug collision display --- maps/spawn.inc | 2 +- src/config.s | 1 + src/debug.s | 52 ++++++++++++++++++++++++++++++++++++++++++++++ src/main.s | 1 + src/update.s | 4 ++++ tiles/bank8800.inc | 4 ++-- 6 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 src/config.s diff --git a/maps/spawn.inc b/maps/spawn.inc index 37ff478..c0186aa 100644 --- a/maps/spawn.inc +++ b/maps/spawn.inc @@ -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 index 0000000..d3cfc84 --- /dev/null +++ b/src/config.s @@ -0,0 +1 @@ +#define DEBUG_COLLISION diff --git a/src/debug.s b/src/debug.s index e69de29..6539673 100644 --- a/src/debug.s +++ b/src/debug.s @@ -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 diff --git a/src/main.s b/src/main.s index f63d46f..9adf896 100644 --- a/src/main.s +++ b/src/main.s @@ -1,4 +1,5 @@ #include "hw.inc" +#include "config.s" #include "macros.inc" #include "oam.s" #include "defs.s" diff --git a/src/update.s b/src/update.s index 97cf79b..67fe3d6 100644 --- a/src/update.s +++ b/src/update.s @@ -15,6 +15,10 @@ update_game: call ui_update + +#ifdef DEBUG_COLLISION + call debug_draw_collision +#endif ; TODO: update map routine diff --git a/tiles/bank8800.inc b/tiles/bank8800.inc index 5d921c7..321d471 100644 --- a/tiles/bank8800.inc +++ b/tiles/bank8800.inc @@ -254,8 +254,8 @@ .chr 00000000 .chr 00000000 ; tile 15 -.chr 00000000 -.chr 00000000 +.chr 23000000 +.chr 32000000 .chr 00000000 .chr 00000000 .chr 00000000 -- 2.30.2