more controllers work

This commit is contained in:
DizzyEggg 2023-08-07 01:05:09 +02:00
parent ef8024d8c5
commit e8d6c99e6d
12 changed files with 88 additions and 236 deletions

View File

@ -267,6 +267,8 @@ void BtlController_HandleLoadMonSprite(u32 battler, struct Pokemon *party, void
void BtlController_HandleSwitchInAnim(u32 battler, bool32 isPlayerSide, void (*controllerCallback)(void)); void BtlController_HandleSwitchInAnim(u32 battler, bool32 isPlayerSide, void (*controllerCallback)(void));
void BtlController_HandleReturnMonToBall(void); void BtlController_HandleReturnMonToBall(void);
void BtlController_HandleDrawTrainerPic(u32 battlerId, u32 trainerPicId, bool32 isFrontPic, s16 xPos, s16 yPos, s32 subpriority); void BtlController_HandleDrawTrainerPic(u32 battlerId, u32 trainerPicId, bool32 isFrontPic, s16 xPos, s16 yPos, s32 subpriority);
void BtlController_HandleTrainerSlide(u32 battler, u32 trainerPicId);
void BtlController_HandleTrainerSlideBack(u32 battlerId, s16 data0, bool32 startAnim);
void BtlController_HandleFaintAnimation(void); void BtlController_HandleFaintAnimation(void);
void BtlController_HandleSuccessBallThrowAnim(u32 battler, u32 target, u32 animId, bool32 allowCriticalCapture); void BtlController_HandleSuccessBallThrowAnim(u32 battler, u32 target, u32 animId, bool32 allowCriticalCapture);
void BtlController_HandleBallThrowAnim(u32 battler, u32 target, u32 animId, bool32 allowCriticalCapture); void BtlController_HandleBallThrowAnim(u32 battler, u32 target, u32 animId, bool32 allowCriticalCapture);

View File

@ -14,7 +14,6 @@ void BattleLoadMonSpriteGfx(struct Pokemon *mon, u32 battlerId);
void BattleGfxSfxDummy2(u16 species); void BattleGfxSfxDummy2(u16 species);
void DecompressTrainerFrontPic(u16 frontPicId, u8 battlerId); void DecompressTrainerFrontPic(u16 frontPicId, u8 battlerId);
void DecompressTrainerBackPic(u16 backPicId, u8 battlerId); void DecompressTrainerBackPic(u16 backPicId, u8 battlerId);
void BattleGfxSfxDummy3(u8 gender);
void FreeTrainerFrontPicPalette(u16 frontPicId); void FreeTrainerFrontPicPalette(u16 frontPicId);
bool8 BattleLoadAllHealthBoxesGfx(u8 state); bool8 BattleLoadAllHealthBoxesGfx(u8 state);
void LoadBattleBarGfx(u8 unused); void LoadBattleBarGfx(u8 unused);

View File

@ -129,23 +129,6 @@ static void LinkOpponentBufferRunCommand(void)
} }
} }
static void CompleteOnBankSpriteCallbackDummy2(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
LinkOpponentBufferExecCompleted();
}
static void FreeTrainerSpriteAfterSlide(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
FreeTrainerFrontPicPalette(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam);
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
LinkOpponentBufferExecCompleted();
}
}
static void Intro_DelayAndEnd(void) static void Intro_DelayAndEnd(void)
{ {
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1) if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1)
@ -421,8 +404,6 @@ static void LinkOpponentHandleSwitchInAnim(void)
BtlController_HandleSwitchInAnim(gActiveBattler, FALSE, SwitchIn_TryShinyAnim); BtlController_HandleSwitchInAnim(gActiveBattler, FALSE, SwitchIn_TryShinyAnim);
} }
#define sSpeedX data[0]
static void LinkOpponentHandleDrawTrainerPic(void) static void LinkOpponentHandleDrawTrainerPic(void)
{ {
s16 xPos; s16 xPos;
@ -509,32 +490,13 @@ static void LinkOpponentHandleTrainerSlide(void)
else else
trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_B); trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_B);
DecompressTrainerFrontPic(trainerPicId, gActiveBattler); BtlController_HandleTrainerSlide(gActiveBattler, trainerPicId);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler)); LinkOpponentBufferExecCompleted(); // Possibly a bug, because execution should be completed after the slide in finishes. See Controller_WaitForTrainerPic.
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, 176, (8 - gTrainerFrontPicCoords[trainerPicId].size) * 4 + 40, 0x1E);
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = 96;
gSprites[gBattlerSpriteIds[gActiveBattler]].x += 32;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId;
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) static void LinkOpponentHandleTrainerSlideBack(void)
{ {
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); BtlController_HandleTrainerSlideBack(gActiveBattler, 35, FALSE);
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 280;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].y;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
gBattlerControllerFuncs[gActiveBattler] = FreeTrainerSpriteAfterSlide;
} }
static void LinkOpponentHandleMoveAnimation(void) static void LinkOpponentHandleMoveAnimation(void)

