Merge pull request #1285 from GriffinRichards/doc-fieldscr

Minor field_screen_effect / field_player_avatar documentation
This commit is contained in:
GriffinR 2021-01-03 01:59:36 -05:00 committed by GitHub
commit f2ce06683d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 206 additions and 191 deletions

View File

@ -209,7 +209,7 @@ gScriptCmdTable:: @ 81DB67C
.4byte ScrCmd_checkmonobedience @ 0xce
.4byte ScrCmd_gotoram @ 0xcf
.4byte ScrCmd_nop1 @ 0xd0
.4byte ScrCmd_warpD1 @ 0xd1
.4byte ScrCmd_warpspinenter @ 0xd1
.4byte ScrCmd_setmonmetlocation @ 0xd2
.4byte ScrCmd_moverotatingtileobjects @ 0xd3
.4byte ScrCmd_turnrotatingtileobjects @ 0xd4

View File

@ -36,7 +36,7 @@ void sub_808BCE8(void);
void InitPlayerAvatar(s16 a, s16 b, u8 c, u8 d);
void sub_808B864(void);
void sub_808BCF4(void);
void sub_808D074(u8);
void SetSpinStartFacingDir(u8);
void GetXYCoordsOneStepInFrontOfPlayer(s16 *xPtr, s16 *yPtr);
u8 GetRivalAvatarGraphicsIdByStateIdAndGender(u8, u8);
void SetPlayerAvatarFieldMove(void);
@ -57,10 +57,10 @@ void PlayerWheelieMove(u8 direction);
void PlayerPopWheelieWhileMoving(u8 direction);
void PlayerUseAcroBikeOnBumpySlope(u8 direction);
void PlayerEndWheelieWhileMoving(u8 direction);
void sub_808D194(void);
void sub_808D1C8(void);
bool32 sub_808D1B4(void);
bool32 sub_808D1E8(void);
void DoPlayerSpinEntrance(void);
void DoPlayerSpinExit(void);
bool32 IsPlayerSpinEntranceActive(void);
bool32 IsPlayerSpinExitActive(void);
void SetPlayerInvisibility(bool8 invisible);
u8 player_get_pos_including_state_based_drift(s16 *x, s16 *y);
void StartFishing(u8 rod);

View File

@ -18,8 +18,8 @@ void FieldCB_WarpExitFadeFromBlack(void);
void FieldCB_WarpExitFadeFromWhite(void);
bool8 FieldCB_ReturnToFieldOpenStartMenu(void);
void ReturnToFieldOpenStartMenu(void);
void sub_80AF6D4(void);
void sub_80AF6F0(void);
void FieldCB_ReturnToFieldNoScript(void);
void FieldCB_ReturnToFieldNoScriptCheckMusic(void);
void DoWarp(void);
void DoDiveWarp(void);
void DoSootopolisLegendWarp(void);
@ -35,8 +35,8 @@ void DoCableClubWarp(void);
void DoContestHallWarp(void);
void AnimateFlash(u8 flashLevel);
void WriteBattlePyramidViewScanlineEffectBuffer(void);
void sub_80B0244(void);
void sub_80B0268(void);
void DoSpinEnterWarp(void);
void DoSpinExitWarp(void);
void DoOrbEffect(void);
void FadeOutOrbEffect(void);
void sub_80B05B4(void);

View File

@ -607,7 +607,7 @@ static void CB2_EndWildBattle(void)
else
{
SetMainCallback2(CB2_ReturnToField);
gFieldCallback = sub_80AF6F0;
gFieldCallback = FieldCB_ReturnToFieldNoScriptCheckMusic;
}
}

View File

@ -730,7 +730,8 @@ static bool8 TryStartWarpEventScript(struct MapPosition *position, u16 metatileB
}
if (MetatileBehavior_IsWarpOrBridge(metatileBehavior) == TRUE)
{
sub_80B0268();
// Maybe unused? This MB is used by log bridges, but there's never a warp event on them
DoSpinExitWarp();
return TRUE;
}
if (MetatileBehavior_IsMtPyreHole(metatileBehavior) == TRUE)

View File

