Document battle_controller_player.c

This commit is contained in:
GriffinR 2021-01-22 20:03:21 -05:00
parent 4eca05ccf5
commit 63a7828772
25 changed files with 747 additions and 648 deletions

View File

@ -6,4 +6,4 @@ gBattlerControllerFuncs
gHealthboxSpriteIds gHealthboxSpriteIds
gMultiUsePlayerCursor gMultiUsePlayerCursor
gNumberOfMovesToChoose gNumberOfMovesToChoose
gUnknown_03005D7C gBattleControllerData

View File

@ -385,7 +385,7 @@ struct BattleStruct
u8 chosenMovePositions[MAX_BATTLERS_COUNT]; u8 chosenMovePositions[MAX_BATTLERS_COUNT];
u8 stateIdAfterSelScript[MAX_BATTLERS_COUNT]; u8 stateIdAfterSelScript[MAX_BATTLERS_COUNT];
u8 unused_3[3]; u8 unused_3[3];
u8 field_8B; // related to player's pokemon switching u8 prevSelectedPartySlot;
u8 unused_4[2]; u8 unused_4[2];
u8 stringMoveType; u8 stringMoveType;
u8 expGetterBattlerId; u8 expGetterBattlerId;
@ -523,7 +523,7 @@ struct BattleAnimationInfo
u8 field_6; u8 field_6;
u8 field_7; u8 field_7;
u8 ballThrowCaseId; u8 ballThrowCaseId;
u8 field_9_x1:1; u8 introAnimActive:1;
u8 wildMonInvisible:1; u8 wildMonInvisible:1;
u8 field_9_x1C:3; u8 field_9_x1C:3;
u8 field_9_x20:1; u8 field_9_x20:1;
@ -548,17 +548,17 @@ struct BattleHealthboxInfo
u8 triedShinyMonAnim:1; u8 triedShinyMonAnim:1;
u8 finishedShinyMonAnim:1; u8 finishedShinyMonAnim:1;
u8 field_1_x1E:4; u8 field_1_x1E:4;
u8 field_1_x20:1; u8 bgmRestored:1;
u8 field_1_x40:1; u8 waitForCry:1;
u8 field_1_x80:1; u8 healthboxSlideInStarted:1;
u8 healthboxBounceSpriteId; u8 healthboxBounceSpriteId;
u8 battlerBounceSpriteId; u8 battlerBounceSpriteId;
u8 animationState; u8 animationState;
u8 field_5; u8 partyStatusDelayTimer;
u8 matrixNum; u8 matrixNum;
u8 shadowSpriteId; u8 shadowSpriteId;
u8 field_8; u8 soundTimer;
u8 field_9; u8 introEndDelay;
u8 field_A; u8 field_A;
u8 field_B; u8 field_B;
}; };
@ -714,6 +714,6 @@ extern void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(void);
extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT]; extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gMultiUsePlayerCursor; extern u8 gMultiUsePlayerCursor;
extern u8 gNumberOfMovesToChoose; extern u8 gNumberOfMovesToChoose;
extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT]; extern u8 gBattleControllerData[MAX_BATTLERS_COUNT];
#endif // GUARD_BATTLE_H #endif // GUARD_BATTLE_H

View File

@ -246,11 +246,11 @@ void BtlController_EmitEndLinkBattle(u8 bufferId, u8 battleOutcome);
void SetControllerToPlayer(void); void SetControllerToPlayer(void);
void BattleControllerDummy(void); void BattleControllerDummy(void);
void PlayerHandleGetRawMonData(void); void PlayerHandleGetRawMonData(void);
void sub_80587B0(void); void SetBattleEndCallbacks(void);
void sub_805CC00(struct Sprite *sprite); void SpriteCB_FreePlayerSpriteLoadMonSprite(struct Sprite *sprite);
void CB2_SetUpReshowBattleScreenAfterMenu(void); void CB2_SetUpReshowBattleScreenAfterMenu(void);
void CB2_SetUpReshowBattleScreenAfterMenu2(void); void CB2_SetUpReshowBattleScreenAfterMenu2(void);
void c3_0802FDF4(u8 taskId); void Task_PlayerController_RestoreBgmAfterCry(u8 taskId);
void ActionSelectionCreateCursorAt(u8 cursorPos, u8 unused); void ActionSelectionCreateCursorAt(u8 cursorPos, u8 unused);
void ActionSelectionDestroyCursorAt(u8 cursorPos); void ActionSelectionDestroyCursorAt(u8 cursorPos);
void InitMoveSelectionsVarsAndStrings(void); void InitMoveSelectionsVarsAndStrings(void);

View File

@ -4,21 +4,20 @@
void AllocateBattleSpritesData(void); void AllocateBattleSpritesData(void);
void FreeBattleSpritesData(void); void FreeBattleSpritesData(void);
u16 ChooseMoveAndTargetInBattlePalace(void); u16 ChooseMoveAndTargetInBattlePalace(void);
void sub_805D714(struct Sprite *sprite); void SpriteCB_WaitForBattlerBallReleaseAnim(struct Sprite *sprite);
void sub_805D770(struct Sprite *sprite, bool8 arg1); void sub_805D770(struct Sprite *sprite, bool8 arg1);
void sub_805D7AC(struct Sprite *sprite); void SpriteCB_TrainerSlideIn(struct Sprite *sprite);
void InitAndLaunchChosenStatusAnimation(bool8 isStatus2, u32 status); void InitAndLaunchChosenStatusAnimation(bool8 isStatus2, u32 status);
bool8 TryHandleLaunchBattleTableAnimation(u8 activeBattlerId, u8 attacker, u8 target, u8 tableId, u16 argument); bool8 TryHandleLaunchBattleTableAnimation(u8 activeBattlerId, u8 attacker, u8 target, u8 tableId, u16 argument);
void InitAndLaunchSpecialAnimation(u8 activeBattlerId, u8 attacker, u8 target, u8 tableId); void InitAndLaunchSpecialAnimation(u8 activeBattlerId, u8 attacker, u8 target, u8 tableId);
bool8 IsMoveWithoutAnimation(u16 moveId, u8 animationTurn); bool8 IsMoveWithoutAnimation(u16 moveId, u8 animationTurn);
bool8 mplay_80342A4(u8 battlerId); bool8 IsBattleSEPlaying(u8 battlerId);
void BattleLoadOpponentMonSpriteGfx(struct Pokemon *mon, u8 battlerId); void BattleLoadOpponentMonSpriteGfx(struct Pokemon *mon, u8 battlerId);
void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 battlerId); void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 battlerId);
void nullsub_23(void); void BattleGfxSfxDummy2(u16 species);
void nullsub_24(u16 species);
void DecompressTrainerFrontPic(u16 frontPicId, u8 battlerId); void DecompressTrainerFrontPic(u16 frontPicId, u8 battlerId);
void DecompressTrainerBackPic(u16 backPicId, u8 battlerId); void DecompressTrainerBackPic(u16 backPicId, u8 battlerId);
void nullsub_25(u8 arg0); void BattleGfxSfxDummy3(u8 gender);
void FreeTrainerFrontPicPalette(u16 frontPicId); void FreeTrainerFrontPicPalette(u16 frontPicId);
void sub_805DFFC(void); void sub_805DFFC(void);
bool8 BattleLoadAllHealthBoxesGfx(u8 state); bool8 BattleLoadAllHealthBoxesGfx(u8 state);
@ -36,7 +35,7 @@ void HandleLowHpMusicChange(struct Pokemon *mon, u8 battlerId);
void BattleStopLowHpSound(void); void BattleStopLowHpSound(void);
u8 GetMonHPBarLevel(struct Pokemon *mon); u8 GetMonHPBarLevel(struct Pokemon *mon);
void HandleBattleLowHpMusicChange(void); void HandleBattleLowHpMusicChange(void);
void sub_805EB9C(u8 affineMode); void SetBattlerSpriteAffineMode(u8 affineMode);
void LoadAndCreateEnemyShadowSprites(void); void LoadAndCreateEnemyShadowSprites(void);
void SpriteCB_SetInvisible(struct Sprite *sprite); void SpriteCB_SetInvisible(struct Sprite *sprite);
void SetBattlerShadowSpriteCallback(u8 battlerId, u16 species); void SetBattlerShadowSpriteCallback(u8 battlerId, u16 species);

View File

@ -51,7 +51,7 @@ void sub_8038A04(void); // unused
void VBlankCB_Battle(void); void VBlankCB_Battle(void);
void nullsub_17(struct Sprite *sprite); void nullsub_17(struct Sprite *sprite);
void sub_8038B74(struct Sprite *sprite); void sub_8038B74(struct Sprite *sprite);
void sub_8038D64(void); void CB2_InitEndLinkBattle(void);
u32 sub_80391E0(u8 arrayId, u8 caseId); u32 sub_80391E0(u8 arrayId, u8 caseId);
u32 sub_80397C4(u32 setId, u32 tableId); u32 sub_80397C4(u32 setId, u32 tableId);
void SpriteCb_WildMon(struct Sprite *sprite); void SpriteCb_WildMon(struct Sprite *sprite);
@ -62,7 +62,7 @@ void SpriteCb_HideAsMoveTarget(struct Sprite *sprite);
void SpriteCb_OpponentMonFromBall(struct Sprite *sprite); void SpriteCb_OpponentMonFromBall(struct Sprite *sprite);
void sub_8039BB4(struct Sprite *sprite); void sub_8039BB4(struct Sprite *sprite);
void sub_80105DC(struct Sprite *sprite); void sub_80105DC(struct Sprite *sprite);
void sub_8039C00(struct Sprite *sprite); void SpriteCB_FaintSlideAnim(struct Sprite *sprite);
void DoBounceEffect(u8 battlerId, u8 b, s8 c, s8 d); void DoBounceEffect(u8 battlerId, u8 b, s8 c, s8 d);
void EndBounceEffect(u8 battlerId, bool8 b); void EndBounceEffect(u8 battlerId, bool8 b);
void SpriteCb_PlayerMonFromBall(struct Sprite *sprite); void SpriteCb_PlayerMonFromBall(struct Sprite *sprite);

View File

@ -34,7 +34,7 @@ extern const struct SpriteTemplate gBallSpriteTemplates[];
u8 DoPokeballSendOutAnimation(s16 pan, u8 kindOfThrow); u8 DoPokeballSendOutAnimation(s16 pan, u8 kindOfThrow);
void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 battler, u8 x, u8 y, u8 oamPriority, u8 subpriortiy, u8 g, u32 h, u16 species); void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 battler, u8 x, u8 y, u8 oamPriority, u8 subpriortiy, u8 g, u32 h, u16 species);
u8 CreateTradePokeballSprite(u8 a, u8 b, u8 x, u8 y, u8 oamPriority, u8 subPriority, u8 g, u32 h); u8 CreateTradePokeballSprite(u8 a, u8 b, u8 x, u8 y, u8 oamPriority, u8 subPriority, u8 g, u32 h);
void sub_8076918(u8 battler); void StartHealthboxSlideIn(u8 battler);
void DoHitAnimHealthboxEffect(u8 battler); void DoHitAnimHealthboxEffect(u8 battler);
void LoadBallGfx(u8 ballId); void LoadBallGfx(u8 ballId);
void FreeBallGfx(u8 ballId); void FreeBallGfx(u8 ballId);

View File

@ -13,8 +13,8 @@ void sub_8184E58(void);
void RecordedBattle_SetBattlerAction(u8 battlerId, u8 action); void RecordedBattle_SetBattlerAction(u8 battlerId, u8 action);
void RecordedBattle_ClearBattlerAction(u8 battlerId, u8 bytesToClear); void RecordedBattle_ClearBattlerAction(u8 battlerId, u8 bytesToClear);
u8 RecordedBattle_GetBattlerAction(u8 battlerId); u8 RecordedBattle_GetBattlerAction(u8 battlerId);
u8 RecordedBattle_GetAllNewBattlerData(u8 *dst); u8 RecordedBattle_BufferNewBattlerData(u8 *dst);
void sub_81851A8(u8 *arg0); void RecordedBattle_RecordAllBattlerData(u8 *data);
bool32 CanCopyRecordedBattleSaveData(void); bool32 CanCopyRecordedBattleSaveData(void);
bool32 MoveRecordedBattleToSaveData(void); bool32 MoveRecordedBattleToSaveData(void);
void PlayRecordedBattle(void (*CB2_After)(void)); void PlayRecordedBattle(void (*CB2_After)(void));

View File

@ -1,7 +1,7 @@
#ifndef GUARD_RESHOW_BATTLE_SCREEN_H #ifndef GUARD_RESHOW_BATTLE_SCREEN_H
#define GUARD_RESHOW_BATTLE_SCREEN_H #define GUARD_RESHOW_BATTLE_SCREEN_H
void nullsub_35(void); void ReshowBattleScreenDummy(void);
void ReshowBattleScreenAfterMenu(void); void ReshowBattleScreenAfterMenu(void);
#endif // GUARD_RESHOW_BATTLE_SCREEN_H #endif // GUARD_RESHOW_BATTLE_SCREEN_H

View File

@ -2337,7 +2337,7 @@ void AnimTask_AttackerPunchWithTrace(u8 taskId)
task->data[2] = 0; task->data[2] = 0;
task->data[3] = 0; task->data[3] = 0;
gSprites[task->data[0]].pos2.x -= task->data[0]; gSprites[task->data[0]].pos2.x -= task->data[0];
task->data[4] = AllocSpritePalette(10097); task->data[4] = AllocSpritePalette(ANIM_TAG_BENT_SPOON);
task->data[5] = 0; task->data[5] = 0;
dest = (task->data[4] + 0x10) * 0x10; dest = (task->data[4] + 0x10) * 0x10;

View File

@ -100,7 +100,7 @@ static void DoSwitchOutAnimation(void);
static void LinkOpponentDoMoveAnimation(void); static void LinkOpponentDoMoveAnimation(void);
static void sub_8067618(u8 taskId); static void sub_8067618(u8 taskId);
static void sub_80676FC(struct Sprite *sprite); static void sub_80676FC(struct Sprite *sprite);
static void sub_806782C(void); static void EndDrawPartyStatusSummary(void);
static void (*const sLinkOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) = static void (*const sLinkOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
{ {
@ -208,9 +208,9 @@ static void sub_8064470(void)
static void sub_80644D8(void) static void sub_80644D8(void)
{ {
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF) if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
} }
} }
@ -250,8 +250,8 @@ static void sub_8064520(void)
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].triedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].finishedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
} }
else else
{ {
@ -263,12 +263,12 @@ static void sub_8064520(void)
if (GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_RIGHT) if (GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_RIGHT)
{ {
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
} }
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
gBattlerControllerFuncs[gActiveBattler] = sub_80644D8; gBattlerControllerFuncs[gActiveBattler] = sub_80644D8;
} }
} }
@ -294,27 +294,27 @@ static void sub_8064734(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].ballAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].ballAnimActive)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted)
{ {
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)], &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)], &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]], HEALTHBOX_ALL);
sub_8076918(BATTLE_PARTNER(gActiveBattler)); StartHealthboxSlideIn(BATTLE_PARTNER(gActiveBattler));
SetHealthboxSpriteVisible(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]);
} }
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = TRUE;
} }
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x40 if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].waitForCry
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].field_1_x40 && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].waitForCry
&& !IsCryPlayingOrClearCrySongs()) && !IsCryPlayingOrClearCrySongs())
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK)
{ {
@ -327,35 +327,35 @@ static void sub_8064734(void)
} }
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE;
r10 = TRUE; r10 = TRUE;
} }
if (r10) if (r10)
{ {
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_MULTI && GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_RIGHT) if (gBattleTypeFlags & BATTLE_TYPE_MULTI && GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_RIGHT)
{ {
if (++gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 1) if (++gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == 1)
return; return;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
} }
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[BATTLE_PARTNER(gActiveBattler)]]); DestroySprite(&gSprites[gBattleControllerData[BATTLE_PARTNER(gActiveBattler)]]);
SetBattlerShadowSpriteCallback(BATTLE_PARTNER(gActiveBattler), GetMonData(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(BATTLE_PARTNER(gActiveBattler), GetMonData(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]], MON_DATA_SPECIES));
} }
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattleSpritesDataPtr->animationData->field_9_x1 = 0; gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = FALSE;
gBattlerControllerFuncs[gActiveBattler] = sub_8064520; gBattlerControllerFuncs[gActiveBattler] = sub_8064520;
} }
@ -377,8 +377,8 @@ static void sub_8064B04(void)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
} }
} }
@ -479,13 +479,13 @@ static void sub_8064E50(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
CopyBattleSpriteInvisibility(gActiveBattler); CopyBattleSpriteInvisibility(gActiveBattler);
gBattlerControllerFuncs[gActiveBattler] = sub_8064D60; gBattlerControllerFuncs[gActiveBattler] = sub_8064D60;
@ -500,10 +500,10 @@ static void sub_8064F40(void)
TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]); TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
} }
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattlerControllerFuncs[gActiveBattler] = sub_8064E50; gBattlerControllerFuncs[gActiveBattler] = sub_8064E50;
} }
@ -1158,7 +1158,7 @@ static void sub_8066494(u8 battlerId, bool8 dontClearSubstituteBit)
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit); ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1]; gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
@ -1168,8 +1168,8 @@ static void sub_8066494(u8 battlerId, bool8 dontClearSubstituteBit)
GetBattlerSpriteDefault_Y(battlerId), GetBattlerSpriteDefault_Y(battlerId),
GetBattlerSpriteSubpriority(battlerId)); GetBattlerSpriteSubpriority(battlerId));
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId]; gSprites[gBattleControllerData[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId; gSprites[gBattleControllerData[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId; gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species; gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
@ -1180,7 +1180,7 @@ static void sub_8066494(u8 battlerId, bool8 dontClearSubstituteBit)
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE; gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT); gSprites[gBattleControllerData[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT);
} }
static void LinkOpponentHandleReturnMonToBall(void) static void LinkOpponentHandleReturnMonToBall(void)
@ -1221,6 +1221,8 @@ static void DoSwitchOutAnimation(void)
} }
} }
#define sSpeedX data[0]
static void LinkOpponentHandleDrawTrainerPic(void) static void LinkOpponentHandleDrawTrainerPic(void)
{ {
s16 xPos; s16 xPos;
@ -1301,10 +1303,10 @@ static void LinkOpponentHandleDrawTrainerPic(void)
GetBattlerSpriteSubpriority(gActiveBattler)); GetBattlerSpriteSubpriority(gActiveBattler));
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -240;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 2; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 2;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
} }
@ -1324,15 +1326,17 @@ static void LinkOpponentHandleTrainerSlide(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 96; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 96;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.x += 32; gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.x += 32;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2; // this line is redundant, because LinkOpponentBufferExecCompleted changes the battle battlerId function gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2; // this line is redundant, because LinkOpponentBufferExecCompleted changes the battle battlerId function
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
} }
#undef sSpeedX
static void LinkOpponentHandleTrainerSlideBack(void) static void LinkOpponentHandleTrainerSlideBack(void)
{ {
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
@ -1386,7 +1390,7 @@ static void LinkOpponentHandlePause(void)
static void LinkOpponentHandleMoveAnimation(void) static void LinkOpponentHandleMoveAnimation(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8);
@ -1429,7 +1433,7 @@ static void LinkOpponentDoMoveAnimation(void)
case 1: case 1:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{ {
sub_805EB9C(ST_OAM_AFFINE_OFF); SetBattlerSpriteAffineMode(ST_OAM_AFFINE_OFF);
DoMoveAnim(move); DoMoveAnim(move);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2;
} }
@ -1438,7 +1442,7 @@ static void LinkOpponentDoMoveAnimation(void)
gAnimScriptCallback(); gAnimScriptCallback();
if (!gAnimScriptActive) if (!gAnimScriptActive)
{ {
sub_805EB9C(ST_OAM_AFFINE_NORMAL); SetBattlerSpriteAffineMode(ST_OAM_AFFINE_NORMAL);
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
{ {
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
@ -1538,7 +1542,7 @@ static void LinkOpponentHandleExpUpdate(void)
static void LinkOpponentHandleStatusIconUpdate(void) static void LinkOpponentHandleStatusIconUpdate(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
u8 battlerId; u8 battlerId;
@ -1551,7 +1555,7 @@ static void LinkOpponentHandleStatusIconUpdate(void)
static void LinkOpponentHandleStatusAnimation(void) static void LinkOpponentHandleStatusAnimation(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1],
gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24));
@ -1710,7 +1714,7 @@ static void LinkOpponentHandleIntroTrainerBallThrow(void)
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary; gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1; gBattleSpritesDataPtr->animationData->introAnimActive = TRUE;
gBattlerControllerFuncs[gActiveBattler] = nullsub_28; gBattlerControllerFuncs[gActiveBattler] = nullsub_28;
} }
@ -1769,20 +1773,20 @@ static void LinkOpponentHandleDrawPartyStatusSummary(void)
} }
gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0;
if (gBattleBufferA[gActiveBattler][2] != 0) if (gBattleBufferA[gActiveBattler][2] != 0)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 93;
gBattlerControllerFuncs[gActiveBattler] = sub_806782C; gBattlerControllerFuncs[gActiveBattler] = EndDrawPartyStatusSummary;
} }
} }
static void sub_806782C(void) static void EndDrawPartyStatusSummary(void)
{ {
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5++ > 0x5C) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer++ > 92)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0;
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
} }
} }
@ -1811,7 +1815,7 @@ static void LinkOpponentHandleSpriteInvisibility(void)
static void LinkOpponentHandleBattleAnimation(void) static void LinkOpponentHandleBattleAnimation(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
u8 animationId = gBattleBufferA[gActiveBattler][1]; u8 animationId = gBattleBufferA[gActiveBattler][1];
u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8);
@ -1827,7 +1831,7 @@ static void LinkOpponentHandleBattleAnimation(void)
static void LinkOpponentHandleLinkStandbyMsg(void) static void LinkOpponentHandleLinkStandbyMsg(void)
{ {
sub_81851A8(&gBattleBufferA[gActiveBattler][2]); RecordedBattle_RecordAllBattlerData(&gBattleBufferA[gActiveBattler][2]);
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
} }
@ -1838,7 +1842,7 @@ static void LinkOpponentHandleResetActionMoveSelection(void)
static void LinkOpponentHandleEndLinkBattle(void) static void LinkOpponentHandleEndLinkBattle(void)
{ {
sub_81851A8(&gBattleBufferA[gActiveBattler][4]); RecordedBattle_RecordAllBattlerData(&gBattleBufferA[gActiveBattler][4]);
if (gBattleBufferA[gActiveBattler][1] == B_OUTCOME_DREW) if (gBattleBufferA[gActiveBattler][1] == B_OUTCOME_DREW)
gBattleOutcome = gBattleBufferA[gActiveBattler][1]; gBattleOutcome = gBattleBufferA[gActiveBattler][1];
@ -1849,7 +1853,7 @@ static void LinkOpponentHandleEndLinkBattle(void)
FadeOutMapMusic(5); FadeOutMapMusic(5);
BeginFastPaletteFade(3); BeginFastPaletteFade(3);
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
gBattlerControllerFuncs[gActiveBattler] = sub_80587B0; gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks;
} }
static void LinkOpponentCmdEnd(void) static void LinkOpponentCmdEnd(void)

View File

@ -97,7 +97,7 @@ static void sub_814CC98(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void); static void DoSwitchOutAnimation(void);
static void LinkPartnerDoMoveAnimation(void); static void LinkPartnerDoMoveAnimation(void);
static void sub_814DCCC(u8 taskId); static void sub_814DCCC(u8 taskId);
static void sub_814DE9C(void); static void EndDrawPartyStatusSummary(void);
static void (*const sLinkPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) = static void (*const sLinkPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
{ {
@ -190,7 +190,7 @@ static void sub_814AF54(void)
{ {
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
nullsub_25(0); BattleGfxSfxDummy3(MALE);
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
@ -199,9 +199,9 @@ static void sub_814AF54(void)
static void sub_814AFBC(void) static void sub_814AFBC(void)
{ {
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF) if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
} }
} }
@ -229,7 +229,7 @@ static void sub_814B004(void)
if (r6) if (r6)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
gBattlerControllerFuncs[gActiveBattler] = sub_814AFBC; gBattlerControllerFuncs[gActiveBattler] = sub_814AFBC;
} }
} }
@ -238,26 +238,26 @@ static void sub_814B0E8(void)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive
&& gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy && gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& ++gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 != 1) && ++gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay != 1)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler ^ BIT_FLANK]]);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler ^ BIT_FLANK); StartHealthboxSlideIn(gActiveBattler ^ BIT_FLANK);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]);
} }
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattleSpritesDataPtr->animationData->field_9_x1 = 0; gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
gBattlerControllerFuncs[gActiveBattler] = sub_814B004; gBattlerControllerFuncs[gActiveBattler] = sub_814B004;
} }
@ -286,13 +286,13 @@ static void CompleteOnHealthbarDone(void)
} }
} }
static void sub_814B340(void) static void FreeMonSpriteAfterFaintAnim(void)
{ {
if (gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y + gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.y > DISPLAY_HEIGHT) if (gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y + gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.y > DISPLAY_HEIGHT)
{ {
u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES); u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
nullsub_24(species); BattleGfxSfxDummy2(species);
FreeOamMatrix(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.matrixNum); FreeOamMatrix(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.matrixNum);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
@ -364,14 +364,14 @@ static void sub_814B5A8(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
CreateTask(c3_0802FDF4, 10); CreateTask(Task_PlayerController_RestoreBgmAfterCry, 10);
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattlerControllerFuncs[gActiveBattler] = sub_814B4E0; gBattlerControllerFuncs[gActiveBattler] = sub_814B4E0;
@ -386,10 +386,10 @@ static void sub_814B69C(void)
TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]); TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
} }
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
gBattlerControllerFuncs[gActiveBattler] = sub_814B5A8; gBattlerControllerFuncs[gActiveBattler] = sub_814B5A8;
} }
} }
@ -1044,7 +1044,7 @@ static void sub_814CC98(u8 battlerId, bool8 dontClearSubstituteBit)
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit); ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1]; gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[battlerId] = CreateSprite( gBattlerSpriteIds[battlerId] = CreateSprite(
@ -1053,8 +1053,8 @@ static void sub_814CC98(u8 battlerId, bool8 dontClearSubstituteBit)
GetBattlerSpriteDefault_Y(battlerId), GetBattlerSpriteDefault_Y(battlerId),
GetBattlerSpriteSubpriority(battlerId)); GetBattlerSpriteSubpriority(battlerId));
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId]; gSprites[gBattleControllerData[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId; gSprites[gBattleControllerData[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId; gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species; gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
@ -1065,7 +1065,7 @@ static void sub_814CC98(u8 battlerId, bool8 dontClearSubstituteBit)
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE; gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT); gSprites[gBattleControllerData[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
} }
static void LinkPartnerHandleReturnMonToBall(void) static void LinkPartnerHandleReturnMonToBall(void)
@ -1105,6 +1105,8 @@ static void DoSwitchOutAnimation(void)
} }
} }
#define sSpeedX data[0]
static void LinkPartnerHandleDrawTrainerPic(void) static void LinkPartnerHandleDrawTrainerPic(void)
{ {
s16 xPos; s16 xPos;
@ -1142,13 +1144,15 @@ static void LinkPartnerHandleDrawTrainerPic(void)
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, (8 - gTrainerBackPicCoords[trainerPicId].size) * 4 + 80, GetBattlerSpriteSubpriority(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, (8 - gTrainerBackPicCoords[trainerPicId].size) * 4 + 80, GetBattlerSpriteSubpriority(gActiveBattler));
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
} }
#undef sSpeedX
static void LinkPartnerHandleTrainerSlide(void) static void LinkPartnerHandleTrainerSlide(void)
{ {
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
@ -1165,6 +1169,9 @@ static void LinkPartnerHandleTrainerSlideBack(void)
gBattlerControllerFuncs[gActiveBattler] = sub_814AF54; gBattlerControllerFuncs[gActiveBattler] = sub_814AF54;
} }
#define sSpeedX data[1]
#define sSpeedY data[2]
static void LinkPartnerHandleFaintAnimation(void) static void LinkPartnerHandleFaintAnimation(void)
{ {
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0)
@ -1180,14 +1187,17 @@ static void LinkPartnerHandleFaintAnimation(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
PlaySE12WithPanning(SE_FAINT, SOUND_PAN_ATTACKER); PlaySE12WithPanning(SE_FAINT, SOUND_PAN_ATTACKER);
gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 0;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 5; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedY = 5;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_8039C00; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_FaintSlideAnim;
gBattlerControllerFuncs[gActiveBattler] = sub_814B340; gBattlerControllerFuncs[gActiveBattler] = FreeMonSpriteAfterFaintAnim;
} }
} }
} }
#undef sSpeedX
#undef sSpeedY
static void LinkPartnerHandlePaletteFade(void) static void LinkPartnerHandlePaletteFade(void)
{ {
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
@ -1210,7 +1220,7 @@ static void LinkPartnerHandlePause(void)
static void LinkPartnerHandleMoveAnimation(void) static void LinkPartnerHandleMoveAnimation(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8);
@ -1253,7 +1263,7 @@ static void LinkPartnerDoMoveAnimation(void)
case 1: case 1:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{ {
sub_805EB9C(ST_OAM_AFFINE_OFF); SetBattlerSpriteAffineMode(ST_OAM_AFFINE_OFF);
DoMoveAnim(move); DoMoveAnim(move);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2;
} }
@ -1262,7 +1272,7 @@ static void LinkPartnerDoMoveAnimation(void)
gAnimScriptCallback(); gAnimScriptCallback();
if (!gAnimScriptActive) if (!gAnimScriptActive)
{ {
sub_805EB9C(ST_OAM_AFFINE_NORMAL); SetBattlerSpriteAffineMode(ST_OAM_AFFINE_NORMAL);
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
{ {
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
@ -1362,7 +1372,7 @@ static void LinkPartnerHandleExpUpdate(void)
static void LinkPartnerHandleStatusIconUpdate(void) static void LinkPartnerHandleStatusIconUpdate(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
u8 battlerId; u8 battlerId;
@ -1375,7 +1385,7 @@ static void LinkPartnerHandleStatusIconUpdate(void)
static void LinkPartnerHandleStatusAnimation(void) static void LinkPartnerHandleStatusAnimation(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1],
gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24));
@ -1529,7 +1539,7 @@ static void LinkPartnerHandleIntroTrainerBallThrow(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gActiveBattler;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_805CC00); StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCB_FreePlayerSpriteLoadMonSprite);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1);
paletteNum = AllocSpritePalette(0xD6F9); paletteNum = AllocSpritePalette(0xD6F9);
@ -1559,7 +1569,7 @@ static void LinkPartnerHandleIntroTrainerBallThrow(void)
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary; gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1; gBattleSpritesDataPtr->animationData->introAnimActive = TRUE;
gBattlerControllerFuncs[gActiveBattler] = SpriteCB_Null2; gBattlerControllerFuncs[gActiveBattler] = SpriteCB_Null2;
} }
@ -1605,20 +1615,20 @@ static void LinkPartnerHandleDrawPartyStatusSummary(void)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1;
gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0;
if (gBattleBufferA[gActiveBattler][2] != 0) if (gBattleBufferA[gActiveBattler][2] != 0)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 93;
gBattlerControllerFuncs[gActiveBattler] = sub_814DE9C; gBattlerControllerFuncs[gActiveBattler] = EndDrawPartyStatusSummary;
} }
} }
static void sub_814DE9C(void) static void EndDrawPartyStatusSummary(void)
{ {
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5++ > 0x5C) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer++ > 92)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0;
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
} }
} }
@ -1647,7 +1657,7 @@ static void LinkPartnerHandleSpriteInvisibility(void)
static void LinkPartnerHandleBattleAnimation(void) static void LinkPartnerHandleBattleAnimation(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
u8 animationId = gBattleBufferA[gActiveBattler][1]; u8 animationId = gBattleBufferA[gActiveBattler][1];
u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8);
@ -1663,7 +1673,7 @@ static void LinkPartnerHandleBattleAnimation(void)
static void LinkPartnerHandleLinkStandbyMsg(void) static void LinkPartnerHandleLinkStandbyMsg(void)
{ {
sub_81851A8(&gBattleBufferA[gActiveBattler][2]); RecordedBattle_RecordAllBattlerData(&gBattleBufferA[gActiveBattler][2]);
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
} }
@ -1674,13 +1684,13 @@ static void LinkPartnerHandleResetActionMoveSelection(void)
static void LinkPartnerHandleEndLinkBattle(void) static void LinkPartnerHandleEndLinkBattle(void)
{ {
sub_81851A8(&gBattleBufferA[gActiveBattler][4]); RecordedBattle_RecordAllBattlerData(&gBattleBufferA[gActiveBattler][4]);
gBattleOutcome = gBattleBufferA[gActiveBattler][1]; gBattleOutcome = gBattleBufferA[gActiveBattler][1];
gSaveBlock2Ptr->frontier.disableRecordBattle = gBattleBufferA[gActiveBattler][2]; gSaveBlock2Ptr->frontier.disableRecordBattle = gBattleBufferA[gActiveBattler][2];
FadeOutMapMusic(5); FadeOutMapMusic(5);
BeginFastPaletteFade(3); BeginFastPaletteFade(3);
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
gBattlerControllerFuncs[gActiveBattler] = sub_80587B0; gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks;
} }
static void LinkPartnerCmdEnd(void) static void LinkPartnerCmdEnd(void)

View File

@ -105,7 +105,7 @@ static void DoSwitchOutAnimation(void);
static void OpponentDoMoveAnimation(void); static void OpponentDoMoveAnimation(void);
static void sub_806280C(struct Sprite *sprite); static void sub_806280C(struct Sprite *sprite);
static void sub_8062828(u8 taskId); static void sub_8062828(u8 taskId);
static void sub_8062A2C(void); static void EndDrawPartyStatusSummary(void);
static void (*const sOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) = static void (*const sOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
{ {
@ -216,9 +216,9 @@ static void sub_805F240(void)
static void sub_805F2A8(void) static void sub_805F2A8(void)
{ {
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF) if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
} }
} }
@ -256,8 +256,8 @@ static void sub_805F2F0(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
} }
else else
return; return;
@ -269,8 +269,8 @@ static void sub_805F2F0(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim)
{ {
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
} }
else else
return; return;
@ -281,7 +281,7 @@ static void sub_805F2F0(void)
else else
return; return;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
gBattlerControllerFuncs[gActiveBattler] = sub_805F2A8; gBattlerControllerFuncs[gActiveBattler] = sub_805F2A8;
} }
} }
@ -306,27 +306,27 @@ static void sub_805F560(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted)
{ {
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler ^ BIT_FLANK); StartHealthboxSlideIn(gActiveBattler ^ BIT_FLANK);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]);
} }
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = TRUE;
} }
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x40 if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].waitForCry
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x40 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].waitForCry
&& !IsCryPlayingOrClearCrySongs()) && !IsCryPlayingOrClearCrySongs())
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK)
{ {
@ -336,13 +336,13 @@ static void sub_805F560(void)
else else
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100); m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE;
sp = TRUE; sp = TRUE;
} }
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
{ {
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
r10 = TRUE; r10 = TRUE;
@ -350,9 +350,9 @@ static void sub_805F560(void)
} }
else else
{ {
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy && gSprites[gBattleControllerData[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
{ {
r10 = TRUE; r10 = TRUE;
@ -363,15 +363,15 @@ static void sub_805F560(void)
{ {
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler ^ BIT_FLANK]]);
SetBattlerShadowSpriteCallback(gActiveBattler ^ BIT_FLANK, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(gActiveBattler ^ BIT_FLANK, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], MON_DATA_SPECIES));
} }
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattleSpritesDataPtr->animationData->field_9_x1 = 0; gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = FALSE;
gBattlerControllerFuncs[gActiveBattler] = sub_805F2F0; gBattlerControllerFuncs[gActiveBattler] = sub_805F2F0;
} }
@ -389,8 +389,8 @@ static void sub_805F994(void)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
} }
} }
@ -482,11 +482,11 @@ static void sub_805FD00(void)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
CopyBattleSpriteInvisibility(gActiveBattler); CopyBattleSpriteInvisibility(gActiveBattler);
gBattlerControllerFuncs[gActiveBattler] = sub_805FC10; gBattlerControllerFuncs[gActiveBattler] = sub_805FC10;
@ -499,10 +499,10 @@ static void sub_805FDF0(void)
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]); TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattlerControllerFuncs[gActiveBattler] = sub_805FD00; gBattlerControllerFuncs[gActiveBattler] = sub_805FD00;
} }
@ -1168,7 +1168,7 @@ static void sub_80613DC(u8 battlerId, bool8 dontClearSubstituteBit)
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit); ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1]; gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
@ -1180,8 +1180,8 @@ static void sub_80613DC(u8 battlerId, bool8 dontClearSubstituteBit)
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId; gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species; gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId]; gSprites[gBattleControllerData[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId; gSprites[gBattleControllerData[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId; gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
@ -1190,7 +1190,7 @@ static void sub_80613DC(u8 battlerId, bool8 dontClearSubstituteBit)
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE; gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT); gSprites[gBattleControllerData[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT);
} }
static void OpponentHandleReturnMonToBall(void) static void OpponentHandleReturnMonToBall(void)
@ -1231,6 +1231,8 @@ static void DoSwitchOutAnimation(void)
} }
} }
#define sSpeedX data[0]
static void OpponentHandleDrawTrainerPic(void) static void OpponentHandleDrawTrainerPic(void)
{ {
u32 trainerPicId; u32 trainerPicId;
@ -1308,10 +1310,10 @@ static void OpponentHandleDrawTrainerPic(void)
GetBattlerSpriteSubpriority(gActiveBattler)); GetBattlerSpriteSubpriority(gActiveBattler));
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -240;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 2; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 2;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
} }
@ -1378,14 +1380,16 @@ static void OpponentHandleTrainerSlide(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 96; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 96;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.x += 32; gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.x += 32;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2;
} }
#undef sSpeedX
static void OpponentHandleTrainerSlideBack(void) static void OpponentHandleTrainerSlideBack(void)
{ {
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
@ -1439,7 +1443,7 @@ static void OpponentHandlePause(void)
static void OpponentHandleMoveAnimation(void) static void OpponentHandleMoveAnimation(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8);
@ -1481,7 +1485,7 @@ static void OpponentDoMoveAnimation(void)
case 1: case 1:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{ {
sub_805EB9C(ST_OAM_AFFINE_OFF); SetBattlerSpriteAffineMode(ST_OAM_AFFINE_OFF);
DoMoveAnim(move); DoMoveAnim(move);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2;
} }
@ -1490,7 +1494,7 @@ static void OpponentDoMoveAnimation(void)
gAnimScriptCallback(); gAnimScriptCallback();
if (!gAnimScriptActive) if (!gAnimScriptActive)
{ {
sub_805EB9C(ST_OAM_AFFINE_NORMAL); SetBattlerSpriteAffineMode(ST_OAM_AFFINE_NORMAL);
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
{ {
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
@ -1703,7 +1707,7 @@ static void OpponentHandleExpUpdate(void)
static void OpponentHandleStatusIconUpdate(void) static void OpponentHandleStatusIconUpdate(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
u8 battlerId; u8 battlerId;
@ -1716,7 +1720,7 @@ static void OpponentHandleStatusIconUpdate(void)
static void OpponentHandleStatusAnimation(void) static void OpponentHandleStatusAnimation(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1],
gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24));
@ -1875,7 +1879,7 @@ static void OpponentHandleIntroTrainerBallThrow(void)
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary; gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1; gBattleSpritesDataPtr->animationData->introAnimActive = TRUE;
gBattlerControllerFuncs[gActiveBattler] = nullsub_26; gBattlerControllerFuncs[gActiveBattler] = nullsub_26;
} }
@ -1939,20 +1943,20 @@ static void OpponentHandleDrawPartyStatusSummary(void)
} }
gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0;
if (gBattleBufferA[gActiveBattler][2] != 0) if (gBattleBufferA[gActiveBattler][2] != 0)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 93;
gBattlerControllerFuncs[gActiveBattler] = sub_8062A2C; gBattlerControllerFuncs[gActiveBattler] = EndDrawPartyStatusSummary;
} }
} }
static void sub_8062A2C(void) static void EndDrawPartyStatusSummary(void)
{ {
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5++ > 0x5C) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer++ > 92)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0;
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
} }
} }
@ -1981,7 +1985,7 @@ static void OpponentHandleSpriteInvisibility(void)
static void OpponentHandleBattleAnimation(void) static void OpponentHandleBattleAnimation(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
u8 animationId = gBattleBufferA[gActiveBattler][1]; u8 animationId = gBattleBufferA[gActiveBattler][1];
u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8);

View File

