From b5b24e7733a4a1e40d4f1ffceafb9c2d4a43dcfe Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sun, 21 Sep 2025 18:27:06 +0200 Subject: [PATCH] map: Added second debug rectangle --- src/debug.s | 22 +++++++++++++++++++++- src/map.s | 14 +++++++++----- src/mapobj.s | 5 +++-- src/video.s | 12 +++++++++++- 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/debug.s b/src/debug.s index 66f26bc..66d3c5b 100644 --- a/src/debug.s +++ b/src/debug.s @@ -73,7 +73,10 @@ dbg_update: ; keys: ; up + select: cycle to next debug rectangle dbg_rect_draw: - ; TODO: add rectangle cycles + ld b, BTNUP | BTNSELECT + input_held + cp a, BTNUP | BTNSELECT + jp z, @rect_draw_cycle ; draw each corner of the rectangle if it is not 0 ld a, [dbg_rect] @@ -194,3 +197,20 @@ dbg_rect_draw: ret @rect_not_alloced: ret +@rect_draw_cycle: + ld a, [dbg_rect] + ld l, a + ld a, [dbg_rect+1] + ld h, a + ld de, r_size + add hl, de + + ; next rectangle + ld a, l + ld [dbg_rect], a + ld a, h + ld [dbg_rect+1], a + + ld a, 16 + ld [dbg_delay], a + ret diff --git a/src/map.s b/src/map.s index 1e15031..0de607c 100644 --- a/src/map.s +++ b/src/map.s @@ -235,11 +235,15 @@ l1_map: mapdef 0, pat_empty, l1_objs, bank8000, bank8800, bank8C00, bank9000 l1_objs: - modef MOT_SET_PAT, 0, 3, pat_center_empty_wall - ; rectangle at y/x 0/0 with height 16 width 64 - modef MOT_RECT, 0, 3, 0x0802 - modef MOT_SET_PAT, 0, 8, pat_center_grass - modef MOT_SET_PAT, 0, 10, pat_center_empty_wall + modef MOT_SET_PAT, 0, 8, pat_center_empty_wall + ; rectangle at y/x 0/0 with height 32 width 64 + modef MOT_RECT, 0, 9, 0x0804 + + ; rectangle at y/x 0/0 with height 32 width 48 + modef MOT_RECT, 0, 9, 0xE604 + + modef MOT_SET_PAT, 0, 10, pat_center_grass + modef MOT_SET_PAT, 0, 18, pat_center_empty_wall modef MOT_SET_PAT, 0, 0x1E, pat_empty modef MOT_DISABLE_SCROLL, 0, 0x20, 0 modef MOT_NOP, 0, 0xFF, 0 diff --git a/src/mapobj.s b/src/mapobj.s index e629ce3..c4c057b 100644 --- a/src/mapobj.s +++ b/src/mapobj.s @@ -119,7 +119,8 @@ mo_rect: add hl, de ; hl = dat1 - ; current row always has y-position 16 + ; current row always has y-position 0 + ; (actually -16 so the next adjust will not move the rectanglet to the wrong spot) ; for the bottom left corner ; calculate y position @@ -128,7 +129,7 @@ mo_rect: swap a mul8 a ; a = y offset - ld b, MAP_ROW_H + ld b, -16 & 0xFF add a, b ld b, a ; b = y position diff --git a/src/video.s b/src/video.s index 2e86d40..11861d9 100644 --- a/src/video.s +++ b/src/video.s @@ -81,13 +81,18 @@ scroll_up_adjust: ld [hl+], a ; hl = page y pos hi ; check if off-screen + ; do not despawn if -16 + cp a, -16 & 0xFF + jr nc, @no_act_despawn REL + pop de push de push af cp a, 0x70 call nc, actor_despawn pop af - + +@no_act_despawn: pop hl push hl @@ -131,10 +136,15 @@ scroll_up_adjust: ld [hl], a ; check if off-screen + cp a, -16 & 0xFF ; do not despawn if -16 + jr nc, @no_rect_despawn REL + pop de push de cp a, 0xB0 call nc, rect_despawn + +@no_rect_despawn: pop hl dec b -- 2.30.2