From 49d885e0d0b8bf605a6016b4192e0c96f1961b75 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Tue, 23 Sep 2025 05:45:06 +0200 Subject: [PATCH] debug: debug rectangle draw now uses the same point functions as collisions This is still wip and kinda broken now --- src/debug.s | 79 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 34 deletions(-) diff --git a/src/debug.s b/src/debug.s index 66d3c5b..427c406 100644 --- a/src/debug.s +++ b/src/debug.s @@ -68,6 +68,25 @@ dbg_update: ld [dbg_delay], a ret + ; gets rectangle point and loads it into de + ; preserves all other registers + ; inputs: + ; $1: rect_br/bl/tr/tl + ; de: rectangle ptr +#macro dbg_rect_draw_get + push hl + push de + + push de + pop hl ; hl = rectangle + call $1 + push de + pop bc ; bc = point + + pop de + pop hl +#endmacro + ; draws a marker obj at ; the edge of a rectangle ; keys: @@ -97,24 +116,17 @@ dbg_rect_draw: pop de ; hl = oam - inc de ; de = y position - - ld a, [de] - add a, OBJ_OFF_Y - ld b, a ; b = y - - inc de - ld a, [de] - add a, OBJ_OFF_X - ld c, a ; c = x - inc de ; de = height + dbg_rect_draw_get rect_tl + ; bc = top left ; write top left y ld a, b + add a, OBJ_OFF_Y ld [hl+], a ; write top left x ld a, c + add a, OBJ_OFF_X ld [hl+], a ; write tile @@ -124,20 +136,19 @@ dbg_rect_draw: ; write flags xor a, a ld [hl+], a - - ; write top left y - ld a, [de] ; a = heigth - push bc - ld c, a - ld a, b - sub a, c ; height - y - pop bc + ; bottom left + dbg_rect_draw_get rect_bl + + ; write bottom left y + ld a, b + add a, OBJ_OFF_Y ld [hl+], a - ; write top left x + ; write bottom left x ld a, c + add a, OBJ_OFF_X ld [hl+], a ; write tile @@ -148,14 +159,19 @@ dbg_rect_draw: xor a, a ld [hl+], a + + + ; bottom right + dbg_rect_draw_get rect_br + ; write bottom right y - inc de ; de = width - ld a, b ; a = y + ld a, b + add a, OBJ_OFF_Y ld [hl+], a ; write bottomt right x ld a, [de] - add a, c ; width + x + add a, OBJ_OFF_X ld [hl+], a ; write tile @@ -166,23 +182,18 @@ dbg_rect_draw: xor a, a ld [hl+], a - dec de ; de = height - ; write top right y - ld a, [de] ; a = height - push bc - ld c, a - ld a, b - sub a, c ; height - y - pop bc + ; top right + dbg_rect_draw_get rect_tr + ld a, b + add a, OBJ_OFF_X ld [hl+], a ; write top left x - inc de ; de = width - ld a, [de] - add a, c ; width + x + add a, c + add a, OBJ_OFF_X ld [hl+], a ; write tile -- 2.30.2