Merge pull request #1314 from GriffinRichards/doc-controllers

Document battle controllers, misc other battle
This commit is contained in:
GriffinR 2021-02-02 00:24:16 -05:00 committed by GitHub
commit 64460e01ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
56 changed files with 1676 additions and 1605 deletions

View File

@ -503,7 +503,7 @@
.byte \battler
.endm
.macro atk57
.macro endlinkbattle
.byte 0x57
.endm

View File

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

View File

@ -2989,7 +2989,7 @@ BattleScript_LocalBattleLostDoTrainer2WinText::
BattleScript_LocalBattleLostEnd_::
end2
BattleScript_82DAA0B::
BattleScript_FrontierLinkBattleLost::
returnopponentmon1toball BS_ATTACKER
waitstate
returnopponentmon2toball BS_ATTACKER
@ -3002,23 +3002,23 @@ BattleScript_82DAA0B::
trainerslidein BS_FAINTED
waitstate
printstring STRINGID_TRAINER2WINTEXT
jumpifbattletype BATTLE_TYPE_RECORDED, BattleScript_82DAA31
atk57
BattleScript_82DAA31::
jumpifbattletype BATTLE_TYPE_RECORDED, BattleScript_FrontierLinkBattleLostEnd
endlinkbattle
BattleScript_FrontierLinkBattleLostEnd::
waitmessage 0x40
end2
BattleScript_LinkBattleWonOrLost::
jumpifbattletype BATTLE_TYPE_BATTLE_TOWER, BattleScript_82DAA5C
jumpifbattletype BATTLE_TYPE_BATTLE_TOWER, BattleScript_TowerLinkBattleWon
printstring STRINGID_BATTLEEND
waitmessage 0x40
jumpifbattletype BATTLE_TYPE_RECORDED, BattleScript_LinkBattleWonOrLostWaitEnd
atk57
endlinkbattle
BattleScript_LinkBattleWonOrLostWaitEnd::
waitmessage 0x40
end2
BattleScript_82DAA5C::
BattleScript_TowerLinkBattleWon::
playtrainerdefeatbgm BS_ATTACKER
printstring STRINGID_BATTLEEND
waitmessage 0x40
@ -3030,9 +3030,9 @@ BattleScript_82DAA5C::
trainerslidein BS_FAINTED
waitstate
printstring STRINGID_TRAINER2LOSETEXT
jumpifbattletype BATTLE_TYPE_RECORDED, BattleScript_82DAA83
atk57
BattleScript_82DAA83::
jumpifbattletype BATTLE_TYPE_RECORDED, BattleScript_TowerLinkBattleWonEnd
endlinkbattle
BattleScript_TowerLinkBattleWonEnd::
waitmessage 0x40
end2
@ -4566,6 +4566,6 @@ BattleScript_PrintPlayerForfeited::
BattleScript_PrintPlayerForfeitedLinkBattle::
printstring STRINGID_FORFEITEDMATCH
waitmessage 0x40
atk57
endlinkbattle
waitmessage 0x40
end2

View File

@ -385,7 +385,7 @@ struct BattleStruct
u8 chosenMovePositions[MAX_BATTLERS_COUNT];
u8 stateIdAfterSelScript[MAX_BATTLERS_COUNT];
u8 unused_3[3];
u8 field_8B; // related to player's pokemon switching
u8 prevSelectedPartySlot;
u8 unused_4[2];
u8 stringMoveType;
u8 expGetterBattlerId;
@ -421,8 +421,8 @@ struct BattleStruct
u16 castformPalette[MAX_BATTLERS_COUNT][16];
u8 field_180; // weird field, used in battle_main.c, once accessed as an array of u32 overwriting the field below
u8 field_181;
u8 field_182;
u8 field_183;
u8 vsScreenHealthFlagsLo;
u8 vsScreenHealthFlagsHi; // Last bit is 'has frontier pass'
struct BattleEnigmaBerry battleEnigmaBerry;
u8 wishPerishSongState;
u8 wishPerishSongBattlerId;
@ -523,7 +523,7 @@ struct BattleAnimationInfo
u8 field_6;
u8 field_7;
u8 ballThrowCaseId;
u8 field_9_x1:1;
u8 introAnimActive:1;
u8 wildMonInvisible:1;
u8 field_9_x1C:3;
u8 field_9_x20:1;
@ -548,17 +548,17 @@ struct BattleHealthboxInfo
u8 triedShinyMonAnim:1;
u8 finishedShinyMonAnim:1;
u8 field_1_x1E:4;
u8 field_1_x20:1;
u8 field_1_x40:1;
u8 field_1_x80:1;
u8 bgmRestored:1;
u8 waitForCry:1;
u8 healthboxSlideInStarted:1;
u8 healthboxBounceSpriteId;
u8 battlerBounceSpriteId;
u8 animationState;
u8 field_5;
u8 partyStatusDelayTimer;
u8 matrixNum;
u8 shadowSpriteId;
u8 field_8;
u8 field_9;
u8 soundTimer;
u8 introEndDelay;
u8 field_A;
u8 field_B;
};
@ -617,7 +617,7 @@ extern u8 gBattleTextBuff2[TEXT_BUFF_ARRAY_COUNT];
extern u8 gBattleTextBuff3[TEXT_BUFF_ARRAY_COUNT];
extern u32 gBattleTypeFlags;
extern u8 gBattleTerrain;
extern u32 gUnknown_02022FF4;
extern u32 gUnusedFirstBattleVar1;
extern u8 *gUnknown_0202305C;
extern u8 *gUnknown_02023060;
extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200];
@ -667,7 +667,7 @@ extern u16 gChosenMoveByBattler[MAX_BATTLERS_COUNT];
extern u8 gMoveResultFlags;
extern u32 gHitMarker;
extern u8 gTakenDmgByBattler[MAX_BATTLERS_COUNT];
extern u8 gUnknown_0202428C;
extern u8 gUnusedFirstBattleVar2;
extern u16 gSideStatuses[2];
extern struct SideTimer gSideTimers[2];
extern u32 gStatuses3[MAX_BATTLERS_COUNT];
@ -700,8 +700,8 @@ extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT];
extern u8 gPlayerDpadHoldFrames;
extern struct BattleSpriteData *gBattleSpritesDataPtr;
extern struct MonSpritesGfx *gMonSpritesGfxPtr;
extern struct BattleHealthboxInfo *gUnknown_020244D8;
extern struct BattleHealthboxInfo *gUnknown_020244DC;
extern struct BattleHealthboxInfo *gBattleControllerOpponentHealthboxData;
extern struct BattleHealthboxInfo *gBattleControllerOpponentFlankHealthboxData;
extern u16 gBattleMovePower;
extern u16 gMoveToLearn;
extern u8 gBattleMonForms[MAX_BATTLERS_COUNT];
@ -714,6 +714,6 @@ extern void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(void);
extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gMultiUsePlayerCursor;
extern u8 gNumberOfMovesToChoose;
extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT];
extern u8 gBattleControllerData[MAX_BATTLERS_COUNT];
#endif // GUARD_BATTLE_H

View File

@ -90,7 +90,7 @@ void InitAnimArcTranslation(struct Sprite *sprite);
bool8 AnimTranslateLinear(struct Sprite *sprite);
void TranslateAnimSpriteToTargetMonLocation(struct Sprite *sprite);
u8 GetBattlerSpriteCoord2(u8 battlerId, u8 attributeId);
void sub_80A6FD4(struct Sprite *sprite);
void InitAnimLinearTranslationWithSpeed(struct Sprite *sprite);
u16 ArcTan2Neg(s16 a, s16 b);
void TrySetSpriteRotScale(struct Sprite *sprite, bool8 a2, s16 xScale, s16 yScale, u16 rotation);
void RunStoredCallbackWhenAffineAnimEnds(struct Sprite *sprite);
@ -103,7 +103,7 @@ u8 GetBattlerYCoordWithElevation(u8 battlerId);
void WaitAnimForDuration(struct Sprite *sprite);
void AnimTravelDiagonally(struct Sprite *sprite);
void InitAnimLinearTranslation(struct Sprite *sprite);
void sub_80A6F98(struct Sprite *sprite);
void AnimTranslateLinear_WaitEnd(struct Sprite *sprite);
u8 GetBattlerSpriteBGPriority(u8 battlerId);
void *LoadPointerFromVars(s16 bottom, s16 top);
void StorePointerInVars(s16 *bottom, s16 *top, const void *ptr);
@ -121,7 +121,7 @@ void PrepareBattlerSpriteForRotScale(u8 spriteId, u8 objMode);
void SetBattlerSpriteYOffsetFromRotation(u8 spriteId);
u32 sub_80A75AC(u8 a1, u8 a2, u8 a3, u8 a4, u8 a5, u8 a6, u8 a7);
u32 sub_80A76C4(u8 a1, u8 a2, u8 a3, u8 a4);
u8 sub_80A77AC(u8 a1);
u8 AnimDummyReturnArg(u8 battler);
s16 CloneBattlerSpriteWithBlend(u8);
void obj_delete_but_dont_free_vram(struct Sprite*);
u8 sub_80A89C8(int, u8, int);
@ -141,14 +141,14 @@ void InitAndRunAnimFastLinearTranslation(struct Sprite *sprite);
void TranslateMonSpriteLinear(struct Sprite *sprite);
void TranslateSpriteLinear(struct Sprite *sprite);
void AnimSpriteOnMonPos(struct Sprite *sprite);
void sub_80A7000(struct Sprite *sprite);
void InitAnimLinearTranslationWithSpeedAndPos(struct Sprite *sprite);
void TranslateSpriteInCircleOverDuration(struct Sprite *sprite);
void SetGreyscaleOrOriginalPalette(u16 palNum, bool8 restoreOriginal);
void PrepareAffineAnimInTaskData(struct Task *task, u8 spriteId, const union AffineAnimCmd *affineAnimCmds);
bool8 RunAffineAnimFromTaskData(struct Task *task);
void AnimThrowProjectile(struct Sprite *sprite);
void sub_80A6BFC(struct BattleAnimBgData *unk, u8 unused);
u8 sub_80A8394(u16 species, bool8 isBackpic, u8 a3, s16 x, s16 y, u8 subpriority, u32 personality, u32 trainerId, u32 battlerId, u32 a10);
u8 CreateAdditionalMonSpriteForMoveAnim(u16 species, bool8 isBackpic, u8 a3, s16 x, s16 y, u8 subpriority, u32 personality, u32 trainerId, u32 battlerId, bool32 ignoreDeoxysForm);
void sub_80A749C(struct Sprite *sprite);
void TradeMenuBouncePartySprites(struct Sprite *sprite);
void DestroyAnimVisualTaskAndDisableBlend(u8 taskId);
@ -158,7 +158,7 @@ u8 GetBattlerSide(u8 battler);
u8 GetBattlerPosition(u8 battler);
u8 GetBattlerAtPosition(u8 position);
void sub_80A64EC(struct Sprite *sprite);
void sub_80A718C(struct Sprite *sprite);
void InitAnimFastLinearTranslationWithSpeedAndPos(struct Sprite *sprite);
enum
{

View File

@ -133,7 +133,7 @@ enum
CONTROLLER_PRINTSTRING,
CONTROLLER_PRINTSTRINGPLAYERONLY,
CONTROLLER_CHOOSEACTION,
CONTROLLER_UNKNOWNYESNOBOX,
CONTROLLER_YESNOBOX,
CONTROLLER_CHOOSEMOVE,
CONTROLLER_OPENBAG,
CONTROLLER_CHOOSEPOKEMON,
@ -169,7 +169,7 @@ enum
CONTROLLER_BATTLEANIMATION,
CONTROLLER_LINKSTANDBYMSG,
CONTROLLER_RESETACTIONMOVESELECTION,
CONTROLLER_55,
CONTROLLER_ENDLINKBATTLE,
/*new controllers should go here*/
CONTROLLER_TERMINATOR_NOP,
CONTROLLER_CMDS_COUNT
@ -180,8 +180,8 @@ extern struct UnusedControllerStruct gUnusedControllerStruct;
// general functions
void HandleLinkBattleSetup(void);
void SetUpBattleVarsAndBirchZigzagoon(void);
void sub_8032768(void);
void sub_8033648(void);
void InitBattleControllers(void);
void TryReceiveLinkBattleData(void);
void PrepareBufferDataTransferLink(u8 bufferId, u16 size, u8 *data);
// emitters
@ -204,7 +204,7 @@ void BtlController_EmitMoveAnimation(u8 bufferId, u16 move, u8 turnOfMove, u16 m
void BtlController_EmitPrintString(u8 bufferId, u16 stringId);
void BtlController_EmitPrintSelectionString(u8 bufferId, u16 stringId);
void BtlController_EmitChooseAction(u8 bufferId, u8 arg1, u16 arg2);
void BtlController_EmitUnknownYesNoBox(u8 bufferId);
void BtlController_EmitYesNoBox(u8 bufferId);
void BtlController_EmitChooseMove(u8 bufferId, bool8 isDoubleBattle, bool8 NoPpNumber, struct ChooseMoveStruct *movePpData);
void BtlController_EmitChooseItem(u8 bufferId, u8* arg1);
void BtlController_EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 abilityId, u8* arg4);
@ -238,19 +238,19 @@ void BtlController_EmitHidePartyStatusSummary(u8 bufferId);
void BtlController_EmitEndBounceEffect(u8 bufferId);
void BtlController_EmitSpriteInvisibility(u8 bufferId, bool8 isInvisible);
void BtlController_EmitBattleAnimation(u8 bufferId, u8 animationId, u16 argument);
void BtlController_EmitLinkStandbyMsg(u8 bufferId, u8 arg1, bool32 arg2);
void BtlController_EmitLinkStandbyMsg(u8 bufferId, u8 arg1, bool32 record);
void BtlController_EmitResetActionMoveSelection(u8 bufferId, u8 caseId);
void BtlController_EmitCmd55(u8 bufferId, u8 battleOutcome);
void BtlController_EmitEndLinkBattle(u8 bufferId, u8 battleOutcome);
// player controller
void SetControllerToPlayer(void);
void nullsub_21(void);
void BattleControllerDummy(void);
void PlayerHandleGetRawMonData(void);
void sub_80587B0(void);
void sub_805CC00(struct Sprite *sprite);
void SetBattleEndCallbacks(void);
void SpriteCB_FreePlayerSpriteLoadMonSprite(struct Sprite *sprite);
void CB2_SetUpReshowBattleScreenAfterMenu(void);
void CB2_SetUpReshowBattleScreenAfterMenu2(void);
void c3_0802FDF4(u8 taskId);
void Task_PlayerController_RestoreBgmAfterCry(u8 taskId);
void ActionSelectionCreateCursorAt(u8 cursorPos, u8 unused);
void ActionSelectionDestroyCursorAt(u8 cursorPos);
void InitMoveSelectionsVarsAndStrings(void);

View File

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

View File

@ -49,27 +49,26 @@ void CB2_QuitRecordedBattle(void);
void sub_8038528(struct Sprite* sprite);
void sub_8038A04(void); // unused
void VBlankCB_Battle(void);
void nullsub_17(struct Sprite *sprite);
void sub_8038B74(struct Sprite *sprite);
void sub_8038D64(void);
u32 sub_80391E0(u8 arrayId, u8 caseId);
u32 sub_80397C4(u32 setId, u32 tableId);
void SpriteCB_VsLetterDummy(struct Sprite *sprite);
void SpriteCB_VsLetterInit(struct Sprite *sprite);
void CB2_InitEndLinkBattle(void);
u32 GetBattleBgTemplateData(u8 arrayId, u8 caseId);
u32 GetBattleWindowTemplatePixelWidth(u32 setId, u32 tableId);
void SpriteCb_WildMon(struct Sprite *sprite);
void SpriteCallbackDummy_2(struct Sprite *sprite);
void SpriteCB_FaintOpponentMon(struct Sprite *sprite);
void SpriteCb_ShowAsMoveTarget(struct Sprite *sprite);
void SpriteCb_HideAsMoveTarget(struct Sprite *sprite);
void SpriteCb_OpponentMonFromBall(struct Sprite *sprite);
void sub_8039BB4(struct Sprite *sprite);
void sub_80105DC(struct Sprite *sprite);
void sub_8039C00(struct Sprite *sprite);
void SpriteCB_BattleSpriteStartSlideLeft(struct Sprite *sprite);
void SpriteCB_FaintSlideAnim(struct Sprite *sprite);
void DoBounceEffect(u8 battlerId, u8 b, s8 c, s8 d);
void EndBounceEffect(u8 battlerId, bool8 b);
void SpriteCb_PlayerMonFromBall(struct Sprite *sprite);
void sub_8039E60(struct Sprite *sprite);
void SpriteCB_TrainerThrowObject(struct Sprite *sprite);
void sub_8039E9C(struct Sprite *sprite);
void nullsub_20(void);
void BeginBattleIntroDummy(void);
void BeginBattleIntro(void);
void SwitchInClearSetData(void);
void FaintClearSetData(void);
@ -86,8 +85,8 @@ void SpecialStatusesClear(void);
extern struct UnknownPokemonStruct4 gMultiPartnerParty[MULTI_PARTY_SIZE];
extern const struct SpriteTemplate gUnknown_0831AC88;
extern const struct OamData gOamData_831ACA8;
extern const struct OamData gOamData_831ACB0;
extern const struct OamData gOamData_BattleSpriteOpponentSide;
extern const struct OamData gOamData_BattleSpritePlayerSide;
extern const u8 gTypeEffectiveness[336];
extern const u8 gTypeNames[NUMBER_OF_MON_TYPES][TYPE_NAME_LENGTH + 1];
extern const struct TrainerMoney gTrainerMoneyTable[];

View File

@ -207,7 +207,7 @@ extern const u8 BattleScript_ActionSelectionItemsCantBeUsed[];
extern const u8 BattleScript_ArenaTurnBeginning[];
extern const u8 BattleScript_PalacePrintFlavorText[];
extern const u8 BattleScript_ArenaDoJudgment[];
extern const u8 BattleScript_82DAA0B[];
extern const u8 BattleScript_FrontierLinkBattleLost[];
extern const u8 BattleScript_AskIfWantsToForfeitMatch[];
extern const u8 BattleScript_PrintPlayerForfeited[];
extern const u8 BattleScript_PrintPlayerForfeitedLinkBattle[];

View File

@ -60,7 +60,7 @@ void PressurePPLoseOnUsingPerishSong(u8 attacker);
void PressurePPLoseOnUsingImprison(u8 attacker);
void MarkAllBattlersForControllerExec(void); // unused
void MarkBattlerForControllerExec(u8 battlerId);
void sub_803F850(u8 arg0);
void MarkBattlerReceivedLinkData(u8 arg0);
void CancelMultiTurnMoves(u8 battlerId);
bool8 WasUnableToUseMove(u8 battlerId);
void PrepareStringBattle(u16 stringId, u8 battlerId);

View File

@ -69,13 +69,13 @@ struct Trainer
#define TRAINER_ENCOUNTER_MUSIC(trainer)((gTrainers[trainer].encounterMusic_gender & 0x7F))
extern const u16 gUnknown_082FF1D8[];
extern const u32 gUnknown_082FF1F8[];
extern const u16 gMinigameDigits_Pal[];
extern const u32 gMinigameDigits_Gfx[];
extern const struct SpriteFrameImage gUnknown_082FF3A8[];
extern const struct SpriteFrameImage gUnknown_082FF3C8[];
extern const struct SpriteFrameImage gUnknown_082FF3E8[];
extern const struct SpriteFrameImage gUnknown_082FF408[];
extern const struct SpriteFrameImage gBattlerPicTable_PlayerLeft[];
extern const struct SpriteFrameImage gBattlerPicTable_OpponentLeft[];
extern const struct SpriteFrameImage gBattlerPicTable_PlayerRight[];
extern const struct SpriteFrameImage gBattlerPicTable_OpponentRight[];
extern const struct SpriteFrameImage gTrainerBackPicTable_Brendan[];
extern const struct SpriteFrameImage gTrainerBackPicTable_May[];
extern const struct SpriteFrameImage gTrainerBackPicTable_Red[];
@ -85,8 +85,8 @@ extern const struct SpriteFrameImage gTrainerBackPicTable_RubySapphireMay[];
extern const struct SpriteFrameImage gTrainerBackPicTable_Wally[];
extern const struct SpriteFrameImage gTrainerBackPicTable_Steven[];
extern const union AffineAnimCmd *const gUnknown_082FF618[];
extern const union AffineAnimCmd *const gUnknown_082FF694[];
extern const union AffineAnimCmd *const gAffineAnims_BattleSpritePlayerSide[];
extern const union AffineAnimCmd *const gAffineAnims_BattleSpriteOpponentSide[];
extern const union AffineAnimCmd *const gUnknown_082FF6C0[];
extern const union AnimCmd *const gUnknown_082FF70C[];

View File

@ -34,7 +34,7 @@ extern const struct SpriteTemplate gBallSpriteTemplates[];
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);
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 LoadBallGfx(u8 ballId);
void FreeBallGfx(u8 ballId);

View File

@ -266,7 +266,7 @@ extern const u8 gPPUpSetMask[];
extern const u8 gPPUpAddMask[];
extern const u8 gStatStageRatios[MAX_STAT_STAGE + 1][2];
extern const u16 gLinkPlayerFacilityClasses[];
extern const struct SpriteTemplate gUnknown_08329D98[];
extern const struct SpriteTemplate gBattlerSpriteTemplates[];
extern const s8 gNatureStatTable[][5];
void ZeroBoxMonData(struct BoxPokemon *boxMon);
@ -287,7 +287,7 @@ void CreateApprenticeMon(struct Pokemon *mon, const struct Apprentice *src, u8 m
void CreateMonWithEVSpreadNatureOTID(struct Pokemon *mon, u16 species, u8 level, u8 nature, u8 fixedIV, u8 evSpread, u32 otId);
void ConvertPokemonToBattleTowerPokemon(struct Pokemon *mon, struct BattleTowerPokemon *dest);
void CreateObedientMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId);
bool8 sub_80688F8(u8 caseId, u8 battlerId);
bool8 ShouldIgnoreDeoxysForm(u8 caseId, u8 battlerId);
void SetDeoxysStats(void);
u16 GetUnionRoomTrainerPic(void);
u16 GetUnionRoomTrainerClass(void);

View File

@ -5,14 +5,16 @@ extern u32 gRecordedBattleRngSeed;
extern u32 gBattlePalaceMoveSelectionRngValue;
extern u8 gRecordedBattleMultiplayerId;
void sub_8184DA4(u8 arg0);
#define B_RECORD_MODE_RECORDING 1
#define B_RECORD_MODE_PLAYBACK 2
void RecordedBattle_Init(u8 arg0);
void sub_8184E58(void);
void RecordedBattle_SetBattlerAction(u8 battlerId, u8 action);
void RecordedBattle_ClearBattlerAction(u8 battlerId, u8 bytesToClear);
u8 RecordedBattle_GetBattlerAction(u8 battlerId);
u8 sub_81850D0(void);
u8 sub_81850DC(u8 *arg0);
void sub_81851A8(u8 *arg0);
u8 RecordedBattle_BufferNewBattlerData(u8 *dst);
void RecordedBattle_RecordAllBattlerData(u8 *data);
bool32 CanCopyRecordedBattleSaveData(void);
bool32 MoveRecordedBattleToSaveData(void);
void PlayRecordedBattle(void (*CB2_After)(void));

View File

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

View File

@ -95,16 +95,16 @@ static void Cmd_if_equal_(void);
static void Cmd_if_not_equal_(void);
static void Cmd_if_user_goes(void);
static void Cmd_if_user_doesnt_go(void);
static void Cmd_nullsub_2A(void);
static void Cmd_nullsub_2B(void);
static void Cmd_nop_2A(void);
static void Cmd_nop_2B(void);
static void Cmd_count_usable_party_mons(void);
static void Cmd_get_considered_move(void);
static void Cmd_get_considered_move_effect(void);
static void Cmd_get_ability(void);
static void Cmd_get_highest_type_effectiveness(void);
static void Cmd_if_type_effectiveness(void);
static void Cmd_nullsub_32(void);
static void Cmd_nullsub_33(void);
static void Cmd_nop_32(void);
static void Cmd_nop_33(void);
static void Cmd_if_status_in_party(void);
static void Cmd_if_status_not_in_party(void);
static void Cmd_get_weather(void);
@ -135,12 +135,12 @@ static void Cmd_get_move_type_from_result(void);
static void Cmd_get_move_power_from_result(void);
static void Cmd_get_move_effect_from_result(void);
static void Cmd_get_protect_count(void);
static void Cmd_nullsub_52(void);
static void Cmd_nullsub_53(void);
static void Cmd_nullsub_54(void);
static void Cmd_nullsub_55(void);
static void Cmd_nullsub_56(void);
static void Cmd_nullsub_57(void);
static void Cmd_nop_52(void);
static void Cmd_nop_53(void);
static void Cmd_nop_54(void);
static void Cmd_nop_55(void);
static void Cmd_nop_56(void);
static void Cmd_nop_57(void);
static void Cmd_call(void);
static void Cmd_goto(void);
static void Cmd_end(void);
@ -204,16 +204,16 @@ static const BattleAICmdFunc sBattleAICmdTable[] =
Cmd_if_not_equal_, // 0x27
Cmd_if_user_goes, // 0x28
Cmd_if_user_doesnt_go, // 0x29
Cmd_nullsub_2A, // 0x2A
Cmd_nullsub_2B, // 0x2B
Cmd_nop_2A, // 0x2A
Cmd_nop_2B, // 0x2B
Cmd_count_usable_party_mons, // 0x2C
Cmd_get_considered_move, // 0x2D
Cmd_get_considered_move_effect, // 0x2E
Cmd_get_ability, // 0x2F
Cmd_get_highest_type_effectiveness, // 0x30
Cmd_if_type_effectiveness, // 0x31
Cmd_nullsub_32, // 0x32
Cmd_nullsub_33, // 0x33
Cmd_nop_32, // 0x32
Cmd_nop_33, // 0x33
Cmd_if_status_in_party, // 0x34
Cmd_if_status_not_in_party, // 0x35
Cmd_get_weather, // 0x36
@ -244,12 +244,12 @@ static const BattleAICmdFunc sBattleAICmdTable[] =
Cmd_get_move_power_from_result, // 0x4F
Cmd_get_move_effect_from_result, // 0x50
Cmd_get_protect_count, // 0x51
Cmd_nullsub_52, // 0x52
Cmd_nullsub_53, // 0x53
Cmd_nullsub_54, // 0x54
Cmd_nullsub_55, // 0x55
Cmd_nullsub_56, // 0x56
Cmd_nullsub_57, // 0x57
Cmd_nop_52, // 0x52
Cmd_nop_53, // 0x53
Cmd_nop_54, // 0x54
Cmd_nop_55, // 0x55
Cmd_nop_56, // 0x56
Cmd_nop_57, // 0x57
Cmd_call, // 0x58
Cmd_goto, // 0x59
Cmd_end, // 0x5A
@ -1278,11 +1278,11 @@ static void Cmd_if_user_doesnt_go(void)
gAIScriptPtr += 6;
}
static void Cmd_nullsub_2A(void)
static void Cmd_nop_2A(void)
{
}
static void Cmd_nullsub_2B(void)
static void Cmd_nop_2B(void)
{
}
@ -1539,11 +1539,11 @@ static void Cmd_if_type_effectiveness(void)
gAIScriptPtr += 6;
}
static void Cmd_nullsub_32(void)
static void Cmd_nop_32(void)
{
}
static void Cmd_nullsub_33(void)
static void Cmd_nop_33(void)
{
}
@ -2134,27 +2134,27 @@ static void Cmd_get_protect_count(void)
gAIScriptPtr += 2;
}
static void Cmd_nullsub_52(void)
static void Cmd_nop_52(void)
{
}
static void Cmd_nullsub_53(void)
static void Cmd_nop_53(void)
{
}
static void Cmd_nullsub_54(void)
static void Cmd_nop_54(void)
{
}
static void Cmd_nullsub_55(void)
static void Cmd_nop_55(void)
{
}
static void Cmd_nullsub_56(void)
static void Cmd_nop_56(void)
{
}
static void Cmd_nullsub_57(void)
static void Cmd_nop_57(void)
{
}

View File

@ -274,7 +274,7 @@ static void AnimTranslateWebThread(struct Sprite *sprite)
SetAverageBattlerPositions(gBattleAnimTarget, 1, &sprite->data[2], &sprite->data[4]);
}
sub_80A6FD4(sprite);
InitAnimLinearTranslationWithSpeed(sprite);
sprite->data[5] = gBattleAnimArgs[3];
sprite->callback = AnimTranslateWebThread_Step;
}

View File

@ -3074,7 +3074,7 @@ static void AnimPresent(struct Sprite* sprite)
sprite->callback = AnimItemSteal_Step1;
}
static void sub_80FFB90(struct Sprite* sprite)
static void AnimKnockOffOpponentsItem(struct Sprite* sprite)
{
int zero;
sprite->data[0] += ((sprite->data[3] * 128) / sprite->data[4]);
@ -3116,7 +3116,7 @@ static void AnimKnockOffItem(struct Sprite* sprite)
sub_80FF9B8(sprite, 40);
sprite->data[3] = 3;
sprite->data[4] = 60;
sprite->callback = sub_80FFB90;
sprite->callback = AnimKnockOffOpponentsItem;
}
}
@ -3731,7 +3731,7 @@ static void AnimNeedleArmSpike_Step(struct Sprite* sprite)
}
}
static void sub_81009DC(struct Sprite* sprite)
static void AnimWhipHit_WaitEnd(struct Sprite* sprite)
{
if (sprite->animEnded)
DestroyAnimSprite(sprite);
@ -3759,7 +3759,7 @@ static void AnimWhipHit(struct Sprite* sprite)
if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER)
StartSpriteAnim(sprite, 1);
sprite->callback = sub_81009DC;
sprite->callback = AnimWhipHit_WaitEnd;
SetAnimSpriteInitialXOffset(sprite, gBattleAnimArgs[0]);
sprite->pos1.y += gBattleAnimArgs[1];
}

View File

@ -1784,7 +1784,7 @@ static void AnimCoinThrow(struct Sprite *sprite)
sprite->data[0] = gBattleAnimArgs[4];
sprite->data[2] = r6;
sprite->data[4] = r7;
sprite->callback = sub_80A7000;
sprite->callback = InitAnimLinearTranslationWithSpeedAndPos;
StoreSpriteCallbackInData6(sprite, DestroyAnimSprite);
}
@ -2569,7 +2569,7 @@ static void AnimBlendThinRing(struct Sprite *sprite)
sprite->callback(sprite);
}
void sub_8105284(struct Sprite *sprite)
static void AnimHyperVoiceRing_WaitEnd(struct Sprite *sprite)
{
if (AnimTranslateLinear(sprite))
{
@ -2659,7 +2659,7 @@ static void AnimHyperVoiceRing(struct Sprite *sprite)
sprite->data[4] = sp1;
sprite->data[0] = gBattleAnimArgs[0];
InitAnimLinearTranslation(sprite);
sprite->callback = sub_8105284;
sprite->callback = AnimHyperVoiceRing_WaitEnd;
sprite->callback(sprite);
}
@ -3523,7 +3523,7 @@ static void AnimAngel(struct Sprite *sprite)
DestroyAnimSprite(sprite);
}
static void sub_8106A64(struct Sprite *sprite)
static void AnimPinkHeart_Step(struct Sprite *sprite)
{
sprite->data[5]++;
sprite->pos2.x = Sin(sprite->data[3], 5);
@ -3552,7 +3552,7 @@ static void AnimPinkHeart(struct Sprite *sprite)
sprite->data[3] = (sprite->data[3] + 3) & 0xFF;
if (sprite->data[3] > 70)
{
sprite->callback = sub_8106A64;
sprite->callback = AnimPinkHeart_Step;
sprite->pos1.x += sprite->pos2.x;
sprite->pos1.y += sprite->pos2.y;
sprite->pos2.x = 0;

View File

@ -2321,7 +2321,7 @@ void AnimTask_TransformMon(u8 taskId)
if (IsSpeciesNotUnown(gContestResources->moveAnim->targetSpecies))
gSprites[gBattlerSpriteIds[gBattleAnimAttacker]].affineAnims = gUnknown_082FF6C0;
else
gSprites[gBattlerSpriteIds[gBattleAnimAttacker]].affineAnims = gUnknown_082FF694;
gSprites[gBattlerSpriteIds[gBattleAnimAttacker]].affineAnims = gAffineAnims_BattleSpriteOpponentSide;
StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[gBattleAnimAttacker]], 0);
}
@ -3248,7 +3248,7 @@ void AnimTask_RolePlaySilhouette(u8 taskId)
coord1 = GetBattlerSpriteCoord(gBattleAnimAttacker, 0);
coord2 = GetBattlerSpriteCoord(gBattleAnimAttacker, 1);
spriteId = sub_80A8394(species, isBackPic, 0, coord1 + xOffset, coord2, 5, personality, otId, gBattleAnimTarget, 1);
spriteId = CreateAdditionalMonSpriteForMoveAnim(species, isBackPic, 0, coord1 + xOffset, coord2, 5, personality, otId, gBattleAnimTarget, TRUE);
gSprites[spriteId].oam.priority = priority;
gSprites[spriteId].oam.objMode = ST_OAM_OBJ_BLEND;
@ -5066,7 +5066,7 @@ void AnimTask_SnatchOpposingMonMove(u8 taskId)
}
}
spriteId2 = sub_80A8394(species, isBackPic, 0, x, GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y), subpriority, personality, otId, gBattleAnimAttacker, 0);
spriteId2 = CreateAdditionalMonSpriteForMoveAnim(species, isBackPic, 0, x, GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y), subpriority, personality, otId, gBattleAnimAttacker, FALSE);
if (gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].transformSpecies != SPECIES_NONE)
BlendPalette((gSprites[spriteId2].oam.paletteNum * 16) | 0x100, 16, 6, RGB_WHITE);

View File

@ -835,7 +835,7 @@ static void AnimSuperpowerOrb_Step(struct Sprite *sprite)
InitAnimLinearTranslation(sprite);
StoreSpriteCallbackInData6(sprite, DestroySpriteAndMatrix);
sprite->callback = sub_80A6F98;
sprite->callback = AnimTranslateLinear_WaitEnd;
}
}
@ -931,7 +931,7 @@ static void AnimSuperpowerFireball(struct Sprite *sprite)
InitAnimLinearTranslation(sprite);
StoreSpriteCallbackInData6(sprite, DestroyAnimSprite);
sprite->callback = sub_80A6F98;
sprite->callback = AnimTranslateLinear_WaitEnd;
}
static void AnimArmThrustHit_Step(struct Sprite *sprite)

