From 0ab2977ef60aad0b369d4b43f691578e5ddd15a0 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Tue, 23 Sep 2025 18:22:01 +0200 Subject: [PATCH] mapobj: map objects are not loaded as soon as the player scrolls instead of during draw --- src/actor.s | 1 - src/map.s | 16 +++++++++++----- src/player.s | 8 +++++--- src/rectangle.s | 1 - src/video.s | 7 +++++++ 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/actor.s b/src/actor.s index d292de9..cbb2377 100644 --- a/src/actor.s +++ b/src/actor.s @@ -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 diff --git a/src/map.s b/src/map.s index 4388b72..c966846 100644 --- 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 diff --git a/src/player.s b/src/player.s index 94e2e24..e4e5599 100644 --- a/src/player.s +++ b/src/player.s @@ -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: diff --git a/src/rectangle.s b/src/rectangle.s index 1cc2744..3a3e012 100644 --- a/src/rectangle.s +++ b/src/rectangle.s @@ -204,7 +204,6 @@ rect_point_test: jp nc, @no_collision @collision: - BREAK ld a, 1 ret @no_collision: diff --git a/src/video.s b/src/video.s index 11861d9..58fff90 100644 --- a/src/video.s +++ b/src/video.s @@ -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 -- 2.30.2