mapobj: map objects are not loaded as soon as the player scrolls instead of during...
authorLukas Krickl <lukas@krickl.dev>
Tue, 23 Sep 2025 16:22:01 +0000 (18:22 +0200)
committerLukas Krickl <lukas@krickl.dev>
Tue, 23 Sep 2025 16:22:01 +0000 (18:22 +0200)
src/actor.s
src/map.s
src/player.s
src/rectangle.s
src/video.s

index d292de9b44af20b3105578b633939a19e4437ffe..cbb23773b48f3fc1b144616ff315ce085b6c6004 100644 (file)
@@ -166,7 +166,6 @@ actor_write_default_collider:
                pop bc
                pop hl ; hl = test rect
 
-               BREAK
                call rect_point_test
                cp a, 1
                jp z, $2
index 4388b725b8aadf0443ed703e8c579344c92e537a..c96684626706a59869c19a6ed25f94798a20f9db 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -195,8 +195,6 @@ map_advance_row:
        inc a
        ld [map_curr_row], a
 
-       call mo_exec
-
        ret
        
        
@@ -205,28 +203,36 @@ map_advance_row:
        ; inputs:
        ;               [map]
 map_page_full_draw:
+       call mo_exec
        call next_vblank_wait
        call map_advance_row
 
+       call mo_exec
        call next_vblank_wait
        call map_advance_row
 
+       call mo_exec
        call next_vblank_wait
        call map_advance_row
 
+       call mo_exec
        call next_vblank_wait
        call map_advance_row
 
+       call mo_exec
        call next_vblank_wait
        call map_advance_row
 
+       call mo_exec
        call next_vblank_wait
        call map_advance_row
 
+       call mo_exec
        call next_vblank_wait
        call map_advance_row
        
        ; last row will be out of visible scroll
+       call mo_exec
        call next_vblank_wait
        call map_advance_row
        ret
@@ -237,13 +243,13 @@ l1_map:
 l1_objs:
        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 
+       modef MOT_RECT, 0, 8, 0x0804 
 
        ; center rectangle
-       ; modef MOT_RECT, 0, 9, 0x8604 
+       ; modef MOT_RECT, 0, 8, 0x8604 
 
        ; rectangle at y/x 0/0 with height 32 width 48 
-       modef MOT_RECT, 0, 9, 0xE604 
+       modef MOT_RECT, 0, 8, 0xE604 
 
        modef MOT_SET_PAT, 0, 10, pat_center_grass 
        modef MOT_SET_PAT, 0, 18, pat_center_empty_wall
index 94e2e24b49441290694ad64513fe921a6018864e..e4e5599328b86b9efea98e0e9eac2055514ae191 100644 (file)
@@ -17,11 +17,11 @@ player_update:
        ld b, BTNUP
        input_held
        jr z, @not_up REL
+               call player_try_scroll_up
                ld b, PLAYER_SPEED
                ld c, 0
                call player_stage_move_n
                call player_try_move
-               call player_try_scroll_up
 @not_up:
 
        ld b, BTNDOWN
@@ -70,8 +70,6 @@ player_update:
        ; if the player's real y position is over
        ; a certain value we should scroll the map
        ; if scrolling is allowed
-       ; inputs:
-       ;               player setp up counter
 player_try_scroll_up:
        ; do not scroll if the scroll timer is enabled
        ld a, [scroll_timer]
@@ -91,6 +89,10 @@ player_try_scroll_up:
                ld a, [game_flags]
                or a, GPF_SCROLL
                ld [game_flags], a
+               
+               ; run next objects
+               ; so they are loaded before a move is attempted
+               call mo_exec
 
        
 @no_scroll:
index 1cc2744a8fe3dd75082d990f0a28cf2378db4370..3a3e0125fc38564636b6b850c2ff0e3e49f53dd2 100644 (file)
@@ -204,7 +204,6 @@ rect_point_test:
        jp nc, @no_collision
 
 @collision:
-       BREAK
        ld a, 1
        ret
 @no_collision:
index 11861d914fa60715606d23ce893ea3e071171687..58fff9057f027277b54c9870774e59561c0997da 100644 (file)
@@ -151,6 +151,13 @@ scroll_up_adjust:
                ld de, r_size
                add hl, de
                jr nz, @rect_loop REL
+
+       ; adjust tmp rect
+       ; (just in case we missed a vblank)
+       ld a, [tmp_rect+r_pos_y]
+       inc a
+       ld [tmp_rect+r_pos_y], a
+
        ret
 
   ; writes scroll to scroll registers