@ -106,22 +106,22 @@ static void MoveSelectionDisplayPpString(void);
static void MoveSelectionDisplayMoveType(void); static void MoveSelectionDisplayMoveType(void);
static void MoveSelectionDisplayMoveNames(void); static void MoveSelectionDisplayMoveNames(void);
static void HandleMoveSwitching(void); static void HandleMoveSwitching(void);
static void sub_8058FC0(void); static void SwitchIn_HandleSoundAndEnd(void);
static void WaitForMonSelection(void); static void WaitForMonSelection(void);
static void CompleteWhenChoseItem(void); static void CompleteWhenChoseItem(void);
static void Task_LaunchLvlUpAnim(u8 taskId); static void Task_LaunchLvlUpAnim(u8 taskId);
static void Task_PrepareToGiveExpWithExpBar(u8 taskId); static void Task_PrepareToGiveExpWithExpBar(u8 taskId);
static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8 taskId); static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8 taskId);
static void sub_8059400(u8 taskId); static void Task_GiveExpWithExpBar(u8 taskId);
static void Task_UpdateLvlInHealthbox(u8 taskId); static void Task_UpdateLvlInHealthbox(u8 taskId);
static void PrintLinkStandbyMsg(void); static void PrintLinkStandbyMsg(void);
static u32 CopyPlayerMonData(u8 monId, u8 *dst); static u32 CopyPlayerMonData(u8 monId, u8 *dst);
static void SetPlayerMonData(u8 monId); static void SetPlayerMonData(u8 monId);
static void sub_805B258(u8 battlerId, bool8 dontClearSubstituteBit); static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void); static void DoSwitchOutAnimation(void);
static void PlayerDoMoveAnimation(void); static void PlayerDoMoveAnimation(void);
static void task05_08033660(u8 taskId); static void Task_StartSendOutAnim(u8 taskId);
static void sub_805CE38(void); static void EndDrawPartyStatusSummary(void);
static void (*const sPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) = static void (*const sPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
{ {
@ -184,7 +184,7 @@ static void (*const sPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
[CONTROLLER_TERMINATOR_NOP] = PlayerCmdEnd [CONTROLLER_TERMINATOR_NOP] = PlayerCmdEnd
}; };
static const u8 sTargetIdentities[] = {B_POSITION_PLAYER_LEFT, B_POSITION_PLAYER_RIGHT, B_POSITION_OPPONENT_RIGHT, B_POSITION_OPPONENT_LEFT}; static const u8 sTargetIdentities[MAX_BATTLERS_COUNT] = {B_POSITION_PLAYER_LEFT, B_POSITION_PLAYER_RIGHT, B_POSITION_OPPONENT_RIGHT, B_POSITION_OPPONENT_LEFT};
// unknown unused data // unknown unused data
static const u8 sUnused[] = {0x48, 0x48, 0x20, 0x5a, 0x50, 0x50, 0x50, 0x58}; static const u8 sUnused[] = {0x48, 0x48, 0x20, 0x5a, 0x50, 0x50, 0x50, 0x58};
@ -332,7 +332,7 @@ static void HandleInputChooseAction(void)
} }
} }
static void sub_80577F0(void) // unused static void UnusedEndBounceEffect(void)
{ {
EndBounceEffect(gActiveBattler, BOUNCE_HEALTHBOX); EndBounceEffect(gActiveBattler, BOUNCE_HEALTHBOX);
EndBounceEffect(gActiveBattler, BOUNCE_MON); EndBounceEffect(gActiveBattler, BOUNCE_MON);
@ -342,7 +342,7 @@ static void sub_80577F0(void) // unused
static void HandleInputChooseTarget(void) static void HandleInputChooseTarget(void)
{ {
s32 i; s32 i;
u8 identities[4]; u8 identities[MAX_BATTLERS_COUNT];
memcpy(identities, sTargetIdentities, ARRAY_COUNT(sTargetIdentities)); memcpy(identities, sTargetIdentities, ARRAY_COUNT(sTargetIdentities));
DoBounceEffect(gMultiUsePlayerCursor, BOUNCE_HEALTHBOX, 15, 1); DoBounceEffect(gMultiUsePlayerCursor, BOUNCE_HEALTHBOX, 15, 1);
@ -398,7 +398,11 @@ static void HandleInputChooseTarget(void)
do do
{ {
if (--i < 0) if (--i < 0)
#ifdef UBFIX
i = MAX_BATTLERS_COUNT - 1;
#else
i = MAX_BATTLERS_COUNT; // UB: array out of range i = MAX_BATTLERS_COUNT; // UB: array out of range
#endif
gMultiUsePlayerCursor = GetBattlerAtPosition(identities[i]); gMultiUsePlayerCursor = GetBattlerAtPosition(identities[i]);
} while (gMultiUsePlayerCursor == gBattlersCount); } while (gMultiUsePlayerCursor == gBattlersCount);
@ -613,7 +617,7 @@ static void HandleInputChooseMove(void)
} }
} }
u32 sub_8057FBC(void) // unused static u32 HandleMoveInputUnused(void)
{ {
u32 var = 0; u32 var = 0;
@ -847,7 +851,7 @@ static void HandleMoveSwitching(void)
} }
} }
static void sub_80586F8(void) static void SetLinkBattleEndCallbacks(void)
{ {
if (gWirelessCommType == 0) if (gWirelessCommType == 0)
{ {
@ -856,7 +860,7 @@ static void sub_80586F8(void)
m4aSongNumStop(SE_LOW_HEALTH); m4aSongNumStop(SE_LOW_HEALTH);
gMain.inBattle = 0; gMain.inBattle = 0;
gMain.callback1 = gPreBattleCallback1; gMain.callback1 = gPreBattleCallback1;
SetMainCallback2(sub_8038D64); SetMainCallback2(CB2_InitEndLinkBattle);
if (gBattleOutcome == B_OUTCOME_WON) if (gBattleOutcome == B_OUTCOME_WON)
TryPutLinkBattleTvShowOnAir(); TryPutLinkBattleTvShowOnAir();
FreeAllWindowBuffers(); FreeAllWindowBuffers();
@ -869,7 +873,7 @@ static void sub_80586F8(void)
m4aSongNumStop(SE_LOW_HEALTH); m4aSongNumStop(SE_LOW_HEALTH);
gMain.inBattle = 0; gMain.inBattle = 0;
gMain.callback1 = gPreBattleCallback1; gMain.callback1 = gPreBattleCallback1;
SetMainCallback2(sub_8038D64); SetMainCallback2(CB2_InitEndLinkBattle);
if (gBattleOutcome == B_OUTCOME_WON) if (gBattleOutcome == B_OUTCOME_WON)
TryPutLinkBattleTvShowOnAir(); TryPutLinkBattleTvShowOnAir();
FreeAllWindowBuffers(); FreeAllWindowBuffers();
@ -877,7 +881,8 @@ static void sub_80586F8(void)
} }
} }
void sub_80587B0(void) // Despite handling link battles separately, this is only ever used by link battles
void SetBattleEndCallbacks(void)
{ {
if (!gPaletteFade.active) if (!gPaletteFade.active)
{ {
@ -890,7 +895,7 @@ void sub_80587B0(void)
else else
SetLinkStandbyCallback(); SetLinkStandbyCallback();
gBattlerControllerFuncs[gActiveBattler] = sub_80586F8; gBattlerControllerFuncs[gActiveBattler] = SetLinkBattleEndCallbacks;
} }
} }
else else
@ -915,161 +920,174 @@ static void CompleteOnBankSpriteCallbackDummy2(void)
PlayerBufferExecCompleted(); PlayerBufferExecCompleted();
} }
static void sub_80588B4(void) static void FreeTrainerSpriteAfterSlide(void)
{ {
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
nullsub_25(gSaveBlock2Ptr->playerGender); BattleGfxSfxDummy3(gSaveBlock2Ptr->playerGender);
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
PlayerBufferExecCompleted(); PlayerBufferExecCompleted();
} }
} }
static void sub_8058924(void) static void Intro_DelayAndEnd(void)
{ {
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF) if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
PlayerBufferExecCompleted(); PlayerBufferExecCompleted();
} }
} }
static void sub_805896C(void) static void Intro_WaitForShinyAnimAndHealthbox(void)
{ {
bool8 var = FALSE; bool8 healthboxAnimDone = FALSE;
// Check if healthbox has finished sliding in
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
{ {
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
var = TRUE; healthboxAnimDone = TRUE;
} }
else else
{ {
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) && gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
var = TRUE; healthboxAnimDone = TRUE;
} }
if (var && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim // If healthbox and shiny anim are done
if (healthboxAnimDone && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim) && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim)
{ {
// Reset shiny anim (even if it didn't occur)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
if (IsDoubleBattle()) if (IsDoubleBattle())
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], gActiveBattler ^ BIT_FLANK); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], gActiveBattler ^ BIT_FLANK);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
gBattlerControllerFuncs[gActiveBattler] = sub_8058924; gBattlerControllerFuncs[gActiveBattler] = Intro_DelayAndEnd;
} }
} }
static void sub_8058B40(void) static void Intro_TryShinyAnimShowHealthbox(void)
{ {
bool32 r9 = FALSE; bool32 bgmRestored = FALSE;
bool32 r8 = FALSE; bool32 battlerAnimsDone = FALSE;
// Start shiny animation if applicable for 1st pokemon
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]); TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
// Start shiny animation if applicable for 2nd pokemon
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive)
TryShinyAnimation(gActiveBattler ^ BIT_FLANK, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]]); TryShinyAnimation(gActiveBattler ^ BIT_FLANK, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]]);
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) // Show healthbox after ball anim
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted)
{ {
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler ^ BIT_FLANK); StartHealthboxSlideIn(gActiveBattler ^ BIT_FLANK);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]);
} }
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = TRUE;
} }
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x40 // Restore bgm after cry has played and healthbox anim is started
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].waitForCry
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x40 && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].waitForCry
&& !IsCryPlayingOrClearCrySongs()) && !IsCryPlayingOrClearCrySongs())
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK)
m4aMPlayContinue(&gMPlayInfo_BGM); m4aMPlayContinue(&gMPlayInfo_BGM);
else else
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100); m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE;
r9 = TRUE; bgmRestored = TRUE;
} }
// Wait for battler anims
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
{ {
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
r8 = TRUE; battlerAnimsDone = TRUE;
} }
} }
else else
{ {
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy && gSprites[gBattleControllerData[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
{ {
r8 = TRUE; battlerAnimsDone = TRUE;
} }
} }
if (r9 && r8) // Clean up
if (bgmRestored && battlerAnimsDone)
{ {
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler ^ BIT_FLANK]]);
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
gBattleSpritesDataPtr->animationData->field_9_x1 = 0; gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = FALSE;
gBattlerControllerFuncs[gActiveBattler] = sub_805896C; gBattlerControllerFuncs[gActiveBattler] = Intro_WaitForShinyAnimAndHealthbox;
} }
} }
static void sub_8058EDC(void) static void SwitchIn_CleanShinyAnimShowSubstitute(void)
{ {
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
CopyBattleSpriteInvisibility(gActiveBattler); CopyBattleSpriteInvisibility(gActiveBattler);
// Reset shiny anim (even if it didn't occur)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
// Check if Substitute should be shown
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattlerControllerFuncs[gActiveBattler] = sub_8058FC0; gBattlerControllerFuncs[gActiveBattler] = SwitchIn_HandleSoundAndEnd;
} }
} }
static void sub_8058FC0(void) static void SwitchIn_HandleSoundAndEnd(void)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive
&& !IsCryPlayingOrClearCrySongs()) && !IsCryPlayingOrClearCrySongs())
@ -1080,24 +1098,26 @@ static void sub_8058FC0(void)
} }
} }
static void sub_805902C(void) static void SwitchIn_TryShinyAnimShowHealthbox(void)
{ {
// Start shiny animation if applicable
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]); TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy // Wait for ball anim, then show healthbox
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattlerControllerFuncs[gActiveBattler] = sub_8058EDC; gBattlerControllerFuncs[gActiveBattler] = SwitchIn_CleanShinyAnimShowSubstitute;
} }
} }
void c3_0802FDF4(u8 taskId) void Task_PlayerController_RestoreBgmAfterCry(u8 taskId)
{ {
if (!IsCryPlayingOrClearCrySongs()) if (!IsCryPlayingOrClearCrySongs())
{ {
@ -1196,10 +1216,10 @@ static void Task_PrepareToGiveExpWithExpBar(u8 taskId)
expToNextLvl = gExperienceTables[gBaseStats[species].growthRate][level + 1] - currLvlExp; expToNextLvl = gExperienceTables[gBaseStats[species].growthRate][level + 1] - currLvlExp;
SetBattleBarStruct(battlerId, gHealthboxSpriteIds[battlerId], expToNextLvl, exp, -gainedExp); SetBattleBarStruct(battlerId, gHealthboxSpriteIds[battlerId], expToNextLvl, exp, -gainedExp);
PlaySE(SE_EXP); PlaySE(SE_EXP);
gTasks[taskId].func = sub_8059400; gTasks[taskId].func = Task_GiveExpWithExpBar;
} }
static void sub_8059400(u8 taskId) static void Task_GiveExpWithExpBar(u8 taskId)
{ {
if (gTasks[taskId].tExpTask_frames < 13) if (gTasks[taskId].tExpTask_frames < 13)
{ {
@ -1294,13 +1314,13 @@ static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8 taskId)
DestroyTask(taskId); DestroyTask(taskId);
} }
static void sub_80596A8(void) static void FreeMonSpriteAfterFaintAnim(void)
{ {
if (gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y + gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.y > DISPLAY_HEIGHT) if (gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y + gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.y > DISPLAY_HEIGHT)
{ {
u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES); u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
nullsub_24(species); BattleGfxSfxDummy2(species);
FreeOamMatrix(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.matrixNum); FreeOamMatrix(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.matrixNum);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
@ -1308,7 +1328,7 @@ static void sub_80596A8(void)
} }
} }
static void sub_8059744(void) static void FreeMonSpriteAfterSwitchOutAnim(void)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{ {
@ -1332,8 +1352,8 @@ static void OpenPartyMenuToChooseMon(void)
u8 caseId; u8 caseId;
gBattlerControllerFuncs[gActiveBattler] = WaitForMonSelection; gBattlerControllerFuncs[gActiveBattler] = WaitForMonSelection;
caseId = gTasks[gUnknown_03005D7C[gActiveBattler]].data[0]; caseId = gTasks[gBattleControllerData[gActiveBattler]].data[0];
DestroyTask(gUnknown_03005D7C[gActiveBattler]); DestroyTask(gBattleControllerData[gActiveBattler]);
FreeAllWindowBuffers(); FreeAllWindowBuffers();
OpenPartyMenuInBattle(caseId); OpenPartyMenuInBattle(caseId);
} }
@ -1360,7 +1380,7 @@ static void OpenBagAndChooseItem(void)
if (!gPaletteFade.active) if (!gPaletteFade.active)
{ {
gBattlerControllerFuncs[gActiveBattler] = CompleteWhenChoseItem; gBattlerControllerFuncs[gActiveBattler] = CompleteWhenChoseItem;
nullsub_35(); ReshowBattleScreenDummy();
FreeAllWindowBuffers(); FreeAllWindowBuffers();
CB2_BagMenuFromBattle(); CB2_BagMenuFromBattle();
} }
@ -2171,18 +2191,18 @@ static void PlayerHandleSwitchInAnim(void)
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
gActionSelectionCursor[gActiveBattler] = 0; gActionSelectionCursor[gActiveBattler] = 0;
gMoveSelectionCursor[gActiveBattler] = 0; gMoveSelectionCursor[gActiveBattler] = 0;
sub_805B258(gActiveBattler, gBattleBufferA[gActiveBattler][2]); StartSendOutAnim(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = sub_805902C; gBattlerControllerFuncs[gActiveBattler] = SwitchIn_TryShinyAnimShowHealthbox;
} }
static void sub_805B258(u8 battlerId, bool8 dontClearSubstituteBit) static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit)
{ {
u16 species; u16 species;
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit); ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1]; gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[battlerId] = CreateSprite( gBattlerSpriteIds[battlerId] = CreateSprite(
@ -2191,8 +2211,8 @@ static void sub_805B258(u8 battlerId, bool8 dontClearSubstituteBit)
GetBattlerSpriteDefault_Y(battlerId), GetBattlerSpriteDefault_Y(battlerId),
GetBattlerSpriteSubpriority(battlerId)); GetBattlerSpriteSubpriority(battlerId));
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId]; gSprites[gBattleControllerData[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId; gSprites[gBattleControllerData[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId; gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species; gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
@ -2203,7 +2223,7 @@ static void sub_805B258(u8 battlerId, bool8 dontClearSubstituteBit)
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE; gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT); gSprites[gBattleControllerData[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
} }
static void PlayerHandleReturnMonToBall(void) static void PlayerHandleReturnMonToBall(void)
@ -2237,12 +2257,14 @@ static void DoSwitchOutAnimation(void)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON);
gBattlerControllerFuncs[gActiveBattler] = sub_8059744; gBattlerControllerFuncs[gActiveBattler] = FreeMonSpriteAfterSwitchOutAnim;
} }
break; break;
} }
} }
#define sSpeedX data[0]
// In emerald it's possible to have a tag battle in the battle frontier facilities with AI // In emerald it's possible to have a tag battle in the battle frontier facilities with AI
// which use the front sprite for both the player and the partner as opposed to any other battles (including the one with Steven) // which use the front sprite for both the player and the partner as opposed to any other battles (including the one with Steven)
// that use an animated back pic. // that use an animated back pic.
@ -2306,10 +2328,10 @@ static void PlayerHandleDrawTrainerPic(void)
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler));
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.y = 48; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.y = 48;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineMode = ST_OAM_AFFINE_OFF; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineMode = ST_OAM_AFFINE_OFF;
gSprites[gBattlerSpriteIds[gActiveBattler]].hFlip = 1; gSprites[gBattlerSpriteIds[gActiveBattler]].hFlip = 1;
} }
@ -2321,9 +2343,9 @@ static void PlayerHandleDrawTrainerPic(void)
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler));
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
} }
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
@ -2361,12 +2383,14 @@ static void PlayerHandleTrainerSlide(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -96; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -96;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 2; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2;
} }
#undef sSpeedX
static void PlayerHandleTrainerSlideBack(void) static void PlayerHandleTrainerSlideBack(void)
{ {
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
@ -2376,9 +2400,12 @@ static void PlayerHandleTrainerSlideBack(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy); StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1);
gBattlerControllerFuncs[gActiveBattler] = sub_80588B4; gBattlerControllerFuncs[gActiveBattler] = FreeTrainerSpriteAfterSlide;
} }
#define sSpeedX data[1]
#define sSpeedY data[2]
static void PlayerHandleFaintAnimation(void) static void PlayerHandleFaintAnimation(void)
{ {
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0)
@ -2394,14 +2421,17 @@ static void PlayerHandleFaintAnimation(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
PlaySE12WithPanning(SE_FAINT, SOUND_PAN_ATTACKER); PlaySE12WithPanning(SE_FAINT, SOUND_PAN_ATTACKER);
gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 0;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 5; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedY = 5;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_8039C00; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_FaintSlideAnim;
gBattlerControllerFuncs[gActiveBattler] = sub_80596A8; gBattlerControllerFuncs[gActiveBattler] = FreeMonSpriteAfterFaintAnim;
} }
} }
} }
#undef sSpeedX
#undef sSpeedY
static void PlayerHandlePaletteFade(void) static void PlayerHandlePaletteFade(void)
{ {
BeginNormalPaletteFade(0xFFFFFFFF, 2, 0, 16, RGB_BLACK); BeginNormalPaletteFade(0xFFFFFFFF, 2, 0, 16, RGB_BLACK);
@ -2428,18 +2458,17 @@ static void PlayerHandleBallThrowAnim(void)
static void PlayerHandlePause(void) static void PlayerHandlePause(void)
{ {
u8 var = gBattleBufferA[gActiveBattler][1]; u8 timer = gBattleBufferA[gActiveBattler][1];
// WTF is this?? while (timer != 0)
while (var != 0) timer--;
var--;
PlayerBufferExecCompleted(); PlayerBufferExecCompleted();
} }
static void PlayerHandleMoveAnimation(void) static void PlayerHandleMoveAnimation(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8);
@ -2482,7 +2511,7 @@ static void PlayerDoMoveAnimation(void)
case 1: case 1:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{ {
sub_805EB9C(ST_OAM_AFFINE_OFF); SetBattlerSpriteAffineMode(ST_OAM_AFFINE_OFF);
DoMoveAnim(move); DoMoveAnim(move);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2;
} }
@ -2491,7 +2520,7 @@ static void PlayerDoMoveAnimation(void)
gAnimScriptCallback(); gAnimScriptCallback();
if (!gAnimScriptActive) if (!gAnimScriptActive)
{ {
sub_805EB9C(ST_OAM_AFFINE_NORMAL); SetBattlerSpriteAffineMode(ST_OAM_AFFINE_NORMAL);
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
{ {
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
@ -2648,10 +2677,10 @@ static void PlayerHandleChoosePokemon(void)
} }
else else
{ {
gUnknown_03005D7C[gActiveBattler] = CreateTask(TaskDummy, 0xFF); gBattleControllerData[gActiveBattler] = CreateTask(TaskDummy, 0xFF);
gTasks[gUnknown_03005D7C[gActiveBattler]].data[0] = gBattleBufferA[gActiveBattler][1] & 0xF; gTasks[gBattleControllerData[gActiveBattler]].data[0] = gBattleBufferA[gActiveBattler][1] & 0xF;
*(&gBattleStruct->battlerPreventingSwitchout) = gBattleBufferA[gActiveBattler][1] >> 4; *(&gBattleStruct->battlerPreventingSwitchout) = gBattleBufferA[gActiveBattler][1] >> 4;
*(&gBattleStruct->field_8B) = gBattleBufferA[gActiveBattler][2]; *(&gBattleStruct->prevSelectedPartySlot) = gBattleBufferA[gActiveBattler][2];
*(&gBattleStruct->abilityPreventingSwitchout) = gBattleBufferA[gActiveBattler][3]; *(&gBattleStruct->abilityPreventingSwitchout) = gBattleBufferA[gActiveBattler][3];
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
gBattlerControllerFuncs[gActiveBattler] = OpenPartyMenuToChooseMon; gBattlerControllerFuncs[gActiveBattler] = OpenPartyMenuToChooseMon;
@ -2726,7 +2755,7 @@ static void PlayerHandleExpUpdate(void)
static void PlayerHandleStatusIconUpdate(void) static void PlayerHandleStatusIconUpdate(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
u8 battlerId; u8 battlerId;
@ -2739,7 +2768,7 @@ static void PlayerHandleStatusIconUpdate(void)
static void PlayerHandleStatusAnimation(void) static void PlayerHandleStatusAnimation(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1],
gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24));
@ -2909,6 +2938,12 @@ static void PlayerHandleIntroSlide(void)
PlayerBufferExecCompleted(); PlayerBufferExecCompleted();
} }
// Task data for Task_StartSendOutAnim
#define tBattlerId data[0]
#define tStartTimer data[1]
#define sBattlerId data[5]
static void PlayerHandleIntroTrainerBallThrow(void) static void PlayerHandleIntroTrainerBallThrow(void)
{ {
u8 paletteNum; u8 paletteNum;
@ -2920,68 +2955,77 @@ static void PlayerHandleIntroTrainerBallThrow(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].sBattlerId = gActiveBattler;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_805CC00); StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCB_FreePlayerSpriteLoadMonSprite);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1);
paletteNum = AllocSpritePalette(0xD6F8); paletteNum = AllocSpritePalette(0xD6F8);
LoadCompressedPalette(gTrainerBackPicPaletteTable[gSaveBlock2Ptr->playerGender].data, 0x100 + paletteNum * 16, 32); LoadCompressedPalette(gTrainerBackPicPaletteTable[gSaveBlock2Ptr->playerGender].data, 0x100 + paletteNum * 16, 32);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum;
taskId = CreateTask(task05_08033660, 5); taskId = CreateTask(Task_StartSendOutAnim, 5);
gTasks[taskId].data[0] = gActiveBattler; gTasks[taskId].tBattlerId = gActiveBattler;
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary; gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1; gBattleSpritesDataPtr->animationData->introAnimActive = TRUE;
gBattlerControllerFuncs[gActiveBattler] = BattleControllerDummy; gBattlerControllerFuncs[gActiveBattler] = BattleControllerDummy;
} }
void sub_805CC00(struct Sprite *sprite) void SpriteCB_FreePlayerSpriteLoadMonSprite(struct Sprite *sprite)
{ {
u8 battlerId = sprite->data[5]; u8 battlerId = sprite->sBattlerId;
// Free player trainer sprite
FreeSpriteOamMatrix(sprite); FreeSpriteOamMatrix(sprite);
FreeSpritePaletteByTag(GetSpritePaletteTagByPaletteNum(sprite->oam.paletteNum)); FreeSpritePaletteByTag(GetSpritePaletteTagByPaletteNum(sprite->oam.paletteNum));
DestroySprite(sprite); DestroySprite(sprite);
// Load mon sprite
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[battlerId]], battlerId); BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[battlerId]], battlerId);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], 0); StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], 0);
} }
static void task05_08033660(u8 taskId) #undef sBattlerId
// Send out at start of battle
static void Task_StartSendOutAnim(u8 taskId)
{ {
if (gTasks[taskId].data[1] < 31) if (gTasks[taskId].tStartTimer < 31)
{ {
gTasks[taskId].data[1]++; gTasks[taskId].tStartTimer++;
} }
else else
{ {
u8 savedActiveBattler = gActiveBattler; u8 savedActiveBattler = gActiveBattler;
gActiveBattler = gTasks[taskId].data[0]; gActiveBattler = gTasks[taskId].tBattlerId;
if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_805B258(gActiveBattler, FALSE); StartSendOutAnim(gActiveBattler, FALSE);
} }
else else
{ {
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_805B258(gActiveBattler, FALSE); StartSendOutAnim(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK; gActiveBattler ^= BIT_FLANK;
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
sub_805B258(gActiveBattler, FALSE); StartSendOutAnim(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK; gActiveBattler ^= BIT_FLANK;
} }
gBattlerControllerFuncs[gActiveBattler] = sub_8058B40; gBattlerControllerFuncs[gActiveBattler] = Intro_TryShinyAnimShowHealthbox;
gActiveBattler = savedActiveBattler; gActiveBattler = savedActiveBattler;
DestroyTask(taskId); DestroyTask(taskId);
} }
} }
#undef tBattlerId
#undef tStartTimer
static void PlayerHandleDrawPartyStatusSummary(void) static void PlayerHandleDrawPartyStatusSummary(void)
{ {
if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
@ -2992,20 +3036,21 @@ static void PlayerHandleDrawPartyStatusSummary(void)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1;
gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0;
// If intro, skip the delay after drawing
if (gBattleBufferA[gActiveBattler][2] != 0) if (gBattleBufferA[gActiveBattler][2] != 0)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 93;
gBattlerControllerFuncs[gActiveBattler] = sub_805CE38; gBattlerControllerFuncs[gActiveBattler] = EndDrawPartyStatusSummary;
} }
} }
static void sub_805CE38(void) static void EndDrawPartyStatusSummary(void)
{ {
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5++ > 0x5C) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer++ > 92)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0;
PlayerBufferExecCompleted(); PlayerBufferExecCompleted();
} }
} }
@ -3036,7 +3081,7 @@ static void PlayerHandleSpriteInvisibility(void)
static void PlayerHandleBattleAnimation(void) static void PlayerHandleBattleAnimation(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
u8 animationId = gBattleBufferA[gActiveBattler][1]; u8 animationId = gBattleBufferA[gActiveBattler][1];
u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8);
@ -3052,7 +3097,7 @@ static void PlayerHandleBattleAnimation(void)
static void PlayerHandleLinkStandbyMsg(void) static void PlayerHandleLinkStandbyMsg(void)
{ {
sub_81851A8(&gBattleBufferA[gActiveBattler][2]); RecordedBattle_RecordAllBattlerData(&gBattleBufferA[gActiveBattler][2]);
switch (gBattleBufferA[gActiveBattler][1]) switch (gBattleBufferA[gActiveBattler][1])
{ {
case 0: case 0:
@ -3089,13 +3134,13 @@ static void PlayerHandleResetActionMoveSelection(void)
static void PlayerHandleEndLinkBattle(void) static void PlayerHandleEndLinkBattle(void)
{ {
sub_81851A8(&gBattleBufferA[gActiveBattler][4]); RecordedBattle_RecordAllBattlerData(&gBattleBufferA[gActiveBattler][4]);
gBattleOutcome = gBattleBufferA[gActiveBattler][1]; gBattleOutcome = gBattleBufferA[gActiveBattler][1];
gSaveBlock2Ptr->frontier.disableRecordBattle = gBattleBufferA[gActiveBattler][2]; gSaveBlock2Ptr->frontier.disableRecordBattle = gBattleBufferA[gActiveBattler][2];
FadeOutMapMusic(5); FadeOutMapMusic(5);
BeginFastPaletteFade(3); BeginFastPaletteFade(3);
PlayerBufferExecCompleted(); PlayerBufferExecCompleted();
gBattlerControllerFuncs[gActiveBattler] = sub_80587B0; gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks;
} }
static void PlayerCmdEnd(void) static void PlayerCmdEnd(void)

View File

@ -101,7 +101,7 @@ static void sub_81BD0E4(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void); static void DoSwitchOutAnimation(void);
static void PlayerPartnerDoMoveAnimation(void); static void PlayerPartnerDoMoveAnimation(void);
static void sub_81BE2C8(u8 taskId); static void sub_81BE2C8(u8 taskId);
static void sub_81BE498(void); static void EndDrawPartyStatusSummary(void);
static void (*const sPlayerPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) = static void (*const sPlayerPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
{ {
@ -203,7 +203,7 @@ static void sub_81BAE98(void)
{ {
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
nullsub_25(0); BattleGfxSfxDummy3(MALE);
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
@ -212,9 +212,9 @@ static void sub_81BAE98(void)
static void sub_81BAF00(void) static void sub_81BAF00(void)
{ {
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF) if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
} }
} }
@ -242,7 +242,7 @@ static void sub_81BAF48(void)
if (r6) if (r6)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
gBattlerControllerFuncs[gActiveBattler] = sub_81BAF00; gBattlerControllerFuncs[gActiveBattler] = sub_81BAF00;
} }
} }
@ -251,26 +251,26 @@ static void sub_81BB02C(void)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive
&& gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy && gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& ++gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 != 1) && ++gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay != 1)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler ^ BIT_FLANK]]);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler ^ BIT_FLANK); StartHealthboxSlideIn(gActiveBattler ^ BIT_FLANK);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]);
} }
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattleSpritesDataPtr->animationData->field_9_x1 = 0; gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
gBattlerControllerFuncs[gActiveBattler] = sub_81BAF48; gBattlerControllerFuncs[gActiveBattler] = sub_81BAF48;
} }
@ -471,13 +471,13 @@ static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8 taskId)
DestroyTask(taskId); DestroyTask(taskId);
} }
static void sub_81BB78C(void) static void FreeMonSpriteAfterFaintAnim(void)
{ {
if (gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y + gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.y > DISPLAY_HEIGHT) if (gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y + gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.y > DISPLAY_HEIGHT)
{ {
u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES); u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
nullsub_24(species); BattleGfxSfxDummy2(species);
FreeOamMatrix(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.matrixNum); FreeOamMatrix(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.matrixNum);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
@ -549,14 +549,14 @@ static void sub_81BB9F4(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
CreateTask(c3_0802FDF4, 10); CreateTask(Task_PlayerController_RestoreBgmAfterCry, 10);
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattlerControllerFuncs[gActiveBattler] = sub_81BB92C; gBattlerControllerFuncs[gActiveBattler] = sub_81BB92C;
@ -571,10 +571,10 @@ static void sub_81BBAE8(void)
TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]); TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
} }
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
gBattlerControllerFuncs[gActiveBattler] = sub_81BB9F4; gBattlerControllerFuncs[gActiveBattler] = sub_81BB9F4;
} }
} }
@ -1229,7 +1229,7 @@ static void sub_81BD0E4(u8 battlerId, bool8 dontClearSubstituteBit)
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit); ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1]; gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[battlerId] = CreateSprite( gBattlerSpriteIds[battlerId] = CreateSprite(
@ -1238,8 +1238,8 @@ static void sub_81BD0E4(u8 battlerId, bool8 dontClearSubstituteBit)
GetBattlerSpriteDefault_Y(battlerId), GetBattlerSpriteDefault_Y(battlerId),
GetBattlerSpriteSubpriority(battlerId)); GetBattlerSpriteSubpriority(battlerId));
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId]; gSprites[gBattleControllerData[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId; gSprites[gBattleControllerData[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId; gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species; gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
@ -1250,7 +1250,7 @@ static void sub_81BD0E4(u8 battlerId, bool8 dontClearSubstituteBit)
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE; gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT); gSprites[gBattleControllerData[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
} }
static void PlayerPartnerHandleReturnMonToBall(void) static void PlayerPartnerHandleReturnMonToBall(void)
@ -1290,6 +1290,8 @@ static void DoSwitchOutAnimation(void)
} }
} }
#define sSpeedX data[0]
// some explanation here // some explanation here
// in emerald it's possible to have a tag battle in the battle frontier facilities with AI // in emerald it's possible to have a tag battle in the battle frontier facilities with AI
// which use the front sprite for both the player and the partner as opposed to any other battles (including the one with Steven) that use the back pic as well as animate it // which use the front sprite for both the player and the partner as opposed to any other battles (including the one with Steven) that use the back pic as well as animate it
@ -1319,9 +1321,9 @@ static void PlayerPartnerHandleDrawTrainerPic(void)
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler));
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
} }
else // otherwise use front sprite else // otherwise use front sprite
{ {
@ -1330,10 +1332,10 @@ static void PlayerPartnerHandleDrawTrainerPic(void)
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler));
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.y = 48; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.y = 48;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineMode = ST_OAM_AFFINE_OFF; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineMode = ST_OAM_AFFINE_OFF;
gSprites[gBattlerSpriteIds[gActiveBattler]].hFlip = 1; gSprites[gBattlerSpriteIds[gActiveBattler]].hFlip = 1;
} }
@ -1341,6 +1343,8 @@ static void PlayerPartnerHandleDrawTrainerPic(void)
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
} }
#undef sSpeedX
static void PlayerPartnerHandleTrainerSlide(void) static void PlayerPartnerHandleTrainerSlide(void)
{ {
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
@ -1357,6 +1361,9 @@ static void PlayerPartnerHandleTrainerSlideBack(void)
gBattlerControllerFuncs[gActiveBattler] = sub_81BAE98; gBattlerControllerFuncs[gActiveBattler] = sub_81BAE98;
} }
#define sSpeedX data[1]
#define sSpeedY data[2]
static void PlayerPartnerHandleFaintAnimation(void) static void PlayerPartnerHandleFaintAnimation(void)
{ {
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0)
@ -1372,14 +1379,17 @@ static void PlayerPartnerHandleFaintAnimation(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
PlaySE12WithPanning(SE_FAINT, SOUND_PAN_ATTACKER); PlaySE12WithPanning(SE_FAINT, SOUND_PAN_ATTACKER);
gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 0;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 5; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedY = 5;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_8039C00; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_FaintSlideAnim;
gBattlerControllerFuncs[gActiveBattler] = sub_81BB78C; gBattlerControllerFuncs[gActiveBattler] = FreeMonSpriteAfterFaintAnim;
} }
} }
} }
#undef sSpeedX
#undef sSpeedY
static void PlayerPartnerHandlePaletteFade(void) static void PlayerPartnerHandlePaletteFade(void)
{ {
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
@ -1402,7 +1412,7 @@ static void PlayerPartnerHandlePause(void)
static void PlayerPartnerHandleMoveAnimation(void) static void PlayerPartnerHandleMoveAnimation(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8);
@ -1444,7 +1454,7 @@ static void PlayerPartnerDoMoveAnimation(void)
case 1: case 1:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{ {
sub_805EB9C(ST_OAM_AFFINE_OFF); SetBattlerSpriteAffineMode(ST_OAM_AFFINE_OFF);
DoMoveAnim(move); DoMoveAnim(move);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2;
} }
@ -1453,7 +1463,7 @@ static void PlayerPartnerDoMoveAnimation(void)
gAnimScriptCallback(); gAnimScriptCallback();
if (!gAnimScriptActive) if (!gAnimScriptActive)
{ {
sub_805EB9C(ST_OAM_AFFINE_NORMAL); SetBattlerSpriteAffineMode(ST_OAM_AFFINE_NORMAL);
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
{ {
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
@ -1613,7 +1623,7 @@ static void PlayerPartnerHandleExpUpdate(void)
static void PlayerPartnerHandleStatusIconUpdate(void) static void PlayerPartnerHandleStatusIconUpdate(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
u8 battlerId; u8 battlerId;
@ -1626,7 +1636,7 @@ static void PlayerPartnerHandleStatusIconUpdate(void)
static void PlayerPartnerHandleStatusAnimation(void) static void PlayerPartnerHandleStatusAnimation(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1],
gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24));
@ -1779,7 +1789,7 @@ static void PlayerPartnerHandleIntroTrainerBallThrow(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gActiveBattler;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_805CC00); StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCB_FreePlayerSpriteLoadMonSprite);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1);
paletteNum = AllocSpritePalette(0xD6F9); paletteNum = AllocSpritePalette(0xD6F9);
@ -1803,7 +1813,7 @@ static void PlayerPartnerHandleIntroTrainerBallThrow(void)
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary; gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1; gBattleSpritesDataPtr->animationData->introAnimActive = TRUE;
gBattlerControllerFuncs[gActiveBattler] = nullsub_77; gBattlerControllerFuncs[gActiveBattler] = nullsub_77;
} }
@ -1849,20 +1859,20 @@ static void PlayerPartnerHandleDrawPartyStatusSummary(void)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1;
gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0;
if (gBattleBufferA[gActiveBattler][2] != 0) if (gBattleBufferA[gActiveBattler][2] != 0)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 93;
gBattlerControllerFuncs[gActiveBattler] = sub_81BE498; gBattlerControllerFuncs[gActiveBattler] = EndDrawPartyStatusSummary;
} }
} }
static void sub_81BE498(void) static void EndDrawPartyStatusSummary(void)
{ {
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5++ > 0x5C) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer++ > 92)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0;
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
} }
} }
@ -1891,7 +1901,7 @@ static void PlayerPartnerHandleSpriteInvisibility(void)
static void PlayerPartnerHandleBattleAnimation(void) static void PlayerPartnerHandleBattleAnimation(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
u8 animationId = gBattleBufferA[gActiveBattler][1]; u8 animationId = gBattleBufferA[gActiveBattler][1];
u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8);
@ -1919,7 +1929,7 @@ static void PlayerPartnerHandleEndLinkBattle(void)
FadeOutMapMusic(5); FadeOutMapMusic(5);
BeginFastPaletteFade(3); BeginFastPaletteFade(3);
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
gBattlerControllerFuncs[gActiveBattler] = sub_80587B0; gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks;
} }
static void PlayerPartnerCmdEnd(void) static void PlayerPartnerCmdEnd(void)

View File

@ -100,7 +100,7 @@ static void DoSwitchOutAnimation(void);
static void RecordedOpponentDoMoveAnimation(void); static void RecordedOpponentDoMoveAnimation(void);
static void sub_8189548(u8 taskId); static void sub_8189548(u8 taskId);
static void sub_818962C(struct Sprite *sprite); static void sub_818962C(struct Sprite *sprite);
static void sub_818975C(void); static void EndDrawPartyStatusSummary(void);
static void (*const sRecordedOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) = static void (*const sRecordedOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
{ {
@ -208,9 +208,9 @@ static void sub_81865C8(void)
static void sub_8186630(void) static void sub_8186630(void)
{ {
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF) if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
} }
} }
@ -248,11 +248,11 @@ static void sub_8186678(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
gBattlerControllerFuncs[gActiveBattler] = sub_8186630; gBattlerControllerFuncs[gActiveBattler] = sub_8186630;
} }
} }
@ -272,27 +272,27 @@ static void sub_818686C(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted)
{ {
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler ^ BIT_FLANK); StartHealthboxSlideIn(gActiveBattler ^ BIT_FLANK);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]);
} }
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = TRUE;
} }
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x40 if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].waitForCry
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x40 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].waitForCry
&& !IsCryPlayingOrClearCrySongs()) && !IsCryPlayingOrClearCrySongs())
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK)
{ {
@ -304,13 +304,13 @@ static void sub_818686C(void)
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100); m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
} }
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE;
r9 = TRUE; r9 = TRUE;
} }
if (!IsDoubleBattle()) if (!IsDoubleBattle())
{ {
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
r8 = TRUE; r8 = TRUE;
@ -318,9 +318,9 @@ static void sub_818686C(void)
} }
else else
{ {
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy && gSprites[gBattleControllerData[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
{ {
r8 = TRUE; r8 = TRUE;
@ -331,16 +331,16 @@ static void sub_818686C(void)
{ {
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler ^ BIT_FLANK]]);
SetBattlerShadowSpriteCallback(gActiveBattler ^ BIT_FLANK, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(gActiveBattler ^ BIT_FLANK, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], MON_DATA_SPECIES));
} }
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattleSpritesDataPtr->animationData->field_9_x1 = 0; gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = FALSE;
gBattlerControllerFuncs[gActiveBattler] = sub_8186678; gBattlerControllerFuncs[gActiveBattler] = sub_8186678;
} }
@ -361,8 +361,8 @@ static void sub_8186C48(void)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
} }
} }
@ -464,13 +464,13 @@ static void sub_8186F94(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
CopyBattleSpriteInvisibility(gActiveBattler); CopyBattleSpriteInvisibility(gActiveBattler);
gBattlerControllerFuncs[gActiveBattler] = sub_8186EA4; gBattlerControllerFuncs[gActiveBattler] = sub_8186EA4;
@ -483,10 +483,10 @@ static void sub_8187084(void)
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim)
TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]); TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattlerControllerFuncs[gActiveBattler] = sub_8186F94; gBattlerControllerFuncs[gActiveBattler] = sub_8186F94;
} }
@ -1141,7 +1141,7 @@ static void sub_81885D8(u8 battlerId, bool8 dontClearSubstituteBit)
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit); ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1]; gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
@ -1150,8 +1150,8 @@ static void sub_81885D8(u8 battlerId, bool8 dontClearSubstituteBit)
GetBattlerSpriteDefault_Y(battlerId), GetBattlerSpriteDefault_Y(battlerId),
GetBattlerSpriteSubpriority(battlerId)); GetBattlerSpriteSubpriority(battlerId));
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId]; gSprites[gBattleControllerData[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId; gSprites[gBattleControllerData[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId; gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species; gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
@ -1162,7 +1162,7 @@ static void sub_81885D8(u8 battlerId, bool8 dontClearSubstituteBit)
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE; gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT); gSprites[gBattleControllerData[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT);
} }
static void RecordedOpponentHandleReturnMonToBall(void) static void RecordedOpponentHandleReturnMonToBall(void)
@ -1203,6 +1203,8 @@ static void DoSwitchOutAnimation(void)
} }
} }
#define sSpeedX data[0]
static void RecordedOpponentHandleDrawTrainerPic(void) static void RecordedOpponentHandleDrawTrainerPic(void)
{ {
s16 xPos; s16 xPos;
@ -1248,14 +1250,16 @@ static void RecordedOpponentHandleDrawTrainerPic(void)
GetBattlerSpriteSubpriority(gActiveBattler)); GetBattlerSpriteSubpriority(gActiveBattler));
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -240;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 2; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 2;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
} }
#undef sSpeedX
static void RecordedOpponentHandleTrainerSlide(void) static void RecordedOpponentHandleTrainerSlide(void)
{ {
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
@ -1314,7 +1318,7 @@ static void RecordedOpponentHandlePause(void)
static void RecordedOpponentHandleMoveAnimation(void) static void RecordedOpponentHandleMoveAnimation(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8);
@ -1356,7 +1360,7 @@ static void RecordedOpponentDoMoveAnimation(void)
case 1: case 1:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{ {
sub_805EB9C(ST_OAM_AFFINE_OFF); SetBattlerSpriteAffineMode(ST_OAM_AFFINE_OFF);
DoMoveAnim(move); DoMoveAnim(move);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2;
} }
@ -1365,7 +1369,7 @@ static void RecordedOpponentDoMoveAnimation(void)
gAnimScriptCallback(); gAnimScriptCallback();
if (!gAnimScriptActive) if (!gAnimScriptActive)
{ {
sub_805EB9C(ST_OAM_AFFINE_NORMAL); SetBattlerSpriteAffineMode(ST_OAM_AFFINE_NORMAL);
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
{ {
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
@ -1478,7 +1482,7 @@ static void RecordedOpponentHandleExpUpdate(void)
static void RecordedOpponentHandleStatusIconUpdate(void) static void RecordedOpponentHandleStatusIconUpdate(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
u8 battlerId; u8 battlerId;
@ -1491,7 +1495,7 @@ static void RecordedOpponentHandleStatusIconUpdate(void)
static void RecordedOpponentHandleStatusAnimation(void) static void RecordedOpponentHandleStatusAnimation(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1],
gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24));
@ -1650,7 +1654,7 @@ static void RecordedOpponentHandleIntroTrainerBallThrow(void)
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary; gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1; gBattleSpritesDataPtr->animationData->introAnimActive = TRUE;
gBattlerControllerFuncs[gActiveBattler] = nullsub_70; gBattlerControllerFuncs[gActiveBattler] = nullsub_70;
} }
@ -1709,20 +1713,20 @@ static void RecordedOpponentHandleDrawPartyStatusSummary(void)
} }
gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0;
if (gBattleBufferA[gActiveBattler][2] != 0) if (gBattleBufferA[gActiveBattler][2] != 0)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 93;
gBattlerControllerFuncs[gActiveBattler] = sub_818975C; gBattlerControllerFuncs[gActiveBattler] = EndDrawPartyStatusSummary;
} }
} }
static void sub_818975C(void) static void EndDrawPartyStatusSummary(void)
{ {
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5++ > 0x5C) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer++ > 92)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0;
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
} }
} }
@ -1751,7 +1755,7 @@ static void RecordedOpponentHandleSpriteInvisibility(void)
static void RecordedOpponentHandleBattleAnimation(void) static void RecordedOpponentHandleBattleAnimation(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
u8 animationId = gBattleBufferA[gActiveBattler][1]; u8 animationId = gBattleBufferA[gActiveBattler][1];
u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8);
@ -1783,7 +1787,7 @@ static void RecordedOpponentHandleEndLinkBattle(void)
FadeOutMapMusic(5); FadeOutMapMusic(5);
BeginFastPaletteFade(3); BeginFastPaletteFade(3);
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
gBattlerControllerFuncs[gActiveBattler] = sub_80587B0; gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks;
} }
static void RecordedOpponentCmdEnd(void) static void RecordedOpponentCmdEnd(void)

View File

@ -95,7 +95,7 @@ static void sub_818BA6C(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void); static void DoSwitchOutAnimation(void);
static void RecordedPlayerDoMoveAnimation(void); static void RecordedPlayerDoMoveAnimation(void);
static void sub_818CC24(u8 taskId); static void sub_818CC24(u8 taskId);
static void sub_818CDF4(void); static void EndDrawPartyStatusSummary(void);
static void (*const sRecordedPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) = static void (*const sRecordedPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
{ {
@ -188,7 +188,7 @@ static void sub_81899F0(void)
{ {
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
nullsub_25(0); BattleGfxSfxDummy3(MALE);
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
@ -197,9 +197,9 @@ static void sub_81899F0(void)
static void sub_8189A58(void) static void sub_8189A58(void)
{ {
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF) if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
} }
} }
@ -233,14 +233,14 @@ static void sub_8189AA0(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
if (IsDoubleBattle()) if (IsDoubleBattle())
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], gActiveBattler ^ BIT_FLANK); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], gActiveBattler ^ BIT_FLANK);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
gBattlerControllerFuncs[gActiveBattler] = sub_8189A58; gBattlerControllerFuncs[gActiveBattler] = sub_8189A58;
} }
} }
@ -265,7 +265,7 @@ static void sub_8189AA0(void)
if (r6) if (r6)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
gBattlerControllerFuncs[gActiveBattler] = sub_8189A58; gBattlerControllerFuncs[gActiveBattler] = sub_8189A58;
} }
} }
@ -289,27 +289,27 @@ static void sub_8189D40(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted)
{ {
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler ^ BIT_FLANK); StartHealthboxSlideIn(gActiveBattler ^ BIT_FLANK);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]);
} }
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = TRUE;
} }
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x40 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].waitForCry
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x40 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].waitForCry
&& !IsCryPlayingOrClearCrySongs()) && !IsCryPlayingOrClearCrySongs())
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored)
{ {
if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && (gBattleTypeFlags & BATTLE_TYPE_MULTI)) if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && (gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
@ -322,20 +322,20 @@ static void sub_8189D40(void)
} }
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE;
r10 = TRUE; r10 = TRUE;
} }
if (r10 && gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (r10 && gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler ^ BIT_FLANK]]);
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
gBattleSpritesDataPtr->animationData->field_9_x1 = 0; gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = FALSE;
gBattlerControllerFuncs[gActiveBattler] = sub_8189AA0; gBattlerControllerFuncs[gActiveBattler] = sub_8189AA0;
} }
} }
@ -363,13 +363,13 @@ static void CompleteOnHealthbarDone(void)
} }
} }
static void sub_818A114(void) static void FreeMonSpriteAfterFaintAnim(void)
{ {
if (gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y + gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.y > DISPLAY_HEIGHT) if (gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y + gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.y > DISPLAY_HEIGHT)
{ {
u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES); u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
nullsub_24(species); BattleGfxSfxDummy2(species);
FreeOamMatrix(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.matrixNum); FreeOamMatrix(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.matrixNum);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
@ -441,14 +441,14 @@ static void sub_818A37C(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
CreateTask(c3_0802FDF4, 10); CreateTask(Task_PlayerController_RestoreBgmAfterCry, 10);
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattlerControllerFuncs[gActiveBattler] = sub_818A2B4; gBattlerControllerFuncs[gActiveBattler] = sub_818A2B4;
@ -463,10 +463,10 @@ static void sub_818A470(void)
TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]); TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
} }
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
gBattlerControllerFuncs[gActiveBattler] = sub_818A37C; gBattlerControllerFuncs[gActiveBattler] = sub_818A37C;
} }
} }
@ -1121,7 +1121,7 @@ static void sub_818BA6C(u8 battlerId, bool8 dontClearSubstituteBit)
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit); ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1]; gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[battlerId] = CreateSprite( gBattlerSpriteIds[battlerId] = CreateSprite(
@ -1130,8 +1130,8 @@ static void sub_818BA6C(u8 battlerId, bool8 dontClearSubstituteBit)
GetBattlerSpriteDefault_Y(battlerId), GetBattlerSpriteDefault_Y(battlerId),
GetBattlerSpriteSubpriority(battlerId)); GetBattlerSpriteSubpriority(battlerId));
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId]; gSprites[gBattleControllerData[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId; gSprites[gBattleControllerData[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId; gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species; gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
@ -1142,7 +1142,7 @@ static void sub_818BA6C(u8 battlerId, bool8 dontClearSubstituteBit)
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE; gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT); gSprites[gBattleControllerData[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
} }
static void RecordedPlayerHandleReturnMonToBall(void) static void RecordedPlayerHandleReturnMonToBall(void)
@ -1182,6 +1182,8 @@ static void DoSwitchOutAnimation(void)
} }
} }
#define sSpeedX data[0]
static void RecordedPlayerHandleDrawTrainerPic(void) static void RecordedPlayerHandleDrawTrainerPic(void)
{ {
s16 xPos, yPos; s16 xPos, yPos;
@ -1231,10 +1233,10 @@ static void RecordedPlayerHandleDrawTrainerPic(void)
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler));
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.y = 48; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.y = 48;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineMode = ST_OAM_AFFINE_OFF; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineMode = ST_OAM_AFFINE_OFF;
gSprites[gBattlerSpriteIds[gActiveBattler]].hFlip = 1; gSprites[gBattlerSpriteIds[gActiveBattler]].hFlip = 1;
} }
@ -1245,14 +1247,16 @@ static void RecordedPlayerHandleDrawTrainerPic(void)
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler));
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
} }
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
} }
#undef sSpeedX
static void RecordedPlayerHandleTrainerSlide(void) static void RecordedPlayerHandleTrainerSlide(void)
{ {
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
@ -1269,6 +1273,9 @@ static void RecordedPlayerHandleTrainerSlideBack(void)
gBattlerControllerFuncs[gActiveBattler] = sub_81899F0; gBattlerControllerFuncs[gActiveBattler] = sub_81899F0;
} }
#define sSpeedX data[1]
#define sSpeedY data[2]
static void RecordedPlayerHandleFaintAnimation(void) static void RecordedPlayerHandleFaintAnimation(void)
{ {
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0)
@ -1284,14 +1291,17 @@ static void RecordedPlayerHandleFaintAnimation(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
PlaySE12WithPanning(SE_FAINT, -64); PlaySE12WithPanning(SE_FAINT, -64);
gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 0;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 5; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedY = 5;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_8039C00; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_FaintSlideAnim;
gBattlerControllerFuncs[gActiveBattler] = sub_818A114; gBattlerControllerFuncs[gActiveBattler] = FreeMonSpriteAfterFaintAnim;
} }
} }
} }
#undef sSpeedX
#undef sSpeedY
static void RecordedPlayerHandlePaletteFade(void) static void RecordedPlayerHandlePaletteFade(void)
{ {
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
@ -1314,7 +1324,7 @@ static void RecordedPlayerHandlePause(void)
static void RecordedPlayerHandleMoveAnimation(void) static void RecordedPlayerHandleMoveAnimation(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8);
@ -1356,7 +1366,7 @@ static void RecordedPlayerDoMoveAnimation(void)
case 1: case 1:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{ {
sub_805EB9C(ST_OAM_AFFINE_OFF); SetBattlerSpriteAffineMode(ST_OAM_AFFINE_OFF);
DoMoveAnim(move); DoMoveAnim(move);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2;
} }
@ -1365,7 +1375,7 @@ static void RecordedPlayerDoMoveAnimation(void)
gAnimScriptCallback(); gAnimScriptCallback();
if (!gAnimScriptActive) if (!gAnimScriptActive)
{ {
sub_805EB9C(ST_OAM_AFFINE_NORMAL); SetBattlerSpriteAffineMode(ST_OAM_AFFINE_NORMAL);
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
{ {
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
@ -1495,7 +1505,7 @@ static void RecordedPlayerHandleExpUpdate(void)
static void RecordedPlayerHandleStatusIconUpdate(void) static void RecordedPlayerHandleStatusIconUpdate(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
u8 battlerId; u8 battlerId;
@ -1508,7 +1518,7 @@ static void RecordedPlayerHandleStatusIconUpdate(void)
static void RecordedPlayerHandleStatusAnimation(void) static void RecordedPlayerHandleStatusAnimation(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1],
gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24));
@ -1662,7 +1672,7 @@ static void RecordedPlayerHandleIntroTrainerBallThrow(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gActiveBattler;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_805CC00); StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCB_FreePlayerSpriteLoadMonSprite);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1);
paletteNum = AllocSpritePalette(0xD6F9); paletteNum = AllocSpritePalette(0xD6F9);
@ -1681,7 +1691,7 @@ static void RecordedPlayerHandleIntroTrainerBallThrow(void)
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary; gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1; gBattleSpritesDataPtr->animationData->introAnimActive = TRUE;
gBattlerControllerFuncs[gActiveBattler] = nullsub_120; gBattlerControllerFuncs[gActiveBattler] = nullsub_120;
} }
@ -1727,20 +1737,20 @@ static void RecordedPlayerHandleDrawPartyStatusSummary(void)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1;
gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0;
if (gBattleBufferA[gActiveBattler][2] != 0) if (gBattleBufferA[gActiveBattler][2] != 0)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 93;
gBattlerControllerFuncs[gActiveBattler] = sub_818CDF4; gBattlerControllerFuncs[gActiveBattler] = EndDrawPartyStatusSummary;
} }
} }
static void sub_818CDF4(void) static void EndDrawPartyStatusSummary(void)
{ {
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5++ > 0x5C) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer++ > 92)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusDelayTimer = 0;
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
} }
} }
@ -1769,7 +1779,7 @@ static void RecordedPlayerHandleSpriteInvisibility(void)
static void RecordedPlayerHandleBattleAnimation(void) static void RecordedPlayerHandleBattleAnimation(void)
{ {
if (!mplay_80342A4(gActiveBattler)) if (!IsBattleSEPlaying(gActiveBattler))
{ {
u8 animationId = gBattleBufferA[gActiveBattler][1]; u8 animationId = gBattleBufferA[gActiveBattler][1];
u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8);
@ -1797,7 +1807,7 @@ static void RecordedPlayerHandleEndLinkBattle(void)
FadeOutMapMusic(5); FadeOutMapMusic(5);
BeginFastPaletteFade(3); BeginFastPaletteFade(3);
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
gBattlerControllerFuncs[gActiveBattler] = sub_80587B0; gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks;
} }
static void RecordedPlayerCmdEnd(void) static void RecordedPlayerCmdEnd(void)

View File

@ -349,6 +349,8 @@ static void SafariHandleReturnMonToBall(void)
SafariBufferExecCompleted(); SafariBufferExecCompleted();
} }
#define sSpeedX data[0]
static void SafariHandleDrawTrainerPic(void) static void SafariHandleDrawTrainerPic(void)
{ {
DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, gActiveBattler); DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, gActiveBattler);
@ -359,12 +361,14 @@ static void SafariHandleDrawTrainerPic(void)
(8 - gTrainerBackPicCoords[gSaveBlock2Ptr->playerGender].size) * 4 + 80, (8 - gTrainerBackPicCoords[gSaveBlock2Ptr->playerGender].size) * 4 + 80,
30); 30);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
} }
#undef sSpeedX
static void SafariHandleTrainerSlide(void) static void SafariHandleTrainerSlide(void)
{ {
SafariBufferExecCompleted(); SafariBufferExecCompleted();
@ -627,7 +631,7 @@ static void SafariHandleIntroSlide(void)
static void SafariHandleIntroTrainerBallThrow(void) static void SafariHandleIntroTrainerBallThrow(void)
{ {
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_SAFARI_ALL_TEXT); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_SAFARI_ALL_TEXT);
sub_8076918(gActiveBattler); StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthboxSpriteCallbackDummy; gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthboxSpriteCallbackDummy;
} }

View File

@ -268,7 +268,7 @@ static void OpenBagAfterPaletteFade(void)
if (!gPaletteFade.active) if (!gPaletteFade.active)
{ {
gBattlerControllerFuncs[gActiveBattler] = CompleteOnChosenItem; gBattlerControllerFuncs[gActiveBattler] = CompleteOnChosenItem;
nullsub_35(); ReshowBattleScreenDummy();
FreeAllWindowBuffers(); FreeAllWindowBuffers();
DoWallyTutorialBagMenu(); DoWallyTutorialBagMenu();
} }
@ -295,22 +295,22 @@ static void sub_816864C(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive
&& gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy && gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler ^ BIT_FLANK]]);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler ^ BIT_FLANK); StartHealthboxSlideIn(gActiveBattler ^ BIT_FLANK);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]);
} }
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattleSpritesDataPtr->animationData->field_9_x1 = 0; gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
gBattlerControllerFuncs[gActiveBattler] = sub_8168818; gBattlerControllerFuncs[gActiveBattler] = sub_8168818;
} }
@ -332,10 +332,10 @@ static void sub_8168818(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim = FALSE; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
CreateTask(c3_0802FDF4, 10); CreateTask(Task_PlayerController_RestoreBgmAfterCry, 10);
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
WallyBufferExecCompleted(); WallyBufferExecCompleted();
@ -1030,6 +1030,8 @@ static void WallyHandleReturnMonToBall(void)
} }
} }
#define sSpeedX data[0]
static void WallyHandleDrawTrainerPic(void) static void WallyHandleDrawTrainerPic(void)
{ {
DecompressTrainerBackPic(TRAINER_BACK_PIC_WALLY, gActiveBattler); DecompressTrainerBackPic(TRAINER_BACK_PIC_WALLY, gActiveBattler);
@ -1039,9 +1041,9 @@ static void WallyHandleDrawTrainerPic(void)
80 + 4 * (8 - gTrainerBackPicCoords[TRAINER_BACK_PIC_WALLY].size), 80 + 4 * (8 - gTrainerBackPicCoords[TRAINER_BACK_PIC_WALLY].size),
30); 30);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
} }
@ -1055,11 +1057,13 @@ static void WallyHandleTrainerSlide(void)
30); 30);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -96; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -96;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 2; gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2;
} }
#undef sSpeedX
static void WallyHandleTrainerSlideBack(void) static void WallyHandleTrainerSlideBack(void)
{ {
WallyBufferExecCompleted(); WallyBufferExecCompleted();
@ -1137,7 +1141,7 @@ static void WallyDoMoveAnimation(void)
case 1: case 1:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{ {
sub_805EB9C(ST_OAM_AFFINE_OFF); SetBattlerSpriteAffineMode(ST_OAM_AFFINE_OFF);
DoMoveAnim(move); DoMoveAnim(move);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2;
} }
@ -1146,7 +1150,7 @@ static void WallyDoMoveAnimation(void)
gAnimScriptCallback(); gAnimScriptCallback();
if (!gAnimScriptActive) if (!gAnimScriptActive)
{ {
sub_805EB9C(ST_OAM_AFFINE_NORMAL); SetBattlerSpriteAffineMode(ST_OAM_AFFINE_NORMAL);
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
{ {
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
@ -1435,7 +1439,7 @@ static void WallyHandleIntroTrainerBallThrow(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gActiveBattler;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_805CC00); StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCB_FreePlayerSpriteLoadMonSprite);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1);
paletteNum = AllocSpritePalette(0xD6F8); paletteNum = AllocSpritePalette(0xD6F8);
@ -1448,7 +1452,7 @@ static void WallyHandleIntroTrainerBallThrow(void)
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary; gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1; gBattleSpritesDataPtr->animationData->introAnimActive = TRUE;
gBattlerControllerFuncs[gActiveBattler] = BattleControllerDummy; gBattlerControllerFuncs[gActiveBattler] = BattleControllerDummy;
} }
@ -1459,15 +1463,15 @@ static void sub_816AA80(u8 battlerId)
gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies = 0; gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies = 0;
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1]; gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714); gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[battlerId] = CreateSprite(&gMultiuseSpriteTemplate, gBattlerSpriteIds[battlerId] = CreateSprite(&gMultiuseSpriteTemplate,
GetBattlerSpriteCoord(battlerId, 2), GetBattlerSpriteCoord(battlerId, 2),
GetBattlerSpriteDefault_Y(battlerId), GetBattlerSpriteDefault_Y(battlerId),
GetBattlerSpriteSubpriority(battlerId)); GetBattlerSpriteSubpriority(battlerId));
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId]; gSprites[gBattleControllerData[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId; gSprites[gBattleControllerData[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId; gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species; gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
@ -1476,7 +1480,7 @@ static void sub_816AA80(u8 battlerId)
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], gBattleMonForms[battlerId]); StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], gBattleMonForms[battlerId]);
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE; gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT); gSprites[gBattleControllerData[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
} }
static void sub_816AC04(u8 taskId) static void sub_816AC04(u8 taskId)
@ -1556,7 +1560,7 @@ static void WallyHandleEndLinkBattle(void)
WallyBufferExecCompleted(); WallyBufferExecCompleted();
if (!(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER) && gBattleTypeFlags & BATTLE_TYPE_LINK) if (!(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER) && gBattleTypeFlags & BATTLE_TYPE_LINK)
gBattlerControllerFuncs[gActiveBattler] = sub_80587B0; gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks;
} }
static void WallyCmdEnd(void) static void WallyCmdEnd(void)

View File

@ -1437,13 +1437,13 @@ void BtlController_EmitIntroTrainerBallThrow(u8 bufferId)
PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4); PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4);
} }
void BtlController_EmitDrawPartyStatusSummary(u8 bufferId, struct HpAndStatus* hpAndStatus, u8 arg2) void BtlController_EmitDrawPartyStatusSummary(u8 bufferId, struct HpAndStatus* hpAndStatus, u8 flags)
{ {
s32 i; s32 i;
sBattleBuffersTransferData[0] = CONTROLLER_DRAWPARTYSTATUSSUMMARY; sBattleBuffersTransferData[0] = CONTROLLER_DRAWPARTYSTATUSSUMMARY;
sBattleBuffersTransferData[1] = arg2 & 0x7F; sBattleBuffersTransferData[1] = flags & 0x7F;
sBattleBuffersTransferData[2] = (arg2 & 0x80) >> 7; sBattleBuffersTransferData[2] = (flags & 0x80) >> 7; // If true, skip delay after drawing. True during intro
sBattleBuffersTransferData[3] = CONTROLLER_DRAWPARTYSTATUSSUMMARY; sBattleBuffersTransferData[3] = CONTROLLER_DRAWPARTYSTATUSSUMMARY;
for (i = 0; i < (s32)(sizeof(struct HpAndStatus) * PARTY_SIZE); i++) for (i = 0; i < (s32)(sizeof(struct HpAndStatus) * PARTY_SIZE); i++)
sBattleBuffersTransferData[4 + i] = *(i + (u8*)(hpAndStatus)); sBattleBuffersTransferData[4 + i] = *(i + (u8*)(hpAndStatus));
@ -1493,7 +1493,7 @@ void BtlController_EmitLinkStandbyMsg(u8 bufferId, u8 arg1, bool32 record)
sBattleBuffersTransferData[1] = arg1; sBattleBuffersTransferData[1] = arg1;
if (record_) if (record_)
sBattleBuffersTransferData[3] = sBattleBuffersTransferData[2] = RecordedBattle_GetAllNewBattlerData(&sBattleBuffersTransferData[4]); sBattleBuffersTransferData[3] = sBattleBuffersTransferData[2] = RecordedBattle_BufferNewBattlerData(&sBattleBuffersTransferData[4]);
else else
sBattleBuffersTransferData[3] = sBattleBuffersTransferData[2] = 0; sBattleBuffersTransferData[3] = sBattleBuffersTransferData[2] = 0;
@ -1513,6 +1513,6 @@ void BtlController_EmitEndLinkBattle(u8 bufferId, u8 battleOutcome)
sBattleBuffersTransferData[1] = battleOutcome; sBattleBuffersTransferData[1] = battleOutcome;
sBattleBuffersTransferData[2] = gSaveBlock2Ptr->frontier.disableRecordBattle; sBattleBuffersTransferData[2] = gSaveBlock2Ptr->frontier.disableRecordBattle;
sBattleBuffersTransferData[3] = gSaveBlock2Ptr->frontier.disableRecordBattle; sBattleBuffersTransferData[3] = gSaveBlock2Ptr->frontier.disableRecordBattle;
sBattleBuffersTransferData[5] = sBattleBuffersTransferData[4] = RecordedBattle_GetAllNewBattlerData(&sBattleBuffersTransferData[6]); sBattleBuffersTransferData[5] = sBattleBuffersTransferData[4] = RecordedBattle_BufferNewBattlerData(&sBattleBuffersTransferData[6]);
PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, sBattleBuffersTransferData[4] + 6); PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, sBattleBuffersTransferData[4] + 6);
} }