@ -31,7 +31,7 @@
#include "constants/songs.h"
#include "constants/trainer_types.h"
static EWRAM_DATA u8 gUnknown_0203734C = 0;
static EWRAM_DATA u8 sSpinStartFacingDir = 0;
EWRAM_DATA struct ObjectEvent gObjectEvents[OBJECT_EVENTS_COUNT] = {};
EWRAM_DATA struct PlayerAvatar gPlayerAvatar = {};
@ -138,7 +138,7 @@ static u8 Fishing_PutRodAway(struct Task *task);
static u8 Fishing_EndNoMon(struct Task *task);
static void AlignFishingAnimationFrames(void);
static u8 sub_808D38C(struct ObjectEvent *object, s16 *a1);
static u8 TrySpinPlayerForWarp(struct ObjectEvent *object, s16 *a1);
// .rodata
@ -2050,54 +2050,64 @@ static void AlignFishingAnimationFrames(void)
SetSurfBobWhileFishingState(gObjectEvents[gPlayerAvatar.objectEventId].fieldEffectSpriteId, 1, playerSprite->pos2.y);
}
void sub_808D074(u8 a0)
void SetSpinStartFacingDir(u8 direction)
{
gUnknown_0203734C = a0;
sSpinStartFacingDir = direction;
}
static u8 sub_808D080(void)
static u8 GetSpinStartFacingDir(void)
{
if (gUnknown_0203734C == 0)
{
return 1;
}
return gUnknown_0203734C;
if (sSpinStartFacingDir == DIR_NONE)
return DIR_SOUTH;
return sSpinStartFacingDir;
}
static void sub_808D094(u8 taskId)
// Task data for Task_DoPlayerSpinEntrance and Task_DoPlayerSpinExit
#define tState data[0]
#define tSpinDelayTimer data[1]
#define tSpeed data[2]
#define tCurY data[3]
#define tDestY data[4]
#define tStartDir data[5]
#define tPriority data[6]
#define tSubpriority data[7]
#define tGroundTimer data[8]
static void Task_DoPlayerSpinExit(u8 taskId)
{
struct ObjectEvent *object = &gObjectEvents[gPlayerAvatar.objectEventId];
struct Sprite *sprite = &gSprites[object->spriteId];
s16 *data = gTasks[taskId].data;
switch (data[0])
switch (tState)
{
case 0:
case 0: // Init
if (!ObjectEventClearHeldMovementIfFinished(object))
{
return;
}
sub_808D074(object->facingDirection);
data[1] = 0;
data[2] = 1;
data[3] = (u16)(sprite->pos1.y + sprite->pos2.y) << 4;
SetSpinStartFacingDir(object->facingDirection);
tSpinDelayTimer = 0;
tSpeed = 1;
tCurY = (u16)(sprite->pos1.y + sprite->pos2.y) << 4;
sprite->pos2.y = 0;
CameraObjectReset2();
object->fixedPriority = TRUE;
sprite->oam.priority = 0;
sprite->subpriority = 0;
sprite->subspriteMode = SUBSPRITES_OFF;
data[0]++;
case 1:
sub_808D38C(object, &data[1]);
data[3] -= data[2];
data[2] += 3;
sprite->pos1.y = data[3] >> 4;
tState++;
case 1: // Spin while rising
TrySpinPlayerForWarp(object, &tSpinDelayTimer);
// Rise and accelerate
tCurY -= tSpeed;
tSpeed += 3;
sprite->pos1.y = tCurY >> 4;
// Check if offscreen
if (sprite->pos1.y + (s16)gTotalCameraPixelOffsetY < -32)
{
data[0]++;
}
tState++;
break;
case 2:
DestroyTask(taskId);
@ -2105,84 +2115,86 @@ static void sub_808D094(u8 taskId)
}
}
static void sub_808D1FC(u8 taskId);
static void Task_DoPlayerSpinEntrance(u8 taskId);
void sub_808D194(void)
void DoPlayerSpinEntrance(void)
{
sub_808D1FC(CreateTask(sub_808D1FC, 0));
Task_DoPlayerSpinEntrance(CreateTask(Task_DoPlayerSpinEntrance, 0));
}
bool32 sub_808D1B4(void)
bool32 IsPlayerSpinEntranceActive(void)
{
return FuncIsActiveTask(sub_808D1FC);
return FuncIsActiveTask(Task_DoPlayerSpinEntrance);
}
void sub_808D1C8(void)
void DoPlayerSpinExit(void)
{
sub_808D094(CreateTask(sub_808D094, 0));
Task_DoPlayerSpinExit(CreateTask(Task_DoPlayerSpinExit, 0));
}
bool32 sub_808D1E8(void)
bool32 IsPlayerSpinExitActive(void)
{
return FuncIsActiveTask(sub_808D094);
return FuncIsActiveTask(Task_DoPlayerSpinExit);
}
static const u8 gUnknown_084975BC[] = {DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH};
static const u8 sSpinDirections[] = {DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH};
static void sub_808D1FC(u8 taskId)
static void Task_DoPlayerSpinEntrance(u8 taskId)
{
struct ObjectEvent *object = &gObjectEvents[gPlayerAvatar.objectEventId];
struct Sprite *sprite = &gSprites[object->spriteId];
s16 *data = gTasks[taskId].data;
switch (data[0])
switch (tState)
{
case 0:
data[5] = sub_808D080();
ObjectEventForceSetHeldMovement(object, GetFaceDirectionMovementAction(gUnknown_084975BC[data[5]]));
data[1] = 0;
data[2] = 116;
data[4] = sprite->pos1.y;
data[6] = sprite->oam.priority;
data[7] = sprite->subpriority;
data[3] = -((u16)sprite->pos2.y + 32) * 16;
// Because the spin start facing direction is never set for this
// warp type, the player will always exit the warp facing South.
// This may have been intentional, unclear
tStartDir = GetSpinStartFacingDir();
ObjectEventForceSetHeldMovement(object, GetFaceDirectionMovementAction(sSpinDirections[tStartDir]));
tSpinDelayTimer = 0;
tSpeed = 116;
tDestY = sprite->pos1.y;
tPriority = sprite->oam.priority;
tSubpriority = sprite->subpriority;
tCurY = -((u16)sprite->pos2.y + 32) * 16;
sprite->pos2.y = 0;
CameraObjectReset2();
object->fixedPriority = TRUE;
sprite->oam.priority = 1;
sprite->subpriority = 0;
sprite->subspriteMode = SUBSPRITES_OFF;
data[0]++;
case 1:
sub_808D38C(object, &data[1]);
data[3] += data[2];
data[2] -= 3;
if (data[2] < 4)
tState++;
case 1: // Spin while descending
TrySpinPlayerForWarp(object, &tSpinDelayTimer);
// Fall and decelerate
tCurY += tSpeed;
tSpeed -= 3;
if (tSpeed < 4)
tSpeed = 4;
sprite->pos1.y = tCurY >> 4;
// Check if reached dest
if (sprite->pos1.y >= tDestY)
{
data[2] = 4;
}
sprite->pos1.y = data[3] >> 4;
if (sprite->pos1.y >= data[4])
{
sprite->pos1.y = data[4];
data[8] = 0;
data[0]++;
sprite->pos1.y = tDestY;
tGroundTimer = 0;
tState++;
}
break;
case 2:
sub_808D38C(object, &data[1]);
data[8]++;
if (data[8] > 8)
{
data[0]++;
}
case 2: // Spin on ground
TrySpinPlayerForWarp(object, &tSpinDelayTimer);
if (++tGroundTimer > 8)
tState++;
break;
case 3:
if (data[5] == sub_808D38C(object, &data[1]))
case 3: // Spin until facing original direction
if (tStartDir == TrySpinPlayerForWarp(object, &tSpinDelayTimer))
{
object->fixedPriority = 0;
sprite->oam.priority = data[6];
sprite->subpriority = data[7];
sprite->oam.priority = tPriority;
sprite->subpriority = tSubpriority;
CameraObjectReset1();
DestroyTask(taskId);
}
@ -2190,19 +2202,15 @@ static void sub_808D1FC(u8 taskId)
}
}
static u8 sub_808D38C(struct ObjectEvent *object, s16 *a1)
static u8 TrySpinPlayerForWarp(struct ObjectEvent *object, s16 *delayTimer)
{
if (*a1 < 8 && ++(*a1) < 8)
{
if (*delayTimer < 8 && ++(*delayTimer) < 8)
return object->facingDirection;
}
if (!ObjectEventCheckHeldMovementStatus(object))
{
return object->facingDirection;
}
ObjectEventForceSetHeldMovement(object, GetFaceDirectionMovementAction(gUnknown_084975BC[object->facingDirection]));
*a1 = 0;
return gUnknown_084975BC[object->facingDirection];
ObjectEventForceSetHeldMovement(object, GetFaceDirectionMovementAction(sSpinDirections[object->facingDirection]));
*delayTimer = 0;
return sSpinDirections[object->facingDirection];
}

View File

@ -42,11 +42,14 @@ static void Task_DoContestHallWarp(u8);
static void FillPalBufferWhite(void);
static void Task_ExitDoor(u8);
static bool32 WaitForWeatherFadeIn(void);
static void Task_TeleportTileWarpExit(u8 taskId);
static void Task_SpinEnterWarp(u8 taskId);
static void Task_WarpAndLoadMap(u8 taskId);
static void Task_DoDoorWarp(u8 taskId);
static void Task_EnableScriptAfterMusicFade(u8 taskId);
// data[0] is used universally by tasks in this file as a state for switches
#define tState data[0]
// const
static const u16 sFlashLevelPixelRadii[] = { 200, 72, 64, 56, 48, 40, 32, 24, 0 };
const s32 gMaxFlashLevel = ARRAY_COUNT(sFlashLevelPixelRadii) - 1;
@ -156,17 +159,17 @@ static void Task_ReturnToFieldCableLink(u8 taskId)
{
struct Task *task = &gTasks[taskId];
switch (task->data[0])
switch (task->tState)
{
case 0:
task->data[1] = CreateTask_ReestablishCableClubLink();
task->data[0]++;
task->tState++;
break;
case 1:
if (gTasks[task->data[1]].isActive != TRUE)
{
WarpFadeInScreen();
task->data[0]++;
task->tState++;
}
break;
case 2:
@ -191,11 +194,11 @@ static void Task_ReturnToFieldWirelessLink(u8 taskId)
{
struct Task *task = &gTasks[taskId];
switch (task->data[0])
switch (task->tState)
{
case 0:
SetLinkStandbyCallback();
task->data[0]++;
task->tState++;
break;
case 1:
if (!IsLinkTaskFinished())
@ -206,7 +209,7 @@ static void Task_ReturnToFieldWirelessLink(u8 taskId)
else
{
WarpFadeInScreen();
task->data[0]++;
task->tState++;
}
break;
case 2:
@ -224,16 +227,16 @@ void Task_ReturnToFieldRecordMixing(u8 taskId)
{
struct Task *task = &gTasks[taskId];
switch (task->data[0])
switch (task->tState)
{
case 0:
SetLinkStandbyCallback();
task->data[0]++;
task->tState++;
break;
case 1:
if (IsLinkTaskFinished())
{
task->data[0]++;
task->tState++;
}
break;
case 2:
@ -295,12 +298,12 @@ void FieldCB_WarpExitFadeFromBlack(void)
ScriptContext2_Enable();
}
static void FieldCB_TeleportTileWarpExit(void)
static void FieldCB_SpinEnterWarp(void)
{
Overworld_PlaySpecialMapMusic();
WarpFadeInScreen();
PlaySE(SE_WARP_OUT);
CreateTask(Task_TeleportTileWarpExit, 10);
CreateTask(Task_SpinEnterWarp, 10);
ScriptContext2_Enable();
}
@ -320,14 +323,14 @@ static void Task_ExitDoor(u8 taskId)
s16 *x = &task->data[2];
s16 *y = &task->data[3];
switch (task->data[0])
switch (task->tState)
{
case 0:
SetPlayerVisibility(FALSE);
FreezeObjectEvents();
PlayerGetDestCoords(x, y);
FieldSetDoorOpened(*x, *y);
task->data[0] = 1;
task->tState = 1;
break;
case 1:
if (WaitForWeatherFadeIn())
@ -336,7 +339,7 @@ static void Task_ExitDoor(u8 taskId)
SetPlayerVisibility(TRUE);
objEventId = GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0);
ObjectEventSetHeldMovement(&gObjectEvents[objEventId], MOVEMENT_ACTION_WALK_NORMAL_DOWN);
task->data[0] = 2;
task->tState = 2;
}
break;
case 2:
@ -346,14 +349,14 @@ static void Task_ExitDoor(u8 taskId)
task->data[1] = FieldAnimateDoorClose(*x, *y);
objEventId = GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0);
ObjectEventClearHeldMovementIfFinished(&gObjectEvents[objEventId]);
task->data[0] = 3;
task->tState = 3;
}
break;
case 3:
if (task->data[1] < 0 || gTasks[task->data[1]].isActive != TRUE)
{
UnfreezeObjectEvents();
task->data[0] = 4;
task->tState = 4;
}
break;
case 4:
@ -369,13 +372,13 @@ static void Task_ExitNonAnimDoor(u8 taskId)
s16 *x = &task->data[2];
s16 *y = &task->data[3];
switch (task->data[0])
switch (task->tState)
{
case 0:
SetPlayerVisibility(FALSE);
FreezeObjectEvents();
PlayerGetDestCoords(x, y);
task->data[0] = 1;
task->tState = 1;
break;
case 1:
if (WaitForWeatherFadeIn())
@ -384,14 +387,14 @@ static void Task_ExitNonAnimDoor(u8 taskId)
SetPlayerVisibility(TRUE);
objEventId = GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0);
ObjectEventSetHeldMovement(&gObjectEvents[objEventId], GetWalkNormalMovementAction(GetPlayerFacingDirection()));
task->data[0] = 2;
task->tState = 2;
}
break;
case 2:
if (IsPlayerStandingStill())
{
UnfreezeObjectEvents();
task->data[0] = 3;
task->tState = 3;
}
break;
case 3:
@ -403,12 +406,12 @@ static void Task_ExitNonAnimDoor(u8 taskId)
static void Task_ExitNonDoor(u8 taskId)
{
switch (gTasks[taskId].data[0])
switch (gTasks[taskId].tState)
{
case 0:
FreezeObjectEvents();
ScriptContext2_Enable();
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
break;
case 1:
if (WaitForWeatherFadeIn())
@ -443,7 +446,7 @@ bool8 FieldCB_ReturnToFieldOpenStartMenu(void)
return FALSE;
}
static void task_mpl_807E3C8(u8 taskId)
static void Task_ReturnToFieldNoScript(u8 taskId)
{
if (WaitForWeatherFadeIn() == 1)
{
@ -453,19 +456,19 @@ static void task_mpl_807E3C8(u8 taskId)
}
}
void sub_80AF6D4(void)
void FieldCB_ReturnToFieldNoScript(void)
{
ScriptContext2_Enable();
FadeInFromBlack();
CreateTask(task_mpl_807E3C8, 10);
CreateTask(Task_ReturnToFieldNoScript, 10);
}
void sub_80AF6F0(void)
void FieldCB_ReturnToFieldNoScriptCheckMusic(void)
{
ScriptContext2_Enable();
Overworld_PlaySpecialMapMusic();
FadeInFromBlack();
CreateTask(task_mpl_807E3C8, 10);
CreateTask(Task_ReturnToFieldNoScript, 10);
}
static bool32 PaletteFadeActive(void)
@ -543,7 +546,9 @@ void DoLavaridgeGym1FWarp(void)
StartLavaridgeGym1FWarp(10);
}
// Warp from a teleporting tile, e.g. in Aqua Hideout (For the move Teleport see FldEff_TeleportWarpOut)
// DoSpinEnterWarp but with a fade out
// Screen fades out to exit current map, player spins down from top to enter new map
// Used by teleporting tiles, e.g. in Aqua Hideout (For the move Teleport see FldEff_TeleportWarpOut)
void DoTeleportTileWarp(void)
{
ScriptContext2_Enable();
@ -551,7 +556,7 @@ void DoTeleportTileWarp(void)
WarpFadeOutScreen();
PlaySE(SE_WARP_IN);
CreateTask(Task_WarpAndLoadMap, 10);
gFieldCallback = FieldCB_TeleportTileWarpExit;
gFieldCallback = FieldCB_SpinEnterWarp;
}
void DoMossdeepGymWarp(void)
@ -574,8 +579,6 @@ void DoPortholeWarp(void)
gFieldCallback = FieldCB_ShowPortholeView;
}
#define tState data[0]
static void Task_DoCableClubWarp(u8 taskId)
{
struct Task *task = &gTasks[taskId];
@ -598,8 +601,6 @@ static void Task_DoCableClubWarp(u8 taskId)
}
}
#undef tState
void DoCableClubWarp(void)
{
ScriptContext2_Enable();
@ -613,20 +614,20 @@ static void Task_ReturnToWorldFromLinkRoom(u8 taskId)
{
s16 *data = gTasks[taskId].data;
switch (data[0])
switch (tState)
{
case 0:
ClearLinkCallback_2();
FadeScreen(FADE_TO_BLACK, 0);
TryFadeOutOldMapMusic();
PlaySE(SE_EXIT);
data[0]++;
tState++;
break;
case 1:
if (!PaletteFadeActive() && BGMusicStopped())
{
SetCloseLinkCallback();
data[0]++;
tState++;
}
break;
case 2:
@ -649,12 +650,12 @@ static void Task_WarpAndLoadMap(u8 taskId)
{
struct Task *task = &gTasks[taskId];
switch (task->data[0])
switch (task->tState)
{
case 0:
FreezeObjectEvents();
ScriptContext2_Enable();
task->data[0]++;
task->tState++;
break;
case 1:
if (!PaletteFadeActive())
@ -665,7 +666,7 @@ static void Task_WarpAndLoadMap(u8 taskId)
task->data[1] = 1;
}
if (BGMusicStopped())
task->data[0]++;
task->tState++;
}
break;
case 2:
@ -682,14 +683,14 @@ static void Task_DoDoorWarp(u8 taskId)
s16 *x = &task->data[2];
s16 *y = &task->data[3];
switch (task->data[0])
switch (task->tState)
{
case 0:
FreezeObjectEvents();
PlayerGetDestCoords(x, y);
PlaySE(GetDoorSoundEffect(*x, *y - 1));
task->data[1] = FieldAnimateDoorOpen(*x, *y - 1);
task->data[0] = 1;
task->tState = 1;
break;
case 1:
if (task->data[1] < 0 || gTasks[task->data[1]].isActive != TRUE)
@ -699,7 +700,7 @@ static void Task_DoDoorWarp(u8 taskId)
ObjectEventClearHeldMovementIfActive(&gObjectEvents[objEventId]);
objEventId = GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0);
ObjectEventSetHeldMovement(&gObjectEvents[objEventId], MOVEMENT_ACTION_WALK_NORMAL_UP);
task->data[0] = 2;
task->tState = 2;
}
break;
case 2:
@ -710,20 +711,20 @@ static void Task_DoDoorWarp(u8 taskId)
objEventId = GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0);
ObjectEventClearHeldMovementIfFinished(&gObjectEvents[objEventId]);
SetPlayerVisibility(FALSE);
task->data[0] = 3;
task->tState = 3;
}
break;
case 3:
if (task->data[1] < 0 || gTasks[task->data[1]].isActive != TRUE)
{
task->data[0] = 4;
task->tState = 4;
}
break;
case 4:
TryFadeOutOldMapMusic();
WarpFadeOutScreen();
PlayRainStoppingSoundEffect();
task->data[0] = 0;
task->tState = 0;
task->func = Task_WarpAndLoadMap;
break;
}
@ -733,17 +734,17 @@ static void Task_DoContestHallWarp(u8 taskId)
{
struct Task *task = &gTasks[taskId];
switch (task->data[0])
switch (task->tState)
{
case 0:
FreezeObjectEvents();
ScriptContext2_Enable();
task->data[0]++;
task->tState++;
break;
case 1:
if (!PaletteFadeActive() && BGMusicStopped())
{
task->data[0]++;
task->tState++;
}
break;
case 2:
@ -850,22 +851,22 @@ static void UpdateFlashLevelEffect(u8 taskId)
{
s16 *data = gTasks[taskId].data;
switch (data[0])
switch (tState)
{
case 0:
SetFlashScanlineEffectWindowBoundaries(gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer], tFlashCenterX, tFlashCenterY, tCurFlashRadius);
data[0] = 1;
tState = 1;
break;
case 1:
SetFlashScanlineEffectWindowBoundaries(gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer], tFlashCenterX, tFlashCenterY, tCurFlashRadius);
data[0] = 0;
tState = 0;
tCurFlashRadius += tFlashRadiusDelta;
if (tCurFlashRadius > tDestFlashRadius)
{
if (tClearScanlineEffect == 1)
{
ScanlineEffect_Stop();
data[0] = 2;
tState = 2;
}
else
{
@ -884,22 +885,22 @@ static void UpdateOrbFlashEffect(u8 taskId)
{
s16 *data = gTasks[taskId].data;
switch (data[0])
switch (tState)
{
case 0:
SetOrbFlashScanlineEffectWindowBoundaries(gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer], tFlashCenterX, tFlashCenterY, tCurFlashRadius);
data[0] = 1;
tState = 1;
break;
case 1:
SetOrbFlashScanlineEffectWindowBoundaries(gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer], tFlashCenterX, tFlashCenterY, tCurFlashRadius);
data[0] = 0;
tState = 0;
tCurFlashRadius += tFlashRadiusDelta;
if (tCurFlashRadius > tDestFlashRadius)
{
if (tClearScanlineEffect == 1)
{
ScanlineEffect_Stop();
data[0] = 2;
tState = 2;
}
else
{
@ -914,7 +915,7 @@ static void UpdateOrbFlashEffect(u8 taskId)
}
}
static void sub_80AFF90(u8 taskId)
static void Task_WaitForFlashUpdate(u8 taskId)
{
if (!FuncIsActiveTask(UpdateFlashLevelEffect))
{
@ -923,13 +924,13 @@ static void sub_80AFF90(u8 taskId)
}
}
static void sub_80AFFB8(void)
static void StartWaitForFlashUpdate(void)
{
if (!FuncIsActiveTask(sub_80AFF90))
CreateTask(sub_80AFF90, 80);
if (!FuncIsActiveTask(Task_WaitForFlashUpdate))
CreateTask(Task_WaitForFlashUpdate, 80);
}
static u8 sub_80AFFDC(s32 centerX, s32 centerY, s32 initialFlashRadius, s32 destFlashRadius, s32 clearScanlineEffect, u8 delta)
static u8 StartUpdateFlashLevelEffect(s32 centerX, s32 centerY, s32 initialFlashRadius, s32 destFlashRadius, s32 clearScanlineEffect, u8 delta)
{
u8 taskId = CreateTask(UpdateFlashLevelEffect, 80);
s16 *data = gTasks[taskId].data;
@ -948,7 +949,7 @@ static u8 sub_80AFFDC(s32 centerX, s32 centerY, s32 initialFlashRadius, s32 dest
return taskId;
}
static u8 sub_80B003C(s32 centerX, s32 centerY, s32 initialFlashRadius, s32 destFlashRadius, s32 clearScanlineEffect, u8 delta)
static u8 StartUpdateOrbFlashEffect(s32 centerX, s32 centerY, s32 initialFlashRadius, s32 destFlashRadius, s32 clearScanlineEffect, u8 delta)
{
u8 taskId = CreateTask(UpdateOrbFlashEffect, 80);
s16 *data = gTasks[taskId].data;
@ -972,14 +973,15 @@ static u8 sub_80B003C(s32 centerX, s32 centerY, s32 initialFlashRadius, s32 dest
#undef tFlashRadiusDelta
#undef tClearScanlineEffect
// A higher flashLevel value is a smaller flash radius (more darkness). 0 is full brightness
void AnimateFlash(u8 flashLevel)
{
u8 curFlashLevel = Overworld_GetFlashLevel();
u8 value = 0;
bool8 fullBrightness = FALSE;
if (!flashLevel)
value = 1;
sub_80AFFDC(DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, sFlashLevelPixelRadii[curFlashLevel], sFlashLevelPixelRadii[flashLevel], value, 1);
sub_80AFFB8();
fullBrightness = TRUE;
StartUpdateFlashLevelEffect(DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, sFlashLevelPixelRadii[curFlashLevel], sFlashLevelPixelRadii[flashLevel], fullBrightness, 1);
StartWaitForFlashUpdate();
ScriptContext2_Enable();
}
@ -998,18 +1000,18 @@ void WriteBattlePyramidViewScanlineEffectBuffer(void)
CpuFastSet(&gScanlineEffectRegBuffers[0], &gScanlineEffectRegBuffers[1], 480);
}
static void Task_TeleportTileWarpExit(u8 taskId)
static void Task_SpinEnterWarp(u8 taskId)
{
switch (gTasks[taskId].data[0])
switch (gTasks[taskId].tState)
{
case 0:
FreezeObjectEvents();
ScriptContext2_Enable();
sub_808D194();
gTasks[taskId].data[0]++;
DoPlayerSpinEntrance();
gTasks[taskId].tState++;
break;
case 1:
if (WaitForWeatherFadeIn() && sub_808D1B4() != TRUE)
if (WaitForWeatherFadeIn() && IsPlayerSpinEntranceActive() != TRUE)
{
UnfreezeObjectEvents();
ScriptContext2_Disable();
@ -1019,29 +1021,29 @@ static void Task_TeleportTileWarpExit(u8 taskId)
}
}
static void sub_80B01BC(u8 taskId)
static void Task_SpinExitWarp(u8 taskId)
{
struct Task *task = &gTasks[taskId];
switch (task->data[0])
switch (task->tState)
{
case 0:
FreezeObjectEvents();
ScriptContext2_Enable();
PlaySE(SE_WARP_IN);
sub_808D1C8();
task->data[0]++;
DoPlayerSpinExit();
task->tState++;
break;
case 1:
if (!sub_808D1E8())
if (!IsPlayerSpinExitActive())
{
WarpFadeOutScreen();
task->data[0]++;
task->tState++;
}
break;
case 2:
if (!PaletteFadeActive() && BGMusicStopped())
task->data[0]++;
task->tState++;
break;
case 3:
WarpIntoMap();
@ -1051,18 +1053,22 @@ static void sub_80B01BC(u8 taskId)
}
}
void sub_80B0244(void)
// Only called by an unused function
// DoTeleportTileWarp is used instead
void DoSpinEnterWarp(void)
{
ScriptContext2_Enable();
CreateTask(Task_WarpAndLoadMap, 10);
gFieldCallback = FieldCB_TeleportTileWarpExit;
gFieldCallback = FieldCB_SpinEnterWarp;
}
void sub_80B0268(void)
// Opposite of DoSpinEnterWarp / DoTeleportTileWarp
// Player exits current map by spinning up offscreen, enters new map with a fade in
void DoSpinExitWarp(void)
{
ScriptContext2_Enable();
gFieldCallback = FieldCB_DefaultWarpExit;
CreateTask(sub_80B01BC, 10);
CreateTask(Task_SpinExitWarp, 10);
}
static void LoadOrbEffectPalette(bool8 blueOrb)
@ -1109,7 +1115,6 @@ static bool8 sub_80B02C8(u16 shakeDir)
return FALSE;
}
#define tState data[0]
#define tBlueOrb data[1]
#define tCenterX data[2]
#define tCenterY data[3]
@ -1148,7 +1153,7 @@ static void Task_OrbEffect(u8 taskId)
case 1:
sub_8199DF0(0, PIXEL_FILL(1), 0, 1);
LoadOrbEffectPalette(tBlueOrb);
sub_80B003C(tCenterX, tCenterY, 1, 160, 1, 2);
StartUpdateOrbFlashEffect(tCenterX, tCenterY, 1, 160, 1, 2);
tState = 2;
break;
case 2:
@ -1243,7 +1248,6 @@ void FadeOutOrbEffect(void)
gTasks[taskId].tState = 6;
}
#undef tState
#undef tBlueOrb
#undef tCenterX
#undef tCenterY

View File

@ -53,7 +53,7 @@ static bool8 ItemfinderCheckForHiddenItems(const struct MapEvents *, u8);
static u8 GetDirectionToHiddenItem(s16 distanceX, s16 distanceY);
static void PlayerFaceHiddenItem(u8 a);
static void CheckForHiddenItemsInMapConnection(u8 taskId);
static void sub_80FDC00(u8 taskId);
static void Task_OpenRegisteredPokeblockCase(u8 taskId);
static void ItemUseOnFieldCB_Bike(u8 taskId);
static void ItemUseOnFieldCB_Rod(u8);
static void ItemUseOnFieldCB_Itemfinder(u8);
@ -69,7 +69,7 @@ static void Task_StartUseRepel(u8 taskId);
static void Task_UseRepel(u8 taskId);
static void Task_CloseCantUseKeyItemMessage(u8 taskId);
static void SetDistanceOfClosestHiddenItem(u8 taskId, s16 x, s16 y);
static void CB2_OpenPokeblockCaseOnField(void);
static void CB2_OpenPokeblockFromBag(void);
// EWRAM variables
EWRAM_DATA static void(*sItemUseOnFieldCB)(u8 taskId) = NULL;
@ -615,23 +615,23 @@ void ItemUseOutOfBattle_PokeblockCase(u8 taskId)
}
else if (gTasks[taskId].tUsingRegisteredKeyItem != TRUE)
{
gBagMenu->exitCallback = CB2_OpenPokeblockCaseOnField;
gBagMenu->exitCallback = CB2_OpenPokeblockFromBag;
Task_FadeAndCloseBagMenu(taskId);
}
else
{
gFieldCallback = sub_80AF6D4;
gFieldCallback = FieldCB_ReturnToFieldNoScript;
FadeScreen(FADE_TO_BLACK, 0);
gTasks[taskId].func = sub_80FDC00;
gTasks[taskId].func = Task_OpenRegisteredPokeblockCase;
}
}
static void CB2_OpenPokeblockCaseOnField(void)
static void CB2_OpenPokeblockFromBag(void)
{
OpenPokeblockCase(PBLOCK_CASE_FIELD, CB2_ReturnToBagMenuPocket);
}
static void sub_80FDC00(u8 taskId)
static void Task_OpenRegisteredPokeblockCase(u8 taskId)
{
if (!gPaletteFade.active)
{

View File

@ -107,7 +107,7 @@ void CB2_EndSafariBattle(void)
{
ScriptContext2_RunNewScript(SafariZone_EventScript_OutOfBallsMidBattle);
WarpIntoMap();
gFieldCallback = sub_80AF6F0;
gFieldCallback = FieldCB_ReturnToFieldNoScriptCheckMusic;
SetMainCallback2(CB2_LoadMap);
}
else if (gBattleOutcome == B_OUTCOME_CAUGHT)

View File

@ -2235,7 +2235,9 @@ bool8 ScrCmd_gotoram(struct ScriptContext *ctx)
return FALSE;
}
bool8 ScrCmd_warpD1(struct ScriptContext *ctx)
// Unused
// For the warp used by the Aqua Hideout, see DoTeleportTileWarp
bool8 ScrCmd_warpspinenter(struct ScriptContext *ctx)
{
u8 mapGroup = ScriptReadByte(ctx);
u8 mapNum = ScriptReadByte(ctx);
@ -2244,8 +2246,8 @@ bool8 ScrCmd_warpD1(struct ScriptContext *ctx)
u16 y = VarGet(ScriptReadHalfword(ctx));
SetWarpDestination(mapGroup, mapNum, warpId, x, y);
sub_808D074(GetPlayerFacingDirection());
sub_80B0244();
SetSpinStartFacingDir(GetPlayerFacingDirection());
DoSpinEnterWarp();
ResetInitialPlayerAvatarState();
return TRUE;
}