View File

@ -1115,7 +1115,7 @@ static void AnimWillOWispOrb(struct Sprite *sprite)
sprite->data[3] = sprite->pos1.y;
sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3);
sub_80A6FD4(sprite);
InitAnimLinearTranslationWithSpeed(sprite);
sprite->callback = AnimWillOWispOrb_Step;
}
break;

View File

@ -225,7 +225,7 @@ static void AnimConfuseRayBallBounce(struct Sprite *sprite)
sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2);
sprite->data[3] = sprite->pos1.y;
sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3);
sub_80A6FD4(sprite);
InitAnimLinearTranslationWithSpeed(sprite);
sprite->callback = AnimConfuseRayBallBounce_Step1;
sprite->data[6] = 16;
SetGpuReg(REG_OFFSET_BLDCNT, (BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL));

View File

@ -710,7 +710,7 @@ static void AnimSwirlingSnowball(struct Sprite *sprite)
for (i = 0; i < 8; i++)
sprite->data[i] = tempDataHolder[i];
sprite->callback = sub_80A718C;
sprite->callback = InitAnimFastLinearTranslationWithSpeedAndPos;
StoreSpriteCallbackInData6(sprite, AnimSwirlingSnowball_Step1);
}
@ -1311,7 +1311,7 @@ static void MovePoisonGasCloud(struct Sprite *sprite)
sprite->data[7]++;
sprite->pos2.x = sprite->pos2.y = 0;
sub_80A6FD4(sprite);
InitAnimLinearTranslationWithSpeed(sprite);
}
break;
case 2:

View File

@ -21,15 +21,15 @@
extern const struct OamData gOamData_AffineNormal_ObjNormal_64x64;
static void sub_80A6FB4(struct Sprite *sprite);
static void sub_80A7144(struct Sprite *sprite);
static void AnimFastTranslateLinearWaitEnd(struct Sprite *sprite);
static void AnimThrowProjectile_Step(struct Sprite *sprite);
static void sub_80A8DFC(struct Sprite *sprite);
static void sub_80A8E88(struct Sprite *sprite);
static void AnimWeatherBallUp_Step(struct Sprite *sprite);
static u16 GetBattlerYDeltaFromSpriteId(u8 spriteId);
static void AnimTask_BlendPalInAndOutSetup(struct Task *task);
static void sub_80A7AFC(u8 taskId);
static void sub_80A8CAC(u8 taskId);
static void AnimTask_BlendMonInAndOutStep(u8 taskId);
static void AnimTask_AlphaFadeIn_Step(u8 taskId);
static void AnimTask_AttackerPunchWithTrace_Step(u8 taskId);
static void AnimTask_BlendMonInAndOut_Step(u8 taskId);
static bool8 sub_80A7238(void);
static void sub_80A8D78(struct Task *task, u8 taskId);
@ -79,11 +79,15 @@ static const u8 sCastformBackSpriteYCoords[] =
0, // HAIL
};
static const struct SpriteTemplate sUnknown_08525F90[] =
// Placeholders for pokemon sprites to be created for a move animation effect (e.g. Role Play / Snatch)
#define TAG_MOVE_EFFECT_MON_1 55125
#define TAG_MOVE_EFFECT_MON_2 55126
static const struct SpriteTemplate sSpriteTemplate_MoveEffectMons[] =
{
{
.tileTag = 55125,
.paletteTag = 55125,
.tileTag = TAG_MOVE_EFFECT_MON_1,
.paletteTag = TAG_MOVE_EFFECT_MON_1,
.oam = &gOamData_AffineNormal_ObjNormal_64x64,
.anims = gDummySpriteAnimTable,
.images = NULL,
@ -91,8 +95,8 @@ static const struct SpriteTemplate sUnknown_08525F90[] =
.callback = SpriteCallbackDummy,
},
{
.tileTag = 55126,
.paletteTag = 55126,
.tileTag = TAG_MOVE_EFFECT_MON_2,
.paletteTag = TAG_MOVE_EFFECT_MON_2,
.oam = &gOamData_AffineNormal_ObjNormal_64x64,
.anims = gDummySpriteAnimTable,
.images = NULL,
@ -101,10 +105,10 @@ static const struct SpriteTemplate sUnknown_08525F90[] =
}
};
static const struct SpriteSheet sUnknown_08525FC0[] =
static const struct SpriteSheet sSpriteSheet_MoveEffectMons[] =
{
{ gMiscBlank_Gfx, 0x800, 55125, },
{ gMiscBlank_Gfx, 0x800, 55126, },
{ gMiscBlank_Gfx, 0x800, TAG_MOVE_EFFECT_MON_1, },
{ gMiscBlank_Gfx, 0x800, TAG_MOVE_EFFECT_MON_2, },
};
u8 GetBattlerSpriteCoord(u8 battlerId, u8 coordType)
@ -1032,7 +1036,7 @@ void StartAnimLinearTranslation(struct Sprite *sprite)
sprite->data[1] = sprite->pos1.x;
sprite->data[3] = sprite->pos1.y;
InitAnimLinearTranslation(sprite);
sprite->callback = sub_80A6F98;
sprite->callback = AnimTranslateLinear_WaitEnd;
sprite->callback(sprite);
}
@ -1075,7 +1079,7 @@ bool8 AnimTranslateLinear(struct Sprite *sprite)
return FALSE;
}
void sub_80A6F98(struct Sprite *sprite)
void AnimTranslateLinear_WaitEnd(struct Sprite *sprite)
{
if (AnimTranslateLinear(sprite))
SetCallbackToStoredInData6(sprite);
@ -1088,19 +1092,19 @@ static void sub_80A6FB4(struct Sprite *sprite)
SetCallbackToStoredInData6(sprite);
}
void sub_80A6FD4(struct Sprite *sprite)
void InitAnimLinearTranslationWithSpeed(struct Sprite *sprite)
{
int v1 = abs(sprite->data[2] - sprite->data[1]) << 8;
sprite->data[0] = v1 / sprite->data[0];
InitAnimLinearTranslation(sprite);
}
void sub_80A7000(struct Sprite *sprite)
void InitAnimLinearTranslationWithSpeedAndPos(struct Sprite *sprite)
{
sprite->data[1] = sprite->pos1.x;
sprite->data[3] = sprite->pos1.y;
sub_80A6FD4(sprite);
sprite->callback = sub_80A6F98;
InitAnimLinearTranslationWithSpeed(sprite);
sprite->callback = AnimTranslateLinear_WaitEnd;
sprite->callback(sprite);
}
@ -1137,7 +1141,7 @@ void InitAndRunAnimFastLinearTranslation(struct Sprite *sprite)
sprite->data[1] = sprite->pos1.x;
sprite->data[3] = sprite->pos1.y;
InitAnimFastLinearTranslation(sprite);
sprite->callback = sub_80A7144;
sprite->callback = AnimFastTranslateLinearWaitEnd;
sprite->callback(sprite);
}
@ -1171,7 +1175,7 @@ bool8 AnimFastTranslateLinear(struct Sprite *sprite)
return FALSE;
}
static void sub_80A7144(struct Sprite *sprite)
static void AnimFastTranslateLinearWaitEnd(struct Sprite *sprite)
{
if (AnimFastTranslateLinear(sprite))
SetCallbackToStoredInData6(sprite);
@ -1184,12 +1188,12 @@ void InitAnimFastLinearTranslationWithSpeed(struct Sprite *sprite)
InitAnimFastLinearTranslation(sprite);
}
void sub_80A718C(struct Sprite *sprite)
void InitAnimFastLinearTranslationWithSpeedAndPos(struct Sprite *sprite)
{
sprite->data[1] = sprite->pos1.x;
sprite->data[3] = sprite->pos1.y;
InitAnimFastLinearTranslationWithSpeed(sprite);
sprite->callback = sub_80A7144;
sprite->callback = AnimFastTranslateLinearWaitEnd;
sprite->callback(sprite);
}
@ -1438,9 +1442,10 @@ u32 sub_80A76C4(u8 a1, u8 a2, u8 a3, u8 a4)
return var;
}
u8 sub_80A77AC(u8 a1)
// Presumably something commented here, just returns arg
u8 AnimDummyReturnArg(u8 battler)
{
return a1;
return battler;
}
static u8 GetBattlerAtPosition_(u8 position)
@ -1611,10 +1616,10 @@ void AnimTask_AlphaFadeIn(u8 taskId)
gTasks[taskId].data[7] = gBattleAnimArgs[2];
gTasks[taskId].data[8] = gBattleAnimArgs[3];
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gBattleAnimArgs[0], gBattleAnimArgs[1]));
gTasks[taskId].func = sub_80A7AFC;
gTasks[taskId].func = AnimTask_AlphaFadeIn_Step;
}
static void sub_80A7AFC(u8 taskId)
static void AnimTask_AlphaFadeIn_Step(u8 taskId)
{
struct Task *task = &gTasks[taskId];
@ -1668,10 +1673,10 @@ static void AnimTask_BlendPalInAndOutSetup(struct Task *task)
task->data[5] = gBattleAnimArgs[3];
task->data[6] = 0;
task->data[7] = gBattleAnimArgs[4];
task->func = AnimTask_BlendMonInAndOutStep;
task->func = AnimTask_BlendMonInAndOut_Step;
}
static void AnimTask_BlendMonInAndOutStep(u8 taskId)
static void AnimTask_BlendMonInAndOut_Step(u8 taskId)
{
struct Task *task = &gTasks[taskId];
@ -2021,18 +2026,19 @@ u8 GetBattlerSpriteBGPriorityRank(u8 battlerId)
return 1;
}
u8 sub_80A8394(u16 species, bool8 isBackpic, u8 a3, s16 x, s16 y, u8 subpriority, u32 personality, u32 trainerId, u32 battlerId, u32 a10)
// Create pokemon sprite to be used for a move animation effect (e.g. Role Play / Snatch)
u8 CreateAdditionalMonSpriteForMoveAnim(u16 species, bool8 isBackpic, u8 id, s16 x, s16 y, u8 subpriority, u32 personality, u32 trainerId, u32 battlerId, bool32 ignoreDeoxysForm)
{
u8 spriteId;
u16 sheet = LoadSpriteSheet(&sUnknown_08525FC0[a3]);
u16 palette = AllocSpritePalette(sUnknown_08525F90[a3].paletteTag);
u16 sheet = LoadSpriteSheet(&sSpriteSheet_MoveEffectMons[id]);
u16 palette = AllocSpritePalette(sSpriteTemplate_MoveEffectMons[id].paletteTag);
if (gMonSpritesGfxPtr != NULL && gMonSpritesGfxPtr->buffer == NULL)
gMonSpritesGfxPtr->buffer = AllocZeroed(0x2000);
if (!isBackpic)
{
LoadCompressedPalette(GetMonSpritePalFromSpeciesAndPersonality(species, trainerId, personality), (palette * 0x10) + 0x100, 0x20);
if (a10 == 1 || sub_80688F8(5, battlerId) == 1 || gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies != 0)
if (ignoreDeoxysForm == TRUE || ShouldIgnoreDeoxysForm(5, battlerId) == TRUE || gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies != 0)
LoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species],
gMonSpritesGfxPtr->buffer,
species,
@ -2048,7 +2054,7 @@ u8 sub_80A8394(u16 species, bool8 isBackpic, u8 a3, s16 x, s16 y, u8 subpriority
else
{
LoadCompressedPalette(GetMonSpritePalFromSpeciesAndPersonality(species, trainerId, personality), (palette * 0x10) + 0x100, 0x20);
if (a10 == 1 || sub_80688F8(5, battlerId) == 1 || gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies != 0)
if (ignoreDeoxysForm == TRUE || ShouldIgnoreDeoxysForm(5, battlerId) == TRUE || gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies != 0)
LoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[species],
gMonSpritesGfxPtr->buffer,
species,
@ -2066,9 +2072,9 @@ u8 sub_80A8394(u16 species, bool8 isBackpic, u8 a3, s16 x, s16 y, u8 subpriority
FREE_AND_SET_NULL(gMonSpritesGfxPtr->buffer);
if (!isBackpic)
spriteId = CreateSprite(&sUnknown_08525F90[a3], x, y + gMonFrontPicCoords[species].y_offset, subpriority);
spriteId = CreateSprite(&sSpriteTemplate_MoveEffectMons[id], x, y + gMonFrontPicCoords[species].y_offset, subpriority);
else
spriteId = CreateSprite(&sUnknown_08525F90[a3], x, y + gMonBackPicCoords[species].y_offset, subpriority);
spriteId = CreateSprite(&sSpriteTemplate_MoveEffectMons[id], x, y + gMonBackPicCoords[species].y_offset, subpriority);
if (IsContest())
{
@ -2337,7 +2343,7 @@ void AnimTask_AttackerPunchWithTrace(u8 taskId)
task->data[2] = 0;
task->data[3] = 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;
dest = (task->data[4] + 0x10) * 0x10;
@ -2349,10 +2355,10 @@ void AnimTask_AttackerPunchWithTrace(u8 taskId)
task->data[6] = 3;
CpuCopy32(&gPlttBufferUnfaded[src], &gPlttBufferFaded[dest], 0x20);
BlendPalette(dest, 16, gBattleAnimArgs[1], gBattleAnimArgs[0]);
task->func = sub_80A8CAC;
task->func = AnimTask_AttackerPunchWithTrace_Step;
}
static void sub_80A8CAC(u8 taskId)
static void AnimTask_AttackerPunchWithTrace_Step(u8 taskId)
{
struct Task *task = &gTasks[taskId];
switch (task->data[2])
@ -2419,10 +2425,10 @@ void AnimWeatherBallUp(struct Sprite *sprite)
else
sprite->data[0] = -10;
sprite->data[1] = -40;
sprite->callback = sub_80A8E88;
sprite->callback = AnimWeatherBallUp_Step;
}
static void sub_80A8E88(struct Sprite *sprite)
static void AnimWeatherBallUp_Step(struct Sprite *sprite)
{
sprite->data[2] += sprite->data[0];
sprite->data[3] += sprite->data[1];

View File

@ -40,10 +40,10 @@ static void AnimTask_WaitAndRestoreVisibility(u8);
const u16 gUnknown_08597418 = RGB(31, 31, 31);
// These belong in battle_intro.c, but there putting them there causes 2 bytes of alignment padding
// These belong in battle_intro.c, but putting them there causes 2 bytes of alignment padding
// between the two .rodata segments. Perhaps battle_intro.c actually belongs in this file, too.
const u8 gUnknown_0859741A[] = {REG_OFFSET_BG0CNT, REG_OFFSET_BG1CNT, REG_OFFSET_BG2CNT, REG_OFFSET_BG3CNT};
const u8 gUnknown_0859741E[] = {REG_OFFSET_BG0CNT, REG_OFFSET_BG1CNT, REG_OFFSET_BG2CNT, REG_OFFSET_BG3CNT};
const u8 gBattleAnimBgCntSet[] = {REG_OFFSET_BG0CNT, REG_OFFSET_BG1CNT, REG_OFFSET_BG2CNT, REG_OFFSET_BG3CNT};
const u8 gBattleAnimBgCntGet[] = {REG_OFFSET_BG0CNT, REG_OFFSET_BG1CNT, REG_OFFSET_BG2CNT, REG_OFFSET_BG3CNT};
void AnimTask_BlendBattleAnimPal(u8 taskId)
{
@ -97,7 +97,7 @@ void AnimTask_BlendBattleAnimPalExclude(u8 taskId)
for (battler = 0; battler < MAX_BATTLERS_COUNT; battler++)
{
if (battler != animBattlers[0] && battler != animBattlers[1] && IsBattlerSpriteVisible(battler))
selectedPalettes |= 0x10000 << sub_80A77AC(battler);
selectedPalettes |= 0x10000 << AnimDummyReturnArg(battler);
}
StartBlendAnimSpriteColor(taskId, selectedPalettes);

View File

@ -100,7 +100,7 @@ static const struct SpriteTemplate sVsLetter_V_SpriteTemplate =
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = sVsLetterAffineAnimTable,
.callback = nullsub_17
.callback = SpriteCB_VsLetterDummy
};
static const struct SpriteTemplate sVsLetter_S_SpriteTemplate =
@ -111,7 +111,7 @@ static const struct SpriteTemplate sVsLetter_S_SpriteTemplate =
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = sVsLetterAffineAnimTable,
.callback = nullsub_17
.callback = SpriteCB_VsLetterDummy
};
static const struct CompressedSpriteSheet sVsLettersSpriteSheet =

View File

@ -51,7 +51,7 @@ static void LinkOpponentHandleMoveAnimation(void);
static void LinkOpponentHandlePrintString(void);
static void LinkOpponentHandlePrintSelectionString(void);
static void LinkOpponentHandleChooseAction(void);
static void LinkOpponentHandleUnknownYesNoBox(void);
static void LinkOpponentHandleYesNoBox(void);
static void LinkOpponentHandleChooseMove(void);
static void LinkOpponentHandleChooseItem(void);
static void LinkOpponentHandleChoosePokemon(void);
@ -87,20 +87,20 @@ static void LinkOpponentHandleSpriteInvisibility(void);
static void LinkOpponentHandleBattleAnimation(void);
static void LinkOpponentHandleLinkStandbyMsg(void);
static void LinkOpponentHandleResetActionMoveSelection(void);
static void LinkOpponentHandleCmd55(void);
static void LinkOpponentHandleEndLinkBattle(void);
static void LinkOpponentCmdEnd(void);
static void LinkOpponentBufferRunCommand(void);
static void LinkOpponentBufferExecCompleted(void);
static void sub_8064DD0(void);
static void SwitchIn_HandleSoundAndEnd(void);
static u32 CopyLinkOpponentMonData(u8 monId, u8 *dst);
static void SetLinkOpponentMonData(u8 monId);
static void sub_8066494(u8 battlerId, bool8 dontClearSubstituteBit);
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void LinkOpponentDoMoveAnimation(void);
static void sub_8067618(u8 taskId);
static void sub_80676FC(struct Sprite *sprite);
static void sub_806782C(void);
static void Task_StartSendOutAnim(u8 taskId);
static void SpriteCB_FreeOpponentSprite(struct Sprite *sprite);
static void EndDrawPartyStatusSummary(void);
static void (*const sLinkOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
{
@ -123,7 +123,7 @@ static void (*const sLinkOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
[CONTROLLER_PRINTSTRING] = LinkOpponentHandlePrintString,
[CONTROLLER_PRINTSTRINGPLAYERONLY] = LinkOpponentHandlePrintSelectionString,
[CONTROLLER_CHOOSEACTION] = LinkOpponentHandleChooseAction,
[CONTROLLER_UNKNOWNYESNOBOX] = LinkOpponentHandleUnknownYesNoBox,
[CONTROLLER_YESNOBOX] = LinkOpponentHandleYesNoBox,
[CONTROLLER_CHOOSEMOVE] = LinkOpponentHandleChooseMove,
[CONTROLLER_OPENBAG] = LinkOpponentHandleChooseItem,
[CONTROLLER_CHOOSEPOKEMON] = LinkOpponentHandleChoosePokemon,
@ -159,11 +159,11 @@ static void (*const sLinkOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
[CONTROLLER_BATTLEANIMATION] = LinkOpponentHandleBattleAnimation,
[CONTROLLER_LINKSTANDBYMSG] = LinkOpponentHandleLinkStandbyMsg,
[CONTROLLER_RESETACTIONMOVESELECTION] = LinkOpponentHandleResetActionMoveSelection,
[CONTROLLER_55] = LinkOpponentHandleCmd55,
[CONTROLLER_ENDLINKBATTLE] = LinkOpponentHandleEndLinkBattle,
[CONTROLLER_TERMINATOR_NOP] = LinkOpponentCmdEnd
};
static void nullsub_28(void)
static void LinkOpponentDummy(void)
{
}
@ -195,7 +195,7 @@ static void CompleteOnBankSpriteCallbackDummy2(void)
LinkOpponentBufferExecCompleted();
}
static void sub_8064470(void)
static void FreeTrainerSpriteAfterSlide(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
@ -206,38 +206,38 @@ static void sub_8064470(void)
}
}
static void sub_80644D8(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;
LinkOpponentBufferExecCompleted();
}
}
static void sub_8064520(void)
static void Intro_WaitForShinyAnimAndHealthbox(void)
{
bool32 r8 = FALSE;
bool32 r4 = FALSE;
bool32 healthboxAnimDone = FALSE;
bool32 twoMons = FALSE;
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
r8 = TRUE;
healthboxAnimDone = TRUE;
}
else
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]].callback == SpriteCallbackDummy)
{
r8 = TRUE;
healthboxAnimDone = TRUE;
}
r4 = TRUE;
twoMons = TRUE;
}
if (r8)
if (healthboxAnimDone)
{
if (r4 || !IsBattlerSpriteVisible(BATTLE_PARTNER(gActiveBattler)))
if (twoMons || !IsBattlerSpriteVisible(BATTLE_PARTNER(gActiveBattler)))
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim)
return;
@ -250,8 +250,8 @@ static void sub_8064520(void)
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
}
else
{
@ -263,19 +263,19 @@ static void sub_8064520(void)
if (GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_RIGHT)
{
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
}
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3;
gBattlerControllerFuncs[gActiveBattler] = sub_80644D8;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
gBattlerControllerFuncs[gActiveBattler] = Intro_DelayAndEnd;
}
}
static void sub_8064734(void)
static void Intro_TryShinyAnimShowHealthbox(void)
{
bool32 r10 = FALSE;
bool32 bgmRestored = FALSE;
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
@ -294,27 +294,27 @@ static void sub_8064734(void)
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))
{
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)]);
}
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler);
StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = TRUE;
}
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x40
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].field_1_x40
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].waitForCry
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted
&& !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].waitForCry
&& !IsCryPlayingOrClearCrySongs())
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored)
{
if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK)
{
@ -327,42 +327,42 @@ static void sub_8064734(void)
}
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 1;
r10 = TRUE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE;
bgmRestored = TRUE;
}
if (r10)
if (bgmRestored)
{
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
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;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
}
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));
}
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattleSpritesDataPtr->animationData->field_9_x1 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0;
gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = FALSE;
gBattlerControllerFuncs[gActiveBattler] = sub_8064520;
gBattlerControllerFuncs[gActiveBattler] = Intro_WaitForShinyAnimAndHealthbox;
}
}
}
static void sub_8064B04(void)
static void TryShinyAnimAfterMonAnim(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x == 0)
@ -377,8 +377,8 @@ static void sub_8064B04(void)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
LinkOpponentBufferExecCompleted();
}
}
@ -401,7 +401,7 @@ static void CompleteOnHealthbarDone(void)
}
}
static void sub_8064C14(void)
static void HideHealthboxAfterMonFaint(void)
{
if (!gSprites[gBattlerSpriteIds[gActiveBattler]].inUse)
{
@ -410,7 +410,7 @@ static void sub_8064C14(void)
}
}
static void sub_8064C58(void)
static void FreeMonSpriteAfterSwitchOutAnim(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{
@ -447,18 +447,18 @@ static void DoHitAnimBlinkSpriteEffect(void)
}
}
static void sub_8064D60(void)
static void SwitchIn_ShowSubstitute(void)
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattlerControllerFuncs[gActiveBattler] = sub_8064DD0;
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_HandleSoundAndEnd;
}
}
static void sub_8064DD0(void)
static void SwitchIn_HandleSoundAndEnd(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive && !IsCryPlayingOrClearCrySongs())
{
@ -471,7 +471,7 @@ static void sub_8064DD0(void)
}
}
static void sub_8064E50(void)
static void SwitchIn_ShowHealthbox(void)
{
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -479,20 +479,20 @@ static void sub_8064E50(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler);
StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
CopyBattleSpriteInvisibility(gActiveBattler);
gBattlerControllerFuncs[gActiveBattler] = sub_8064D60;
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowSubstitute;
}
}
static void sub_8064F40(void)
static void SwitchIn_TryShinyAnim(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim)
@ -500,12 +500,12 @@ static void sub_8064F40(void)
TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
}
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattlerControllerFuncs[gActiveBattler] = sub_8064E50;
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowHealthbox;
}
}
@ -1141,24 +1141,24 @@ static void LinkOpponentHandleLoadMonSprite(void)
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattlerControllerFuncs[gActiveBattler] = sub_8064B04;
gBattlerControllerFuncs[gActiveBattler] = TryShinyAnimAfterMonAnim;
}
static void LinkOpponentHandleSwitchInAnim(void)
{
gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1];
sub_8066494(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = sub_8064F40;
StartSendOutAnim(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_TryShinyAnim;
}
static void sub_8066494(u8 battlerId, bool8 dontClearSubstituteBit)
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
@ -1168,8 +1168,8 @@ static void sub_8066494(u8 battlerId, bool8 dontClearSubstituteBit)
GetBattlerSpriteDefault_Y(battlerId),
GetBattlerSpriteSubpriority(battlerId));
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattleControllerData[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gBattleControllerData[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
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]].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)
@ -1215,12 +1215,14 @@ static void DoSwitchOutAnimation(void)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_OPPONENT_MON);
gBattlerControllerFuncs[gActiveBattler] = sub_8064C58;
gBattlerControllerFuncs[gActiveBattler] = FreeMonSpriteAfterSwitchOutAnim;
}
break;
}
}
#define sSpeedX data[0]
static void LinkOpponentHandleDrawTrainerPic(void)
{
s16 xPos;
@ -1301,10 +1303,10 @@ static void LinkOpponentHandleDrawTrainerPic(void)
GetBattlerSpriteSubpriority(gActiveBattler));
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.affineParam = trainerPicId;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
}
@ -1324,15 +1326,17 @@ static void LinkOpponentHandleTrainerSlide(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 96;
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.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
LinkOpponentBufferExecCompleted();
}
#undef sSpeedX
static void LinkOpponentHandleTrainerSlideBack(void)
{
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
@ -1341,7 +1345,7 @@ static void LinkOpponentHandleTrainerSlideBack(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
gBattlerControllerFuncs[gActiveBattler] = sub_8064470;
gBattlerControllerFuncs[gActiveBattler] = FreeTrainerSpriteAfterSlide;
}
static void LinkOpponentHandleFaintAnimation(void)
@ -1359,7 +1363,7 @@ static void LinkOpponentHandleFaintAnimation(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
PlaySE12WithPanning(SE_FAINT, SOUND_PAN_TARGET);
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_FaintOpponentMon;
gBattlerControllerFuncs[gActiveBattler] = sub_8064C14;
gBattlerControllerFuncs[gActiveBattler] = HideHealthboxAfterMonFaint;
}
}
}
@ -1386,7 +1390,7 @@ static void LinkOpponentHandlePause(void)
static void LinkOpponentHandleMoveAnimation(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8);
@ -1429,7 +1433,7 @@ static void LinkOpponentDoMoveAnimation(void)
case 1:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{
sub_805EB9C(ST_OAM_AFFINE_OFF);
SetBattlerSpriteAffineMode(ST_OAM_AFFINE_OFF);
DoMoveAnim(move);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2;
}
@ -1438,7 +1442,7 @@ static void LinkOpponentDoMoveAnimation(void)
gAnimScriptCallback();
if (!gAnimScriptActive)
{
sub_805EB9C(ST_OAM_AFFINE_NORMAL);
SetBattlerSpriteAffineMode(ST_OAM_AFFINE_NORMAL);
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
{
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
@ -1482,7 +1486,7 @@ static void LinkOpponentHandleChooseAction(void)
LinkOpponentBufferExecCompleted();
}
static void LinkOpponentHandleUnknownYesNoBox(void)
static void LinkOpponentHandleYesNoBox(void)
{
LinkOpponentBufferExecCompleted();
}
@ -1538,7 +1542,7 @@ static void LinkOpponentHandleExpUpdate(void)
static void LinkOpponentHandleStatusIconUpdate(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
u8 battlerId;
@ -1551,7 +1555,7 @@ static void LinkOpponentHandleStatusIconUpdate(void)
static void LinkOpponentHandleStatusAnimation(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1],
gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24));
@ -1702,19 +1706,19 @@ static void LinkOpponentHandleIntroTrainerBallThrow(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_80676FC);
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCB_FreeOpponentSprite);
taskId = CreateTask(sub_8067618, 5);
taskId = CreateTask(Task_StartSendOutAnim, 5);
gTasks[taskId].data[0] = gActiveBattler;
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1;
gBattlerControllerFuncs[gActiveBattler] = nullsub_28;
gBattleSpritesDataPtr->animationData->introAnimActive = TRUE;
gBattlerControllerFuncs[gActiveBattler] = LinkOpponentDummy;
}
static void sub_8067618(u8 taskId)
static void Task_StartSendOutAnim(u8 taskId)
{
u8 savedActiveBank = gActiveBattler;
@ -1722,23 +1726,23 @@ static void sub_8067618(u8 taskId)
if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_8066494(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
}
else
{
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_8066494(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
gActiveBattler = BATTLE_PARTNER(gActiveBattler);
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_8066494(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
gActiveBattler = BATTLE_PARTNER(gActiveBattler);
}
gBattlerControllerFuncs[gActiveBattler] = sub_8064734;
gBattlerControllerFuncs[gActiveBattler] = Intro_TryShinyAnimShowHealthbox;
gActiveBattler = savedActiveBank;
DestroyTask(taskId);
}
static void sub_80676FC(struct Sprite *sprite)
static void SpriteCB_FreeOpponentSprite(struct Sprite *sprite)
{
FreeTrainerFrontPicPalette(sprite->oam.affineParam);
FreeSpriteOamMatrix(sprite);
@ -1769,20 +1773,20 @@ static void LinkOpponentHandleDrawPartyStatusSummary(void)
}
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)
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();
}
}
@ -1811,7 +1815,7 @@ static void LinkOpponentHandleSpriteInvisibility(void)
static void LinkOpponentHandleBattleAnimation(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
u8 animationId = gBattleBufferA[gActiveBattler][1];
u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8);
@ -1827,7 +1831,7 @@ static void LinkOpponentHandleBattleAnimation(void)
static void LinkOpponentHandleLinkStandbyMsg(void)
{
sub_81851A8(&gBattleBufferA[gActiveBattler][2]);
RecordedBattle_RecordAllBattlerData(&gBattleBufferA[gActiveBattler][2]);
LinkOpponentBufferExecCompleted();
}
@ -1836,9 +1840,9 @@ static void LinkOpponentHandleResetActionMoveSelection(void)
LinkOpponentBufferExecCompleted();
}
static void LinkOpponentHandleCmd55(void)
static void LinkOpponentHandleEndLinkBattle(void)
{
sub_81851A8(&gBattleBufferA[gActiveBattler][4]);
RecordedBattle_RecordAllBattlerData(&gBattleBufferA[gActiveBattler][4]);
if (gBattleBufferA[gActiveBattler][1] == B_OUTCOME_DREW)
gBattleOutcome = gBattleBufferA[gActiveBattler][1];
@ -1849,7 +1853,7 @@ static void LinkOpponentHandleCmd55(void)
FadeOutMapMusic(5);
BeginFastPaletteFade(3);
LinkOpponentBufferExecCompleted();
gBattlerControllerFuncs[gActiveBattler] = sub_80587B0;
gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks;
}
static void LinkOpponentCmdEnd(void)

View File

@ -49,7 +49,7 @@ static void LinkPartnerHandleMoveAnimation(void);
static void LinkPartnerHandlePrintString(void);
static void LinkPartnerHandlePrintSelectionString(void);
static void LinkPartnerHandleChooseAction(void);
static void LinkPartnerHandleUnknownYesNoBox(void);
static void LinkPartnerHandleYesNoBox(void);
static void LinkPartnerHandleChooseMove(void);
static void LinkPartnerHandleChooseItem(void);
static void LinkPartnerHandleChoosePokemon(void);
@ -85,19 +85,19 @@ static void LinkPartnerHandleSpriteInvisibility(void);
static void LinkPartnerHandleBattleAnimation(void);
static void LinkPartnerHandleLinkStandbyMsg(void);
static void LinkPartnerHandleResetActionMoveSelection(void);
static void LinkPartnerHandleCmd55(void);
static void LinkPartnerHandleEndLinkBattle(void);
static void LinkPartnerCmdEnd(void);
static void LinkPartnerBufferRunCommand(void);
static void LinkPartnerBufferExecCompleted(void);
static void sub_814B554(void);
static void SwitchIn_WaitAndEnd(void);
static u32 CopyLinkPartnerMonData(u8 monId, u8 *dst);
static void SetLinkPartnerMonData(u8 monId);
static void sub_814CC98(u8 battlerId, bool8 dontClearSubstituteBit);
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void LinkPartnerDoMoveAnimation(void);
static void sub_814DCCC(u8 taskId);
static void sub_814DE9C(void);
static void Task_StartSendOutAnim(u8 taskId);
static void EndDrawPartyStatusSummary(void);
static void (*const sLinkPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
{
@ -120,7 +120,7 @@ static void (*const sLinkPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
[CONTROLLER_PRINTSTRING] = LinkPartnerHandlePrintString,
[CONTROLLER_PRINTSTRINGPLAYERONLY] = LinkPartnerHandlePrintSelectionString,
[CONTROLLER_CHOOSEACTION] = LinkPartnerHandleChooseAction,
[CONTROLLER_UNKNOWNYESNOBOX] = LinkPartnerHandleUnknownYesNoBox,
[CONTROLLER_YESNOBOX] = LinkPartnerHandleYesNoBox,
[CONTROLLER_CHOOSEMOVE] = LinkPartnerHandleChooseMove,
[CONTROLLER_OPENBAG] = LinkPartnerHandleChooseItem,
[CONTROLLER_CHOOSEPOKEMON] = LinkPartnerHandleChoosePokemon,
@ -156,7 +156,7 @@ static void (*const sLinkPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
[CONTROLLER_BATTLEANIMATION] = LinkPartnerHandleBattleAnimation,
[CONTROLLER_LINKSTANDBYMSG] = LinkPartnerHandleLinkStandbyMsg,
[CONTROLLER_RESETACTIONMOVESELECTION] = LinkPartnerHandleResetActionMoveSelection,
[CONTROLLER_55] = LinkPartnerHandleCmd55,
[CONTROLLER_ENDLINKBATTLE] = LinkPartnerHandleEndLinkBattle,
[CONTROLLER_TERMINATOR_NOP] = LinkPartnerCmdEnd
};
@ -186,84 +186,84 @@ static void CompleteOnBattlerSpriteCallbackDummy(void)
LinkPartnerBufferExecCompleted();
}
static void sub_814AF54(void)
static void FreeTrainerSpriteAfterSlide(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
nullsub_25(0);
BattleGfxSfxDummy3(MALE);
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
LinkPartnerBufferExecCompleted();
}
}
static void sub_814AFBC(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;
LinkPartnerBufferExecCompleted();
}
}
static void sub_814B004(void)
static void Intro_WaitForHealthbox(void)
{
bool32 r6 = FALSE;
bool32 finished = FALSE;
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
r6 = TRUE;
finished = TRUE;
}
else
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
{
r6 = TRUE;
finished = TRUE;
}
}
if (IsCryPlayingOrClearCrySongs())
r6 = FALSE;
finished = FALSE;
if (r6)
if (finished)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3;
gBattlerControllerFuncs[gActiveBattler] = sub_814AFBC;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
gBattlerControllerFuncs[gActiveBattler] = Intro_DelayAndEnd;
}
}
static void sub_814B0E8(void)
static void Intro_ShowHealthbox(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive
&& gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattleControllerData[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))
{
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);
sub_8076918(gActiveBattler ^ BIT_FLANK);
StartHealthboxSlideIn(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);
sub_8076918(gActiveBattler);
StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattleSpritesDataPtr->animationData->field_9_x1 = 0;
gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
gBattlerControllerFuncs[gActiveBattler] = sub_814B004;
gBattlerControllerFuncs[gActiveBattler] = Intro_WaitForHealthbox;
}
}
static void sub_814B290(void)
static void WaitForMonAnimAfterLoad(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded && gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x == 0)
LinkPartnerBufferExecCompleted();
@ -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)
{
u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
nullsub_24(species);
BattleGfxSfxDummy2(species);
FreeOamMatrix(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.matrixNum);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
@ -300,7 +300,7 @@ static void sub_814B340(void)
}
}
static void sub_814B3DC(void)
static void FreeMonSpriteAfterSwitchOutAnim(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{
@ -336,7 +336,7 @@ static void DoHitAnimBlinkSpriteEffect(void)
}
}
static void sub_814B4E0(void)
static void SwitchIn_ShowSubstitute(void)
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
@ -344,11 +344,11 @@ static void sub_814B4E0(void)
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattlerControllerFuncs[gActiveBattler] = sub_814B554;
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_WaitAndEnd;
}
}
static void sub_814B554(void)
static void SwitchIn_WaitAndEnd(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -357,28 +357,28 @@ static void sub_814B554(void)
}
}
static void sub_814B5A8(void)
static void SwitchIn_ShowHealthbox(void)
{
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
CreateTask(c3_0802FDF4, 10);
CreateTask(Task_PlayerController_RestoreBgmAfterCry, 10);
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler);
StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattlerControllerFuncs[gActiveBattler] = sub_814B4E0;
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowSubstitute;
}
}
static void sub_814B69C(void)
static void SwitchIn_TryShinyAnim(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
@ -386,11 +386,11 @@ static void sub_814B69C(void)
TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
}
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
gBattlerControllerFuncs[gActiveBattler] = sub_814B5A8;
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowHealthbox;
}
}
@ -1025,7 +1025,7 @@ static void LinkPartnerHandleLoadMonSprite(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]);
gBattlerControllerFuncs[gActiveBattler] = sub_814B290;
gBattlerControllerFuncs[gActiveBattler] = WaitForMonAnimAfterLoad;
}
static void LinkPartnerHandleSwitchInAnim(void)
@ -1033,18 +1033,18 @@ static void LinkPartnerHandleSwitchInAnim(void)
ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1];
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
sub_814CC98(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = sub_814B69C;
StartSendOutAnim(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_TryShinyAnim;
}
static void sub_814CC98(u8 battlerId, bool8 dontClearSubstituteBit)
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[battlerId] = CreateSprite(
@ -1053,8 +1053,8 @@ static void sub_814CC98(u8 battlerId, bool8 dontClearSubstituteBit)
GetBattlerSpriteDefault_Y(battlerId),
GetBattlerSpriteSubpriority(battlerId));
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattleControllerData[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gBattleControllerData[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
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]].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)
@ -1099,12 +1099,14 @@ static void DoSwitchOutAnimation(void)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON);
gBattlerControllerFuncs[gActiveBattler] = sub_814B3DC;
gBattlerControllerFuncs[gActiveBattler] = FreeMonSpriteAfterSwitchOutAnim;
}
break;
}
}
#define sSpeedX data[0]
static void LinkPartnerHandleDrawTrainerPic(void)
{
s16 xPos;
@ -1142,13 +1144,15 @@ static void LinkPartnerHandleDrawTrainerPic(void)
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, (8 - gTrainerBackPicCoords[trainerPicId].size) * 4 + 80, GetBattlerSpriteSubpriority(gActiveBattler));
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
}
#undef sSpeedX
static void LinkPartnerHandleTrainerSlide(void)
{
LinkPartnerBufferExecCompleted();
@ -1162,9 +1166,12 @@ static void LinkPartnerHandleTrainerSlideBack(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
gBattlerControllerFuncs[gActiveBattler] = sub_814AF54;
gBattlerControllerFuncs[gActiveBattler] = FreeTrainerSpriteAfterSlide;
}
#define sSpeedX data[1]
#define sSpeedY data[2]
static void LinkPartnerHandleFaintAnimation(void)
{
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0)
@ -1180,14 +1187,17 @@ static void LinkPartnerHandleFaintAnimation(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
PlaySE12WithPanning(SE_FAINT, SOUND_PAN_ATTACKER);
gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 5;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_8039C00;
gBattlerControllerFuncs[gActiveBattler] = sub_814B340;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 0;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedY = 5;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_FaintSlideAnim;
gBattlerControllerFuncs[gActiveBattler] = FreeMonSpriteAfterFaintAnim;
}
}
}
#undef sSpeedX
#undef sSpeedY
static void LinkPartnerHandlePaletteFade(void)
{
LinkPartnerBufferExecCompleted();
@ -1210,7 +1220,7 @@ static void LinkPartnerHandlePause(void)
static void LinkPartnerHandleMoveAnimation(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8);
@ -1253,7 +1263,7 @@ static void LinkPartnerDoMoveAnimation(void)
case 1:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{
sub_805EB9C(ST_OAM_AFFINE_OFF);
SetBattlerSpriteAffineMode(ST_OAM_AFFINE_OFF);
DoMoveAnim(move);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2;
}
@ -1262,7 +1272,7 @@ static void LinkPartnerDoMoveAnimation(void)
gAnimScriptCallback();
if (!gAnimScriptActive)
{
sub_805EB9C(ST_OAM_AFFINE_NORMAL);
SetBattlerSpriteAffineMode(ST_OAM_AFFINE_NORMAL);
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
{
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
@ -1306,7 +1316,7 @@ static void LinkPartnerHandleChooseAction(void)
LinkPartnerBufferExecCompleted();
}
static void LinkPartnerHandleUnknownYesNoBox(void)
static void LinkPartnerHandleYesNoBox(void)
{
LinkPartnerBufferExecCompleted();
}
@ -1362,7 +1372,7 @@ static void LinkPartnerHandleExpUpdate(void)
static void LinkPartnerHandleStatusIconUpdate(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
u8 battlerId;
@ -1375,7 +1385,7 @@ static void LinkPartnerHandleStatusIconUpdate(void)
static void LinkPartnerHandleStatusAnimation(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1],
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]].data[5] = gActiveBattler;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_805CC00);
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCB_FreePlayerSpriteLoadMonSprite);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1);
paletteNum = AllocSpritePalette(0xD6F9);
@ -1553,17 +1563,17 @@ static void LinkPartnerHandleIntroTrainerBallThrow(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum;
taskId = CreateTask(sub_814DCCC, 5);
taskId = CreateTask(Task_StartSendOutAnim, 5);
gTasks[taskId].data[0] = gActiveBattler;
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1;
gBattleSpritesDataPtr->animationData->introAnimActive = TRUE;
gBattlerControllerFuncs[gActiveBattler] = SpriteCB_Null2;
}
static void sub_814DCCC(u8 taskId)
static void Task_StartSendOutAnim(u8 taskId)
{
if (gTasks[taskId].data[1] < 24)
{
@ -1577,19 +1587,19 @@ static void sub_814DCCC(u8 taskId)
if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_814CC98(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
}
else
{
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_814CC98(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK;
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
sub_814CC98(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK;
}
gBattlerControllerFuncs[gActiveBattler] = sub_814B0E8;
gBattlerControllerFuncs[gActiveBattler] = Intro_ShowHealthbox;
gActiveBattler = savedActiveBank;
DestroyTask(taskId);
}
@ -1605,20 +1615,20 @@ static void LinkPartnerHandleDrawPartyStatusSummary(void)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1;
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)
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();
}
}
@ -1647,7 +1657,7 @@ static void LinkPartnerHandleSpriteInvisibility(void)
static void LinkPartnerHandleBattleAnimation(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
u8 animationId = gBattleBufferA[gActiveBattler][1];
u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8);
@ -1663,7 +1673,7 @@ static void LinkPartnerHandleBattleAnimation(void)
static void LinkPartnerHandleLinkStandbyMsg(void)
{
sub_81851A8(&gBattleBufferA[gActiveBattler][2]);
RecordedBattle_RecordAllBattlerData(&gBattleBufferA[gActiveBattler][2]);
LinkPartnerBufferExecCompleted();
}
@ -1672,15 +1682,15 @@ static void LinkPartnerHandleResetActionMoveSelection(void)
LinkPartnerBufferExecCompleted();
}
static void LinkPartnerHandleCmd55(void)
static void LinkPartnerHandleEndLinkBattle(void)
{
sub_81851A8(&gBattleBufferA[gActiveBattler][4]);
RecordedBattle_RecordAllBattlerData(&gBattleBufferA[gActiveBattler][4]);
gBattleOutcome = gBattleBufferA[gActiveBattler][1];
gSaveBlock2Ptr->frontier.disableRecordBattle = gBattleBufferA[gActiveBattler][2];
FadeOutMapMusic(5);
BeginFastPaletteFade(3);
LinkPartnerBufferExecCompleted();
gBattlerControllerFuncs[gActiveBattler] = sub_80587B0;
gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks;
}
static void LinkPartnerCmdEnd(void)

View File

@ -56,7 +56,7 @@ static void OpponentHandleMoveAnimation(void);
static void OpponentHandlePrintString(void);
static void OpponentHandlePrintSelectionString(void);
static void OpponentHandleChooseAction(void);
static void OpponentHandleUnknownYesNoBox(void);
static void OpponentHandleYesNoBox(void);
static void OpponentHandleChooseMove(void);
static void OpponentHandleChooseItem(void);
static void OpponentHandleChoosePokemon(void);
@ -92,20 +92,20 @@ static void OpponentHandleSpriteInvisibility(void);
static void OpponentHandleBattleAnimation(void);
static void OpponentHandleLinkStandbyMsg(void);
static void OpponentHandleResetActionMoveSelection(void);
static void OpponentHandleCmd55(void);
static void OpponentHandleEndLinkBattle(void);
static void OpponentCmdEnd(void);
static void OpponentBufferRunCommand(void);
static void OpponentBufferExecCompleted(void);
static void sub_805FC80(void);
static void SwitchIn_HandleSoundAndEnd(void);
static u32 GetOpponentMonData(u8 monId, u8 *dst);
static void SetOpponentMonData(u8 monId);
static void sub_80613DC(u8 battlerId, bool8 dontClearSubstituteBit);
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void OpponentDoMoveAnimation(void);
static void sub_806280C(struct Sprite *sprite);
static void sub_8062828(u8 taskId);
static void sub_8062A2C(void);
static void SpriteCB_FreeOpponentSprite(struct Sprite *sprite);
static void Task_StartSendOutAnim(u8 taskId);
static void EndDrawPartyStatusSummary(void);
static void (*const sOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
{
@ -128,7 +128,7 @@ static void (*const sOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
[CONTROLLER_PRINTSTRING] = OpponentHandlePrintString,
[CONTROLLER_PRINTSTRINGPLAYERONLY] = OpponentHandlePrintSelectionString,
[CONTROLLER_CHOOSEACTION] = OpponentHandleChooseAction,
[CONTROLLER_UNKNOWNYESNOBOX] = OpponentHandleUnknownYesNoBox,
[CONTROLLER_YESNOBOX] = OpponentHandleYesNoBox,
[CONTROLLER_CHOOSEMOVE] = OpponentHandleChooseMove,
[CONTROLLER_OPENBAG] = OpponentHandleChooseItem,
[CONTROLLER_CHOOSEPOKEMON] = OpponentHandleChoosePokemon,
@ -164,14 +164,14 @@ static void (*const sOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
[CONTROLLER_BATTLEANIMATION] = OpponentHandleBattleAnimation,
[CONTROLLER_LINKSTANDBYMSG] = OpponentHandleLinkStandbyMsg,
[CONTROLLER_RESETACTIONMOVESELECTION] = OpponentHandleResetActionMoveSelection,
[CONTROLLER_55] = OpponentHandleCmd55,
[CONTROLLER_ENDLINKBATTLE] = OpponentHandleEndLinkBattle,
[CONTROLLER_TERMINATOR_NOP] = OpponentCmdEnd
};
// unknown unused data
static const u8 sUnused[] = {0xB0, 0xB0, 0xC8, 0x98, 0x28, 0x28, 0x28, 0x20};
static void nullsub_26(void)
static void OpponentDummy(void)
{
}
@ -203,7 +203,7 @@ static void CompleteOnBankSpriteCallbackDummy2(void)
OpponentBufferExecCompleted();
}
static void sub_805F240(void)
static void FreeTrainerSpriteAfterSlide(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
@ -214,40 +214,40 @@ static void sub_805F240(void)
}
}
static void sub_805F2A8(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;
OpponentBufferExecCompleted();
}
}
static void sub_805F2F0(void)
static void Intro_WaitForShinyAnimAndHealthbox(void)
{
bool8 var = FALSE;
bool8 var2;
bool8 healthboxAnimDone = FALSE;
bool8 twoMons;
if (!IsDoubleBattle() || ((IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)) || (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)))
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
var = TRUE;
var2 = FALSE;
healthboxAnimDone = TRUE;
twoMons = FALSE;
}
else
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
var = TRUE;
var2 = TRUE;
healthboxAnimDone = TRUE;
twoMons = TRUE;
}
gUnknown_020244D8 = &gBattleSpritesDataPtr->healthBoxesData[gActiveBattler];
gUnknown_020244DC = &gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK];
gBattleControllerOpponentHealthboxData = &gBattleSpritesDataPtr->healthBoxesData[gActiveBattler];
gBattleControllerOpponentFlankHealthboxData = &gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK];
if (var)
if (healthboxAnimDone)
{
if (var2 == TRUE)
if (twoMons == TRUE)
{
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim)
@ -256,8 +256,8 @@ static void sub_805F2F0(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
}
else
return;
@ -269,8 +269,8 @@ static void sub_805F2F0(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim)
{
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
}
else
return;
@ -281,15 +281,15 @@ static void sub_805F2F0(void)
else
return;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3;
gBattlerControllerFuncs[gActiveBattler] = sub_805F2A8;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
gBattlerControllerFuncs[gActiveBattler] = Intro_DelayAndEnd;
}
}
static void sub_805F560(void)
static void Intro_TryShinyAnimShowHealthbox(void)
{
bool32 sp = FALSE;
bool32 r10 = FALSE;
bool32 bgmRestored = FALSE;
bool32 battlerAnimsDone = FALSE;
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
@ -306,27 +306,27 @@ static void sub_805F560(void)
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))
{
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]);
}
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler);
StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = TRUE;
}
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x40
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x40
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].waitForCry
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].waitForCry
&& !IsCryPlayingOrClearCrySongs())
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored)
{
if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK)
{
@ -336,48 +336,48 @@ static void sub_805F560(void)
else
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 1;
sp = TRUE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE;
bgmRestored = TRUE;
}
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)
{
r10 = TRUE;
battlerAnimsDone = TRUE;
}
}
else
{
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
if (gSprites[gBattleControllerData[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)
{
r10 = TRUE;
battlerAnimsDone = TRUE;
}
}
if (sp && r10)
if (bgmRestored && battlerAnimsDone)
{
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));
}
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattleSpritesDataPtr->animationData->field_9_x1 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0;
gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = FALSE;
gBattlerControllerFuncs[gActiveBattler] = sub_805F2F0;
gBattlerControllerFuncs[gActiveBattler] = Intro_WaitForShinyAnimAndHealthbox;
}
}
static void sub_805F994(void)
static void TryShinyAnimAfterMonAnim(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x == 0
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
@ -389,8 +389,8 @@ static void sub_805F994(void)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
OpponentBufferExecCompleted();
}
}
@ -407,7 +407,7 @@ static void CompleteOnHealthbarDone(void)
OpponentBufferExecCompleted();
}
static void sub_805FAC4(void)
static void HideHealthboxAfterMonFaint(void)
{
if (!gSprites[gBattlerSpriteIds[gActiveBattler]].inUse)
{
@ -416,7 +416,7 @@ static void sub_805FAC4(void)
}
}
static void sub_805FB08(void)
static void FreeMonSpriteAfterSwitchOutAnim(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{
@ -453,21 +453,22 @@ static void DoHitAnimBlinkSpriteEffect(void)
}
}
static void sub_805FC10(void)
static void SwitchIn_ShowSubstitute(void)
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattlerControllerFuncs[gActiveBattler] = sub_805FC80;
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_HandleSoundAndEnd;
}
}
static void sub_805FC80(void)
static void SwitchIn_HandleSoundAndEnd(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive && !IsCryPlayingOrClearCrySongs())
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy || gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2)
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|| gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2)
{
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
OpponentBufferExecCompleted();
@ -475,36 +476,36 @@ static void sub_805FC80(void)
}
}
static void sub_805FD00(void)
static void SwitchIn_ShowHealthbox(void)
{
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler);
StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
CopyBattleSpriteInvisibility(gActiveBattler);
gBattlerControllerFuncs[gActiveBattler] = sub_805FC10;
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowSubstitute;
}
}
static void sub_805FDF0(void)
static void SwitchIn_TryShinyAnim(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattlerControllerFuncs[gActiveBattler] = sub_805FD00;
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowHealthbox;
}
}
@ -1150,25 +1151,25 @@ static void OpponentHandleLoadMonSprite(void)
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattlerControllerFuncs[gActiveBattler] = sub_805F994;
gBattlerControllerFuncs[gActiveBattler] = TryShinyAnimAfterMonAnim;
}
static void OpponentHandleSwitchInAnim(void)
{
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = 6;
gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1];
sub_80613DC(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = sub_805FDF0;
StartSendOutAnim(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_TryShinyAnim;
}
static void sub_80613DC(u8 battlerId, bool8 dontClearSubstituteBit)
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
@ -1180,8 +1181,8 @@ static void sub_80613DC(u8 battlerId, bool8 dontClearSubstituteBit)
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattleControllerData[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gBattleControllerData[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
@ -1190,7 +1191,7 @@ static void sub_80613DC(u8 battlerId, bool8 dontClearSubstituteBit)
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
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)
@ -1225,12 +1226,14 @@ static void DoSwitchOutAnimation(void)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_OPPONENT_MON);
gBattlerControllerFuncs[gActiveBattler] = sub_805FB08;
gBattlerControllerFuncs[gActiveBattler] = FreeMonSpriteAfterSwitchOutAnim;
}
break;
}
}
#define sSpeedX data[0]
static void OpponentHandleDrawTrainerPic(void)
{
u32 trainerPicId;
@ -1308,10 +1311,10 @@ static void OpponentHandleDrawTrainerPic(void)
GetBattlerSpriteSubpriority(gActiveBattler));
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.affineParam = trainerPicId;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
}
@ -1378,14 +1381,16 @@ static void OpponentHandleTrainerSlide(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 96;
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.affineParam = trainerPicId;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2;
}
#undef sSpeedX
static void OpponentHandleTrainerSlideBack(void)
{
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
@ -1394,7 +1399,7 @@ static void OpponentHandleTrainerSlideBack(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
gBattlerControllerFuncs[gActiveBattler] = sub_805F240;
gBattlerControllerFuncs[gActiveBattler] = FreeTrainerSpriteAfterSlide;
}
static void OpponentHandleFaintAnimation(void)
@ -1412,7 +1417,7 @@ static void OpponentHandleFaintAnimation(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
PlaySE12WithPanning(SE_FAINT, SOUND_PAN_TARGET);
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_FaintOpponentMon;
gBattlerControllerFuncs[gActiveBattler] = sub_805FAC4;
gBattlerControllerFuncs[gActiveBattler] = HideHealthboxAfterMonFaint;
}
}
}
@ -1439,7 +1444,7 @@ static void OpponentHandlePause(void)
static void OpponentHandleMoveAnimation(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8);
@ -1481,7 +1486,7 @@ static void OpponentDoMoveAnimation(void)
case 1:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{
sub_805EB9C(ST_OAM_AFFINE_OFF);
SetBattlerSpriteAffineMode(ST_OAM_AFFINE_OFF);
DoMoveAnim(move);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2;
}
@ -1490,7 +1495,7 @@ static void OpponentDoMoveAnimation(void)
gAnimScriptCallback();
if (!gAnimScriptActive)
{
sub_805EB9C(ST_OAM_AFFINE_NORMAL);
SetBattlerSpriteAffineMode(ST_OAM_AFFINE_NORMAL);
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
{
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
@ -1535,7 +1540,7 @@ static void OpponentHandleChooseAction(void)
OpponentBufferExecCompleted();
}
static void OpponentHandleUnknownYesNoBox(void)
static void OpponentHandleYesNoBox(void)
{
OpponentBufferExecCompleted();
}
@ -1703,7 +1708,7 @@ static void OpponentHandleExpUpdate(void)
static void OpponentHandleStatusIconUpdate(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
u8 battlerId;
@ -1716,7 +1721,7 @@ static void OpponentHandleStatusIconUpdate(void)
static void OpponentHandleStatusAnimation(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1],
gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24));
@ -1867,26 +1872,26 @@ static void OpponentHandleIntroTrainerBallThrow(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_806280C);
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCB_FreeOpponentSprite);
taskId = CreateTask(sub_8062828, 5);
taskId = CreateTask(Task_StartSendOutAnim, 5);
gTasks[taskId].data[0] = gActiveBattler;
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1;
gBattlerControllerFuncs[gActiveBattler] = nullsub_26;
gBattleSpritesDataPtr->animationData->introAnimActive = TRUE;
gBattlerControllerFuncs[gActiveBattler] = OpponentDummy;
}
static void sub_806280C(struct Sprite *sprite)
static void SpriteCB_FreeOpponentSprite(struct Sprite *sprite)
{
FreeTrainerFrontPicPalette(sprite->oam.affineParam);
FreeSpriteOamMatrix(sprite);
DestroySprite(sprite);
}
static void sub_8062828(u8 taskId)
static void Task_StartSendOutAnim(u8 taskId)
{
u8 savedActiveBank = gActiveBattler;
@ -1894,23 +1899,23 @@ static void sub_8062828(u8 taskId)
if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_80613DC(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
}
else if ((gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS))
{
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_80613DC(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
}
else
{
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_80613DC(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK;
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_80613DC(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK;
}
gBattlerControllerFuncs[gActiveBattler] = sub_805F560;
gBattlerControllerFuncs[gActiveBattler] = Intro_TryShinyAnimShowHealthbox;
gActiveBattler = savedActiveBank;
DestroyTask(taskId);
}
@ -1939,20 +1944,20 @@ static void OpponentHandleDrawPartyStatusSummary(void)
}
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)
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();
}
}
@ -1981,7 +1986,7 @@ static void OpponentHandleSpriteInvisibility(void)
static void OpponentHandleBattleAnimation(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
u8 animationId = gBattleBufferA[gActiveBattler][1];
u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8);
@ -2003,7 +2008,7 @@ static void OpponentHandleResetActionMoveSelection(void)
OpponentBufferExecCompleted();
}
static void OpponentHandleCmd55(void)
static void OpponentHandleEndLinkBattle(void)
{
if (gBattleTypeFlags & BATTLE_TYPE_LINK && !(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER))
{

View File

@ -57,7 +57,7 @@ static void PlayerHandleMoveAnimation(void);
static void PlayerHandlePrintString(void);
static void PlayerHandlePrintSelectionString(void);
static void PlayerHandleChooseAction(void);
static void PlayerHandleUnknownYesNoBox(void);
static void PlayerHandleYesNoBox(void);
static void PlayerHandleChooseMove(void);
static void PlayerHandleChooseItem(void);
static void PlayerHandleChoosePokemon(void);
@ -93,7 +93,7 @@ static void PlayerHandleSpriteInvisibility(void);
static void PlayerHandleBattleAnimation(void);
static void PlayerHandleLinkStandbyMsg(void);
static void PlayerHandleResetActionMoveSelection(void);
static void PlayerHandleCmd55(void);
static void PlayerHandleEndLinkBattle(void);
static void PlayerCmdEnd(void);
static void PlayerBufferRunCommand(void);
@ -106,22 +106,22 @@ static void MoveSelectionDisplayPpString(void);
static void MoveSelectionDisplayMoveType(void);
static void MoveSelectionDisplayMoveNames(void);
static void HandleMoveSwitching(void);
static void sub_8058FC0(void);
static void SwitchIn_HandleSoundAndEnd(void);
static void WaitForMonSelection(void);
static void CompleteWhenChoseItem(void);
static void Task_LaunchLvlUpAnim(u8 taskId);
static void Task_PrepareToGiveExpWithExpBar(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 PrintLinkStandbyMsg(void);
static u32 CopyPlayerMonData(u8 monId, u8 *dst);
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 PlayerDoMoveAnimation(void);
static void task05_08033660(u8 taskId);
static void sub_805CE38(void);
static void Task_StartSendOutAnim(u8 taskId);
static void EndDrawPartyStatusSummary(void);
static void (*const sPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
{
@ -144,7 +144,7 @@ static void (*const sPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
[CONTROLLER_PRINTSTRING] = PlayerHandlePrintString,
[CONTROLLER_PRINTSTRINGPLAYERONLY] = PlayerHandlePrintSelectionString,
[CONTROLLER_CHOOSEACTION] = PlayerHandleChooseAction,
[CONTROLLER_UNKNOWNYESNOBOX] = PlayerHandleUnknownYesNoBox,
[CONTROLLER_YESNOBOX] = PlayerHandleYesNoBox,
[CONTROLLER_CHOOSEMOVE] = PlayerHandleChooseMove,
[CONTROLLER_OPENBAG] = PlayerHandleChooseItem,
[CONTROLLER_CHOOSEPOKEMON] = PlayerHandleChoosePokemon,
@ -180,16 +180,16 @@ static void (*const sPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
[CONTROLLER_BATTLEANIMATION] = PlayerHandleBattleAnimation,
[CONTROLLER_LINKSTANDBYMSG] = PlayerHandleLinkStandbyMsg,
[CONTROLLER_RESETACTIONMOVESELECTION] = PlayerHandleResetActionMoveSelection,
[CONTROLLER_55] = PlayerHandleCmd55,
[CONTROLLER_ENDLINKBATTLE] = PlayerHandleEndLinkBattle,
[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
static const u8 sUnused[] = {0x48, 0x48, 0x20, 0x5a, 0x50, 0x50, 0x50, 0x58};
void nullsub_21(void)
void BattleControllerDummy(void)
{
}
@ -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_MON);
@ -342,7 +342,7 @@ static void sub_80577F0(void) // unused
static void HandleInputChooseTarget(void)
{
s32 i;
u8 identities[4];
u8 identities[MAX_BATTLERS_COUNT];
memcpy(identities, sTargetIdentities, ARRAY_COUNT(sTargetIdentities));
DoBounceEffect(gMultiUsePlayerCursor, BOUNCE_HEALTHBOX, 15, 1);
@ -398,7 +398,11 @@ static void HandleInputChooseTarget(void)
do
{
if (--i < 0)
#ifdef UBFIX
i = MAX_BATTLERS_COUNT - 1;
#else
i = MAX_BATTLERS_COUNT; // UB: array out of range
#endif
gMultiUsePlayerCursor = GetBattlerAtPosition(identities[i]);
} while (gMultiUsePlayerCursor == gBattlersCount);
@ -613,7 +617,7 @@ static void HandleInputChooseMove(void)
}
}
u32 sub_8057FBC(void) // unused
static u32 HandleMoveInputUnused(void)
{
u32 var = 0;
@ -847,7 +851,7 @@ static void HandleMoveSwitching(void)
}
}
static void sub_80586F8(void)
static void SetLinkBattleEndCallbacks(void)
{
if (gWirelessCommType == 0)
{
@ -856,7 +860,7 @@ static void sub_80586F8(void)
m4aSongNumStop(SE_LOW_HEALTH);
gMain.inBattle = 0;
gMain.callback1 = gPreBattleCallback1;
SetMainCallback2(sub_8038D64);
SetMainCallback2(CB2_InitEndLinkBattle);
if (gBattleOutcome == B_OUTCOME_WON)
TryPutLinkBattleTvShowOnAir();
FreeAllWindowBuffers();
@ -869,7 +873,7 @@ static void sub_80586F8(void)
m4aSongNumStop(SE_LOW_HEALTH);
gMain.inBattle = 0;
gMain.callback1 = gPreBattleCallback1;
SetMainCallback2(sub_8038D64);
SetMainCallback2(CB2_InitEndLinkBattle);
if (gBattleOutcome == B_OUTCOME_WON)
TryPutLinkBattleTvShowOnAir();
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)
{
@ -890,7 +895,7 @@ void sub_80587B0(void)
else
SetLinkStandbyCallback();
gBattlerControllerFuncs[gActiveBattler] = sub_80586F8;
gBattlerControllerFuncs[gActiveBattler] = SetLinkBattleEndCallbacks;
}
}
else
@ -915,161 +920,174 @@ static void CompleteOnBankSpriteCallbackDummy2(void)
PlayerBufferExecCompleted();
}
static void sub_80588B4(void)
static void FreeTrainerSpriteAfterSlide(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
nullsub_25(gSaveBlock2Ptr->playerGender);
BattleGfxSfxDummy3(gSaveBlock2Ptr->playerGender);
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
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();
}
}
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 (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
var = TRUE;
healthboxAnimDone = TRUE;
}
else
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].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)
{
// Reset shiny anim (even if it didn't occur)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
if (IsDoubleBattle())
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], gActiveBattler ^ BIT_FLANK);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3;
gBattlerControllerFuncs[gActiveBattler] = sub_8058924;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
gBattlerControllerFuncs[gActiveBattler] = Intro_DelayAndEnd;
}
}
static void sub_8058B40(void)
static void Intro_TryShinyAnimShowHealthbox(void)
{
bool32 r9 = FALSE;
bool32 r8 = FALSE;
bool32 bgmRestored = FALSE;
bool32 battlerAnimsDone = FALSE;
// Start shiny animation if applicable for 1st pokemon
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
// Start shiny animation if applicable for 2nd pokemon
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive)
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))
{
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]);
}
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler);
StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = TRUE;
}
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x40
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x40
// Restore bgm after cry has played and healthbox anim is started
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].waitForCry
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].waitForCry
&& !IsCryPlayingOrClearCrySongs())
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored)
{
if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK)
m4aMPlayContinue(&gMPlayInfo_BGM);
else
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 1;
r9 = TRUE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE;
bgmRestored = TRUE;
}
// Wait for battler anims
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)
{
r8 = TRUE;
battlerAnimsDone = TRUE;
}
}
else
{
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
if (gSprites[gBattleControllerData[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)
{
r8 = TRUE;
battlerAnimsDone = TRUE;
}
}
if (r9 && r8)
// Clean up
if (bgmRestored && battlerAnimsDone)
{
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]);
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler ^ BIT_FLANK]]);
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
gBattleSpritesDataPtr->animationData->field_9_x1 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0;
gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = FALSE;
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
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
CopyBattleSpriteInvisibility(gActiveBattler);
// Reset shiny anim (even if it didn't occur)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
// Check if Substitute should be shown
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
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
&& !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
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
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)
{
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler);
StartHealthboxSlideIn(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())
{
@ -1196,10 +1216,10 @@ static void Task_PrepareToGiveExpWithExpBar(u8 taskId)
expToNextLvl = gExperienceTables[gBaseStats[species].growthRate][level + 1] - currLvlExp;
SetBattleBarStruct(battlerId, gHealthboxSpriteIds[battlerId], expToNextLvl, exp, -gainedExp);
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)
{
@ -1294,13 +1314,13 @@ static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8 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)
{
u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
nullsub_24(species);
BattleGfxSfxDummy2(species);
FreeOamMatrix(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.matrixNum);
DestroySprite(&gSprites[gBattlerSpriteIds[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)
{
@ -1332,8 +1352,8 @@ static void OpenPartyMenuToChooseMon(void)
u8 caseId;
gBattlerControllerFuncs[gActiveBattler] = WaitForMonSelection;
caseId = gTasks[gUnknown_03005D7C[gActiveBattler]].data[0];
DestroyTask(gUnknown_03005D7C[gActiveBattler]);
caseId = gTasks[gBattleControllerData[gActiveBattler]].data[0];
DestroyTask(gBattleControllerData[gActiveBattler]);
FreeAllWindowBuffers();
OpenPartyMenuInBattle(caseId);
}
@ -1360,7 +1380,7 @@ static void OpenBagAndChooseItem(void)
if (!gPaletteFade.active)
{
gBattlerControllerFuncs[gActiveBattler] = CompleteWhenChoseItem;
nullsub_35();
ReshowBattleScreenDummy();
FreeAllWindowBuffers();
CB2_BagMenuFromBattle();
}
@ -1400,7 +1420,7 @@ static void DoHitAnimBlinkSpriteEffect(void)
}
}
static void PlayerHandleUnknownYesNoInput(void)
static void PlayerHandleYesNoInput(void)
{
if (JOY_NEW(DPAD_UP) && gMultiUsePlayerCursor != 0)
{
@ -2171,18 +2191,18 @@ static void PlayerHandleSwitchInAnim(void)
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
gActionSelectionCursor[gActiveBattler] = 0;
gMoveSelectionCursor[gActiveBattler] = 0;
sub_805B258(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = sub_805902C;
StartSendOutAnim(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_TryShinyAnimShowHealthbox;
}
static void sub_805B258(u8 battlerId, bool8 dontClearSubstituteBit)
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[battlerId] = CreateSprite(
@ -2191,8 +2211,8 @@ static void sub_805B258(u8 battlerId, bool8 dontClearSubstituteBit)
GetBattlerSpriteDefault_Y(battlerId),
GetBattlerSpriteSubpriority(battlerId));
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattleControllerData[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gBattleControllerData[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
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]].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)
@ -2237,12 +2257,14 @@ static void DoSwitchOutAnimation(void)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON);
gBattlerControllerFuncs[gActiveBattler] = sub_8059744;
gBattlerControllerFuncs[gActiveBattler] = FreeMonSpriteAfterSwitchOutAnim;
}
break;
}
}
#define sSpeedX data[0]
// 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 an animated back pic.
@ -2306,10 +2328,10 @@ static void PlayerHandleDrawTrainerPic(void)
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler));
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]].data[0] = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineMode = ST_OAM_AFFINE_OFF;
gSprites[gBattlerSpriteIds[gActiveBattler]].hFlip = 1;
}
@ -2321,9 +2343,9 @@ static void PlayerHandleDrawTrainerPic(void)
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler));
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
}
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
@ -2361,12 +2383,14 @@ static void PlayerHandleTrainerSlide(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -96;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2;
}
#undef sSpeedX
static void PlayerHandleTrainerSlideBack(void)
{
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
@ -2376,9 +2400,12 @@ static void PlayerHandleTrainerSlideBack(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1);
gBattlerControllerFuncs[gActiveBattler] = sub_80588B4;
gBattlerControllerFuncs[gActiveBattler] = FreeTrainerSpriteAfterSlide;
}
#define sSpeedX data[1]
#define sSpeedY data[2]
static void PlayerHandleFaintAnimation(void)
{
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0)
@ -2394,14 +2421,17 @@ static void PlayerHandleFaintAnimation(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
PlaySE12WithPanning(SE_FAINT, SOUND_PAN_ATTACKER);
gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 5;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_8039C00;
gBattlerControllerFuncs[gActiveBattler] = sub_80596A8;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 0;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedY = 5;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_FaintSlideAnim;
gBattlerControllerFuncs[gActiveBattler] = FreeMonSpriteAfterFaintAnim;
}
}
}
#undef sSpeedX
#undef sSpeedY
static void PlayerHandlePaletteFade(void)
{
BeginNormalPaletteFade(0xFFFFFFFF, 2, 0, 16, RGB_BLACK);
@ -2428,18 +2458,17 @@ static void PlayerHandleBallThrowAnim(void)
static void PlayerHandlePause(void)
{
u8 var = gBattleBufferA[gActiveBattler][1];
u8 timer = gBattleBufferA[gActiveBattler][1];
// WTF is this??
while (var != 0)
var--;
while (timer != 0)
timer--;
PlayerBufferExecCompleted();
}
static void PlayerHandleMoveAnimation(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8);
@ -2482,7 +2511,7 @@ static void PlayerDoMoveAnimation(void)
case 1:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{
sub_805EB9C(ST_OAM_AFFINE_OFF);
SetBattlerSpriteAffineMode(ST_OAM_AFFINE_OFF);
DoMoveAnim(move);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2;
}
@ -2491,7 +2520,7 @@ static void PlayerDoMoveAnimation(void)
gAnimScriptCallback();
if (!gAnimScriptActive)
{
sub_805EB9C(ST_OAM_AFFINE_NORMAL);
SetBattlerSpriteAffineMode(ST_OAM_AFFINE_NORMAL);
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
{
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
@ -2560,7 +2589,7 @@ static void PlayerHandleChooseAction(void)
BattlePutTextOnWindow(gDisplayedStringBattle, 1);
}
static void PlayerHandleUnknownYesNoBox(void)
static void PlayerHandleYesNoBox(void)
{
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
{
@ -2568,7 +2597,7 @@ static void PlayerHandleUnknownYesNoBox(void)
BattlePutTextOnWindow(gText_BattleYesNoChoice, 12);
gMultiUsePlayerCursor = 1;
BattleCreateYesNoCursorAt(1);
gBattlerControllerFuncs[gActiveBattler] = PlayerHandleUnknownYesNoInput;
gBattlerControllerFuncs[gActiveBattler] = PlayerHandleYesNoInput;
}
else
{
@ -2648,10 +2677,10 @@ static void PlayerHandleChoosePokemon(void)
}
else
{
gUnknown_03005D7C[gActiveBattler] = CreateTask(TaskDummy, 0xFF);
gTasks[gUnknown_03005D7C[gActiveBattler]].data[0] = gBattleBufferA[gActiveBattler][1] & 0xF;
gBattleControllerData[gActiveBattler] = CreateTask(TaskDummy, 0xFF);
gTasks[gBattleControllerData[gActiveBattler]].data[0] = gBattleBufferA[gActiveBattler][1] & 0xF;
*(&gBattleStruct->battlerPreventingSwitchout) = gBattleBufferA[gActiveBattler][1] >> 4;
*(&gBattleStruct->field_8B) = gBattleBufferA[gActiveBattler][2];
*(&gBattleStruct->prevSelectedPartySlot) = gBattleBufferA[gActiveBattler][2];
*(&gBattleStruct->abilityPreventingSwitchout) = gBattleBufferA[gActiveBattler][3];
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
gBattlerControllerFuncs[gActiveBattler] = OpenPartyMenuToChooseMon;
@ -2715,7 +2744,7 @@ static void PlayerHandleExpUpdate(void)
gTasks[taskId].tExpTask_monId = monId;
gTasks[taskId].tExpTask_gainedExp = expPointsToGive;
gTasks[taskId].tExpTask_battler = gActiveBattler;
gBattlerControllerFuncs[gActiveBattler] = nullsub_21;
gBattlerControllerFuncs[gActiveBattler] = BattleControllerDummy;
}
}
@ -2726,7 +2755,7 @@ static void PlayerHandleExpUpdate(void)
static void PlayerHandleStatusIconUpdate(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
u8 battlerId;
@ -2739,7 +2768,7 @@ static void PlayerHandleStatusIconUpdate(void)
static void PlayerHandleStatusAnimation(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1],
gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24));
@ -2909,6 +2938,12 @@ static void PlayerHandleIntroSlide(void)
PlayerBufferExecCompleted();
}
// Task data for Task_StartSendOutAnim
#define tBattlerId data[0]
#define tStartTimer data[1]
#define sBattlerId data[5]
static void PlayerHandleIntroTrainerBallThrow(void)
{
u8 paletteNum;
@ -2920,68 +2955,77 @@ static void PlayerHandleIntroTrainerBallThrow(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
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);
paletteNum = AllocSpritePalette(0xD6F8);
LoadCompressedPalette(gTrainerBackPicPaletteTable[gSaveBlock2Ptr->playerGender].data, 0x100 + paletteNum * 16, 32);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum;
taskId = CreateTask(task05_08033660, 5);
gTasks[taskId].data[0] = gActiveBattler;
taskId = CreateTask(Task_StartSendOutAnim, 5);
gTasks[taskId].tBattlerId = gActiveBattler;
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1;
gBattlerControllerFuncs[gActiveBattler] = nullsub_21;
gBattleSpritesDataPtr->animationData->introAnimActive = TRUE;
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);
FreeSpritePaletteByTag(GetSpritePaletteTagByPaletteNum(sprite->oam.paletteNum));
DestroySprite(sprite);
// Load mon sprite
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[battlerId]], battlerId);
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
{
u8 savedActiveBattler = gActiveBattler;
gActiveBattler = gTasks[taskId].data[0];
gActiveBattler = gTasks[taskId].tBattlerId;
if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_805B258(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
}
else
{
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_805B258(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK;
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
sub_805B258(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK;
}
gBattlerControllerFuncs[gActiveBattler] = sub_8058B40;
gBattlerControllerFuncs[gActiveBattler] = Intro_TryShinyAnimShowHealthbox;
gActiveBattler = savedActiveBattler;
DestroyTask(taskId);
}
}
#undef tBattlerId
#undef tStartTimer
static void PlayerHandleDrawPartyStatusSummary(void)
{
if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
@ -2992,20 +3036,21 @@ static void PlayerHandleDrawPartyStatusSummary(void)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1;
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)
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();
}
}
@ -3036,7 +3081,7 @@ static void PlayerHandleSpriteInvisibility(void)
static void PlayerHandleBattleAnimation(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
u8 animationId = gBattleBufferA[gActiveBattler][1];
u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8);
@ -3052,7 +3097,7 @@ static void PlayerHandleBattleAnimation(void)
static void PlayerHandleLinkStandbyMsg(void)
{
sub_81851A8(&gBattleBufferA[gActiveBattler][2]);
RecordedBattle_RecordAllBattlerData(&gBattleBufferA[gActiveBattler][2]);
switch (gBattleBufferA[gActiveBattler][1])
{
case 0:
@ -3087,15 +3132,15 @@ static void PlayerHandleResetActionMoveSelection(void)
PlayerBufferExecCompleted();
}
static void PlayerHandleCmd55(void)
static void PlayerHandleEndLinkBattle(void)
{
sub_81851A8(&gBattleBufferA[gActiveBattler][4]);
RecordedBattle_RecordAllBattlerData(&gBattleBufferA[gActiveBattler][4]);
gBattleOutcome = gBattleBufferA[gActiveBattler][1];
gSaveBlock2Ptr->frontier.disableRecordBattle = gBattleBufferA[gActiveBattler][2];
FadeOutMapMusic(5);
BeginFastPaletteFade(3);
PlayerBufferExecCompleted();
gBattlerControllerFuncs[gActiveBattler] = sub_80587B0;
gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks;
}
static void PlayerCmdEnd(void)

View File

@ -47,7 +47,7 @@ static void PlayerPartnerHandleMoveAnimation(void);
static void PlayerPartnerHandlePrintString(void);
static void PlayerPartnerHandlePrintSelectionString(void);
static void PlayerPartnerHandleChooseAction(void);
static void PlayerPartnerHandleUnknownYesNoBox(void);
static void PlayerPartnerHandleYesNoBox(void);
static void PlayerPartnerHandleChooseMove(void);
static void PlayerPartnerHandleChooseItem(void);
static void PlayerPartnerHandleChoosePokemon(void);
@ -83,25 +83,24 @@ static void PlayerPartnerHandleSpriteInvisibility(void);
static void PlayerPartnerHandleBattleAnimation(void);
static void PlayerPartnerHandleLinkStandbyMsg(void);
static void PlayerPartnerHandleResetActionMoveSelection(void);
static void PlayerPartnerHandleCmd55(void);
static void PlayerPartnerHandleEndLinkBattle(void);
static void PlayerPartnerCmdEnd(void);
static void PlayerPartnerBufferRunCommand(void);
static void PlayerPartnerBufferExecCompleted(void);
static void sub_81BB628(u8 taskId);
static void Task_LaunchLvlUpAnim(u8 taskId);
static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8 taskId);
static void Task_PrepareToGiveExpWithExpBar(u8 taskId);
static void sub_81BB4E4(u8 taskId);
static void sub_81BB628(u8 taskId);
static void sub_81BB688(u8 taskId);
static void sub_81BB9A0(void);
static void Task_GiveExpWithExpBar(u8 taskId);
static void Task_UpdateLvlInHealthbox(u8 taskId);
static void SwitchIn_WaitAndEnd(void);
static u32 CopyPlayerPartnerMonData(u8 monId, u8 *dst);
static void SetPlayerPartnerMonData(u8 monId);
static void sub_81BD0E4(u8 battlerId, bool8 dontClearSubstituteBit);
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void PlayerPartnerDoMoveAnimation(void);
static void sub_81BE2C8(u8 taskId);
static void sub_81BE498(void);
static void Task_StartSendOutAnim(u8 taskId);
static void EndDrawPartyStatusSummary(void);
static void (*const sPlayerPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
{
@ -124,7 +123,7 @@ static void (*const sPlayerPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
[CONTROLLER_PRINTSTRING] = PlayerPartnerHandlePrintString,
[CONTROLLER_PRINTSTRINGPLAYERONLY] = PlayerPartnerHandlePrintSelectionString,
[CONTROLLER_CHOOSEACTION] = PlayerPartnerHandleChooseAction,
[CONTROLLER_UNKNOWNYESNOBOX] = PlayerPartnerHandleUnknownYesNoBox,
[CONTROLLER_YESNOBOX] = PlayerPartnerHandleYesNoBox,
[CONTROLLER_CHOOSEMOVE] = PlayerPartnerHandleChooseMove,
[CONTROLLER_OPENBAG] = PlayerPartnerHandleChooseItem,
[CONTROLLER_CHOOSEPOKEMON] = PlayerPartnerHandleChoosePokemon,
@ -160,7 +159,7 @@ static void (*const sPlayerPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
[CONTROLLER_BATTLEANIMATION] = PlayerPartnerHandleBattleAnimation,
[CONTROLLER_LINKSTANDBYMSG] = PlayerPartnerHandleLinkStandbyMsg,
[CONTROLLER_RESETACTIONMOVESELECTION] = PlayerPartnerHandleResetActionMoveSelection,
[CONTROLLER_55] = PlayerPartnerHandleCmd55,
[CONTROLLER_ENDLINKBATTLE] = PlayerPartnerHandleEndLinkBattle,
[CONTROLLER_TERMINATOR_NOP] = PlayerPartnerCmdEnd
};
@ -173,7 +172,7 @@ static const u8 sUnused[] =
0x3b, 0x43, 0xda, 0x36, 0x79, 0x2a, 0x0e, 0x53,
};
static void nullsub_77(void)
static void PlayerPartnerDummy(void)
{
}
@ -199,84 +198,84 @@ static void CompleteOnBattlerSpriteCallbackDummy(void)
PlayerPartnerBufferExecCompleted();
}
static void sub_81BAE98(void)
static void FreeTrainerSpriteAfterSlide(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
nullsub_25(0);
BattleGfxSfxDummy3(MALE);
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
PlayerPartnerBufferExecCompleted();
}
}
static void sub_81BAF00(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;
PlayerPartnerBufferExecCompleted();
}
}
static void sub_81BAF48(void)
static void Intro_WaitForHealthbox(void)
{
bool32 r6 = FALSE;
bool32 finished = FALSE;
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
r6 = TRUE;
finished = TRUE;
}
else
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
{
r6 = TRUE;
finished = TRUE;
}
}
if (IsCryPlayingOrClearCrySongs())
r6 = FALSE;
finished = FALSE;
if (r6)
if (finished)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3;
gBattlerControllerFuncs[gActiveBattler] = sub_81BAF00;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
gBattlerControllerFuncs[gActiveBattler] = Intro_DelayAndEnd;
}
}
static void sub_81BB02C(void)
static void Intro_ShowHealthbox(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive
&& gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattleControllerData[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))
{
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);
sub_8076918(gActiveBattler ^ BIT_FLANK);
StartHealthboxSlideIn(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);
sub_8076918(gActiveBattler);
StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattleSpritesDataPtr->animationData->field_9_x1 = 0;
gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
gBattlerControllerFuncs[gActiveBattler] = sub_81BAF48;
gBattlerControllerFuncs[gActiveBattler] = Intro_WaitForHealthbox;
}
}
static void sub_81BB1D4(void)
static void WaitForMonAnimAfterLoad(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded && gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x == 0)
PlayerPartnerBufferExecCompleted();
@ -339,7 +338,7 @@ static void Task_GiveExpToMon(u8 taskId)
if (IsDoubleBattle() == TRUE
&& ((u16)(monId) == gBattlerPartyIndexes[battlerId] || (u16)(monId) == gBattlerPartyIndexes[battlerId ^ BIT_FLANK]))
gTasks[taskId].func = sub_81BB628;
gTasks[taskId].func = Task_LaunchLvlUpAnim;
else
gTasks[taskId].func = DestroyExpTaskAndCompleteOnInactiveTextPrinter;
}
@ -373,10 +372,10 @@ static void Task_PrepareToGiveExpWithExpBar(u8 taskId)
expToNextLvl = gExperienceTables[gBaseStats[species].growthRate][level + 1] - currLvlExp;
SetBattleBarStruct(battlerId, gHealthboxSpriteIds[battlerId], expToNextLvl, exp, -gainedExp);
PlaySE(SE_EXP);
gTasks[taskId].func = sub_81BB4E4;
gTasks[taskId].func = Task_GiveExpWithExpBar;
}
static void sub_81BB4E4(u8 taskId)
static void Task_GiveExpWithExpBar(u8 taskId)
{
if (gTasks[taskId].tExpTask_frames < 13)
{
@ -415,7 +414,7 @@ static void sub_81BB4E4(u8 taskId)
gActiveBattler = battlerId;
BtlController_EmitTwoReturnValues(1, RET_VALUE_LEVELED_UP, gainedExp);
gActiveBattler = savedActiveBank;
gTasks[taskId].func = sub_81BB628;
gTasks[taskId].func = Task_LaunchLvlUpAnim;
}
else
{
@ -428,7 +427,7 @@ static void sub_81BB4E4(u8 taskId)
}
}
static void sub_81BB628(u8 taskId)
static void Task_LaunchLvlUpAnim(u8 taskId)
{
u8 battlerId = gTasks[taskId].tExpTask_bank;
u8 monIndex = gTasks[taskId].tExpTask_monId;
@ -437,10 +436,10 @@ static void sub_81BB628(u8 taskId)
battlerId ^= BIT_FLANK;
InitAndLaunchSpecialAnimation(battlerId, battlerId, battlerId, B_ANIM_LVL_UP);
gTasks[taskId].func = sub_81BB688;
gTasks[taskId].func = Task_UpdateLvlInHealthbox;
}
static void sub_81BB688(u8 taskId)
static void Task_UpdateLvlInHealthbox(u8 taskId)
{
u8 battlerId = gTasks[taskId].tExpTask_bank;
@ -471,13 +470,13 @@ static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8 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)
{
u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
nullsub_24(species);
BattleGfxSfxDummy2(species);
FreeOamMatrix(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.matrixNum);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
@ -485,7 +484,7 @@ static void sub_81BB78C(void)
}
}
static void sub_81BB828(void)
static void FreeMonSpriteAfterSwitchOutAnim(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{
@ -521,7 +520,7 @@ static void DoHitAnimBlinkSpriteEffect(void)
}
}
static void sub_81BB92C(void)
static void SwitchIn_ShowSubstitute(void)
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
@ -529,11 +528,11 @@ static void sub_81BB92C(void)
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattlerControllerFuncs[gActiveBattler] = sub_81BB9A0;
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_WaitAndEnd;
}
}
static void sub_81BB9A0(void)
static void SwitchIn_WaitAndEnd(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -542,28 +541,28 @@ static void sub_81BB9A0(void)
}
}
static void sub_81BB9F4(void)
static void SwitchIn_ShowHealthbox(void)
{
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
CreateTask(c3_0802FDF4, 10);
CreateTask(Task_PlayerController_RestoreBgmAfterCry, 10);
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler);
StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattlerControllerFuncs[gActiveBattler] = sub_81BB92C;
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowSubstitute;
}
}
static void sub_81BBAE8(void)
static void SwitchIn_TryShinyAnim(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
@ -571,11 +570,11 @@ static void sub_81BBAE8(void)
TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
}
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
gBattlerControllerFuncs[gActiveBattler] = sub_81BB9F4;
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowHealthbox;
}
}
@ -1210,7 +1209,7 @@ static void PlayerPartnerHandleLoadMonSprite(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]);
gBattlerControllerFuncs[gActiveBattler] = sub_81BB1D4;
gBattlerControllerFuncs[gActiveBattler] = WaitForMonAnimAfterLoad;
}
static void PlayerPartnerHandleSwitchInAnim(void)
@ -1218,18 +1217,18 @@ static void PlayerPartnerHandleSwitchInAnim(void)
ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1];
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
sub_81BD0E4(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = sub_81BBAE8;
StartSendOutAnim(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_TryShinyAnim;
}
static void sub_81BD0E4(u8 battlerId, bool8 dontClearSubstituteBit)
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[battlerId] = CreateSprite(
@ -1238,8 +1237,8 @@ static void sub_81BD0E4(u8 battlerId, bool8 dontClearSubstituteBit)
GetBattlerSpriteDefault_Y(battlerId),
GetBattlerSpriteSubpriority(battlerId));
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattleControllerData[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gBattleControllerData[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
@ -1250,7 +1249,7 @@ static void sub_81BD0E4(u8 battlerId, bool8 dontClearSubstituteBit)
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
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)
@ -1284,12 +1283,14 @@ static void DoSwitchOutAnimation(void)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON);
gBattlerControllerFuncs[gActiveBattler] = sub_81BB828;
gBattlerControllerFuncs[gActiveBattler] = FreeMonSpriteAfterSwitchOutAnim;
}
break;
}
}
#define sSpeedX data[0]
// some explanation here
// 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
@ -1319,9 +1320,9 @@ static void PlayerPartnerHandleDrawTrainerPic(void)
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler));
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
}
else // otherwise use front sprite
{
@ -1330,10 +1331,10 @@ static void PlayerPartnerHandleDrawTrainerPic(void)
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler));
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]].data[0] = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineMode = ST_OAM_AFFINE_OFF;
gSprites[gBattlerSpriteIds[gActiveBattler]].hFlip = 1;
}
@ -1341,6 +1342,8 @@ static void PlayerPartnerHandleDrawTrainerPic(void)
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
}
#undef sSpeedX
static void PlayerPartnerHandleTrainerSlide(void)
{
PlayerPartnerBufferExecCompleted();
@ -1354,9 +1357,12 @@ static void PlayerPartnerHandleTrainerSlideBack(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
gBattlerControllerFuncs[gActiveBattler] = sub_81BAE98;
gBattlerControllerFuncs[gActiveBattler] = FreeTrainerSpriteAfterSlide;
}
#define sSpeedX data[1]
#define sSpeedY data[2]
static void PlayerPartnerHandleFaintAnimation(void)
{
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0)
@ -1372,14 +1378,17 @@ static void PlayerPartnerHandleFaintAnimation(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
PlaySE12WithPanning(SE_FAINT, SOUND_PAN_ATTACKER);
gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 5;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_8039C00;
gBattlerControllerFuncs[gActiveBattler] = sub_81BB78C;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 0;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedY = 5;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_FaintSlideAnim;
gBattlerControllerFuncs[gActiveBattler] = FreeMonSpriteAfterFaintAnim;
}
}
}
#undef sSpeedX
#undef sSpeedY
static void PlayerPartnerHandlePaletteFade(void)
{
PlayerPartnerBufferExecCompleted();
@ -1402,7 +1411,7 @@ static void PlayerPartnerHandlePause(void)
static void PlayerPartnerHandleMoveAnimation(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8);
@ -1444,7 +1453,7 @@ static void PlayerPartnerDoMoveAnimation(void)
case 1:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{
sub_805EB9C(ST_OAM_AFFINE_OFF);
SetBattlerSpriteAffineMode(ST_OAM_AFFINE_OFF);
DoMoveAnim(move);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2;
}
@ -1453,7 +1462,7 @@ static void PlayerPartnerDoMoveAnimation(void)
gAnimScriptCallback();
if (!gAnimScriptActive)
{
sub_805EB9C(ST_OAM_AFFINE_NORMAL);
SetBattlerSpriteAffineMode(ST_OAM_AFFINE_NORMAL);
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
{
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
@ -1497,7 +1506,7 @@ static void PlayerPartnerHandleChooseAction(void)
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleUnknownYesNoBox(void)
static void PlayerPartnerHandleYesNoBox(void)
{
PlayerPartnerBufferExecCompleted();
}
@ -1602,7 +1611,7 @@ static void PlayerPartnerHandleExpUpdate(void)
gTasks[taskId].tExpTask_monId = monId;
gTasks[taskId].tExpTask_gainedExp = expPointsToGive;
gTasks[taskId].tExpTask_bank = gActiveBattler;
gBattlerControllerFuncs[gActiveBattler] = nullsub_21;
gBattlerControllerFuncs[gActiveBattler] = BattleControllerDummy;
}
}
@ -1613,7 +1622,7 @@ static void PlayerPartnerHandleExpUpdate(void)
static void PlayerPartnerHandleStatusIconUpdate(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
u8 battlerId;
@ -1626,7 +1635,7 @@ static void PlayerPartnerHandleStatusIconUpdate(void)
static void PlayerPartnerHandleStatusAnimation(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1],
gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24));
@ -1779,7 +1788,7 @@ static void PlayerPartnerHandleIntroTrainerBallThrow(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gActiveBattler;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_805CC00);
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCB_FreePlayerSpriteLoadMonSprite);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1);
paletteNum = AllocSpritePalette(0xD6F9);
@ -1797,17 +1806,17 @@ static void PlayerPartnerHandleIntroTrainerBallThrow(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum;
taskId = CreateTask(sub_81BE2C8, 5);
taskId = CreateTask(Task_StartSendOutAnim, 5);
gTasks[taskId].data[0] = gActiveBattler;
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1;
gBattlerControllerFuncs[gActiveBattler] = nullsub_77;
gBattleSpritesDataPtr->animationData->introAnimActive = TRUE;
gBattlerControllerFuncs[gActiveBattler] = PlayerPartnerDummy;
}
static void sub_81BE2C8(u8 taskId)
static void Task_StartSendOutAnim(u8 taskId)
{
if (gTasks[taskId].data[1] < 24)
{
@ -1821,19 +1830,19 @@ static void sub_81BE2C8(u8 taskId)
if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_81BD0E4(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
}
else
{
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_81BD0E4(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK;
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
sub_81BD0E4(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK;
}
gBattlerControllerFuncs[gActiveBattler] = sub_81BB02C;
gBattlerControllerFuncs[gActiveBattler] = Intro_ShowHealthbox;
gActiveBattler = savedActiveBank;
DestroyTask(taskId);
}
@ -1849,20 +1858,20 @@ static void PlayerPartnerHandleDrawPartyStatusSummary(void)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1;
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)
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();
}
}
@ -1891,7 +1900,7 @@ static void PlayerPartnerHandleSpriteInvisibility(void)
static void PlayerPartnerHandleBattleAnimation(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
u8 animationId = gBattleBufferA[gActiveBattler][1];
u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8);
@ -1913,13 +1922,13 @@ static void PlayerPartnerHandleResetActionMoveSelection(void)
PlayerPartnerBufferExecCompleted();
}
static void PlayerPartnerHandleCmd55(void)
static void PlayerPartnerHandleEndLinkBattle(void)
{
gBattleOutcome = gBattleBufferA[gActiveBattler][1];
FadeOutMapMusic(5);
BeginFastPaletteFade(3);
PlayerPartnerBufferExecCompleted();
gBattlerControllerFuncs[gActiveBattler] = sub_80587B0;
gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks;
}
static void PlayerPartnerCmdEnd(void)

View File

@ -51,7 +51,7 @@ static void RecordedOpponentHandleMoveAnimation(void);
static void RecordedOpponentHandlePrintString(void);
static void RecordedOpponentHandlePrintSelectionString(void);
static void RecordedOpponentHandleChooseAction(void);
static void RecordedOpponentHandleUnknownYesNoBox(void);
static void RecordedOpponentHandleYesNoBox(void);
static void RecordedOpponentHandleChooseMove(void);
static void RecordedOpponentHandleChooseItem(void);
static void RecordedOpponentHandleChoosePokemon(void);
@ -87,20 +87,20 @@ static void RecordedOpponentHandleSpriteInvisibility(void);
static void RecordedOpponentHandleBattleAnimation(void);
static void RecordedOpponentHandleLinkStandbyMsg(void);
static void RecordedOpponentHandleResetActionMoveSelection(void);
static void RecordedOpponentHandleCmd55(void);
static void RecordedOpponentHandleEndLinkBattle(void);
static void RecordedOpponentCmdEnd(void);
static void RecordedOpponentBufferRunCommand(void);
static void RecordedOpponentBufferExecCompleted(void);
static void sub_8186F14(void);
static void SwitchIn_HandleSoundAndEnd(void);
static u32 CopyRecordedOpponentMonData(u8 monId, u8 *dst);
static void SetRecordedOpponentMonData(u8 monId);
static void sub_81885D8(u8 battlerId, bool8 dontClearSubstituteBit);
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void RecordedOpponentDoMoveAnimation(void);
static void sub_8189548(u8 taskId);
static void sub_818962C(struct Sprite *sprite);
static void sub_818975C(void);
static void Task_StartSendOutAnim(u8 taskId);
static void SpriteCB_FreeOpponentSprite(struct Sprite *sprite);
static void EndDrawPartyStatusSummary(void);
static void (*const sRecordedOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
{
@ -123,7 +123,7 @@ static void (*const sRecordedOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void
[CONTROLLER_PRINTSTRING] = RecordedOpponentHandlePrintString,
[CONTROLLER_PRINTSTRINGPLAYERONLY] = RecordedOpponentHandlePrintSelectionString,
[CONTROLLER_CHOOSEACTION] = RecordedOpponentHandleChooseAction,
[CONTROLLER_UNKNOWNYESNOBOX] = RecordedOpponentHandleUnknownYesNoBox,
[CONTROLLER_YESNOBOX] = RecordedOpponentHandleYesNoBox,
[CONTROLLER_CHOOSEMOVE] = RecordedOpponentHandleChooseMove,
[CONTROLLER_OPENBAG] = RecordedOpponentHandleChooseItem,
[CONTROLLER_CHOOSEPOKEMON] = RecordedOpponentHandleChoosePokemon,
@ -159,11 +159,11 @@ static void (*const sRecordedOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void
[CONTROLLER_BATTLEANIMATION] = RecordedOpponentHandleBattleAnimation,
[CONTROLLER_LINKSTANDBYMSG] = RecordedOpponentHandleLinkStandbyMsg,
[CONTROLLER_RESETACTIONMOVESELECTION] = RecordedOpponentHandleResetActionMoveSelection,
[CONTROLLER_55] = RecordedOpponentHandleCmd55,
[CONTROLLER_ENDLINKBATTLE] = RecordedOpponentHandleEndLinkBattle,
[CONTROLLER_TERMINATOR_NOP] = RecordedOpponentCmdEnd
};
static void nullsub_70(void)
static void RecordedOpponentDummy(void)
{
}
@ -195,7 +195,7 @@ static void CompleteOnBankSpriteCallbackDummy2(void)
RecordedOpponentBufferExecCompleted();
}
static void sub_81865C8(void)
static void FreeTrainerSpriteAfterSlide(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
@ -206,24 +206,24 @@ static void sub_81865C8(void)
}
}
static void sub_8186630(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;
RecordedOpponentBufferExecCompleted();
}
}
static void sub_8186678(void)
static void Intro_WaitForShinyAnimAndHealthbox(void)
{
bool8 var = FALSE;
bool8 healthboxAnimDone = FALSE;
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded)
var = TRUE;
healthboxAnimDone = TRUE;
}
else
@ -232,10 +232,10 @@ static void sub_8186678(void)
&& gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded
&& gSprites[gBattlerSpriteIds[gActiveBattler ^ BIT_FLANK]].animEnded)
var = TRUE;
healthboxAnimDone = TRUE;
}
if (var)
if (healthboxAnimDone)
{
if (GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_LEFT)
{
@ -248,19 +248,19 @@ static void sub_8186678(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3;
gBattlerControllerFuncs[gActiveBattler] = sub_8186630;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
gBattlerControllerFuncs[gActiveBattler] = Intro_DelayAndEnd;
}
}
static void sub_818686C(void)
static void Intro_TryShinyAnimShowHealthbox(void)
{
bool32 r9 = FALSE;
bool32 r8 = FALSE;
bool32 bgmRestored = FALSE;
bool32 battlerAnimsDone = FALSE;
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
@ -272,27 +272,27 @@ static void sub_818686C(void)
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))
{
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]);
}
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler);
StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = TRUE;
}
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x40
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x40
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].waitForCry
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].waitForCry
&& !IsCryPlayingOrClearCrySongs())
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored)
{
if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK)
{
@ -304,49 +304,49 @@ static void sub_818686C(void)
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
}
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 1;
r9 = TRUE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE;
bgmRestored = TRUE;
}
if (!IsDoubleBattle())
{
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
r8 = TRUE;
battlerAnimsDone = TRUE;
}
}
else
{
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
if (gSprites[gBattleControllerData[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)
{
r8 = TRUE;
battlerAnimsDone = TRUE;
}
}
if (r9 && r8)
if (bgmRestored && battlerAnimsDone)
{
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));
}
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattleSpritesDataPtr->animationData->field_9_x1 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0;
gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = FALSE;
gBattlerControllerFuncs[gActiveBattler] = sub_8186678;
gBattlerControllerFuncs[gActiveBattler] = Intro_WaitForShinyAnimAndHealthbox;
}
}
static void sub_8186C48(void)
static void TryShinyAnimAfterMonAnim(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x == 0)
@ -361,8 +361,8 @@ static void sub_8186C48(void)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
RecordedOpponentBufferExecCompleted();
}
}
@ -385,7 +385,7 @@ static void CompleteOnHealthbarDone(void)
}
}
static void sub_8186D58(void)
static void HideHealthboxAfterMonFaint(void)
{
if (!gSprites[gBattlerSpriteIds[gActiveBattler]].inUse)
{
@ -394,7 +394,7 @@ static void sub_8186D58(void)
}
}
static void sub_8186D9C(void)
static void FreeMonSpriteAfterSwitchOutAnim(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{
@ -431,18 +431,18 @@ static void DoHitAnimBlinkSpriteEffect(void)
}
}
static void sub_8186EA4(void)
static void SwitchIn_ShowSubstitute(void)
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattlerControllerFuncs[gActiveBattler] = sub_8186F14;
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_HandleSoundAndEnd;
}
}
static void sub_8186F14(void)
static void SwitchIn_HandleSoundAndEnd(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive
&& !IsCryPlayingOrClearCrySongs())
@ -456,7 +456,7 @@ static void sub_8186F14(void)
}
}
static void sub_8186F94(void)
static void SwitchIn_ShowHealthbox(void)
{
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -464,31 +464,31 @@ static void sub_8186F94(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler);
StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
CopyBattleSpriteInvisibility(gActiveBattler);
gBattlerControllerFuncs[gActiveBattler] = sub_8186EA4;
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowSubstitute;
}
}
static void sub_8187084(void)
static void SwitchIn_TryShinyAnim(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim)
TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattlerControllerFuncs[gActiveBattler] = sub_8186F94;
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowHealthbox;
}
}
@ -1124,24 +1124,24 @@ static void RecordedOpponentHandleLoadMonSprite(void)
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattlerControllerFuncs[gActiveBattler] = sub_8186C48;
gBattlerControllerFuncs[gActiveBattler] = TryShinyAnimAfterMonAnim;
}
static void RecordedOpponentHandleSwitchInAnim(void)
{
gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1];
sub_81885D8(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = sub_8187084;
StartSendOutAnim(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_TryShinyAnim;
}
static void sub_81885D8(u8 battlerId, bool8 dontClearSubstituteBit)
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
@ -1150,8 +1150,8 @@ static void sub_81885D8(u8 battlerId, bool8 dontClearSubstituteBit)
GetBattlerSpriteDefault_Y(battlerId),
GetBattlerSpriteSubpriority(battlerId));
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattleControllerData[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gBattleControllerData[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
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]].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)
@ -1197,12 +1197,14 @@ static void DoSwitchOutAnimation(void)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_OPPONENT_MON);
gBattlerControllerFuncs[gActiveBattler] = sub_8186D9C;
gBattlerControllerFuncs[gActiveBattler] = FreeMonSpriteAfterSwitchOutAnim;
}
break;
}
}
#define sSpeedX data[0]
static void RecordedOpponentHandleDrawTrainerPic(void)
{
s16 xPos;
@ -1248,14 +1250,16 @@ static void RecordedOpponentHandleDrawTrainerPic(void)
GetBattlerSpriteSubpriority(gActiveBattler));
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.affineParam = trainerPicId;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
}
#undef sSpeedX
static void RecordedOpponentHandleTrainerSlide(void)
{
RecordedOpponentBufferExecCompleted();
@ -1269,7 +1273,7 @@ static void RecordedOpponentHandleTrainerSlideBack(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
gBattlerControllerFuncs[gActiveBattler] = sub_81865C8;
gBattlerControllerFuncs[gActiveBattler] = FreeTrainerSpriteAfterSlide;
}
static void RecordedOpponentHandleFaintAnimation(void)
@ -1287,7 +1291,7 @@ static void RecordedOpponentHandleFaintAnimation(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
PlaySE12WithPanning(SE_FAINT, SOUND_PAN_TARGET);
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_FaintOpponentMon;
gBattlerControllerFuncs[gActiveBattler] = sub_8186D58;
gBattlerControllerFuncs[gActiveBattler] = HideHealthboxAfterMonFaint;
}
}
}
@ -1314,7 +1318,7 @@ static void RecordedOpponentHandlePause(void)
static void RecordedOpponentHandleMoveAnimation(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8);
@ -1356,7 +1360,7 @@ static void RecordedOpponentDoMoveAnimation(void)
case 1:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{
sub_805EB9C(ST_OAM_AFFINE_OFF);
SetBattlerSpriteAffineMode(ST_OAM_AFFINE_OFF);
DoMoveAnim(move);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2;
}
@ -1365,7 +1369,7 @@ static void RecordedOpponentDoMoveAnimation(void)
gAnimScriptCallback();
if (!gAnimScriptActive)
{
sub_805EB9C(ST_OAM_AFFINE_NORMAL);
SetBattlerSpriteAffineMode(ST_OAM_AFFINE_NORMAL);
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
{
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
@ -1409,7 +1413,7 @@ static void RecordedOpponentHandleChooseAction(void)
RecordedOpponentBufferExecCompleted();
}
static void RecordedOpponentHandleUnknownYesNoBox(void)
static void RecordedOpponentHandleYesNoBox(void)
{
RecordedOpponentBufferExecCompleted();
}
@ -1478,7 +1482,7 @@ static void RecordedOpponentHandleExpUpdate(void)
static void RecordedOpponentHandleStatusIconUpdate(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
u8 battlerId;
@ -1491,7 +1495,7 @@ static void RecordedOpponentHandleStatusIconUpdate(void)
static void RecordedOpponentHandleStatusAnimation(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1],
gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24));
@ -1642,19 +1646,19 @@ static void RecordedOpponentHandleIntroTrainerBallThrow(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_818962C);
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCB_FreeOpponentSprite);
taskId = CreateTask(sub_8189548, 5);
taskId = CreateTask(Task_StartSendOutAnim, 5);
gTasks[taskId].data[0] = gActiveBattler;
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1;
gBattlerControllerFuncs[gActiveBattler] = nullsub_70;
gBattleSpritesDataPtr->animationData->introAnimActive = TRUE;
gBattlerControllerFuncs[gActiveBattler] = RecordedOpponentDummy;
}
static void sub_8189548(u8 taskId)
static void Task_StartSendOutAnim(u8 taskId)
{
u8 savedActiveBank = gActiveBattler;
@ -1662,23 +1666,23 @@ static void sub_8189548(u8 taskId)
if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_81885D8(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
}
else
{
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_81885D8(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK;
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_81885D8(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK;
}
gBattlerControllerFuncs[gActiveBattler] = sub_818686C;
gBattlerControllerFuncs[gActiveBattler] = Intro_TryShinyAnimShowHealthbox;
gActiveBattler = savedActiveBank;
DestroyTask(taskId);
}
static void sub_818962C(struct Sprite *sprite)
static void SpriteCB_FreeOpponentSprite(struct Sprite *sprite)
{
FreeTrainerFrontPicPalette(sprite->oam.affineParam);
FreeSpriteOamMatrix(sprite);
@ -1709,20 +1713,20 @@ static void RecordedOpponentHandleDrawPartyStatusSummary(void)
}
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)
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();
}
}
@ -1751,7 +1755,7 @@ static void RecordedOpponentHandleSpriteInvisibility(void)
static void RecordedOpponentHandleBattleAnimation(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
u8 animationId = gBattleBufferA[gActiveBattler][1];
u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8);
@ -1773,7 +1777,7 @@ static void RecordedOpponentHandleResetActionMoveSelection(void)
RecordedOpponentBufferExecCompleted();
}
static void RecordedOpponentHandleCmd55(void)
static void RecordedOpponentHandleEndLinkBattle(void)
{
if (gBattleBufferA[gActiveBattler][1] == B_OUTCOME_DREW)
gBattleOutcome = gBattleBufferA[gActiveBattler][1];
@ -1783,7 +1787,7 @@ static void RecordedOpponentHandleCmd55(void)
FadeOutMapMusic(5);
BeginFastPaletteFade(3);
RecordedOpponentBufferExecCompleted();
gBattlerControllerFuncs[gActiveBattler] = sub_80587B0;
gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks;
}
static void RecordedOpponentCmdEnd(void)

View File

@ -47,7 +47,7 @@ static void RecordedPlayerHandleMoveAnimation(void);
static void RecordedPlayerHandlePrintString(void);
static void RecordedPlayerHandlePrintSelectionString(void);
static void RecordedPlayerHandleChooseAction(void);
static void RecordedPlayerHandleUnknownYesNoBox(void);
static void RecordedPlayerHandleYesNoBox(void);
static void RecordedPlayerHandleChooseMove(void);
static void RecordedPlayerHandleChooseItem(void);
static void RecordedPlayerHandleChoosePokemon(void);
@ -83,19 +83,19 @@ static void RecordedPlayerHandleSpriteInvisibility(void);
static void RecordedPlayerHandleBattleAnimation(void);
static void RecordedPlayerHandleLinkStandbyMsg(void);
static void RecordedPlayerHandleResetActionMoveSelection(void);
static void RecordedPlayerHandleCmd55(void);
static void RecordedPlayerHandleEndLinkBattle(void);
static void RecordedPlayerCmdEnd(void);
static void RecordedPlayerBufferRunCommand(void);
static void RecordedPlayerBufferExecCompleted(void);
static void sub_818A328(void);
static void SwitchIn_WaitAndEnd(void);
static u32 CopyRecordedPlayerMonData(u8 monId, u8 *dst);
static void SetRecordedPlayerMonData(u8 monId);
static void sub_818BA6C(u8 battlerId, bool8 dontClearSubstituteBit);
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void RecordedPlayerDoMoveAnimation(void);
static void sub_818CC24(u8 taskId);
static void sub_818CDF4(void);
static void Task_StartSendOutAnim(u8 taskId);
static void EndDrawPartyStatusSummary(void);
static void (*const sRecordedPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
{
@ -118,7 +118,7 @@ static void (*const sRecordedPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void)
[CONTROLLER_PRINTSTRING] = RecordedPlayerHandlePrintString,
[CONTROLLER_PRINTSTRINGPLAYERONLY] = RecordedPlayerHandlePrintSelectionString,
[CONTROLLER_CHOOSEACTION] = RecordedPlayerHandleChooseAction,
[CONTROLLER_UNKNOWNYESNOBOX] = RecordedPlayerHandleUnknownYesNoBox,
[CONTROLLER_YESNOBOX] = RecordedPlayerHandleYesNoBox,
[CONTROLLER_CHOOSEMOVE] = RecordedPlayerHandleChooseMove,
[CONTROLLER_OPENBAG] = RecordedPlayerHandleChooseItem,
[CONTROLLER_CHOOSEPOKEMON] = RecordedPlayerHandleChoosePokemon,
@ -154,11 +154,11 @@ static void (*const sRecordedPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void)
[CONTROLLER_BATTLEANIMATION] = RecordedPlayerHandleBattleAnimation,
[CONTROLLER_LINKSTANDBYMSG] = RecordedPlayerHandleLinkStandbyMsg,
[CONTROLLER_RESETACTIONMOVESELECTION] = RecordedPlayerHandleResetActionMoveSelection,
[CONTROLLER_55] = RecordedPlayerHandleCmd55,
[CONTROLLER_ENDLINKBATTLE] = RecordedPlayerHandleEndLinkBattle,
[CONTROLLER_TERMINATOR_NOP] = RecordedPlayerCmdEnd
};
static void nullsub_120(void)
static void RecordedPlayerDummy(void)
{
}
@ -184,47 +184,47 @@ static void CompleteOnBattlerSpriteCallbackDummy(void)
RecordedPlayerBufferExecCompleted();
}
static void sub_81899F0(void)
static void FreeTrainerSpriteAfterSlide(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
nullsub_25(0);
BattleGfxSfxDummy3(MALE);
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
RecordedPlayerBufferExecCompleted();
}
}
static void sub_8189A58(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;
RecordedPlayerBufferExecCompleted();
}
}
static void sub_8189AA0(void)
static void Intro_WaitForShinyAnimAndHealthbox(void)
{
bool32 r6 = FALSE;
bool32 healthboxAnimDone = FALSE;
if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT)
{
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
r6 = TRUE;
healthboxAnimDone = TRUE;
}
else
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
{
r6 = TRUE;
healthboxAnimDone = TRUE;
}
}
if (r6 && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim
if (healthboxAnimDone && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
@ -233,15 +233,15 @@ static void sub_8189AA0(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
if (IsDoubleBattle())
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], gActiveBattler ^ BIT_FLANK);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3;
gBattlerControllerFuncs[gActiveBattler] = sub_8189A58;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
gBattlerControllerFuncs[gActiveBattler] = Intro_DelayAndEnd;
}
}
else
@ -249,31 +249,31 @@ static void sub_8189AA0(void)
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
r6 = TRUE;
healthboxAnimDone = TRUE;
}
else
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
{
r6 = TRUE;
healthboxAnimDone = TRUE;
}
}
if (IsCryPlayingOrClearCrySongs())
r6 = FALSE;
healthboxAnimDone = FALSE;
if (r6)
if (healthboxAnimDone)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3;
gBattlerControllerFuncs[gActiveBattler] = sub_8189A58;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
gBattlerControllerFuncs[gActiveBattler] = Intro_DelayAndEnd;
}
}
}
static void sub_8189D40(void)
static void Intro_TryShinyAnimShowHealthbox(void)
{
bool32 r10 = FALSE;
bool32 bgmRestored = FALSE;
if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT)
{
@ -289,27 +289,27 @@ static void sub_8189D40(void)
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))
{
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]);
}
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler);
StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = TRUE;
}
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x40
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x40
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].waitForCry
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].waitForCry
&& !IsCryPlayingOrClearCrySongs())
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored)
{
if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && (gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
@ -322,25 +322,25 @@ static void sub_8189D40(void)
}
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 1;
r10 = TRUE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE;
bgmRestored = TRUE;
}
if (r10 && gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
if (bgmRestored && gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]);
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler ^ BIT_FLANK]]);
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
gBattleSpritesDataPtr->animationData->field_9_x1 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0;
gBattlerControllerFuncs[gActiveBattler] = sub_8189AA0;
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = FALSE;
gBattlerControllerFuncs[gActiveBattler] = Intro_WaitForShinyAnimAndHealthbox;
}
}
static void sub_818A064(void)
static void WaitForMonAnimAfterLoad(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded && gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x == 0)
RecordedPlayerBufferExecCompleted();
@ -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)
{
u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
nullsub_24(species);
BattleGfxSfxDummy2(species);
FreeOamMatrix(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.matrixNum);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
@ -377,7 +377,7 @@ static void sub_818A114(void)
}
}
static void sub_818A1B0(void)
static void FreeMonSpriteAfterSwitchOutAnim(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{
@ -413,7 +413,7 @@ static void DoHitAnimBlinkSpriteEffect(void)
}
}
static void sub_818A2B4(void)
static void SwitchIn_ShowSubstitute(void)
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
@ -421,11 +421,11 @@ static void sub_818A2B4(void)
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattlerControllerFuncs[gActiveBattler] = sub_818A328;
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_WaitAndEnd;
}
}
static void sub_818A328(void)
static void SwitchIn_WaitAndEnd(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -434,28 +434,28 @@ static void sub_818A328(void)
}
}
static void sub_818A37C(void)
static void SwitchIn_ShowHealthbox(void)
{
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
CreateTask(c3_0802FDF4, 10);
CreateTask(Task_PlayerController_RestoreBgmAfterCry, 10);
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler);
StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattlerControllerFuncs[gActiveBattler] = sub_818A2B4;
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowSubstitute;
}
}
static void sub_818A470(void)
static void SwitchIn_TryShinyAnim(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
@ -463,11 +463,11 @@ static void sub_818A470(void)
TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
}
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
gBattlerControllerFuncs[gActiveBattler] = sub_818A37C;
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowHealthbox;
}
}
@ -1102,7 +1102,7 @@ static void RecordedPlayerHandleLoadMonSprite(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]);
gBattlerControllerFuncs[gActiveBattler] = sub_818A064;
gBattlerControllerFuncs[gActiveBattler] = WaitForMonAnimAfterLoad;
}
static void RecordedPlayerHandleSwitchInAnim(void)
@ -1110,18 +1110,18 @@ static void RecordedPlayerHandleSwitchInAnim(void)
ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1];
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
sub_818BA6C(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = sub_818A470;
StartSendOutAnim(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_TryShinyAnim;
}
static void sub_818BA6C(u8 battlerId, bool8 dontClearSubstituteBit)
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[battlerId] = CreateSprite(
@ -1130,8 +1130,8 @@ static void sub_818BA6C(u8 battlerId, bool8 dontClearSubstituteBit)
GetBattlerSpriteDefault_Y(battlerId),
GetBattlerSpriteSubpriority(battlerId));
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattleControllerData[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gBattleControllerData[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
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]].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)
@ -1176,12 +1176,14 @@ static void DoSwitchOutAnimation(void)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON);
gBattlerControllerFuncs[gActiveBattler] = sub_818A1B0;
gBattlerControllerFuncs[gActiveBattler] = FreeMonSpriteAfterSwitchOutAnim;
}
break;
}
}
#define sSpeedX data[0]
static void RecordedPlayerHandleDrawTrainerPic(void)
{
s16 xPos, yPos;
@ -1231,10 +1233,10 @@ static void RecordedPlayerHandleDrawTrainerPic(void)
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler));
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]].data[0] = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineMode = ST_OAM_AFFINE_OFF;
gSprites[gBattlerSpriteIds[gActiveBattler]].hFlip = 1;
}
@ -1245,14 +1247,16 @@ static void RecordedPlayerHandleDrawTrainerPic(void)
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler));
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
}
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
}
#undef sSpeedX
static void RecordedPlayerHandleTrainerSlide(void)
{
RecordedPlayerBufferExecCompleted();
@ -1266,9 +1270,12 @@ static void RecordedPlayerHandleTrainerSlideBack(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
gBattlerControllerFuncs[gActiveBattler] = sub_81899F0;
gBattlerControllerFuncs[gActiveBattler] = FreeTrainerSpriteAfterSlide;
}
#define sSpeedX data[1]
#define sSpeedY data[2]
static void RecordedPlayerHandleFaintAnimation(void)
{
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0)
@ -1284,14 +1291,17 @@ static void RecordedPlayerHandleFaintAnimation(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
PlaySE12WithPanning(SE_FAINT, -64);
gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 5;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_8039C00;
gBattlerControllerFuncs[gActiveBattler] = sub_818A114;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 0;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedY = 5;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_FaintSlideAnim;
gBattlerControllerFuncs[gActiveBattler] = FreeMonSpriteAfterFaintAnim;
}
}
}
#undef sSpeedX
#undef sSpeedY
static void RecordedPlayerHandlePaletteFade(void)
{
RecordedPlayerBufferExecCompleted();
@ -1314,7 +1324,7 @@ static void RecordedPlayerHandlePause(void)
static void RecordedPlayerHandleMoveAnimation(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8);
@ -1356,7 +1366,7 @@ static void RecordedPlayerDoMoveAnimation(void)
case 1:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{
sub_805EB9C(ST_OAM_AFFINE_OFF);
SetBattlerSpriteAffineMode(ST_OAM_AFFINE_OFF);
DoMoveAnim(move);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2;
}
@ -1365,7 +1375,7 @@ static void RecordedPlayerDoMoveAnimation(void)
gAnimScriptCallback();
if (!gAnimScriptActive)
{
sub_805EB9C(ST_OAM_AFFINE_NORMAL);
SetBattlerSpriteAffineMode(ST_OAM_AFFINE_NORMAL);
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
{
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
@ -1425,7 +1435,7 @@ static void RecordedPlayerHandleChooseAction(void)
}
}
static void RecordedPlayerHandleUnknownYesNoBox(void)
static void RecordedPlayerHandleYesNoBox(void)
{
RecordedPlayerBufferExecCompleted();
}
@ -1495,7 +1505,7 @@ static void RecordedPlayerHandleExpUpdate(void)
static void RecordedPlayerHandleStatusIconUpdate(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
u8 battlerId;
@ -1508,7 +1518,7 @@ static void RecordedPlayerHandleStatusIconUpdate(void)
static void RecordedPlayerHandleStatusAnimation(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1],
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]].data[5] = gActiveBattler;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_805CC00);
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCB_FreePlayerSpriteLoadMonSprite);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1);
paletteNum = AllocSpritePalette(0xD6F9);
@ -1675,17 +1685,17 @@ static void RecordedPlayerHandleIntroTrainerBallThrow(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum;
taskId = CreateTask(sub_818CC24, 5);
taskId = CreateTask(Task_StartSendOutAnim, 5);
gTasks[taskId].data[0] = gActiveBattler;
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1;
gBattlerControllerFuncs[gActiveBattler] = nullsub_120;
gBattleSpritesDataPtr->animationData->introAnimActive = TRUE;
gBattlerControllerFuncs[gActiveBattler] = RecordedPlayerDummy;
}
static void sub_818CC24(u8 taskId)
static void Task_StartSendOutAnim(u8 taskId)
{
if (gTasks[taskId].data[1] < 24)
{
@ -1699,19 +1709,19 @@ static void sub_818CC24(u8 taskId)
if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_818BA6C(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
}
else
{
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_818BA6C(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK;
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
sub_818BA6C(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK;
}
gBattlerControllerFuncs[gActiveBattler] = sub_8189D40;
gBattlerControllerFuncs[gActiveBattler] = Intro_TryShinyAnimShowHealthbox;
gActiveBattler = savedActiveBank;
DestroyTask(taskId);
}
@ -1727,20 +1737,20 @@ static void RecordedPlayerHandleDrawPartyStatusSummary(void)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1;
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)
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();
}
}
@ -1769,7 +1779,7 @@ static void RecordedPlayerHandleSpriteInvisibility(void)
static void RecordedPlayerHandleBattleAnimation(void)
{
if (!mplay_80342A4(gActiveBattler))
if (!IsBattleSEPlaying(gActiveBattler))
{
u8 animationId = gBattleBufferA[gActiveBattler][1];
u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8);
@ -1791,13 +1801,13 @@ static void RecordedPlayerHandleResetActionMoveSelection(void)
RecordedPlayerBufferExecCompleted();
}
static void RecordedPlayerHandleCmd55(void)
static void RecordedPlayerHandleEndLinkBattle(void)
{
gBattleOutcome = gBattleBufferA[gActiveBattler][1];
FadeOutMapMusic(5);
BeginFastPaletteFade(3);
RecordedPlayerBufferExecCompleted();
gBattlerControllerFuncs[gActiveBattler] = sub_80587B0;
gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks;
}
static void RecordedPlayerCmdEnd(void)

View File

@ -44,7 +44,7 @@ static void SafariHandleMoveAnimation(void);
static void SafariHandlePrintString(void);
static void SafariHandlePrintSelectionString(void);
static void SafariHandleChooseAction(void);
static void SafariHandleUnknownYesNoBox(void);
static void SafariHandleYesNoBox(void);
static void SafariHandleChooseMove(void);
static void SafariHandleChooseItem(void);
static void SafariHandleChoosePokemon(void);
@ -80,7 +80,7 @@ static void SafariHandleSpriteInvisibility(void);
static void SafariHandleBattleAnimation(void);
static void SafariHandleLinkStandbyMsg(void);
static void SafariHandleResetActionMoveSelection(void);
static void SafariHandleCmd55(void);
static void SafariHandleEndLinkBattle(void);
static void SafariCmdEnd(void);
static void SafariBufferRunCommand(void);
@ -108,7 +108,7 @@ static void (*const sSafariBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
[CONTROLLER_PRINTSTRING] = SafariHandlePrintString,
[CONTROLLER_PRINTSTRINGPLAYERONLY] = SafariHandlePrintSelectionString,
[CONTROLLER_CHOOSEACTION] = SafariHandleChooseAction,
[CONTROLLER_UNKNOWNYESNOBOX] = SafariHandleUnknownYesNoBox,
[CONTROLLER_YESNOBOX] = SafariHandleYesNoBox,
[CONTROLLER_CHOOSEMOVE] = SafariHandleChooseMove,
[CONTROLLER_OPENBAG] = SafariHandleChooseItem,
[CONTROLLER_CHOOSEPOKEMON] = SafariHandleChoosePokemon,
@ -144,7 +144,7 @@ static void (*const sSafariBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
[CONTROLLER_BATTLEANIMATION] = SafariHandleBattleAnimation,
[CONTROLLER_LINKSTANDBYMSG] = SafariHandleLinkStandbyMsg,
[CONTROLLER_RESETACTIONMOVESELECTION] = SafariHandleResetActionMoveSelection,
[CONTROLLER_55] = SafariHandleCmd55,
[CONTROLLER_ENDLINKBATTLE] = SafariHandleEndLinkBattle,
[CONTROLLER_TERMINATOR_NOP] = SafariCmdEnd
};
@ -251,7 +251,7 @@ static void CompleteOnHealthboxSpriteCallbackDummy(void)
SafariBufferExecCompleted();
}
static void sub_81595E4(void)
static void SafariSetBattleEndCallbacks(void)
{
if (!gPaletteFade.active)
{
@ -349,6 +349,8 @@ static void SafariHandleReturnMonToBall(void)
SafariBufferExecCompleted();
}
#define sSpeedX data[0]
static void SafariHandleDrawTrainerPic(void)
{
DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, gActiveBattler);
@ -359,12 +361,14 @@ static void SafariHandleDrawTrainerPic(void)
(8 - gTrainerBackPicCoords[gSaveBlock2Ptr->playerGender].size) * 4 + 80,
30);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
}
#undef sSpeedX
static void SafariHandleTrainerSlide(void)
{
SafariBufferExecCompleted();
@ -458,7 +462,7 @@ static void SafariHandleChooseAction(void)
BattlePutTextOnWindow(gDisplayedStringBattle, 1);
}
static void SafariHandleUnknownYesNoBox(void)
static void SafariHandleYesNoBox(void)
{
SafariBufferExecCompleted();
}
@ -627,7 +631,7 @@ static void SafariHandleIntroSlide(void)
static void SafariHandleIntroTrainerBallThrow(void)
{
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_SAFARI_ALL_TEXT);
sub_8076918(gActiveBattler);
StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthboxSpriteCallbackDummy;
}
@ -673,14 +677,14 @@ static void SafariHandleResetActionMoveSelection(void)
SafariBufferExecCompleted();
}
static void SafariHandleCmd55(void)
static void SafariHandleEndLinkBattle(void)
{
gBattleOutcome = gBattleBufferA[gActiveBattler][1];
FadeOutMapMusic(5);
BeginFastPaletteFade(3);
SafariBufferExecCompleted();
if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && !(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER))
gBattlerControllerFuncs[gActiveBattler] = sub_81595E4;
gBattlerControllerFuncs[gActiveBattler] = SafariSetBattleEndCallbacks;
}
static void SafariCmdEnd(void)

View File

@ -52,7 +52,7 @@ static void WallyHandleMoveAnimation(void);
static void WallyHandlePrintString(void);
static void WallyHandlePrintSelectionString(void);
static void WallyHandleChooseAction(void);
static void WallyHandleUnknownYesNoBox(void);
static void WallyHandleYesNoBox(void);
static void WallyHandleChooseMove(void);
static void WallyHandleChooseItem(void);
static void WallyHandleChoosePokemon(void);
@ -88,17 +88,17 @@ static void WallyHandleSpriteInvisibility(void);
static void WallyHandleBattleAnimation(void);
static void WallyHandleLinkStandbyMsg(void);
static void WallyHandleResetActionMoveSelection(void);
static void WallyHandleCmd55(void);
static void WallyHandleEndLinkBattle(void);
static void WallyCmdEnd(void);
static void WallyBufferRunCommand(void);
static void WallyBufferExecCompleted(void);
static void CompleteOnChosenItem(void);
static void sub_8168818(void);
static void Intro_WaitForShinyAnimAndHealthbox(void);
static u32 CopyWallyMonData(u8 monId, u8 *dst);
static void SetWallyMonData(u8 monId);
static void WallyDoMoveAnimation(void);
static void sub_816AC04(u8 taskId);
static void Task_StartSendOutAnim(u8 taskId);
static void (*const sWallyBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
{
@ -121,7 +121,7 @@ static void (*const sWallyBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
[CONTROLLER_PRINTSTRING] = WallyHandlePrintString,
[CONTROLLER_PRINTSTRINGPLAYERONLY] = WallyHandlePrintSelectionString,
[CONTROLLER_CHOOSEACTION] = WallyHandleChooseAction,
[CONTROLLER_UNKNOWNYESNOBOX] = WallyHandleUnknownYesNoBox,
[CONTROLLER_YESNOBOX] = WallyHandleYesNoBox,
[CONTROLLER_CHOOSEMOVE] = WallyHandleChooseMove,
[CONTROLLER_OPENBAG] = WallyHandleChooseItem,
[CONTROLLER_CHOOSEPOKEMON] = WallyHandleChoosePokemon,
@ -157,7 +157,7 @@ static void (*const sWallyBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
[CONTROLLER_BATTLEANIMATION] = WallyHandleBattleAnimation,
[CONTROLLER_LINKSTANDBYMSG] = WallyHandleLinkStandbyMsg,
[CONTROLLER_RESETACTIONMOVESELECTION] = WallyHandleResetActionMoveSelection,
[CONTROLLER_55] = WallyHandleCmd55,
[CONTROLLER_ENDLINKBATTLE] = WallyHandleEndLinkBattle,
[CONTROLLER_TERMINATOR_NOP] = WallyCmdEnd
};
@ -268,7 +268,7 @@ static void OpenBagAfterPaletteFade(void)
if (!gPaletteFade.active)
{
gBattlerControllerFuncs[gActiveBattler] = CompleteOnChosenItem;
nullsub_35();
ReshowBattleScreenDummy();
FreeAllWindowBuffers();
DoWallyTutorialBagMenu();
}
@ -283,7 +283,7 @@ static void CompleteOnChosenItem(void)
}
}
static void sub_816864C(void)
static void Intro_TryShinyAnimShowHealthbox(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
@ -295,35 +295,35 @@ static void sub_816864C(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive
&& gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
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);
sub_8076918(gActiveBattler ^ BIT_FLANK);
StartHealthboxSlideIn(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);
sub_8076918(gActiveBattler);
StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattleSpritesDataPtr->animationData->field_9_x1 = 0;
gBattlerControllerFuncs[gActiveBattler] = sub_8168818;
gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
gBattlerControllerFuncs[gActiveBattler] = Intro_WaitForShinyAnimAndHealthbox;
}
}
static void sub_8168818(void)
static void Intro_WaitForShinyAnimAndHealthbox(void)
{
bool32 r4 = FALSE;
bool32 healthboxAnimDone = FALSE;
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
r4 = TRUE;
healthboxAnimDone = TRUE;
if (r4 && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim
if (healthboxAnimDone && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
@ -332,10 +332,10 @@ static void sub_8168818(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9);
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
CreateTask(c3_0802FDF4, 10);
CreateTask(Task_PlayerController_RestoreBgmAfterCry, 10);
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
WallyBufferExecCompleted();
@ -378,7 +378,7 @@ static void DoHitAnimBlinkSpriteEffect(void)
}
}
static void sub_8168A20(void)
static void DoSwitchOutAnimation(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{
@ -1019,7 +1019,7 @@ static void WallyHandleReturnMonToBall(void)
if (gBattleBufferA[gActiveBattler][1] == 0)
{
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON);
gBattlerControllerFuncs[gActiveBattler] = sub_8168A20;
gBattlerControllerFuncs[gActiveBattler] = DoSwitchOutAnimation;
}
else
{
@ -1030,6 +1030,8 @@ static void WallyHandleReturnMonToBall(void)
}
}
#define sSpeedX data[0]
static void WallyHandleDrawTrainerPic(void)
{
DecompressTrainerBackPic(TRAINER_BACK_PIC_WALLY, gActiveBattler);
@ -1039,9 +1041,9 @@ static void WallyHandleDrawTrainerPic(void)
80 + 4 * (8 - gTrainerBackPicCoords[TRAINER_BACK_PIC_WALLY].size),
30);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
}
@ -1055,11 +1057,13 @@ static void WallyHandleTrainerSlide(void)
30);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -96;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2;
}
#undef sSpeedX
static void WallyHandleTrainerSlideBack(void)
{
WallyBufferExecCompleted();
@ -1137,7 +1141,7 @@ static void WallyDoMoveAnimation(void)
case 1:
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{
sub_805EB9C(ST_OAM_AFFINE_OFF);
SetBattlerSpriteAffineMode(ST_OAM_AFFINE_OFF);
DoMoveAnim(move);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2;
}
@ -1146,7 +1150,7 @@ static void WallyDoMoveAnimation(void)
gAnimScriptCallback();
if (!gAnimScriptActive)
{
sub_805EB9C(ST_OAM_AFFINE_NORMAL);
SetBattlerSpriteAffineMode(ST_OAM_AFFINE_NORMAL);
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
{
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
@ -1211,7 +1215,7 @@ static void WallyHandleChooseAction(void)
BattlePutTextOnWindow(gDisplayedStringBattle, 1);
}
static void WallyHandleUnknownYesNoBox(void)
static void WallyHandleYesNoBox(void)
{
WallyBufferExecCompleted();
}
@ -1435,39 +1439,39 @@ static void WallyHandleIntroTrainerBallThrow(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gActiveBattler;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_805CC00);
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCB_FreePlayerSpriteLoadMonSprite);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1);
paletteNum = AllocSpritePalette(0xD6F8);
LoadCompressedPalette(gTrainerBackPicPaletteTable[TRAINER_BACK_PIC_WALLY].data, 0x100 + paletteNum * 16, 32);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum;
taskId = CreateTask(sub_816AC04, 5);
taskId = CreateTask(Task_StartSendOutAnim, 5);
gTasks[taskId].data[0] = gActiveBattler;
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1;
gBattlerControllerFuncs[gActiveBattler] = nullsub_21;
gBattleSpritesDataPtr->animationData->introAnimActive = TRUE;
gBattlerControllerFuncs[gActiveBattler] = BattleControllerDummy;
}
static void sub_816AA80(u8 battlerId)
static void StartSendOutAnim(u8 battlerId)
{
u16 species;
gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies = 0;
gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714);
gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[battlerId] = CreateSprite(&gMultiuseSpriteTemplate,
GetBattlerSpriteCoord(battlerId, 2),
GetBattlerSpriteDefault_Y(battlerId),
GetBattlerSpriteSubpriority(battlerId));
gSprites[gUnknown_03005D7C[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gUnknown_03005D7C[battlerId]].data[2] = battlerId;
gSprites[gBattleControllerData[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gBattleControllerData[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
@ -1476,10 +1480,10 @@ static void sub_816AA80(u8 battlerId)
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], gBattleMonForms[battlerId]);
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
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 Task_StartSendOutAnim(u8 taskId)
{
if (gTasks[taskId].data[1] < 31)
{
@ -1491,8 +1495,8 @@ static void sub_816AC04(u8 taskId)
gActiveBattler = gTasks[taskId].data[0];
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_816AA80(gActiveBattler);
gBattlerControllerFuncs[gActiveBattler] = sub_816864C;
StartSendOutAnim(gActiveBattler);
gBattlerControllerFuncs[gActiveBattler] = Intro_TryShinyAnimShowHealthbox;
gActiveBattler = savedActiveBank;
DestroyTask(taskId);
}
@ -1548,7 +1552,7 @@ static void WallyHandleResetActionMoveSelection(void)
WallyBufferExecCompleted();
}
static void WallyHandleCmd55(void)
static void WallyHandleEndLinkBattle(void)
{
gBattleOutcome = gBattleBufferA[gActiveBattler][1];
FadeOutMapMusic(5);
@ -1556,7 +1560,7 @@ static void WallyHandleCmd55(void)
WallyBufferExecCompleted();
if (!(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER) && gBattleTypeFlags & BATTLE_TYPE_LINK)
gBattlerControllerFuncs[gActiveBattler] = sub_80587B0;
gBattlerControllerFuncs[gActiveBattler] = SetBattleEndCallbacks;
}
static void WallyCmdEnd(void)

View File

@ -16,11 +16,10 @@
static EWRAM_DATA u8 sLinkSendTaskId = 0;
static EWRAM_DATA u8 sLinkReceiveTaskId = 0;
static EWRAM_DATA u8 sUnknown_02022D0A = 0;
static EWRAM_DATA u8 sUnused = 0; // Debug? Never read
EWRAM_DATA struct UnusedControllerStruct gUnusedControllerStruct = {}; // Debug? Unused code that writes to it, never read
static EWRAM_DATA u8 sBattleBuffersTransferData[0x100] = {};
// this file's funcionts
static void CreateTasksForSendRecvLinkBuffers(void);
static void InitLinkBtlControllers(void);
static void InitSinglePlayerBtlControllers(void);
@ -45,11 +44,11 @@ void SetUpBattleVarsAndBirchZigzagoon(void)
{
s32 i;
gBattleMainFunc = nullsub_20;
gBattleMainFunc = BeginBattleIntroDummy;
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
gBattlerControllerFuncs[i] = nullsub_21;
gBattlerControllerFuncs[i] = BattleControllerDummy;
gBattlerPositions[i] = 0xFF;
gActionSelectionCursor[i] = 0;
gMoveSelectionCursor[i] = 0;
@ -69,18 +68,19 @@ void SetUpBattleVarsAndBirchZigzagoon(void)
SetMonData(&gEnemyParty[0], MON_DATA_HELD_ITEM, &i);
}
gUnknown_02022FF4 = 0;
gUnknown_0202428C = 0;
// Below are never read
gUnusedFirstBattleVar1 = 0;
gUnusedFirstBattleVar2 = 0;
}
void sub_8032768(void)
void InitBattleControllers(void)
{
s32 i;
if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED))
sub_8184DA4(1);
RecordedBattle_Init(B_RECORD_MODE_RECORDING);
else
sub_8184DA4(2);
RecordedBattle_Init(B_RECORD_MODE_PLAYBACK);
if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED))
RecordedBattle_SaveParties();
@ -693,7 +693,7 @@ static void CreateTasksForSendRecvLinkBuffers(void)
gTasks[sLinkReceiveTaskId].data[14] = 0;
gTasks[sLinkReceiveTaskId].data[15] = 0;
sUnknown_02022D0A = 0;
sUnused = 0;
}
enum
@ -819,7 +819,7 @@ static void Task_HandleSendLinkBuffersData(u8 taskId)
}
}
void sub_8033648(void)
void TryReceiveLinkBattleData(void)
{
u8 i;
s32 j;
@ -836,9 +836,9 @@ void sub_8033648(void)
recvBuffer = (u8 *)gBlockRecvBuffer[i];
{
u8 *dest, *src;
u16 r6 = gBlockRecvBuffer[i][2];
u16 dataSize = gBlockRecvBuffer[i][2];
if (gTasks[sLinkReceiveTaskId].data[14] + 9 + r6 > 0x1000)
if (gTasks[sLinkReceiveTaskId].data[14] + 9 + dataSize > 0x1000)
{
gTasks[sLinkReceiveTaskId].data[12] = gTasks[sLinkReceiveTaskId].data[14];
gTasks[sLinkReceiveTaskId].data[14] = 0;
@ -847,10 +847,10 @@ void sub_8033648(void)
dest = &gLinkBattleRecvBuffer[gTasks[sLinkReceiveTaskId].data[14]];
src = recvBuffer;
for (j = 0; j < r6 + 8; j++)
for (j = 0; j < dataSize + 8; j++)
dest[j] = src[j];
gTasks[sLinkReceiveTaskId].data[14] = gTasks[sLinkReceiveTaskId].data[14] + r6 + 8;
gTasks[sLinkReceiveTaskId].data[14] = gTasks[sLinkReceiveTaskId].data[14] + dataSize + 8;
}
}
}
@ -881,7 +881,7 @@ static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId)
return;
memcpy(gBattleBufferA[battlerId], &gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_DATA], blockSize);
sub_803F850(battlerId);
MarkBattlerReceivedLinkData(battlerId);
if (!(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER))
{
@ -1143,12 +1143,14 @@ void BtlController_EmitChooseAction(u8 bufferId, u8 arg1, u16 arg2)
PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4);
}
void BtlController_EmitUnknownYesNoBox(u8 bufferId)
// Only used by the forfeit prompt in the Battle Frontier
// For other Yes/No boxes in battle, see Cmd_yesnobox
void BtlController_EmitYesNoBox(u8 bufferId)
{
sBattleBuffersTransferData[0] = CONTROLLER_UNKNOWNYESNOBOX;
sBattleBuffersTransferData[1] = CONTROLLER_UNKNOWNYESNOBOX;
sBattleBuffersTransferData[2] = CONTROLLER_UNKNOWNYESNOBOX;
sBattleBuffersTransferData[3] = CONTROLLER_UNKNOWNYESNOBOX;
sBattleBuffersTransferData[0] = CONTROLLER_YESNOBOX;
sBattleBuffersTransferData[1] = CONTROLLER_YESNOBOX;
sBattleBuffersTransferData[2] = CONTROLLER_YESNOBOX;
sBattleBuffersTransferData[3] = CONTROLLER_YESNOBOX;
PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4);
}
@ -1435,13 +1437,13 @@ void BtlController_EmitIntroTrainerBallThrow(u8 bufferId)
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;
sBattleBuffersTransferData[0] = CONTROLLER_DRAWPARTYSTATUSSUMMARY;
sBattleBuffersTransferData[1] = arg2 & 0x7F;
sBattleBuffersTransferData[2] = (arg2 & 0x80) >> 7;
sBattleBuffersTransferData[1] = flags & 0x7F;
sBattleBuffersTransferData[2] = (flags & 0x80) >> 7; // If true, skip delay after drawing. True during intro
sBattleBuffersTransferData[3] = CONTROLLER_DRAWPARTYSTATUSSUMMARY;
for (i = 0; i < (s32)(sizeof(struct HpAndStatus) * PARTY_SIZE); i++)
sBattleBuffersTransferData[4 + i] = *(i + (u8*)(hpAndStatus));
@ -1484,14 +1486,14 @@ void BtlController_EmitBattleAnimation(u8 bufferId, u8 animationId, u16 argument
PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4);
}
void BtlController_EmitLinkStandbyMsg(u8 bufferId, u8 arg1, bool32 arg2)
void BtlController_EmitLinkStandbyMsg(u8 bufferId, u8 arg1, bool32 record)
{
bool8 arg2_ = arg2;
bool8 record_ = record;
sBattleBuffersTransferData[0] = CONTROLLER_LINKSTANDBYMSG;
sBattleBuffersTransferData[1] = arg1;
if (arg2_)
sBattleBuffersTransferData[3] = sBattleBuffersTransferData[2] = sub_81850DC(&sBattleBuffersTransferData[4]);
if (record_)
sBattleBuffersTransferData[3] = sBattleBuffersTransferData[2] = RecordedBattle_BufferNewBattlerData(&sBattleBuffersTransferData[4]);
else
sBattleBuffersTransferData[3] = sBattleBuffersTransferData[2] = 0;
@ -1505,12 +1507,12 @@ void BtlController_EmitResetActionMoveSelection(u8 bufferId, u8 caseId)
PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 2);
}
void BtlController_EmitCmd55(u8 bufferId, u8 battleOutcome)
void BtlController_EmitEndLinkBattle(u8 bufferId, u8 battleOutcome)
{
sBattleBuffersTransferData[0] = CONTROLLER_55;
sBattleBuffersTransferData[0] = CONTROLLER_ENDLINKBATTLE;
sBattleBuffersTransferData[1] = battleOutcome;
sBattleBuffersTransferData[2] = gSaveBlock2Ptr->frontier.disableRecordBattle;
sBattleBuffersTransferData[3] = gSaveBlock2Ptr->frontier.disableRecordBattle;
sBattleBuffersTransferData[5] = sBattleBuffersTransferData[4] = sub_81850DC(&sBattleBuffersTransferData[6]);
sBattleBuffersTransferData[5] = sBattleBuffersTransferData[4] = RecordedBattle_BufferNewBattlerData(&sBattleBuffersTransferData[6]);
PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, sBattleBuffersTransferData[4] + 6);
}

View File

@ -39,7 +39,7 @@ extern const struct SpriteTemplate gSpriteTemplate_EnemyShadow;
// this file's functions
static u8 GetBattlePalaceMoveGroup(u16 move);
static u16 GetBattlePalaceTarget(void);
static void sub_805D7EC(struct Sprite *sprite);
static void SpriteCB_TrainerSlideVertical(struct Sprite *sprite);
static bool8 ShouldAnimBeDoneRegardlessOfSubsitute(u8 animId);
static void Task_ClearBitWhenBattleTableAnimDone(u8 taskId);
static void Task_ClearBitWhenSpecialAnimDone(u8 taskId);
@ -336,7 +336,8 @@ static u16 GetBattlePalaceTarget(void)
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];
@ -356,9 +357,9 @@ void sub_805D714(struct Sprite *sprite)
}
}
void sub_805D770(struct Sprite *sprite, bool8 arg1)
static void UnusedDoBattleSpriteAffineAnim(struct Sprite *sprite, bool8 arg1)
{
sprite->animPaused = 1;
sprite->animPaused = TRUE;
sprite->callback = SpriteCallbackDummy;
if (!arg1)
@ -369,28 +370,33 @@ void sub_805D770(struct Sprite *sprite, bool8 arg1)
AnimateSprite(sprite);
}
void sub_805D7AC(struct Sprite *sprite)
#define sSpeedX data[0]
void SpriteCB_TrainerSlideIn(struct Sprite *sprite)
{
if (!(gIntroSlideFlags & 1))
{
sprite->pos2.x += sprite->data[0];
sprite->pos2.x += sprite->sSpeedX;
if (sprite->pos2.x == 0)
{
if (sprite->pos2.y != 0)
sprite->callback = sub_805D7EC;
sprite->callback = SpriteCB_TrainerSlideVertical;
else
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;
if (sprite->pos2.y == 0)
sprite->callback = SpriteCallbackDummy;
}
#undef sSpeedX
void InitAndLaunchChosenStatusAnimation(bool8 isStatus2, u32 status)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive = 1;
@ -522,14 +528,15 @@ bool8 IsMoveWithoutAnimation(u16 moveId, u8 animationTurn)
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;
if (IsSEPlaying())
{
gBattleSpritesDataPtr->healthBoxesData[battlerId].field_8++;
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_8 < 30)
gBattleSpritesDataPtr->healthBoxesData[battlerId].soundTimer++;
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].soundTimer < 30)
return TRUE;
m4aMPlayStop(&gMPlayInfo_SE1);
@ -537,10 +544,11 @@ bool8 mplay_80342A4(u8 battlerId)
}
if (zero == 0)
{
gBattleSpritesDataPtr->healthBoxesData[battlerId].field_8 = 0;
gBattleSpritesDataPtr->healthBoxesData[battlerId].soundTimer = 0;
return FALSE;
}
// Never reached
return TRUE;
}
@ -621,7 +629,7 @@ void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 battlerId)
otId = GetMonData(mon, MON_DATA_OT_ID);
position = GetBattlerPosition(battlerId);
if (sub_80688F8(1, battlerId) == 1 || gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies != SPECIES_NONE)
if (ShouldIgnoreDeoxysForm(1, battlerId) == TRUE || gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies != SPECIES_NONE)
{
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[species],
gMonSpritesGfxPtr->sprites.ptr[position],
@ -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);
}
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;
@ -1246,7 +1255,7 @@ void AllocateMonSpritesGfx(void)
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
gMonSpritesGfxPtr->sprites.ptr[i] = gMonSpritesGfxPtr->firstDecompressed + (i * 0x2000);
*(gMonSpritesGfxPtr->templates + i) = gUnknown_08329D98[i];
*(gMonSpritesGfxPtr->templates + i) = gBattlerSpriteTemplates[i];
for (j = 0; j < 4; j++)
{

View File

@ -13,8 +13,8 @@
static EWRAM_DATA u16 sBgCnt = 0;
extern const u8 gUnknown_0859741A[];
extern const u8 gUnknown_0859741E[];
extern const u8 gBattleAnimBgCntSet[];
extern const u8 gBattleAnimBgCntGet[];
static void BattleIntroSlide1(u8);
static void BattleIntroSlide2(u8);
@ -24,23 +24,23 @@ static void BattleIntroSlidePartner(u8);
static const TaskFunc sBattleIntroSlideFuncs[] =
{
BattleIntroSlide1, // BATTLE_TERRAIN_GRASS
BattleIntroSlide1, // BATTLE_TERRAIN_LONG_GRASS
BattleIntroSlide2, // BATTLE_TERRAIN_SAND
BattleIntroSlide2, // BATTLE_TERRAIN_UNDERWATER
BattleIntroSlide2, // BATTLE_TERRAIN_WATER
BattleIntroSlide1, // BATTLE_TERRAIN_POND
BattleIntroSlide1, // BATTLE_TERRAIN_MOUNTAIN
BattleIntroSlide1, // BATTLE_TERRAIN_CAVE
BattleIntroSlide3, // BATTLE_TERRAIN_BUILDING
BattleIntroSlide3, // BATTLE_TERRAIN_PLAIN
[BATTLE_TERRAIN_GRASS] = BattleIntroSlide1,
[BATTLE_TERRAIN_LONG_GRASS] = BattleIntroSlide1,
[BATTLE_TERRAIN_SAND] = BattleIntroSlide2,
[BATTLE_TERRAIN_UNDERWATER] = BattleIntroSlide2,
[BATTLE_TERRAIN_WATER] = BattleIntroSlide2,
[BATTLE_TERRAIN_POND] = BattleIntroSlide1,
[BATTLE_TERRAIN_MOUNTAIN] = BattleIntroSlide1,
[BATTLE_TERRAIN_CAVE] = BattleIntroSlide1,
[BATTLE_TERRAIN_BUILDING] = BattleIntroSlide3,
[BATTLE_TERRAIN_PLAIN] = BattleIntroSlide3,
};
void SetAnimBgAttribute(u8 bgId, u8 attributeId, u8 value)
{
if (bgId < 4)
{
sBgCnt = GetGpuReg(gUnknown_0859741A[bgId]);
sBgCnt = GetGpuReg(gBattleAnimBgCntSet[bgId]);
switch (attributeId)
{
case BG_ANIM_SCREEN_SIZE:
@ -66,7 +66,7 @@ void SetAnimBgAttribute(u8 bgId, u8 attributeId, u8 value)
break;
}
SetGpuReg(gUnknown_0859741A[bgId], sBgCnt);
SetGpuReg(gBattleAnimBgCntSet[bgId], sBgCnt);
}
}
@ -76,7 +76,7 @@ int GetAnimBgAttribute(u8 bgId, u8 attributeId)
if (bgId < 4)
{
bgCnt = GetGpuReg(gUnknown_0859741E[bgId]);
bgCnt = GetGpuReg(gBattleAnimBgCntGet[bgId]);
switch (attributeId)
{
case BG_ANIM_SCREEN_SIZE:
@ -99,6 +99,9 @@ int GetAnimBgAttribute(u8 bgId, u8 attributeId)
return 0;
}
#define tState data[0]
#define tTerrain data[1]
void HandleIntroSlide(u8 terrain)
{
u8 taskId;
@ -125,8 +128,8 @@ void HandleIntroSlide(u8 terrain)
taskId = CreateTask(sBattleIntroSlideFuncs[terrain], 0);
}
gTasks[taskId].data[0] = 0;
gTasks[taskId].data[1] = terrain;
gTasks[taskId].tState = 0;
gTasks[taskId].tTerrain = terrain;
gTasks[taskId].data[2] = 0;
gTasks[taskId].data[3] = 0;
gTasks[taskId].data[4] = 0;
@ -134,7 +137,7 @@ void HandleIntroSlide(u8 terrain)
gTasks[taskId].data[6] = 0;
}
void sub_811828C(u8 taskId)
static void BattleIntroSlideEnd(u8 taskId)
{
DestroyTask(taskId);
gBattle_BG1_X = 0;
@ -153,24 +156,24 @@ static void BattleIntroSlide1(u8 taskId)
int i;
gBattle_BG1_X += 6;
switch (gTasks[taskId].data[0])
switch (gTasks[taskId].tState)
{
case 0:
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
gTasks[taskId].data[2] = 16;
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
}
else
{
gTasks[taskId].data[2] = 1;
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
}
break;
case 1:
if (--gTasks[taskId].data[2] == 0)
{
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR);
}
break;
@ -178,7 +181,7 @@ static void BattleIntroSlide1(u8 taskId)
gBattle_WIN0V -= 0xFF;
if ((gBattle_WIN0V & 0xFF00) == 0x3000)
{
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
gTasks[taskId].data[2] = 240;
gTasks[taskId].data[3] = 32;
gIntroSlideFlags &= ~1;
@ -191,7 +194,7 @@ static void BattleIntroSlide1(u8 taskId)
}
else
{
if (gTasks[taskId].data[1] == 1)
if (gTasks[taskId].tTerrain == BATTLE_TERRAIN_LONG_GRASS)
{
if (gBattle_BG1_Y != 0xFFB0)
gBattle_BG1_Y -= 2;
@ -219,7 +222,7 @@ static void BattleIntroSlide1(u8 taskId)
if (!gTasks[taskId].data[2])
{
gScanlineEffect.state = 3;
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
CpuFill32(0, (void *)BG_SCREEN_ADDR(28), BG_SCREEN_SIZE);
SetBgAttribute(1, BG_ATTR_CHARBASEINDEX, 0);
SetBgAttribute(2, BG_ATTR_CHARBASEINDEX, 0);
@ -228,7 +231,7 @@ static void BattleIntroSlide1(u8 taskId)
}
break;
case 4:
sub_811828C(taskId);
BattleIntroSlideEnd(taskId);
break;
}
}
@ -237,18 +240,18 @@ static void BattleIntroSlide2(u8 taskId)
{
int i;
switch (gTasks[taskId].data[1])
switch (gTasks[taskId].tTerrain)
{
case 2:
case 4:
case BATTLE_TERRAIN_SAND:
case BATTLE_TERRAIN_WATER:
gBattle_BG1_X += 8;
break;
case 3:
case BATTLE_TERRAIN_UNDERWATER:
gBattle_BG1_X += 6;
break;
}
if (gTasks[taskId].data[1] == 4)
if (gTasks[taskId].tTerrain == BATTLE_TERRAIN_WATER)
{
gBattle_BG1_Y = Cos2(gTasks[taskId].data[6]) / 512 - 8;
if (gTasks[taskId].data[6] < 180)
@ -260,25 +263,25 @@ static void BattleIntroSlide2(u8 taskId)
gTasks[taskId].data[6] = 0;
}
switch (gTasks[taskId].data[0])
switch (gTasks[taskId].tState)
{
case 0:
gTasks[taskId].data[4] = 16;
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
gTasks[taskId].data[2] = 16;
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
}
else
{
gTasks[taskId].data[2] = 1;
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
}
break;
case 1:
if (--gTasks[taskId].data[2] == 0)
{
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR);
}
break;
@ -286,7 +289,7 @@ static void BattleIntroSlide2(u8 taskId)
gBattle_WIN0V -= 0xFF;
if ((gBattle_WIN0V & 0xFF00) == 0x3000)
{
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
gTasks[taskId].data[2] = 240;
gTasks[taskId].data[3] = 32;
gTasks[taskId].data[5] = 1;
@ -328,7 +331,7 @@ static void BattleIntroSlide2(u8 taskId)
if (!gTasks[taskId].data[2])
{
gScanlineEffect.state = 3;
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
CpuFill32(0, (void *)BG_SCREEN_ADDR(28), BG_SCREEN_SIZE);
SetBgAttribute(1, BG_ATTR_CHARBASEINDEX, 0);
SetBgAttribute(2, BG_ATTR_CHARBASEINDEX, 0);
@ -337,11 +340,11 @@ static void BattleIntroSlide2(u8 taskId)
}
break;
case 4:
sub_811828C(taskId);
BattleIntroSlideEnd(taskId);
break;
}
if (gTasks[taskId].data[0] != 4)
if (gTasks[taskId].tState != 4)
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[4], 0));
}
@ -350,7 +353,7 @@ static void BattleIntroSlide3(u8 taskId)
int i;
gBattle_BG1_X += 8;
switch (gTasks[taskId].data[0])
switch (gTasks[taskId].tState)
{
case 0:
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ);
@ -360,18 +363,18 @@ static void BattleIntroSlide3(u8 taskId)
if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK))
{
gTasks[taskId].data[2] = 16;
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
}
else
{
gTasks[taskId].data[2] = 1;
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
}
break;
case 1:
if (--gTasks[taskId].data[2] == 0)
{
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR);
}
break;
@ -379,7 +382,7 @@ static void BattleIntroSlide3(u8 taskId)
gBattle_WIN0V -= 0xFF;
if ((gBattle_WIN0V & 0xFF00) == 0x3000)
{
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
gTasks[taskId].data[2] = 240;
gTasks[taskId].data[3] = 32;
gTasks[taskId].data[5] = 1;
@ -416,7 +419,7 @@ static void BattleIntroSlide3(u8 taskId)
if (!gTasks[taskId].data[2])
{
gScanlineEffect.state = 3;
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
CpuFill32(0, (void *)BG_SCREEN_ADDR(28), BG_SCREEN_SIZE);
SetBgAttribute(1, BG_ATTR_CHARBASEINDEX, 0);
SetBgAttribute(2, BG_ATTR_CHARBASEINDEX, 0);
@ -425,11 +428,11 @@ static void BattleIntroSlide3(u8 taskId)
}
break;
case 4:
sub_811828C(taskId);
BattleIntroSlideEnd(taskId);
break;
}
if (gTasks[taskId].data[0] != 4)
if (gTasks[taskId].tState != 4)
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[4], 0));
}
@ -437,7 +440,7 @@ static void BattleIntroSlideLink(u8 taskId)
{
int i;
if (gTasks[taskId].data[0] > 1 && !gTasks[taskId].data[4])
if (gTasks[taskId].tState > 1 && !gTasks[taskId].data[4])
{
u16 var0 = gBattle_BG1_X & 0x8000;
if (var0 || gBattle_BG1_X < 80)
@ -453,20 +456,20 @@ static void BattleIntroSlideLink(u8 taskId)
}
}
switch (gTasks[taskId].data[0])
switch (gTasks[taskId].tState)
{
case 0:
gTasks[taskId].data[2] = 32;
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
break;
case 1:
if (--gTasks[taskId].data[2] == 0)
{
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
gSprites[gBattleStruct->linkBattleVsSpriteId_V].oam.objMode = ST_OAM_OBJ_WINDOW;
gSprites[gBattleStruct->linkBattleVsSpriteId_V].callback = sub_8038B74;
gSprites[gBattleStruct->linkBattleVsSpriteId_V].callback = SpriteCB_VsLetterInit;
gSprites[gBattleStruct->linkBattleVsSpriteId_S].oam.objMode = ST_OAM_OBJ_WINDOW;
gSprites[gBattleStruct->linkBattleVsSpriteId_S].callback = sub_8038B74;
gSprites[gBattleStruct->linkBattleVsSpriteId_S].callback = SpriteCB_VsLetterInit;
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR);
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2);
}
@ -475,7 +478,7 @@ static void BattleIntroSlideLink(u8 taskId)
gBattle_WIN0V -= 0xFF;
if ((gBattle_WIN0V & 0xFF00) == 0x3000)
{
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
gTasks[taskId].data[2] = 240;
gTasks[taskId].data[3] = 32;
gIntroSlideFlags &= ~1;
@ -498,7 +501,7 @@ static void BattleIntroSlideLink(u8 taskId)
if (!gTasks[taskId].data[2])
{
gScanlineEffect.state = 3;
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
SetBgAttribute(1, BG_ATTR_CHARBASEINDEX, 0);
SetBgAttribute(2, BG_ATTR_CHARBASEINDEX, 0);
SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(28) | BGCNT_TXT256x512);
@ -506,23 +509,23 @@ static void BattleIntroSlideLink(u8 taskId)
}
break;
case 4:
sub_811828C(taskId);
BattleIntroSlideEnd(taskId);
break;
}
}
static void BattleIntroSlidePartner(u8 taskId)
{
switch (gTasks[taskId].data[0])
switch (gTasks[taskId].tState)
{
case 0:
gTasks[taskId].data[2] = 1;
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
break;
case 1:
if (--gTasks[taskId].data[2] == 0)
{
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(2) | BGCNT_CHARBASE(2) | BGCNT_16COLOR | BGCNT_SCREENBASE(28) | BGCNT_TXT512x256);
SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) | BGCNT_CHARBASE(2) | BGCNT_16COLOR | BGCNT_SCREENBASE(30) | BGCNT_TXT512x256);
SetGpuReg(REG_OFFSET_DISPCNT, GetGpuReg(REG_OFFSET_DISPCNT) | DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON | DISPCNT_WIN1_ON | DISPCNT_OBJWIN_ON);
@ -540,7 +543,7 @@ static void BattleIntroSlidePartner(u8 taskId)
if ((gBattle_WIN0V & 0xFF00) == 0x2000)
{
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
gTasks[taskId].data[2] = 240;
gIntroSlideFlags &= ~1;
}
@ -555,7 +558,7 @@ static void BattleIntroSlidePartner(u8 taskId)
gBattle_BG1_X = gTasks[taskId].data[2];
gBattle_BG2_X = -gTasks[taskId].data[2];
if (!gTasks[taskId].data[2])
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
break;
case 4:
gBattle_BG0_Y += 2;
@ -572,11 +575,11 @@ static void BattleIntroSlidePartner(u8 taskId)
SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(28) | BGCNT_TXT256x512);
SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(30) | BGCNT_TXT512x256);
gScanlineEffect.state = 3;
gTasks[taskId].data[0]++;
gTasks[taskId].tState++;
}
break;
case 5:
sub_811828C(taskId);
BattleIntroSlideEnd(taskId);
break;
}
}

View File

@ -81,8 +81,8 @@ static void TryCorrectShedinjaLanguage(struct Pokemon *mon);
static u8 CreateNPCTrainerParty(struct Pokemon *party, u16 trainerNum, bool8 firstTrainer);
static void BattleMainCB1(void);
static void sub_8038538(struct Sprite *sprite);
static void sub_8038F14(void);
static void sub_8038F34(void);
static void CB2_EndLinkBattle(void);
static void EndLinkBattleInSteps(void);
static void sub_80392A8(void);
static void sub_803937C(void);
static void sub_803939C(void);
@ -93,7 +93,7 @@ static void sub_80398D0(struct Sprite *sprite);
static void SpriteCB_AnimFaintOpponent(struct Sprite *sprite);
static void SpriteCb_BlinkVisible(struct Sprite *sprite);
static void SpriteCallbackDummy_3(struct Sprite *sprite);
static void oac_poke_ally_(struct Sprite *sprite);
static void SpriteCB_BattleSpriteSlideLeft(struct Sprite *sprite);
static void TurnValuesCleanUp(bool8 var0);
static void SpriteCB_BounceEffect(struct Sprite *sprite);
static void BattleStartClearSetData(void);
@ -147,7 +147,7 @@ EWRAM_DATA u8 gBattleTextBuff3[TEXT_BUFF_ARRAY_COUNT] = {0};
EWRAM_DATA static u32 sUnusedUnknownArray[25] = {0};
EWRAM_DATA u32 gBattleTypeFlags = 0;
EWRAM_DATA u8 gBattleTerrain = 0;
EWRAM_DATA u32 gUnknown_02022FF4 = 0;
EWRAM_DATA u32 gUnusedFirstBattleVar1 = 0; // Never read
EWRAM_DATA struct UnknownPokemonStruct4 gMultiPartnerParty[MULTI_PARTY_SIZE] = {0};
EWRAM_DATA static struct UnknownPokemonStruct4* sMultiPartnerPartyBuffer = NULL;
EWRAM_DATA u8 *gUnknown_0202305C = NULL;
@ -200,7 +200,7 @@ EWRAM_DATA u8 gMoveResultFlags = 0;
EWRAM_DATA u32 gHitMarker = 0;
EWRAM_DATA static u8 sUnusedBattlersArray[MAX_BATTLERS_COUNT] = {0};
EWRAM_DATA u8 gTakenDmgByBattler[MAX_BATTLERS_COUNT] = {0};
EWRAM_DATA u8 gUnknown_0202428C = 0;
EWRAM_DATA u8 gUnusedFirstBattleVar2 = 0; // Never read
EWRAM_DATA u16 gSideStatuses[2] = {0};
EWRAM_DATA struct SideTimer gSideTimers[2] = {0};
EWRAM_DATA u32 gStatuses3[MAX_BATTLERS_COUNT] = {0};
@ -233,8 +233,8 @@ EWRAM_DATA u32 gTransformedPersonalities[MAX_BATTLERS_COUNT] = {0};
EWRAM_DATA u8 gPlayerDpadHoldFrames = 0;
EWRAM_DATA struct BattleSpriteData *gBattleSpritesDataPtr = NULL;
EWRAM_DATA struct MonSpritesGfx *gMonSpritesGfxPtr = NULL;
EWRAM_DATA struct BattleHealthboxInfo *gUnknown_020244D8 = NULL;
EWRAM_DATA struct BattleHealthboxInfo *gUnknown_020244DC = NULL;
EWRAM_DATA struct BattleHealthboxInfo *gBattleControllerOpponentHealthboxData = NULL; // Never read
EWRAM_DATA struct BattleHealthboxInfo *gBattleControllerOpponentFlankHealthboxData = NULL; // Never read
EWRAM_DATA u16 gBattleMovePower = 0;
EWRAM_DATA u16 gMoveToLearn = 0;
EWRAM_DATA u8 gBattleMonForms[MAX_BATTLERS_COUNT] = {0};
@ -248,7 +248,7 @@ void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(void);
u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
u8 gMultiUsePlayerCursor;
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
static const struct ScanlineEffectParams sIntroScanlineParams16Bit =
@ -275,7 +275,7 @@ const struct SpriteTemplate gUnknown_0831AC88 =
static const u8 sText_ShedinjaJpnName[] = _("ヌケニン"); // Nukenin
const struct OamData gOamData_831ACA8 =
const struct OamData gOamData_BattleSpriteOpponentSide =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_NORMAL,
@ -290,7 +290,7 @@ const struct OamData gOamData_831ACA8 =
.affineParam = 0,
};
const struct OamData gOamData_831ACB0 =
const struct OamData gOamData_BattleSpritePlayerSide =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_NORMAL,
@ -306,10 +306,10 @@ const struct OamData gOamData_831ACB0 =
};
// Unknown and unused data. Feel free to remove.
static const u16 gUnknown_0831ACB8[] = {0, 5, 0xfffe, 0};
static const u16 *const gUnknown_0831ACC0 = gUnknown_0831ACB8;
static const u16 gUnknown_0831ACC4[] = {0xfff0, 0, 0x0400, 0, 0, 0, 0x3c00, 0, 0x7ffe, 1, 0, 0};
static const u16 *const gUnknown_0831ACDC = gUnknown_0831ACC4;
static const u16 sUnused1[] = {0, 5, 0xfffe, 0};
static const u16 *const sUnused1Ptr = sUnused1;
static const u16 sUnused2[] = {0xfff0, 0, 0x0400, 0, 0, 0, 0x3c00, 0, 0x7ffe, 1, 0, 0};
static const u16 *const sUnused2Ptr = sUnused2;
static const s8 gUnknown_0831ACE0[] ={-32, -16, -16, -32, -32, 0, 0, 0};
@ -700,39 +700,45 @@ static void CB2_InitBattleInternal(void)
gBattleCommunication[MULTIUSE_STATE] = 0;
}
static void sub_8036A5C(void)
{
u16 r6 = 0;
u16 species = 0;
u16 hp = 0;
u32 status = 0;
s32 i;
for (i = 0; i < PARTY_SIZE; i++)
{
species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2);
hp = GetMonData(&gPlayerParty[i], MON_DATA_HP);
status = GetMonData(&gPlayerParty[i], MON_DATA_STATUS);
if (species == SPECIES_NONE)
continue;
if (species != SPECIES_EGG && hp != 0 && status == 0)
r6 |= 1 << i * 2;
if (species == SPECIES_NONE)
continue;
if (hp != 0 && (species == SPECIES_EGG || status != 0))
r6 |= 2 << i * 2;
if (species == SPECIES_NONE)
continue;
if (species != SPECIES_EGG && hp == 0)
r6 |= 3 << i * 2;
#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; \
}
gBattleStruct->field_182 = r6;
*(&gBattleStruct->field_183) = r6 >> 8;
gBattleStruct->field_183 |= FlagGet(FLAG_SYS_FRONTIER_PASS) << 7;
// For Vs Screen at link battle start
static void BufferPartyVsScreenHealth_AtStart(void)
{
u16 flags = 0;
s32 i;
BUFFER_PARTY_VS_SCREEN_STATUS(gPlayerParty, flags, i);
gBattleStruct->vsScreenHealthFlagsLo = flags;
*(&gBattleStruct->vsScreenHealthFlagsHi) = flags >> 8;
gBattleStruct->vsScreenHealthFlagsHi |= FlagGet(FLAG_SYS_FRONTIER_PASS) << 7;
}
static void SetPlayerBerryDataInBattleStruct(void)
@ -969,7 +975,7 @@ static void CB2_HandleStartBattle(void)
{
*(&gBattleStruct->field_180) = 0;
*(&gBattleStruct->field_181) = 3;
sub_8036A5C();
BufferPartyVsScreenHealth_AtStart();
SetPlayerBerryDataInBattleStruct();
if (gTrainerBattleOpponent_A == TRAINER_UNION_ROOM)
@ -1005,7 +1011,7 @@ static void CB2_HandleStartBattle(void)
gTasks[taskId].data[1] = 0x10E;
gTasks[taskId].data[2] = 0x5A;
gTasks[taskId].data[5] = 0;
gTasks[taskId].data[3] = gBattleStruct->field_182 | (gBattleStruct->field_183 << 8);
gTasks[taskId].data[3] = gBattleStruct->vsScreenHealthFlagsLo | (gBattleStruct->vsScreenHealthFlagsHi << 8);
gTasks[taskId].data[4] = gBlockRecvBuffer[enemyMultiplayerId][1];
sub_8185F90(gBlockRecvBuffer[playerMultiplayerId][1]);
sub_8185F90(gBlockRecvBuffer[enemyMultiplayerId][1]);
@ -1065,7 +1071,7 @@ static void CB2_HandleStartBattle(void)
}
break;
case 15:
sub_8032768();
InitBattleControllers();
sub_8184E58();
gBattleCommunication[SPRITES_INIT_STATE1] = 0;
gBattleCommunication[SPRITES_INIT_STATE2] = 0;
@ -1177,7 +1183,7 @@ static void CB2_HandleStartMultiPartnerBattle(void)
{
*(&gBattleStruct->field_180) = 0;
*(&gBattleStruct->field_181) = 3;
sub_8036A5C();
BufferPartyVsScreenHealth_AtStart();
SetPlayerBerryDataInBattleStruct();
SendBlock(bitmask_all_link_players_but_self(), &gBattleStruct->field_180, 32);
gBattleCommunication[MULTIUSE_STATE] = 2;
@ -1325,7 +1331,7 @@ static void CB2_HandleStartMultiPartnerBattle(void)
}
break;
case 13:
sub_8032768();
InitBattleControllers();
sub_8184E58();
gBattleCommunication[SPRITES_INIT_STATE1] = 0;
gBattleCommunication[SPRITES_INIT_STATE2] = 0;
@ -1564,7 +1570,7 @@ static void CB2_HandleStartMultiBattle(void)
{
*(&gBattleStruct->field_180) = 0;
*(&gBattleStruct->field_181) = 3;
sub_8036A5C();
BufferPartyVsScreenHealth_AtStart();
SetPlayerBerryDataInBattleStruct();
SendBlock(bitmask_all_link_players_but_self(), &gBattleStruct->field_180, 32);
@ -1762,7 +1768,7 @@ static void CB2_HandleStartMultiBattle(void)
}
break;
case 7:
sub_8032768();
InitBattleControllers();
sub_8184E58();
gBattleCommunication[SPRITES_INIT_STATE1] = 0;
gBattleCommunication[SPRITES_INIT_STATE2] = 0;
@ -2064,12 +2070,12 @@ void VBlankCB_Battle(void)
ScanlineEffect_InitHBlankDmaTransfer();
}
void nullsub_17(struct Sprite *sprite)
void SpriteCB_VsLetterDummy(struct Sprite *sprite)
{
}
static void sub_8038B04(struct Sprite *sprite)
static void SpriteCB_VsLetter(struct Sprite *sprite)
{
if (sprite->data[0] != 0)
sprite->pos1.x = sprite->data[1] + ((sprite->data[2] & 0xFF00) >> 8);
@ -2080,100 +2086,60 @@ static void sub_8038B04(struct Sprite *sprite)
if (sprite->affineAnimEnded)
{
FreeSpriteTilesByTag(0x2710);
FreeSpritePaletteByTag(0x2710);
FreeSpriteTilesByTag(ANIM_SPRITES_START);
FreeSpritePaletteByTag(ANIM_SPRITES_START);
FreeSpriteOamMatrix(sprite);
DestroySprite(sprite);
}
}
void sub_8038B74(struct Sprite *sprite)
void SpriteCB_VsLetterInit(struct Sprite *sprite)
{
StartSpriteAffineAnim(sprite, 1);
sprite->callback = sub_8038B04;
sprite->callback = SpriteCB_VsLetter;
PlaySE(SE_MUGSHOT);
}
static void sub_8038B94(u8 taskId)
static void BufferPartyVsScreenHealth_AtEnd(u8 taskId)
{
struct Pokemon *sp4 = NULL;
struct Pokemon *sp8 = NULL;
u8 r2 = gBattleScripting.multiplayerId;
u32 r7;
struct Pokemon *party1 = NULL;
struct Pokemon *party2 = NULL;
u8 multiplayerId = gBattleScripting.multiplayerId;
u32 flags;
s32 i;
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
{
switch (gLinkPlayers[r2].id)
switch (gLinkPlayers[multiplayerId].id)
{
case 0:
case 2:
sp4 = gPlayerParty;
sp8 = gEnemyParty;
party1 = gPlayerParty;
party2 = gEnemyParty;
break;
case 1:
case 3:
sp4 = gEnemyParty;
sp8 = gPlayerParty;
party1 = gEnemyParty;
party2 = gPlayerParty;
break;
}
}
else
{
sp4 = gPlayerParty;
sp8 = gEnemyParty;
party1 = gPlayerParty;
party2 = gEnemyParty;
}
r7 = 0;
for (i = 0; i < PARTY_SIZE; i++)
{
u16 species = GetMonData(&sp4[i], MON_DATA_SPECIES2);
u16 hp = GetMonData(&sp4[i], MON_DATA_HP);
u32 status = GetMonData(&sp4[i], MON_DATA_STATUS);
flags = 0;
BUFFER_PARTY_VS_SCREEN_STATUS(party1, flags, i);
gTasks[taskId].data[3] = flags;
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[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;
flags = 0;
BUFFER_PARTY_VS_SCREEN_STATUS(party2, flags, i);
gTasks[taskId].data[4] = flags;
}
void sub_8038D64(void)
void CB2_InitEndLinkBattle(void)
{
s32 i;
u8 taskId;
@ -2193,12 +2159,12 @@ void sub_8038D64(void)
{
CpuFill32(0, (void*)(VRAM), VRAM_SIZE);
SetGpuReg(REG_OFFSET_MOSAIC, 0);
SetGpuReg(REG_OFFSET_WIN0H, 0xF0);
SetGpuReg(REG_OFFSET_WIN0V, 0x5051);
SetGpuReg(REG_OFFSET_WIN0H, DISPLAY_WIDTH);
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(DISPLAY_HEIGHT / 2, DISPLAY_HEIGHT / 2 + 1));
SetGpuReg(REG_OFFSET_WININ, 0);
SetGpuReg(REG_OFFSET_WINOUT, 0);
gBattle_WIN0H = 0xF0;
gBattle_WIN0V = 0x5051;
gBattle_WIN0H = DISPLAY_WIDTH;
gBattle_WIN0V = WIN_RANGE(DISPLAY_HEIGHT / 2, DISPLAY_HEIGHT / 2 + 1);
ScanlineEffect_Clear();
i = 0;
@ -2233,24 +2199,26 @@ void sub_8038D64(void)
ResetSpriteData();
ResetTasks();
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();
gReservedSpritePaletteCount = 4;
SetVBlankCallback(VBlankCB_Battle);
// Show end Vs screen with battle results
taskId = CreateTask(InitLinkBattleVsScreen, 0);
gTasks[taskId].data[1] = 0x10E;
gTasks[taskId].data[2] = 0x5A;
gTasks[taskId].data[5] = 1;
sub_8038B94(taskId);
SetMainCallback2(sub_8038F14);
BufferPartyVsScreenHealth_AtEnd(taskId);
SetMainCallback2(CB2_EndLinkBattle);
gBattleCommunication[MULTIUSE_STATE] = 0;
}
}
static void sub_8038F14(void)
static void CB2_EndLinkBattle(void)
{
sub_8038F34();
EndLinkBattleInSteps();
AnimateSprites();
BuildOamBuffer();
RunTextPrinters();
@ -2258,7 +2226,7 @@ static void sub_8038F14(void)
RunTasks();
}
static void sub_8038F34(void)
static void EndLinkBattleInSteps(void)
{
s32 i;
@ -2375,7 +2343,7 @@ static void sub_8038F34(void)
}
}
u32 sub_80391E0(u8 arrayId, u8 caseId)
u32 GetBattleBgTemplateData(u8 arrayId, u8 caseId)
{
u32 ret = 0;
@ -2396,7 +2364,7 @@ u32 sub_80391E0(u8 arrayId, u8 caseId)
case 4:
ret = gBattleBgTemplates[arrayId].paletteMode;
break;
case 5:
case 5: // Only this case is used
ret = gBattleBgTemplates[arrayId].priority;
break;
case 6:
@ -2627,7 +2595,7 @@ static void TryCorrectShedinjaLanguage(struct Pokemon *mon)
}
}
u32 sub_80397C4(u32 setId, u32 tableId)
u32 GetBattleWindowTemplatePixelWidth(u32 setId, u32 tableId)
{
return gBattleWindowTemplates[setId][tableId].width * 8;
}
@ -2658,7 +2626,7 @@ static void SpriteCb_WildMonShowHealthbox(struct Sprite *sprite)
{
if (sprite->animEnded)
{
sub_8076918(sprite->sBattler);
StartHealthboxSlideIn(sprite->sBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[sprite->sBattler]);
sprite->callback = SpriteCb_WildMonAnimate;
StartSpriteAnimIfDifferent(sprite, 0);
@ -2679,7 +2647,8 @@ void SpriteCallbackDummy_2(struct Sprite *sprite)
}
static void sub_80398BC(struct Sprite *sprite) // unused?
// Unused
static void sub_80398BC(struct Sprite *sprite)
{
sprite->data[3] = 6;
sprite->data[4] = 1;
@ -2812,12 +2781,13 @@ void SpriteCb_OpponentMonFromBall(struct Sprite *sprite)
}
}
void sub_8039BB4(struct Sprite *sprite)
// This callback is frequently overwritten by SpriteCB_TrainerSlideIn
void SpriteCB_BattleSpriteStartSlideLeft(struct Sprite *sprite)
{
sprite->callback = oac_poke_ally_;
sprite->callback = SpriteCB_BattleSpriteSlideLeft;
}
static void oac_poke_ally_(struct Sprite *sprite)
static void SpriteCB_BattleSpriteSlideLeft(struct Sprite *sprite)
{
if (!(gIntroSlideFlags & 1))
{
@ -2830,7 +2800,8 @@ static void oac_poke_ally_(struct Sprite *sprite)
}
}
void sub_80105DC(struct Sprite *sprite)
// Unused
static void sub_80105DC(struct Sprite *sprite)
{
sprite->callback = SpriteCallbackDummy_3;
}
@ -2839,15 +2810,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))
{
sprite->pos2.x += sprite->data[1];
sprite->pos2.y += sprite->data[2];
sprite->pos2.x += sprite->sSpeedX;
sprite->pos2.y += sprite->sSpeedY;
}
}
#undef sSpeedX
#undef sSpeedY
#define sSinIndex data[0]
#define sDelta data[1]
#define sAmplitude data[2]
@ -2967,7 +2944,7 @@ void sub_8039E9C(struct Sprite *sprite)
sprite->centerToCornerVecX = gUnknown_0831ACE0[sprite->animCmdIndex];
}
void nullsub_20(void)
void BeginBattleIntroDummy(void)
{
}
@ -4393,7 +4370,11 @@ static void HandleTurnActionSelectionState(void)
}
break;
case STATE_WAIT_ACTION_CONFIRMED_STANDBY:
if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler]) | (0xF0000000) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 0xC))))
if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler])
| (0xF0000000)
| (gBitTable[gActiveBattler] << 4)
| (gBitTable[gActiveBattler] << 8)
| (gBitTable[gActiveBattler] << 12))))
{
if (AllAtActionConfirmed())
i = TRUE;
@ -4962,7 +4943,7 @@ static void HandleEndTurn_BattleLost(void)
}
else
{
gBattlescriptCurrInstr = BattleScript_82DAA0B;
gBattlescriptCurrInstr = BattleScript_FrontierLinkBattleLost;
gBattleOutcome &= ~(B_OUTCOME_LINK_BATTLE_RAN);
}
}

View File

@ -3001,7 +3001,7 @@ void BattlePutTextOnWindow(const u8 *text, u8 windowId)
if (printerTemplate.x == 0xFF)
{
u32 width = sub_80397C4(gBattleScripting.windowsType, windowId);
u32 width = GetBattleWindowTemplatePixelWidth(gBattleScripting.windowsType, windowId);
s32 alignX = GetStringCenterAlignXOffsetWithLetterSpacing(printerTemplate.fontId, printerTemplate.currentChar, width, printerTemplate.letterSpacing);
printerTemplate.x = printerTemplate.currentX = alignX;
}

View File

@ -163,7 +163,7 @@ static void Cmd_trainerslidein(void);
static void Cmd_playse(void);
static void Cmd_fanfare(void);
static void Cmd_playfaintcry(void);
static void Cmd_unknown_57(void);
static void Cmd_endlinkbattle(void);
static void Cmd_returntoball(void);
static void Cmd_handlelearnnewmove(void);
static void Cmd_yesnoboxlearnmove(void);
@ -415,7 +415,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
Cmd_playse, //0x54
Cmd_fanfare, //0x55
Cmd_playfaintcry, //0x56
Cmd_unknown_57, //0x57
Cmd_endlinkbattle, //0x57
Cmd_returntoball, //0x58
Cmd_handlelearnnewmove, //0x59
Cmd_yesnoboxlearnmove, //0x5A
@ -4835,7 +4835,7 @@ static void Cmd_openpartyscreen(void)
{
gAbsentBattlerFlags |= gBitTable[gActiveBattler];
gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler));
BtlController_EmitLinkStandbyMsg(0, 2, 0);
BtlController_EmitLinkStandbyMsg(0, 2, FALSE);
MarkBattlerForControllerExec(gActiveBattler);
}
else if (!gSpecialStatuses[gActiveBattler].flag40)
@ -4846,7 +4846,7 @@ static void Cmd_openpartyscreen(void)
}
else
{
BtlController_EmitLinkStandbyMsg(0, 2, 0);
BtlController_EmitLinkStandbyMsg(0, 2, FALSE);
MarkBattlerForControllerExec(gActiveBattler);
}
}
@ -4874,7 +4874,7 @@ static void Cmd_openpartyscreen(void)
}
else
{
BtlController_EmitLinkStandbyMsg(0, 2, 0);
BtlController_EmitLinkStandbyMsg(0, 2, FALSE);
MarkBattlerForControllerExec(gActiveBattler);
flags |= 1;
}
@ -4896,7 +4896,7 @@ static void Cmd_openpartyscreen(void)
}
else if (!(flags & 1))
{
BtlController_EmitLinkStandbyMsg(0, 2, 0);
BtlController_EmitLinkStandbyMsg(0, 2, FALSE);
MarkBattlerForControllerExec(gActiveBattler);
}
}
@ -4917,7 +4917,7 @@ static void Cmd_openpartyscreen(void)
}
else
{
BtlController_EmitLinkStandbyMsg(0, 2, 0);
BtlController_EmitLinkStandbyMsg(0, 2, FALSE);
MarkBattlerForControllerExec(gActiveBattler);
flags |= 2;
}
@ -4939,7 +4939,7 @@ static void Cmd_openpartyscreen(void)
}
else if (!(flags & 2))
{
BtlController_EmitLinkStandbyMsg(0, 2, 0);
BtlController_EmitLinkStandbyMsg(0, 2, FALSE);
MarkBattlerForControllerExec(gActiveBattler);
}
}
@ -4955,7 +4955,7 @@ static void Cmd_openpartyscreen(void)
else
gActiveBattler = 0;
BtlController_EmitLinkStandbyMsg(0, 2, 0);
BtlController_EmitLinkStandbyMsg(0, 2, FALSE);
MarkBattlerForControllerExec(gActiveBattler);
}
@ -4971,7 +4971,7 @@ static void Cmd_openpartyscreen(void)
else
gActiveBattler = 1;
BtlController_EmitLinkStandbyMsg(0, 2, 0);
BtlController_EmitLinkStandbyMsg(0, 2, FALSE);
MarkBattlerForControllerExec(gActiveBattler);
}
}
@ -5079,7 +5079,7 @@ static void Cmd_openpartyscreen(void)
{
if (gActiveBattler != battlerId)
{
BtlController_EmitLinkStandbyMsg(0, 2, 0);
BtlController_EmitLinkStandbyMsg(0, 2, FALSE);
MarkBattlerForControllerExec(gActiveBattler);
}
}
@ -5090,7 +5090,7 @@ static void Cmd_openpartyscreen(void)
if (gAbsentBattlerFlags & gBitTable[gActiveBattler])
gActiveBattler ^= BIT_FLANK;
BtlController_EmitLinkStandbyMsg(0, 2, 0);
BtlController_EmitLinkStandbyMsg(0, 2, FALSE);
MarkBattlerForControllerExec(gActiveBattler);
}
}
@ -5282,10 +5282,10 @@ static void Cmd_playfaintcry(void)
gBattlescriptCurrInstr += 2;
}
static void Cmd_unknown_57(void)
static void Cmd_endlinkbattle(void)
{
gActiveBattler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
BtlController_EmitCmd55(0, gBattleOutcome);
BtlController_EmitEndLinkBattle(0, gBattleOutcome);
MarkBattlerForControllerExec(gActiveBattler);
gBattlescriptCurrInstr += 1;
@ -6362,7 +6362,7 @@ static void Cmd_various(void)
gDisableStructs[1].truantSwitchInHack = 1;
break;
case VARIOUS_EMIT_YESNOBOX:
BtlController_EmitUnknownYesNoBox(0);
BtlController_EmitYesNoBox(0);
MarkBattlerForControllerExec(gActiveBattler);
break;
case 14:

View File

@ -819,14 +819,14 @@ void MarkBattlerForControllerExec(u8 battlerId)
gBattleControllerExecFlags |= gBitTable[battlerId];
}
void sub_803F850(u8 arg0)
void MarkBattlerReceivedLinkData(u8 battlerId)
{
s32 i;
for (i = 0; i < GetLinkPlayerCount(); i++)
gBattleControllerExecFlags |= gBitTable[arg0] << (i << 2);
gBattleControllerExecFlags |= gBitTable[battlerId] << (i << 2);
gBattleControllerExecFlags &= ~(0x10000000 << arg0);
gBattleControllerExecFlags &= ~(0x10000000 << battlerId);
}
void CancelMultiTurnMoves(u8 battler)

View File

@ -3135,7 +3135,7 @@ static u8 CreateContestantSprite(u16 species, u32 otId, u32 personality, u32 ind
if (IsSpeciesNotUnown(species))
gSprites[spriteId].affineAnims = gUnknown_082FF6C0;
else
gSprites[spriteId].affineAnims = gUnknown_082FF694;
gSprites[spriteId].affineAnims = gAffineAnims_BattleSpriteOpponentSide;
StartSpriteAffineAnim(gSprites + spriteId, 0);
return spriteId;

View File

@ -8,12 +8,11 @@
#include "constants/trainers.h"
#include "constants/battle_ai.h"
const u16 gUnknown_082FF1D8[] = INCBIN_U16("graphics/link/minigame_digits.gbapal");
const u32 gUnknown_082FF1F8[] = INCBIN_U32("graphics/link/minigame_digits.4bpp.lz");
// unused
const u32 gUnknown_082FF2B8[] = INCBIN_U32("graphics/link/minigame_digits2.4bpp.lz");
const u16 gMinigameDigits_Pal[] = INCBIN_U16("graphics/link/minigame_digits.gbapal");
const u32 gMinigameDigits_Gfx[] = INCBIN_U32("graphics/link/minigame_digits.4bpp.lz");
static const u32 sMinigameDigitsThin_Gfx[] = INCBIN_U32("graphics/link/minigame_digits2.4bpp.lz"); // Unused
const struct SpriteFrameImage gUnknown_082FF3A8[] =
const struct SpriteFrameImage gBattlerPicTable_PlayerLeft[] =
{
gHeap + 0x8000, 0x800,
gHeap + 0x8800, 0x800,
@ -21,7 +20,7 @@ const struct SpriteFrameImage gUnknown_082FF3A8[] =
gHeap + 0x9800, 0x800,
};
const struct SpriteFrameImage gUnknown_082FF3C8[] =
const struct SpriteFrameImage gBattlerPicTable_OpponentLeft[] =
{
gHeap + 0xA000, 0x800,
gHeap + 0xA800, 0x800,
@ -29,7 +28,7 @@ const struct SpriteFrameImage gUnknown_082FF3C8[] =
gHeap + 0xB800, 0x800,
};
const struct SpriteFrameImage gUnknown_082FF3E8[] =
const struct SpriteFrameImage gBattlerPicTable_PlayerRight[] =
{
gHeap + 0xC000, 0x800,
gHeap + 0xC800, 0x800,
@ -37,7 +36,7 @@ const struct SpriteFrameImage gUnknown_082FF3E8[] =
gHeap + 0xD800, 0x800,
};
const struct SpriteFrameImage gUnknown_082FF408[] =
const struct SpriteFrameImage gBattlerPicTable_OpponentRight[] =
{
gHeap + 0xE000, 0x800,
gHeap + 0xE800, 0x800,
@ -189,7 +188,7 @@ static const union AffineAnimCmd gUnknown_082FF600[] =
AFFINEANIMCMD_END,
};
const union AffineAnimCmd *const gUnknown_082FF618[] =
const union AffineAnimCmd *const gAffineAnims_BattleSpritePlayerSide[] =
{
gUnknown_082FF548,
gUnknown_082FF568,
@ -229,7 +228,7 @@ static const union AffineAnimCmd gUnknown_082FF684[] =
AFFINEANIMCMD_END,
};
const union AffineAnimCmd *const gUnknown_082FF694[] =
const union AffineAnimCmd *const gAffineAnims_BattleSpriteOpponentSide[] =
{
gUnknown_082FF548,
gUnknown_082FF568,
@ -313,8 +312,7 @@ const union AnimCmd *const gUnknown_082FF70C[] =
#include "data/pokemon_graphics/front_pic_anims.h"
#include "data/pokemon_graphics/front_pic_table.h"
// unused
const u32 gUnknown830AF4C[] =
static const u32 sUnused[] =
{
0x00000888, 0x00000888, 0x00000888, 0x00000888,
0x00000088, 0x00000888, 0x00000888, 0x00000886,

View File

@ -1522,8 +1522,8 @@ static void sub_8140174(void)
gBattle_BG1_X = 0;
gBattle_BG1_Y = 0;
gBattle_BG2_X = 0;
SetBgAttribute(1, BG_ATTR_PRIORITY, sub_80391E0(1, 5));
SetBgAttribute(2, BG_ATTR_PRIORITY, sub_80391E0(2, 5));
SetBgAttribute(1, BG_ATTR_PRIORITY, GetBattleBgTemplateData(1, 5));
SetBgAttribute(2, BG_ATTR_PRIORITY, GetBattleBgTemplateData(2, 5));
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG3_ON | DISPCNT_BG0_ON | DISPCNT_OBJ_1D_MAP);
Free(sEvoMovingBgPtr);
}

View File

@ -350,7 +350,7 @@ static void VBlankIntr(void)
gPcmDmaCounter = gSoundInfo.pcmDmaCounter;
m4aSoundMain();
sub_8033648();
TryReceiveLinkBattleData();
if (!gMain.inBattle || !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_RECORDED)))
Random();

View File

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

View File

@ -34,13 +34,13 @@ static void sub_8075970(struct Sprite *sprite);
static void HandleBallAnimEnd(struct Sprite *sprite);
static void sub_8075FB4(struct Sprite *sprite);
static void sub_80760F8(struct Sprite *sprite);
static void sub_8076524(struct Sprite *sprite);
static void sub_80765E0(struct Sprite *sprite);
static void sub_80767D4(struct Sprite *sprite);
static void sub_807687C(struct Sprite *sprite);
static void sub_80768F0(struct Sprite *sprite);
static void sub_80769A8(struct Sprite *sprite);
static void sub_80769CC(struct Sprite *sprite);
static void SpriteCB_PokeballReleaseMon(struct Sprite *sprite);
static void SpriteCB_ReleasedMonFlyOut(struct Sprite *sprite);
static void SpriteCB_TradePokeball(struct Sprite *sprite);
static void SpriteCB_TradePokeballSendOff(struct Sprite *sprite);
static void SpriteCB_TradePokeballEnd(struct Sprite *sprite);
static void SpriteCB_HealthboxSlideInDelayed(struct Sprite *sprite);
static void SpriteCB_HealthboxSlideIn(struct Sprite *sprite);
static void SpriteCB_HitAnimHealthoxEffect(struct Sprite *sprite);
static u16 GetBattlerPokeballItemId(u8 battlerId);
@ -61,34 +61,34 @@ static u16 GetBattlerPokeballItemId(u8 battlerId);
const struct CompressedSpriteSheet gBallSpriteSheets[POKEBALL_COUNT] =
{
{gInterfaceGfx_PokeBall, 384, GFX_TAG_POKEBALL},
{gInterfaceGfx_GreatBall, 384, GFX_TAG_GREATBALL},
{gInterfaceGfx_SafariBall, 384, GFX_TAG_SAFARIBALL},
{gInterfaceGfx_UltraBall, 384, GFX_TAG_ULTRABALL},
{gInterfaceGfx_MasterBall, 384, GFX_TAG_MASTERBALL},
{gInterfaceGfx_NetBall, 384, GFX_TAG_NETBALL},
{gInterfaceGfx_DiveBall, 384, GFX_TAG_DIVEBALL},
{gInterfaceGfx_NestBall, 384, GFX_TAG_NESTBALL},
{gInterfaceGfx_RepeatBall, 384, GFX_TAG_REPEATBALL},
{gInterfaceGfx_TimerBall, 384, GFX_TAG_TIMERBALL},
{gInterfaceGfx_LuxuryBall, 384, GFX_TAG_LUXURYBALL},
{gInterfaceGfx_PremierBall, 384, GFX_TAG_PREMIERBALL},
[BALL_POKE] = {gInterfaceGfx_PokeBall, 384, GFX_TAG_POKEBALL},
[BALL_GREAT] = {gInterfaceGfx_GreatBall, 384, GFX_TAG_GREATBALL},
[BALL_SAFARI] = {gInterfaceGfx_SafariBall, 384, GFX_TAG_SAFARIBALL},
[BALL_ULTRA] = {gInterfaceGfx_UltraBall, 384, GFX_TAG_ULTRABALL},
[BALL_MASTER] = {gInterfaceGfx_MasterBall, 384, GFX_TAG_MASTERBALL},
[BALL_NET] = {gInterfaceGfx_NetBall, 384, GFX_TAG_NETBALL},
[BALL_DIVE] = {gInterfaceGfx_DiveBall, 384, GFX_TAG_DIVEBALL},
[BALL_NEST] = {gInterfaceGfx_NestBall, 384, GFX_TAG_NESTBALL},
[BALL_REPEAT] = {gInterfaceGfx_RepeatBall, 384, GFX_TAG_REPEATBALL},
[BALL_TIMER] = {gInterfaceGfx_TimerBall, 384, GFX_TAG_TIMERBALL},
[BALL_LUXURY] = {gInterfaceGfx_LuxuryBall, 384, GFX_TAG_LUXURYBALL},
[BALL_PREMIER] = {gInterfaceGfx_PremierBall, 384, GFX_TAG_PREMIERBALL},
};
const struct CompressedSpritePalette gBallSpritePalettes[POKEBALL_COUNT] =
{
{gInterfacePal_PokeBall, GFX_TAG_POKEBALL},
{gInterfacePal_GreatBall, GFX_TAG_GREATBALL},
{gInterfacePal_SafariBall, GFX_TAG_SAFARIBALL},
{gInterfacePal_UltraBall, GFX_TAG_ULTRABALL},
{gInterfacePal_MasterBall, GFX_TAG_MASTERBALL},
{gInterfacePal_NetBall, GFX_TAG_NETBALL},
{gInterfacePal_DiveBall, GFX_TAG_DIVEBALL},
{gInterfacePal_NestBall, GFX_TAG_NESTBALL},
{gInterfacePal_RepeatBall, GFX_TAG_REPEATBALL},
{gInterfacePal_TimerBall, GFX_TAG_TIMERBALL},
{gInterfacePal_LuxuryBall, GFX_TAG_LUXURYBALL},
{gInterfacePal_PremierBall, GFX_TAG_PREMIERBALL},
[BALL_POKE] = {gInterfacePal_PokeBall, GFX_TAG_POKEBALL},
[BALL_GREAT] = {gInterfacePal_GreatBall, GFX_TAG_GREATBALL},
[BALL_SAFARI] = {gInterfacePal_SafariBall, GFX_TAG_SAFARIBALL},
[BALL_ULTRA] = {gInterfacePal_UltraBall, GFX_TAG_ULTRABALL},
[BALL_MASTER] = {gInterfacePal_MasterBall, GFX_TAG_MASTERBALL},
[BALL_NET] = {gInterfacePal_NetBall, GFX_TAG_NETBALL},
[BALL_DIVE] = {gInterfacePal_DiveBall, GFX_TAG_DIVEBALL},
[BALL_NEST] = {gInterfacePal_NestBall, GFX_TAG_NESTBALL},
[BALL_REPEAT] = {gInterfacePal_RepeatBall, GFX_TAG_REPEATBALL},
[BALL_TIMER] = {gInterfacePal_TimerBall, GFX_TAG_TIMERBALL},
[BALL_LUXURY] = {gInterfacePal_LuxuryBall, GFX_TAG_LUXURYBALL},
[BALL_PREMIER] = {gInterfacePal_PremierBall, GFX_TAG_PREMIERBALL},
};
static const struct OamData sBallOamData =
@ -656,7 +656,7 @@ static void Task_PlayCryWhenReleasedFromBall(u8 taskId)
u16 species = gTasks[taskId].tCryTaskSpecies;
u8 battlerId = gTasks[taskId].tCryTaskBattler;
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)
{
@ -670,7 +670,7 @@ static void Task_PlayCryWhenReleasedFromBall(u8 taskId)
PlayCry3(species, pan, 0);
else
PlayCry3(species, pan, 11);
gBattleSpritesDataPtr->healthBoxesData[battlerId].field_1_x40 = 0;
gBattleSpritesDataPtr->healthBoxesData[battlerId].waitForCry = FALSE;
DestroyTask(taskId);
break;
case 2:
@ -686,7 +686,7 @@ static void Task_PlayCryWhenReleasedFromBall(u8 taskId)
else
PlayCry4(species, pan, 12);
gBattleSpritesDataPtr->healthBoxesData[battlerId].field_1_x40 = 0;
gBattleSpritesDataPtr->healthBoxesData[battlerId].waitForCry = FALSE;
DestroyTask(taskId);
}
else
@ -725,7 +725,7 @@ static void Task_PlayCryWhenReleasedFromBall(u8 taskId)
else
PlayCry4(species, pan, 11);
gBattleSpritesDataPtr->healthBoxesData[battlerId].field_1_x40 = 0;
gBattleSpritesDataPtr->healthBoxesData[battlerId].waitForCry = FALSE;
DestroyTask(taskId);
break;
}
@ -763,7 +763,7 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite)
species = GetMonData(mon, MON_DATA_SPECIES);
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)
{
@ -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;
else if (battlerId == GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) || battlerId == GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT))
wantedCryCase = 1;
else
wantedCryCase = 2;
gBattleSpritesDataPtr->healthBoxesData[battlerId].field_1_x40 = 1;
gBattleSpritesDataPtr->healthBoxesData[battlerId].waitForCry = TRUE;
taskId = CreateTask(Task_PlayCryWhenReleasedFromBall, 3);
gTasks[taskId].tCryTaskSpecies = species;
@ -950,7 +950,7 @@ static void SpriteCB_PlayerMonSendOut_2(struct Sprite *sprite)
sprite->sBattler = sprite->oam.affineParam & 0xFF;
sprite->data[0] = 0;
if (IsDoubleBattle() && gBattleSpritesDataPtr->animationData->field_9_x1
if (IsDoubleBattle() && gBattleSpritesDataPtr->animationData->introAnimActive
&& sprite->sBattler == GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT))
sprite->callback = SpriteCB_ReleaseMon2FromBall;
else
@ -976,7 +976,7 @@ static void SpriteCB_OpponentMonSendOut(struct Sprite *sprite)
if (sprite->data[0] > 15)
{
sprite->data[0] = 0;
if (IsDoubleBattle() && gBattleSpritesDataPtr->animationData->field_9_x1
if (IsDoubleBattle() && gBattleSpritesDataPtr->animationData->introAnimActive
&& sprite->sBattler == GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT))
sprite->callback = SpriteCB_ReleaseMon2FromBall;
else
@ -996,6 +996,7 @@ static u8 LaunchBallFadeMonTaskForPokeball(bool8 unFadeLater, u8 battlerId, u32
return LaunchBallFadeMonTask(unFadeLater, battlerId, arg2, BALL_POKE);
}
// Pokeball in Birch intro, and when receiving via trade
void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 battlerId, u8 x, u8 y, u8 oamPriority, u8 subpriortiy, u8 g, u32 h, u16 species)
{
u8 spriteId;
@ -1017,12 +1018,12 @@ void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 battlerId, u8 x, u8 y,
gSprites[spriteId].data[3] = h;
gSprites[spriteId].data[4] = h >> 0x10;
gSprites[spriteId].oam.priority = oamPriority;
gSprites[spriteId].callback = sub_8076524;
gSprites[spriteId].callback = SpriteCB_PokeballReleaseMon;
gSprites[monSpriteId].invisible = TRUE;
}
static void sub_8076524(struct Sprite *sprite)
static void SpriteCB_PokeballReleaseMon(struct Sprite *sprite)
{
if (sprite->data[1] == 0)
{
@ -1039,7 +1040,7 @@ static void sub_8076524(struct Sprite *sprite)
StartSpriteAnim(sprite, 1);
AnimateBallOpenParticlesForPokeball(sprite->pos1.x, sprite->pos1.y - 5, sprite->oam.priority, r5);
sprite->data[1] = LaunchBallFadeMonTaskForPokeball(1, battlerId, r4);
sprite->callback = sub_80765E0;
sprite->callback = SpriteCB_ReleasedMonFlyOut;
gSprites[r7].invisible = FALSE;
StartSpriteAffineAnim(&gSprites[r7], 1);
AnimateSprite(&gSprites[r7]);
@ -1052,7 +1053,7 @@ static void sub_8076524(struct Sprite *sprite)
}
}
static void sub_80765E0(struct Sprite *sprite)
static void SpriteCB_ReleasedMonFlyOut(struct Sprite *sprite)
{
bool8 r12 = FALSE;
bool8 r6 = FALSE;
@ -1111,16 +1112,16 @@ u8 CreateTradePokeballSprite(u8 a, u8 b, u8 x, u8 y, u8 oamPriority, u8 subPrior
gSprites[spriteId].data[3] = h;
gSprites[spriteId].data[4] = h >> 16;
gSprites[spriteId].oam.priority = oamPriority;
gSprites[spriteId].callback = sub_80767D4;
gSprites[spriteId].callback = SpriteCB_TradePokeball;
return spriteId;
}
static void sub_80767D4(struct Sprite *sprite)
static void SpriteCB_TradePokeball(struct Sprite *sprite)
{
if (sprite->data[1] == 0)
{
u8 r6;
u8 r7 = sprite->data[0];
u8 monSpriteId = sprite->data[0];
u8 r8 = sprite->data[2];
u32 r5 = (u16)sprite->data[3] | ((u16)sprite->data[4] << 16);
@ -1132,15 +1133,15 @@ static void sub_80767D4(struct Sprite *sprite)
StartSpriteAnim(sprite, 1);
AnimateBallOpenParticlesForPokeball(sprite->pos1.x, sprite->pos1.y - 5, sprite->oam.priority, r6);
sprite->data[1] = LaunchBallFadeMonTaskForPokeball(1, r8, r5);
sprite->callback = sub_807687C;
sprite->callback = SpriteCB_TradePokeballSendOff;
#ifdef BUGFIX
// FIX: If this is used on a sprite that has previously had an affine animation, it will not
// play the shrink anim properly due to being paused. Works together with the fix to `sub_817F77C`.
gSprites[r7].affineAnimPaused = FALSE;
gSprites[monSpriteId].affineAnimPaused = FALSE;
#endif // BUGFIX
StartSpriteAffineAnim(&gSprites[r7], 2);
AnimateSprite(&gSprites[r7]);
gSprites[r7].data[1] = 0;
StartSpriteAffineAnim(&gSprites[monSpriteId], 2);
AnimateSprite(&gSprites[monSpriteId]);
gSprites[monSpriteId].data[1] = 0;
}
else
{
@ -1148,29 +1149,29 @@ static void sub_80767D4(struct Sprite *sprite)
}
}
static void sub_807687C(struct Sprite *sprite)
static void SpriteCB_TradePokeballSendOff(struct Sprite *sprite)
{
u8 r1;
u8 monSpriteId;
sprite->data[5]++;
if (sprite->data[5] == 11)
PlaySE(SE_BALL_TRADE);
r1 = sprite->data[0];
if (gSprites[r1].affineAnimEnded)
monSpriteId = sprite->data[0];
if (gSprites[monSpriteId].affineAnimEnded)
{
StartSpriteAnim(sprite, 2);
gSprites[r1].invisible = TRUE;
gSprites[monSpriteId].invisible = TRUE;
sprite->data[5] = 0;
sprite->callback = sub_80768F0;
sprite->callback = SpriteCB_TradePokeballEnd;
}
else
{
gSprites[r1].data[1] += 96;
gSprites[r1].pos2.y = -gSprites[r1].data[1] >> 8;
gSprites[monSpriteId].data[1] += 96;
gSprites[monSpriteId].pos2.y = -gSprites[monSpriteId].data[1] >> 8;
}
}
static void sub_80768F0(struct Sprite *sprite)
static void SpriteCB_TradePokeballEnd(struct Sprite *sprite)
{
if (sprite->animEnded)
sprite->callback = SpriteCallbackDummy;
@ -1181,45 +1182,54 @@ static void Unref_DestroySpriteAndFreeResources(struct Sprite *sprite)
DestroySpriteAndFreeResources(sprite);
}
void sub_8076918(u8 battlerId)
#define sSpeedX data[0]
#define sSpeedY data[1]
#define sDelayTimer data[1]
void StartHealthboxSlideIn(u8 battlerId)
{
struct Sprite *healthboxSprite = &gSprites[gHealthboxSpriteIds[battlerId]];
healthboxSprite->data[0] = 5;
healthboxSprite->data[1] = 0;
healthboxSprite->sSpeedX = 5;
healthboxSprite->sSpeedY = 0;
healthboxSprite->pos2.x = 0x73;
healthboxSprite->pos2.y = 0;
healthboxSprite->callback = sub_80769CC;
healthboxSprite->callback = SpriteCB_HealthboxSlideIn;
if (GetBattlerSide(battlerId) != B_SIDE_PLAYER)
{
healthboxSprite->data[0] = -healthboxSprite->data[0];
healthboxSprite->data[1] = -healthboxSprite->data[1];
healthboxSprite->sSpeedX = -healthboxSprite->sSpeedX;
healthboxSprite->sSpeedY = -healthboxSprite->sSpeedY;
healthboxSprite->pos2.x = -healthboxSprite->pos2.x;
healthboxSprite->pos2.y = -healthboxSprite->pos2.y;
}
gSprites[healthboxSprite->data[5]].callback(&gSprites[healthboxSprite->data[5]]);
if (GetBattlerPosition(battlerId) == B_POSITION_PLAYER_RIGHT)
healthboxSprite->callback = sub_80769A8;
healthboxSprite->callback = SpriteCB_HealthboxSlideInDelayed;
}
static void sub_80769A8(struct Sprite *sprite)
static void SpriteCB_HealthboxSlideInDelayed(struct Sprite *sprite)
{
sprite->data[1]++;
if (sprite->data[1] == 20)
sprite->sDelayTimer++;
if (sprite->sDelayTimer == 20)
{
sprite->data[1] = 0;
sprite->callback = sub_80769CC;
sprite->sDelayTimer = 0;
sprite->callback = SpriteCB_HealthboxSlideIn;
}
}
static void sub_80769CC(struct Sprite *sprite)
static void SpriteCB_HealthboxSlideIn(struct Sprite *sprite)
{
sprite->pos2.x -= sprite->data[0];
sprite->pos2.y -= sprite->data[1];
sprite->pos2.x -= sprite->sSpeedX;
sprite->pos2.y -= sprite->sSpeedY;
if (sprite->pos2.x == 0 && sprite->pos2.y == 0)
sprite->callback = SpriteCallbackDummy;
}
#undef sSpeedX
#undef sSpeedY
#undef sDelayTimer
void DoHitAnimHealthboxEffect(u8 battlerId)
{
u8 spriteId;

View File

@ -1350,32 +1350,32 @@ const struct SpindaSpot gSpindaSpotGraphics[] =
const s8 gNatureStatTable[NUM_NATURES][NUM_NATURE_STATS] =
{
// Atk Def Spd Sp.Atk Sp.Def
{ 0, 0, 0, 0, 0}, // Hardy
{ +1, -1, 0, 0, 0}, // Lonely
{ +1, 0, -1, 0, 0}, // Brave
{ +1, 0, 0, -1, 0}, // Adamant
{ +1, 0, 0, 0, -1}, // Naughty
{ -1, +1, 0, 0, 0}, // Bold
{ 0, 0, 0, 0, 0}, // Docile
{ 0, +1, -1, 0, 0}, // Relaxed
{ 0, +1, 0, -1, 0}, // Impish
{ 0, +1, 0, 0, -1}, // Lax
{ -1, 0, +1, 0, 0}, // Timid
{ 0, -1, +1, 0, 0}, // Hasty
{ 0, 0, 0, 0, 0}, // Serious
{ 0, 0, +1, -1, 0}, // Jolly
{ 0, 0, +1, 0, -1}, // Naive
{ -1, 0, 0, +1, 0}, // Modest
{ 0, -1, 0, +1, 0}, // Mild
{ 0, 0, -1, +1, 0}, // Quiet
{ 0, 0, 0, 0, 0}, // Bashful
{ 0, 0, 0, +1, -1}, // Rash
{ -1, 0, 0, 0, +1}, // Calm
{ 0, -1, 0, 0, +1}, // Gentle
{ 0, 0, -1, 0, +1}, // Sassy
{ 0, 0, 0, -1, +1}, // Careful
{ 0, 0, 0, 0, 0}, // Quirky
// Atk Def Spd Sp.Atk Sp.Def
[NATURE_HARDY] = { 0, 0, 0, 0, 0},
[NATURE_LONELY] = { +1, -1, 0, 0, 0},
[NATURE_BRAVE] = { +1, 0, -1, 0, 0},
[NATURE_ADAMANT] = { +1, 0, 0, -1, 0},
[NATURE_NAUGHTY] = { +1, 0, 0, 0, -1},
[NATURE_BOLD] = { -1, +1, 0, 0, 0},
[NATURE_DOCILE] = { 0, 0, 0, 0, 0},
[NATURE_RELAXED] = { 0, +1, -1, 0, 0},
[NATURE_IMPISH] = { 0, +1, 0, -1, 0},
[NATURE_LAX] = { 0, +1, 0, 0, -1},
[NATURE_TIMID] = { -1, 0, +1, 0, 0},
[NATURE_HASTY] = { 0, -1, +1, 0, 0},
[NATURE_SERIOUS] = { 0, 0, 0, 0, 0},
[NATURE_JOLLY] = { 0, 0, +1, -1, 0},
[NATURE_NAIVE] = { 0, 0, +1, 0, -1},
[NATURE_MODEST] = { -1, 0, 0, +1, 0},
[NATURE_MILD] = { 0, -1, 0, +1, 0},
[NATURE_QUIET] = { 0, 0, -1, +1, 0},
[NATURE_BASHFUL] = { 0, 0, 0, 0, 0},
[NATURE_RASH] = { 0, 0, 0, +1, -1},
[NATURE_CALM] = { -1, 0, 0, 0, +1},
[NATURE_GENTLE] = { 0, -1, 0, 0, +1},
[NATURE_SASSY] = { 0, 0, -1, 0, +1},
[NATURE_CAREFUL] = { 0, 0, 0, -1, +1},
[NATURE_QUIRKY] = { 0, 0, 0, 0, 0},
};
#include "data/pokemon/tmhm_learnsets.h"
@ -1937,119 +1937,119 @@ static const u8 sHoldEffectToType[][2] =
{HOLD_EFFECT_NORMAL_POWER, TYPE_NORMAL},
};
const struct SpriteTemplate gUnknown_08329D98[MAX_BATTLERS_COUNT] =
const struct SpriteTemplate gBattlerSpriteTemplates[MAX_BATTLERS_COUNT] =
{
{ // B_POSITION_PLAYER_LEFT
[B_POSITION_PLAYER_LEFT] = {
.tileTag = 0xFFFF,
.paletteTag = 0,
.oam = &gOamData_831ACB0,
.oam = &gOamData_BattleSpritePlayerSide,
.anims = NULL,
.images = gUnknown_082FF3A8,
.affineAnims = gUnknown_082FF618,
.callback = sub_8039BB4,
.images = gBattlerPicTable_PlayerLeft,
.affineAnims = gAffineAnims_BattleSpritePlayerSide,
.callback = SpriteCB_BattleSpriteStartSlideLeft,
},
{ // B_POSITION_OPPONENT_LEFT
[B_POSITION_OPPONENT_LEFT] = {
.tileTag = 0xFFFF,
.paletteTag = 0,
.oam = &gOamData_831ACA8,
.oam = &gOamData_BattleSpriteOpponentSide,
.anims = NULL,
.images = gUnknown_082FF3C8,
.affineAnims = gUnknown_082FF694,
.images = gBattlerPicTable_OpponentLeft,
.affineAnims = gAffineAnims_BattleSpriteOpponentSide,
.callback = SpriteCb_WildMon,
},
{ // B_POSITION_PLAYER_RIGHT
[B_POSITION_PLAYER_RIGHT] = {
.tileTag = 0xFFFF,
.paletteTag = 0,
.oam = &gOamData_831ACB0,
.oam = &gOamData_BattleSpritePlayerSide,
.anims = NULL,
.images = gUnknown_082FF3E8,
.affineAnims = gUnknown_082FF618,
.callback = sub_8039BB4,
.images = gBattlerPicTable_PlayerRight,
.affineAnims = gAffineAnims_BattleSpritePlayerSide,
.callback = SpriteCB_BattleSpriteStartSlideLeft,
},
{ // B_POSITION_OPPONENT_RIGHT
[B_POSITION_OPPONENT_RIGHT] = {
.tileTag = 0xFFFF,
.paletteTag = 0,
.oam = &gOamData_831ACA8,
.oam = &gOamData_BattleSpriteOpponentSide,
.anims = NULL,
.images = gUnknown_082FF408,
.affineAnims = gUnknown_082FF694,
.images = gBattlerPicTable_OpponentRight,
.affineAnims = gAffineAnims_BattleSpriteOpponentSide,
.callback = SpriteCb_WildMon
},
};
static const struct SpriteTemplate gSpriteTemplateTable_TrainerBackSprites[] =
static const struct SpriteTemplate sTrainerBackSpriteTemplates[] =
{
{
[TRAINER_BACK_PIC_BRENDAN] = {
.tileTag = 0xFFFF,
.paletteTag = 0,
.oam = &gOamData_831ACB0,
.oam = &gOamData_BattleSpritePlayerSide,
.anims = NULL,
.images = gTrainerBackPicTable_Brendan,
.affineAnims = gUnknown_082FF618,
.callback = sub_8039BB4,
.affineAnims = gAffineAnims_BattleSpritePlayerSide,
.callback = SpriteCB_BattleSpriteStartSlideLeft,
},
{
[TRAINER_BACK_PIC_MAY] = {
.tileTag = 0xFFFF,
.paletteTag = 0,
.oam = &gOamData_831ACB0,
.oam = &gOamData_BattleSpritePlayerSide,
.anims = NULL,
.images = gTrainerBackPicTable_May,
.affineAnims = gUnknown_082FF618,
.callback = sub_8039BB4,
.affineAnims = gAffineAnims_BattleSpritePlayerSide,
.callback = SpriteCB_BattleSpriteStartSlideLeft,
},
{
[TRAINER_BACK_PIC_RED] = {
.tileTag = 0xFFFF,
.paletteTag = 0,
.oam = &gOamData_831ACB0,
.oam = &gOamData_BattleSpritePlayerSide,
.anims = NULL,
.images = gTrainerBackPicTable_Red,
.affineAnims = gUnknown_082FF618,
.callback = sub_8039BB4,
.affineAnims = gAffineAnims_BattleSpritePlayerSide,
.callback = SpriteCB_BattleSpriteStartSlideLeft,
},
{
[TRAINER_BACK_PIC_LEAF] = {
.tileTag = 0xFFFF,
.paletteTag = 0,
.oam = &gOamData_831ACB0,
.oam = &gOamData_BattleSpritePlayerSide,
.anims = NULL,
.images = gTrainerBackPicTable_Leaf,
.affineAnims = gUnknown_082FF618,
.callback = sub_8039BB4,
.affineAnims = gAffineAnims_BattleSpritePlayerSide,
.callback = SpriteCB_BattleSpriteStartSlideLeft,
},
{
[TRAINER_BACK_PIC_RUBY_SAPPHIRE_BRENDAN] = {
.tileTag = 0xFFFF,
.paletteTag = 0,
.oam = &gOamData_831ACB0,
.oam = &gOamData_BattleSpritePlayerSide,
.anims = NULL,
.images = gTrainerBackPicTable_RubySapphireBrendan,
.affineAnims = gUnknown_082FF618,
.callback = sub_8039BB4,
.affineAnims = gAffineAnims_BattleSpritePlayerSide,
.callback = SpriteCB_BattleSpriteStartSlideLeft,
},
{
[TRAINER_BACK_PIC_RUBY_SAPPHIRE_MAY] = {
.tileTag = 0xFFFF,
.paletteTag = 0,
.oam = &gOamData_831ACB0,
.oam = &gOamData_BattleSpritePlayerSide,
.anims = NULL,
.images = gTrainerBackPicTable_RubySapphireMay,
.affineAnims = gUnknown_082FF618,
.callback = sub_8039BB4,
.affineAnims = gAffineAnims_BattleSpritePlayerSide,
.callback = SpriteCB_BattleSpriteStartSlideLeft,
},
{
[TRAINER_BACK_PIC_WALLY] = {
.tileTag = 0xFFFF,
.paletteTag = 0,
.oam = &gOamData_831ACB0,
.oam = &gOamData_BattleSpritePlayerSide,
.anims = NULL,
.images = gTrainerBackPicTable_Wally,
.affineAnims = gUnknown_082FF618,
.callback = sub_8039BB4,
.affineAnims = gAffineAnims_BattleSpritePlayerSide,
.callback = SpriteCB_BattleSpriteStartSlideLeft,
},
{
[TRAINER_BACK_PIC_STEVEN] = {
.tileTag = 0xFFFF,
.paletteTag = 0,
.oam = &gOamData_831ACB0,
.oam = &gOamData_BattleSpritePlayerSide,
.anims = NULL,
.images = gTrainerBackPicTable_Steven,
.affineAnims = gUnknown_082FF618,
.callback = sub_8039BB4,
.affineAnims = gAffineAnims_BattleSpritePlayerSide,
.callback = SpriteCB_BattleSpriteStartSlideLeft,
},
};
@ -2623,14 +2623,15 @@ void CreateObedientMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u
SetMonData(mon, MON_DATA_OBEDIENCE, &obedient);
}
bool8 sub_80688F8(u8 caseId, u8 battlerId)
// If FALSE, should load this game's Deoxys form. If TRUE, should load normal Deoxys form
bool8 ShouldIgnoreDeoxysForm(u8 caseId, u8 battlerId)
{
switch (caseId)
{
case 0:
default:
return FALSE;
case 1:
case 1: // Player's side in battle
if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI))
return FALSE;
if (!gMain.inBattle)
@ -2640,7 +2641,7 @@ bool8 sub_80688F8(u8 caseId, u8 battlerId)
break;
case 2:
break;
case 3:
case 3: // Summary Screen
if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI))
return FALSE;
if (!gMain.inBattle)
@ -2650,7 +2651,7 @@ bool8 sub_80688F8(u8 caseId, u8 battlerId)
return FALSE;
case 4:
break;
case 5:
case 5: // In move animation, e.g. in Role Play or Snatch
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
if (!gMain.inBattle)
@ -3454,7 +3455,7 @@ void SetMultiuseSpriteTemplateToPokemon(u16 speciesTag, u8 battlerPosition)
else if (gUnknown_020249B4[1])
gMultiuseSpriteTemplate = gUnknown_020249B4[1]->templates[battlerPosition];
else
gMultiuseSpriteTemplate = gUnknown_08329D98[battlerPosition];
gMultiuseSpriteTemplate = gBattlerSpriteTemplates[battlerPosition];
gMultiuseSpriteTemplate.paletteTag = speciesTag;
if (battlerPosition == B_POSITION_PLAYER_LEFT || battlerPosition == B_POSITION_PLAYER_RIGHT)
@ -3470,7 +3471,7 @@ void SetMultiuseSpriteTemplateToTrainerBack(u16 trainerSpriteId, u8 battlerPosit
gMultiuseSpriteTemplate.paletteTag = trainerSpriteId;
if (battlerPosition == B_POSITION_PLAYER_LEFT || battlerPosition == B_POSITION_PLAYER_RIGHT)
{
gMultiuseSpriteTemplate = gSpriteTemplateTable_TrainerBackSprites[trainerSpriteId];
gMultiuseSpriteTemplate = sTrainerBackSpriteTemplates[trainerSpriteId];
gMultiuseSpriteTemplate.anims = gTrainerBackAnimsPtrTable[trainerSpriteId];
}
else
@ -3478,7 +3479,7 @@ void SetMultiuseSpriteTemplateToTrainerBack(u16 trainerSpriteId, u8 battlerPosit
if (gMonSpritesGfxPtr != NULL)
gMultiuseSpriteTemplate = gMonSpritesGfxPtr->templates[battlerPosition];
else
gMultiuseSpriteTemplate = gUnknown_08329D98[battlerPosition];
gMultiuseSpriteTemplate = gBattlerSpriteTemplates[battlerPosition];
gMultiuseSpriteTemplate.anims = gTrainerFrontAnimsPtrTable[trainerSpriteId];
}
}
@ -3488,7 +3489,7 @@ void SetMultiuseSpriteTemplateToTrainerFront(u16 arg0, u8 battlerPosition)
if (gMonSpritesGfxPtr != NULL)
gMultiuseSpriteTemplate = gMonSpritesGfxPtr->templates[battlerPosition];
else
gMultiuseSpriteTemplate = gUnknown_08329D98[battlerPosition];
gMultiuseSpriteTemplate = gBattlerSpriteTemplates[battlerPosition];
gMultiuseSpriteTemplate.paletteTag = arg0;
gMultiuseSpriteTemplate.anims = gTrainerFrontAnimsPtrTable[arg0];
@ -5594,96 +5595,63 @@ u16 SpeciesToCryId(u16 species)
return gSpeciesIdToCryId[species - (SPECIES_TREECKO - 1)];
}
void sub_806D544(u16 species, u32 personality, u8 *dest)
#define DRAW_SPINDA_SPOTS \
{ \
int i; \
for (i = 0; i < 4; i++) \
{ \
int j; \
u8 x = gSpindaSpotGraphics[i].x + ((personality & 0x0F) - 8); \
u8 y = gSpindaSpotGraphics[i].y + (((personality & 0xF0) >> 4) - 8); \
\
for (j = 0; j < 16; j++) \
{ \
int k; \
s32 row = gSpindaSpotGraphics[i].image[j]; \
\
for (k = x; k < x + 16; k++) \
{ \
u8 *val = dest + ((k / 8) * 32) + \
((k % 8) / 2) + \
((y >> 3) << 8) + \
((y & 7) << 2); \
\
if (row & 1) \
{ \
if (k & 1) \
{ \
if ((u8)((*val & 0xF0) - 0x10) <= 0x20) \
*val += 0x40; \
} \
else \
{ \
if ((u8)((*val & 0xF) - 0x01) <= 0x02) \
*val += 0x04; \
} \
} \
\
row >>= 1; \
} \
\
y++; \
} \
\
personality >>= 8; \
} \
}
static void DrawSpindaSpotsUnused(u16 species, u32 personality, u8 *dest)
{
if (species == SPECIES_SPINDA
&& dest != gMonSpritesGfxPtr->sprites.ptr[0]
&& dest != gMonSpritesGfxPtr->sprites.ptr[2])
{
int i;
for (i = 0; i < 4; i++)
{
int j;
u8 x = gSpindaSpotGraphics[i].x + ((personality & 0x0F) - 8);
u8 y = gSpindaSpotGraphics[i].y + (((personality & 0xF0) >> 4) - 8);
for (j = 0; j < 16; j++)
{
int k;
s32 row = gSpindaSpotGraphics[i].image[j];
for (k = x; k < x + 16; k++)
{
u8 *val = dest + ((k / 8) * 32) + ((k % 8) / 2) + ((y >> 3) << 8) + ((y & 7) << 2);
if (row & 1)
{
if (k & 1)
{
if ((u8)((*val & 0xF0) - 0x10) <= 0x20)
*val += 0x40;
}
else
{
if ((u8)((*val & 0xF) - 0x01) <= 0x02)
*val += 0x04;
}
}
row >>= 1;
}
y++;
}
personality >>= 8;
}
}
DRAW_SPINDA_SPOTS;
}
void DrawSpindaSpots(u16 species, u32 personality, u8 *dest, u8 a4)
void DrawSpindaSpots(u16 species, u32 personality, u8 *dest, bool8 isFrontPic)
{
if (species == SPECIES_SPINDA && a4)
{
int i;
for (i = 0; i < 4; i++)
{
int j;
u8 x = gSpindaSpotGraphics[i].x + ((personality & 0x0F) - 8);
u8 y = gSpindaSpotGraphics[i].y + (((personality & 0xF0) >> 4) - 8);
for (j = 0; j < 16; j++)
{
int k;
s32 row = gSpindaSpotGraphics[i].image[j];
for (k = x; k < x + 16; k++)
{
u8 *val = dest + ((k / 8) * 32) + ((k % 8) / 2) + ((y >> 3) << 8) + ((y & 7) << 2);
if (row & 1)
{
if (k & 1)
{
if ((u8)((*val & 0xF0) - 0x10) <= 0x20)
*val += 0x40;
}
else
{
if ((u8)((*val & 0xF) - 0x01) <= 0x02)
*val += 0x04;
}
}
row >>= 1;
}
y++;
}
personality >>= 8;
}
}
if (species == SPECIES_SPINDA && isFrontPic)
DRAW_SPINDA_SPOTS;
}
void EvolutionRenameMon(struct Pokemon *mon, u16 oldSpecies, u16 newSpecies)
@ -6824,7 +6792,7 @@ static void sub_806F160(struct Unknown_806F160_Struct* structPtr)
u16 i, j;
for (i = 0; i < structPtr->field_0_0; i++)
{
structPtr->templates[i] = gUnknown_08329D98[i];
structPtr->templates[i] = gBattlerSpriteTemplates[i];
for (j = 0; j < structPtr->field_1; j++)
{
structPtr->frameImages[i * structPtr->field_1 + j].data = &structPtr->byteArrays[i][j * 0x800];

View File

@ -1047,7 +1047,7 @@ static void sub_817F77C(struct Sprite *sprite)
{
// FIX: Reset these back to normal after they were changed so Poké Ball catch/release
// animations without a screen transition in between don't break
sprite->affineAnims = gUnknown_082FF694;
sprite->affineAnims = gAffineAnims_BattleSpriteOpponentSide;
}
#endif // BUGFIX
}

View File

@ -3426,8 +3426,8 @@ static void sub_802DB8C(void)
static const u8 gUnknown_082FE1DF[] = {2, 2, 0, 0, 1, 1, 1, 0, 0, 2, 0, 0, 0};
static const struct CompressedSpriteSheet gUnknown_082FE1EC = {gUnknown_082FF1F8, 0, 0x320};
static const struct SpritePalette gUnknown_082FE1F4 = {gUnknown_082FF1D8, 0x320};
static const struct CompressedSpriteSheet sSpriteSheet_Digits = {gMinigameDigits_Gfx, 0, 0x320};
static const struct SpritePalette sSpritePalette_Digits = {gMinigameDigits_Pal, 0x320};
static const u16 gUnknown_082FE1FC[] = {0x06, 0x08, 0x10, 0x08};
static const u16 gUnknown_082FE204[] = {0x06, 0x08, 0x0b, 0x06, 0x10, 0x08};
@ -3513,8 +3513,8 @@ static void sub_802DD08(void)
ptr->xDelta = 8;
ptr->x = 108;
ptr->y = 6;
ptr->spriteSheet = (void*) &gUnknown_082FE1EC;
ptr->spritePal = &gUnknown_082FE1F4;
ptr->spriteSheet = (void*) &sSpriteSheet_Digits;
ptr->spritePal = &sSpritePalette_Digits;
DigitObjUtil_Init(2);
DigitObjUtil_CreatePrinter(0, 0, ptr);

View File

@ -3857,7 +3857,7 @@ static u8 LoadMonGfxAndSprite(struct Pokemon *mon, s16 *state)
case 0:
if (gMain.inBattle)
{
if (sub_80688F8(3, sMonSummaryScreen->curMonIndex))
if (ShouldIgnoreDeoxysForm(3, sMonSummaryScreen->curMonIndex))
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[summary->species2], gMonSpritesGfxPtr->sprites.ptr[1], summary->species2, summary->pid);
else
HandleLoadSpecialPokePic_2(&gMonFrontPicTable[summary->species2], gMonSpritesGfxPtr->sprites.ptr[1], summary->species2, summary->pid);

View File

@ -75,10 +75,10 @@ struct RecordedBattleSave
EWRAM_DATA u32 gRecordedBattleRngSeed = 0;
EWRAM_DATA u32 gBattlePalaceMoveSelectionRngValue = 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 sUnknown_0203C79C[4] = {0};
EWRAM_DATA static u16 sUnknown_0203C7A4[4] = {0};
EWRAM_DATA static u8 sUnknown_0203C7AC = 0;
EWRAM_DATA static u16 sBattlerRecordSizes[MAX_BATTLERS_COUNT] = {0};
EWRAM_DATA static u16 sBattlerPrevRecordSizes[MAX_BATTLERS_COUNT] = {0};
EWRAM_DATA static u16 sBattlerSavedRecordSizes[MAX_BATTLERS_COUNT] = {0};
EWRAM_DATA static u8 sRecordMode = 0;
EWRAM_DATA static u8 sLvlMode = 0;
EWRAM_DATA static u8 sFrontierFacility = 0;
EWRAM_DATA static u8 sFrontierBrainSymbol = 0;
@ -93,7 +93,7 @@ EWRAM_DATA static struct Pokemon sSavedPlayerParty[PARTY_SIZE] = {0};
EWRAM_DATA static struct Pokemon sSavedOpponentParty[PARTY_SIZE] = {0};
EWRAM_DATA static u16 sPlayerMonMoves[2][MAX_MON_MOVES] = {0};
EWRAM_DATA static struct PlayerInfo sPlayers[MAX_BATTLERS_COUNT] = {0};
EWRAM_DATA static u8 sUnknown_0203CCD0 = 0;
EWRAM_DATA static bool8 sUnknown_0203CCD0 = 0;
EWRAM_DATA static u8 sRecordMixFriendName[PLAYER_NAME_LENGTH + 1] = {0};
EWRAM_DATA static u8 sRecordMixFriendClass = 0;
EWRAM_DATA static u8 sApprenticeId = 0;
@ -103,26 +103,25 @@ EWRAM_DATA static u8 sBattleOutcome = 0;
static u8 sRecordMixFriendLanguage;
static u8 sApprenticeLanguage;
// this file's functions
static u8 sub_8185278(u8 *arg0, u8 *arg1, u8 *arg2);
static bool32 CopyRecordedBattleFromSave(struct RecordedBattleSave *dst);
static u8 GetNextRecordedDataByte(u8 *, u8 *, u8 *);
static bool32 CopyRecordedBattleFromSave(struct RecordedBattleSave *);
static void RecordedBattle_RestoreSavedParties(void);
static void CB2_RecordedBattle(void);
void sub_8184DA4(u8 arg0)
void RecordedBattle_Init(u8 mode)
{
s32 i, j;
sUnknown_0203C7AC = arg0;
sUnknown_0203CCD0 = 0;
sRecordMode = mode;
sUnknown_0203CCD0 = FALSE;
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
sRecordedBytesNo[i] = 0;
sUnknown_0203C79C[i] = 0;
sUnknown_0203C7A4[i] = 0;
sBattlerRecordSizes[i] = 0;
sBattlerPrevRecordSizes[i] = 0;
sBattlerSavedRecordSizes[i] = 0;
if (arg0 == 1)
if (mode == B_RECORD_MODE_RECORDING)
{
for (j = 0; j < BATTLER_RECORD_SIZE; j++)
{
@ -138,13 +137,13 @@ void sub_8184E58(void)
{
s32 i, j;
if (sUnknown_0203C7AC == 1)
if (sRecordMode == B_RECORD_MODE_RECORDING)
{
gRecordedBattleRngSeed = gRngValue;
sFrontierFacility = VarGet(VAR_FRONTIER_FACILITY);
sFrontierBrainSymbol = GetFronterBrainSymbol();
}
else if (sUnknown_0203C7AC == 2)
else if (sRecordMode == B_RECORD_MODE_PLAYBACK)
{
gRngValue = gRecordedBattleRngSeed;
}
@ -195,9 +194,9 @@ void sub_8184E58(void)
void RecordedBattle_SetBattlerAction(u8 battlerId, u8 action)
{
if (sRecordedBytesNo[battlerId] < BATTLER_RECORD_SIZE && sUnknown_0203C7AC != 2)
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++)
{
sRecordedBytesNo[battlerId]--;
sBattleRecords[battlerId][sRecordedBytesNo[battlerId]] = 0xFF;
if (sRecordedBytesNo[battlerId] == 0)
sBattlerRecordSizes[battlerId]--;
sBattleRecords[battlerId][sBattlerRecordSizes[battlerId]] = 0xFF;
if (sBattlerRecordSizes[battlerId] == 0)
break;
}
}
@ -217,7 +216,7 @@ void RecordedBattle_ClearBattlerAction(u8 battlerId, u8 bytesToClear)
u8 RecordedBattle_GetBattlerAction(u8 battlerId)
{
// 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
ResetPaletteFadeControl();
@ -227,44 +226,45 @@ u8 RecordedBattle_GetBattlerAction(u8 battlerId)
}
else
{
return sBattleRecords[battlerId][sRecordedBytesNo[battlerId]++];
return sBattleRecords[battlerId][sBattlerRecordSizes[battlerId]++];
}
}
u8 sub_81850D0(void)
// Unused
static u8 GetRecordedBattleMode(void)
{
return sUnknown_0203C7AC;
return sRecordMode;
}
u8 sub_81850DC(u8 *arg0)
u8 RecordedBattle_BufferNewBattlerData(u8 *dst)
{
u8 i, j;
u8 ret = 0;
u8 idx = 0;
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
if (sRecordedBytesNo[i] != sUnknown_0203C79C[i])
if (sBattlerRecordSizes[i] != sBattlerPrevRecordSizes[i])
{
arg0[ret++] = i;
arg0[ret++] = sRecordedBytesNo[i] - sUnknown_0203C79C[i];
dst[idx++] = i;
dst[idx++] = sBattlerRecordSizes[i] - sBattlerPrevRecordSizes[i];
for (j = 0; j < sRecordedBytesNo[i] - sUnknown_0203C79C[i]; j++)
for (j = 0; j < sBattlerRecordSizes[i] - sBattlerPrevRecordSizes[i]; j++)
{
arg0[ret++] = sBattleRecords[i][sUnknown_0203C79C[i] + j];
dst[idx++] = sBattleRecords[i][sBattlerPrevRecordSizes[i] + j];
}
sUnknown_0203C79C[i] = sRecordedBytesNo[i];
sBattlerPrevRecordSizes[i] = sBattlerRecordSizes[i];
}
}
return ret;
return idx;
}
void sub_81851A8(u8 *arg0)
void RecordedBattle_RecordAllBattlerData(u8 *src)
{
s32 i;
u8 var1 = 2;
u8 var2;
u8 idx = 2;
u8 size;
if (!(gBattleTypeFlags & BATTLE_TYPE_LINK))
return;
@ -277,23 +277,23 @@ void sub_81851A8(u8 *arg0)
if (!(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER))
{
for (var2 = *arg0; var2 != 0;)
for (size = *src; size != 0;)
{
u8 unkVar = sub_8185278(arg0, &var1, &var2);
u8 unkVar2 = sub_8185278(arg0, &var1, &var2);
u8 battlerId = GetNextRecordedDataByte(src, &idx, &size);
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)--;
return arg0[(*arg1)++];
(*size)--;
return data[(*idx)++];
}
bool32 CanCopyRecordedBattleSaveData(void)
@ -720,7 +720,7 @@ void RecordedBattle_CopyBattlerMoves(void)
return;
if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED_LINK))
return;
if (sUnknown_0203C7AC == 2)
if (sRecordMode == B_RECORD_MODE_PLAYBACK)
return;
for (i = 0; i < MAX_MON_MOVES; i++)
@ -767,7 +767,7 @@ void sub_818603C(u8 arg0)
}
else
{
if (sBattleRecords[battlerId][sRecordedBytesNo[battlerId]] == ACTION_MOVE_CHANGE)
if (sBattleRecords[battlerId][sBattlerRecordSizes[battlerId]] == ACTION_MOVE_CHANGE)
{
u8 ppBonuses[MAX_MON_MOVES];
u8 array1[MAX_MON_MOVES];
@ -841,12 +841,12 @@ u32 GetAiScriptsInRecordedBattle(void)
void sub_8186444(void)
{
sUnknown_0203CCD0 = 1;
sUnknown_0203CCD0 = TRUE;
}
bool8 sub_8186450(void)
{
return (sUnknown_0203CCD0 == 0);
return (sUnknown_0203CCD0 == FALSE);
}
void GetRecordedBattleRecordMixFriendName(u8 *dst)

View File

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

View File

@ -262,12 +262,12 @@ u16 CreatePicSprite2(u16 species, u32 otId, u32 personality, u8 flags, s16 x, s1
sCreatingSpriteTemplate.images = images;
if (flags2 == 0x01)
{
sCreatingSpriteTemplate.affineAnims = gUnknown_082FF694;
sCreatingSpriteTemplate.affineAnims = gAffineAnims_BattleSpriteOpponentSide;
sCreatingSpriteTemplate.oam = &gUnknown_0860B06C;
}
else if (flags2 == 0x00)
{
sCreatingSpriteTemplate.affineAnims = gUnknown_082FF618;
sCreatingSpriteTemplate.affineAnims = gAffineAnims_BattleSpritePlayerSide;
sCreatingSpriteTemplate.oam = &gUnknown_0860B06C;
}
else