Fixed fadescreen interaction with weather on outdoor maps.

This commit is contained in:
Ariel A 2022-07-04 03:56:02 -04:00
parent 7fca787f1d
commit 8e436e3add
6 changed files with 28 additions and 14 deletions

View File

@ -276,7 +276,7 @@
.2byte SPECIAL_\function
.endm
@ Blocks script execution until a command or C code manually unblocks it. Generally used with specific
@ Blocks script execution until a command or C code manually unblocks it. Generally used with specific
@ commands and specials. Calling EnableBothScriptContexts for instance will allow execution to continue.
.macro waitstate
.byte 0x27
@ -998,7 +998,7 @@
.endm
@ Gives the player an Egg of the specified species.
@ VAR_RESULT will be set to MON_GIVEN_TO_PARTY, MON_GIVEN_TO_PC, or MON_CANT_GIVE depending on the outcome.
@ VAR_RESULT will be set to MON_GIVEN_TO_PARTY, MON_GIVEN_TO_PC, or MON_CANT_GIVE depending on the outcome.
.macro giveegg species:req
.byte 0x7a
.2byte \species
@ -1416,7 +1416,7 @@
.2byte \out
.endm
@ Gives 'count' coins to the player, up to a total of MAX_COINS.
@ Gives 'count' coins to the player, up to a total of MAX_COINS.
@ If the player already has MAX_COINS then VAR_RESULT is set to TRUE, otherwise it is set to FALSE.
.macro addcoins count:req
.byte 0xb4
@ -1677,9 +1677,11 @@
@ Equivalent to fadescreen but copies gPlttBufferUnfaded to gPaletteDecompressionBuffer on the fade out
@ and the reverse on the fade in, in effect saving gPlttBufferUnfaded to restore it.
.macro fadescreenswapbuffers mode:req
@ If nowait set, does not wait for the fade to complete
.macro fadescreenswapbuffers mode:req, nowait=0
.byte 0xdc
.byte \mode
.byte \nowait
.endm
@ Buffers the specified trainer's class name to the given string var.
@ -1893,7 +1895,7 @@
@ Gives 'amount' of the specified 'item' to the player and prints a message with fanfare.
@ If the player doesn't have space for all the items then as many are added as possible, the
@ message indicates there is no room, and VAR_RESULT is set to FALSE.
@ message indicates there is no room, and VAR_RESULT is set to FALSE.
@ Otherwise VAR_RESULT is set to TRUE, and the message indicates they have received the item(s).
.macro giveitem item:req, amount=1
setorcopyvar VAR_0x8000, \item

View File

@ -716,12 +716,14 @@ Common_EventScript_PlayGymBadgeFanfare::
return
Common_EventScript_OutOfCenterPartyHeal::
fadescreen FADE_TO_BLACK
fadescreenswapbuffers FADE_TO_BLACK
playfanfare MUS_HEAL
waitfanfare
special HealPlayerParty
@ start fade then immediately load following pokemon, and wait for fade
fadescreenswapbuffers FADE_FROM_BLACK, 1
callnative UpdateFollowingPokemon
fadescreen FADE_FROM_BLACK
callfunc ScrFunc_WaitPaletteNotActive
return
EventScript_RegionMap::

View File

@ -54,13 +54,13 @@ MtChimney_EventScript_Maxie::
msgbox MtChimney_Text_MaxieYouHaventSeenLastOfMagma, MSGBOX_DEFAULT
closemessage
delay 30
fadescreen FADE_TO_BLACK
fadescreenswapbuffers FADE_TO_BLACK
removeobject LOCALID_MAXIE
removeobject LOCALID_MAGMA_GRUNT_1
removeobject LOCALID_TABITHA
removeobject LOCALID_MAGMA_GRUNT_2
setflag FLAG_HIDE_MT_CHIMNEY_TEAM_MAGMA
fadescreen FADE_FROM_BLACK
fadescreenswapbuffers FADE_FROM_BLACK
setobjectxyperm LOCALID_ARCHIE, 10, 12
addobject LOCALID_ARCHIE
call_if_eq VAR_FACING, DIR_EAST, MtChimney_EventScript_ArchieApproachPlayerEast

View File

@ -49,7 +49,7 @@ MtPyre_Summit_EventScript_TeamAquaExits::
call_if_eq VAR_0x8008, 2, MtPyre_Summit_EventScript_ArchieFacePlayer2
msgbox MtPyre_Summit_Text_ArchieWeGotTheOrbLetsGo, MSGBOX_DEFAULT
closemessage
fadescreen FADE_TO_BLACK
fadescreenswapbuffers FADE_TO_BLACK
removeobject LOCALID_ARCHIE
removeobject LOCALID_GRUNT_1
removeobject LOCALID_GRUNT_2
@ -58,7 +58,7 @@ MtPyre_Summit_EventScript_TeamAquaExits::
setflag FLAG_HIDE_MT_PYRE_SUMMIT_ARCHIE
setflag FLAG_HIDE_MT_PYRE_SUMMIT_TEAM_AQUA
fadedefaultbgm
fadescreen FADE_FROM_BLACK
fadescreenswapbuffers FADE_FROM_BLACK
delay 20
setvar VAR_MT_PYRE_STATE, 1
call_if_eq VAR_0x8008, 0, MtPyre_Summit_EventScript_OldLadyApproachPlayer0
@ -622,4 +622,3 @@ MtPyre_Summit_Text_HoennTrioTale:
.string "becalmed the two enraged POKéMON.\p"
.string "Then, its duty done, the green POKéMON\n"
.string "flew off into the wild blue yonder…$"

View File

@ -811,8 +811,10 @@ void FadeScreen(u8 mode, s8 delay)
if (fadeOut)
{
if (TRUE || useWeatherPal) // TODO: Can copying Faded to Unfaded before fadeout cause problems ?
CpuFastCopy(gPlttBufferFaded, gPlttBufferUnfaded, PLTT_BUFFER_SIZE * 2);
// Note: Copying faded -> unfaded like this works fine, except if the screen is faded back in
// without transitioning to a different screen
// For cases like that, use fadescreenswapbuffers
CpuFastCopy(gPlttBufferFaded, gPlttBufferUnfaded, PLTT_BUFFER_SIZE * 2);
BeginNormalPaletteFade(PALETTES_ALL, delay, 0, 16, fadeColor);
gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_SCREEN_FADING_OUT;

View File

@ -632,6 +632,12 @@ static bool8 IsPaletteNotActive(void)
return FALSE;
}
// pauses script until palette fade inactive
bool8 ScrFunc_WaitPaletteNotActive(struct ScriptContext *ctx) {
SetupNativeScript(ctx, IsPaletteNotActive);
return TRUE;
}
bool8 ScrCmd_fadescreen(struct ScriptContext *ctx)
{
FadeScreen(ScriptReadByte(ctx), 0);
@ -652,6 +658,7 @@ bool8 ScrCmd_fadescreenspeed(struct ScriptContext *ctx)
bool8 ScrCmd_fadescreenswapbuffers(struct ScriptContext *ctx)
{
u8 mode = ScriptReadByte(ctx);
u8 nowait = ScriptReadByte(ctx);
switch (mode)
{
@ -668,6 +675,8 @@ bool8 ScrCmd_fadescreenswapbuffers(struct ScriptContext *ctx)
break;
}
if (nowait)
return FALSE;
SetupNativeScript(ctx, IsPaletteNotActive);
return TRUE;
}