End space effect (#22)

This commit is contained in:
xCrystal 2023-10-21 18:00:59 +02:00
parent b0e2e7aef3
commit 961d2f0b6e
7 changed files with 70 additions and 7 deletions

View File

@ -130,4 +130,5 @@ DEF NUM_PREDEF_PALS EQU const_value
const RGBFADE_TO_BLACK_6BGP const RGBFADE_TO_BLACK_6BGP
const RGBFADE_TO_LIGHTER_6BGP const RGBFADE_TO_LIGHTER_6BGP
const RGBFADE_TO_WHITE_6BGP_2OBP const RGBFADE_TO_WHITE_6BGP_2OBP
const RGBFADE_TO_WHITE_8BGP_8OBP
DEF NUM_RGB_FADE_EFFECTS EQU const_value DEF NUM_RGB_FADE_EFFECTS EQU const_value

View File

@ -330,3 +330,8 @@ DEF NUM_UNOWN_PUZZLES EQU const_value
const BOARDEVENT_HANDLE_BOARD ; 2 const BOARDEVENT_HANDLE_BOARD ; 2
const BOARDEVENT_END_TURN ; 3 const BOARDEVENT_END_TURN ; 3
DEF NUM_BOARD_EVENTS EQU const_value - 1 DEF NUM_BOARD_EVENTS EQU const_value - 1
; exitoverworld arguments
const_def
const ABANDONED_LEVEL ; 0
const CLEARED_LEVEL ; 1

View File

@ -56,7 +56,7 @@ BoardMenuScript::
.exit: .exit:
wait 300 wait 300
exitoverworld $00 exitoverworld ABANDONED_LEVEL
.ConfirmExitText: .ConfirmExitText:
text "Abandon level and" text "Abandon level and"

View File

@ -43,8 +43,25 @@ MinigameSpaceScript::
end end
EndSpaceScript:: EndSpaceScript::
; fading out will kick before reaching HandleMapBackground, so update sprites after any change
scall ArriveToRegularSpaceScript
wait 400
playmusic MUSIC_TRAINER_VICTORY
wait 600
callasm .FadeOutSlow ; 800 ms
wait 400
exitoverworld CLEARED_LEVEL
end end
.FadeOutSlow:
; clear spaces left sprites
ld hl, wDisplaySecondarySprites
res SECONDARYSPRITES_SPACES_LEFT_F, [hl]
farcall _UpdateSprites
; fade out slow to white
ld b, RGBFADE_TO_WHITE_8BGP_8OBP
jp DoRGBFadeEffect
GreySpaceScript:: GreySpaceScript::
scall ArriveToRegularSpaceScript scall ArriveToRegularSpaceScript
iftrue .not_landed iftrue .not_landed
@ -69,9 +86,15 @@ ArriveToRegularSpace:
ld [hScriptVar], a ld [hScriptVar], a
; if landed, clear spaces left sprites ; if landed, clear spaces left sprites
and a and a
ret nz jr nz, .not_landed
ld hl, wDisplaySecondarySprites ld hl, wDisplaySecondarySprites
res SECONDARYSPRITES_SPACES_LEFT_F, [hl] res SECONDARYSPRITES_SPACES_LEFT_F, [hl]
.not_landed
; if End Space, update sprites
ld a, [wPlayerTile]
cp COLL_END_SPACE
ret nz
farcall _UpdateSprites
ret ret
LandedInRegularSpaceScript: LandedInRegularSpaceScript:

View File

@ -275,9 +275,10 @@ _DoRGBFadeEffect::
RGBFadeEffectJumptable: RGBFadeEffectJumptable:
; entries correspond to RGBFADE_* constants (see constants/cgb_pal_constants.asm) ; entries correspond to RGBFADE_* constants (see constants/cgb_pal_constants.asm)
table_width 2, RGBFadeEffectJumptable table_width 2, RGBFadeEffectJumptable
dw _RGBFadeToBlack_6BGP dw _RGBFadeToBlack_6BGP ; RGBFADE_TO_BLACK_6BGP
dw _RGBFadeToLighter_6BGP dw _RGBFadeToLighter_6BGP ; RGBFADE_TO_LIGHTER_6BGP
dw _RGBFadeToWhite_6BGP_2OBP dw _RGBFadeToWhite_6BGP_2OBP ; RGBFADE_TO_WHITE_6BGP_2OBP
dw _RGBFadeToWhite_8BGP_8OBP ; RGBFADE_TO_WHITE_8BGP_8OBP
assert_table_length NUM_RGB_FADE_EFFECTS assert_table_length NUM_RGB_FADE_EFFECTS
_RGBFadeToBlack_6BGP: _RGBFadeToBlack_6BGP:
@ -344,4 +345,35 @@ _RGBFadeToWhite_6BGP_2OBP:
pop bc pop bc
dec c dec c
jr nz, .loop jr nz, .loop
ret ret
_RGBFadeToWhite_8BGP_8OBP:
ld c, 32 / 2
.loop
push bc
; fade BGP to white
ld de, wBGPals2
ld c, 8 * NUM_PAL_COLORS
call FadeStepColorsToWhite
; commit pals
ld a, TRUE
ldh [hCGBPalUpdate], a
call DelayFrame
; fade OBP to white
ld de, wOBPals2
ld c, 8 * NUM_PAL_COLORS
call FadeStepColorsToWhite
; commit pals and apply delay
ld a, TRUE
ldh [hCGBPalUpdate], a
ld c, 2
call DelayFrames
pop bc
dec c
jr nz, .loop
ret

View File

@ -14,6 +14,8 @@ GameMenu:
GameMenu_KeepMusic: GameMenu_KeepMusic:
xor a xor a
ldh [hMapAnims], a ldh [hMapAnims], a
ldh [hSCX], a
ldh [hSCY], a
call ClearTilemap call ClearTilemap
call LoadFrame call LoadFrame
call LoadStandardFont call LoadStandardFont

View File

@ -3080,7 +3080,7 @@ InitSprites:
_UpdateSecondarySprites:: _UpdateSecondarySprites::
; this is a shorter _UpdateSprites for when only secondary sprites have changed since the last sprites update, ; this is a shorter _UpdateSprites for when only secondary sprites have changed since the last sprites update,
; but NOT expanded, which would require to displace primary (NPC) sprites in OAM. ; but NOT expanded or shrinked, which would require to displace primary (NPC) sprites in OAM.
; if it is detected that the size of secondary sprites has increased in the end, ; if it is detected that the size of secondary sprites has increased in the end,
; fall back to calling _UpdateSprites to avoid corruption. ; fall back to calling _UpdateSprites to avoid corruption.
ld a, [wVramState] ld a, [wVramState]