View File

@ -129,17 +129,6 @@ static void LinkPartnerBufferRunCommand(void)
} }
} }
static void FreeTrainerSpriteAfterSlide(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
BattleGfxSfxDummy3(MALE);
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
LinkPartnerBufferExecCompleted();
}
}
static void WaitForMonAnimAfterLoad(void) static void WaitForMonAnimAfterLoad(void)
{ {
if (gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded && gSprites[gBattlerSpriteIds[gActiveBattler]].x2 == 0) if (gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded && gSprites[gBattlerSpriteIds[gActiveBattler]].x2 == 0)
@ -247,8 +236,6 @@ static void LinkPartnerHandleSwitchInAnim(void)
BtlController_HandleSwitchInAnim(gActiveBattler, TRUE, SwitchIn_TryShinyAnim); BtlController_HandleSwitchInAnim(gActiveBattler, TRUE, SwitchIn_TryShinyAnim);
} }
#define sSpeedX data[0]
static void LinkPartnerHandleDrawTrainerPic(void) static void LinkPartnerHandleDrawTrainerPic(void)
{ {
s16 xPos; s16 xPos;
@ -272,17 +259,9 @@ static void LinkPartnerHandleDrawTrainerPic(void)
-1); -1);
} }
#undef sSpeedX
static void LinkPartnerHandleTrainerSlideBack(void) static void LinkPartnerHandleTrainerSlideBack(void)
{ {
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); BtlController_HandleTrainerSlideBack(gActiveBattler, 35, FALSE);
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].y;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
gBattlerControllerFuncs[gActiveBattler] = FreeTrainerSpriteAfterSlide;
} }
static void LinkPartnerHandleMoveAnimation(void) static void LinkPartnerHandleMoveAnimation(void)

View File

@ -145,23 +145,6 @@ static void OpponentBufferRunCommand(void)
} }
} }
static void CompleteOnBankSpriteCallbackDummy2(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
OpponentBufferExecCompleted();
}
static void FreeTrainerSpriteAfterSlide(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
FreeTrainerFrontPicPalette(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam);
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
OpponentBufferExecCompleted();
}
}
static void Intro_DelayAndEnd(void) static void Intro_DelayAndEnd(void)
{ {
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1) if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1)
@ -498,8 +481,6 @@ static u32 OpponentGetTrainerPicId(u32 battlerId)
return trainerPicId; return trainerPicId;
} }
#define sSpeedX data[0]
static void OpponentHandleDrawTrainerPic(void) static void OpponentHandleDrawTrainerPic(void)
{ {
s16 xPos; s16 xPos;
@ -525,32 +506,12 @@ static void OpponentHandleDrawTrainerPic(void)
static void OpponentHandleTrainerSlide(void) static void OpponentHandleTrainerSlide(void)
{ {
u32 trainerPicId = OpponentGetTrainerPicId(gActiveBattler); u32 trainerPicId = OpponentGetTrainerPicId(gActiveBattler);
BtlController_HandleTrainerSlide(gActiveBattler, trainerPicId);
DecompressTrainerFrontPic(trainerPicId, gActiveBattler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler));
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, 176, (8 - gTrainerFrontPicCoords[trainerPicId].size) * 4 + 40, 0x1E);
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = 96;
gSprites[gBattlerSpriteIds[gActiveBattler]].x += 32;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2;
} }
#undef sSpeedX
static void OpponentHandleTrainerSlideBack(void) static void OpponentHandleTrainerSlideBack(void)
{ {
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); BtlController_HandleTrainerSlideBack(gActiveBattler, 35, FALSE);
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 280;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].y;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
gBattlerControllerFuncs[gActiveBattler] = FreeTrainerSpriteAfterSlide;
} }
static void OpponentHandleMoveAnimation(void) static void OpponentHandleMoveAnimation(void)

View File

@ -1087,23 +1087,6 @@ void SetBattleEndCallbacks(void)
} }
} }
static void CompleteOnBankSpriteCallbackDummy2(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
PlayerBufferExecCompleted();
}
static void FreeTrainerSpriteAfterSlide(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
BattleGfxSfxDummy3(gSaveBlock2Ptr->playerGender);
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
PlayerBufferExecCompleted();
}
}
static void Intro_DelayAndEnd(void) static void Intro_DelayAndEnd(void)
{ {
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1) if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1)
@ -1691,8 +1674,6 @@ static void PlayerHandleSwitchInAnim(void)
BtlController_HandleSwitchInAnim(gActiveBattler, TRUE, SwitchIn_TryShinyAnimShowHealthbox); BtlController_HandleSwitchInAnim(gActiveBattler, TRUE, SwitchIn_TryShinyAnimShowHealthbox);
} }
#define sSpeedX data[0]
u32 LinkPlayerGetTrainerPicId(u32 multiplayerId) u32 LinkPlayerGetTrainerPicId(u32 multiplayerId)
{ {
u32 trainerPicId; u32 trainerPicId;
@ -1773,31 +1754,12 @@ static void PlayerHandleDrawTrainerPic(void)
static void PlayerHandleTrainerSlide(void) static void PlayerHandleTrainerSlide(void)
{ {
u32 trainerPicId = PlayerGetTrainerBackPicId(); u32 trainerPicId = PlayerGetTrainerBackPicId();
BtlController_HandleTrainerSlide(gActiveBattler, trainerPicId);
DecompressTrainerBackPic(trainerPicId, gActiveBattler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler));
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, 80, (8 - gTrainerBackPicCoords[trainerPicId].size) * 4 + 80, 30);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = -96;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2;
} }
#undef sSpeedX
static void PlayerHandleTrainerSlideBack(void) static void PlayerHandleTrainerSlideBack(void)
{ {
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); BtlController_HandleTrainerSlideBack(gActiveBattler, 50, TRUE);
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 50;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].y;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1);
gBattlerControllerFuncs[gActiveBattler] = FreeTrainerSpriteAfterSlide;
} }
static void PlayerHandlePaletteFade(void) static void PlayerHandlePaletteFade(void)

View File

