; inputs:
; $1: BGP
#macro video_fade_set_bgp
- ld a, BGP
+ ld a, [RBGP]
and a, $1
ld [RBGP], a
; interrupts must be enabled
; preserved all registers
; disables window
+ ; fades away from current RBGP
video_fade_out:
push_all
; interrupts must be enabled
; preserved all registers
; enables window
+ ; inputs:
+ ; a: new palette
video_fade_in:
push_all
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
+
+ ; wait a few frames
+ call next_vblank_wait
+ call next_vblank_wait
+ call next_vblank_wait
+ call next_vblank_wait
+ call next_vblank_wait
+ call next_vblank_wait
+ call next_vblank_wait
; re-enable window
ld a, [RLCD]
or a, LCDF_WINDOWON
ld [RLCD], a
- ld a, BGP
- ld [RBGP], a
pop_all
+ ; push all saved new palette value
+ ; so we can use it here
+ ld [RBGP], a
ret
#undefine video_fade_set_bgp