more work on controllers

This commit is contained in:
DizzyEggg 2023-08-04 13:42:40 +02:00
parent cc30d2fb53
commit 7ba8a0216f
10 changed files with 66 additions and 298 deletions

View File

@ -251,11 +251,14 @@ void BtlController_EmitResetActionMoveSelection(u8 bufferId, u8 caseId);
void BtlController_EmitEndLinkBattle(u8 bufferId, u8 battleOutcome);
void BtlController_EmitDebugMenu(u8 bufferId);
void StartSendOutAnim(u32 battler, bool32 dontClearSubstituteBit);
void BtlController_HandleGetMonData(u32 battler, struct Pokemon *party, void (*execCompleteFunc)(void));
void BtlController_HandleGetRawMonData(u32 battler, struct Pokemon *party, void (*execCompleteFunc)(void));
void BtlController_HandleSetMonData(u32 battler, struct Pokemon *party, void (*execCompleteFunc)(void));
void BtlController_HandleSetRawMonData(u32 battler, struct Pokemon *party, void (*execCompleteFunc)(void));
void BtlController_HandleLoadMonSprite(u32 battler, struct Pokemon *party, void (*controllerFunc)(void));
void BtlController_HandleSwitchInAnim(u32 battler, bool32 isPlayerSide, void (*controllerFunc)(void));
// player controller
void SetControllerToPlayer(void);

View File

@ -93,7 +93,6 @@ static void LinkOpponentBufferExecCompleted(void);
static void SwitchIn_HandleSoundAndEnd(void);
static u32 CopyLinkOpponentMonData(u8 monId, u8 *dst);
static void SetLinkOpponentMonData(u8 monId);
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void LinkOpponentDoMoveAnimation(void);
static void Task_StartSendOutAnim(u8 taskId);
@ -556,43 +555,7 @@ static void LinkOpponentHandleLoadMonSprite(void)
static void LinkOpponentHandleSwitchInAnim(void)
{
gBattlerPartyIndexes[gActiveBattler] = gBattleResources->bufferA[gActiveBattler][1];
StartSendOutAnim(gActiveBattler, gBattleResources->bufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_TryShinyAnim;
}
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1];
species = GetIllusionMonSpecies(battlerId);
if (species == SPECIES_NONE)
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
BattleLoadMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[battlerId] = CreateSprite(
&gMultiuseSpriteTemplate,
GetBattlerSpriteCoord(battlerId, BATTLER_COORD_X_2),
GetBattlerSpriteDefault_Y(battlerId),
GetBattlerSpriteSubpriority(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;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], 0);
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gBattleControllerData[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT);
BtlController_HandleSwitchInAnim(gActiveBattler, FALSE, SwitchIn_TryShinyAnim);
}
static void LinkOpponentHandleReturnMonToBall(void)

View File

@ -93,7 +93,6 @@ static void LinkPartnerBufferExecCompleted(void);
static void SwitchIn_WaitAndEnd(void);
static u32 CopyLinkPartnerMonData(u8 monId, u8 *dst);
static void SetLinkPartnerMonData(u8 monId);
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void LinkPartnerDoMoveAnimation(void);
static void Task_StartSendOutAnim(u8 taskId);
@ -450,42 +449,7 @@ static void LinkPartnerHandleLoadMonSprite(void)
static void LinkPartnerHandleSwitchInAnim(void)
{
ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleResources->bufferA[gActiveBattler][2]);
gBattlerPartyIndexes[gActiveBattler] = gBattleResources->bufferA[gActiveBattler][1];
BattleLoadMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
StartSendOutAnim(gActiveBattler, gBattleResources->bufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_TryShinyAnim;
}
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[battlerId] = CreateSprite(
&gMultiuseSpriteTemplate,
GetBattlerSpriteCoord(battlerId, BATTLER_COORD_X_2),
GetBattlerSpriteDefault_Y(battlerId),
GetBattlerSpriteSubpriority(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;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], 0);
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gBattleControllerData[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
BtlController_HandleSwitchInAnim(gActiveBattler, TRUE, SwitchIn_TryShinyAnim);
}
static void LinkPartnerHandleReturnMonToBall(void)

View File

