diff options
author | DizzyEggg <jajkodizzy@wp.pl> | 2017-10-26 23:12:48 +0200 |
---|---|---|
committer | DizzyEggg <jajkodizzy@wp.pl> | 2017-10-26 23:12:48 +0200 |
commit | 15061844651c0d0cdbe5ec0a3097b054d58e7f88 (patch) | |
tree | 6994733eb96e290e7790c5b5b17e776ee91e45d8 /src | |
parent | fa36e23683a27876156d74829c543f69fcd1f297 (diff) |
battle controller opponent is done
Diffstat (limited to 'src')
-rw-r--r-- | src/battle_ai_switch_items.c | 2 | ||||
-rw-r--r-- | src/battle_anim.c | 2 | ||||
-rw-r--r-- | src/battle_controller_link_opponent.c | 4 | ||||
-rw-r--r-- | src/battle_controller_link_partner.c | 4 | ||||
-rw-r--r-- | src/battle_controller_opponent.c | 686 | ||||
-rw-r--r-- | src/battle_controller_player.c | 4 | ||||
-rw-r--r-- | src/battle_controller_player_partner.c | 4 | ||||
-rw-r--r-- | src/battle_controller_recorded_opponent.c | 4 | ||||
-rw-r--r-- | src/battle_controller_recorded_player.c | 4 | ||||
-rw-r--r-- | src/battle_controller_safari.c | 2 | ||||
-rw-r--r-- | src/battle_controller_wally.c | 2 | ||||
-rw-r--r-- | src/battle_controllers.c | 128 |
12 files changed, 633 insertions, 213 deletions
diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index de440054c..a57df85fb 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -941,7 +941,7 @@ static bool8 ShouldUseItem(void) if (shouldUse) { EmitTwoReturnValues(1, ACTION_USE_ITEM, 0); - *(gBattleStruct->field_C0 + (gActiveBank / 2) * 2) = item; + *(gBattleStruct->chosenItem + (gActiveBank / 2) * 2) = item; gBattleResources->battleHistory->trainerItems[i] = 0; return shouldUse; } diff --git a/src/battle_anim.c b/src/battle_anim.c index d41dc77c4..fa3ac73be 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -660,7 +660,7 @@ bool8 IsAnimBankSpriteVisible(u8 bank) else return FALSE; } - if (!AnimBankSpriteExists(bank)) + if (!IsBankSpritePresent(bank)) return FALSE; if (IsContest()) return TRUE; // this line wont ever be reached. diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c index 95cb80146..6d5059787 100644 --- a/src/battle_controller_link_opponent.c +++ b/src/battle_controller_link_opponent.c @@ -199,7 +199,7 @@ static void nullsub_28(void) { } -void SetBankFuncToLinkOpponentBufferRunCommand(void) +void SetControllerToLinkOpponent(void) { gBattleBankFunc[gActiveBank] = LinkOpponentBufferRunCommand; } @@ -1846,7 +1846,7 @@ static void LinkOpponentHandleCmd50(void) static void LinkOpponentHandleSpriteInvisibility(void) { - if (AnimBankSpriteExists(gActiveBank)) + if (IsBankSpritePresent(gActiveBank)) { gSprites[gBankSpriteIds[gActiveBank]].invisible = gBattleBufferA[gActiveBank][1]; SetBattleSpriteInvisibilityBitToSpriteInvisibility(gActiveBank); diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c index 8ad497807..4fee08431 100644 --- a/src/battle_controller_link_partner.c +++ b/src/battle_controller_link_partner.c @@ -194,7 +194,7 @@ static void nullsub_112(void) { } -void SetBankFuncToLinkPartnerBufferRunCommand(void) +void SetControllerToLinkPartner(void) { gBattleBankFunc[gActiveBank] = LinkPartnerBufferRunCommand; } @@ -1678,7 +1678,7 @@ static void LinkPartnerHandleCmd50(void) static void LinkPartnerHandleSpriteInvisibility(void) { - if (AnimBankSpriteExists(gActiveBank)) + if (IsBankSpritePresent(gActiveBank)) { gSprites[gBankSpriteIds[gActiveBank]].invisible = gBattleBufferA[gActiveBank][1]; SetBattleSpriteInvisibilityBitToSpriteInvisibility(gActiveBank); diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 664d12142..fc19f9065 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -50,6 +50,9 @@ extern u16 gTrainerBattleOpponent_B; extern u32 gTransformedPersonalities[BATTLE_BANKS_COUNT]; extern u16 gBattle_BG0_X; extern u16 gBattle_BG0_Y; +extern u16 gUnknown_020243FC; +extern u8 gUnknown_020244B4[]; +extern void (*gPreBattleCallback1)(void); extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[]; extern const struct BattleMove gBattleMoves[]; @@ -57,76 +60,83 @@ extern const struct BattleMove gBattleMoves[]; extern void sub_8172EF0(u8 bank, struct Pokemon *mon); extern void sub_806A068(u16, u8); extern void sub_81A57E4(u8 bank, u16 stringId); +extern u8 sub_81A4CB0(void); +extern u8 sub_81D5588(u16 trainerId); +extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); +extern u8 GetEreaderTrainerFrontSpriteId(void); // this file's functions -void OpponentHandleGetMonData(void); -void OpponentHandleGetRawMonData(void); -void OpponentHandleSetMonData(void); -void OpponentHandleSetRawMonData(void); -void OpponentHandleLoadMonSprite(void); -void OpponentHandleSwitchInAnim(void); -void OpponentHandleReturnMonToBall(void); -void OpponentHandleDrawTrainerPic(void); -void OpponentHandleTrainerSlide(void); -void OpponentHandleTrainerSlideBack(void); -void OpponentHandleFaintAnimation(void); -void OpponentHandlePaletteFade(void); -void OpponentHandleSuccessBallThrowAnim(void); -void OpponentHandleBallThrow(void); -void OpponentHandlePause(void); -void OpponentHandleMoveAnimation(void); -void OpponentHandlePrintString(void); -void OpponentHandlePrintStringPlayerOnly(void); -void OpponentHandleChooseAction(void); -void OpponentHandleUnknownYesNoBox(void); -void OpponentHandleChooseMove(void); -void OpponentHandleOpenBag(void); -void OpponentHandleChoosePokemon(void); -void OpponentHandleCmd23(void); -void OpponentHandleHealthBarUpdate(void); -void OpponentHandleExpUpdate(void); -void OpponentHandleStatusIconUpdate(void); -void OpponentHandleStatusAnimation(void); -void OpponentHandleStatusXor(void); -void OpponentHandleDataTransfer(void); -void OpponentHandleDMA3Transfer(void); -void OpponentHandlePlayBGM(void); -void OpponentHandleCmd32(void); -void OpponentHandleCmd33(void); -void OpponentHandleCmd34(void); -void OpponentHandleCmd35(void); -void OpponentHandleCmd36(void); -void OpponentHandleCmd37(void); -void OpponentHandleCmd38(void); -void OpponentHandleCmd39(void); -void OpponentHandleCmd40(void); -void OpponentHandleHitAnimation(void); -void OpponentHandleCmd42(void); -void OpponentHandleEffectivenessSound(void); -void OpponentHandlePlayFanfareOrBGM(void); -void OpponentHandleFaintingCry(void); -void OpponentHandleIntroSlide(void); -void OpponentHandleIntroTrainerBallThrow(void); -void OpponentHandleDrawPartyStatusSummary(void); -void OpponentHandleCmd49(void); -void OpponentHandleCmd50(void); -void OpponentHandleSpriteInvisibility(void); -void OpponentHandleBattleAnimation(void); -void OpponentHandleLinkStandbyMsg(void); -void OpponentHandleResetActionMoveSelection(void); -void OpponentHandleCmd55(void); -void nullsub_91(void); - -void OpponentBufferRunCommand(void); -void OpponentBufferExecCompleted(void); -void bx_803AEDC(void); -u32 sub_8060004(u8 monId, u8 *dst); -void sub_8060890(u8 monId); -void sub_80613DC(u8 bank, bool8 dontClearSubstituteBit); -void DoSwitchOutAnimation(void); -void OpponentDoMoveAnimation(void); - -void (*const gOpponentBufferCommands[CONTOLLER_CMDS_COUNT])(void) = +static void OpponentHandleGetMonData(void); +static void OpponentHandleGetRawMonData(void); +static void OpponentHandleSetMonData(void); +static void OpponentHandleSetRawMonData(void); +static void OpponentHandleLoadMonSprite(void); +static void OpponentHandleSwitchInAnim(void); +static void OpponentHandleReturnMonToBall(void); +static void OpponentHandleDrawTrainerPic(void); +static void OpponentHandleTrainerSlide(void); +static void OpponentHandleTrainerSlideBack(void); +static void OpponentHandleFaintAnimation(void); +static void OpponentHandlePaletteFade(void); +static void OpponentHandleSuccessBallThrowAnim(void); +static void OpponentHandleBallThrow(void); +static void OpponentHandlePause(void); +static void OpponentHandleMoveAnimation(void); +static void OpponentHandlePrintString(void); +static void OpponentHandlePrintStringPlayerOnly(void); +static void OpponentHandleChooseAction(void); +static void OpponentHandleUnknownYesNoBox(void); +static void OpponentHandleChooseMove(void); +static void OpponentHandleChooseItem(void); +static void OpponentHandleChoosePokemon(void); +static void OpponentHandleCmd23(void); +static void OpponentHandleHealthBarUpdate(void); +static void OpponentHandleExpUpdate(void); +static void OpponentHandleStatusIconUpdate(void); +static void OpponentHandleStatusAnimation(void); +static void OpponentHandleStatusXor(void); +static void OpponentHandleDataTransfer(void); +static void OpponentHandleDMA3Transfer(void); +static void OpponentHandlePlayBGM(void); +static void OpponentHandleCmd32(void); +static void OpponentHandleTwoReturnValues(void); +static void OpponentHandleChosenMonReturnValue(void); +static void OpponentHandleOneReturnValue(void); +static void OpponentHandleOneReturnValue_Duplicate(void); +static void OpponentHandleCmd37(void); +static void OpponentHandleCmd38(void); +static void OpponentHandleCmd39(void); +static void OpponentHandleCmd40(void); +static void OpponentHandleHitAnimation(void); +static void OpponentHandleCmd42(void); +static void OpponentHandleEffectivenessSound(void); +static void OpponentHandlePlayFanfareOrBGM(void); +static void OpponentHandleFaintingCry(void); +static void OpponentHandleIntroSlide(void); +static void OpponentHandleIntroTrainerBallThrow(void); +static void OpponentHandleDrawPartyStatusSummary(void); +static void OpponentHandleCmd49(void); +static void OpponentHandleCmd50(void); +static void OpponentHandleSpriteInvisibility(void); +static void OpponentHandleBattleAnimation(void); +static void OpponentHandleLinkStandbyMsg(void); +static void OpponentHandleResetActionMoveSelection(void); +static void OpponentHandleCmd55(void); +static void nullsub_91(void); + +static void OpponentBufferRunCommand(void); +static void OpponentBufferExecCompleted(void); +static void sub_805FC80(void); +static u32 GetOpponentMonData(u8 monId, u8 *dst); +static void SetOpponentMonData(u8 monId); +static void sub_80613DC(u8 bank, 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 (*const sOpponentBufferCommands[CONTOLLER_CMDS_COUNT])(void) = { OpponentHandleGetMonData, OpponentHandleGetRawMonData, @@ -149,7 +159,7 @@ void (*const gOpponentBufferCommands[CONTOLLER_CMDS_COUNT])(void) = OpponentHandleChooseAction, OpponentHandleUnknownYesNoBox, OpponentHandleChooseMove, - OpponentHandleOpenBag, + OpponentHandleChooseItem, OpponentHandleChoosePokemon, OpponentHandleCmd23, OpponentHandleHealthBarUpdate, @@ -161,10 +171,10 @@ void (*const gOpponentBufferCommands[CONTOLLER_CMDS_COUNT])(void) = OpponentHandleDMA3Transfer, OpponentHandlePlayBGM, OpponentHandleCmd32, - OpponentHandleCmd33, - OpponentHandleCmd34, - OpponentHandleCmd35, - OpponentHandleCmd36, + OpponentHandleTwoReturnValues, + OpponentHandleChosenMonReturnValue, + OpponentHandleOneReturnValue, + OpponentHandleOneReturnValue_Duplicate, OpponentHandleCmd37, OpponentHandleCmd38, OpponentHandleCmd39, @@ -190,39 +200,39 @@ void (*const gOpponentBufferCommands[CONTOLLER_CMDS_COUNT])(void) = // unknown unused data static const u8 sUnknown_0831C7AC[] = {0xB0, 0xB0, 0xC8, 0x98, 0x28, 0x28, 0x28, 0x20}; -void nullsub_26(void) +static void nullsub_26(void) { } -void SetBankFuncToOpponentBufferRunCommand(void) +void SetControllerToOpponent(void) { gBattleBankFunc[gActiveBank] = OpponentBufferRunCommand; } -void OpponentBufferRunCommand(void) +static void OpponentBufferRunCommand(void) { if (gBattleExecBuffer & gBitTable[gActiveBank]) { - if (gBattleBufferA[gActiveBank][0] < ARRAY_COUNT(gOpponentBufferCommands)) - gOpponentBufferCommands[gBattleBufferA[gActiveBank][0]](); + if (gBattleBufferA[gActiveBank][0] < ARRAY_COUNT(sOpponentBufferCommands)) + sOpponentBufferCommands[gBattleBufferA[gActiveBank][0]](); else OpponentBufferExecCompleted(); } } -void CompleteOnBankSpriteCallbackDummy(void) +static void CompleteOnBankSpriteCallbackDummy(void) { if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) OpponentBufferExecCompleted(); } -void CompleteOnBankSpriteCallbackDummy2(void) +static void CompleteOnBankSpriteCallbackDummy2(void) { if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) OpponentBufferExecCompleted(); } -void sub_805F240(void) +static void sub_805F240(void) { if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) { @@ -233,7 +243,7 @@ void sub_805F240(void) } } -void sub_805F2A8(void) +static void sub_805F2A8(void) { if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 == 0xFF) { @@ -242,7 +252,7 @@ void sub_805F2A8(void) } } -void sub_805F2F0(void) +static void sub_805F2F0(void) { bool8 var = FALSE; bool8 var2; @@ -303,7 +313,7 @@ void sub_805F2F0(void) } } -void sub_805F560(void) +static void sub_805F560(void) { bool32 sp = FALSE; bool32 r10 = FALSE; @@ -385,7 +395,7 @@ void sub_805F560(void) } } -void sub_805F994(void) +static void sub_805F994(void) { if (gSprites[gBankSpriteIds[gActiveBank]].pos2.x == 0 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1) sub_8172EF0(gActiveBank, &gEnemyParty[gBattlePartyID[gActiveBank]]); @@ -400,7 +410,7 @@ void sub_805F994(void) } } -void sub_805FA70(void) +static void CompleteOnHealthbarDone(void) { s16 hpValue = sub_8074AA0(gActiveBank, gHealthBoxesIds[gActiveBank], 0, 0); SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); @@ -412,7 +422,7 @@ void sub_805FA70(void) OpponentBufferExecCompleted(); } -void sub_805FAC4(void) +static void sub_805FAC4(void) { if (!gSprites[gBankSpriteIds[gActiveBank]].inUse) { @@ -421,7 +431,7 @@ void sub_805FAC4(void) } } -void sub_805FB08(void) +static void sub_805FB08(void) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) { @@ -433,13 +443,13 @@ void sub_805FB08(void) } } -void CompleteOnInactiveTextPrinter(void) +static void CompleteOnInactiveTextPrinter(void) { if (!IsTextPrinterActive(0)) OpponentBufferExecCompleted(); } -void bx_blink_t7(void) +static void DoHitAnimBlinkSpriteEffect(void) { u8 spriteId = gBankSpriteIds[gActiveBank]; @@ -458,17 +468,17 @@ void bx_blink_t7(void) } } -void sub_805FC10(void) +static void sub_805FC10(void) { if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy) { if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) DoSpecialBattleAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); - gBattleBankFunc[gActiveBank] = bx_803AEDC; + gBattleBankFunc[gActiveBank] = sub_805FC80; } } -void bx_803AEDC(void) +static void sub_805FC80(void) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive && !IsCryPlayingOrClearCrySongs()) { @@ -480,7 +490,7 @@ void bx_803AEDC(void) } } -void sub_805FD00(void) +static void sub_805FD00(void) { if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 && gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) { @@ -497,7 +507,7 @@ void sub_805FD00(void) } } -void sub_805FDF0(void) +static void sub_805FDF0(void) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x8) sub_8172EF0(gActiveBank, &gEnemyParty[gBattlePartyID[gActiveBank]]); @@ -511,19 +521,19 @@ void sub_805FDF0(void) } } -void sub_805FEB8(void) +static void CompleteOnFinishedStatusAnimation(void) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive) OpponentBufferExecCompleted(); } -void bx_803B0F4(void) +static void CompleteOnFinishedBattleAnimation(void) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animFromTableActive) OpponentBufferExecCompleted(); } -void OpponentBufferExecCompleted(void) +static void OpponentBufferExecCompleted(void) { gBattleBankFunc[gActiveBank] = OpponentBufferRunCommand; if (gBattleTypeFlags & BATTLE_TYPE_LINK) @@ -539,7 +549,7 @@ void OpponentBufferExecCompleted(void) } } -void OpponentHandleGetMonData(void) +static void OpponentHandleGetMonData(void) { u8 monData[sizeof(struct Pokemon) * 2 + 56]; // this allows to get full data of two pokemon, trying to get more will result in overwriting data u32 size = 0; @@ -548,7 +558,7 @@ void OpponentHandleGetMonData(void) if (gBattleBufferA[gActiveBank][2] == 0) { - size += sub_8060004(gBattlePartyID[gActiveBank], monData); + size += GetOpponentMonData(gBattlePartyID[gActiveBank], monData); } else { @@ -556,7 +566,7 @@ void OpponentHandleGetMonData(void) for (i = 0; i < 6; i++) { if (monsToCheck & 1) - size += sub_8060004(i, monData + size); + size += GetOpponentMonData(i, monData + size); monsToCheck >>= 1; } } @@ -564,7 +574,7 @@ void OpponentHandleGetMonData(void) OpponentBufferExecCompleted(); } -u32 sub_8060004(u8 monId, u8 *dst) +static u32 GetOpponentMonData(u8 monId, u8 *dst) { struct BattlePokemon battleMon; struct MovePpInfo moveData; @@ -870,7 +880,7 @@ u32 sub_8060004(u8 monId, u8 *dst) return size; } -void OpponentHandleGetRawMonData(void) +static void OpponentHandleGetRawMonData(void) { struct BattlePokemon battleMon; u8 *src = (u8 *)&gEnemyParty[gBattlePartyID[gActiveBank]] + gBattleBufferA[gActiveBank][1]; @@ -884,14 +894,14 @@ void OpponentHandleGetRawMonData(void) OpponentBufferExecCompleted(); } -void OpponentHandleSetMonData(void) +static void OpponentHandleSetMonData(void) { u8 monsToCheck; u8 i; if (gBattleBufferA[gActiveBank][2] == 0) { - sub_8060890(gBattlePartyID[gActiveBank]); + SetOpponentMonData(gBattlePartyID[gActiveBank]); } else { @@ -899,14 +909,14 @@ void OpponentHandleSetMonData(void) for (i = 0; i < 6; i++) { if (monsToCheck & 1) - sub_8060890(i); + SetOpponentMonData(i); monsToCheck >>= 1; } } OpponentBufferExecCompleted(); } -void sub_8060890(u8 monId) +static void SetOpponentMonData(u8 monId) { struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBank][3]; struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBank][3]; @@ -1122,7 +1132,7 @@ void sub_8060890(u8 monId) } } -void OpponentHandleSetRawMonData(void) +static void OpponentHandleSetRawMonData(void) { u8 *dst = (u8 *)&gEnemyParty[gBattlePartyID[gActiveBank]] + gBattleBufferA[gActiveBank][1]; u8 i; @@ -1133,7 +1143,7 @@ void OpponentHandleSetRawMonData(void) OpponentBufferExecCompleted(); } -void OpponentHandleLoadMonSprite(void) +static void OpponentHandleLoadMonSprite(void) { u16 species = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES); @@ -1156,7 +1166,7 @@ void OpponentHandleLoadMonSprite(void) gBattleBankFunc[gActiveBank] = sub_805F994; } -void OpponentHandleSwitchInAnim(void) +static void OpponentHandleSwitchInAnim(void) { *(gBattleStruct->field_5C + gActiveBank) = 6; gBattlePartyID[gActiveBank] = gBattleBufferA[gActiveBank][1]; @@ -1164,7 +1174,7 @@ void OpponentHandleSwitchInAnim(void) gBattleBankFunc[gActiveBank] = sub_805FDF0; } -void sub_80613DC(u8 bank, bool8 dontClearSubstituteBit) +static void sub_80613DC(u8 bank, bool8 dontClearSubstituteBit) { u16 species; @@ -1196,7 +1206,7 @@ void sub_80613DC(u8 bank, bool8 dontClearSubstituteBit) gSprites[gUnknown_03005D7C[bank]].data0 = sub_80753E8(0, 0xFE); } -void OpponentHandleReturnMonToBall(void) +static void OpponentHandleReturnMonToBall(void) { if (gBattleBufferA[gActiveBank][1] == 0) { @@ -1213,7 +1223,7 @@ void OpponentHandleReturnMonToBall(void) } } -void DoSwitchOutAnimation(void) +static void DoSwitchOutAnimation(void) { switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState) { @@ -1234,11 +1244,6 @@ void DoSwitchOutAnimation(void) } } -u8 sub_81A4CB0(void); -u8 sub_81D5588(u16 trainerId); -u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); -u8 GetEreaderTrainerFrontSpriteId(void); - // todo: get rid of it once the struct is declared in a header struct MonCoords { @@ -1249,7 +1254,7 @@ struct MonCoords }; extern const struct MonCoords gTrainerFrontPicCoords[]; -void OpponentHandleDrawTrainerPic(void) +static void OpponentHandleDrawTrainerPic(void) { u32 trainerPicId; s16 xPos; @@ -1334,7 +1339,7 @@ void OpponentHandleDrawTrainerPic(void) gBattleBankFunc[gActiveBank] = CompleteOnBankSpriteCallbackDummy; } -void OpponentHandleTrainerSlide(void) +static void OpponentHandleTrainerSlide(void) { u32 trainerPicId; @@ -1404,7 +1409,7 @@ void OpponentHandleTrainerSlide(void) gBattleBankFunc[gActiveBank] = CompleteOnBankSpriteCallbackDummy2; } -void OpponentHandleTrainerSlideBack(void) +static void OpponentHandleTrainerSlideBack(void) { oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBank]]); gSprites[gBankSpriteIds[gActiveBank]].data0 = 35; @@ -1415,7 +1420,7 @@ void OpponentHandleTrainerSlideBack(void) gBattleBankFunc[gActiveBank] = sub_805F240; } -void OpponentHandleFaintAnimation(void) +static void OpponentHandleFaintAnimation(void) { if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0) { @@ -1435,27 +1440,27 @@ void OpponentHandleFaintAnimation(void) } } -void OpponentHandlePaletteFade(void) +static void OpponentHandlePaletteFade(void) { OpponentBufferExecCompleted(); } -void OpponentHandleSuccessBallThrowAnim(void) +static void OpponentHandleSuccessBallThrowAnim(void) { OpponentBufferExecCompleted(); } -void OpponentHandleBallThrow(void) +static void OpponentHandleBallThrow(void) { OpponentBufferExecCompleted(); } -void OpponentHandlePause(void) +static void OpponentHandlePause(void) { OpponentBufferExecCompleted(); } -void OpponentHandleMoveAnimation(void) +static void OpponentHandleMoveAnimation(void) { if (!mplay_80342A4(gActiveBank)) { @@ -1480,7 +1485,7 @@ void OpponentHandleMoveAnimation(void) } } -void OpponentDoMoveAnimation(void) +static void OpponentDoMoveAnimation(void) { u16 move = gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8); u8 multihit = gBattleBufferA[gActiveBank][11]; @@ -1529,7 +1534,7 @@ void OpponentDoMoveAnimation(void) } } -void OpponentHandlePrintString(void) +static void OpponentHandlePrintString(void) { u16 *stringId; @@ -1542,23 +1547,23 @@ void OpponentHandlePrintString(void) sub_81A57E4(gActiveBank, *stringId); } -void OpponentHandlePrintStringPlayerOnly(void) +static void OpponentHandlePrintStringPlayerOnly(void) { OpponentBufferExecCompleted(); } -void OpponentHandleChooseAction(void) +static void OpponentHandleChooseAction(void) { AI_TrySwitchOrUseItem(); OpponentBufferExecCompleted(); } -void OpponentHandleUnknownYesNoBox(void) +static void OpponentHandleUnknownYesNoBox(void) { OpponentBufferExecCompleted(); } -void OpponentHandleChooseMove(void) +static void OpponentHandleChooseMove(void) { if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { @@ -1621,3 +1626,418 @@ void OpponentHandleChooseMove(void) } } } + +static void OpponentHandleChooseItem(void) +{ + EmitOneReturnValue(1, *(gBattleStruct->chosenItem + (gActiveBank / 2) * 2)); + OpponentBufferExecCompleted(); +} + +static void OpponentHandleChoosePokemon(void) +{ + s32 chosenMonId; + + if (*(gBattleStruct->field_294 + gActiveBank) == 6) + { + chosenMonId = GetMostSuitableMonToSwitchInto(); + + if (chosenMonId == 6) + { + s32 bank1, bank2, firstId, lastId; + + if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) + { + bank2 = bank1 = GetBankByIdentity(IDENTITY_OPPONENT_MON1); + } + else + { + bank1 = GetBankByIdentity(IDENTITY_OPPONENT_MON1); + bank2 = GetBankByIdentity(IDENTITY_OPPONENT_MON2); + } + + if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) + { + if (gActiveBank == 1) + firstId = 0, lastId = 3; + else + firstId = 3, lastId = 6; + } + else + { + firstId = 0, lastId = 6; + } + + for (chosenMonId = firstId; chosenMonId < lastId; chosenMonId++) + { + if (GetMonData(&gEnemyParty[chosenMonId], MON_DATA_HP) != 0 + && chosenMonId != gBattlePartyID[bank1] + && chosenMonId != gBattlePartyID[bank2]) + { + break; + } + } + } + } + else + { + chosenMonId = *(gBattleStruct->field_294 + gActiveBank); + *(gBattleStruct->field_294 + gActiveBank) = 6; + } + + + *(gBattleStruct->field_5C + gActiveBank) = chosenMonId; + EmitChosenMonReturnValue(1, chosenMonId, NULL); + OpponentBufferExecCompleted(); +} + +static void OpponentHandleCmd23(void) +{ + OpponentBufferExecCompleted(); +} + +static void OpponentHandleHealthBarUpdate(void) +{ + s16 hpVal; + + LoadBattleBarGfx(0); + hpVal = (gBattleBufferA[gActiveBank][3] << 8) | gBattleBufferA[gActiveBank][2]; + + if (hpVal != INSTANT_HP_BAR_DROP) + { + u32 maxHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); + u32 curHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_HP); + + SetBattleBarStruct(gActiveBank, gHealthBoxesIds[gActiveBank], maxHP, curHP, hpVal); + } + else + { + u32 maxHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); + + SetBattleBarStruct(gActiveBank, gHealthBoxesIds[gActiveBank], maxHP, 0, hpVal); + } + + gBattleBankFunc[gActiveBank] = CompleteOnHealthbarDone; +} + +static void OpponentHandleExpUpdate(void) +{ + OpponentBufferExecCompleted(); +} + +static void OpponentHandleStatusIconUpdate(void) +{ + if (!mplay_80342A4(gActiveBank)) + { + u8 bank; + + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gEnemyParty[gBattlePartyID[gActiveBank]], HEALTHBOX_STATUS_ICON); + bank = gActiveBank; + gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0; + gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; + } +} + +static void OpponentHandleStatusAnimation(void) +{ + if (!mplay_80342A4(gActiveBank)) + { + DoStatusAnimation(gBattleBufferA[gActiveBank][1], + gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24)); + gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; + } +} + +static void OpponentHandleStatusXor(void) +{ + OpponentBufferExecCompleted(); +} + +static void OpponentHandleDataTransfer(void) +{ + OpponentBufferExecCompleted(); +} + +static void OpponentHandleDMA3Transfer(void) +{ + OpponentBufferExecCompleted(); +} + +static void OpponentHandlePlayBGM(void) +{ + OpponentBufferExecCompleted(); +} + +static void OpponentHandleCmd32(void) +{ + OpponentBufferExecCompleted(); +} + +static void OpponentHandleTwoReturnValues(void) +{ + OpponentBufferExecCompleted(); +} + +static void OpponentHandleChosenMonReturnValue(void) +{ + OpponentBufferExecCompleted(); +} + +static void OpponentHandleOneReturnValue(void) +{ + OpponentBufferExecCompleted(); +} + +static void OpponentHandleOneReturnValue_Duplicate(void) +{ + OpponentBufferExecCompleted(); +} + +static void OpponentHandleCmd37(void) +{ + gUnknown_02022D0C.field_0 = 0; + OpponentBufferExecCompleted(); +} + +static void OpponentHandleCmd38(void) +{ + gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBank][1]; + OpponentBufferExecCompleted(); +} + +static void OpponentHandleCmd39(void) +{ + gUnknown_02022D0C.flag_x80 = 0; + OpponentBufferExecCompleted(); +} + +static void OpponentHandleCmd40(void) +{ + gUnknown_02022D0C.flag_x80 ^= 1; + OpponentBufferExecCompleted(); +} + +static void OpponentHandleHitAnimation(void) +{ + if (gSprites[gBankSpriteIds[gActiveBank]].invisible == TRUE) + { + OpponentBufferExecCompleted(); + } + else + { + gDoingBattleAnim = TRUE; + gSprites[gBankSpriteIds[gActiveBank]].data1 = 0; + DoHitAnimHealthboxEffect(gActiveBank); + gBattleBankFunc[gActiveBank] = DoHitAnimBlinkSpriteEffect; + } +} + +static void OpponentHandleCmd42(void) +{ + OpponentBufferExecCompleted(); +} + +static void OpponentHandleEffectivenessSound(void) +{ + s8 pan; + + if (GetBankSide(gActiveBank) == SIDE_PLAYER) + pan = PAN_SIDE_PLAYER; + else + pan = PAN_SIDE_OPPONENT; + + PlaySE12WithPanning(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8), pan); + OpponentBufferExecCompleted(); +} + +static void OpponentHandlePlayFanfareOrBGM(void) +{ + if (gBattleBufferA[gActiveBank][3]) + { + BattleMusicStop(); + PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + } + else + { + PlayFanfare(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + } + + OpponentBufferExecCompleted(); +} + +static void OpponentHandleFaintingCry(void) +{ + u16 species = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES); + + PlayCry3(species, 25, 5); + OpponentBufferExecCompleted(); +} + +static void OpponentHandleIntroSlide(void) +{ + HandleIntroSlide(gBattleBufferA[gActiveBank][1]); + gUnknown_020243FC |= 1; + OpponentBufferExecCompleted(); +} + +static void OpponentHandleIntroTrainerBallThrow(void) +{ + u8 paletteNum; + u8 taskId; + + oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBank]]); + + gSprites[gBankSpriteIds[gActiveBank]].data0 = 35; + gSprites[gBankSpriteIds[gActiveBank]].data2 = 280; + gSprites[gBankSpriteIds[gActiveBank]].data4 = gSprites[gBankSpriteIds[gActiveBank]].pos1.y; + gSprites[gBankSpriteIds[gActiveBank]].callback = sub_80A6EEC; + + StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBank]], sub_806280C); + + taskId = CreateTask(sub_8062828, 5); + gTasks[taskId].data[0] = gActiveBank; + + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1) + gTasks[gUnknown_020244B4[gActiveBank]].func = sub_8073C30; + + gBattleSpritesDataPtr->animationData->field_9_x1 = 1; + gBattleBankFunc[gActiveBank] = nullsub_26; +} + +static void sub_806280C(struct Sprite *sprite) +{ + FreeTrainerFrontPicPalette(sprite->oam.affineParam); + FreeSpriteOamMatrix(sprite); + DestroySprite(sprite); +} + +static void sub_8062828(u8 taskId) +{ + u8 savedActiveBank = gActiveBank; + + gActiveBank = gTasks[taskId].data[0]; + if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) + { + gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; + sub_80613DC(gActiveBank, FALSE); + } + else if ((gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)) + { + gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; + sub_80613DC(gActiveBank, FALSE); + } + else + { + gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; + sub_80613DC(gActiveBank, FALSE); + gActiveBank ^= BIT_MON; + gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; + sub_80613DC(gActiveBank, FALSE); + gActiveBank ^= BIT_MON; + } + gBattleBankFunc[gActiveBank] = sub_805F560; + gActiveBank = savedActiveBank; + DestroyTask(taskId); +} + +static void OpponentHandleDrawPartyStatusSummary(void) +{ + if (gBattleBufferA[gActiveBank][1] != 0 && GetBankSide(gActiveBank) == SIDE_PLAYER) + { + OpponentBufferExecCompleted(); + } + else + { + gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1 = 1; + + if (gBattleBufferA[gActiveBank][2] != 0) + { + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1E < 2) + { + gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1E++; + return; + } + else + { + gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1E = 0; + } + } + + gUnknown_020244B4[gActiveBank] = CreatePartyStatusSummarySprites(gActiveBank, (struct HpAndStatus *)&gBattleBufferA[gActiveBank][4], gBattleBufferA[gActiveBank][1], gBattleBufferA[gActiveBank][2]); + gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0; + + if (gBattleBufferA[gActiveBank][2] != 0) + gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0x5D; + + gBattleBankFunc[gActiveBank] = sub_8062A2C; + } +} + +static void sub_8062A2C(void) +{ + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5++ > 0x5C) + { + gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0; + OpponentBufferExecCompleted(); + } +} + +static void OpponentHandleCmd49(void) +{ + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1) + gTasks[gUnknown_020244B4[gActiveBank]].func = sub_8073C30; + OpponentBufferExecCompleted(); +} + +static void OpponentHandleCmd50(void) +{ + OpponentBufferExecCompleted(); +} + +static void OpponentHandleSpriteInvisibility(void) +{ + if (IsBankSpritePresent(gActiveBank)) + { + gSprites[gBankSpriteIds[gActiveBank]].invisible = gBattleBufferA[gActiveBank][1]; + SetBattleSpriteInvisibilityBitToSpriteInvisibility(gActiveBank); + } + OpponentBufferExecCompleted(); +} + +static void OpponentHandleBattleAnimation(void) +{ + if (!mplay_80342A4(gActiveBank)) + { + u8 animationId = gBattleBufferA[gActiveBank][1]; + u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + + if (DoBattleAnimationFromTable(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) + OpponentBufferExecCompleted(); + else + gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; + } +} + +static void OpponentHandleLinkStandbyMsg(void) +{ + OpponentBufferExecCompleted(); +} + +static void OpponentHandleResetActionMoveSelection(void) +{ + OpponentBufferExecCompleted(); +} + +static void OpponentHandleCmd55(void) +{ + if (gBattleTypeFlags & BATTLE_TYPE_LINK && !(gBattleTypeFlags & BATTLE_TYPE_WILD)) + { + gMain.inBattle = 0; + gMain.callback1 = gPreBattleCallback1; + SetMainCallback2(gMain.savedCallback); + } + OpponentBufferExecCompleted(); +} + +static void nullsub_91(void) +{ +} diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 68e328acc..a07aacd20 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -239,7 +239,7 @@ void nullsub_21(void) { } -void SetBankFuncToPlayerBufferRunCommand(void) +void SetControllerToPlayer(void) { gBattleBankFunc[gActiveBank] = PlayerBufferRunCommand; gDoingBattleAnim = FALSE; @@ -3083,7 +3083,7 @@ static void PlayerHandleCmd50(void) static void PlayerHandleSpriteInvisibility(void) { - if (AnimBankSpriteExists(gActiveBank)) + if (IsBankSpritePresent(gActiveBank)) { gSprites[gBankSpriteIds[gActiveBank]].invisible = gBattleBufferA[gActiveBank][1]; SetBattleSpriteInvisibilityBitToSpriteInvisibility(gActiveBank); diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c index 283c79e66..cc659972e 100644 --- a/src/battle_controller_player_partner.c +++ b/src/battle_controller_player_partner.c @@ -209,7 +209,7 @@ static void nullsub_77(void) { } -void SetBankFuncToPlayerPartnerBufferRunCommand(void) +void SetControllerToPlayerPartner(void) { gBattleBankFunc[gActiveBank] = PlayerPartnerBufferRunCommand; } @@ -1924,7 +1924,7 @@ static void PlayerPartnerHandleCmd50(void) static void PlayerPartnerHandleSpriteInvisibility(void) { - if (AnimBankSpriteExists(gActiveBank)) + if (IsBankSpritePresent(gActiveBank)) { gSprites[gBankSpriteIds[gActiveBank]].invisible = gBattleBufferA[gActiveBank][1]; SetBattleSpriteInvisibilityBitToSpriteInvisibility(gActiveBank); diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index 8f30febe2..9043f84e6 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -198,7 +198,7 @@ static void nullsub_70(void) { } -void SetBankFuncToRecordedOpponentBufferRunCommand(void) +void SetControllerToRecordedOpponent(void) { gBattleBankFunc[gActiveBank] = RecordedOpponentBufferRunCommand; } @@ -1788,7 +1788,7 @@ static void RecordedOpponentHandleCmd50(void) static void RecordedOpponentHandleSpriteInvisibility(void) { - if (AnimBankSpriteExists(gActiveBank)) + if (IsBankSpritePresent(gActiveBank)) { gSprites[gBankSpriteIds[gActiveBank]].invisible = gBattleBufferA[gActiveBank][1]; SetBattleSpriteInvisibilityBitToSpriteInvisibility(gActiveBank); diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index 4e71537b0..971a3e656 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -197,7 +197,7 @@ static void nullsub_120(void) { } -void SetBankFuncToRecordedPlayerBufferRunCommand(void) +void SetControllerToRecordedPlayer(void) { gBattleBankFunc[gActiveBank] = RecordedPlayerBufferRunCommand; } @@ -1808,7 +1808,7 @@ static void RecordedPlayerHandleCmd50(void) static void RecordedPlayerHandleSpriteInvisibility(void) { - if (AnimBankSpriteExists(gActiveBank)) + if (IsBankSpritePresent(gActiveBank)) { gSprites[gBankSpriteIds[gActiveBank]].invisible = gBattleBufferA[gActiveBank][1]; SetBattleSpriteInvisibilityBitToSpriteInvisibility(gActiveBank); diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c index 6eb19df84..292a631f4 100644 --- a/src/battle_controller_safari.c +++ b/src/battle_controller_safari.c @@ -175,7 +175,7 @@ static void nullsub_114(void) { } -void SetBankFuncToSafariBufferRunCommand(void) +void SetControllerToSafari(void) { gBattleBankFunc[gActiveBank] = SafariBufferRunCommand; } diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c index 5e454deb5..3314cfe21 100644 --- a/src/battle_controller_wally.c +++ b/src/battle_controller_wally.c @@ -201,7 +201,7 @@ static void nullsub_117(void) { } -void SetBankFuncToWallyBufferRunCommand(void) +void SetControllerToWally(void) { gBattleBankFunc[gActiveBank] = WallyBufferRunCommand; gBattleStruct->wallyBattleState = 0; diff --git a/src/battle_controllers.c b/src/battle_controllers.c index ee835586b..2ba245363 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -145,30 +145,30 @@ static void SetControllersVariables(void) if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) { - gBattleBankFunc[0] = SetBankFuncToRecordedPlayerBufferRunCommand; + gBattleBankFunc[0] = SetControllerToRecordedPlayer; gBanksByIdentity[0] = IDENTITY_PLAYER_MON1; - gBattleBankFunc[1] = SetBankFuncToOpponentBufferRunCommand; + gBattleBankFunc[1] = SetControllerToOpponent; gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; - gBattleBankFunc[2] = SetBankFuncToPlayerPartnerBufferRunCommand; + gBattleBankFunc[2] = SetControllerToPlayerPartner; gBanksByIdentity[2] = IDENTITY_PLAYER_MON2; - gBattleBankFunc[3] = SetBankFuncToOpponentBufferRunCommand; + gBattleBankFunc[3] = SetControllerToOpponent; gBanksByIdentity[3] = IDENTITY_OPPONENT_MON2; } else { - gBattleBankFunc[0] = SetBankFuncToPlayerBufferRunCommand; + gBattleBankFunc[0] = SetControllerToPlayer; gBanksByIdentity[0] = IDENTITY_PLAYER_MON1; - gBattleBankFunc[1] = SetBankFuncToOpponentBufferRunCommand; + gBattleBankFunc[1] = SetControllerToOpponent; gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; - gBattleBankFunc[2] = SetBankFuncToPlayerPartnerBufferRunCommand; + gBattleBankFunc[2] = SetControllerToPlayerPartner; gBanksByIdentity[2] = IDENTITY_PLAYER_MON2; - gBattleBankFunc[3] = SetBankFuncToOpponentBufferRunCommand; + gBattleBankFunc[3] = SetControllerToOpponent; gBanksByIdentity[3] = IDENTITY_OPPONENT_MON2; } @@ -189,15 +189,15 @@ static void SetControllersVariables(void) gBattleMainFunc = BeginBattleIntro; if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) - gBattleBankFunc[0] = SetBankFuncToSafariBufferRunCommand; + gBattleBankFunc[0] = SetControllerToSafari; else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL) - gBattleBankFunc[0] = SetBankFuncToWallyBufferRunCommand; + gBattleBankFunc[0] = SetControllerToWally; else - gBattleBankFunc[0] = SetBankFuncToPlayerBufferRunCommand; + gBattleBankFunc[0] = SetControllerToPlayer; gBanksByIdentity[0] = IDENTITY_PLAYER_MON1; - gBattleBankFunc[1] = SetBankFuncToOpponentBufferRunCommand; + gBattleBankFunc[1] = SetControllerToOpponent; gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; gNoOfAllBanks = 2; @@ -210,20 +210,20 @@ static void SetControllersVariables(void) { gBattleMainFunc = BeginBattleIntro; - gBattleBankFunc[0] = SetBankFuncToRecordedPlayerBufferRunCommand; + gBattleBankFunc[0] = SetControllerToRecordedPlayer; gBanksByIdentity[0] = IDENTITY_PLAYER_MON1; - gBattleBankFunc[1] = SetBankFuncToRecordedOpponentBufferRunCommand; + gBattleBankFunc[1] = SetControllerToRecordedOpponent; gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; gNoOfAllBanks = 2; } else // see how the banks are switched { - gBattleBankFunc[1] = SetBankFuncToRecordedPlayerBufferRunCommand; + gBattleBankFunc[1] = SetControllerToRecordedPlayer; gBanksByIdentity[1] = IDENTITY_PLAYER_MON1; - gBattleBankFunc[0] = SetBankFuncToRecordedOpponentBufferRunCommand; + gBattleBankFunc[0] = SetControllerToRecordedOpponent; gBanksByIdentity[0] = IDENTITY_OPPONENT_MON1; gNoOfAllBanks = 2; @@ -231,10 +231,10 @@ static void SetControllersVariables(void) } else { - gBattleBankFunc[0] = SetBankFuncToRecordedPlayerBufferRunCommand; + gBattleBankFunc[0] = SetControllerToRecordedPlayer; gBanksByIdentity[0] = IDENTITY_PLAYER_MON1; - gBattleBankFunc[1] = SetBankFuncToOpponentBufferRunCommand; + gBattleBankFunc[1] = SetControllerToOpponent; gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; } } @@ -243,16 +243,16 @@ static void SetControllersVariables(void) { gBattleMainFunc = BeginBattleIntro; - gBattleBankFunc[0] = SetBankFuncToPlayerBufferRunCommand; + gBattleBankFunc[0] = SetControllerToPlayer; gBanksByIdentity[0] = IDENTITY_PLAYER_MON1; - gBattleBankFunc[1] = SetBankFuncToOpponentBufferRunCommand; + gBattleBankFunc[1] = SetControllerToOpponent; gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; - gBattleBankFunc[2] = SetBankFuncToPlayerBufferRunCommand; + gBattleBankFunc[2] = SetControllerToPlayer; gBanksByIdentity[2] = IDENTITY_PLAYER_MON2; - gBattleBankFunc[3] = SetBankFuncToOpponentBufferRunCommand; + gBattleBankFunc[3] = SetControllerToOpponent; gBanksByIdentity[3] = IDENTITY_OPPONENT_MON2; gNoOfAllBanks = 4; @@ -263,16 +263,16 @@ static void SetControllersVariables(void) { gBattleMainFunc = BeginBattleIntro; - gBattleBankFunc[0] = SetBankFuncToRecordedPlayerBufferRunCommand; + gBattleBankFunc[0] = SetControllerToRecordedPlayer; gBanksByIdentity[0] = 0; - gBattleBankFunc[1] = SetBankFuncToOpponentBufferRunCommand; + gBattleBankFunc[1] = SetControllerToOpponent; gBanksByIdentity[1] = 1; - gBattleBankFunc[2] = SetBankFuncToRecordedPlayerBufferRunCommand; + gBattleBankFunc[2] = SetControllerToRecordedPlayer; gBanksByIdentity[2] = 2; - gBattleBankFunc[3] = SetBankFuncToOpponentBufferRunCommand; + gBattleBankFunc[3] = SetControllerToOpponent; gBanksByIdentity[3] = 3; gNoOfAllBanks = 4; @@ -307,7 +307,7 @@ static void SetControllersVariables(void) if (i == var) { - gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetBankFuncToRecordedPlayerBufferRunCommand; + gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetControllerToRecordedPlayer; switch (gLinkPlayers[i].lp_field_18) { case 0: @@ -325,7 +325,7 @@ static void SetControllersVariables(void) else if ((!(gLinkPlayers[i].lp_field_18 & 1) && !(gLinkPlayers[var].lp_field_18 & 1)) || ((gLinkPlayers[i].lp_field_18 & 1) && (gLinkPlayers[var].lp_field_18 & 1))) { - gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetBankFuncToRecordedPlayerBufferRunCommand; + gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetControllerToRecordedPlayer; switch (gLinkPlayers[i].lp_field_18) { case 0: @@ -342,7 +342,7 @@ static void SetControllersVariables(void) } else { - gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetBankFuncToRecordedOpponentBufferRunCommand; + gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetControllerToRecordedOpponent; switch (gLinkPlayers[i].lp_field_18) { case 0: @@ -361,51 +361,51 @@ static void SetControllersVariables(void) } else if (gBattleTypeFlags & BATTLE_TYPE_WILD) { - gBattleBankFunc[0] = SetBankFuncToRecordedPlayerBufferRunCommand; + gBattleBankFunc[0] = SetControllerToRecordedPlayer; gBanksByIdentity[0] = IDENTITY_PLAYER_MON1; - gBattleBankFunc[2] = SetBankFuncToRecordedPlayerBufferRunCommand; + gBattleBankFunc[2] = SetControllerToRecordedPlayer; gBanksByIdentity[2] = IDENTITY_PLAYER_MON2; if (gBattleTypeFlags & BATTLE_TYPE_x2000000) { - gBattleBankFunc[1] = SetBankFuncToRecordedOpponentBufferRunCommand; + gBattleBankFunc[1] = SetControllerToRecordedOpponent; gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; - gBattleBankFunc[3] = SetBankFuncToRecordedOpponentBufferRunCommand; + gBattleBankFunc[3] = SetControllerToRecordedOpponent; gBanksByIdentity[3] = IDENTITY_OPPONENT_MON2; } else { - gBattleBankFunc[1] = SetBankFuncToOpponentBufferRunCommand; + gBattleBankFunc[1] = SetControllerToOpponent; gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; - gBattleBankFunc[3] = SetBankFuncToOpponentBufferRunCommand; + gBattleBankFunc[3] = SetControllerToOpponent; gBanksByIdentity[3] = IDENTITY_OPPONENT_MON2; } } else { - gBattleBankFunc[1] = SetBankFuncToRecordedPlayerBufferRunCommand; + gBattleBankFunc[1] = SetControllerToRecordedPlayer; gBanksByIdentity[1] = IDENTITY_PLAYER_MON1; - gBattleBankFunc[3] = SetBankFuncToRecordedPlayerBufferRunCommand; + gBattleBankFunc[3] = SetControllerToRecordedPlayer; gBanksByIdentity[3] = IDENTITY_PLAYER_MON2; if (gBattleTypeFlags & BATTLE_TYPE_x2000000) { - gBattleBankFunc[0] = SetBankFuncToRecordedOpponentBufferRunCommand; + gBattleBankFunc[0] = SetControllerToRecordedOpponent; gBanksByIdentity[0] = IDENTITY_OPPONENT_MON1; - gBattleBankFunc[2] = SetBankFuncToRecordedOpponentBufferRunCommand; + gBattleBankFunc[2] = SetControllerToRecordedOpponent; gBanksByIdentity[2] = IDENTITY_OPPONENT_MON2; } else { - gBattleBankFunc[0] = SetBankFuncToOpponentBufferRunCommand; + gBattleBankFunc[0] = SetControllerToOpponent; gBanksByIdentity[0] = IDENTITY_OPPONENT_MON1; - gBattleBankFunc[2] = SetBankFuncToOpponentBufferRunCommand; + gBattleBankFunc[2] = SetControllerToOpponent; gBanksByIdentity[2] = IDENTITY_OPPONENT_MON2; } } @@ -424,20 +424,20 @@ static void SetControllersVariablesInLinkBattle(void) { gBattleMainFunc = BeginBattleIntro; - gBattleBankFunc[0] = SetBankFuncToPlayerBufferRunCommand; + gBattleBankFunc[0] = SetControllerToPlayer; gBanksByIdentity[0] = IDENTITY_PLAYER_MON1; - gBattleBankFunc[1] = SetBankFuncToLinkOpponentBufferRunCommand; + gBattleBankFunc[1] = SetControllerToLinkOpponent; gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; gNoOfAllBanks = 2; } else { - gBattleBankFunc[1] = SetBankFuncToPlayerBufferRunCommand; + gBattleBankFunc[1] = SetControllerToPlayer; gBanksByIdentity[1] = IDENTITY_PLAYER_MON1; - gBattleBankFunc[0] = SetBankFuncToLinkOpponentBufferRunCommand; + gBattleBankFunc[0] = SetControllerToLinkOpponent; gBanksByIdentity[0] = IDENTITY_OPPONENT_MON1; gNoOfAllBanks = 2; @@ -449,32 +449,32 @@ static void SetControllersVariablesInLinkBattle(void) { gBattleMainFunc = BeginBattleIntro; - gBattleBankFunc[0] = SetBankFuncToPlayerBufferRunCommand; + gBattleBankFunc[0] = SetControllerToPlayer; gBanksByIdentity[0] = IDENTITY_PLAYER_MON1; - gBattleBankFunc[1] = SetBankFuncToLinkOpponentBufferRunCommand; + gBattleBankFunc[1] = SetControllerToLinkOpponent; gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; - gBattleBankFunc[2] = SetBankFuncToPlayerBufferRunCommand; + gBattleBankFunc[2] = SetControllerToPlayer; gBanksByIdentity[2] = IDENTITY_PLAYER_MON2; - gBattleBankFunc[3] = SetBankFuncToLinkOpponentBufferRunCommand; + gBattleBankFunc[3] = SetControllerToLinkOpponent; gBanksByIdentity[3] = IDENTITY_OPPONENT_MON2; gNoOfAllBanks = 4; } else { - gBattleBankFunc[1] = SetBankFuncToPlayerBufferRunCommand; + gBattleBankFunc[1] = SetControllerToPlayer; gBanksByIdentity[1] = IDENTITY_PLAYER_MON1; - gBattleBankFunc[0] = SetBankFuncToLinkOpponentBufferRunCommand; + gBattleBankFunc[0] = SetControllerToLinkOpponent; gBanksByIdentity[0] = IDENTITY_OPPONENT_MON1; - gBattleBankFunc[3] = SetBankFuncToPlayerBufferRunCommand; + gBattleBankFunc[3] = SetControllerToPlayer; gBanksByIdentity[3] = IDENTITY_PLAYER_MON2; - gBattleBankFunc[2] = SetBankFuncToLinkOpponentBufferRunCommand; + gBattleBankFunc[2] = SetControllerToLinkOpponent; gBanksByIdentity[2] = IDENTITY_OPPONENT_MON2; gNoOfAllBanks = 4; @@ -486,32 +486,32 @@ static void SetControllersVariablesInLinkBattle(void) { gBattleMainFunc = BeginBattleIntro; - gBattleBankFunc[0] = SetBankFuncToPlayerBufferRunCommand; + gBattleBankFunc[0] = SetControllerToPlayer; gBanksByIdentity[0] = IDENTITY_PLAYER_MON1; - gBattleBankFunc[1] = SetBankFuncToOpponentBufferRunCommand; + gBattleBankFunc[1] = SetControllerToOpponent; gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; - gBattleBankFunc[2] = SetBankFuncToLinkPartnerBufferRunCommand; + gBattleBankFunc[2] = SetControllerToLinkPartner; gBanksByIdentity[2] = IDENTITY_PLAYER_MON2; - gBattleBankFunc[3] = SetBankFuncToOpponentBufferRunCommand; + gBattleBankFunc[3] = SetControllerToOpponent; gBanksByIdentity[3] = IDENTITY_OPPONENT_MON2; gNoOfAllBanks = 4; } else { - gBattleBankFunc[0] = SetBankFuncToLinkPartnerBufferRunCommand; + gBattleBankFunc[0] = SetControllerToLinkPartner; gBanksByIdentity[0] = IDENTITY_PLAYER_MON1; - gBattleBankFunc[1] = SetBankFuncToLinkOpponentBufferRunCommand; + gBattleBankFunc[1] = SetControllerToLinkOpponent; gBanksByIdentity[1] = IDENTITY_OPPONENT_MON1; - gBattleBankFunc[2] = SetBankFuncToPlayerBufferRunCommand; + gBattleBankFunc[2] = SetControllerToPlayer; gBanksByIdentity[2] = IDENTITY_PLAYER_MON2; - gBattleBankFunc[3] = SetBankFuncToLinkOpponentBufferRunCommand; + gBattleBankFunc[3] = SetControllerToLinkOpponent; gBanksByIdentity[3] = IDENTITY_OPPONENT_MON2; gNoOfAllBanks = 4; @@ -549,7 +549,7 @@ static void SetControllersVariablesInLinkBattle(void) if (i == multiplayerId) { - gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetBankFuncToPlayerBufferRunCommand; + gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetControllerToPlayer; switch (gLinkPlayers[i].lp_field_18) { case 0: @@ -569,7 +569,7 @@ static void SetControllersVariablesInLinkBattle(void) if ((!(gLinkPlayers[i].lp_field_18 & 1) && !(gLinkPlayers[multiplayerId].lp_field_18 & 1)) || ((gLinkPlayers[i].lp_field_18 & 1) && (gLinkPlayers[multiplayerId].lp_field_18 & 1))) { - gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetBankFuncToLinkPartnerBufferRunCommand; + gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetControllerToLinkPartner; switch (gLinkPlayers[i].lp_field_18) { case 0: @@ -586,7 +586,7 @@ static void SetControllersVariablesInLinkBattle(void) } else { - gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetBankFuncToLinkOpponentBufferRunCommand; + gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetControllerToLinkOpponent; switch (gLinkPlayers[i].lp_field_18) { case 0: |