@ -138,17 +138,6 @@ static void PlayerPartnerBufferRunCommand(void)
} }
} }
static void FreeTrainerSpriteAfterSlide(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
BattleGfxSfxDummy3(MALE);
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
PlayerPartnerBufferExecCompleted();
}
}
static void Intro_DelayAndEnd(void) static void Intro_DelayAndEnd(void)
{ {
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1) if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1)
@ -323,8 +312,6 @@ static void PlayerPartnerHandleSwitchInAnim(void)
BtlController_HandleSwitchInAnim(gActiveBattler, TRUE, SwitchIn_TryShinyAnim); BtlController_HandleSwitchInAnim(gActiveBattler, TRUE, SwitchIn_TryShinyAnim);
} }
#define sSpeedX data[0]
// some explanation here // some explanation here
// in emerald it's possible to have a tag battle in the battle frontier facilities with AI // in emerald it's possible to have a tag battle in the battle frontier facilities with AI
// which use the front sprite for both the player and the partner as opposed to any other battles (including the one with Steven) that use the back pic as well as animate it // which use the front sprite for both the player and the partner as opposed to any other battles (including the one with Steven) that use the back pic as well as animate it
@ -362,17 +349,9 @@ static void PlayerPartnerHandleDrawTrainerPic(void)
BtlController_HandleDrawTrainerPic(gActiveBattler, trainerPicId, isFrontPic, xPos, yPos, -1); BtlController_HandleDrawTrainerPic(gActiveBattler, trainerPicId, isFrontPic, xPos, yPos, -1);
} }
#undef sSpeedX
static void PlayerPartnerHandleTrainerSlideBack(void) static void PlayerPartnerHandleTrainerSlideBack(void)
{ {
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); BtlController_HandleTrainerSlideBack(gActiveBattler, 35, FALSE);
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].y;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
gBattlerControllerFuncs[gActiveBattler] = FreeTrainerSpriteAfterSlide;
} }
static void PlayerPartnerHandleMoveAnimation(void) static void PlayerPartnerHandleMoveAnimation(void)

View File

@ -143,17 +143,6 @@ static void CompleteOnBankSpriteCallbackDummy2(void)
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
} }
static void FreeTrainerSpriteAfterSlide(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
FreeTrainerFrontPicPalette(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam);
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
RecordedOpponentBufferExecCompleted();
}
}
static void Intro_DelayAndEnd(void) static void Intro_DelayAndEnd(void)
{ {
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1) if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1)
@ -416,8 +405,6 @@ static void RecordedOpponentHandleSwitchInAnim(void)
BtlController_HandleSwitchInAnim(gActiveBattler, FALSE, SwitchIn_TryShinyAnim); BtlController_HandleSwitchInAnim(gActiveBattler, FALSE, SwitchIn_TryShinyAnim);
} }
#define sSpeedX data[0]
static void RecordedOpponentHandleDrawTrainerPic(void) static void RecordedOpponentHandleDrawTrainerPic(void)
{ {
s16 xPos; s16 xPos;
@ -460,17 +447,9 @@ static void RecordedOpponentHandleDrawTrainerPic(void)
-1); -1);
} }
#undef sSpeedX
static void RecordedOpponentHandleTrainerSlideBack(void) static void RecordedOpponentHandleTrainerSlideBack(void)
{ {
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); BtlController_HandleTrainerSlideBack(gActiveBattler, 35, FALSE);
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 280;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].y;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
gBattlerControllerFuncs[gActiveBattler] = FreeTrainerSpriteAfterSlide;
} }
static void RecordedOpponentHandleMoveAnimation(void) static void RecordedOpponentHandleMoveAnimation(void)

View File

@ -134,17 +134,6 @@ static void RecordedPlayerBufferRunCommand(void)
} }
} }
static void FreeTrainerSpriteAfterSlide(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
BattleGfxSfxDummy3(MALE);
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
RecordedPlayerBufferExecCompleted();
}
}
static void Intro_DelayAndEnd(void) static void Intro_DelayAndEnd(void)
{ {
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1) if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1)
@ -449,13 +438,7 @@ static void RecordedPlayerHandleDrawTrainerPic(void)
static void RecordedPlayerHandleTrainerSlideBack(void) static void RecordedPlayerHandleTrainerSlideBack(void)
{ {
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); BtlController_HandleTrainerSlideBack(gActiveBattler, 35, FALSE);
gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40;
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].y;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
gBattlerControllerFuncs[gActiveBattler] = FreeTrainerSpriteAfterSlide;
} }
static void RecordedPlayerHandleMoveAnimation(void) static void RecordedPlayerHandleMoveAnimation(void)

View File

@ -329,17 +329,7 @@ static void WallyHandleDrawTrainerPic(void)
static void WallyHandleTrainerSlide(void) static void WallyHandleTrainerSlide(void)
{ {
DecompressTrainerBackPic(TRAINER_BACK_PIC_WALLY, gActiveBattler); BtlController_HandleTrainerSlide(gActiveBattler, TRAINER_BACK_PIC_WALLY);
SetMultiuseSpriteTemplateToTrainerBack(TRAINER_BACK_PIC_WALLY, GetBattlerPosition(gActiveBattler));
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate,
80,
80 + 4 * (8 - gTrainerBackPicCoords[TRAINER_BACK_PIC_WALLY].size),
30);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = -96;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
//gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2;
} }
#undef sSpeedX #undef sSpeedX

View File

@ -2185,6 +2185,18 @@ static void Controller_FaintOpponentMon(void)
} }
} }
static void Controller_HandleTrainerSlideBack(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT)
FreeTrainerFrontPicPalette(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam);
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
BattleControllerComplete(gActiveBattler);
}
}
static void Controller_WaitForBallThrow(void) static void Controller_WaitForBallThrow(void)
{ {
if (!gDoingBattleAnim || !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) if (!gDoingBattleAnim || !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
@ -2443,11 +2455,59 @@ void BtlController_HandleDrawTrainerPic(u32 battler, u32 trainerPicId, bool32 is
} }
gSprites[gBattlerSpriteIds[battler]].callback = SpriteCB_TrainerSlideIn; gSprites[gBattlerSpriteIds[battler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = Controller_WaitForTrainerPic; gBattlerControllerFuncs[battler] = Controller_WaitForTrainerPic;
}
void BtlController_HandleTrainerSlide(u32 battler, u32 trainerPicId)
{
if (GetBattlerSide(battler) == B_SIDE_PLAYER)
{
DecompressTrainerBackPic(trainerPicId, battler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(battler));
gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate,
80,
(8 - gTrainerBackPicCoords[trainerPicId].size) * 4 + 80,
30);
gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler;
gSprites[gBattlerSpriteIds[battler]].x2 = -96;
gSprites[gBattlerSpriteIds[battler]].sSpeedX = 2;
}
else
{
DecompressTrainerFrontPic(trainerPicId, battler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(battler));
gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate,
176,
(8 - gTrainerFrontPicCoords[trainerPicId].size) * 4 + 40,
30);
gSprites[gBattlerSpriteIds[battler]].oam.affineParam = trainerPicId;
gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBattlerSpriteIds[battler]].x2 = 96;
gSprites[gBattlerSpriteIds[battler]].x += 32;
gSprites[gBattlerSpriteIds[battler]].sSpeedX = -2;
}
gSprites[gBattlerSpriteIds[battler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[battler] = Controller_WaitForTrainerPic;
} }
#undef sSpeedX #undef sSpeedX
void BtlController_HandleTrainerSlideBack(u32 battlerId, s16 data0, bool32 startAnim)
{
u32 side = GetBattlerSide(battlerId);
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[battlerId]]);
gSprites[gBattlerSpriteIds[battlerId]].data[0] = data0;
gSprites[gBattlerSpriteIds[battlerId]].data[2] = (side == B_SIDE_PLAYER) ? -40 : 280;
gSprites[gBattlerSpriteIds[battlerId]].data[4] = gSprites[gBattlerSpriteIds[battlerId]].y;
gSprites[gBattlerSpriteIds[battlerId]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[battlerId]], SpriteCallbackDummy);
if (startAnim)
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], 1);
gBattlerControllerFuncs[battlerId] = Controller_HandleTrainerSlideBack;
}
#define sSpeedX data[1] #define sSpeedX data[1]
#define sSpeedY data[2] #define sSpeedY data[2]
@ -2653,16 +2713,16 @@ void BtlController_HandleSpriteInvisibility(void)
BattleControllerComplete(gActiveBattler); BattleControllerComplete(gActiveBattler);
} }
bool32 TwoPlayerIntroMons(u32 battlerId) // Double battle with both player pokemon active. bool32 TwoPlayerIntroMons(u32 battler) // Double battle with both player pokemon active.
{ {
return (IsDoubleBattle() && IsValidForBattle(&gPlayerParty[gBattlerPartyIndexes[battlerId ^ BIT_FLANK]])); return (IsDoubleBattle() && IsValidForBattle(&gPlayerParty[gBattlerPartyIndexes[battler ^ BIT_FLANK]]));
} }
bool32 TwoOpponentIntroMons(u32 battlerId) // Double battle with both opponent pokemon active. bool32 TwoOpponentIntroMons(u32 battler) // Double battle with both opponent pokemon active.
{ {
return (IsDoubleBattle() return (IsDoubleBattle()
&& IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[battlerId]]) && IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[battler]])
&& IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battlerId)]])); && IsValidForBattle(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(battler)]]));
} }
// Task data for Task_StartSendOutAnim // Task data for Task_StartSendOutAnim
@ -2722,20 +2782,20 @@ void BtlController_HandleIntroTrainerBallThrow(u32 battler, u16 tagTrainerPal, c
gBattlerControllerFuncs[battler] = BattleControllerDummy; gBattlerControllerFuncs[battler] = BattleControllerDummy;
} }
static bool32 TwoMonsAtSendOut(u32 battlerId) static bool32 TwoMonsAtSendOut(u32 battler)
{ {
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER) if (GetBattlerSide(battler) == B_SIDE_PLAYER)
{ {
if (TwoPlayerIntroMons(battlerId) && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (TwoPlayerIntroMons(battler) && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
} }
else else
{ {
if ((!TwoOpponentIntroMons(battlerId) || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) && !BATTLE_TWO_VS_ONE_OPPONENT) if ((!TwoOpponentIntroMons(battler) || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) && !BATTLE_TWO_VS_ONE_OPPONENT)
return FALSE; return FALSE;
else if ((gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) || (BATTLE_TWO_VS_ONE_OPPONENT && !TwoOpponentIntroMons(battlerId))) else if ((gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) || (BATTLE_TWO_VS_ONE_OPPONENT && !TwoOpponentIntroMons(battler)))
return FALSE; return FALSE;
else else
return TRUE; return TRUE;
@ -2784,7 +2844,7 @@ static void Task_StartSendOutAnim(u8 taskId)
static void SpriteCB_FreePlayerSpriteLoadMonSprite(struct Sprite *sprite) static void SpriteCB_FreePlayerSpriteLoadMonSprite(struct Sprite *sprite)
{ {
u8 battlerId = sprite->sBattlerId; u8 battler = sprite->sBattlerId;
// Free player trainer sprite // Free player trainer sprite
FreeSpriteOamMatrix(sprite); FreeSpriteOamMatrix(sprite);
@ -2792,8 +2852,8 @@ static void SpriteCB_FreePlayerSpriteLoadMonSprite(struct Sprite *sprite)
DestroySprite(sprite); DestroySprite(sprite);
// Load mon sprite // Load mon sprite
BattleLoadMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[battlerId]], battlerId); BattleLoadMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[battler]], battler);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerId]], 0); StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], 0);
} }
static void SpriteCB_FreeOpponentSprite(struct Sprite *sprite) static void SpriteCB_FreeOpponentSprite(struct Sprite *sprite)

View File

@ -632,10 +632,6 @@ void DecompressTrainerBackPic(u16 backPicId, u8 battlerId)
OBJ_PLTT_ID(battlerId), PLTT_SIZE_4BPP); OBJ_PLTT_ID(battlerId), PLTT_SIZE_4BPP);
} }
void BattleGfxSfxDummy3(u8 gender)
{
}
void FreeTrainerFrontPicPalette(u16 frontPicId) void FreeTrainerFrontPicPalette(u16 frontPicId)
{ {
FreeSpritePaletteByTag(gTrainerFrontPicPaletteTable[frontPicId].tag); FreeSpritePaletteByTag(gTrainerFrontPicPaletteTable[frontPicId].tag);