@ -104,7 +104,6 @@ static void OpponentBufferExecCompleted(void);
static void SwitchIn_HandleSoundAndEnd(void);
static u32 GetOpponentMonData(u8 monId, u8 *dst);
static void SetOpponentMonData(u8 monId);
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void OpponentDoMoveAnimation(void);
static void SpriteCB_FreeOpponentSprite(struct Sprite *sprite);
@ -577,44 +576,8 @@ static void OpponentHandleLoadMonSprite(void)
static void OpponentHandleSwitchInAnim(void)
{
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = PARTY_SIZE;
gBattlerPartyIndexes[gActiveBattler] = gBattleResources->bufferA[gActiveBattler][1];
StartSendOutAnim(gActiveBattler, gBattleResources->bufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_TryShinyAnim;
}
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1];
species = GetIllusionMonSpecies(battlerId);
if (species == SPECIES_NONE)
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
BattleLoadMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[battlerId] = CreateSprite(&gMultiuseSpriteTemplate,
GetBattlerSpriteCoord(battlerId, BATTLER_COORD_X_2),
GetBattlerSpriteDefault_Y(battlerId),
GetBattlerSpriteSubpriority(battlerId));
gSprites[gBattlerSpriteIds[battlerId]].data[0] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = species;
gSprites[gBattleControllerData[battlerId]].data[1] = gBattlerSpriteIds[battlerId];
gSprites[gBattleControllerData[battlerId]].data[2] = battlerId;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], 0);
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gBattleControllerData[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT);
gBattleStruct->monToSwitchIntoId[gActiveBattler] = PARTY_SIZE;
BtlController_HandleSwitchInAnim(gActiveBattler, FALSE, SwitchIn_TryShinyAnim);
}
static void OpponentHandleReturnMonToBall(void)

View File

@ -115,7 +115,6 @@ static void Task_UpdateLvlInHealthbox(u8);
static void PrintLinkStandbyMsg(void);
static u32 CopyPlayerMonData(u8, u8 *);
static void SetPlayerMonData(u8);
static void StartSendOutAnim(u8, bool8);
static void DoSwitchOutAnimation(void);
static void PlayerDoMoveAnimation(void);
static void Task_StartSendOutAnim(u8);
@ -226,7 +225,7 @@ static void PlayerBufferRunCommand(void)
}
}
static void CompleteOnBankSpritePosX_0(void)
static void CompleteOnBattlerSpritePosX_0(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].x2 == 0)
PlayerBufferExecCompleted();
@ -1824,49 +1823,14 @@ static void PlayerHandleLoadMonSprite(void)
{
BattleLoadMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpritePosX_0;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpritePosX_0;
}
static void PlayerHandleSwitchInAnim(void)
{
ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleResources->bufferA[gActiveBattler][2]);
gBattlerPartyIndexes[gActiveBattler] = gBattleResources->bufferA[gActiveBattler][1];
BattleLoadMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
gActionSelectionCursor[gActiveBattler] = 0;
gMoveSelectionCursor[gActiveBattler] = 0;
StartSendOutAnim(gActiveBattler, gBattleResources->bufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_TryShinyAnimShowHealthbox;
}
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[battlerId] = CreateSprite(
&gMultiuseSpriteTemplate,
GetBattlerSpriteCoord(battlerId, BATTLER_COORD_X_2),
GetBattlerSpriteDefault_Y(battlerId),
GetBattlerSpriteSubpriority(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;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], 0);
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gBattleControllerData[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
BtlController_HandleSwitchInAnim(gActiveBattler, TRUE, SwitchIn_TryShinyAnimShowHealthbox);
}
static void PlayerHandleReturnMonToBall(void)

View File

@ -100,7 +100,6 @@ 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 StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void PlayerPartnerDoMoveAnimation(void);
static void Task_StartSendOutAnim(u8 taskId);
@ -638,42 +637,7 @@ static void PlayerPartnerHandleLoadMonSprite(void)
static void PlayerPartnerHandleSwitchInAnim(void)
{
ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleResources->bufferA[gActiveBattler][2]);
gBattlerPartyIndexes[gActiveBattler] = gBattleResources->bufferA[gActiveBattler][1];
BattleLoadMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
StartSendOutAnim(gActiveBattler, gBattleResources->bufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_TryShinyAnim;
}
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[battlerId] = CreateSprite(
&gMultiuseSpriteTemplate,
GetBattlerSpriteCoord(battlerId, BATTLER_COORD_X_2),
GetBattlerSpriteDefault_Y(battlerId),
GetBattlerSpriteSubpriority(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;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], 0);
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gBattleControllerData[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
BtlController_HandleSwitchInAnim(gActiveBattler, TRUE, SwitchIn_TryShinyAnim);
}
static void PlayerPartnerHandleReturnMonToBall(void)

View File

