ret z ; if not input bail
@skip_input_check:
+ ; fade out
+ call video_fade_out
+
; now we can load the map
; load map ptr
ld de, exit_to
add hl, de ; hl = map ptr
- ; fade out
- call video_fade_out
ld a, [hl+]
ld c, a
ld l, a ; hl = map header ptr
call map_load
- ; fade back in
- call video_fade_in
-
pop bc ; bc = exit table now
; finally adjust player position
call z, map_exit_absolute_adjust
call nz, map_exit_relative_adjust
+
+ ; scroll to player's position
+ ld de, player_unit
+ call unit_scroll_center
+ call next_vblank_wait
+ call scroll_write
+
+ ; fade back in
+ call video_fade_in
+
+
ret
; adjusts player position to aboslute
or a, c
jr nz, video_wait_n_frames REL
ret
-
+
+ ; sets BGP | $1
+ ; and then waits
+ ; inputs:
+ ; $1: BGP
+#macro video_fade_set_bgp
+ ld a, BGP
+ and a, $1
+ ld [RBGP], a
+
+ ; wait for 5 frames
+ ld bc, 0x4
+ call video_wait_n_frames
+#endmacro
+
; fades out the background
; interrupts must be enabled
; preserved all registers
+ ; disables window
video_fade_out:
- push_all
+ push_all
+
+ ; disable winodw
+ ld a, [RLCD]
+ and a, ~LCDF_WINDOWON & 0xFF
+ ld [RLCD], a
- ld bc, 0xF
- call video_wait_n_frames
+ video_fade_set_bgp 0b11111111
+ video_fade_set_bgp 0b11111100
+ video_fade_set_bgp 0b11110000
+ video_fade_set_bgp 0b11000000
+ video_fade_set_bgp 0b00000000
pop_all
ret
+
+
; fades the background in
; sets RBGP to BGP
; interrupts must be enabled
; preserved all registers
+ ; enables window
video_fade_in:
push_all
- ld bc, 0xF
- call video_wait_n_frames
+ ; disable winodw
+ ld a, [RLCD]
+ and a, ~LCDF_WINDOWON & 0xFF
+ ld [RLCD], a
+
+ video_fade_set_bgp 0b11000000
+ video_fade_set_bgp 0b11110000
+ video_fade_set_bgp 0b11111100
+ video_fade_set_bgp 0b11111111
+
+ ; re-enable window
+ ld a, [RLCD]
+ or a, LCDF_WINDOWON
+ ld [RLCD], a
ld a, BGP
ld [RBGP], a
pop_all
ret
+#undefine video_fade_set_bgp
; loads tilesets
; inputs: