diff --git a/data/script_cmd_table.inc b/data/script_cmd_table.inc index 0971358a1..7edb5c4b7 100644 --- a/data/script_cmd_table.inc +++ b/data/script_cmd_table.inc @@ -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 diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index 722fe4444..aa1a2e0dc 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -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); diff --git a/include/field_screen_effect.h b/include/field_screen_effect.h index 951bf0788..deb80f3dd 100644 --- a/include/field_screen_effect.h +++ b/include/field_screen_effect.h @@ -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); diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index fab14c577..a811901a9 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -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) diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index f57cc9979..cc4c03c9d 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -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]; } diff --git a/src/field_screen_effect.c b/src/field_screen_effect.c index dc911f9f7..4676776d1 100644 --- a/src/field_screen_effect.c +++ b/src/field_screen_effect.c @@ -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()) @@ -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 { @@ -999,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(); @@ -1020,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(); @@ -1052,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) @@ -1110,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] @@ -1244,7 +1248,6 @@ void FadeOutOrbEffect(void) gTasks[taskId].tState = 6; } -#undef tState #undef tBlueOrb #undef tCenterX #undef tCenterY diff --git a/src/scrcmd.c b/src/scrcmd.c index ef0b3f86b..f36a44187 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -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; }