@ -96,7 +96,6 @@ static void RecordedOpponentBufferExecCompleted(void);
static void SwitchIn_HandleSoundAndEnd(void);
static u32 CopyRecordedOpponentMonData(u8 monId, u8 *dst);
static void SetRecordedOpponentMonData(u8 monId);
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void RecordedOpponentDoMoveAnimation(void);
static void Task_StartSendOutAnim(u8 taskId);
@ -545,40 +544,7 @@ static void RecordedOpponentHandleLoadMonSprite(void)
static void RecordedOpponentHandleSwitchInAnim(void)
{
gBattlerPartyIndexes[gActiveBattler] = gBattleResources->bufferA[gActiveBattler][1];
StartSendOutAnim(gActiveBattler, gBattleResources->bufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_TryShinyAnim;
}
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1];
species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
BattleLoadMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[battlerId] = CreateSprite(&gMultiuseSpriteTemplate,
GetBattlerSpriteCoord(battlerId, BATTLER_COORD_X_2),
GetBattlerSpriteDefault_Y(battlerId),
GetBattlerSpriteSubpriority(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;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], 0);
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gBattleControllerData[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT);
BtlController_HandleSwitchInAnim(gActiveBattler, FALSE, SwitchIn_TryShinyAnim);
}
static void RecordedOpponentHandleReturnMonToBall(void)

View File

@ -91,7 +91,6 @@ static void RecordedPlayerBufferExecCompleted(void);
static void SwitchIn_WaitAndEnd(void);
static u32 CopyRecordedPlayerMonData(u8 monId, u8 *dst);
static void SetRecordedPlayerMonData(u8 monId);
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void RecordedPlayerDoMoveAnimation(void);
static void Task_StartSendOutAnim(u8 taskId);
@ -526,42 +525,7 @@ static void RecordedPlayerHandleLoadMonSprite(void)
static void RecordedPlayerHandleSwitchInAnim(void)
{
ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleResources->bufferA[gActiveBattler][2]);
gBattlerPartyIndexes[gActiveBattler] = gBattleResources->bufferA[gActiveBattler][1];
BattleLoadMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
StartSendOutAnim(gActiveBattler, gBattleResources->bufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_TryShinyAnim;
}
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit);
gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[battlerId] = CreateSprite(
&gMultiuseSpriteTemplate,
GetBattlerSpriteCoord(battlerId, BATTLER_COORD_X_2),
GetBattlerSpriteDefault_Y(battlerId),
GetBattlerSpriteSubpriority(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;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], 0);
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gBattleControllerData[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
BtlController_HandleSwitchInAnim(gActiveBattler, TRUE, SwitchIn_TryShinyAnim);
}
static void RecordedPlayerHandleReturnMonToBall(void)

View File

@ -892,33 +892,6 @@ static void WallyHandleIntroTrainerBallThrow(void)
gBattlerControllerFuncs[gActiveBattler] = BattleControllerDummy;
}
static void StartSendOutAnim(u8 battlerId)
{
u16 species;
gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies = 0;
gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES);
gBattleControllerData[battlerId] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId));
gBattlerSpriteIds[battlerId] = CreateSprite(&gMultiuseSpriteTemplate,
GetBattlerSpriteCoord(battlerId, BATTLER_COORD_X_2),
GetBattlerSpriteDefault_Y(battlerId),
GetBattlerSpriteSubpriority(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;
gSprites[gBattlerSpriteIds[battlerId]].oam.paletteNum = battlerId;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], 0);
gSprites[gBattlerSpriteIds[battlerId]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battlerId]].callback = SpriteCallbackDummy;
gSprites[gBattleControllerData[battlerId]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
}
static void Task_StartSendOutAnim(u8 taskId)
{
if (gTasks[taskId].data[1] < 31)
@ -931,7 +904,7 @@ static void Task_StartSendOutAnim(u8 taskId)
gActiveBattler = gTasks[taskId].data[0];
gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
StartSendOutAnim(gActiveBattler);
StartSendOutAnim(gActiveBattler, FALSE);
gBattlerControllerFuncs[gActiveBattler] = Intro_TryShinyAnimShowHealthbox;
gActiveBattler = savedActiveBank;
DestroyTask(taskId);

View File

@ -863,7 +863,7 @@ void TryReceiveLinkBattleData(void)
static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId)
{
u16 blockSize;
u8 battlerId;
u8 battler;
u8 var;
if (gTasks[taskId].data[15] != gTasks[taskId].data[14])
@ -874,17 +874,17 @@ static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId)
gTasks[taskId].data[12] = 0;
gTasks[taskId].data[15] = 0;
}
battlerId = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_ACTIVE_BATTLER];
battler = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_ACTIVE_BATTLER];
blockSize = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_SIZE_LO] | (gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_SIZE_HI] << 8);
switch (gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 0])
{
case 0:
if (gBattleControllerExecFlags & gBitTable[battlerId])
if (gBattleControllerExecFlags & gBitTable[battler])
return;
memcpy(gBattleResources->bufferA[battlerId], &gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_DATA], blockSize);
MarkBattlerReceivedLinkData(battlerId);
memcpy(gBattleResources->bufferA[battler], &gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_DATA], blockSize);
MarkBattlerReceivedLinkData(battler);
if (!(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER))
{
@ -895,11 +895,11 @@ static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId)
}
break;
case 1:
memcpy(gBattleResources->bufferB[battlerId], &gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_DATA], blockSize);
memcpy(gBattleResources->bufferB[battler], &gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_DATA], blockSize);
break;
case 2:
var = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_DATA];
gBattleControllerExecFlags &= ~(gBitTable[battlerId] << (var * 4));
gBattleControllerExecFlags &= ~(gBitTable[battler] << (var * 4));
break;
}
@ -2075,6 +2075,39 @@ static void SetBattlerMonData(u32 battler, struct Pokemon *party, u32 monId)
HandleLowHpMusicChange(&party[gBattlerPartyIndexes[battler]], battler);
}
void StartSendOutAnim(u32 battler, bool32 dontClearSubstituteBit)
{
u16 species;
u32 side = GetBattlerSide(battler);
struct Pokemon *party = GetBattlerParty(battler);
ClearTemporarySpeciesSpriteData(battler, dontClearSubstituteBit);
gBattlerPartyIndexes[battler] = gBattleResources->bufferA[battler][1];
species = GetIllusionMonSpecies(battler);
if (species == SPECIES_NONE)
species = GetMonData(&party[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES);
gBattleControllerData[battler] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim);
// Load sprite for opponent only, player sprite is expected to be already loaded.
if (side == B_SIDE_OPPONENT)
BattleLoadMonSpriteGfx(&party[gBattlerPartyIndexes[battler]], battler);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battler));
gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate,
GetBattlerSpriteCoord(battler, BATTLER_COORD_X_2),
GetBattlerSpriteDefault_Y(battler),
GetBattlerSpriteSubpriority(battler));
gSprites[gBattlerSpriteIds[battler]].data[0] = battler;
gSprites[gBattlerSpriteIds[battler]].data[2] = species;
gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler;
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], 0);
gSprites[gBattlerSpriteIds[battler]].invisible = TRUE;
gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy;
gSprites[gBattleControllerData[battler]].data[1] = gBattlerSpriteIds[battler];
gSprites[gBattleControllerData[battler]].data[2] = battler;
gSprites[gBattleControllerData[battler]].data[0] = DoPokeballSendOutAnimation(0, (side == B_SIDE_OPPONENT) ? POKEBALL_OPPONENT_SENDOUT : POKEBALL_PLAYER_SENDOUT);
}
void BtlController_HandleGetMonData(u32 battler, struct Pokemon *party, void (*execCompleteFunc)(void))
{
@ -2151,7 +2184,7 @@ void BtlController_HandleLoadMonSprite(u32 battler, struct Pokemon *party, void
{
u16 species = GetMonData(&party[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES);
BattleLoadMonSpriteGfx(&party[gBattlerPartyIndexes[battler]], battler, GetBattlerSide(battler));
BattleLoadMonSpriteGfx(&party[gBattlerPartyIndexes[battler]], battler);
SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battler));
gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate,
@ -2169,3 +2202,14 @@ void BtlController_HandleLoadMonSprite(u32 battler, struct Pokemon *party, void
gBattlerControllerFuncs[battler] = controllerFunc;
}
void BtlController_HandleSwitchInAnim(u32 battler, bool32 isPlayerSide, void (*controllerFunc)(void))
{
if (isPlayerSide)
ClearTemporarySpeciesSpriteData(battler, gBattleResources->bufferA[battler][2]);
gBattlerPartyIndexes[battler] = gBattleResources->bufferA[battler][1];
if (isPlayerSide)
BattleLoadMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[battler]], battler);
StartSendOutAnim(battler, gBattleResources->bufferA[battler][2]);
gBattlerControllerFuncs[battler] = controllerFunc;
}