map: Added second debug rectangle
authorLukas Krickl <lukas@krickl.dev>
Sun, 21 Sep 2025 16:27:06 +0000 (18:27 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sun, 21 Sep 2025 16:27:06 +0000 (18:27 +0200)
src/debug.s
src/map.s
src/mapobj.s
src/video.s

index 66f26bc85a3a9fc4d832a3f654324046a19b1e87..66d3c5b517149fbded9268fcef4ea98aecf2cf33 100644 (file)
@@ -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
index 1e1503193be17d12828a35f7fe904f03c3644abb..0de607cbd45dd42c29050bc3b36fe6dfc0342649 100644 (file)
--- 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
index e629ce361126c971d32e4bac39c71ce0d92d4c91..c4c057bf1240c22942ade3537aa190a3b9fce69b 100644 (file)
@@ -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
        
index 2e86d40356419b3e9cc793066057acc7165de734..11861d914fa60715606d23ce893ea3e071171687 100644 (file)
@@ -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