View File

@ -39,7 +39,7 @@ extern const struct SpriteTemplate gSpriteTemplate_EnemyShadow;
// this file's functions // this file's functions
static u8 GetBattlePalaceMoveGroup(u16 move); static u8 GetBattlePalaceMoveGroup(u16 move);
static u16 GetBattlePalaceTarget(void); static u16 GetBattlePalaceTarget(void);
static void sub_805D7EC(struct Sprite *sprite); static void SpriteCB_TrainerSlideVertical(struct Sprite *sprite);
static bool8 ShouldAnimBeDoneRegardlessOfSubsitute(u8 animId); static bool8 ShouldAnimBeDoneRegardlessOfSubsitute(u8 animId);
static void Task_ClearBitWhenBattleTableAnimDone(u8 taskId); static void Task_ClearBitWhenBattleTableAnimDone(u8 taskId);
static void Task_ClearBitWhenSpecialAnimDone(u8 taskId); static void Task_ClearBitWhenSpecialAnimDone(u8 taskId);
@ -336,7 +336,8 @@ static u16 GetBattlePalaceTarget(void)
return (gActiveBattler ^ BIT_SIDE) << 8; return (gActiveBattler ^ BIT_SIDE) << 8;
} }
void sub_805D714(struct Sprite *sprite) // Wait for the pokemon to finish appearing out from the pokeball on send out
void SpriteCB_WaitForBattlerBallReleaseAnim(struct Sprite *sprite)
{ {
u8 spriteId = sprite->data[1]; u8 spriteId = sprite->data[1];
@ -369,28 +370,33 @@ void sub_805D770(struct Sprite *sprite, bool8 arg1)
AnimateSprite(sprite); AnimateSprite(sprite);
} }
void sub_805D7AC(struct Sprite *sprite) #define sSpeedX data[0]
void SpriteCB_TrainerSlideIn(struct Sprite *sprite)
{ {
if (!(gIntroSlideFlags & 1)) if (!(gIntroSlideFlags & 1))
{ {
sprite->pos2.x += sprite->data[0]; sprite->pos2.x += sprite->sSpeedX;
if (sprite->pos2.x == 0) if (sprite->pos2.x == 0)
{ {
if (sprite->pos2.y != 0) if (sprite->pos2.y != 0)
sprite->callback = sub_805D7EC; sprite->callback = SpriteCB_TrainerSlideVertical;
else else
sprite->callback = SpriteCallbackDummy; sprite->callback = SpriteCallbackDummy;
} }
} }
} }
static void sub_805D7EC(struct Sprite *sprite) // Slide up to 0 if necessary (used by multi battle intro)
static void SpriteCB_TrainerSlideVertical(struct Sprite *sprite)
{ {
sprite->pos2.y -= 2; sprite->pos2.y -= 2;
if (sprite->pos2.y == 0) if (sprite->pos2.y == 0)
sprite->callback = SpriteCallbackDummy; sprite->callback = SpriteCallbackDummy;
} }
#undef sSpeedX
void InitAndLaunchChosenStatusAnimation(bool8 isStatus2, u32 status) void InitAndLaunchChosenStatusAnimation(bool8 isStatus2, u32 status)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive = 1;
@ -522,14 +528,15 @@ bool8 IsMoveWithoutAnimation(u16 moveId, u8 animationTurn)
return FALSE; return FALSE;
} }
bool8 mplay_80342A4(u8 battlerId) // Check if SE has finished or 30 calls, whichever comes first
bool8 IsBattleSEPlaying(u8 battlerId)
{ {
u8 zero = 0; u8 zero = 0;
if (IsSEPlaying()) if (IsSEPlaying())
{ {
gBattleSpritesDataPtr->healthBoxesData[battlerId].field_8++; gBattleSpritesDataPtr->healthBoxesData[battlerId].soundTimer++;
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_8 < 30) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].soundTimer < 30)
return TRUE; return TRUE;
m4aMPlayStop(&gMPlayInfo_SE1); m4aMPlayStop(&gMPlayInfo_SE1);
@ -537,10 +544,11 @@ bool8 mplay_80342A4(u8 battlerId)
} }
if (zero == 0) if (zero == 0)
{ {
gBattleSpritesDataPtr->healthBoxesData[battlerId].field_8 = 0; gBattleSpritesDataPtr->healthBoxesData[battlerId].soundTimer = 0;
return FALSE; return FALSE;
} }
// Never reached
return TRUE; return TRUE;
} }
@ -660,11 +668,12 @@ void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 battlerId)
} }
} }
void nullsub_23(void) // Unused
static void BattleGfxSfxDummy1(void)
{ {
} }
void nullsub_24(u16 species) void BattleGfxSfxDummy2(u16 species)
{ {
} }
@ -687,7 +696,7 @@ void DecompressTrainerBackPic(u16 backPicId, u8 battlerId)
0x100 + 16 * battlerId, 0x20); 0x100 + 16 * battlerId, 0x20);
} }
void nullsub_25(u8 arg0) void BattleGfxSfxDummy3(u8 gender)
{ {
} }
@ -1110,7 +1119,7 @@ void HandleBattleLowHpMusicChange(void)
} }
} }
void sub_805EB9C(u8 affineMode) void SetBattlerSpriteAffineMode(u8 affineMode)
{ {
s32 i; s32 i;

View File

@ -81,8 +81,8 @@ static void TryCorrectShedinjaLanguage(struct Pokemon *mon);
static u8 CreateNPCTrainerParty(struct Pokemon *party, u16 trainerNum, bool8 firstTrainer); static u8 CreateNPCTrainerParty(struct Pokemon *party, u16 trainerNum, bool8 firstTrainer);
static void BattleMainCB1(void); static void BattleMainCB1(void);
static void sub_8038538(struct Sprite *sprite); static void sub_8038538(struct Sprite *sprite);
static void sub_8038F14(void); static void CB2_EndLinkBattle(void);
static void sub_8038F34(void); static void EndLinkBattleInSteps(void);
static void sub_80392A8(void); static void sub_80392A8(void);
static void sub_803937C(void); static void sub_803937C(void);
static void sub_803939C(void); static void sub_803939C(void);
@ -248,7 +248,7 @@ void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(void);
u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT]; u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
u8 gMultiUsePlayerCursor; u8 gMultiUsePlayerCursor;
u8 gNumberOfMovesToChoose; u8 gNumberOfMovesToChoose;
u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT]; u8 gBattleControllerData[MAX_BATTLERS_COUNT]; // Used by the battle controllers to store misc sprite/task IDs for each battler
// rom const data // rom const data
static const struct ScanlineEffectParams sIntroScanlineParams16Bit = static const struct ScanlineEffectParams sIntroScanlineParams16Bit =
@ -2080,8 +2080,8 @@ static void sub_8038B04(struct Sprite *sprite)
if (sprite->affineAnimEnded) if (sprite->affineAnimEnded)
{ {
FreeSpriteTilesByTag(0x2710); FreeSpriteTilesByTag(ANIM_SPRITES_START);
FreeSpritePaletteByTag(0x2710); FreeSpritePaletteByTag(ANIM_SPRITES_START);
FreeSpriteOamMatrix(sprite); FreeSpriteOamMatrix(sprite);
DestroySprite(sprite); DestroySprite(sprite);
} }
@ -2094,86 +2094,75 @@ void sub_8038B74(struct Sprite *sprite)
PlaySE(SE_MUGSHOT); PlaySE(SE_MUGSHOT);
} }
static void sub_8038B94(u8 taskId) #define BUFFER_PARTY_VS_SCREEN_STATUS(party, flags, i) \
for ((i) = 0; (i) < PARTY_SIZE; (i)++) \
{ \
u16 species = GetMonData(&(party)[(i)], MON_DATA_SPECIES2); \
u16 hp = GetMonData(&(party)[(i)], MON_DATA_HP); \
u32 status = GetMonData(&(party)[(i)], MON_DATA_STATUS); \
\
if (species == SPECIES_NONE) \
continue; \
\
/* Is healthy mon? */ \
if (species != SPECIES_EGG && hp != 0 && status == 0) \
(flags) |= 1 << (i) * 2; \
\
if (species == SPECIES_NONE) /* Redundant */ \
continue; \
\
/* Is Egg or statused? */ \
if (hp != 0 && (species == SPECIES_EGG || status != 0)) \
(flags) |= 2 << (i) * 2; \
\
if (species == SPECIES_NONE) /* Redundant */ \
continue; \
\
/* Is fainted? */ \
if (species != SPECIES_EGG && hp == 0) \
(flags) |= 3 << (i) * 2; \
}
static void LoadPartyDataForLinkVsScreen(u8 taskId)
{ {
struct Pokemon *sp4 = NULL; struct Pokemon *party1 = NULL;
struct Pokemon *sp8 = NULL; struct Pokemon *party2 = NULL;
u8 r2 = gBattleScripting.multiplayerId; u8 multiplayerId = gBattleScripting.multiplayerId;
u32 r7; u32 statusFlags;
s32 i; s32 i;
if (gBattleTypeFlags & BATTLE_TYPE_MULTI) if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
{ {
switch (gLinkPlayers[r2].id) switch (gLinkPlayers[multiplayerId].id)
{ {
case 0: case 0:
case 2: case 2:
sp4 = gPlayerParty; party1 = gPlayerParty;
sp8 = gEnemyParty; party2 = gEnemyParty;
break; break;
case 1: case 1:
case 3: case 3:
sp4 = gEnemyParty; party1 = gEnemyParty;
sp8 = gPlayerParty; party2 = gPlayerParty;
break; break;
} }
} }
else else
{ {
sp4 = gPlayerParty; party1 = gPlayerParty;
sp8 = gEnemyParty; party2 = gEnemyParty;
} }
r7 = 0; statusFlags = 0;
for (i = 0; i < PARTY_SIZE; i++) BUFFER_PARTY_VS_SCREEN_STATUS(party1, statusFlags, i);
{ gTasks[taskId].data[3] = statusFlags;
u16 species = GetMonData(&sp4[i], MON_DATA_SPECIES2);
u16 hp = GetMonData(&sp4[i], MON_DATA_HP);
u32 status = GetMonData(&sp4[i], MON_DATA_STATUS);
if (species == SPECIES_NONE) statusFlags = 0;
continue; BUFFER_PARTY_VS_SCREEN_STATUS(party2, statusFlags, i);
if (species != SPECIES_EGG && hp != 0 && status == 0) gTasks[taskId].data[4] = statusFlags;
r7 |= 1 << i * 2;
if (species == SPECIES_NONE)
continue;
if (hp != 0 && (species == SPECIES_EGG || status != 0))
r7 |= 2 << i * 2;
if (species == SPECIES_NONE)
continue;
if (species != SPECIES_EGG && hp == 0)
r7 |= 3 << i * 2;
}
gTasks[taskId].data[3] = r7;
r7 = 0;
for (i = 0; i < PARTY_SIZE; i++)
{
u16 species = GetMonData(&sp8[i], MON_DATA_SPECIES2);
u16 hp = GetMonData(&sp8[i], MON_DATA_HP);
u32 status = GetMonData(&sp8[i], MON_DATA_STATUS);
if (species == SPECIES_NONE)
continue;
if (species != SPECIES_EGG && hp != 0 && status == 0)
r7 |= 1 << i * 2;
if (species == SPECIES_NONE)
continue;
if (hp != 0 && (species == SPECIES_EGG || status != 0))
r7 |= 2 << i * 2;
if (species == SPECIES_NONE)
continue;
if (species != SPECIES_EGG && hp == 0)
r7 |= 3 << i * 2;
}
gTasks[taskId].data[4] = r7;
} }
void sub_8038D64(void) void CB2_InitEndLinkBattle(void)
{ {
s32 i; s32 i;
u8 taskId; u8 taskId;
@ -2193,12 +2182,12 @@ void sub_8038D64(void)
{ {
CpuFill32(0, (void*)(VRAM), VRAM_SIZE); CpuFill32(0, (void*)(VRAM), VRAM_SIZE);
SetGpuReg(REG_OFFSET_MOSAIC, 0); SetGpuReg(REG_OFFSET_MOSAIC, 0);
SetGpuReg(REG_OFFSET_WIN0H, 0xF0); SetGpuReg(REG_OFFSET_WIN0H, DISPLAY_WIDTH);
SetGpuReg(REG_OFFSET_WIN0V, 0x5051); SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(DISPLAY_HEIGHT / 2, DISPLAY_HEIGHT / 2 + 1));
SetGpuReg(REG_OFFSET_WININ, 0); SetGpuReg(REG_OFFSET_WININ, 0);
SetGpuReg(REG_OFFSET_WINOUT, 0); SetGpuReg(REG_OFFSET_WINOUT, 0);
gBattle_WIN0H = 0xF0; gBattle_WIN0H = DISPLAY_WIDTH;
gBattle_WIN0V = 0x5051; gBattle_WIN0V = WIN_RANGE(DISPLAY_HEIGHT / 2, DISPLAY_HEIGHT / 2 + 1);
ScanlineEffect_Clear(); ScanlineEffect_Clear();
i = 0; i = 0;
@ -2233,24 +2222,26 @@ void sub_8038D64(void)
ResetSpriteData(); ResetSpriteData();
ResetTasks(); ResetTasks();
DrawBattleEntryBackground(); DrawBattleEntryBackground();
SetGpuReg(REG_OFFSET_WINOUT, 0x37); SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR);
FreeAllSpritePalettes(); FreeAllSpritePalettes();
gReservedSpritePaletteCount = 4; gReservedSpritePaletteCount = 4;
SetVBlankCallback(VBlankCB_Battle); SetVBlankCallback(VBlankCB_Battle);
// Show end Vs screen with battle results
taskId = CreateTask(InitLinkBattleVsScreen, 0); taskId = CreateTask(InitLinkBattleVsScreen, 0);
gTasks[taskId].data[1] = 0x10E; gTasks[taskId].data[1] = 0x10E;
gTasks[taskId].data[2] = 0x5A; gTasks[taskId].data[2] = 0x5A;
gTasks[taskId].data[5] = 1; gTasks[taskId].data[5] = 1;
sub_8038B94(taskId); LoadPartyDataForLinkVsScreen(taskId);
SetMainCallback2(sub_8038F14);
SetMainCallback2(CB2_EndLinkBattle);
gBattleCommunication[MULTIUSE_STATE] = 0; gBattleCommunication[MULTIUSE_STATE] = 0;
} }
} }
static void sub_8038F14(void) static void CB2_EndLinkBattle(void)
{ {
sub_8038F34(); EndLinkBattleInSteps();
AnimateSprites(); AnimateSprites();
BuildOamBuffer(); BuildOamBuffer();
RunTextPrinters(); RunTextPrinters();
@ -2258,7 +2249,7 @@ static void sub_8038F14(void)
RunTasks(); RunTasks();
} }
static void sub_8038F34(void) static void EndLinkBattleInSteps(void)
{ {
s32 i; s32 i;
@ -2658,7 +2649,7 @@ static void SpriteCb_WildMonShowHealthbox(struct Sprite *sprite)
{ {
if (sprite->animEnded) if (sprite->animEnded)
{ {
sub_8076918(sprite->sBattler); StartHealthboxSlideIn(sprite->sBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[sprite->sBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[sprite->sBattler]);
sprite->callback = SpriteCb_WildMonAnimate; sprite->callback = SpriteCb_WildMonAnimate;
StartSpriteAnimIfDifferent(sprite, 0); StartSpriteAnimIfDifferent(sprite, 0);
@ -2839,15 +2830,21 @@ static void SpriteCallbackDummy_3(struct Sprite *sprite)
{ {
} }
void sub_8039C00(struct Sprite *sprite) #define sSpeedX data[1]
#define sSpeedY data[2]
void SpriteCB_FaintSlideAnim(struct Sprite *sprite)
{ {
if (!(gIntroSlideFlags & 1)) if (!(gIntroSlideFlags & 1))
{ {
sprite->pos2.x += sprite->data[1]; sprite->pos2.x += sprite->sSpeedX;
sprite->pos2.y += sprite->data[2]; sprite->pos2.y += sprite->sSpeedY;
} }
} }
#undef sSpeedX
#undef sSpeedY
#define sSinIndex data[0] #define sSinIndex data[0]
#define sDelta data[1] #define sDelta data[1]
#define sAmplitude data[2] #define sAmplitude data[2]

View File

@ -5697,14 +5697,14 @@ static u8 GetPartyLayoutFromBattleType(void)
void OpenPartyMenuInBattle(u8 partyAction) void OpenPartyMenuInBattle(u8 partyAction)
{ {
InitPartyMenu(PARTY_MENU_TYPE_IN_BATTLE, GetPartyLayoutFromBattleType(), partyAction, FALSE, PARTY_MSG_CHOOSE_MON, Task_HandleChooseMonInput, CB2_SetUpReshowBattleScreenAfterMenu); InitPartyMenu(PARTY_MENU_TYPE_IN_BATTLE, GetPartyLayoutFromBattleType(), partyAction, FALSE, PARTY_MSG_CHOOSE_MON, Task_HandleChooseMonInput, CB2_SetUpReshowBattleScreenAfterMenu);
nullsub_35(); ReshowBattleScreenDummy();
UpdatePartyToBattleOrder(); UpdatePartyToBattleOrder();
} }
void ChooseMonForInBattleItem(void) void ChooseMonForInBattleItem(void)
{ {
InitPartyMenu(PARTY_MENU_TYPE_IN_BATTLE, GetPartyLayoutFromBattleType(), PARTY_ACTION_USE_ITEM, FALSE, PARTY_MSG_USE_ON_WHICH_MON, Task_HandleChooseMonInput, CB2_ReturnToBagMenu); InitPartyMenu(PARTY_MENU_TYPE_IN_BATTLE, GetPartyLayoutFromBattleType(), PARTY_ACTION_USE_ITEM, FALSE, PARTY_MSG_USE_ON_WHICH_MON, Task_HandleChooseMonInput, CB2_ReturnToBagMenu);
nullsub_35(); ReshowBattleScreenDummy();
UpdatePartyToBattleOrder(); UpdatePartyToBattleOrder();
} }
@ -5753,7 +5753,7 @@ static bool8 TrySwitchInPokemon(void)
StringExpandPlaceholders(gStringVar4, gText_EggCantBattle); StringExpandPlaceholders(gStringVar4, gText_EggCantBattle);
return FALSE; return FALSE;
} }
if (GetPartyIdFromBattleSlot(slot) == gBattleStruct->field_8B) if (GetPartyIdFromBattleSlot(slot) == gBattleStruct->prevSelectedPartySlot)
{ {
GetMonNickname(&gPlayerParty[slot], gStringVar1); GetMonNickname(&gPlayerParty[slot], gStringVar1);
StringExpandPlaceholders(gStringVar4, gText_PkmnAlreadySelected); StringExpandPlaceholders(gStringVar4, gText_PkmnAlreadySelected);

View File

@ -656,7 +656,7 @@ static void Task_PlayCryWhenReleasedFromBall(u8 taskId)
u16 species = gTasks[taskId].tCryTaskSpecies; u16 species = gTasks[taskId].tCryTaskSpecies;
u8 battlerId = gTasks[taskId].tCryTaskBattler; u8 battlerId = gTasks[taskId].tCryTaskBattler;
u8 monSpriteId = gTasks[taskId].tCryTaskMonSpriteId; u8 monSpriteId = gTasks[taskId].tCryTaskMonSpriteId;
struct Pokemon *mon = (void*)(u32)((gTasks[taskId].tCryTaskMonPtr1 << 0x10) | (u16)(gTasks[taskId].tCryTaskMonPtr2)); struct Pokemon *mon = (void*)(u32)((gTasks[taskId].tCryTaskMonPtr1 << 16) | (u16)(gTasks[taskId].tCryTaskMonPtr2));
switch (gTasks[taskId].tCryTaskState) switch (gTasks[taskId].tCryTaskState)
{ {
@ -670,7 +670,7 @@ static void Task_PlayCryWhenReleasedFromBall(u8 taskId)
PlayCry3(species, pan, 0); PlayCry3(species, pan, 0);
else else
PlayCry3(species, pan, 11); PlayCry3(species, pan, 11);
gBattleSpritesDataPtr->healthBoxesData[battlerId].field_1_x40 = 0; gBattleSpritesDataPtr->healthBoxesData[battlerId].waitForCry = FALSE;
DestroyTask(taskId); DestroyTask(taskId);
break; break;
case 2: case 2:
@ -686,7 +686,7 @@ static void Task_PlayCryWhenReleasedFromBall(u8 taskId)
else else
PlayCry4(species, pan, 12); PlayCry4(species, pan, 12);
gBattleSpritesDataPtr->healthBoxesData[battlerId].field_1_x40 = 0; gBattleSpritesDataPtr->healthBoxesData[battlerId].waitForCry = FALSE;
DestroyTask(taskId); DestroyTask(taskId);
} }
else else
@ -725,7 +725,7 @@ static void Task_PlayCryWhenReleasedFromBall(u8 taskId)
else else
PlayCry4(species, pan, 11); PlayCry4(species, pan, 11);
gBattleSpritesDataPtr->healthBoxesData[battlerId].field_1_x40 = 0; gBattleSpritesDataPtr->healthBoxesData[battlerId].waitForCry = FALSE;
DestroyTask(taskId); DestroyTask(taskId);
break; break;
} }
@ -763,7 +763,7 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite)
species = GetMonData(mon, MON_DATA_SPECIES); species = GetMonData(mon, MON_DATA_SPECIES);
if ((battlerId == GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) || battlerId == GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT)) if ((battlerId == GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) || battlerId == GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT))
&& IsDoubleBattle() && gBattleSpritesDataPtr->animationData->field_9_x1) && IsDoubleBattle() && gBattleSpritesDataPtr->animationData->introAnimActive)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK)
{ {
@ -776,14 +776,14 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite)
} }
} }
if (!IsDoubleBattle() || !gBattleSpritesDataPtr->animationData->field_9_x1) if (!IsDoubleBattle() || !gBattleSpritesDataPtr->animationData->introAnimActive)
wantedCryCase = 0; wantedCryCase = 0;
else if (battlerId == GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) || battlerId == GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT)) else if (battlerId == GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) || battlerId == GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT))
wantedCryCase = 1; wantedCryCase = 1;
else else
wantedCryCase = 2; wantedCryCase = 2;
gBattleSpritesDataPtr->healthBoxesData[battlerId].field_1_x40 = 1; gBattleSpritesDataPtr->healthBoxesData[battlerId].waitForCry = TRUE;
taskId = CreateTask(Task_PlayCryWhenReleasedFromBall, 3); taskId = CreateTask(Task_PlayCryWhenReleasedFromBall, 3);
gTasks[taskId].tCryTaskSpecies = species; gTasks[taskId].tCryTaskSpecies = species;
@ -950,7 +950,7 @@ static void SpriteCB_PlayerMonSendOut_2(struct Sprite *sprite)
sprite->sBattler = sprite->oam.affineParam & 0xFF; sprite->sBattler = sprite->oam.affineParam & 0xFF;
sprite->data[0] = 0; sprite->data[0] = 0;
if (IsDoubleBattle() && gBattleSpritesDataPtr->animationData->field_9_x1 if (IsDoubleBattle() && gBattleSpritesDataPtr->animationData->introAnimActive
&& sprite->sBattler == GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT)) && sprite->sBattler == GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT))
sprite->callback = SpriteCB_ReleaseMon2FromBall; sprite->callback = SpriteCB_ReleaseMon2FromBall;
else else
@ -976,7 +976,7 @@ static void SpriteCB_OpponentMonSendOut(struct Sprite *sprite)
if (sprite->data[0] > 15) if (sprite->data[0] > 15)
{ {
sprite->data[0] = 0; sprite->data[0] = 0;
if (IsDoubleBattle() && gBattleSpritesDataPtr->animationData->field_9_x1 if (IsDoubleBattle() && gBattleSpritesDataPtr->animationData->introAnimActive
&& sprite->sBattler == GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT)) && sprite->sBattler == GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT))
sprite->callback = SpriteCB_ReleaseMon2FromBall; sprite->callback = SpriteCB_ReleaseMon2FromBall;
else else
@ -1181,7 +1181,7 @@ static void Unref_DestroySpriteAndFreeResources(struct Sprite *sprite)
DestroySpriteAndFreeResources(sprite); DestroySpriteAndFreeResources(sprite);
} }
void sub_8076918(u8 battlerId) void StartHealthboxSlideIn(u8 battlerId)
{ {
struct Sprite *healthboxSprite = &gSprites[gHealthboxSpriteIds[battlerId]]; struct Sprite *healthboxSprite = &gSprites[gHealthboxSpriteIds[battlerId]];

View File

@ -75,9 +75,9 @@ struct RecordedBattleSave
EWRAM_DATA u32 gRecordedBattleRngSeed = 0; EWRAM_DATA u32 gRecordedBattleRngSeed = 0;
EWRAM_DATA u32 gBattlePalaceMoveSelectionRngValue = 0; EWRAM_DATA u32 gBattlePalaceMoveSelectionRngValue = 0;
EWRAM_DATA static u8 sBattleRecords[MAX_BATTLERS_COUNT][BATTLER_RECORD_SIZE] = {0}; EWRAM_DATA static u8 sBattleRecords[MAX_BATTLERS_COUNT][BATTLER_RECORD_SIZE] = {0};
EWRAM_DATA static u16 sRecordedBytesNo[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA static u16 sBattlerRecordSizes[MAX_BATTLERS_COUNT] = {0};
EWRAM_DATA static u16 sPrevRecordedBytesNo[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA static u16 sBattlerPrevRecordSizes[MAX_BATTLERS_COUNT] = {0};
EWRAM_DATA static u16 sUnknown_0203C7A4[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA static u16 sBattlerSavedRecordSizes[MAX_BATTLERS_COUNT] = {0};
EWRAM_DATA static u8 sRecordMode = 0; EWRAM_DATA static u8 sRecordMode = 0;
EWRAM_DATA static u8 sLvlMode = 0; EWRAM_DATA static u8 sLvlMode = 0;
EWRAM_DATA static u8 sFrontierFacility = 0; EWRAM_DATA static u8 sFrontierFacility = 0;
@ -103,8 +103,7 @@ EWRAM_DATA static u8 sBattleOutcome = 0;
static u8 sRecordMixFriendLanguage; static u8 sRecordMixFriendLanguage;
static u8 sApprenticeLanguage; static u8 sApprenticeLanguage;
// this file's functions static u8 GetNextRecordedDataByte(u8 *, u8 *, u8 *);
static u8 sub_8185278(u8 *, u8 *, u8 *);
static bool32 CopyRecordedBattleFromSave(struct RecordedBattleSave *); static bool32 CopyRecordedBattleFromSave(struct RecordedBattleSave *);
static void RecordedBattle_RestoreSavedParties(void); static void RecordedBattle_RestoreSavedParties(void);
static void CB2_RecordedBattle(void); static void CB2_RecordedBattle(void);
@ -118,9 +117,9 @@ void RecordedBattle_Init(u8 mode)
for (i = 0; i < MAX_BATTLERS_COUNT; i++) for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{ {
sRecordedBytesNo[i] = 0; sBattlerRecordSizes[i] = 0;
sPrevRecordedBytesNo[i] = 0; sBattlerPrevRecordSizes[i] = 0;
sUnknown_0203C7A4[i] = 0; sBattlerSavedRecordSizes[i] = 0;
if (mode == B_RECORD_MODE_RECORDING) if (mode == B_RECORD_MODE_RECORDING)
{ {
@ -195,9 +194,9 @@ void sub_8184E58(void)
void RecordedBattle_SetBattlerAction(u8 battlerId, u8 action) void RecordedBattle_SetBattlerAction(u8 battlerId, u8 action)
{ {
if (sRecordedBytesNo[battlerId] < BATTLER_RECORD_SIZE && sRecordMode != B_RECORD_MODE_PLAYBACK) if (sBattlerRecordSizes[battlerId] < BATTLER_RECORD_SIZE && sRecordMode != B_RECORD_MODE_PLAYBACK)
{ {
sBattleRecords[battlerId][sRecordedBytesNo[battlerId]++] = action; sBattleRecords[battlerId][sBattlerRecordSizes[battlerId]++] = action;
} }
} }
@ -207,9 +206,9 @@ void RecordedBattle_ClearBattlerAction(u8 battlerId, u8 bytesToClear)
for (i = 0; i < bytesToClear; i++) for (i = 0; i < bytesToClear; i++)
{ {
sRecordedBytesNo[battlerId]--; sBattlerRecordSizes[battlerId]--;
sBattleRecords[battlerId][sRecordedBytesNo[battlerId]] = 0xFF; sBattleRecords[battlerId][sBattlerRecordSizes[battlerId]] = 0xFF;
if (sRecordedBytesNo[battlerId] == 0) if (sBattlerRecordSizes[battlerId] == 0)
break; break;
} }
} }
@ -217,7 +216,7 @@ void RecordedBattle_ClearBattlerAction(u8 battlerId, u8 bytesToClear)
u8 RecordedBattle_GetBattlerAction(u8 battlerId) u8 RecordedBattle_GetBattlerAction(u8 battlerId)
{ {
// Trying to read past array or invalid action byte, battle is over. // Trying to read past array or invalid action byte, battle is over.
if (sRecordedBytesNo[battlerId] >= BATTLER_RECORD_SIZE || sBattleRecords[battlerId][sRecordedBytesNo[battlerId]] == 0xFF) if (sBattlerRecordSizes[battlerId] >= BATTLER_RECORD_SIZE || sBattleRecords[battlerId][sBattlerRecordSizes[battlerId]] == 0xFF)
{ {
gSpecialVar_Result = gBattleOutcome = B_OUTCOME_PLAYER_TELEPORTED; // hah gSpecialVar_Result = gBattleOutcome = B_OUTCOME_PLAYER_TELEPORTED; // hah
ResetPaletteFadeControl(); ResetPaletteFadeControl();
@ -227,7 +226,7 @@ u8 RecordedBattle_GetBattlerAction(u8 battlerId)
} }
else else
{ {
return sBattleRecords[battlerId][sRecordedBytesNo[battlerId]++]; return sBattleRecords[battlerId][sBattlerRecordSizes[battlerId]++];
} }
} }
@ -237,35 +236,35 @@ static u8 GetRecordedBattleMode(void)
return sRecordMode; return sRecordMode;
} }
u8 RecordedBattle_GetAllNewBattlerData(u8 *dst) u8 RecordedBattle_BufferNewBattlerData(u8 *dst)
{ {
u8 i, j; u8 i, j;
u8 idx = 0; u8 idx = 0;
for (i = 0; i < MAX_BATTLERS_COUNT; i++) for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{ {
if (sRecordedBytesNo[i] != sPrevRecordedBytesNo[i]) if (sBattlerRecordSizes[i] != sBattlerPrevRecordSizes[i])
{ {
dst[idx++] = i; dst[idx++] = i;
dst[idx++] = sRecordedBytesNo[i] - sPrevRecordedBytesNo[i]; dst[idx++] = sBattlerRecordSizes[i] - sBattlerPrevRecordSizes[i];
for (j = 0; j < sRecordedBytesNo[i] - sPrevRecordedBytesNo[i]; j++) for (j = 0; j < sBattlerRecordSizes[i] - sBattlerPrevRecordSizes[i]; j++)
{ {
dst[idx++] = sBattleRecords[i][sPrevRecordedBytesNo[i] + j]; dst[idx++] = sBattleRecords[i][sBattlerPrevRecordSizes[i] + j];
} }
sPrevRecordedBytesNo[i] = sRecordedBytesNo[i]; sBattlerPrevRecordSizes[i] = sBattlerRecordSizes[i];
} }
} }
return idx; return idx;
} }
void sub_81851A8(u8 *arg0) void RecordedBattle_RecordAllBattlerData(u8 *src)
{ {
s32 i; s32 i;
u8 var1 = 2; u8 idx = 2;
u8 var2; u8 size;
if (!(gBattleTypeFlags & BATTLE_TYPE_LINK)) if (!(gBattleTypeFlags & BATTLE_TYPE_LINK))
return; return;
@ -278,23 +277,23 @@ void sub_81851A8(u8 *arg0)
if (!(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER)) if (!(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER))
{ {
for (var2 = *arg0; var2 != 0;) for (size = *src; size != 0;)
{ {
u8 unkVar = sub_8185278(arg0, &var1, &var2); u8 battlerId = GetNextRecordedDataByte(src, &idx, &size);
u8 unkVar2 = sub_8185278(arg0, &var1, &var2); u8 numActions = GetNextRecordedDataByte(src, &idx, &size);
for (i = 0; i < unkVar2; i++) for (i = 0; i < numActions; i++)
{ {
sBattleRecords[unkVar][sUnknown_0203C7A4[unkVar]++] = sub_8185278(arg0, &var1, &var2); sBattleRecords[battlerId][sBattlerSavedRecordSizes[battlerId]++] = GetNextRecordedDataByte(src, &idx, &size);
} }
} }
} }
} }
static u8 sub_8185278(u8 *arg0, u8 *arg1, u8 *arg2) static u8 GetNextRecordedDataByte(u8 *data, u8 *idx, u8 *size)
{ {
(*arg2)--; (*size)--;
return arg0[(*arg1)++]; return data[(*idx)++];
} }
bool32 CanCopyRecordedBattleSaveData(void) bool32 CanCopyRecordedBattleSaveData(void)
@ -768,7 +767,7 @@ void sub_818603C(u8 arg0)
} }
else else
{ {
if (sBattleRecords[battlerId][sRecordedBytesNo[battlerId]] == ACTION_MOVE_CHANGE) if (sBattleRecords[battlerId][sBattlerRecordSizes[battlerId]] == ACTION_MOVE_CHANGE)
{ {
u8 ppBonuses[MAX_MON_MOVES]; u8 ppBonuses[MAX_MON_MOVES];
u8 array1[MAX_MON_MOVES]; u8 array1[MAX_MON_MOVES];

View File

@ -23,7 +23,7 @@ static void CreateBattlerSprite(u8 battlerId);
static void CreateHealthboxSprite(u8 battlerId); static void CreateHealthboxSprite(u8 battlerId);
static void sub_80A95F4(void); static void sub_80A95F4(void);
void nullsub_35(void) void ReshowBattleScreenDummy(void)
{ {
} }