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_LIGHTER_6BGP
const RGBFADE_TO_WHITE_6BGP_2OBP
const RGBFADE_TO_WHITE_8BGP_8OBP
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_END_TURN ; 3
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:
wait 300
exitoverworld $00
exitoverworld ABANDONED_LEVEL
.ConfirmExitText:
text "Abandon level and"

View File

@ -43,8 +43,25 @@ MinigameSpaceScript::
end
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
.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::
scall ArriveToRegularSpaceScript
iftrue .not_landed
@ -69,9 +86,15 @@ ArriveToRegularSpace:
ld [hScriptVar], a
; if landed, clear spaces left sprites
and a
ret nz
jr nz, .not_landed
ld hl, wDisplaySecondarySprites
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
LandedInRegularSpaceScript:

View File

@ -275,9 +275,10 @@ _DoRGBFadeEffect::
RGBFadeEffectJumptable:
; entries correspond to RGBFADE_* constants (see constants/cgb_pal_constants.asm)
table_width 2, RGBFadeEffectJumptable
dw _RGBFadeToBlack_6BGP
dw _RGBFadeToLighter_6BGP
dw _RGBFadeToWhite_6BGP_2OBP
dw _RGBFadeToBlack_6BGP ; RGBFADE_TO_BLACK_6BGP
dw _RGBFadeToLighter_6BGP ; RGBFADE_TO_LIGHTER_6BGP
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
_RGBFadeToBlack_6BGP:
@ -344,4 +345,35 @@ _RGBFadeToWhite_6BGP_2OBP:
pop bc
dec c
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:
xor a
ldh [hMapAnims], a
ldh [hSCX], a
ldh [hSCY], a
call ClearTilemap
call LoadFrame
call LoadStandardFont

View File

@ -3080,7 +3080,7 @@ InitSprites:
_UpdateSecondarySprites::
; 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,
; fall back to calling _UpdateSprites to avoid corruption.
ld a, [wVramState]