#define PLAYER_SPRITE_IDLE1 0x8D
- ; if the player's real y position is over
- ; a certain value we should scroll the map
- ; if scrolling is allowed
-player_try_scroll_up:
- ; do not scroll if the scroll timer is enabled
+ ; sets scroll unless scroll is diabled
+player_set_scroll:
+ ; scroll can still be allowed to complete the next tile
+ ; even if the scroll disable object is loaded
ld a, [scroll_timer]
- cp a, 0
- ret nz
+ cp a, MAP_ROW_H-1
+ jr z, @scroll_anyway REL
ld a, [game_flags]
and a, GPF_NO_SCROLL
- ret nz ; no scroll allowed for now
+ ret nz
+
+@scroll_anyway:
+ ld a, [game_flags]
+ or a, GPF_SCROLL
+ ld [game_flags], a
+ ret
+ ; if the player's real y position is over
+ ; a certain value we should scroll the map
+ ; if scrolling is allowed
+player_try_scroll_up:
ld a, [player_next_scroll_y]
ld b, a
ld a, [player+act_pos_y]
cp a, b
jp nc, @no_scroll
- ld a, [game_flags]
- or a, GPF_SCROLL
- ld [game_flags], a
+ call player_set_scroll
; run next objects
; so they are loaded before a move is attempted
; loads a new map row and sets the scroll
; timer
video_map_perform_scroll:
- ld a, [game_flags]
- and a, GPF_SCROLL
- ret z
+ ld a, [scroll_timer]
+ cp a, MAP_ROW_H-1
+ ret nz
- call map_advance_row
+ xor a, a
+ ld [scroll_timer], a
- ; unset flag
- ld a, [game_flags]
- and a, ~GPF_SCROLL & 0xFF
- ld [game_flags], a
+ call map_advance_row
- ld a, MAP_ROW_H
- ld [scroll_timer], a
ret
; adjusts the scroll slowly 1 pixel each frame
; until the timer reaches 0
video_map_adjust_scroll:
- ld a, [scroll_timer]
- cp a, 0
+ ld a, [game_flags]
+ and a, GPF_SCROLL
ret z
- dec a
+ ; unset flag
+ ld a, [game_flags]
+ and a, ~GPF_SCROLL & 0xFF
+ ld [game_flags], a
+
+ ld a, [scroll_timer]
+ inc a
ld [scroll_timer], a
ld a, [scroll_y]