From 25a57093b12b684d5d14c7e0b365840a004b6314 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 20 Feb 2018 02:01:51 +0100 Subject: [PATCH 01/10] start battle link file --- ld_script.txt | 1 + src/battle_link_817C95C.c | 301 ++++++++++++++++ src/battle_message.c | 738 +++++++++++++++++++------------------- 3 files changed, 671 insertions(+), 369 deletions(-) create mode 100644 src/battle_link_817C95C.c diff --git a/ld_script.txt b/ld_script.txt index 4c7b40dd9..4ec960eb4 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -237,6 +237,7 @@ SECTIONS { src/bard_music.o(.text); src/fldeff_teleport.o(.text); asm/battle_link_817C95C.o(.text); + src/battle_link_817C95C.o(.text); src/pokemon_animation.o(.text); src/recorded_battle.o(.text); src/battle_controller_recorded_opponent.o(.text); diff --git a/src/battle_link_817C95C.c b/src/battle_link_817C95C.c new file mode 100644 index 000000000..25640b12c --- /dev/null +++ b/src/battle_link_817C95C.c @@ -0,0 +1,301 @@ +#include "global.h" +#include "pokemon.h" +#include "battle.h" +#include "battle_link_817C95C.h" +#include "constants/battle_string_ids.h" +#include "battle_message.h" + +struct UnknownBattleLinkSubStruct1 +{ + u32 field_8_0:15; + u32 field_8_1:3; // correct + u32 field_8_2:3; // correct + u32 field_8_3:3; // correct + u32 field_8_4:3; // correct + u32 field_8_5:3; // correct + u32 field_8_6:2; + + u32 field_0_0a:3; // correct + u32 field_0_0b:7; + u32 field_0_1:2; // correct + u32 field_0_2:2; // correct + u32 field_0_3:2; // correct + u32 field_0_4:2; // correct + u32 field_0_5:2; // correct + u32 field_0_6:3; // correct + u32 field_0_7:2; // correct + + u32 field_3_0:4; // correct + u32 field_3_1:3; // correct + + u32 field_4_0:6; + u32 field_4_1:1; + u32 field_4_2:1; + + u32 field_5_0:3; // correct + u32 field_5_1:2; // correct + u32 field_4_3:19; +}; + +struct UnknownBattleLinkSubStruct2 +{ + u32 field_0_0:3; // correct + u32 field_0_3:3; // correct + u32 field_0_6:3; // correct + u32 field_1_1:3; // correct + u32 field_1_4:4; + u32 field_2_0:2; + u32 field_2_3:2; // correct + u32 field_2_5:2; // correct + u32 field_2_7:2; // correct + u32 field_3_0:2; // correct + u32 field_3_2:6; + u32 field_4:8; + u32 field_5_0:3; // correct + u32 field_5_3:2; // correct + u32 field_5_5:2; + u32 field_5_7:1; + u32 field_6:8; + u32 field_7:8; +}; + +struct UnknownBattleLinkSubStruct3 +{ + u32 field_0 : 8; + u32 field_1 : 8; + u32 field_2 : 8; + u32 field_3 : 8; + u32 field_4 : 8; + u32 field_5 : 8; + u32 field_6 : 8; + u32 field_7 : 8; + u32 field_8 : 8; + u32 field_9 : 8; + u32 field_A : 8; + u32 field_B : 8; +}; + +struct UnknownBattleLinkStruct +{ + u8 field_0[0x2f]; + struct UnknownBattleLinkSubStruct2 pos[2][2]; // [side][flank] + struct UnknownBattleLinkSubStruct1 side[2]; // [side] +}; + +extern struct StringInfoBattle *gStringInfo; + +// this file's functions +bool8 sub_817E0B8(u16 stringId); +void sub_817E684(u8 arg0, u16 moveSlotId, u8 arg2, u8 arg3); +void sub_817EECC(void); + +void sub_817C95C(u16 stringId) +{ + struct UnknownBattleLinkStruct *structPtr; + u8 atkSide, defSide, effSide, scriptingSide; + struct Pokemon *atkMon, *defMon; + u8 moveSlot; + u8 atkFlank, defFlank, effFlank; + + if (!(gBattleTypeFlags & BATTLE_TYPE_LINK) && stringId != STRINGID_ITDOESNTAFFECT && stringId != STRINGID_NOTVERYEFFECTIVE) + return; + + structPtr = (void*)(&gBattleStruct->field_204); + + atkSide = GetBattlerSide(gBattlerAttacker); + defSide = GetBattlerSide(gBattlerTarget); + effSide = GetBattlerSide(gEffectBattler); + scriptingSide = GetBattlerSide(gStringInfo->scrActive); + + if (atkSide == B_SIDE_PLAYER) + atkMon = &gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]]; + else + atkMon = &gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker]]; + + if (defSide == B_SIDE_PLAYER) + defMon = &gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]]; + else + defMon = &gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker]]; + + moveSlot = GetBattlerMoveSlotId(gBattlerAttacker, gStringInfo->currentMove); + + if (moveSlot >= 4 && sub_817E0B8(stringId) && stringId >= BATTLESTRINGS_ID_ADDER) + { + return; + } + + atkFlank = GetBattlerPosition(gBattlerAttacker) / 2; + defFlank = GetBattlerPosition(gBattlerTarget) / 2; + effFlank = GetBattlerPosition(gEffectBattler) / 2; + + switch (stringId) + { + case STRINGID_ITDOESNTAFFECT: + sub_817E684(1, moveSlot, 2, 0); + if (!(gBattleTypeFlags & BATTLE_TYPE_LINK)) + sub_817EECC(); + break; + case STRINGID_NOTVERYEFFECTIVE: + sub_817E684(1, moveSlot, 1, 0); + if (!(gBattleTypeFlags & BATTLE_TYPE_LINK) && GetMonData(defMon, MON_DATA_HP, NULL) != 0) + sub_817EECC(); + break; + case STRINGID_SUPEREFFECTIVE: + sub_817E684(1, moveSlot, 0, 0); + break; + case STRINGID_PKMNFORESAWATTACK: + structPtr->side[atkSide].field_8_1 = gBattlerPartyIndexes[gBattlerAttacker]; + structPtr->side[atkSide].field_0_1 = moveSlot; + break; + case STRINGID_PKMNCHOSEXASDESTINY: + structPtr->side[atkSide].field_8_2 = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[atkSide].field_0_2 = moveSlot; + break; + case STRINGID_FAINTINTHREE: + structPtr->side[atkSide].field_8_3 = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[atkSide].field_0_3 = moveSlot; + structPtr->side[atkSide].field_4_1 = 1; + break; + case STRINGID_PKMNPERISHCOUNTFELL: + if (gBattleTextBuff1[4] == 0) + structPtr->side[atkSide].field_3_0 = 10; + break; + case STRINGID_PKMNWISHCAMETRUE: + if (structPtr->side[defSide].field_8_4 != 0) + sub_817E684(2, 3, defSide, (structPtr->side[defSide].field_8_4 - 1) * 4 + structPtr->side[defSide].field_0_4); + break; + case STRINGID_PKMNWANTSGRUDGE: + structPtr->side[atkSide].field_8_5 = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[atkSide].field_0_5 = moveSlot; + break; + case STRINGID_PKMNLOSTPPGRUDGE: + if (structPtr->side[defSide].field_8_5 != 0) + sub_817E684(2, 4, defSide, (structPtr->side[defSide].field_8_5 - 1) * 4 + structPtr->side[defSide].field_0_5); + break; + case STRINGID_PKMNTRYINGTOTAKEFOE: + structPtr->side[atkSide].field_0_6 = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[atkSide].field_0_7 = moveSlot; + break; + case STRINGID_PKMNTOOKFOE: + if (structPtr->side[defSide].field_0_6 != 0) + structPtr->side[defSide].field_3_0 = 11; + break; + case STRINGID_PKMNPLANTEDROOTS: + structPtr->pos[atkSide][atkFlank].field_5_0 = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->pos[atkSide][atkFlank].field_5_3 = moveSlot; + break; + case STRINGID_PKMNABSORBEDNUTRIENTS: + if (structPtr->pos[atkSide][atkFlank].field_5_0 != 0) + sub_817E684(2, 6, atkSide, (structPtr->pos[atkSide][atkFlank].field_5_0 - 1) * 4 + structPtr->pos[atkSide][atkFlank].field_5_3); + break; + case STRINGID_PKMNANCHOREDITSELF: + if (structPtr->pos[defSide][defFlank].field_5_0 != 0) + sub_817E684(2, 6, defSide, (structPtr->pos[defSide][defFlank].field_5_0 - 1) * 4 + structPtr->pos[defSide][defFlank].field_5_3); + break; + case STRINGID_PKMNTRANSFORMEDINTO: + gBattleStruct->field_B3 = 1; + break; + case STRINGID_CRITICALHIT: + sub_817E684(0x12, moveSlot, 0, 0); + break; + case STRINGID_PKMNSSTATCHANGED: + if (gBattleTextBuff1[2] != 0) + { + u16 *statStringId = (void*)(gBattleTextBuff2 + 2); + if (*statStringId == STRINGID_STATSHARPLY) + sub_817E684(0x17, moveSlot, gBattleTextBuff1[2] - 1, 0); + else + sub_817E684(0x16, moveSlot, gBattleTextBuff1[2] - 1, 0); + } + break; + case STRINGID_PKMNSSTATCHANGED2: + if (gBattleTextBuff1[2] != 0) + { + if (gBattlerAttacker == gBattlerTarget) + { + u16 *statStringId = (void*)(gBattleTextBuff2 + 2); + if (*statStringId == STRINGID_STATSHARPLY) + sub_817E684(0x17, moveSlot, gBattleTextBuff1[2] - 1, 0); + else + sub_817E684(0x16, moveSlot, gBattleTextBuff1[2] - 1, 0); + } + else + { + sub_817E684(0x1B, moveSlot, gBattleTextBuff1[2] - 1, 0); + } + } + break; + case STRINGID_PKMNSSTATCHANGED3: + if (gBattleTextBuff1[2] != 0) + sub_817E684(0x18, moveSlot, gBattleTextBuff1[2] - 1, 0); + break; + case STRINGID_PKMNSSTATCHANGED4: + if (gBattleTextBuff1[2] != 0) + { + u16 *statStringId = (void*)(gBattleTextBuff2 + 2); + if (*statStringId == STRINGID_STATHARSHLY) + sub_817E684(0x1A, moveSlot, gBattleTextBuff1[2] - 1, 0); + else + sub_817E684(0x19, moveSlot, gBattleTextBuff1[2] - 1, 0); + } + break; + case STRINGID_PKMNLAIDCURSE: + structPtr->pos[defSide][defFlank].field_0_0 = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->pos[defSide][defFlank].field_2_3 = moveSlot; + break; + case STRINGID_PKMNAFFLICTEDBYCURSE: + if (GetMonData(atkMon, MON_DATA_HP, NULL) != 0 + && structPtr->pos[atkSide][atkFlank].field_0_0 != 0) + { + sub_817E684(8, 0, structPtr->pos[atkSide][atkFlank].field_0_0 - 1, structPtr->pos[atkSide][atkFlank].field_2_3); + structPtr->side[atkSide].field_3_0 = 1; + structPtr->side[atkSide].field_3_1 = atkFlank; + } + break; + case STRINGID_PKMNSEEDED: + structPtr->pos[defSide][defFlank].field_0_3 = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->pos[defSide][defFlank].field_2_5 = moveSlot; + break; + case STRINGID_PKMNSAPPEDBYLEECHSEED: + if (structPtr->pos[atkSide][atkFlank].field_0_3 != 0) + { + sub_817E684(8, 1, structPtr->pos[atkSide][atkFlank].field_0_3 - 1, structPtr->pos[atkSide][atkFlank].field_2_5); + structPtr->side[atkSide].field_3_0 = 2; + structPtr->side[atkSide].field_3_1 = atkFlank; + } + break; + case STRINGID_PKMNFELLINTONIGHTMARE: + structPtr->pos[defSide][defFlank].field_0_6 = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->pos[defSide][defFlank].field_2_7 = moveSlot; + break; + case STRINGID_PKMNLOCKEDINNIGHTMARE: + if (GetMonData(atkMon, MON_DATA_HP, NULL) != 0 + && structPtr->pos[atkSide][atkFlank].field_0_6 != 0) + { + sub_817E684(8, 5, structPtr->pos[atkSide][atkFlank].field_0_6 - 1, structPtr->pos[atkSide][atkFlank].field_2_7); + structPtr->side[atkSide].field_3_0 = 5; + structPtr->side[atkSide].field_3_1 = atkFlank; + } + break; + case STRINGID_PKMNSQUEEZEDBYBIND: + case STRINGID_PKMNTRAPPEDINVORTEX: + case STRINGID_PKMNWRAPPEDBY: + case STRINGID_PKMNCLAMPED: + case STRINGID_PKMNTRAPPEDBYSANDTOMB: + structPtr->pos[defSide][defFlank].field_1_1 = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->pos[defSide][defFlank].field_3_0 = moveSlot; + break; + case STRINGID_PKMNHURTBY: + if (GetMonData(atkMon, MON_DATA_HP, NULL) != 0 + && structPtr->pos[atkSide][atkFlank].field_1_1 != 0) + { + sub_817E684(8, 6, structPtr->pos[atkSide][atkFlank].field_1_1 - 1, structPtr->pos[atkSide][atkFlank].field_3_0); + structPtr->side[atkSide].field_3_0 = 6; + structPtr->side[atkSide].field_3_1 = atkFlank; + } + break; + case STRINGID_PKMNWASBURNED: + + break; + } +} diff --git a/src/battle_message.c b/src/battle_message.c index 9a4a062ad..0358c0956 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -516,375 +516,375 @@ const u8 gText_Trainer2LoseText[]; const u8 * const gBattleStringsTable[BATTLESTRINGS_COUNT] = { - gText_Trainer1LoseText, - gText_PkmnGainedEXP, - gText_PkmnGrewToLv, - gText_PkmnLearnedMove, - gText_TryToLearnMove1, - gText_TryToLearnMove2, - gText_TryToLearnMove3, - gText_PkmnForgotMove, - gText_StopLearningMove, - gText_DidNotLearnMove, - gText_PkmnLearnedMove2, - gText_AttackMissed, - gText_PkmnProtectedItself, - gText_StatsWontIncrease2, - gText_AvoidedDamage, - gText_ItDoesntAffect, - gText_AttackerFainted, - gText_TargetFainted, - gText_PlayerGotMoney, - gText_PlayerWhiteout, - gText_PlayerWhiteout2, - gText_PreventsEscape, - gText_HitXTimes, - gText_PkmnFellAsleep, - gText_PkmnMadeSleep, - gText_PkmnAlreadyAsleep, - gText_PkmnAlreadyAsleep2, - gText_PkmnWasntAffected, - gText_PkmnWasPoisoned, - gText_PkmnPoisonedBy, - gText_PkmnHurtByPoison, - gText_PkmnAlreadyPoisoned, - gText_PkmnBadlyPoisoned, - gText_PkmnEnergyDrained, - gText_PkmnWasBurned, - gText_PkmnBurnedBy, - gText_PkmnHurtByBurn, - gText_PkmnWasFrozen, - gText_PkmnFrozenBy, - gText_PkmnIsFrozen, - gText_PkmnWasDefrosted, - gText_PkmnWasDefrosted2, - gText_PkmnWasDefrostedBy, - gText_PkmnWasParalyzed, - gText_PkmnWasParalyzedBy, - gText_PkmnIsParalyzed, - gText_PkmnIsAlreadyParalyzed, - gText_PkmnHealedParalysis, - gText_PkmnDreamEaten, - gText_StatsWontIncrease, - gText_StatsWontDecrease, - gText_TeamStoppedWorking, - gText_FoeStoppedWorking, - gText_PkmnIsConfused, - gText_PkmnHealedConfusion, - gText_PkmnWasConfused, - gText_PkmnAlreadyConfused, - gText_PkmnFellInLove, - gText_PkmnInLove, - gText_PkmnImmobilizedByLove, - gText_PkmnBlownAway, - gText_PkmnChangedType, - gText_PkmnFlinched, - gText_PkmnRegainedHealth, - gText_PkmnHPFull, - gText_PkmnRaisedSpDef, - gText_PkmnRaisedDef, - gText_PkmnCoveredByVeil, - gText_PkmnUsedSafeguard, - gText_PkmnSafeguardExpired, - gText_PkmnWentToSleep, - gText_PkmnSleptHealthy, - gText_PkmnWhippedWhirlwind, - gText_PkmnTookSunlight, - gText_PkmnLoweredHead, - gText_PkmnIsGlowing, - gText_PkmnFlewHigh, - gText_PkmnDugHole, - gText_PkmnSqueezedByBind, - gText_PkmnTrappedInVortex, - gText_PkmnWrappedBy, - gText_PkmnClamped, - gText_PkmnHurtBy, - gText_PkmnFreedFrom, - gText_PkmnCrashed, - gText_PkmnShroudedInMist, - gText_PkmnProtectedByMist, - gText_PkmnGettingPumped, - gText_PkmnHitWithRecoil, - gText_PkmnProtectedItself2, - gText_PkmnBuffetedBySandstorm, - gText_PkmnPeltedByHail, - gText_PkmnSeeded, - gText_PkmnEvadedAttack, - gText_PkmnSappedByLeechSeed, - gText_PkmnFastAsleep, - gText_PkmnWokeUp, - gText_PkmnUproarKeptAwake, - gText_PkmnWokeUpInUproar, - gText_PkmnCausedUproar, - gText_PkmnMakingUproar, - gText_PkmnCalmedDown, - gText_PkmnCantSleepInUproar, - gText_PkmnStockpiled, - gText_PkmnCantStockpile, - gText_PkmnCantSleepInUproar2, - gText_UproarKeptPkmnAwake, - gText_PkmnStayedAwakeUsing, - gText_PkmnStoringEnergy, - gText_PkmnUnleashedEnergy, - gText_PkmnFatigueConfusion, - gText_PkmnPickedUpItem, - gText_PkmnUnaffected, - gText_PkmnTransformedInto, - gText_PkmnMadeSubstitute, - gText_PkmnHasSubstitute, - gText_SubstituteDamaged, - gText_PkmnSubstituteFaded, - gText_PkmnMustRecharge, - gText_PkmnRageBuilding, - gText_PkmnMoveWasDisabled, - gText_PkmnMoveIsDisabled, - gText_PkmnMoveDisabledNoMore, - gText_PkmnGotEncore, - gText_PkmnEncoreEnded, - gText_PkmnTookAim, - gText_PkmnSketchedMove, - gText_PkmnTryingToTakeFoe, - gText_PkmnTookFoe, - gText_PkmnReducedPP, - gText_PkmnStoleItem, - gText_TargetCantEscapeNow, - gText_PkmnFellIntoNightmare, - gText_PkmnLockedInNightmare, - gText_PkmnLaidCurse, - gText_PkmnAfflictedByCurse, - gText_SpikesScattered, - gText_PkmnHurtBySpikes, - gText_PkmnIdentified, - gText_PkmnPerishCountFell, - gText_PkmnBracedItself, - gText_PkmnEnduredHit, - gText_MagnitudeStrength, - gText_PkmnCutHPMaxedAttack, - gText_PkmnCopiedStatChanges, - gText_PkmnGotFree, - gText_PkmnShedLeechSeed, - gText_PkmnBlewAwaySpikes, - gText_PkmnFledFromBattle, - gText_PkmnForesawAttack, - gText_PkmnTookAttack, - gText_PkmnAttack, - gText_PkmnCenterAttention, - gText_PkmnChargingPower, - gText_NaturePowerTurnedInto, - gText_PkmnStatusNormal, - gText_PkmnHasNoMovesLeft, - gText_PkmnSubjectedToTorment, - gText_PkmnCantUseMoveTorment, - gText_PkmnTighteningFocus, - gText_PkmnFellForTaunt, - gText_PkmnCantUseMoveTaunt, - gText_PkmnReadyToHelp, - gText_PkmnSwitchedItems, - gText_PkmnCopiedFoe, - gText_PkmnMadeWish, - gText_PkmnWishCameTrue, - gText_PkmnPlantedRoots, - gText_PkmnAbsorbedNutrients, - gText_PkmnAnchoredItself, - gText_PkmnWasMadeDrowsy, - gText_PkmnKnockedOff, - gText_PkmnSwappedAbilities, - gText_PkmnSealedOpponentMove, - gText_PkmnCantUseMoveSealed, - gText_PkmnWantsGrudge, - gText_PkmnLostPPGrudge, - gText_PkmnShroudedItself, - gText_PkmnMoveBounced, - gText_PkmnWaitsForTarget, - gText_PkmnSnatchedMove, - gText_PkmnMadeItRain, - gText_PkmnRaisedSpeed, - gText_PkmnProtectedBy, - gText_PkmnPreventsUsage, - gText_PkmnRestoredHPUsing, - gText_PkmnChangedTypeWith, - gText_PkmnPreventsParalysisWith, - gText_PkmnPreventsRomanceWith, - gText_PkmnPreventsPoisoningWith, - gText_PkmnPreventsConfusionWith, - gText_PkmnRaisedFirePowerWith, - gText_PkmnAnchorsItselfWith, - gText_PkmnCutsAttackWith, - gText_PkmnPreventsStatLossWith, - gText_PkmnHurtsWith, - gText_PkmnTraced, - gText_StatSharply, - gText_StatRose, - gText_StatHarshly, - gText_StatFell, - gText_PkmnsStatChanged, - gText_PkmnsStatChanged2, - gText_PkmnsStatChanged3, - gText_PkmnsStatChanged4, - gText_CriticalHit, - gText_OneHitKO, - gText_123Poof, - gText_AndEllipsis, - gText_NotVeryEffective, - gText_SuperEffective, - gText_GotAwaySafely, - gText_WildPkmnFled, - gText_NoRunningFromTrainers, - gText_CantEscape, - gText_DontLeaveBirch, - gText_ButNothingHappened, - gText_ButItFailed, - gText_ItHurtConfusion, - gText_MirrorMoveFailed, - gText_StartedToRain, - gText_DownpourStarted, - gText_RainContinues, - gText_DownpourContinues, - gText_RainStopped, - gText_SandstormBrewed, - gText_SandstormRages, - gText_SandstormSubsided, - gText_SunlightGotBright, - gText_SunlightStrong, - gText_SunlightFaded, - gText_StartedHail, - gText_HailContinues, - gText_HailStopped, - gText_FailedToSpitUp, - gText_FailedToSwallow, - gText_WindBecameHeatWave, - gText_StatChangesGone, - gText_CoinsScattered, - gText_TooWeakForSubstitute, - gText_SharedPain, - gText_BellChimed, - gText_FaintInThree, - gText_NoPPLeft, - gText_ButNoPPLeft, - gText_PlayerUsedItem, - gText_WallyUsedItem, - gText_TrainerBlockedBall, - gText_DontBeAThief, - gText_ItDodgedBall, - gText_YouMissedPkmn, - gText_PkmnBrokeFree, - gText_ItAppearedCaught, - gText_AarghAlmostHadIt, - gText_ShootSoClose, - gText_GotchaPkmnCaught, - gText_GotchaPkmnCaught2, - gText_GiveNicknameCaptured, - gText_PkmnSentToPC, - gText_PkmnDataAddedToDex, - gText_ItIsRaining, - gText_SandstormIsRaging, - gText_CantEscape2, - gText_PkmnIgnoresAsleep, - gText_PkmnIgnoredOrders, - gText_PkmnBeganToNap, - gText_PkmnLoafing, - gText_PkmnWontObey, - gText_PkmnTurnedAway, - gText_PkmnPretendNotNotice, - gText_EnemyAboutToSwitchPkmn, - gText_CreptCloser, - gText_CantGetCloser, - gText_PkmnWatchingCarefully, - gText_PkmnCuriousAboutX, - gText_PkmnEnthralledByX, - gText_PkmnIgnoredX, - gText_ThrewPokeblockAtPkmn, - gText_OutOfSafariBalls, - gText_PkmnsItemCuredParalysis, - gText_PkmnsItemCuredPoison, - gText_PkmnsItemHealedBurn, - gText_PkmnsItemDefrostedIt, - gText_PkmnsItemWokeIt, - gText_PkmnsItemSnappedOut, - gText_PkmnsItemCuredProblem, - gText_PkmnsItemRestoredHealth, - gText_PkmnsItemRestoredPP, - gText_PkmnsItemRestoredStatus, - gText_PkmnsItemRestoredHPALittle, - gText_ItemAllowsOnlyYMove, - gText_PkmnHungOnWithX, - gText_EmptyString3, - gText_PkmnsXPreventsBurns, - gText_PkmnsXBlocksY, - gText_PkmnsXRestoredHPALittle2, - gText_PkmnsXWhippedUpSandstorm, - gText_PkmnsXPreventsYLoss, - gText_PkmnsXInfatuatedY, - gText_PkmnsXMadeYIneffective, - gText_PkmnsXCuredYProblem, - gText_ItSuckedLiquidOoze, - gText_PkmnTransformed, - gText_ElectricityWeakened, - gText_FireWeakened, - gText_PkmnHidUnderwater, - gText_PkmnSprangUp, - gText_HMMovesCantBeForgotten, - gText_XFoundOneY, - gText_PlayerDefeatedLinkTrainerTrainer1, - gText_SoothingAroma, - gText_ItemsCantBeUsedNow, - gText_ForXCommaYZ, - gText_UsingXTheYOfZN, - gText_PkmnUsedXToGetPumped, - gText_PkmnsXMadeYUseless, - gText_PkmnTrappedBySandTomb, - gText_EmptyString4, - gText_ABoosted, - gText_PkmnsXIntensifiedSun, - gText_PkmnMakesGroundMiss, - gText_YouThrowABallNowRight, - gText_PkmnsXTookAttack, - gText_PkmnChoseXAsDestiny, - gText_PkmnLostFocus, - gText_UseNextPkmn, - gText_PkmnFledUsingIts, - gText_PkmnFledUsing, - gText_PkmnWasDraggedOut, - gText_PreventedFromWorking, - gText_PkmnsItemNormalizedStatus, - gText_Trainer1UsedItem, - gText_BoxIsFull, - gText_PkmnAvoidedAttack, - gText_PkmnsXMadeItIneffective, - gText_PkmnsXPreventsFlinching, - gText_PkmnAlreadyHasBurn, - gText_StatsWontDecrease2, - gText_PkmnsXBlocksY2, - gText_PkmnsXWoreOff, - gText_PkmnRaisedDefALittle, - gText_PkmnRaisedSpDefALittle, - gText_TheWallShattered, - gText_PkmnsXPreventsYsZ, - gText_PkmnsXCuredItsYProblem, - gText_AttackerCantEscape, - gText_PkmnObtainedX, - gText_PkmnObtainedX2, - gText_PkmnObtainedXYObtainedZ, - gText_ButNoEffect, - gText_PkmnsXHadNoEffectOnY, - gText_TwoInGameTrainersDefeated, - gText_Trainer2LoseText, - gText_PkmnIncapableOfPower, - gText_GlintAppearsInEye, - gText_PkmnGettingIntoPosition, - gText_PkmnBeganGrowlingDeeply, - gText_PkmnEagerForMore, - gText_DefeatedOpponentByReferee, - gText_LostToOpponentByReferee, - gText_TiedOpponentByReferee, - gText_QuestionForfeitMatch, - gText_ForfeitedMatch, - gText_PkmnTransferredSomeonesPC, - gText_PkmnTransferredLanettesPC, - gText_PkmnBoxSomeonesPCFull, - gText_PkmnBoxLanettesPCFull, - gText_Trainer1WinText, - gText_Trainer2WinText, + gText_Trainer1LoseText, // 12 + gText_PkmnGainedEXP, // 13 + gText_PkmnGrewToLv, // 14 + gText_PkmnLearnedMove, // 15 + gText_TryToLearnMove1, // 16 + gText_TryToLearnMove2, // 17 + gText_TryToLearnMove3, // 18 + gText_PkmnForgotMove, // 19 + gText_StopLearningMove, // 20 + gText_DidNotLearnMove, // 21 + gText_PkmnLearnedMove2, // 22 + gText_AttackMissed, // 23 + gText_PkmnProtectedItself, // 24 + gText_StatsWontIncrease2, // 25 + gText_AvoidedDamage, // 26 + gText_ItDoesntAffect, // 27 + gText_AttackerFainted, // 28 + gText_TargetFainted, // 29 + gText_PlayerGotMoney, // 30 + gText_PlayerWhiteout, // 31 + gText_PlayerWhiteout2, // 32 + gText_PreventsEscape, // 33 + gText_HitXTimes, // 34 + gText_PkmnFellAsleep, // 35 + gText_PkmnMadeSleep, // 36 + gText_PkmnAlreadyAsleep, // 37 + gText_PkmnAlreadyAsleep2, // 38 + gText_PkmnWasntAffected, // 39 + gText_PkmnWasPoisoned, // 40 + gText_PkmnPoisonedBy, // 41 + gText_PkmnHurtByPoison, // 42 + gText_PkmnAlreadyPoisoned, // 43 + gText_PkmnBadlyPoisoned, // 44 + gText_PkmnEnergyDrained, // 45 + gText_PkmnWasBurned, // 46 + gText_PkmnBurnedBy, // 47 + gText_PkmnHurtByBurn, // 48 + gText_PkmnWasFrozen, // 49 + gText_PkmnFrozenBy, // 50 + gText_PkmnIsFrozen, // 51 + gText_PkmnWasDefrosted, // 52 + gText_PkmnWasDefrosted2, // 53 + gText_PkmnWasDefrostedBy, // 54 + gText_PkmnWasParalyzed, // 55 + gText_PkmnWasParalyzedBy, // 56 + gText_PkmnIsParalyzed, // 57 + gText_PkmnIsAlreadyParalyzed, // 58 + gText_PkmnHealedParalysis, // 59 + gText_PkmnDreamEaten, // 60 + gText_StatsWontIncrease, // 61 + gText_StatsWontDecrease, // 62 + gText_TeamStoppedWorking, // 63 + gText_FoeStoppedWorking, // 64 + gText_PkmnIsConfused, // 65 + gText_PkmnHealedConfusion, // 66 + gText_PkmnWasConfused, // 67 + gText_PkmnAlreadyConfused, // 68 + gText_PkmnFellInLove, // 69 + gText_PkmnInLove, // 70 + gText_PkmnImmobilizedByLove, // 71 + gText_PkmnBlownAway, // 72 + gText_PkmnChangedType, // 73 + gText_PkmnFlinched, // 74 + gText_PkmnRegainedHealth, // 75 + gText_PkmnHPFull, // 76 + gText_PkmnRaisedSpDef, // 77 + gText_PkmnRaisedDef, // 78 + gText_PkmnCoveredByVeil, // 79 + gText_PkmnUsedSafeguard, // 80 + gText_PkmnSafeguardExpired, // 81 + gText_PkmnWentToSleep, // 82 + gText_PkmnSleptHealthy, // 83 + gText_PkmnWhippedWhirlwind, // 84 + gText_PkmnTookSunlight, // 85 + gText_PkmnLoweredHead, // 86 + gText_PkmnIsGlowing, // 87 + gText_PkmnFlewHigh, // 88 + gText_PkmnDugHole, // 89 + gText_PkmnSqueezedByBind, // 90 + gText_PkmnTrappedInVortex, // 91 + gText_PkmnWrappedBy, // 92 + gText_PkmnClamped, // 93 + gText_PkmnHurtBy, // 94 + gText_PkmnFreedFrom, // 95 + gText_PkmnCrashed, // 96 + gText_PkmnShroudedInMist, // 97 + gText_PkmnProtectedByMist, // 98 + gText_PkmnGettingPumped, // 99 + gText_PkmnHitWithRecoil, // 100 + gText_PkmnProtectedItself2, // 101 + gText_PkmnBuffetedBySandstorm, // 102 + gText_PkmnPeltedByHail, // 103 + gText_PkmnSeeded, // 104 + gText_PkmnEvadedAttack, // 105 + gText_PkmnSappedByLeechSeed, // 106 + gText_PkmnFastAsleep, // 107 + gText_PkmnWokeUp, // 108 + gText_PkmnUproarKeptAwake, // 109 + gText_PkmnWokeUpInUproar, // 110 + gText_PkmnCausedUproar, // 111 + gText_PkmnMakingUproar, // 112 + gText_PkmnCalmedDown, // 113 + gText_PkmnCantSleepInUproar, // 114 + gText_PkmnStockpiled, // 115 + gText_PkmnCantStockpile, // 116 + gText_PkmnCantSleepInUproar2, // 117 + gText_UproarKeptPkmnAwake, // 118 + gText_PkmnStayedAwakeUsing, // 119 + gText_PkmnStoringEnergy, // 120 + gText_PkmnUnleashedEnergy, // 121 + gText_PkmnFatigueConfusion, // 122 + gText_PkmnPickedUpItem, // 123 + gText_PkmnUnaffected, // 124 + gText_PkmnTransformedInto, // 125 + gText_PkmnMadeSubstitute, // 126 + gText_PkmnHasSubstitute, // 127 + gText_SubstituteDamaged, // 128 + gText_PkmnSubstituteFaded, // 129 + gText_PkmnMustRecharge, // 130 + gText_PkmnRageBuilding, // 131 + gText_PkmnMoveWasDisabled, // 132 + gText_PkmnMoveIsDisabled, // 133 + gText_PkmnMoveDisabledNoMore, // 134 + gText_PkmnGotEncore, // 135 + gText_PkmnEncoreEnded, // 136 + gText_PkmnTookAim, // 137 + gText_PkmnSketchedMove, // 138 + gText_PkmnTryingToTakeFoe, // 139 + gText_PkmnTookFoe, // 140 + gText_PkmnReducedPP, // 141 + gText_PkmnStoleItem, // 142 + gText_TargetCantEscapeNow, // 143 + gText_PkmnFellIntoNightmare, // 144 + gText_PkmnLockedInNightmare, // 145 + gText_PkmnLaidCurse, // 146 + gText_PkmnAfflictedByCurse, // 147 + gText_SpikesScattered, // 148 + gText_PkmnHurtBySpikes, // 149 + gText_PkmnIdentified, // 150 + gText_PkmnPerishCountFell, // 151 + gText_PkmnBracedItself, // 152 + gText_PkmnEnduredHit, // 153 + gText_MagnitudeStrength, // 154 + gText_PkmnCutHPMaxedAttack, // 155 + gText_PkmnCopiedStatChanges, // 156 + gText_PkmnGotFree, // 157 + gText_PkmnShedLeechSeed, // 158 + gText_PkmnBlewAwaySpikes, // 159 + gText_PkmnFledFromBattle, // 160 + gText_PkmnForesawAttack, // 161 + gText_PkmnTookAttack, // 162 + gText_PkmnAttack, // 163 + gText_PkmnCenterAttention, // 164 + gText_PkmnChargingPower, // 165 + gText_NaturePowerTurnedInto, // 166 + gText_PkmnStatusNormal, // 167 + gText_PkmnHasNoMovesLeft, // 168 + gText_PkmnSubjectedToTorment, // 169 + gText_PkmnCantUseMoveTorment, // 170 + gText_PkmnTighteningFocus, // 171 + gText_PkmnFellForTaunt, // 172 + gText_PkmnCantUseMoveTaunt, // 173 + gText_PkmnReadyToHelp, // 174 + gText_PkmnSwitchedItems, // 175 + gText_PkmnCopiedFoe, // 176 + gText_PkmnMadeWish, // 177 + gText_PkmnWishCameTrue, // 178 + gText_PkmnPlantedRoots, // 179 + gText_PkmnAbsorbedNutrients, // 180 + gText_PkmnAnchoredItself, // 181 + gText_PkmnWasMadeDrowsy, // 182 + gText_PkmnKnockedOff, // 183 + gText_PkmnSwappedAbilities, // 184 + gText_PkmnSealedOpponentMove, // 185 + gText_PkmnCantUseMoveSealed, // 186 + gText_PkmnWantsGrudge, // 187 + gText_PkmnLostPPGrudge, // 188 + gText_PkmnShroudedItself, // 189 + gText_PkmnMoveBounced, // 190 + gText_PkmnWaitsForTarget, // 191 + gText_PkmnSnatchedMove, // 192 + gText_PkmnMadeItRain, // 193 + gText_PkmnRaisedSpeed, // 194 + gText_PkmnProtectedBy, // 195 + gText_PkmnPreventsUsage, // 196 + gText_PkmnRestoredHPUsing, // 197 + gText_PkmnChangedTypeWith, // 198 + gText_PkmnPreventsParalysisWith, // 199 + gText_PkmnPreventsRomanceWith, // 200 + gText_PkmnPreventsPoisoningWith, // 201 + gText_PkmnPreventsConfusionWith, // 202 + gText_PkmnRaisedFirePowerWith, // 203 + gText_PkmnAnchorsItselfWith, // 204 + gText_PkmnCutsAttackWith, // 205 + gText_PkmnPreventsStatLossWith, // 206 + gText_PkmnHurtsWith, // 207 + gText_PkmnTraced, // 208 + gText_StatSharply, // 209 + gText_StatRose, // 210 + gText_StatHarshly, // 211 + gText_StatFell, // 212 + gText_PkmnsStatChanged, // 213 + gText_PkmnsStatChanged2, // 214 + gText_PkmnsStatChanged3, // 215 + gText_PkmnsStatChanged4, // 216 + gText_CriticalHit, // 217 + gText_OneHitKO, // 218 + gText_123Poof, // 219 + gText_AndEllipsis, // 220 + gText_NotVeryEffective, // 221 + gText_SuperEffective, // 222 + gText_GotAwaySafely, // 223 + gText_WildPkmnFled, // 224 + gText_NoRunningFromTrainers, // 225 + gText_CantEscape, // 226 + gText_DontLeaveBirch, // 227 + gText_ButNothingHappened, // 228 + gText_ButItFailed, // 229 + gText_ItHurtConfusion, // 230 + gText_MirrorMoveFailed, // 231 + gText_StartedToRain, // 232 + gText_DownpourStarted, // 233 + gText_RainContinues, // 234 + gText_DownpourContinues, // 235 + gText_RainStopped, // 236 + gText_SandstormBrewed, // 237 + gText_SandstormRages, // 238 + gText_SandstormSubsided, // 239 + gText_SunlightGotBright, // 240 + gText_SunlightStrong, // 241 + gText_SunlightFaded, // 242 + gText_StartedHail, // 243 + gText_HailContinues, // 244 + gText_HailStopped, // 245 + gText_FailedToSpitUp, // 246 + gText_FailedToSwallow, // 247 + gText_WindBecameHeatWave, // 248 + gText_StatChangesGone, // 249 + gText_CoinsScattered, // 250 + gText_TooWeakForSubstitute, // 251 + gText_SharedPain, // 252 + gText_BellChimed, // 253 + gText_FaintInThree, // 254 + gText_NoPPLeft, // 255 + gText_ButNoPPLeft, // 256 + gText_PlayerUsedItem, // 257 + gText_WallyUsedItem, // 258 + gText_TrainerBlockedBall, // 259 + gText_DontBeAThief, // 260 + gText_ItDodgedBall, // 261 + gText_YouMissedPkmn, // 262 + gText_PkmnBrokeFree, // 263 + gText_ItAppearedCaught, // 264 + gText_AarghAlmostHadIt, // 265 + gText_ShootSoClose, // 266 + gText_GotchaPkmnCaught, // 267 + gText_GotchaPkmnCaught2, // 268 + gText_GiveNicknameCaptured, // 269 + gText_PkmnSentToPC, // 270 + gText_PkmnDataAddedToDex, // 271 + gText_ItIsRaining, // 272 + gText_SandstormIsRaging, // 273 + gText_CantEscape2, // 274 + gText_PkmnIgnoresAsleep, // 275 + gText_PkmnIgnoredOrders, // 276 + gText_PkmnBeganToNap, // 277 + gText_PkmnLoafing, // 278 + gText_PkmnWontObey, // 279 + gText_PkmnTurnedAway, // 280 + gText_PkmnPretendNotNotice, // 281 + gText_EnemyAboutToSwitchPkmn, // 282 + gText_CreptCloser, // 283 + gText_CantGetCloser, // 284 + gText_PkmnWatchingCarefully, // 285 + gText_PkmnCuriousAboutX, // 286 + gText_PkmnEnthralledByX, // 287 + gText_PkmnIgnoredX, // 288 + gText_ThrewPokeblockAtPkmn, // 289 + gText_OutOfSafariBalls, // 290 + gText_PkmnsItemCuredParalysis, // 291 + gText_PkmnsItemCuredPoison, // 292 + gText_PkmnsItemHealedBurn, // 293 + gText_PkmnsItemDefrostedIt, // 294 + gText_PkmnsItemWokeIt, // 295 + gText_PkmnsItemSnappedOut, // 296 + gText_PkmnsItemCuredProblem, // 297 + gText_PkmnsItemRestoredHealth, // 298 + gText_PkmnsItemRestoredPP, // 299 + gText_PkmnsItemRestoredStatus, // 300 + gText_PkmnsItemRestoredHPALittle, // 301 + gText_ItemAllowsOnlyYMove, // 302 + gText_PkmnHungOnWithX, // 303 + gText_EmptyString3, // 304 + gText_PkmnsXPreventsBurns, // 305 + gText_PkmnsXBlocksY, // 306 + gText_PkmnsXRestoredHPALittle2, // 307 + gText_PkmnsXWhippedUpSandstorm, // 308 + gText_PkmnsXPreventsYLoss, // 309 + gText_PkmnsXInfatuatedY, // 310 + gText_PkmnsXMadeYIneffective, // 311 + gText_PkmnsXCuredYProblem, // 312 + gText_ItSuckedLiquidOoze, // 313 + gText_PkmnTransformed, // 314 + gText_ElectricityWeakened, // 315 + gText_FireWeakened, // 316 + gText_PkmnHidUnderwater, // 317 + gText_PkmnSprangUp, // 318 + gText_HMMovesCantBeForgotten, // 319 + gText_XFoundOneY, // 320 + gText_PlayerDefeatedLinkTrainerTrainer1, // 321 + gText_SoothingAroma, // 322 + gText_ItemsCantBeUsedNow, // 323 + gText_ForXCommaYZ, // 324 + gText_UsingXTheYOfZN, // 325 + gText_PkmnUsedXToGetPumped, // 326 + gText_PkmnsXMadeYUseless, // 327 + gText_PkmnTrappedBySandTomb, // 328 + gText_EmptyString4, // 329 + gText_ABoosted, // 330 + gText_PkmnsXIntensifiedSun, // 331 + gText_PkmnMakesGroundMiss, // 332 + gText_YouThrowABallNowRight, // 333 + gText_PkmnsXTookAttack, // 334 + gText_PkmnChoseXAsDestiny, // 335 + gText_PkmnLostFocus, // 336 + gText_UseNextPkmn, // 337 + gText_PkmnFledUsingIts, // 338 + gText_PkmnFledUsing, // 339 + gText_PkmnWasDraggedOut, // 340 + gText_PreventedFromWorking, // 341 + gText_PkmnsItemNormalizedStatus, // 342 + gText_Trainer1UsedItem, // 343 + gText_BoxIsFull, // 344 + gText_PkmnAvoidedAttack, // 345 + gText_PkmnsXMadeItIneffective, // 346 + gText_PkmnsXPreventsFlinching, // 347 + gText_PkmnAlreadyHasBurn, // 348 + gText_StatsWontDecrease2, // 349 + gText_PkmnsXBlocksY2, // 350 + gText_PkmnsXWoreOff, // 351 + gText_PkmnRaisedDefALittle, // 352 + gText_PkmnRaisedSpDefALittle, // 353 + gText_TheWallShattered, // 354 + gText_PkmnsXPreventsYsZ, // 355 + gText_PkmnsXCuredItsYProblem, // 356 + gText_AttackerCantEscape, // 357 + gText_PkmnObtainedX, // 358 + gText_PkmnObtainedX2, // 359 + gText_PkmnObtainedXYObtainedZ, // 360 + gText_ButNoEffect, // 361 + gText_PkmnsXHadNoEffectOnY, // 362 + gText_TwoInGameTrainersDefeated, // 363 + gText_Trainer2LoseText, // 364 + gText_PkmnIncapableOfPower, // 365 + gText_GlintAppearsInEye, // 366 + gText_PkmnGettingIntoPosition, // 367 + gText_PkmnBeganGrowlingDeeply, // 368 + gText_PkmnEagerForMore, // 369 + gText_DefeatedOpponentByReferee, // 370 + gText_LostToOpponentByReferee, // 371 + gText_TiedOpponentByReferee, // 372 + gText_QuestionForfeitMatch, // 373 + gText_ForfeitedMatch, // 374 + gText_PkmnTransferredSomeonesPC, // 375 + gText_PkmnTransferredLanettesPC, // 376 + gText_PkmnBoxSomeonesPCFull, // 377 + gText_PkmnBoxLanettesPCFull, // 378 + gText_Trainer1WinText, // 379 + gText_Trainer2WinText, // 380 }; const u16 gMissStringIds[] = From 558133bba0ca6fba3ff71217e9f750e7a3e9033a Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 24 Feb 2018 13:44:26 +0100 Subject: [PATCH 02/10] almost match --- asm/battle_link_817C95C.s | 2486 ------------------------------------- ld_script.txt | 2 +- src/battle_link_817C95C.c | 320 ++++- 3 files changed, 269 insertions(+), 2539 deletions(-) diff --git a/asm/battle_link_817C95C.s b/asm/battle_link_817C95C.s index 55d0bae39..e64d142fa 100644 --- a/asm/battle_link_817C95C.s +++ b/asm/battle_link_817C95C.s @@ -5,2492 +5,6 @@ .text - thumb_func_start sub_817C95C -sub_817C95C: @ 817C95C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x10 - lsls r0, 16 - lsrs r0, 16 - str r0, [sp] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x2 - ands r0, r1 - cmp r0, 0 - bne _0817C988 - ldr r0, [sp] - cmp r0, 0x1B - beq _0817C988 - cmp r0, 0xDD - beq _0817C988 - bl _0817E0A6 -_0817C988: - ldr r0, =gBattleStruct - ldr r0, [r0] - movs r1, 0x81 - lsls r1, 2 - adds r7, r0, r1 - ldr r5, =gBattlerAttacker - ldrb r0, [r5] - bl GetBattlerSide - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gBattlerTarget - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - lsrs r6, r0, 24 - ldr r0, =gEffectBattler - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - ldr r0, =gStringInfo - ldr r0, [r0] - ldrb r0, [r0, 0x7] - bl GetBattlerSide - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x4] - cmp r4, 0 - bne _0817CA00 - ldr r2, =gBattlerPartyIndexes - ldrb r0, [r5] - lsls r0, 1 - adds r0, r2 - ldrh r1, [r0] - movs r0, 0x64 - muls r1, r0 - ldr r0, =gPlayerParty - b _0817CA10 - .pool -_0817CA00: - ldr r2, =gBattlerPartyIndexes - ldrb r0, [r5] - lsls r0, 1 - adds r0, r2 - ldrh r1, [r0] - movs r0, 0x64 - muls r1, r0 - ldr r0, =gEnemyParty -_0817CA10: - adds r1, r0 - str r1, [sp, 0x8] - cmp r6, 0 - bne _0817CA3C - ldr r0, =gBattlerTarget - ldrb r0, [r0] - lsls r0, 1 - adds r0, r2 - ldrh r1, [r0] - movs r0, 0x64 - muls r1, r0 - ldr r0, =gPlayerParty - b _0817CA4C - .pool -_0817CA3C: - ldr r0, =gBattlerTarget - ldrb r0, [r0] - lsls r0, 1 - adds r0, r2 - ldrh r1, [r0] - movs r0, 0x64 - muls r1, r0 - ldr r0, =gEnemyParty -_0817CA4C: - adds r1, r0 - str r1, [sp, 0xC] - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - ldr r1, =gStringInfo - ldr r1, [r1] - ldrh r1, [r1] - bl GetBattlerMoveSlotId - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - cmp r0, 0x3 - bls _0817CA9C - ldr r0, [sp] - bl sub_817E0B8 - lsls r0, 24 - cmp r0, 0 - beq _0817CA9C - ldr r2, [sp] - cmp r2, 0xC - bls _0817CA9C - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 2 - adds r0, r7, r0 - adds r0, 0x57 - ldrb r1, [r0] - movs r2, 0x1E - bl _0817E0A2 - .pool -_0817CA9C: - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - bl GetBattlerPosition - lsls r0, 24 - lsrs r0, 25 - mov r8, r0 - ldr r0, =gBattlerTarget - ldrb r0, [r0] - bl GetBattlerPosition - lsls r0, 24 - lsrs r5, r0, 25 - ldr r0, =gEffectBattler - ldrb r0, [r0] - bl GetBattlerPosition - lsls r0, 24 - lsrs r3, r0, 25 - ldr r1, [sp] - subs r1, 0x2 - movs r0, 0xB0 - lsls r0, 1 - cmp r1, r0 - bls _0817CAD2 - bl _0817E0A6 -_0817CAD2: - lsls r0, r1, 2 - ldr r1, =_0817CAEC - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0817CAEC: - .4byte _0817DD7A - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817D070 - .4byte _0817DD74 - .4byte _0817DD80 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817DA68 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817D7D8 - .4byte _0817E0A6 - .4byte _0817D8A4 - .4byte _0817E0A6 - .4byte _0817D838 - .4byte _0817E0A6 - .4byte _0817D704 - .4byte _0817E0A6 - .4byte _0817D76C - .4byte _0817DB24 - .4byte _0817E0A6 - .4byte _0817DB90 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817D9C2 - .4byte _0817E0A6 - .4byte _0817DA24 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817DBD4 - .4byte _0817E0A6 - .4byte _0817D94C - .4byte _0817E0A6 - .4byte _0817D994 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E040 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817DE10 - .4byte _0817DDC8 - .4byte _0817DEDC - .4byte _0817DF24 - .4byte _0817DF4E - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817D65E - .4byte _0817D65E - .4byte _0817D65E - .4byte _0817D65E - .4byte _0817D698 - .4byte _0817E0A6 - .4byte _0817E08E - .4byte _0817DF70 - .4byte _0817DFBC - .4byte _0817E0A6 - .4byte _0817E08E - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817D53C - .4byte _0817E0A6 - .4byte _0817D584 - .4byte _0817DACC - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817D3A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817D296 - .4byte _0817D2E4 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817D5CE - .4byte _0817D608 - .4byte _0817D498 - .4byte _0817D4E0 - .4byte _0817DC62 - .4byte _0817DC98 - .4byte _0817E0A6 - .4byte _0817D1B8 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817DCDC - .4byte _0817E0A6 - .4byte _0817D0DC - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817D1E0 - .4byte _0817D314 - .4byte _0817D354 - .4byte _0817D372 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817D216 - .4byte _0817D260 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817D3C0 - .4byte _0817D3F2 - .4byte _0817D440 - .4byte _0817D45C - .4byte _0817D3B8 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817D098 - .4byte _0817D0D4 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817DC20 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817D16C - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817DD38 - .4byte _0817DCFC - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817D65E - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817D124 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817E0A6 - .4byte _0817DE58 - .4byte _0817DDC8 - .4byte _0817DE10 - .4byte _0817DFE6 -_0817D070: - movs r0, 0x1 - mov r1, r10 - movs r2, 0x2 - movs r3, 0 - bl sub_817E684 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0817D08C - bl _0817E0A6 -_0817D08C: - bl sub_817EECC - bl _0817E0A6 - .pool -_0817D098: - movs r0, 0x1 - mov r1, r10 - movs r2, 0x1 - movs r3, 0 - bl sub_817E684 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0817D0B4 - bl _0817E0A6 -_0817D0B4: - ldr r0, [sp, 0xC] - movs r1, 0x39 - movs r2, 0 - bl GetMonData - cmp r0, 0 - bne _0817D0C6 - bl _0817E0A6 -_0817D0C6: - bl sub_817EECC - bl _0817E0A6 - .pool -_0817D0D4: - movs r0, 0x1 - mov r1, r10 - movs r2, 0 - b _0817D48E -_0817D0DC: - lsls r3, r4, 1 - adds r3, r4 - lsls r3, 2 - adds r3, r7, r3 - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - adds r0, 0x1 - movs r1, 0x7 - ands r0, r1 - lsls r0, 15 - ldr r1, [r3, 0x50] - ldr r2, =0xfffc7fff - ands r1, r2 - orrs r1, r0 - str r1, [r3, 0x50] - adds r3, 0x55 - movs r0, 0x3 - mov r1, r10 - ands r1, r0 - lsls r1, 2 - ldrb r2, [r3] - movs r0, 0xD - negs r0, r0 - bl _0817DC0C - .pool -_0817D124: - lsls r2, r4, 1 - adds r2, r4 - lsls r2, 2 - adds r2, r7, r2 - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - adds r1, 0x1 - adds r4, r2, 0 - adds r4, 0x52 - movs r0, 0x7 - ands r1, r0 - lsls r1, 2 - ldrb r3, [r4] - movs r0, 0x1D - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r4] - adds r2, 0x55 - movs r0, 0x3 - mov r1, r10 - ands r1, r0 - lsls r1, 4 - ldrb r3, [r2] - movs r0, 0x31 - negs r0, r0 - bl _0817DFAA - .pool -_0817D16C: - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 2 - adds r5, r7, r0 - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - adds r1, 0x1 - adds r3, r5, 0 - adds r3, 0x52 - lsls r1, 5 - ldrb r2, [r3] - movs r0, 0x1F - ands r0, r2 - orrs r0, r1 - strb r0, [r3] - adds r4, r5, 0 - adds r4, 0x55 - mov r0, r10 - lsls r2, r0, 6 - ldrb r1, [r4] - movs r0, 0x3F - ands r0, r1 - orrs r0, r2 - strb r0, [r4] - adds r2, r5, 0 - adds r2, 0x58 - ldrb r0, [r2] - movs r1, 0x40 - bl _0817DFAC - .pool -_0817D1B8: - ldr r1, =gBattleTextBuff1 + 4 - ldrb r0, [r1] - cmp r0, 0 - beq _0817D1C4 - bl _0817E0A6 -_0817D1C4: - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 2 - adds r0, r7, r0 - adds r0, 0x57 - ldrb r2, [r0] - movs r1, 0x1F - negs r1, r1 - ands r1, r2 - movs r2, 0x14 - bl _0817E0A2 - .pool -_0817D1E0: - lsls r0, r6, 1 - adds r0, r6 - lsls r0, 2 - adds r3, r7, r0 - adds r0, r3, 0 - adds r0, 0x53 - ldrb r0, [r0] - lsls r0, 29 - lsrs r0, 29 - cmp r0, 0 - bne _0817D1FA - bl _0817E0A6 -_0817D1FA: - adds r2, r6, 0 - subs r1, r0, 0x1 - lsls r1, 2 - adds r0, r3, 0 - adds r0, 0x56 - ldrb r3, [r0] - lsls r3, 30 - lsrs r3, 30 - adds r3, r1 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x2 - bl _0817DB10 -_0817D216: - lsls r2, r4, 1 - adds r2, r4 - lsls r2, 2 - adds r2, r7, r2 - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - adds r1, 0x1 - adds r4, r2, 0 - adds r4, 0x53 - movs r0, 0x7 - ands r1, r0 - lsls r1, 3 - ldrb r3, [r4] - movs r0, 0x39 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r4] - adds r2, 0x56 - movs r0, 0x3 - mov r1, r10 - ands r1, r0 - lsls r1, 2 - ldrb r3, [r2] - movs r0, 0xD - negs r0, r0 - bl _0817DFAA - .pool -_0817D260: - lsls r0, r6, 1 - adds r0, r6 - lsls r0, 2 - adds r3, r7, r0 - adds r0, r3, 0 - adds r0, 0x53 - ldrb r0, [r0] - lsls r0, 26 - lsrs r0, 29 - cmp r0, 0 - bne _0817D27A - bl _0817E0A6 -_0817D27A: - adds r2, r6, 0 - subs r1, r0, 0x1 - lsls r1, 2 - adds r0, r3, 0 - adds r0, 0x56 - ldrb r3, [r0] - lsls r3, 28 - lsrs r3, 30 - adds r3, r1 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x2 - bl _0817DBC2 -_0817D296: - lsls r2, r4, 1 - adds r2, r4 - lsls r2, 2 - adds r2, r7, r2 - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - adds r1, 0x1 - adds r2, 0x56 - movs r0, 0x7 - ands r1, r0 - lsls r1, 4 - ldrb r3, [r2] - movs r0, 0x71 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2] - movs r0, 0x3 - mov r1, r10 - ands r1, r0 - lsls r1, 7 - ldrh r3, [r2] - ldr r0, =0xfffffe7f - ands r0, r3 - orrs r0, r1 - strh r0, [r2] - bl _0817E0A6 - .pool -_0817D2E4: - lsls r0, r6, 1 - adds r0, r6 - lsls r0, 2 - adds r0, r7, r0 - adds r0, 0x56 - ldrb r0, [r0] - lsls r0, 25 - lsrs r0, 29 - cmp r0, 0 - bne _0817D2FC - bl _0817E0A6 -_0817D2FC: - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 2 - adds r0, r7, r0 - adds r0, 0x57 - ldrb r2, [r0] - movs r1, 0x1F - negs r1, r1 - ands r1, r2 - movs r2, 0x16 - bl _0817E0A2 -_0817D314: - mov r2, r8 - lsls r3, r2, 3 - lsls r0, r4, 4 - adds r3, r0 - adds r3, r7, r3 - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - adds r1, 0x1 - adds r3, 0x35 - movs r0, 0x7 - ands r1, r0 - ldrb r2, [r3] - movs r0, 0x8 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - movs r2, 0x3 - mov r1, r10 - ands r1, r2 - lsls r1, 3 - movs r2, 0x19 - negs r2, r2 - bl _0817DC0C - .pool -_0817D354: - mov r1, r8 - lsls r0, r1, 3 - lsls r1, r4, 4 - adds r0, r1 - adds r0, r7, r0 - adds r0, 0x35 - ldrb r1, [r0] - lsls r0, r1, 29 - lsrs r0, 29 - cmp r0, 0 - bne _0817D36E - bl _0817E0A6 -_0817D36E: - adds r2, r4, 0 - b _0817D38C -_0817D372: - lsls r0, r5, 3 - lsls r1, r6, 4 - adds r0, r1 - adds r0, r7, r0 - adds r0, 0x35 - ldrb r1, [r0] - lsls r0, r1, 29 - lsrs r0, 29 - cmp r0, 0 - bne _0817D38A - bl _0817E0A6 -_0817D38A: - adds r2, r6, 0 -_0817D38C: - subs r0, 0x1 - lsls r0, 2 - lsls r3, r1, 27 - lsrs r3, 30 - adds r3, r0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x2 - movs r1, 0x6 - bl sub_817E684 - bl _0817E0A6 -_0817D3A6: - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0xB3 - movs r1, 0x1 - bl _0817E0A4 - .pool -_0817D3B8: - movs r0, 0x12 - mov r1, r10 - movs r2, 0 - b _0817D48E -_0817D3C0: - ldr r0, =gBattleTextBuff1 - ldrb r2, [r0, 0x2] - cmp r2, 0 - bne _0817D3CC - bl _0817E0A6 -_0817D3CC: - ldr r1, =gBattleTextBuff2 + 2 - ldrh r0, [r1] - cmp r0, 0xD1 - bne _0817D3E8 - subs r2, 0x1 - lsls r2, 24 - lsrs r2, 24 - movs r0, 0x17 - b _0817D48C - .pool -_0817D3E8: - subs r2, 0x1 - lsls r2, 24 - lsrs r2, 24 - movs r0, 0x16 - b _0817D48C -_0817D3F2: - ldr r0, =gBattleTextBuff1 - ldrb r2, [r0, 0x2] - cmp r2, 0 - bne _0817D3FE - bl _0817E0A6 -_0817D3FE: - ldr r0, =gBattlerAttacker - ldr r1, =gBattlerTarget - ldrb r0, [r0] - ldrb r1, [r1] - cmp r0, r1 - bne _0817D436 - ldr r1, =gBattleTextBuff2 + 2 - ldrh r0, [r1] - cmp r0, 0xD1 - bne _0817D42C - subs r2, 0x1 - lsls r2, 24 - lsrs r2, 24 - movs r0, 0x17 - b _0817D48C - .pool -_0817D42C: - subs r2, 0x1 - lsls r2, 24 - lsrs r2, 24 - movs r0, 0x16 - b _0817D48C -_0817D436: - subs r2, 0x1 - lsls r2, 24 - lsrs r2, 24 - movs r0, 0x1B - b _0817D48C -_0817D440: - ldr r0, =gBattleTextBuff1 - ldrb r2, [r0, 0x2] - cmp r2, 0 - bne _0817D44C - bl _0817E0A6 -_0817D44C: - subs r2, 0x1 - lsls r2, 24 - lsrs r2, 24 - movs r0, 0x18 - b _0817D48C - .pool -_0817D45C: - ldr r0, =gBattleTextBuff1 - ldrb r2, [r0, 0x2] - cmp r2, 0 - bne _0817D468 - bl _0817E0A6 -_0817D468: - ldr r1, =gBattleTextBuff2 + 2 - ldrh r0, [r1] - cmp r0, 0xD3 - bne _0817D484 - subs r2, 0x1 - lsls r2, 24 - lsrs r2, 24 - movs r0, 0x1A - b _0817D48C - .pool -_0817D484: - subs r2, 0x1 - lsls r2, 24 - lsrs r2, 24 - movs r0, 0x19 -_0817D48C: - mov r1, r10 -_0817D48E: - movs r3, 0 - bl sub_817E684 - bl _0817E0A6 -_0817D498: - lsls r2, r5, 3 - lsls r0, r6, 4 - adds r2, r0 - adds r2, r7, r2 - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - adds r1, 0x1 - adds r4, r2, 0 - adds r4, 0x30 - movs r0, 0x7 - ands r1, r0 - ldrb r3, [r4] - movs r0, 0x8 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r4] - adds r2, 0x32 - movs r0, 0x3 - mov r1, r10 - ands r1, r0 - lsls r1, 2 - ldrb r3, [r2] - movs r0, 0xD - negs r0, r0 - bl _0817DFAA - .pool -_0817D4E0: - ldr r0, [sp, 0x8] - movs r1, 0x39 - movs r2, 0 - bl GetMonData - cmp r0, 0 - bne _0817D4F2 - bl _0817E0A6 -_0817D4F2: - mov r2, r8 - lsls r0, r2, 3 - lsls r1, r4, 4 - adds r0, r1 - adds r1, r7, r0 - adds r0, r1, 0 - adds r0, 0x30 - ldrb r0, [r0] - lsls r0, 29 - lsrs r0, 29 - cmp r0, 0 - bne _0817D50E - bl _0817E0A6 -_0817D50E: - subs r2, r0, 0x1 - lsls r2, 24 - lsrs r2, 24 - adds r0, r1, 0 - adds r0, 0x32 - ldrb r3, [r0] - lsls r3, 28 - lsrs r3, 30 - movs r0, 0x8 - movs r1, 0 - bl sub_817E684 - lsls r1, r4, 1 - adds r1, r4 - lsls r1, 2 - adds r1, r7, r1 - adds r1, 0x57 - ldrb r2, [r1] - movs r0, 0x1F - negs r0, r0 - ands r0, r2 - movs r2, 0x2 - b _0817D6F2 -_0817D53C: - lsls r2, r5, 3 - lsls r0, r6, 4 - adds r2, r0 - adds r2, r7, r2 - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - adds r1, 0x1 - adds r4, r2, 0 - adds r4, 0x30 - movs r0, 0x7 - ands r1, r0 - lsls r1, 3 - ldrb r3, [r4] - movs r0, 0x39 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r4] - adds r2, 0x32 - movs r0, 0x3 - mov r1, r10 - ands r1, r0 - lsls r1, 4 - ldrb r3, [r2] - movs r0, 0x31 - negs r0, r0 - bl _0817DFAA - .pool -_0817D584: - mov r1, r8 - lsls r0, r1, 3 - lsls r1, r4, 4 - adds r0, r1 - adds r1, r7, r0 - adds r0, r1, 0 - adds r0, 0x30 - ldrb r0, [r0] - lsls r0, 26 - lsrs r0, 29 - cmp r0, 0 - bne _0817D5A0 - bl _0817E0A6 -_0817D5A0: - subs r2, r0, 0x1 - lsls r2, 24 - lsrs r2, 24 - adds r0, r1, 0 - adds r0, 0x32 - ldrb r3, [r0] - lsls r3, 26 - lsrs r3, 30 - movs r0, 0x8 - movs r1, 0x1 - bl sub_817E684 - lsls r1, r4, 1 - adds r1, r4 - lsls r1, 2 - adds r1, r7, r1 - adds r1, 0x57 - ldrb r2, [r1] - movs r0, 0x1F - negs r0, r0 - ands r0, r2 - movs r2, 0x4 - b _0817D6F2 -_0817D5CE: - lsls r2, r5, 3 - lsls r0, r6, 4 - adds r2, r0 - adds r2, r7, r2 - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - adds r1, 0x1 - movs r0, 0x7 - ands r1, r0 - lsls r1, 6 - ldrh r3, [r2, 0x30] - ldr r0, =0xfffffe3f - ands r0, r3 - orrs r0, r1 - strh r0, [r2, 0x30] - adds r2, 0x32 - bl _0817DF0A - .pool -_0817D608: - ldr r0, [sp, 0x8] - movs r1, 0x39 - movs r2, 0 - bl GetMonData - cmp r0, 0 - bne _0817D61A - bl _0817E0A6 -_0817D61A: - mov r1, r8 - lsls r0, r1, 3 - lsls r1, r4, 4 - adds r0, r1 - adds r1, r7, r0 - ldrh r0, [r1, 0x30] - lsls r0, 23 - lsrs r0, 29 - cmp r0, 0 - bne _0817D632 - bl _0817E0A6 -_0817D632: - subs r2, r0, 0x1 - lsls r2, 24 - lsrs r2, 24 - adds r0, r1, 0 - adds r0, 0x32 - ldrb r3, [r0] - lsrs r3, 6 - movs r0, 0x8 - movs r1, 0x5 - bl sub_817E684 - lsls r1, r4, 1 - adds r1, r4 - lsls r1, 2 - adds r1, r7, r1 - adds r1, 0x57 - ldrb r2, [r1] - movs r0, 0x1F - negs r0, r0 - ands r0, r2 - movs r2, 0xA - b _0817D6F2 -_0817D65E: - lsls r2, r5, 3 - lsls r0, r6, 4 - adds r2, r0 - adds r2, r7, r2 - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - adds r1, 0x1 - adds r4, r2, 0 - adds r4, 0x31 - movs r0, 0x7 - ands r1, r0 - lsls r1, 1 - ldrb r3, [r4] - movs r0, 0xF - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r4] - adds r2, 0x33 - bl _0817DF9E - .pool -_0817D698: - ldr r0, [sp, 0x8] - movs r1, 0x39 - movs r2, 0 - bl GetMonData - cmp r0, 0 - bne _0817D6AA - bl _0817E0A6 -_0817D6AA: - mov r1, r8 - lsls r0, r1, 3 - lsls r1, r4, 4 - adds r0, r1 - adds r1, r7, r0 - adds r0, r1, 0 - adds r0, 0x31 - ldrb r0, [r0] - lsls r0, 28 - lsrs r0, 29 - cmp r0, 0 - bne _0817D6C6 - bl _0817E0A6 -_0817D6C6: - subs r2, r0, 0x1 - lsls r2, 24 - lsrs r2, 24 - adds r0, r1, 0 - adds r0, 0x33 - ldrb r3, [r0] - lsls r3, 30 - lsrs r3, 30 - movs r0, 0x8 - movs r1, 0x6 - bl sub_817E684 - lsls r1, r4, 1 - adds r1, r4 - lsls r1, 2 - adds r1, r7, r1 - adds r1, 0x57 - ldrb r2, [r1] - movs r0, 0x1F - negs r0, r0 - ands r0, r2 - movs r2, 0xC -_0817D6F2: - orrs r0, r2 - mov r2, r8 - lsls r3, r2, 5 - movs r2, 0x1F - ands r0, r2 - orrs r0, r3 - strb r0, [r1] - bl _0817E0A6 -_0817D704: - ldr r5, =gBattlerPartyIndexes - ldr r6, =gEffectBattler - ldrb r0, [r6] - lsls r0, 1 - adds r0, r5 - ldrh r2, [r0] - lsls r2, 2 - mov r0, r9 - lsls r4, r0, 1 - add r4, r9 - lsls r4, 3 - adds r2, r4 - adds r2, r7, r2 - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r5 - ldrh r1, [r0] - adds r1, 0x1 - movs r0, 0x7 - ands r1, r0 - lsls r1, 6 - ldrh r3, [r2] - ldr r0, =0xfffffe3f - ands r0, r3 - orrs r0, r1 - strh r0, [r2] - ldrb r0, [r6] - lsls r0, 1 - adds r0, r5 - ldrh r1, [r0] - lsls r1, 2 - adds r1, r4 - adds r1, r7, r1 - mov r2, r10 - lsls r3, r2, 6 - ldrb r2, [r1, 0x2] - movs r0, 0x3F - ands r0, r2 - orrs r0, r3 - strb r0, [r1, 0x2] - bl _0817E0A6 - .pool -_0817D76C: - ldr r0, [sp, 0x8] - movs r1, 0x39 - movs r2, 0 - bl GetMonData - cmp r0, 0 - bne _0817D77E - bl _0817E0A6 -_0817D77E: - ldr r6, =gBattlerPartyIndexes - ldr r5, =gBattlerAttacker - ldrb r0, [r5] - lsls r0, 1 - adds r0, r6 - ldrh r0, [r0] - lsls r0, 2 - lsls r1, r4, 1 - adds r4, r1, r4 - lsls r1, r4, 3 - adds r0, r1 - adds r1, r7, r0 - ldrh r0, [r1] - lsls r0, 23 - lsrs r0, 29 - cmp r0, 0 - beq _0817D7B2 - subs r2, r0, 0x1 - lsls r2, 24 - lsrs r2, 24 - ldrb r3, [r1, 0x2] - lsrs r3, 6 - movs r0, 0x8 - movs r1, 0x4 - bl sub_817E684 -_0817D7B2: - lsls r3, r4, 2 - adds r3, r7, r3 - adds r3, 0x57 - ldrb r0, [r3] - movs r1, 0x1F - negs r1, r1 - ands r1, r0 - movs r0, 0x8 - orrs r1, r0 - strb r1, [r3] - ldrb r0, [r5] - lsls r0, 1 - adds r0, r6 - b _0817D934 - .pool -_0817D7D8: - ldr r5, =gBattlerPartyIndexes - ldr r6, =gEffectBattler - ldrb r0, [r6] - lsls r0, 1 - adds r0, r5 - ldrh r2, [r0] - lsls r2, 2 - mov r0, r9 - lsls r4, r0, 1 - add r4, r9 - lsls r4, 3 - adds r2, r4 - adds r2, r7, r2 - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r5 - ldrh r1, [r0] - adds r1, 0x1 - movs r0, 0x7 - ands r1, r0 - ldrb r3, [r2] - movs r0, 0x8 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2] - ldrb r0, [r6] - lsls r0, 1 - adds r0, r5 - ldrh r1, [r0] - lsls r1, 2 - adds r1, r4 - adds r1, r7, r1 - movs r0, 0x3 - mov r2, r10 - ands r2, r0 - lsls r2, 2 - ldrb r3, [r1, 0x2] - movs r0, 0xD - negs r0, r0 - b _0817D88C - .pool -_0817D838: - ldr r5, =gBattlerPartyIndexes - ldr r6, =gEffectBattler - ldrb r0, [r6] - lsls r0, 1 - adds r0, r5 - ldrh r2, [r0] - lsls r2, 2 - mov r1, r9 - lsls r4, r1, 1 - add r4, r9 - lsls r4, 3 - adds r2, r4 - adds r2, r7, r2 - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r5 - ldrh r1, [r0] - adds r1, 0x1 - movs r0, 0x7 - ands r1, r0 - lsls r1, 3 - ldrb r3, [r2] - movs r0, 0x39 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2] - ldrb r0, [r6] - lsls r0, 1 - adds r0, r5 - ldrh r1, [r0] - lsls r1, 2 - adds r1, r4 - adds r1, r7, r1 - movs r0, 0x3 - mov r2, r10 - ands r2, r0 - lsls r2, 4 - ldrb r3, [r1, 0x2] - movs r0, 0x31 - negs r0, r0 -_0817D88C: - ands r0, r3 - orrs r0, r2 - strb r0, [r1, 0x2] - bl _0817E0A6 - .pool -_0817D8A4: - ldr r0, [sp, 0x8] - movs r1, 0x39 - movs r2, 0 - bl GetMonData - cmp r0, 0 - bne _0817D8B6 - bl _0817E0A6 -_0817D8B6: - ldr r2, =gBattlerPartyIndexes - mov r8, r2 - ldr r6, =gBattlerAttacker - ldrb r0, [r6] - lsls r0, 1 - add r0, r8 - ldrh r0, [r0] - lsls r0, 2 - lsls r1, r4, 1 - adds r5, r1, r4 - lsls r4, r5, 3 - adds r0, r4 - adds r1, r7, r0 - ldrb r0, [r1] - lsls r0, 29 - lsrs r0, 29 - cmp r0, 0 - beq _0817D8EE - subs r2, r0, 0x1 - lsls r2, 24 - lsrs r2, 24 - ldrb r3, [r1, 0x2] - lsls r3, 28 - lsrs r3, 30 - movs r0, 0x8 - movs r1, 0x2 - bl sub_817E684 -_0817D8EE: - ldrb r0, [r6] - lsls r0, 1 - add r0, r8 - ldrh r0, [r0] - lsls r0, 2 - adds r0, r4 - adds r1, r7, r0 - ldrb r0, [r1] - lsls r0, 26 - lsrs r0, 29 - cmp r0, 0 - beq _0817D91A - subs r2, r0, 0x1 - lsls r2, 24 - lsrs r2, 24 - ldrb r3, [r1, 0x2] - lsls r3, 26 - lsrs r3, 30 - movs r0, 0x8 - movs r1, 0x3 - bl sub_817E684 -_0817D91A: - lsls r3, r5, 2 - adds r3, r7, r3 - adds r3, 0x57 - ldrb r0, [r3] - movs r1, 0x1F - negs r1, r1 - ands r1, r0 - movs r0, 0x6 - orrs r1, r0 - strb r1, [r3] - ldrb r0, [r6] - lsls r0, 1 - add r0, r8 -_0817D934: - ldrh r0, [r0] - lsls r0, 5 - movs r2, 0x1F - ands r1, r2 - orrs r1, r0 - strb r1, [r3] - b _0817E0A6 - .pool -_0817D94C: - lsls r2, r5, 3 - lsls r0, r6, 4 - adds r2, r0 - adds r2, r7, r2 - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - adds r1, 0x1 - adds r4, r2, 0 - adds r4, 0x31 - movs r0, 0x7 - ands r1, r0 - lsls r1, 4 - ldrb r3, [r4] - movs r0, 0x71 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r4] - adds r2, 0x33 - movs r0, 0x3 - mov r1, r10 - ands r1, r0 - lsls r1, 2 - ldrb r3, [r2] - movs r0, 0xD - negs r0, r0 - b _0817DFAA - .pool -_0817D994: - mov r1, r8 - lsls r0, r1, 3 - lsls r1, r4, 4 - adds r0, r1 - adds r1, r7, r0 - adds r0, r1, 0 - adds r0, 0x31 - ldrb r0, [r0] - lsls r0, 25 - lsrs r0, 29 - cmp r0, 0 - bne _0817D9AE - b _0817E0A6 -_0817D9AE: - subs r2, r0, 0x1 - lsls r2, 24 - lsrs r2, 24 - adds r0, r1, 0 - adds r0, 0x33 - ldrb r3, [r0] - lsls r3, 28 - lsrs r3, 30 - movs r0, 0x9 - b _0817E086 -_0817D9C2: - ldr r5, =gBattlerPartyIndexes - ldr r6, =gEffectBattler - ldrb r0, [r6] - lsls r0, 1 - adds r0, r5 - ldrh r2, [r0] - lsls r2, 2 - mov r0, r9 - lsls r4, r0, 1 - add r4, r9 - lsls r4, 3 - adds r2, r4 - adds r2, r7, r2 - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r5 - ldrh r1, [r0] - adds r1, 0x1 - movs r0, 0x7 - ands r1, r0 - lsls r1, 1 - ldrb r3, [r2, 0x1] - movs r0, 0xF - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0x1] - ldrb r0, [r6] - lsls r0, 1 - adds r0, r5 - ldrh r1, [r0] - lsls r1, 2 - adds r1, r4 - adds r1, r7, r1 - movs r0, 0x3 - mov r2, r10 - ands r2, r0 - ldrb r3, [r1, 0x3] - movs r0, 0x4 - negs r0, r0 - b _0817DB76 - .pool -_0817DA24: - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - lsls r1, 2 - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 3 - adds r1, r0 - adds r1, r7, r1 - ldrb r0, [r1, 0x1] - lsls r0, 28 - lsrs r0, 29 - cmp r0, 0 - bne _0817DA48 - b _0817E0A6 -_0817DA48: - subs r2, r0, 0x1 - lsls r2, 24 - lsrs r2, 24 - ldrb r3, [r1, 0x3] - lsls r3, 30 - lsrs r3, 30 - movs r0, 0x9 - movs r1, 0x2 - bl sub_817E684 - b _0817E0A6 - .pool -_0817DA68: - ldr r5, =gBattlerPartyIndexes - ldr r6, =gEffectBattler - ldrb r0, [r6] - lsls r0, 1 - adds r0, r5 - ldrh r2, [r0] - lsls r2, 2 - mov r1, r9 - lsls r4, r1, 1 - add r4, r9 - lsls r4, 3 - adds r2, r4 - adds r2, r7, r2 - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r5 - ldrh r1, [r0] - adds r1, 0x1 - movs r0, 0x7 - ands r1, r0 - lsls r1, 4 - ldrb r3, [r2, 0x1] - movs r0, 0x71 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0x1] - ldrb r0, [r6] - lsls r0, 1 - adds r0, r5 - ldrh r1, [r0] - lsls r1, 2 - adds r1, r4 - adds r1, r7, r1 - movs r0, 0x3 - mov r2, r10 - ands r2, r0 - lsls r2, 2 - ldrb r3, [r1, 0x3] - movs r0, 0xD - negs r0, r0 - b _0817DB76 - .pool -_0817DACC: - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - lsls r1, 2 - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 3 - adds r1, r0 - adds r1, r7, r1 - ldrb r0, [r1, 0x1] - lsls r0, 25 - lsrs r2, r0, 29 - cmp r2, 0 - bne _0817DAF0 - b _0817E0A6 -_0817DAF0: - ldr r0, =gStringInfo - ldr r0, [r0] - ldrh r0, [r0] - cmp r0, 0xAD - bne _0817DAFC - b _0817E0A6 -_0817DAFC: - cmp r0, 0xD6 - bne _0817DB02 - b _0817E0A6 -_0817DB02: - subs r2, 0x1 - lsls r2, 24 - lsrs r2, 24 - ldrb r3, [r1, 0x3] - lsls r3, 28 - lsrs r3, 30 - movs r0, 0x9 -_0817DB10: - movs r1, 0x3 - bl sub_817E684 - b _0817E0A6 - .pool -_0817DB24: - ldr r5, =gBattlerPartyIndexes - ldr r6, =gEffectBattler - ldrb r0, [r6] - lsls r0, 1 - adds r0, r5 - ldrh r3, [r0] - lsls r3, 2 - mov r2, r9 - lsls r4, r2, 1 - add r4, r9 - lsls r4, 3 - adds r3, r4 - adds r3, r7, r3 - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r5 - ldrh r0, [r0] - adds r0, 0x1 - movs r1, 0x7 - ands r0, r1 - lsls r0, 15 - ldr r1, [r3] - ldr r2, =0xfffc7fff - ands r1, r2 - orrs r1, r0 - str r1, [r3] - ldrb r0, [r6] - lsls r0, 1 - adds r0, r5 - ldrh r1, [r0] - lsls r1, 2 - adds r1, r4 - adds r1, r7, r1 - movs r0, 0x3 - mov r2, r10 - ands r2, r0 - lsls r2, 4 - ldrb r3, [r1, 0x3] - movs r0, 0x31 - negs r0, r0 -_0817DB76: - ands r0, r3 - orrs r0, r2 - strb r0, [r1, 0x3] - b _0817E0A6 - .pool -_0817DB90: - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - lsls r1, 2 - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 3 - adds r1, r0 - adds r1, r7, r1 - ldr r0, [r1] - lsls r0, 14 - lsrs r0, 29 - cmp r0, 0 - bne _0817DBB4 - b _0817E0A6 -_0817DBB4: - subs r2, r0, 0x1 - lsls r2, 24 - lsrs r2, 24 - ldrb r3, [r1, 0x3] - lsls r3, 26 - lsrs r3, 30 - movs r0, 0x9 -_0817DBC2: - movs r1, 0x4 - bl sub_817E684 - b _0817E0A6 - .pool -_0817DBD4: - lsls r3, 3 - mov r1, r9 - lsls r0, r1, 4 - adds r3, r0 - adds r3, r7, r3 - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - adds r0, 0x1 - movs r1, 0x7 - ands r0, r1 - lsls r0, 15 - ldr r1, [r3, 0x30] - ldr r2, =0xfffc7fff - ands r1, r2 - orrs r1, r0 - str r1, [r3, 0x30] - adds r3, 0x33 - movs r0, 0x3 - mov r1, r10 - ands r1, r0 - lsls r1, 4 - ldrb r2, [r3] - movs r0, 0x31 - negs r0, r0 -_0817DC0C: - ands r0, r2 - orrs r0, r1 - strb r0, [r3] - b _0817E0A6 - .pool -_0817DC20: - mov r2, r8 - lsls r0, r2, 3 - lsls r1, r4, 4 - adds r0, r1 - adds r3, r7, r0 - ldr r0, [r3, 0x30] - lsls r0, 14 - lsrs r0, 29 - cmp r0, 0 - beq _0817DC4C - subs r2, r0, 0x1 - lsls r2, 24 - lsrs r2, 24 - adds r0, r3, 0 - adds r0, 0x33 - ldrb r3, [r0] - lsls r3, 26 - lsrs r3, 30 - movs r0, 0x9 - movs r1, 0x1 - bl sub_817E684 -_0817DC4C: - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 2 - adds r0, r7, r0 - adds r0, 0x57 - ldrb r2, [r0] - movs r1, 0x1F - negs r1, r1 - ands r1, r2 - movs r2, 0x18 - b _0817E0A2 -_0817DC62: - lsls r2, r6, 1 - adds r2, r6 - lsls r2, 2 - adds r2, r7, r2 - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - adds r1, 0x1 - adds r4, r2, 0 - adds r4, 0x50 - movs r0, 0x7 - ands r1, r0 - ldrb r3, [r4] - movs r0, 0x8 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r4] - adds r2, 0x54 - b _0817DF9E - .pool -_0817DC98: - ldr r1, [sp, 0x4] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r4, r7, r0 - adds r0, r4, 0 - adds r0, 0x50 - ldrb r0, [r0] - lsls r0, 29 - lsrs r2, r0, 29 - cmp r2, 0 - bne _0817DCB2 - b _0817E0A6 -_0817DCB2: - movs r0, 0x1 - eors r1, r0 - subs r2, 0x1 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r0, 0x54 - ldrb r3, [r0] - lsls r3, 30 - lsrs r3, 30 - movs r0, 0xA - bl sub_817E684 - adds r2, r4, 0 - adds r2, 0x57 - ldrb r1, [r2] - movs r0, 0x1F - negs r0, r0 - ands r0, r1 - movs r1, 0xE - b _0817DFAC -_0817DCDC: - lsls r1, r4, 1 - adds r1, r4 - lsls r1, 2 - adds r1, r7, r1 - adds r3, r1, 0 - adds r3, 0x50 - ldrb r2, [r3] - movs r0, 0x8 - negs r0, r0 - ands r0, r2 - strb r0, [r3] - adds r1, 0x54 - ldrb r2, [r1] - movs r0, 0x4 - negs r0, r0 - b _0817DF6A -_0817DCFC: - mov r0, r8 - lsls r2, r0, 3 - lsls r0, r4, 4 - adds r2, r0 - adds r2, r7, r2 - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - adds r1, 0x1 - adds r4, r2, 0 - adds r4, 0x34 - movs r0, 0x7 - ands r1, r0 - ldrb r3, [r4] - movs r0, 0x8 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r4] - adds r2, 0x33 - mov r1, r10 - lsls r3, r1, 6 - b _0817DF0E - .pool -_0817DD38: - mov r0, r8 - lsls r2, r0, 3 - lsls r0, r4, 4 - adds r2, r0 - adds r2, r7, r2 - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - adds r1, 0x1 - adds r2, 0x34 - movs r0, 0x7 - ands r1, r0 - lsls r1, 3 - ldrb r3, [r2] - movs r0, 0x39 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - mov r1, r10 - lsls r3, r1, 6 - movs r1, 0x3F - b _0817DF12 - .pool -_0817DD74: - movs r0, 0 - bl sub_817EA80 -_0817DD7A: - mov r2, r8 - lsls r0, r2, 3 - b _0817DD88 -_0817DD80: - movs r0, 0x1 - bl sub_817EA80 - lsls r0, r5, 3 -_0817DD88: - lsls r1, r4, 4 - adds r0, r1 - adds r1, r7, r0 - adds r4, r1, 0 - adds r4, 0x34 - ldrb r5, [r4] - lsls r0, r5, 29 - cmp r0, 0 - beq _0817DDAE - movs r0, 0x8 - negs r0, r0 - ands r0, r5 - strb r0, [r4] - adds r2, r1, 0 - adds r2, 0x33 - ldrb r1, [r2] - movs r0, 0x3F - ands r0, r1 - strb r0, [r2] -_0817DDAE: - ldrb r1, [r4] - lsls r0, r1, 26 - lsrs r0, 29 - cmp r0, 0 - bne _0817DDBA - b _0817E0A6 -_0817DDBA: - movs r0, 0x39 - negs r0, r0 - ands r0, r1 - movs r1, 0x3F - ands r0, r1 - strb r0, [r4] - b _0817E0A6 -_0817DDC8: - lsls r2, r4, 1 - adds r2, r4 - lsls r2, 2 - adds r2, r7, r2 - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - adds r1, 0x1 - adds r4, r2, 0 - adds r4, 0x50 - movs r0, 0x7 - ands r1, r0 - lsls r1, 3 - ldrb r3, [r4] - movs r0, 0x39 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r4] - adds r2, 0x54 - movs r0, 0x3 - mov r1, r10 - ands r1, r0 - lsls r1, 2 - ldrb r3, [r2] - movs r0, 0xD - negs r0, r0 - b _0817DFAA - .pool -_0817DE10: - lsls r2, r4, 1 - adds r2, r4 - lsls r2, 2 - adds r2, r7, r2 - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - adds r1, 0x1 - adds r4, r2, 0 - adds r4, 0x50 - movs r0, 0x7 - ands r1, r0 - lsls r1, 6 - ldrh r3, [r4] - ldr r0, =0xfffffe3f - ands r0, r3 - orrs r0, r1 - strh r0, [r4] - adds r2, 0x54 - movs r0, 0x3 - mov r1, r10 - ands r1, r0 - lsls r1, 4 - ldrb r3, [r2] - movs r0, 0x31 - negs r0, r0 - b _0817DFAA - .pool -_0817DE58: - ldr r1, =gBattleTextBuff1 + 2 - ldrh r0, [r1] - cmp r0, 0x73 - bne _0817DE82 - lsls r1, r4, 1 - adds r1, r4 - lsls r1, 2 - adds r1, r7, r1 - adds r3, r1, 0 - adds r3, 0x50 - ldrb r2, [r3] - movs r0, 0x39 - negs r0, r0 - ands r0, r2 - strb r0, [r3] - adds r1, 0x54 - ldrb r2, [r1] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - strb r0, [r1] -_0817DE82: - ldr r2, =gBattleTextBuff1 + 2 - ldrh r0, [r2] - cmp r0, 0x71 - bne _0817DEAA - lsls r1, r4, 1 - adds r1, r4 - lsls r1, 2 - adds r1, r7, r1 - adds r3, r1, 0 - adds r3, 0x50 - ldrh r2, [r3] - ldr r0, =0xfffffe3f - ands r0, r2 - strh r0, [r3] - adds r1, 0x54 - ldrb r2, [r1] - movs r0, 0x31 - negs r0, r0 - ands r0, r2 - strb r0, [r1] -_0817DEAA: - ldr r1, =gBattleTextBuff1 + 2 - ldrh r0, [r1] - cmp r0, 0x36 - beq _0817DEB4 - b _0817E0A6 -_0817DEB4: - lsls r1, r4, 1 - adds r1, r4 - lsls r1, 2 - adds r1, r7, r1 - adds r4, r1, 0 - adds r4, 0x51 - ldrb r2, [r4] - movs r0, 0x71 - negs r0, r0 - ands r0, r2 - strb r0, [r4] - adds r1, 0x55 - ldrb r2, [r1] - movs r0, 0x4 - negs r0, r0 - b _0817DF6A - .pool -_0817DEDC: - lsls r2, r4, 1 - adds r2, r4 - lsls r2, 2 - adds r2, r7, r2 - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - adds r1, 0x1 - adds r4, r2, 0 - adds r4, 0x51 - movs r0, 0x7 - ands r1, r0 - lsls r1, 1 - ldrb r3, [r4] - movs r0, 0xF - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r4] - adds r2, 0x54 -_0817DF0A: - mov r0, r10 - lsls r3, r0, 6 -_0817DF0E: - ldrb r1, [r2] - movs r0, 0x3F -_0817DF12: - ands r0, r1 - orrs r0, r3 - strb r0, [r2] - b _0817E0A6 - .pool -_0817DF24: - lsls r0, r6, 1 - adds r0, r6 - lsls r0, 2 - adds r1, r7, r0 - adds r0, r1, 0 - adds r0, 0x51 - ldrb r0, [r0] - lsls r0, 28 - lsrs r0, 29 - cmp r0, 0 - bne _0817DF3C - b _0817E0A6 -_0817DF3C: - subs r2, r0, 0x1 - lsls r2, 24 - lsrs r2, 24 - adds r0, r1, 0 - adds r0, 0x54 - ldrb r3, [r0] - lsrs r3, 6 - movs r0, 0xF - b _0817E086 -_0817DF4E: - lsls r1, r4, 1 - adds r1, r4 - lsls r1, 2 - adds r1, r7, r1 - adds r4, r1, 0 - adds r4, 0x51 - ldrb r2, [r4] - movs r0, 0xF - negs r0, r0 - ands r0, r2 - strb r0, [r4] - adds r1, 0x54 - ldrb r2, [r1] - movs r0, 0x3F -_0817DF6A: - ands r0, r2 - strb r0, [r1] - b _0817E0A6 -_0817DF70: - lsls r2, r4, 1 - adds r2, r4 - lsls r2, 2 - adds r2, r7, r2 - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - adds r1, 0x1 - adds r4, r2, 0 - adds r4, 0x51 - movs r0, 0x7 - ands r1, r0 - lsls r1, 4 - ldrb r3, [r4] - movs r0, 0x71 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r4] - adds r2, 0x55 -_0817DF9E: - movs r0, 0x3 - mov r1, r10 - ands r1, r0 - ldrb r3, [r2] - movs r0, 0x4 - negs r0, r0 -_0817DFAA: - ands r0, r3 -_0817DFAC: - orrs r0, r1 - strb r0, [r2] - b _0817E0A6 - .pool -_0817DFBC: - lsls r0, r6, 1 - adds r0, r6 - lsls r0, 2 - adds r1, r7, r0 - adds r0, r1, 0 - adds r0, 0x51 - ldrb r0, [r0] - lsls r0, 25 - lsrs r0, 29 - cmp r0, 0 - beq _0817E0A6 - subs r2, r0, 0x1 - lsls r2, 24 - lsrs r2, 24 - adds r0, r1, 0 - adds r0, 0x55 - ldrb r3, [r0] - lsls r3, 30 - lsrs r3, 30 - movs r0, 0x10 - b _0817E086 -_0817DFE6: - lsls r1, r6, 1 - adds r1, r6 - lsls r1, 2 - adds r1, r7, r1 - adds r3, r1, 0 - adds r3, 0x50 - ldrb r2, [r3] - movs r0, 0x39 - negs r0, r0 - ands r0, r2 - strb r0, [r3] - adds r1, 0x54 - ldrb r2, [r1] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - strb r0, [r1] - ldrh r2, [r3] - ldr r0, =0xfffffe3f - ands r0, r2 - strh r0, [r3] - ldrb r2, [r1] - movs r0, 0x31 - negs r0, r0 - ands r0, r2 - strb r0, [r1] - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrb r2, [r0] - movs r0, 0x11 - movs r1, 0 - mov r3, r10 - bl sub_817E684 - b _0817E0A6 - .pool -_0817E040: - lsls r0, r4, 4 - adds r4, r7, r0 - adds r0, r4, 0 - adds r0, 0x35 - ldrb r0, [r0] - lsrs r0, 5 - cmp r0, 0 - beq _0817E068 - subs r2, r0, 0x1 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r0, 0x36 - ldrb r3, [r0] - lsls r3, 30 - lsrs r3, 30 - movs r0, 0x15 - movs r1, 0 - bl sub_817E684 -_0817E068: - adds r0, r4, 0 - adds r0, 0x3D - ldrb r0, [r0] - lsrs r0, 5 - cmp r0, 0 - beq _0817E0A6 - subs r2, r0, 0x1 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r0, 0x3E - ldrb r3, [r0] - lsls r3, 30 - lsrs r3, 30 - movs r0, 0x15 -_0817E086: - movs r1, 0 - bl sub_817E684 - b _0817E0A6 -_0817E08E: - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 2 - adds r0, r7, r0 - adds r0, 0x57 - ldrb r2, [r0] - movs r1, 0x1F - negs r1, r1 - ands r1, r2 - movs r2, 0x1C -_0817E0A2: - orrs r1, r2 -_0817E0A4: - strb r1, [r0] -_0817E0A6: - add sp, 0x10 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_817C95C - thumb_func_start sub_817E0B8 sub_817E0B8: @ 817E0B8 push {r4-r6,lr} diff --git a/ld_script.txt b/ld_script.txt index 4ec960eb4..4ae3f183a 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -236,8 +236,8 @@ SECTIONS { src/evolution_graphics.o(.text); src/bard_music.o(.text); src/fldeff_teleport.o(.text); - asm/battle_link_817C95C.o(.text); src/battle_link_817C95C.o(.text); + asm/battle_link_817C95C.o(.text); src/pokemon_animation.o(.text); src/recorded_battle.o(.text); src/battle_controller_recorded_opponent.o(.text); diff --git a/src/battle_link_817C95C.c b/src/battle_link_817C95C.c index 25640b12c..9ac402a03 100644 --- a/src/battle_link_817C95C.c +++ b/src/battle_link_817C95C.c @@ -3,11 +3,16 @@ #include "battle.h" #include "battle_link_817C95C.h" #include "constants/battle_string_ids.h" +#include "constants/moves.h" #include "battle_message.h" -struct UnknownBattleLinkSubStruct1 +struct BattleLinkStringSide { - u32 field_8_0:15; + u32 field_8_0:3; // correct + u32 field_8_0_b:3; // correct + u32 field_8_0_c:3; // correct + u32 field_8_0_d:3; + u32 field_8_0_e:3; u32 field_8_1:3; // correct u32 field_8_2:3; // correct u32 field_8_3:3; // correct @@ -15,8 +20,11 @@ struct UnknownBattleLinkSubStruct1 u32 field_8_5:3; // correct u32 field_8_6:2; - u32 field_0_0a:3; // correct - u32 field_0_0b:7; + u32 field_0_0a:2; // correct + u32 field_0_0b:2; // correct + u32 field_0_0c:2; // correct + u32 field_0_0d:2; + u32 field_0_0e:2; u32 field_0_1:2; // correct u32 field_0_2:2; // correct u32 field_0_3:2; // correct @@ -34,73 +42,78 @@ struct UnknownBattleLinkSubStruct1 u32 field_5_0:3; // correct u32 field_5_1:2; // correct - u32 field_4_3:19; }; -struct UnknownBattleLinkSubStruct2 +struct BattleLinkStringPosition { u32 field_0_0:3; // correct u32 field_0_3:3; // correct u32 field_0_6:3; // correct u32 field_1_1:3; // correct - u32 field_1_4:4; - u32 field_2_0:2; + u32 field_1_4:3; // correct + u32 field_2_0:3; u32 field_2_3:2; // correct u32 field_2_5:2; // correct u32 field_2_7:2; // correct u32 field_3_0:2; // correct - u32 field_3_2:6; - u32 field_4:8; + u32 field_3_2:2; // correct + u32 field_3_4:2; + u32 field_3_6:2; + u32 field_4_0:3; + u32 field_4_3:3; + u32 field_4_6:2; u32 field_5_0:3; // correct u32 field_5_3:2; // correct - u32 field_5_5:2; - u32 field_5_7:1; - u32 field_6:8; - u32 field_7:8; + u32 field_5_5:3; // correct + u32 field_6_0:2; }; -struct UnknownBattleLinkSubStruct3 +struct BattleLinkStringMon { - u32 field_0 : 8; - u32 field_1 : 8; - u32 field_2 : 8; - u32 field_3 : 8; - u32 field_4 : 8; - u32 field_5 : 8; - u32 field_6 : 8; - u32 field_7 : 8; - u32 field_8 : 8; - u32 field_9 : 8; - u32 field_A : 8; - u32 field_B : 8; + u32 field_0_0:3; // correct + u32 field_0_3:3; // correct + u32 field_0_6:3; // correct + u32 field_1_1:3; // correct + u32 field_1_4:3; // correct + u32 field_1_7:3; + u32 field_2_2:2; + u32 field_2_4:2; // correct + u32 field_2_6:2; // correct + u32 field_3_0:2; // correct + u32 field_3_2:2; // correct + u32 field_3_4:2; + u32 field_3_6:2; }; struct UnknownBattleLinkStruct { - u8 field_0[0x2f]; - struct UnknownBattleLinkSubStruct2 pos[2][2]; // [side][flank] - struct UnknownBattleLinkSubStruct1 side[2]; // [side] + struct BattleLinkStringMon mon[2][6]; // [side][partyId] + struct BattleLinkStringPosition pos[2][2]; // [side][flank] + struct BattleLinkStringSide side[2]; // [side] }; extern struct StringInfoBattle *gStringInfo; // this file's functions bool8 sub_817E0B8(u16 stringId); -void sub_817E684(u8 arg0, u16 moveSlotId, u8 arg2, u8 arg3); +void sub_817E684(u8 arg0, u16 arg1, u8 arg2, u8 arg3); void sub_817EECC(void); +void sub_817EA80(u8 arg0); void sub_817C95C(u16 stringId) { struct UnknownBattleLinkStruct *structPtr; - u8 atkSide, defSide, effSide, scriptingSide; + u32 atkSide, defSide, effSide, scriptingSide; struct Pokemon *atkMon, *defMon; u8 moveSlot; - u8 atkFlank, defFlank, effFlank; + u32 atkFlank, defFlank, effFlank; + + register void *var1 asm("r1"), *var2 asm("r2"); if (!(gBattleTypeFlags & BATTLE_TYPE_LINK) && stringId != STRINGID_ITDOESNTAFFECT && stringId != STRINGID_NOTVERYEFFECTIVE) return; - structPtr = (void*)(&gBattleStruct->field_204); + structPtr = (struct UnknownBattleLinkStruct*)(&gBattleStruct->field_204); atkSide = GetBattlerSide(gBattlerAttacker); defSide = GetBattlerSide(gBattlerTarget); @@ -113,14 +126,15 @@ void sub_817C95C(u16 stringId) atkMon = &gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker]]; if (defSide == B_SIDE_PLAYER) - defMon = &gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]]; + defMon = &gPlayerParty[gBattlerPartyIndexes[gBattlerTarget]]; else - defMon = &gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker]]; + defMon = &gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]]; moveSlot = GetBattlerMoveSlotId(gBattlerAttacker, gStringInfo->currentMove); - if (moveSlot >= 4 && sub_817E0B8(stringId) && stringId >= BATTLESTRINGS_ID_ADDER) + if (moveSlot >= 4 && sub_817E0B8(stringId) && stringId > BATTLESTRINGS_ID_ADDER) { + structPtr->side[atkSide].field_3_0 = 15; return; } @@ -144,7 +158,7 @@ void sub_817C95C(u16 stringId) sub_817E684(1, moveSlot, 0, 0); break; case STRINGID_PKMNFORESAWATTACK: - structPtr->side[atkSide].field_8_1 = gBattlerPartyIndexes[gBattlerAttacker]; + structPtr->side[atkSide].field_8_1 = gBattlerPartyIndexes[gBattlerAttacker] + 1; structPtr->side[atkSide].field_0_1 = moveSlot; break; case STRINGID_PKMNCHOSEXASDESTINY: @@ -157,12 +171,16 @@ void sub_817C95C(u16 stringId) structPtr->side[atkSide].field_4_1 = 1; break; case STRINGID_PKMNPERISHCOUNTFELL: - if (gBattleTextBuff1[4] == 0) + var1 = gBattleTextBuff1 + 4; + if (*(u8*)(var1) == 0) structPtr->side[atkSide].field_3_0 = 10; break; case STRINGID_PKMNWISHCAMETRUE: if (structPtr->side[defSide].field_8_4 != 0) - sub_817E684(2, 3, defSide, (structPtr->side[defSide].field_8_4 - 1) * 4 + structPtr->side[defSide].field_0_4); + { + sub_817E684(2, 3, defSide, + (structPtr->side[defSide].field_8_4 - 1) * 4 + structPtr->side[defSide].field_0_4); + } break; case STRINGID_PKMNWANTSGRUDGE: structPtr->side[atkSide].field_8_5 = gBattlerPartyIndexes[gBattlerAttacker] + 1; @@ -170,7 +188,10 @@ void sub_817C95C(u16 stringId) break; case STRINGID_PKMNLOSTPPGRUDGE: if (structPtr->side[defSide].field_8_5 != 0) - sub_817E684(2, 4, defSide, (structPtr->side[defSide].field_8_5 - 1) * 4 + structPtr->side[defSide].field_0_5); + { + sub_817E684(2, 4, defSide, + (structPtr->side[defSide].field_8_5 - 1) * 4 + structPtr->side[defSide].field_0_5); + } break; case STRINGID_PKMNTRYINGTOTAKEFOE: structPtr->side[atkSide].field_0_6 = gBattlerPartyIndexes[gBattlerAttacker] + 1; @@ -178,7 +199,7 @@ void sub_817C95C(u16 stringId) break; case STRINGID_PKMNTOOKFOE: if (structPtr->side[defSide].field_0_6 != 0) - structPtr->side[defSide].field_3_0 = 11; + structPtr->side[atkSide].field_3_0 = 11; break; case STRINGID_PKMNPLANTEDROOTS: structPtr->pos[atkSide][atkFlank].field_5_0 = gBattlerPartyIndexes[gBattlerAttacker] + 1; @@ -186,11 +207,17 @@ void sub_817C95C(u16 stringId) break; case STRINGID_PKMNABSORBEDNUTRIENTS: if (structPtr->pos[atkSide][atkFlank].field_5_0 != 0) - sub_817E684(2, 6, atkSide, (structPtr->pos[atkSide][atkFlank].field_5_0 - 1) * 4 + structPtr->pos[atkSide][atkFlank].field_5_3); + { + sub_817E684(2, 6, atkSide, + (structPtr->pos[atkSide][atkFlank].field_5_0 - 1) * 4 + structPtr->pos[atkSide][atkFlank].field_5_3); + } break; case STRINGID_PKMNANCHOREDITSELF: if (structPtr->pos[defSide][defFlank].field_5_0 != 0) - sub_817E684(2, 6, defSide, (structPtr->pos[defSide][defFlank].field_5_0 - 1) * 4 + structPtr->pos[defSide][defFlank].field_5_3); + { + sub_817E684(2, 6, defSide, + (structPtr->pos[defSide][defFlank].field_5_0 - 1) * 4 + structPtr->pos[defSide][defFlank].field_5_3); + } break; case STRINGID_PKMNTRANSFORMEDINTO: gBattleStruct->field_B3 = 1; @@ -201,8 +228,8 @@ void sub_817C95C(u16 stringId) case STRINGID_PKMNSSTATCHANGED: if (gBattleTextBuff1[2] != 0) { - u16 *statStringId = (void*)(gBattleTextBuff2 + 2); - if (*statStringId == STRINGID_STATSHARPLY) + var1 = gBattleTextBuff2 + 2; + if (*(u16*)(var1) == STRINGID_STATSHARPLY) sub_817E684(0x17, moveSlot, gBattleTextBuff1[2] - 1, 0); else sub_817E684(0x16, moveSlot, gBattleTextBuff1[2] - 1, 0); @@ -213,8 +240,8 @@ void sub_817C95C(u16 stringId) { if (gBattlerAttacker == gBattlerTarget) { - u16 *statStringId = (void*)(gBattleTextBuff2 + 2); - if (*statStringId == STRINGID_STATSHARPLY) + var1 = gBattleTextBuff2 + 2; + if (*(u16*)(var1) == STRINGID_STATSHARPLY) sub_817E684(0x17, moveSlot, gBattleTextBuff1[2] - 1, 0); else sub_817E684(0x16, moveSlot, gBattleTextBuff1[2] - 1, 0); @@ -232,8 +259,8 @@ void sub_817C95C(u16 stringId) case STRINGID_PKMNSSTATCHANGED4: if (gBattleTextBuff1[2] != 0) { - u16 *statStringId = (void*)(gBattleTextBuff2 + 2); - if (*statStringId == STRINGID_STATHARSHLY) + var1 = gBattleTextBuff2 + 2; + if (*(u16*)(var1) == STRINGID_STATHARSHLY) sub_817E684(0x1A, moveSlot, gBattleTextBuff1[2] - 1, 0); else sub_817E684(0x19, moveSlot, gBattleTextBuff1[2] - 1, 0); @@ -244,7 +271,7 @@ void sub_817C95C(u16 stringId) structPtr->pos[defSide][defFlank].field_2_3 = moveSlot; break; case STRINGID_PKMNAFFLICTEDBYCURSE: - if (GetMonData(atkMon, MON_DATA_HP, NULL) != 0 + if (GetMonData(atkMon, MON_DATA_HP, NULL) && structPtr->pos[atkSide][atkFlank].field_0_0 != 0) { sub_817E684(8, 0, structPtr->pos[atkSide][atkFlank].field_0_0 - 1, structPtr->pos[atkSide][atkFlank].field_2_3); @@ -295,7 +322,196 @@ void sub_817C95C(u16 stringId) } break; case STRINGID_PKMNWASBURNED: - + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_0_6 = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_2_6 = moveSlot; + break; + case STRINGID_PKMNHURTBYBURN: + if (GetMonData(atkMon, MON_DATA_HP, NULL) != 0) + { + if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_0_6 != 0) + sub_817E684(8, 4, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_0_6 - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_2_6); + structPtr->side[atkSide].field_3_0 = 4; + structPtr->side[atkSide].field_3_1 = gBattlerPartyIndexes[gBattlerAttacker]; + } + break; + case STRINGID_PKMNWASPOISONED: + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_0_0 = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_2_2 = moveSlot; + break; + case STRINGID_PKMNBADLYPOISONED: + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_0_3 = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_2_4 = moveSlot; + break; + case STRINGID_PKMNHURTBYPOISON: + if (GetMonData(atkMon, MON_DATA_HP, NULL) != 0) + { + if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_0_0 != 0) + sub_817E684(8, 2, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_0_0 - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_2_2); + if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_0_3 != 0) + sub_817E684(8, 3, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_0_3 - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_2_4); + structPtr->side[atkSide].field_3_0 = 3; + structPtr->side[atkSide].field_3_1 = gBattlerPartyIndexes[gBattlerAttacker]; + } + break; + case STRINGID_PKMNFELLINLOVE: + structPtr->pos[defSide][defFlank].field_1_4 = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->pos[defSide][defFlank].field_3_2 = moveSlot; + break; + case STRINGID_PKMNIMMOBILIZEDBYLOVE: + if (structPtr->pos[atkSide][atkFlank].field_1_4 != 0) + sub_817E684(9, 0, structPtr->pos[atkSide][atkFlank].field_1_4 - 1, structPtr->pos[atkSide][atkFlank].field_3_2); + break; + case STRINGID_PKMNWASPARALYZED: + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_1_1 = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_3_0 = moveSlot; + break; + case STRINGID_PKMNISPARALYZED: + if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_1_1 != 0) + sub_817E684(9, 2, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_1_1 - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_3_0); + break; + case STRINGID_PKMNFELLASLEEP: + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_1_4 = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_3_2 = moveSlot; + break; + case STRINGID_PKMNFASTASLEEP: + if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_1_4 != 0 + && gStringInfo->currentMove != MOVE_SNORE + && gStringInfo->currentMove != MOVE_SLEEP_TALK) + sub_817E684(9, 3, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_1_4 - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_3_2); + break; + case STRINGID_PKMNWASFROZEN: + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_1_7 = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_3_4 = moveSlot; + break; + case STRINGID_PKMNISFROZEN: + if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_1_7 != 0) + sub_817E684(9, 4, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_1_7 - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_3_4); + break; + case STRINGID_PKMNWASCONFUSED: + structPtr->pos[effSide][effFlank].field_2_0 = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->pos[effSide][effFlank].field_3_4 = moveSlot; + break; + case STRINGID_ITHURTCONFUSION: + if (structPtr->pos[atkSide][atkFlank].field_2_0 != 0) + sub_817E684(9, 1, structPtr->pos[atkSide][atkFlank].field_2_0 - 1, structPtr->pos[atkSide][atkFlank].field_3_4); + structPtr->side[atkSide].field_3_0 = 12; + break; + case STRINGID_SPIKESSCATTERED: + structPtr->side[defSide].field_8_0 = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[defSide].field_0_0a = moveSlot; + break; + case STRINGID_PKMNHURTBYSPIKES: + if (structPtr->side[scriptingSide].field_8_0 != 0) + { + sub_817E684(10, scriptingSide ^ BIT_SIDE, structPtr->side[scriptingSide].field_8_0 - 1, structPtr->side[scriptingSide].field_0_0a); + structPtr->side[scriptingSide].field_3_0 = 7; + } + break; + case STRINGID_PKMNBLEWAWAYSPIKES: + structPtr->side[atkSide].field_8_0 = 0; + structPtr->side[atkSide].field_0_0a = 0; + break; + case STRINGID_FIREWEAKENED: + structPtr->pos[atkSide][atkFlank].field_4_0 = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->pos[atkSide][atkFlank].field_3_6 = moveSlot; + break; + case STRINGID_ELECTRICITYWEAKENED: + structPtr->pos[atkSide][atkFlank].field_4_3 = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->pos[atkSide][atkFlank].field_4_6 = moveSlot; + break; + case STRINGID_ATTACKERFAINTED: + sub_817EA80(0); + case STRINGID_RETURNMON: + if (structPtr->pos[atkSide][atkFlank].field_4_0 != 0) + { + structPtr->pos[atkSide][atkFlank].field_4_0 = 0; + structPtr->pos[atkSide][atkFlank].field_3_6 = 0; + } + if (structPtr->pos[atkSide][atkFlank].field_4_3 != 0) + { + structPtr->pos[atkSide][atkFlank].field_4_3 = 0; + structPtr->pos[atkSide][atkFlank].field_4_6 = 0; + } + break; + case STRINGID_TARGETFAINTED: + sub_817EA80(1); + if (structPtr->pos[atkSide][defFlank].field_4_0 != 0) + { + structPtr->pos[atkSide][defFlank].field_4_0 = 0; + structPtr->pos[atkSide][defFlank].field_3_6 = 0; + } + if (structPtr->pos[atkSide][defFlank].field_4_3 != 0) + { + structPtr->pos[atkSide][defFlank].field_4_3 = 0; + structPtr->pos[atkSide][defFlank].field_4_6 = 0; + } + break; + case STRINGID_PKMNRAISEDDEF: + case STRINGID_PKMNRAISEDDEFALITTLE: + structPtr->side[atkSide].field_8_0_b = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[atkSide].field_0_0b = moveSlot; + break; + case STRINGID_PKMNRAISEDSPDEF: + case STRINGID_PKMNRAISEDSPDEFALITTLE: + structPtr->side[atkSide].field_8_0_c = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[atkSide].field_0_0c = moveSlot; + break; + case STRINGID_PKMNSXWOREOFF: + var1 = gBattleTextBuff1 + 2; + if (*(u16*)(var1) == MOVE_REFLECT) + { + structPtr->side[atkSide].field_8_0_b = 0; + structPtr->side[atkSide].field_0_0b = 0; + } + var2 = gBattleTextBuff1 + 2; + if (*(u16*)(var2) == MOVE_LIGHT_SCREEN) + { + structPtr->side[atkSide].field_8_0_c = 0; + structPtr->side[atkSide].field_0_0c = 0; + } + var1 = gBattleTextBuff1 + 2; + if (*(u16*)(var1) == MOVE_MIST) + { + structPtr->side[atkSide].field_8_0_e = 0; + structPtr->side[atkSide].field_0_0e = 0; + } + break; + case STRINGID_PKMNCOVEREDBYVEIL: + structPtr->side[atkSide].field_8_0_d = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[atkSide].field_0_0d = moveSlot; + break; + case STRINGID_PKMNUSEDSAFEGUARD: + if (structPtr->side[defSide].field_8_0_d != 0) + sub_817E684(15, 0, structPtr->side[defSide].field_8_0_d - 1, structPtr->side[defSide].field_0_0d); + break; + case STRINGID_PKMNSAFEGUARDEXPIRED: + structPtr->side[atkSide].field_8_0_d = 0; + structPtr->side[atkSide].field_0_0d = 0; + break; + case STRINGID_PKMNSHROUDEDINMIST: + structPtr->side[atkSide].field_8_0_e = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[atkSide].field_0_0e = moveSlot; + break; + case STRINGID_PKMNPROTECTEDBYMIST: + if (structPtr->side[defSide].field_8_0_e != 0) + sub_817E684(16, 0, structPtr->side[defSide].field_8_0_e - 1, structPtr->side[defSide].field_0_0e); + break; + case STRINGID_THEWALLSHATTERED: + structPtr->side[defSide].field_8_0_b = 0; + structPtr->side[defSide].field_0_0b = 0; + structPtr->side[defSide].field_8_0_c = 0; + structPtr->side[defSide].field_0_0c = 0; + sub_817E684(17, 0, gBattlerPartyIndexes[gBattlerAttacker], moveSlot); + break; + case STRINGID_PKMNFLINCHED: + if (structPtr->pos[atkSide][0].field_5_5 != 0) + sub_817E684(21, 0, structPtr->pos[atkSide][0].field_5_5 - 1, structPtr->pos[atkSide][0].field_6_0); + if (structPtr->pos[atkSide][1].field_5_5 != 0) + sub_817E684(21, 0, structPtr->pos[atkSide][1].field_5_5 - 1, structPtr->pos[atkSide][1].field_6_0); + break; + case STRINGID_PKMNCRASHED: + case STRINGID_PKMNHITWITHRECOIL: + structPtr->side[atkSide].field_3_0 = 14; break; } } From f2052e5d8ff66512b155b1418fe5c6d70e63fa07 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 24 Feb 2018 19:34:43 +0100 Subject: [PATCH 03/10] PRAISE CAM FOR HE IS CHAMP --- src/battle_link_817C95C.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/battle_link_817C95C.c b/src/battle_link_817C95C.c index 9ac402a03..c17b57c39 100644 --- a/src/battle_link_817C95C.c +++ b/src/battle_link_817C95C.c @@ -107,8 +107,8 @@ void sub_817C95C(u16 stringId) struct Pokemon *atkMon, *defMon; u8 moveSlot; u32 atkFlank, defFlank, effFlank; - - register void *var1 asm("r1"), *var2 asm("r2"); + u8 *perishCount; + u16 *statStringId, *finishedMoveId; if (!(gBattleTypeFlags & BATTLE_TYPE_LINK) && stringId != STRINGID_ITDOESNTAFFECT && stringId != STRINGID_NOTVERYEFFECTIVE) return; @@ -138,6 +138,10 @@ void sub_817C95C(u16 stringId) return; } + perishCount = (u8 *)(gBattleTextBuff1 + 4); + statStringId = (u16 *)(gBattleTextBuff2 + 2); + finishedMoveId = (u16 *)(gBattleTextBuff1 + 2); + atkFlank = GetBattlerPosition(gBattlerAttacker) / 2; defFlank = GetBattlerPosition(gBattlerTarget) / 2; effFlank = GetBattlerPosition(gEffectBattler) / 2; @@ -171,8 +175,7 @@ void sub_817C95C(u16 stringId) structPtr->side[atkSide].field_4_1 = 1; break; case STRINGID_PKMNPERISHCOUNTFELL: - var1 = gBattleTextBuff1 + 4; - if (*(u8*)(var1) == 0) + if (*perishCount == 0) structPtr->side[atkSide].field_3_0 = 10; break; case STRINGID_PKMNWISHCAMETRUE: @@ -228,8 +231,7 @@ void sub_817C95C(u16 stringId) case STRINGID_PKMNSSTATCHANGED: if (gBattleTextBuff1[2] != 0) { - var1 = gBattleTextBuff2 + 2; - if (*(u16*)(var1) == STRINGID_STATSHARPLY) + if (*statStringId == STRINGID_STATSHARPLY) sub_817E684(0x17, moveSlot, gBattleTextBuff1[2] - 1, 0); else sub_817E684(0x16, moveSlot, gBattleTextBuff1[2] - 1, 0); @@ -240,8 +242,7 @@ void sub_817C95C(u16 stringId) { if (gBattlerAttacker == gBattlerTarget) { - var1 = gBattleTextBuff2 + 2; - if (*(u16*)(var1) == STRINGID_STATSHARPLY) + if (*statStringId == STRINGID_STATSHARPLY) sub_817E684(0x17, moveSlot, gBattleTextBuff1[2] - 1, 0); else sub_817E684(0x16, moveSlot, gBattleTextBuff1[2] - 1, 0); @@ -259,8 +260,7 @@ void sub_817C95C(u16 stringId) case STRINGID_PKMNSSTATCHANGED4: if (gBattleTextBuff1[2] != 0) { - var1 = gBattleTextBuff2 + 2; - if (*(u16*)(var1) == STRINGID_STATHARSHLY) + if (*statStringId == STRINGID_STATHARSHLY) sub_817E684(0x1A, moveSlot, gBattleTextBuff1[2] - 1, 0); else sub_817E684(0x19, moveSlot, gBattleTextBuff1[2] - 1, 0); @@ -457,20 +457,17 @@ void sub_817C95C(u16 stringId) structPtr->side[atkSide].field_0_0c = moveSlot; break; case STRINGID_PKMNSXWOREOFF: - var1 = gBattleTextBuff1 + 2; - if (*(u16*)(var1) == MOVE_REFLECT) + if (*finishedMoveId == MOVE_REFLECT) { structPtr->side[atkSide].field_8_0_b = 0; structPtr->side[atkSide].field_0_0b = 0; } - var2 = gBattleTextBuff1 + 2; - if (*(u16*)(var2) == MOVE_LIGHT_SCREEN) + if (*finishedMoveId == MOVE_LIGHT_SCREEN) { structPtr->side[atkSide].field_8_0_c = 0; structPtr->side[atkSide].field_0_0c = 0; } - var1 = gBattleTextBuff1 + 2; - if (*(u16*)(var1) == MOVE_MIST) + if (*finishedMoveId == MOVE_MIST) { structPtr->side[atkSide].field_8_0_e = 0; structPtr->side[atkSide].field_0_0e = 0; From c0ea81afc552456215a57918acf11d161af338e3 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 25 Feb 2018 00:36:37 +0100 Subject: [PATCH 04/10] add meaningful struct field names --- asm/battle_link_817C95C.s | 303 --------------------------- src/battle_link_817C95C.c | 427 ++++++++++++++++++++++---------------- 2 files changed, 249 insertions(+), 481 deletions(-) diff --git a/asm/battle_link_817C95C.s b/asm/battle_link_817C95C.s index e64d142fa..234cad55d 100644 --- a/asm/battle_link_817C95C.s +++ b/asm/battle_link_817C95C.s @@ -5,310 +5,7 @@ .text - thumb_func_start sub_817E0B8 -sub_817E0B8: @ 817E0B8 - push {r4-r6,lr} - lsls r0, 16 - lsrs r5, r0, 16 - movs r3, 0 - ldr r4, =gUnknown_0860A8A4 - ldr r6, =0x0000ffff - adds r2, r4, 0 - adds r1, r4, 0 -_0817E0C8: - ldrh r0, [r1] - cmp r0, r5 - beq _0817E0DA - adds r2, 0x2 - adds r1, 0x2 - adds r3, 0x1 - ldrh r0, [r2] - cmp r0, r6 - bne _0817E0C8 -_0817E0DA: - lsls r0, r3, 1 - adds r0, r4 - ldrh r1, [r0] - ldr r0, =0x0000ffff - cmp r1, r0 - beq _0817E0F4 - movs r0, 0 - b _0817E0F6 - .pool -_0817E0F4: - movs r0, 0x1 -_0817E0F6: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_817E0B8 - thumb_func_start sub_817E0FC -sub_817E0FC: @ 817E0FC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x14 - str r2, [sp, 0x4] - lsls r0, 16 - lsrs r7, r0, 16 - lsls r1, 16 - lsrs r1, 16 - str r1, [sp] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x2 - ands r0, r1 - cmp r0, 0 - bne _0817E122 - b _0817E310 -_0817E122: - ldr r0, =gBattleStruct - ldr r0, [r0] - movs r1, 0x81 - lsls r1, 2 - adds r1, r0, r1 - str r1, [sp, 0x8] - ldr r2, =gBattlerAttacker - mov r10, r2 - ldrb r0, [r2] - bl GetBattlerSide - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - ldr r0, =gBattlerTarget - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - lsrs r4, r0, 24 - mov r1, r10 - ldrb r0, [r1] - adds r1, r7, 0 - bl GetBattlerMoveSlotId - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x3 - bls _0817E184 - mov r2, r9 - lsls r0, r2, 1 - add r0, r9 - lsls r0, 2 - ldr r1, [sp, 0x8] - adds r0, r1, r0 - adds r0, 0x57 - ldrb r1, [r0] - movs r2, 0x1E - orrs r1, r2 - strb r1, [r0] - b _0817E310 - .pool -_0817E184: - mov r2, r10 - ldrb r0, [r2] - bl GetBattlerPosition - lsls r0, 24 - lsrs r0, 25 - lsls r0, 3 - lsls r4, 4 - adds r0, r4 - ldr r1, [sp, 0x8] - adds r0, r1, r0 - mov r2, r10 - ldrb r1, [r2] - lsls r1, 1 - ldr r2, =gBattlerPartyIndexes - adds r1, r2 - ldrh r2, [r1] - adds r2, 0x1 - adds r0, 0x35 - lsls r2, 5 - ldrb r3, [r0] - movs r1, 0x1F - ands r1, r3 - orrs r1, r2 - strb r1, [r0] - mov r1, r10 - ldrb r0, [r1] - bl GetBattlerPosition - lsls r0, 24 - lsrs r0, 25 - lsls r0, 3 - adds r0, r4 - ldr r2, [sp, 0x8] - adds r0, r2, r0 - adds r0, 0x36 - movs r1, 0x3 - mov r8, r6 - mov r2, r8 - ands r2, r1 - mov r8, r2 - ldrb r2, [r0] - movs r1, 0x4 - negs r1, r1 - ands r1, r2 - mov r2, r8 - orrs r1, r2 - strb r1, [r0] - mov r1, r9 - lsls r0, r1, 1 - add r0, r9 - lsls r0, 2 - ldr r2, [sp, 0x8] - adds r0, r2, r0 - str r0, [sp, 0xC] - adds r5, r0, 0 - adds r5, 0x53 - lsls r2, r6, 6 - ldrb r1, [r5] - movs r0, 0x3F - ands r0, r1 - orrs r0, r2 - strb r0, [r5] - ldr r1, =gBattleMoves - lsls r4, r7, 1 - adds r0, r4, r7 - lsls r0, 2 - adds r0, r1 - ldrb r2, [r0] - movs r0, 0 - adds r1, r6, 0 - movs r3, 0 - bl sub_817E684 - ldr r0, [sp] - adds r1, r7, 0 - adds r2, r6, 0 - bl sub_817F394 - ldr r0, [sp, 0x4] - ldrb r1, [r0, 0x12] - movs r0, 0xF - ands r0, r1 - str r4, [sp, 0x10] - cmp r0, 0 - beq _0817E23C - movs r0, 0x7 - adds r1, r7, 0 - adds r2, r6, 0 - movs r3, 0 - bl sub_817E684 -_0817E23C: - ldr r0, =0x00000111 - cmp r7, r0 - bne _0817E272 - mov r1, r10 - ldrb r0, [r1] - lsls r0, 1 - ldr r2, =gBattlerPartyIndexes - adds r0, r2 - ldrh r1, [r0] - adds r1, 0x1 - movs r0, 0x7 - ands r1, r0 - ldrb r2, [r5] - movs r0, 0x8 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r5] - ldr r2, [sp, 0xC] - adds r2, 0x56 - ldrb r1, [r2] - movs r0, 0x4 - negs r0, r0 - ands r0, r1 - mov r1, r8 - orrs r0, r1 - strb r0, [r2] -_0817E272: - cmp r7, 0x78 - beq _0817E27A - cmp r7, 0x99 - bne _0817E2D2 -_0817E27A: - movs r0, 0x1 - mov r2, r9 - eors r0, r2 - lsls r2, r0, 1 - adds r2, r0 - lsls r2, 2 - ldr r0, [sp, 0x8] - adds r2, r0, r2 - mov r1, r10 - ldrb r0, [r1] - lsls r0, 1 - ldr r1, =gBattlerPartyIndexes - adds r0, r1 - ldrh r1, [r0] - adds r1, 0x1 - adds r4, r2, 0 - adds r4, 0x58 - movs r0, 0x7 - ands r1, r0 - lsls r1, 3 - ldrb r3, [r4] - movs r0, 0x39 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - mov r1, r8 - lsls r3, r1, 1 - movs r1, 0x7 - negs r1, r1 - ands r0, r1 - orrs r0, r3 - strb r0, [r4] - adds r2, 0x57 - ldrb r1, [r2] - movs r0, 0x1F - negs r0, r0 - ands r0, r1 - movs r1, 0x1A - orrs r0, r1 - strb r0, [r2] - ldrb r0, [r4] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r4] -_0817E2D2: - ldr r1, =gBattleMoves - ldr r2, [sp, 0x10] - adds r0, r2, r7 - lsls r0, 2 - adds r0, r1 - ldrb r4, [r0, 0x2] - ldrb r5, [r0, 0x1] - movs r0, 0xD - adds r1, r4, 0 - adds r2, r5, 0 - movs r3, 0 - bl sub_817E684 - movs r0, 0xE - adds r1, r4, 0 - adds r2, r5, 0 - movs r3, 0 - bl sub_817E684 - movs r0, 0xB - adds r1, r4, 0 - movs r2, 0 - movs r3, 0 - bl sub_817E684 - movs r0, 0xC - adds r1, r4, 0 - movs r2, 0 - movs r3, 0 - bl sub_817E684 -_0817E310: - add sp, 0x14 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817E0FC thumb_func_start sub_817E32C sub_817E32C: @ 817E32C diff --git a/src/battle_link_817C95C.c b/src/battle_link_817C95C.c index c17b57c39..4b310c273 100644 --- a/src/battle_link_817C95C.c +++ b/src/battle_link_817C95C.c @@ -8,81 +8,78 @@ struct BattleLinkStringSide { - u32 field_8_0:3; // correct - u32 field_8_0_b:3; // correct - u32 field_8_0_c:3; // correct - u32 field_8_0_d:3; - u32 field_8_0_e:3; - u32 field_8_1:3; // correct - u32 field_8_2:3; // correct - u32 field_8_3:3; // correct - u32 field_8_4:3; // correct - u32 field_8_5:3; // correct + u32 spikesMonId:3; + u32 reflectMoveId:3; + u32 lightScreenMonId:3; + u32 safeguardMonId:3; + u32 mistMonId:3; + u32 futureSightMonId:3; + u32 doomDesireMonId:3; + u32 perishSongMonId:3; + u32 wishMonId:3; + u32 grudgeMonId:3; u32 field_8_6:2; - - u32 field_0_0a:2; // correct - u32 field_0_0b:2; // correct - u32 field_0_0c:2; // correct - u32 field_0_0d:2; - u32 field_0_0e:2; - u32 field_0_1:2; // correct - u32 field_0_2:2; // correct - u32 field_0_3:2; // correct - u32 field_0_4:2; // correct - u32 field_0_5:2; // correct - u32 field_0_6:3; // correct - u32 field_0_7:2; // correct - - u32 field_3_0:4; // correct - u32 field_3_1:3; // correct - - u32 field_4_0:6; + u32 spikesMoveSlot:2; + u32 reflectMoveSlot:2; + u32 lightScreenMoveSlot:2; + u32 safeguardMoveSlot:2; + u32 mistMoveSlot:2; + u32 futureSightMoveSlot:2; + u32 doomDesireMoveSlot:2; + u32 perishSongMoveSlot:2; + u32 wishMoveSlot:2; + u32 grudgeMoveSlot:2; + u32 destinyBondMonId:3; + u32 destinyBondMoveSlot:2; + u32 field_3_0:4; + u32 field_3_1:3; + u32 field_4_0_0:1; + u32 field_4_0:2; + u32 field_4_0_b:3; u32 field_4_1:1; u32 field_4_2:1; - - u32 field_5_0:3; // correct - u32 field_5_1:2; // correct + u32 field_5_0:3; + u32 field_5_1:2; }; struct BattleLinkStringPosition { - u32 field_0_0:3; // correct - u32 field_0_3:3; // correct - u32 field_0_6:3; // correct - u32 field_1_1:3; // correct - u32 field_1_4:3; // correct - u32 field_2_0:3; - u32 field_2_3:2; // correct - u32 field_2_5:2; // correct - u32 field_2_7:2; // correct - u32 field_3_0:2; // correct - u32 field_3_2:2; // correct - u32 field_3_4:2; - u32 field_3_6:2; - u32 field_4_0:3; - u32 field_4_3:3; - u32 field_4_6:2; - u32 field_5_0:3; // correct - u32 field_5_3:2; // correct - u32 field_5_5:3; // correct + u32 curseMonId:3; + u32 leechSeedMonId:3; + u32 nightmareMonId:3; + u32 wrapMonId:3; + u32 attractMonId:3; + u32 confusionMonId:3; + u32 curseMoveSlot:2; + u32 leechSeedMoveSlot:2; + u32 nightmareMoveSlot:2; + u32 wrapMoveSlot:2; + u32 attractMoveSlot:2; + u32 confusionMoveSlot:2; + u32 waterSportMoveSlot:2; + u32 waterSportMonId:3; + u32 mudSportMonId:3; + u32 mudSportMoveSlot:2; + u32 ingrainMonId:3; + u32 ingrainMoveSlot:2; + u32 field_5_5:3; u32 field_6_0:2; }; struct BattleLinkStringMon { - u32 field_0_0:3; // correct - u32 field_0_3:3; // correct - u32 field_0_6:3; // correct - u32 field_1_1:3; // correct - u32 field_1_4:3; // correct - u32 field_1_7:3; - u32 field_2_2:2; - u32 field_2_4:2; // correct - u32 field_2_6:2; // correct - u32 field_3_0:2; // correct - u32 field_3_2:2; // correct - u32 field_3_4:2; - u32 field_3_6:2; + u32 psnMonId:3; + u32 badPsnMonId:3; + u32 brnMonId:3; + u32 prlzMonId:3; + u32 slpMonId:3; + u32 frzMonId:3; + u32 psnMoveSlot:2; + u32 badPsnMoveSlot:2; + u32 brnMoveSlot:2; + u32 prlzMoveSlot:2; + u32 slpMoveSlot:2; + u32 frzMoveSlot:2; }; struct UnknownBattleLinkStruct @@ -94,12 +91,19 @@ struct UnknownBattleLinkStruct extern struct StringInfoBattle *gStringInfo; +extern const struct BattleMove gBattleMoves[]; + // this file's functions bool8 sub_817E0B8(u16 stringId); void sub_817E684(u8 arg0, u16 arg1, u8 arg2, u8 arg3); void sub_817EECC(void); void sub_817EA80(u8 arg0); +void sub_817F394(u16 weatherFlags, u16 moveId, u8 moveSlot); +// const rom data +extern const u16 gUnknown_0860A8A4[]; + +// code void sub_817C95C(u16 stringId) { struct UnknownBattleLinkStruct *structPtr; @@ -162,16 +166,16 @@ void sub_817C95C(u16 stringId) sub_817E684(1, moveSlot, 0, 0); break; case STRINGID_PKMNFORESAWATTACK: - structPtr->side[atkSide].field_8_1 = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[atkSide].field_0_1 = moveSlot; + structPtr->side[atkSide].futureSightMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[atkSide].futureSightMoveSlot = moveSlot; break; case STRINGID_PKMNCHOSEXASDESTINY: - structPtr->side[atkSide].field_8_2 = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[atkSide].field_0_2 = moveSlot; + structPtr->side[atkSide].doomDesireMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[atkSide].doomDesireMoveSlot = moveSlot; break; case STRINGID_FAINTINTHREE: - structPtr->side[atkSide].field_8_3 = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[atkSide].field_0_3 = moveSlot; + structPtr->side[atkSide].perishSongMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[atkSide].perishSongMoveSlot = moveSlot; structPtr->side[atkSide].field_4_1 = 1; break; case STRINGID_PKMNPERISHCOUNTFELL: @@ -179,47 +183,47 @@ void sub_817C95C(u16 stringId) structPtr->side[atkSide].field_3_0 = 10; break; case STRINGID_PKMNWISHCAMETRUE: - if (structPtr->side[defSide].field_8_4 != 0) + if (structPtr->side[defSide].wishMonId != 0) { sub_817E684(2, 3, defSide, - (structPtr->side[defSide].field_8_4 - 1) * 4 + structPtr->side[defSide].field_0_4); + (structPtr->side[defSide].wishMonId - 1) * 4 + structPtr->side[defSide].wishMoveSlot); } break; case STRINGID_PKMNWANTSGRUDGE: - structPtr->side[atkSide].field_8_5 = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[atkSide].field_0_5 = moveSlot; + structPtr->side[atkSide].grudgeMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[atkSide].grudgeMoveSlot = moveSlot; break; case STRINGID_PKMNLOSTPPGRUDGE: - if (structPtr->side[defSide].field_8_5 != 0) + if (structPtr->side[defSide].grudgeMonId != 0) { sub_817E684(2, 4, defSide, - (structPtr->side[defSide].field_8_5 - 1) * 4 + structPtr->side[defSide].field_0_5); + (structPtr->side[defSide].grudgeMonId - 1) * 4 + structPtr->side[defSide].grudgeMoveSlot); } break; case STRINGID_PKMNTRYINGTOTAKEFOE: - structPtr->side[atkSide].field_0_6 = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[atkSide].field_0_7 = moveSlot; + structPtr->side[atkSide].destinyBondMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[atkSide].destinyBondMoveSlot = moveSlot; break; case STRINGID_PKMNTOOKFOE: - if (structPtr->side[defSide].field_0_6 != 0) + if (structPtr->side[defSide].destinyBondMonId != 0) structPtr->side[atkSide].field_3_0 = 11; break; case STRINGID_PKMNPLANTEDROOTS: - structPtr->pos[atkSide][atkFlank].field_5_0 = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->pos[atkSide][atkFlank].field_5_3 = moveSlot; + structPtr->pos[atkSide][atkFlank].ingrainMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->pos[atkSide][atkFlank].ingrainMoveSlot = moveSlot; break; case STRINGID_PKMNABSORBEDNUTRIENTS: - if (structPtr->pos[atkSide][atkFlank].field_5_0 != 0) + if (structPtr->pos[atkSide][atkFlank].ingrainMonId != 0) { sub_817E684(2, 6, atkSide, - (structPtr->pos[atkSide][atkFlank].field_5_0 - 1) * 4 + structPtr->pos[atkSide][atkFlank].field_5_3); + (structPtr->pos[atkSide][atkFlank].ingrainMonId - 1) * 4 + structPtr->pos[atkSide][atkFlank].ingrainMoveSlot); } break; case STRINGID_PKMNANCHOREDITSELF: - if (structPtr->pos[defSide][defFlank].field_5_0 != 0) + if (structPtr->pos[defSide][defFlank].ingrainMonId != 0) { sub_817E684(2, 6, defSide, - (structPtr->pos[defSide][defFlank].field_5_0 - 1) * 4 + structPtr->pos[defSide][defFlank].field_5_3); + (structPtr->pos[defSide][defFlank].ingrainMonId - 1) * 4 + structPtr->pos[defSide][defFlank].ingrainMoveSlot); } break; case STRINGID_PKMNTRANSFORMEDINTO: @@ -267,39 +271,39 @@ void sub_817C95C(u16 stringId) } break; case STRINGID_PKMNLAIDCURSE: - structPtr->pos[defSide][defFlank].field_0_0 = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->pos[defSide][defFlank].field_2_3 = moveSlot; + structPtr->pos[defSide][defFlank].curseMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->pos[defSide][defFlank].curseMoveSlot = moveSlot; break; case STRINGID_PKMNAFFLICTEDBYCURSE: if (GetMonData(atkMon, MON_DATA_HP, NULL) - && structPtr->pos[atkSide][atkFlank].field_0_0 != 0) + && structPtr->pos[atkSide][atkFlank].curseMonId != 0) { - sub_817E684(8, 0, structPtr->pos[atkSide][atkFlank].field_0_0 - 1, structPtr->pos[atkSide][atkFlank].field_2_3); + sub_817E684(8, 0, structPtr->pos[atkSide][atkFlank].curseMonId - 1, structPtr->pos[atkSide][atkFlank].curseMoveSlot); structPtr->side[atkSide].field_3_0 = 1; structPtr->side[atkSide].field_3_1 = atkFlank; } break; case STRINGID_PKMNSEEDED: - structPtr->pos[defSide][defFlank].field_0_3 = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->pos[defSide][defFlank].field_2_5 = moveSlot; + structPtr->pos[defSide][defFlank].leechSeedMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->pos[defSide][defFlank].leechSeedMoveSlot = moveSlot; break; case STRINGID_PKMNSAPPEDBYLEECHSEED: - if (structPtr->pos[atkSide][atkFlank].field_0_3 != 0) + if (structPtr->pos[atkSide][atkFlank].leechSeedMonId != 0) { - sub_817E684(8, 1, structPtr->pos[atkSide][atkFlank].field_0_3 - 1, structPtr->pos[atkSide][atkFlank].field_2_5); + sub_817E684(8, 1, structPtr->pos[atkSide][atkFlank].leechSeedMonId - 1, structPtr->pos[atkSide][atkFlank].leechSeedMoveSlot); structPtr->side[atkSide].field_3_0 = 2; structPtr->side[atkSide].field_3_1 = atkFlank; } break; case STRINGID_PKMNFELLINTONIGHTMARE: - structPtr->pos[defSide][defFlank].field_0_6 = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->pos[defSide][defFlank].field_2_7 = moveSlot; + structPtr->pos[defSide][defFlank].nightmareMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->pos[defSide][defFlank].nightmareMoveSlot = moveSlot; break; case STRINGID_PKMNLOCKEDINNIGHTMARE: if (GetMonData(atkMon, MON_DATA_HP, NULL) != 0 - && structPtr->pos[atkSide][atkFlank].field_0_6 != 0) + && structPtr->pos[atkSide][atkFlank].nightmareMonId != 0) { - sub_817E684(8, 5, structPtr->pos[atkSide][atkFlank].field_0_6 - 1, structPtr->pos[atkSide][atkFlank].field_2_7); + sub_817E684(8, 5, structPtr->pos[atkSide][atkFlank].nightmareMonId - 1, structPtr->pos[atkSide][atkFlank].nightmareMoveSlot); structPtr->side[atkSide].field_3_0 = 5; structPtr->side[atkSide].field_3_1 = atkFlank; } @@ -309,195 +313,195 @@ void sub_817C95C(u16 stringId) case STRINGID_PKMNWRAPPEDBY: case STRINGID_PKMNCLAMPED: case STRINGID_PKMNTRAPPEDBYSANDTOMB: - structPtr->pos[defSide][defFlank].field_1_1 = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->pos[defSide][defFlank].field_3_0 = moveSlot; + structPtr->pos[defSide][defFlank].wrapMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->pos[defSide][defFlank].wrapMoveSlot = moveSlot; break; case STRINGID_PKMNHURTBY: if (GetMonData(atkMon, MON_DATA_HP, NULL) != 0 - && structPtr->pos[atkSide][atkFlank].field_1_1 != 0) + && structPtr->pos[atkSide][atkFlank].wrapMonId != 0) { - sub_817E684(8, 6, structPtr->pos[atkSide][atkFlank].field_1_1 - 1, structPtr->pos[atkSide][atkFlank].field_3_0); + sub_817E684(8, 6, structPtr->pos[atkSide][atkFlank].wrapMonId - 1, structPtr->pos[atkSide][atkFlank].wrapMoveSlot); structPtr->side[atkSide].field_3_0 = 6; structPtr->side[atkSide].field_3_1 = atkFlank; } break; case STRINGID_PKMNWASBURNED: - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_0_6 = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_2_6 = moveSlot; + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].brnMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].brnMoveSlot = moveSlot; break; case STRINGID_PKMNHURTBYBURN: if (GetMonData(atkMon, MON_DATA_HP, NULL) != 0) { - if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_0_6 != 0) - sub_817E684(8, 4, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_0_6 - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_2_6); + if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].brnMonId != 0) + sub_817E684(8, 4, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].brnMonId - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].brnMoveSlot); structPtr->side[atkSide].field_3_0 = 4; structPtr->side[atkSide].field_3_1 = gBattlerPartyIndexes[gBattlerAttacker]; } break; case STRINGID_PKMNWASPOISONED: - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_0_0 = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_2_2 = moveSlot; + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].psnMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].psnMoveSlot = moveSlot; break; case STRINGID_PKMNBADLYPOISONED: - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_0_3 = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_2_4 = moveSlot; + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].badPsnMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].badPsnMoveSlot = moveSlot; break; case STRINGID_PKMNHURTBYPOISON: if (GetMonData(atkMon, MON_DATA_HP, NULL) != 0) { - if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_0_0 != 0) - sub_817E684(8, 2, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_0_0 - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_2_2); - if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_0_3 != 0) - sub_817E684(8, 3, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_0_3 - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_2_4); + if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].psnMonId != 0) + sub_817E684(8, 2, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].psnMonId - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].psnMoveSlot); + if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].badPsnMonId != 0) + sub_817E684(8, 3, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].badPsnMonId - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].badPsnMoveSlot); structPtr->side[atkSide].field_3_0 = 3; structPtr->side[atkSide].field_3_1 = gBattlerPartyIndexes[gBattlerAttacker]; } break; case STRINGID_PKMNFELLINLOVE: - structPtr->pos[defSide][defFlank].field_1_4 = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->pos[defSide][defFlank].field_3_2 = moveSlot; + structPtr->pos[defSide][defFlank].attractMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->pos[defSide][defFlank].attractMoveSlot = moveSlot; break; case STRINGID_PKMNIMMOBILIZEDBYLOVE: - if (structPtr->pos[atkSide][atkFlank].field_1_4 != 0) - sub_817E684(9, 0, structPtr->pos[atkSide][atkFlank].field_1_4 - 1, structPtr->pos[atkSide][atkFlank].field_3_2); + if (structPtr->pos[atkSide][atkFlank].attractMonId != 0) + sub_817E684(9, 0, structPtr->pos[atkSide][atkFlank].attractMonId - 1, structPtr->pos[atkSide][atkFlank].attractMoveSlot); break; case STRINGID_PKMNWASPARALYZED: - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_1_1 = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_3_0 = moveSlot; + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].prlzMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].prlzMoveSlot = moveSlot; break; case STRINGID_PKMNISPARALYZED: - if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_1_1 != 0) - sub_817E684(9, 2, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_1_1 - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_3_0); + if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].prlzMonId != 0) + sub_817E684(9, 2, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].prlzMonId - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].prlzMoveSlot); break; case STRINGID_PKMNFELLASLEEP: - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_1_4 = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_3_2 = moveSlot; + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].slpMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].slpMoveSlot = moveSlot; break; case STRINGID_PKMNFASTASLEEP: - if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_1_4 != 0 + if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].slpMonId != 0 && gStringInfo->currentMove != MOVE_SNORE && gStringInfo->currentMove != MOVE_SLEEP_TALK) - sub_817E684(9, 3, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_1_4 - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_3_2); + sub_817E684(9, 3, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].slpMonId - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].slpMoveSlot); break; case STRINGID_PKMNWASFROZEN: - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_1_7 = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].field_3_4 = moveSlot; + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].frzMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].frzMoveSlot = moveSlot; break; case STRINGID_PKMNISFROZEN: - if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_1_7 != 0) - sub_817E684(9, 4, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_1_7 - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].field_3_4); + if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].frzMonId != 0) + sub_817E684(9, 4, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].frzMonId - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].frzMoveSlot); break; case STRINGID_PKMNWASCONFUSED: - structPtr->pos[effSide][effFlank].field_2_0 = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->pos[effSide][effFlank].field_3_4 = moveSlot; + structPtr->pos[effSide][effFlank].confusionMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->pos[effSide][effFlank].confusionMoveSlot = moveSlot; break; case STRINGID_ITHURTCONFUSION: - if (structPtr->pos[atkSide][atkFlank].field_2_0 != 0) - sub_817E684(9, 1, structPtr->pos[atkSide][atkFlank].field_2_0 - 1, structPtr->pos[atkSide][atkFlank].field_3_4); + if (structPtr->pos[atkSide][atkFlank].confusionMonId != 0) + sub_817E684(9, 1, structPtr->pos[atkSide][atkFlank].confusionMonId - 1, structPtr->pos[atkSide][atkFlank].confusionMoveSlot); structPtr->side[atkSide].field_3_0 = 12; break; case STRINGID_SPIKESSCATTERED: - structPtr->side[defSide].field_8_0 = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[defSide].field_0_0a = moveSlot; + structPtr->side[defSide].spikesMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[defSide].spikesMoveSlot = moveSlot; break; case STRINGID_PKMNHURTBYSPIKES: - if (structPtr->side[scriptingSide].field_8_0 != 0) + if (structPtr->side[scriptingSide].spikesMonId != 0) { - sub_817E684(10, scriptingSide ^ BIT_SIDE, structPtr->side[scriptingSide].field_8_0 - 1, structPtr->side[scriptingSide].field_0_0a); + sub_817E684(10, scriptingSide ^ BIT_SIDE, structPtr->side[scriptingSide].spikesMonId - 1, structPtr->side[scriptingSide].spikesMoveSlot); structPtr->side[scriptingSide].field_3_0 = 7; } break; case STRINGID_PKMNBLEWAWAYSPIKES: - structPtr->side[atkSide].field_8_0 = 0; - structPtr->side[atkSide].field_0_0a = 0; + structPtr->side[atkSide].spikesMonId = 0; + structPtr->side[atkSide].spikesMoveSlot = 0; break; case STRINGID_FIREWEAKENED: - structPtr->pos[atkSide][atkFlank].field_4_0 = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->pos[atkSide][atkFlank].field_3_6 = moveSlot; + structPtr->pos[atkSide][atkFlank].waterSportMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->pos[atkSide][atkFlank].waterSportMoveSlot = moveSlot; break; case STRINGID_ELECTRICITYWEAKENED: - structPtr->pos[atkSide][atkFlank].field_4_3 = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->pos[atkSide][atkFlank].field_4_6 = moveSlot; + structPtr->pos[atkSide][atkFlank].mudSportMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->pos[atkSide][atkFlank].mudSportMoveSlot = moveSlot; break; case STRINGID_ATTACKERFAINTED: sub_817EA80(0); case STRINGID_RETURNMON: - if (structPtr->pos[atkSide][atkFlank].field_4_0 != 0) + if (structPtr->pos[atkSide][atkFlank].waterSportMonId != 0) { - structPtr->pos[atkSide][atkFlank].field_4_0 = 0; - structPtr->pos[atkSide][atkFlank].field_3_6 = 0; + structPtr->pos[atkSide][atkFlank].waterSportMonId = 0; + structPtr->pos[atkSide][atkFlank].waterSportMoveSlot = 0; } - if (structPtr->pos[atkSide][atkFlank].field_4_3 != 0) + if (structPtr->pos[atkSide][atkFlank].mudSportMonId != 0) { - structPtr->pos[atkSide][atkFlank].field_4_3 = 0; - structPtr->pos[atkSide][atkFlank].field_4_6 = 0; + structPtr->pos[atkSide][atkFlank].mudSportMonId = 0; + structPtr->pos[atkSide][atkFlank].mudSportMoveSlot = 0; } break; case STRINGID_TARGETFAINTED: sub_817EA80(1); - if (structPtr->pos[atkSide][defFlank].field_4_0 != 0) + if (structPtr->pos[atkSide][defFlank].waterSportMonId != 0) { - structPtr->pos[atkSide][defFlank].field_4_0 = 0; - structPtr->pos[atkSide][defFlank].field_3_6 = 0; + structPtr->pos[atkSide][defFlank].waterSportMonId = 0; + structPtr->pos[atkSide][defFlank].waterSportMoveSlot = 0; } - if (structPtr->pos[atkSide][defFlank].field_4_3 != 0) + if (structPtr->pos[atkSide][defFlank].mudSportMonId != 0) { - structPtr->pos[atkSide][defFlank].field_4_3 = 0; - structPtr->pos[atkSide][defFlank].field_4_6 = 0; + structPtr->pos[atkSide][defFlank].mudSportMonId = 0; + structPtr->pos[atkSide][defFlank].mudSportMoveSlot = 0; } break; case STRINGID_PKMNRAISEDDEF: case STRINGID_PKMNRAISEDDEFALITTLE: - structPtr->side[atkSide].field_8_0_b = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[atkSide].field_0_0b = moveSlot; + structPtr->side[atkSide].reflectMoveId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[atkSide].reflectMoveSlot = moveSlot; break; case STRINGID_PKMNRAISEDSPDEF: case STRINGID_PKMNRAISEDSPDEFALITTLE: - structPtr->side[atkSide].field_8_0_c = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[atkSide].field_0_0c = moveSlot; + structPtr->side[atkSide].lightScreenMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[atkSide].lightScreenMoveSlot = moveSlot; break; case STRINGID_PKMNSXWOREOFF: if (*finishedMoveId == MOVE_REFLECT) { - structPtr->side[atkSide].field_8_0_b = 0; - structPtr->side[atkSide].field_0_0b = 0; + structPtr->side[atkSide].reflectMoveId = 0; + structPtr->side[atkSide].reflectMoveSlot = 0; } if (*finishedMoveId == MOVE_LIGHT_SCREEN) { - structPtr->side[atkSide].field_8_0_c = 0; - structPtr->side[atkSide].field_0_0c = 0; + structPtr->side[atkSide].lightScreenMonId = 0; + structPtr->side[atkSide].lightScreenMoveSlot = 0; } if (*finishedMoveId == MOVE_MIST) { - structPtr->side[atkSide].field_8_0_e = 0; - structPtr->side[atkSide].field_0_0e = 0; + structPtr->side[atkSide].mistMonId = 0; + structPtr->side[atkSide].mistMoveSlot = 0; } break; case STRINGID_PKMNCOVEREDBYVEIL: - structPtr->side[atkSide].field_8_0_d = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[atkSide].field_0_0d = moveSlot; + structPtr->side[atkSide].safeguardMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[atkSide].safeguardMoveSlot = moveSlot; break; case STRINGID_PKMNUSEDSAFEGUARD: - if (structPtr->side[defSide].field_8_0_d != 0) - sub_817E684(15, 0, structPtr->side[defSide].field_8_0_d - 1, structPtr->side[defSide].field_0_0d); + if (structPtr->side[defSide].safeguardMonId != 0) + sub_817E684(15, 0, structPtr->side[defSide].safeguardMonId - 1, structPtr->side[defSide].safeguardMoveSlot); break; case STRINGID_PKMNSAFEGUARDEXPIRED: - structPtr->side[atkSide].field_8_0_d = 0; - structPtr->side[atkSide].field_0_0d = 0; + structPtr->side[atkSide].safeguardMonId = 0; + structPtr->side[atkSide].safeguardMoveSlot = 0; break; case STRINGID_PKMNSHROUDEDINMIST: - structPtr->side[atkSide].field_8_0_e = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[atkSide].field_0_0e = moveSlot; + structPtr->side[atkSide].mistMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[atkSide].mistMoveSlot = moveSlot; break; case STRINGID_PKMNPROTECTEDBYMIST: - if (structPtr->side[defSide].field_8_0_e != 0) - sub_817E684(16, 0, structPtr->side[defSide].field_8_0_e - 1, structPtr->side[defSide].field_0_0e); + if (structPtr->side[defSide].mistMonId != 0) + sub_817E684(16, 0, structPtr->side[defSide].mistMonId - 1, structPtr->side[defSide].mistMoveSlot); break; case STRINGID_THEWALLSHATTERED: - structPtr->side[defSide].field_8_0_b = 0; - structPtr->side[defSide].field_0_0b = 0; - structPtr->side[defSide].field_8_0_c = 0; - structPtr->side[defSide].field_0_0c = 0; + structPtr->side[defSide].reflectMoveId = 0; + structPtr->side[defSide].reflectMoveSlot = 0; + structPtr->side[defSide].lightScreenMonId = 0; + structPtr->side[defSide].lightScreenMoveSlot = 0; sub_817E684(17, 0, gBattlerPartyIndexes[gBattlerAttacker], moveSlot); break; case STRINGID_PKMNFLINCHED: @@ -512,3 +516,70 @@ void sub_817C95C(u16 stringId) break; } } + +bool8 sub_817E0B8(u16 stringId) +{ + s32 i = 0; + + while (1) + { + if (gUnknown_0860A8A4[i] == stringId) + break; + i++; + if (gUnknown_0860A8A4[i] == 0xFFFF) + break; + } + + if (gUnknown_0860A8A4[i] == 0xFFFF) + return TRUE; + else + return FALSE; +} + +void sub_817E0FC(u16 move, u16 weatherFlags, struct DisableStruct *disableStructPtr) +{ + struct UnknownBattleLinkStruct *structPtr; + u32 atkSide, defSide; + u8 moveSlot; + + if (!(gBattleTypeFlags & BATTLE_TYPE_LINK)) + return; + + structPtr = (struct UnknownBattleLinkStruct*)(&gBattleStruct->field_204); + + atkSide = GetBattlerSide(gBattlerAttacker); + defSide = GetBattlerSide(gBattlerTarget); + moveSlot = GetBattlerMoveSlotId(gBattlerAttacker, move); + + if (moveSlot >= 4) + { + structPtr->side[atkSide].field_3_0 = 15; + return; + } + + structPtr->pos[defSide][GetBattlerPosition(gBattlerAttacker) / 2].field_5_5 = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->pos[defSide][GetBattlerPosition(gBattlerAttacker) / 2].field_6_0 = moveSlot; + structPtr->side[atkSide].field_8_6 = moveSlot; + sub_817E684(0, moveSlot, gBattleMoves[move].effect, 0); + sub_817F394(weatherFlags, move, moveSlot); + if (disableStructPtr->chargeTimer1 != 0) + sub_817E684(7, move, moveSlot, 0); + + if (move == MOVE_WISH) + { + structPtr->side[atkSide].wishMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[atkSide].wishMoveSlot = moveSlot; + } + if (move == MOVE_SELF_DESTRUCT || move == MOVE_EXPLOSION) + { + structPtr->side[atkSide ^ BIT_SIDE].field_4_0_b = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[atkSide ^ BIT_SIDE].field_4_0 = moveSlot; + structPtr->side[atkSide ^ BIT_SIDE].field_3_0 = 13; + structPtr->side[atkSide ^ BIT_SIDE].field_4_0_0 = 1; + } + + sub_817E684(13, gBattleMoves[move].type, gBattleMoves[move].power, 0); + sub_817E684(14, gBattleMoves[move].type, gBattleMoves[move].power, 0); + sub_817E684(11, gBattleMoves[move].type, 0, 0); + sub_817E684(12, gBattleMoves[move].type, 0, 0); +} From 4a45b4de4ecc5fb1dbe12868866737e1fc81b7fb Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 25 Feb 2018 18:45:00 +0100 Subject: [PATCH 05/10] more work --- include/battle.h | 2 +- include/tv.h | 1 + src/battle_link_817C95C.c | 136 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+), 1 deletion(-) diff --git a/include/battle.h b/include/battle.h index 5225b72e3..6d456fd1b 100644 --- a/include/battle.h +++ b/include/battle.h @@ -472,7 +472,7 @@ struct BattleStruct u8 wishPerishSongBattlerId; bool8 overworldWeatherDone; u8 atkCancellerTracker; - u8 field_1A4[96]; + s16 field_1A4[2][6][4]; u8 field_204[104]; u8 field_26C[40]; u8 AI_monToSwitchIntoId[MAX_BATTLERS_COUNT]; diff --git a/include/tv.h b/include/tv.h index eca11385e..8235373ae 100644 --- a/include/tv.h +++ b/include/tv.h @@ -16,5 +16,6 @@ size_t sub_80EF370(int value); bool8 Put3CheersForPokeblocksOnTheAir(const u8 *partnersName, u8 flavor, u8 unused, u8 sheen, u8 language); void SetPokemonAnglerSpecies(u16 species); void UpdateTVShowsPerDay(u16 days); +void PutBattleUpdateOnTheAir(u8 a0, u16 a1, u16 a2, u16 a3); #endif //GUARD_TV_H diff --git a/src/battle_link_817C95C.c b/src/battle_link_817C95C.c index 4b310c273..f951b3da8 100644 --- a/src/battle_link_817C95C.c +++ b/src/battle_link_817C95C.c @@ -3,8 +3,11 @@ #include "battle.h" #include "battle_link_817C95C.h" #include "constants/battle_string_ids.h" +#include "constants/battle_anim.h" #include "constants/moves.h" +#include "constants/species.h" #include "battle_message.h" +#include "tv.h" struct BattleLinkStringSide { @@ -583,3 +586,136 @@ void sub_817E0FC(u16 move, u16 weatherFlags, struct DisableStruct *disableStruct sub_817E684(11, gBattleMoves[move].type, 0, 0); sub_817E684(12, gBattleMoves[move].type, 0, 0); } + +void sub_817E32C(u8 animationId) +{ + struct UnknownBattleLinkStruct *structPtr; + u32 atkSide; + + if (!(gBattleTypeFlags & BATTLE_TYPE_LINK)) + return; + + structPtr = (struct UnknownBattleLinkStruct*)(&gBattleStruct->field_204); + atkSide = GetBattlerSide(gBattlerAttacker); + switch (animationId) + { + case B_ANIM_FUTURE_SIGHT_HIT: + if (structPtr->side[atkSide].futureSightMonId != 0) + { + sub_817E684(2, 0, atkSide, + (structPtr->side[atkSide].futureSightMonId - 1) * 4 + structPtr->side[atkSide].futureSightMoveSlot); + structPtr->side[atkSide].field_3_0 = 8; + } + break; + case B_ANIM_DOOM_DESIRE_HIT: + if (structPtr->side[atkSide].doomDesireMonId != 0) + { + sub_817E684(2, 1, atkSide, + (structPtr->side[atkSide].doomDesireMonId - 1) * 4 + structPtr->side[atkSide].doomDesireMoveSlot); + structPtr->side[atkSide].field_3_0 = 9; + } + break; + } +} + +void sub_817E3F4(void) +{ + u16 playerBestSpecies = 0, opponentBestSpecies = 0; + s16 playerBestSum = 0, opponentBestSum = SHRT_MAX; + u8 playerBestMonId = 0, opponentBestMonId = 0; + s16 (*array)[2][6][4] = NULL; + u8 countPlayer = 0, countOpponent = 0; + s16 sum = 0; + u16 moveId = 0; + s32 i, j; + + if (gBattleStruct->field_B3) + return; + + array = &gBattleStruct->field_1A4; + for (i = 0; i < PARTY_SIZE; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL) != SPECIES_NONE) + countPlayer++; + if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES, NULL) != SPECIES_NONE) + countOpponent++; + } + + if (!(gBattleTypeFlags & BATTLE_TYPE_LINK) || countPlayer != countOpponent) + return; + + for (i = 0; i < PARTY_SIZE; i++) + { + u16 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL); + if (species != SPECIES_NONE && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG, NULL)) + { + for (sum = 0, j = 0; j < 4; j++) + sum += (*array)[0][i][j]; + + if (playerBestSum < sum) + { + playerBestMonId = i; + playerBestSum = sum; + playerBestSpecies = species; + } + } + + species = GetMonData(&gEnemyParty[i], MON_DATA_SPECIES, NULL); + if (species != SPECIES_NONE && !GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG, NULL)) + { + s32 sideId = B_SIDE_OPPONENT; + for (sum = 0, j = 0; j < 4; j++) + sum += (*array)[sideId][i][j]; + + if (opponentBestSum == sum) + { + if (GetMonData(&gEnemyParty[i], MON_DATA_EXP, NULL) > GetMonData(&gEnemyParty[opponentBestMonId], MON_DATA_EXP, NULL)) + { + opponentBestMonId = i; + opponentBestSum = sum; + opponentBestSpecies = species; + } + } + else if (opponentBestSum > sum) + { + opponentBestMonId = i; + opponentBestSum = sum; + opponentBestSpecies = species; + } + } + } + + for (sum = 0, i = 0, j = 0; j < 4; j++) + { + if (sum < (*array)[0][playerBestMonId][j]) + { + sum = (*array)[0][playerBestMonId][j]; + i = j; + } + } + + moveId = GetMonData(&gPlayerParty[playerBestMonId], MON_DATA_MOVE1 + i, NULL); + if (playerBestSum == 0 || moveId == 0) + return; + + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + { + if (playerBestMonId < 3) + { + if (sub_806D82C(gBattleScripting.multiplayerId)) + return; + } + else + { + if (!sub_806D82C(gBattleScripting.multiplayerId)) + return; + } + + j = (opponentBestMonId < 3) ? 0 : 1; + PutBattleUpdateOnTheAir(sub_806EF84(j, gBattleScripting.multiplayerId), moveId, playerBestSpecies, opponentBestSpecies); + } + else + { + PutBattleUpdateOnTheAir(gBattleScripting.multiplayerId ^ 1, moveId, playerBestSpecies, opponentBestSpecies); + } +} From 8ff9cb0edec3d8af7f89d7a7a6f83cc457f0ed7c Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 26 Feb 2018 11:45:47 +0100 Subject: [PATCH 06/10] give up for now --- asm/battle_link_817C95C.s | 423 -------------------------------------- include/battle.h | 2 +- src/battle_link_817C95C.c | 360 ++++++++++++++++++++++++++++++-- 3 files changed, 342 insertions(+), 443 deletions(-) diff --git a/asm/battle_link_817C95C.s b/asm/battle_link_817C95C.s index 234cad55d..7db185572 100644 --- a/asm/battle_link_817C95C.s +++ b/asm/battle_link_817C95C.s @@ -6,429 +6,6 @@ .text - - thumb_func_start sub_817E32C -sub_817E32C: @ 817E32C - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0817E3EE - ldr r0, =gBattleStruct - ldr r0, [r0] - movs r1, 0x81 - lsls r1, 2 - adds r4, r0, r1 - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - lsrs r2, r0, 24 - cmp r5, 0x12 - beq _0817E36C - cmp r5, 0x13 - beq _0817E3AA - b _0817E3EE - .pool -_0817E36C: - lsls r0, r2, 1 - adds r0, r2 - lsls r0, 2 - adds r4, r0 - ldr r0, [r4, 0x50] - lsls r0, 14 - lsrs r0, 29 - cmp r0, 0 - beq _0817E3EE - subs r0, 0x1 - lsls r0, 2 - adds r1, r4, 0 - adds r1, 0x55 - ldrb r3, [r1] - lsls r3, 28 - lsrs r3, 30 - adds r3, r0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x2 - movs r1, 0 - bl sub_817E684 - adds r2, r4, 0 - adds r2, 0x57 - ldrb r1, [r2] - movs r0, 0x1F - negs r0, r0 - ands r0, r1 - movs r1, 0x10 - b _0817E3EA -_0817E3AA: - lsls r0, r2, 1 - adds r0, r2 - lsls r0, 2 - adds r4, r0 - adds r0, r4, 0 - adds r0, 0x52 - ldrb r0, [r0] - lsls r0, 27 - lsrs r0, 29 - cmp r0, 0 - beq _0817E3EE - subs r0, 0x1 - lsls r0, 2 - adds r1, r4, 0 - adds r1, 0x55 - ldrb r3, [r1] - lsls r3, 26 - lsrs r3, 30 - adds r3, r0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x2 - movs r1, 0x1 - bl sub_817E684 - adds r2, r4, 0 - adds r2, 0x57 - ldrb r1, [r2] - movs r0, 0x1F - negs r0, r0 - ands r0, r1 - movs r1, 0x12 -_0817E3EA: - orrs r0, r1 - strb r0, [r2] -_0817E3EE: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_817E32C - - thumb_func_start sub_817E3F4 -sub_817E3F4: @ 817E3F4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x20 - movs r0, 0 - str r0, [sp] - movs r1, 0 - str r1, [sp, 0x4] - movs r2, 0 - str r2, [sp, 0x8] - ldr r3, =0x00007fff - str r3, [sp, 0xC] - movs r4, 0 - str r4, [sp, 0x10] - movs r7, 0 - str r7, [sp, 0x14] - mov r8, r0 - ldr r0, =gBattleStruct - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0xB3 - ldrb r0, [r0] - cmp r0, 0 - beq _0817E42A - b _0817E670 -_0817E42A: - movs r2, 0xD2 - lsls r2, 1 - adds r2, r1 - mov r10, r2 - movs r6, 0 -_0817E434: - movs r0, 0x64 - adds r4, r6, 0 - muls r4, r0 - ldr r0, =gPlayerParty - adds r0, r4, r0 - movs r1, 0xB - movs r2, 0 - bl GetMonData - cmp r0, 0 - beq _0817E454 - mov r0, r8 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 -_0817E454: - ldr r5, =gEnemyParty - adds r0, r4, r5 - movs r1, 0xB - movs r2, 0 - bl GetMonData - cmp r0, 0 - beq _0817E46A - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 -_0817E46A: - adds r6, 0x1 - cmp r6, 0x5 - ble _0817E434 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x2 - ands r0, r1 - cmp r0, 0 - bne _0817E47E - b _0817E670 -_0817E47E: - cmp r8, r7 - beq _0817E484 - b _0817E670 -_0817E484: - movs r6, 0 - lsls r3, r6, 1 - str r3, [sp, 0x18] - movs r4, 0x64 - mov r8, r4 -_0817E48E: - mov r1, r8 - muls r1, r6 - ldr r0, =gPlayerParty - adds r4, r1, r0 - adds r0, r4, 0 - movs r1, 0xB - movs r2, 0 - bl GetMonData - lsls r0, 16 - lsrs r7, r0, 16 - adds r0, r6, 0x1 - mov r9, r0 - cmp r7, 0 - beq _0817E4EE - adds r0, r4, 0 - movs r1, 0x2D - movs r2, 0 - bl GetMonData - cmp r0, 0 - bne _0817E4EE - movs r4, 0 - lsls r0, r6, 3 - mov r2, r10 - adds r1, r0, r2 - movs r3, 0x3 -_0817E4C4: - lsls r0, r4, 16 - asrs r0, 16 - ldrh r4, [r1] - adds r0, r4 - lsls r0, 16 - lsrs r4, r0, 16 - adds r1, 0x2 - subs r3, 0x1 - cmp r3, 0 - bge _0817E4C4 - ldr r1, [sp, 0x8] - lsls r0, r1, 16 - lsls r1, r4, 16 - cmp r0, r1 - bge _0817E4EE - lsls r0, r6, 24 - lsrs r0, 24 - str r0, [sp, 0x10] - lsrs r1, 16 - str r1, [sp, 0x8] - str r7, [sp] -_0817E4EE: - mov r0, r8 - muls r0, r6 - ldr r2, =gEnemyParty - adds r4, r0, r2 - adds r0, r4, 0 - movs r1, 0xB - movs r2, 0 - bl GetMonData - lsls r0, 16 - lsrs r7, r0, 16 - ldr r3, [sp, 0x8] - lsls r3, 16 - str r3, [sp, 0x1C] - cmp r7, 0 - beq _0817E5A0 - adds r0, r4, 0 - movs r1, 0x2D - movs r2, 0 - bl GetMonData - cmp r0, 0 - bne _0817E5A0 - movs r4, 0 - ldr r0, [sp, 0xC] - lsls r2, r0, 16 - movs r3, 0x1 - lsls r1, r3, 1 - adds r1, 0x1 - lsls r1, 4 - lsls r0, r6, 3 - adds r0, r1 - mov r3, r10 - adds r1, r0, r3 - movs r3, 0x3 -_0817E534: - lsls r0, r4, 16 - asrs r0, 16 - ldrh r4, [r1] - adds r0, r4 - lsls r0, 16 - lsrs r4, r0, 16 - adds r1, 0x2 - subs r3, 0x1 - cmp r3, 0 - bge _0817E534 - asrs r1, r2, 16 - lsls r5, r4, 16 - asrs r0, r5, 16 - cmp r1, r0 - bne _0817E590 - mov r0, r8 - muls r0, r6 - ldr r1, =gEnemyParty - adds r0, r1 - movs r1, 0x19 - movs r2, 0 - bl GetMonData - adds r4, r0, 0 - ldr r2, [sp, 0x14] - mov r0, r8 - muls r0, r2 - ldr r3, =gEnemyParty - adds r0, r3 - movs r1, 0x19 - movs r2, 0 - bl GetMonData - cmp r4, r0 - bls _0817E5A0 - b _0817E594 - .pool -_0817E590: - cmp r1, r0 - ble _0817E5A0 -_0817E594: - lsls r0, r6, 24 - lsrs r0, 24 - str r0, [sp, 0x14] - lsrs r5, 16 - str r5, [sp, 0xC] - str r7, [sp, 0x4] -_0817E5A0: - mov r6, r9 - cmp r6, 0x5 - bgt _0817E5A8 - b _0817E48E -_0817E5A8: - movs r4, 0 - movs r6, 0 - movs r3, 0 - ldr r5, =gPlayerParty - ldr r7, [sp, 0x10] - lsls r0, r7, 3 - mov r1, r10 - adds r2, r0, r1 -_0817E5B8: - lsls r0, r4, 16 - asrs r0, 16 - movs r7, 0 - ldrsh r1, [r2, r7] - cmp r0, r1 - bge _0817E5C8 - ldrh r4, [r2] - adds r6, r3, 0 -_0817E5C8: - adds r2, 0x2 - adds r3, 0x1 - cmp r3, 0x3 - ble _0817E5B8 - movs r0, 0x64 - ldr r1, [sp, 0x10] - muls r0, r1 - adds r0, r5 - adds r1, r6, 0 - adds r1, 0xD - movs r2, 0 - bl GetMonData - lsls r0, 16 - lsrs r4, r0, 16 - ldr r2, [sp, 0x1C] - cmp r2, 0 - beq _0817E670 - cmp r4, 0 - beq _0817E670 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x40 - ands r0, r1 - cmp r0, 0 - beq _0817E65C - ldr r3, [sp, 0x10] - cmp r3, 0x2 - bhi _0817E620 - ldr r0, =gBattleScripting - adds r0, 0x25 - ldrb r0, [r0] - bl sub_806D82C - lsls r0, 16 - cmp r0, 0 - beq _0817E630 - b _0817E670 - .pool -_0817E620: - ldr r0, =gBattleScripting - adds r0, 0x25 - ldrb r0, [r0] - bl sub_806D82C - lsls r0, 16 - cmp r0, 0 - beq _0817E670 -_0817E630: - movs r3, 0 - ldr r7, [sp, 0x14] - cmp r7, 0x2 - bls _0817E63A - movs r3, 0x1 -_0817E63A: - lsls r0, r3, 24 - lsrs r0, 24 - ldr r1, =gBattleScripting - adds r1, 0x25 - ldrb r1, [r1] - bl sub_806EF84 - lsls r0, 24 - lsrs r0, 24 - adds r1, r4, 0 - ldr r2, [sp] - ldr r3, [sp, 0x4] - bl PutBattleUpdateOnTheAir - b _0817E670 - .pool -_0817E65C: - ldr r0, =gBattleScripting - adds r0, 0x25 - ldrb r1, [r0] - movs r0, 0x1 - eors r0, r1 - adds r1, r4, 0 - ldr r2, [sp] - ldr r3, [sp, 0x4] - bl PutBattleUpdateOnTheAir -_0817E670: - add sp, 0x20 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817E3F4 - thumb_func_start sub_817E684 sub_817E684: @ 817E684 push {r4-r7,lr} diff --git a/include/battle.h b/include/battle.h index 6d456fd1b..71e8f336d 100644 --- a/include/battle.h +++ b/include/battle.h @@ -472,7 +472,7 @@ struct BattleStruct u8 wishPerishSongBattlerId; bool8 overworldWeatherDone; u8 atkCancellerTracker; - s16 field_1A4[2][6][4]; + s16 field_1A4[2][PARTY_SIZE * 4]; u8 field_204[104]; u8 field_26C[40]; u8 AI_monToSwitchIntoId[MAX_BATTLERS_COUNT]; diff --git a/src/battle_link_817C95C.c b/src/battle_link_817C95C.c index f951b3da8..c92a963eb 100644 --- a/src/battle_link_817C95C.c +++ b/src/battle_link_817C95C.c @@ -618,21 +618,24 @@ void sub_817E32C(u8 animationId) } } +#ifdef NONMATCHING +// for loop has an unused stack variable void sub_817E3F4(void) { u16 playerBestSpecies = 0, opponentBestSpecies = 0; s16 playerBestSum = 0, opponentBestSum = SHRT_MAX; u8 playerBestMonId = 0, opponentBestMonId = 0; - s16 (*array)[2][6][4] = NULL; + s16 *array = NULL; u8 countPlayer = 0, countOpponent = 0; s16 sum = 0; + u16 species = 0; u16 moveId = 0; s32 i, j; if (gBattleStruct->field_B3) return; - array = &gBattleStruct->field_1A4; + array = (void*) &gBattleStruct->field_1A4[0]; for (i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL) != SPECIES_NONE) @@ -646,11 +649,11 @@ void sub_817E3F4(void) for (i = 0; i < PARTY_SIZE; i++) { - u16 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL); + species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL); if (species != SPECIES_NONE && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG, NULL)) { for (sum = 0, j = 0; j < 4; j++) - sum += (*array)[0][i][j]; + sum += array[i * 4 + j]; if (playerBestSum < sum) { @@ -663,9 +666,8 @@ void sub_817E3F4(void) species = GetMonData(&gEnemyParty[i], MON_DATA_SPECIES, NULL); if (species != SPECIES_NONE && !GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG, NULL)) { - s32 sideId = B_SIDE_OPPONENT; for (sum = 0, j = 0; j < 4; j++) - sum += (*array)[sideId][i][j]; + sum += array[i * 4 + j]; if (opponentBestSum == sum) { @@ -687,9 +689,9 @@ void sub_817E3F4(void) for (sum = 0, i = 0, j = 0; j < 4; j++) { - if (sum < (*array)[0][playerBestMonId][j]) + if (sum < array[playerBestMonId * 4 + j]) { - sum = (*array)[0][playerBestMonId][j]; + sum = array[playerBestMonId * 4 + j]; i = j; } } @@ -700,22 +702,342 @@ void sub_817E3F4(void) if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - if (playerBestMonId < 3) + if ((playerBestMonId < 3 && !sub_806D82C(gBattleScripting.multiplayerId)) + || (playerBestMonId >= 3 && sub_806D82C(gBattleScripting.multiplayerId))) { - if (sub_806D82C(gBattleScripting.multiplayerId)) - return; + j = (opponentBestMonId < 3) ? 0 : 1; + PutBattleUpdateOnTheAir(sub_806EF84(j, gBattleScripting.multiplayerId), moveId, playerBestSpecies, opponentBestSpecies); } - else - { - if (!sub_806D82C(gBattleScripting.multiplayerId)) - return; - } - - j = (opponentBestMonId < 3) ? 0 : 1; - PutBattleUpdateOnTheAir(sub_806EF84(j, gBattleScripting.multiplayerId), moveId, playerBestSpecies, opponentBestSpecies); } else { PutBattleUpdateOnTheAir(gBattleScripting.multiplayerId ^ 1, moveId, playerBestSpecies, opponentBestSpecies); } } + +#else +ASM_DIRECT +void sub_817E3F4(void) +{ + asm_unified( + "push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x20\n\ + movs r0, 0\n\ + str r0, [sp]\n\ + movs r1, 0\n\ + str r1, [sp, 0x4]\n\ + movs r2, 0\n\ + str r2, [sp, 0x8]\n\ + ldr r3, =0x00007fff\n\ + str r3, [sp, 0xC]\n\ + movs r4, 0\n\ + str r4, [sp, 0x10]\n\ + movs r7, 0\n\ + str r7, [sp, 0x14]\n\ + mov r8, r0\n\ + ldr r0, =gBattleStruct\n\ + ldr r1, [r0]\n\ + adds r0, r1, 0\n\ + adds r0, 0xB3\n\ + ldrb r0, [r0]\n\ + cmp r0, 0\n\ + beq _0817E42A\n\ + b _0817E670\n\ +_0817E42A:\n\ + movs r2, 0xD2\n\ + lsls r2, 1\n\ + adds r2, r1\n\ + mov r10, r2\n\ + movs r6, 0\n\ +_0817E434:\n\ + movs r0, 0x64\n\ + adds r4, r6, 0\n\ + muls r4, r0\n\ + ldr r0, =gPlayerParty\n\ + adds r0, r4, r0\n\ + movs r1, 0xB\n\ + movs r2, 0\n\ + bl GetMonData\n\ + cmp r0, 0\n\ + beq _0817E454\n\ + mov r0, r8\n\ + adds r0, 0x1\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r8, r0\n\ +_0817E454:\n\ + ldr r5, =gEnemyParty\n\ + adds r0, r4, r5\n\ + movs r1, 0xB\n\ + movs r2, 0\n\ + bl GetMonData\n\ + cmp r0, 0\n\ + beq _0817E46A\n\ + adds r0, r7, 0x1\n\ + lsls r0, 24\n\ + lsrs r7, r0, 24\n\ +_0817E46A:\n\ + adds r6, 0x1\n\ + cmp r6, 0x5\n\ + ble _0817E434\n\ + ldr r0, =gBattleTypeFlags\n\ + ldr r0, [r0]\n\ + movs r1, 0x2\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _0817E47E\n\ + b _0817E670\n\ +_0817E47E:\n\ + cmp r8, r7\n\ + beq _0817E484\n\ + b _0817E670\n\ +_0817E484:\n\ + movs r6, 0\n\ + lsls r3, r6, 1\n\ + str r3, [sp, 0x18]\n\ + movs r4, 0x64\n\ + mov r8, r4\n\ +_0817E48E:\n\ + mov r1, r8\n\ + muls r1, r6\n\ + ldr r0, =gPlayerParty\n\ + adds r4, r1, r0\n\ + adds r0, r4, 0\n\ + movs r1, 0xB\n\ + movs r2, 0\n\ + bl GetMonData\n\ + lsls r0, 16\n\ + lsrs r7, r0, 16\n\ + adds r0, r6, 0x1\n\ + mov r9, r0\n\ + cmp r7, 0\n\ + beq _0817E4EE\n\ + adds r0, r4, 0\n\ + movs r1, 0x2D\n\ + movs r2, 0\n\ + bl GetMonData\n\ + cmp r0, 0\n\ + bne _0817E4EE\n\ + movs r4, 0\n\ + lsls r0, r6, 3\n\ + mov r2, r10\n\ + adds r1, r0, r2\n\ + movs r3, 0x3\n\ +_0817E4C4:\n\ + lsls r0, r4, 16\n\ + asrs r0, 16\n\ + ldrh r4, [r1]\n\ + adds r0, r4\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + adds r1, 0x2\n\ + subs r3, 0x1\n\ + cmp r3, 0\n\ + bge _0817E4C4\n\ + ldr r1, [sp, 0x8]\n\ + lsls r0, r1, 16\n\ + lsls r1, r4, 16\n\ + cmp r0, r1\n\ + bge _0817E4EE\n\ + lsls r0, r6, 24\n\ + lsrs r0, 24\n\ + str r0, [sp, 0x10]\n\ + lsrs r1, 16\n\ + str r1, [sp, 0x8]\n\ + str r7, [sp]\n\ +_0817E4EE:\n\ + mov r0, r8\n\ + muls r0, r6\n\ + ldr r2, =gEnemyParty\n\ + adds r4, r0, r2\n\ + adds r0, r4, 0\n\ + movs r1, 0xB\n\ + movs r2, 0\n\ + bl GetMonData\n\ + lsls r0, 16\n\ + lsrs r7, r0, 16\n\ + ldr r3, [sp, 0x8]\n\ + lsls r3, 16\n\ + str r3, [sp, 0x1C]\n\ + cmp r7, 0\n\ + beq _0817E5A0\n\ + adds r0, r4, 0\n\ + movs r1, 0x2D\n\ + movs r2, 0\n\ + bl GetMonData\n\ + cmp r0, 0\n\ + bne _0817E5A0\n\ + movs r4, 0\n\ + ldr r0, [sp, 0xC]\n\ + lsls r2, r0, 16\n\ + movs r3, 0x1\n\ + lsls r1, r3, 1\n\ + adds r1, 0x1\n\ + lsls r1, 4\n\ + lsls r0, r6, 3\n\ + adds r0, r1\n\ + mov r3, r10\n\ + adds r1, r0, r3\n\ + movs r3, 0x3\n\ +_0817E534:\n\ + lsls r0, r4, 16\n\ + asrs r0, 16\n\ + ldrh r4, [r1]\n\ + adds r0, r4\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + adds r1, 0x2\n\ + subs r3, 0x1\n\ + cmp r3, 0\n\ + bge _0817E534\n\ + asrs r1, r2, 16\n\ + lsls r5, r4, 16\n\ + asrs r0, r5, 16\n\ + cmp r1, r0\n\ + bne _0817E590\n\ + mov r0, r8\n\ + muls r0, r6\n\ + ldr r1, =gEnemyParty\n\ + adds r0, r1\n\ + movs r1, 0x19\n\ + movs r2, 0\n\ + bl GetMonData\n\ + adds r4, r0, 0\n\ + ldr r2, [sp, 0x14]\n\ + mov r0, r8\n\ + muls r0, r2\n\ + ldr r3, =gEnemyParty\n\ + adds r0, r3\n\ + movs r1, 0x19\n\ + movs r2, 0\n\ + bl GetMonData\n\ + cmp r4, r0\n\ + bls _0817E5A0\n\ + b _0817E594\n\ + .pool\n\ +_0817E590:\n\ + cmp r1, r0\n\ + ble _0817E5A0\n\ +_0817E594:\n\ + lsls r0, r6, 24\n\ + lsrs r0, 24\n\ + str r0, [sp, 0x14]\n\ + lsrs r5, 16\n\ + str r5, [sp, 0xC]\n\ + str r7, [sp, 0x4]\n\ +_0817E5A0:\n\ + mov r6, r9\n\ + cmp r6, 0x5\n\ + bgt _0817E5A8\n\ + b _0817E48E\n\ +_0817E5A8:\n\ + movs r4, 0\n\ + movs r6, 0\n\ + movs r3, 0\n\ + ldr r5, =gPlayerParty\n\ + ldr r7, [sp, 0x10]\n\ + lsls r0, r7, 3\n\ + mov r1, r10\n\ + adds r2, r0, r1\n\ +_0817E5B8:\n\ + lsls r0, r4, 16\n\ + asrs r0, 16\n\ + movs r7, 0\n\ + ldrsh r1, [r2, r7]\n\ + cmp r0, r1\n\ + bge _0817E5C8\n\ + ldrh r4, [r2]\n\ + adds r6, r3, 0\n\ +_0817E5C8:\n\ + adds r2, 0x2\n\ + adds r3, 0x1\n\ + cmp r3, 0x3\n\ + ble _0817E5B8\n\ + movs r0, 0x64\n\ + ldr r1, [sp, 0x10]\n\ + muls r0, r1\n\ + adds r0, r5\n\ + adds r1, r6, 0\n\ + adds r1, 0xD\n\ + movs r2, 0\n\ + bl GetMonData\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + ldr r2, [sp, 0x1C]\n\ + cmp r2, 0\n\ + beq _0817E670\n\ + cmp r4, 0\n\ + beq _0817E670\n\ + ldr r0, =gBattleTypeFlags\n\ + ldr r0, [r0]\n\ + movs r1, 0x40\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0817E65C\n\ + ldr r3, [sp, 0x10]\n\ + cmp r3, 0x2\n\ + bhi _0817E620\n\ + ldr r0, =gBattleScripting\n\ + adds r0, 0x25\n\ + ldrb r0, [r0]\n\ + bl sub_806D82C\n\ + lsls r0, 16\n\ + cmp r0, 0\n\ + beq _0817E630\n\ + b _0817E670\n\ + .pool\n\ +_0817E620:\n\ + ldr r0, =gBattleScripting\n\ + adds r0, 0x25\n\ + ldrb r0, [r0]\n\ + bl sub_806D82C\n\ + lsls r0, 16\n\ + cmp r0, 0\n\ + beq _0817E670\n\ +_0817E630:\n\ + movs r3, 0\n\ + ldr r7, [sp, 0x14]\n\ + cmp r7, 0x2\n\ + bls _0817E63A\n\ + movs r3, 0x1\n\ +_0817E63A:\n\ + lsls r0, r3, 24\n\ + lsrs r0, 24\n\ + ldr r1, =gBattleScripting\n\ + adds r1, 0x25\n\ + ldrb r1, [r1]\n\ + bl sub_806EF84\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + adds r1, r4, 0\n\ + ldr r2, [sp]\n\ + ldr r3, [sp, 0x4]\n\ + bl PutBattleUpdateOnTheAir\n\ + b _0817E670\n\ + .pool\n\ +_0817E65C:\n\ + ldr r0, =gBattleScripting\n\ + adds r0, 0x25\n\ + ldrb r1, [r0]\n\ + movs r0, 0x1\n\ + eors r0, r1\n\ + adds r1, r4, 0\n\ + ldr r2, [sp]\n\ + ldr r3, [sp, 0x4]\n\ + bl PutBattleUpdateOnTheAir\n\ +_0817E670:\n\ + add sp, 0x20\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool"); +} +#endif From a9212eeb664efcdfb74a2f4bbc5e94f37e27e748 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 27 Feb 2018 18:13:28 +0100 Subject: [PATCH 07/10] battle file more done and clean up tv --- asm/battle_link_817C95C.s | 1433 ------------------------------ asm/field_specials.s | 4 +- include/battle.h | 95 +- include/battle_script_commands.h | 8 +- include/tv.h | 43 +- src/battle_controllers.c | 4 +- src/battle_link_817C95C.c | 461 +++++++--- src/pokemon.c | 20 +- src/scrcmd.c | 2 +- src/tv.c | 456 +++++----- 10 files changed, 719 insertions(+), 1807 deletions(-) diff --git a/asm/battle_link_817C95C.s b/asm/battle_link_817C95C.s index 7db185572..91406075d 100644 --- a/asm/battle_link_817C95C.s +++ b/asm/battle_link_817C95C.s @@ -5,1439 +5,6 @@ .text - - thumb_func_start sub_817E684 -sub_817E684: @ 817E684 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - lsls r1, 16 - lsrs r6, r1, 16 - lsls r2, 24 - lsrs r5, r2, 24 - lsls r3, 24 - lsrs r3, 24 - mov r9, r3 - ldr r0, =gBattleStruct - ldr r0, [r0] - movs r1, 0xD2 - lsls r1, 1 - adds r1, r0 - mov r8, r1 - movs r2, 0x81 - lsls r2, 2 - adds r7, r0, r2 - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gBattlerTarget - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - lsrs r3, r0, 24 - mov r0, r10 - cmp r0, 0x1B - bls _0817E6D4 - b _0817EA6C -_0817E6D4: - lsls r0, 2 - ldr r1, =_0817E6F0 - adds r1, r0, r1 - ldr r1, [r1] - mov r12, r0 - mov pc, r1 - .pool - .align 2, 0 -_0817E6F0: - .4byte _0817E760 - .4byte _0817E760 - .4byte _0817E85C - .4byte _0817E79C - .4byte _0817E79C - .4byte _0817E79C - .4byte _0817E79C - .4byte _0817E79C - .4byte _0817E8A0 - .4byte _0817E8A0 - .4byte _0817E8CC - .4byte _0817E8F0 - .4byte _0817E978 - .4byte _0817E9E0 - .4byte _0817EA28 - .4byte _0817E8A0 - .4byte _0817E8A0 - .4byte _0817E880 - .4byte _0817E760 - .4byte _0817E80A - .4byte _0817E848 - .4byte _0817E8A0 - .4byte _0817E760 - .4byte _0817E760 - .4byte _0817E760 - .4byte _0817E760 - .4byte _0817E760 - .4byte _0817E760 -_0817E760: - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - lsls r1, 2 - adds r1, r6 - lsls r1, 1 - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 4 - adds r1, r0 - add r1, r8 - ldr r0, =gUnknown_0860A834 - add r0, r12 - ldr r2, [r0] - lsls r0, r5, 1 - adds r0, r2 - ldrh r0, [r0] - ldrh r2, [r1] - adds r0, r2 - b _0817EA6A - .pool -_0817E79C: - ldr r1, =gUnknown_0860A834 - add r1, r12 - ldr r7, =gBattlerPartyIndexes - lsls r0, r4, 1 - adds r0, r4 - lsls r2, r0, 4 - ldr r4, =0x0000ffff - ldr r1, [r1] - ldr r3, =gBattlerAttacker - ldrh r0, [r1] - cmp r6, r0 - bne _0817E7E0 - ldrb r0, [r3] - lsls r0, 1 - adds r0, r7 - ldrh r0, [r0] - lsls r0, 2 - adds r0, r5 - lsls r0, 1 - adds r0, r2 - add r0, r8 - ldrh r1, [r1, 0x2] - ldrh r2, [r0] - adds r1, r2 - strh r1, [r0] - b _0817EA6C - .pool -_0817E7E0: - adds r1, 0x4 - ldrh r0, [r1] - cmp r0, r4 - bne _0817E7EA - b _0817EA6C -_0817E7EA: - cmp r6, r0 - bne _0817E7E0 - ldrb r0, [r3] - lsls r0, 1 - adds r0, r7 - ldrh r0, [r0] - lsls r0, 2 - adds r0, r5 - lsls r0, 1 - adds r0, r2 - add r0, r8 - ldrh r1, [r1, 0x2] - ldrh r5, [r0] - adds r1, r5 - strh r1, [r0] - b _0817EA6C -_0817E80A: - movs r0, 0x1 - adds r1, r5, 0 - eors r1, r0 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r7, r0 - adds r0, 0x57 - ldrb r2, [r0] - movs r1, 0x1F - negs r1, r1 - ands r1, r2 - strb r1, [r0] - mov r0, r9 - lsls r1, r0, 1 - lsls r0, r5, 1 - adds r0, r5 - lsls r0, 4 - adds r1, r0 - add r1, r8 - ldr r0, =gUnknown_0860A834 - add r0, r12 - ldr r2, [r0] - lsls r0, r6, 1 - adds r0, r2 - ldrh r0, [r0] - ldrh r2, [r1] - adds r0, r2 - b _0817EA6A - .pool -_0817E848: - lsls r0, r5, 1 - adds r0, r5 - lsls r0, 2 - adds r0, r7, r0 - adds r0, 0x57 - ldrb r2, [r0] - movs r1, 0x1F - negs r1, r1 - ands r1, r2 - strb r1, [r0] -_0817E85C: - mov r0, r9 - lsls r1, r0, 1 - lsls r0, r5, 1 - adds r0, r5 - lsls r0, 4 - adds r1, r0 - add r1, r8 - ldr r0, =gUnknown_0860A834 - add r0, r12 - ldr r2, [r0] - lsls r0, r6, 1 - adds r0, r2 - ldrh r0, [r0] - ldrh r2, [r1] - adds r0, r2 - b _0817EA6A - .pool -_0817E880: - lsls r1, r5, 2 - add r1, r9 - lsls r1, 1 - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 4 - adds r1, r0 - add r1, r8 - ldr r0, =gUnknown_0860A834 - add r0, r12 - ldr r2, [r0] - lsls r0, r6, 1 - adds r0, r2 - b _0817EA64 - .pool -_0817E8A0: - lsls r2, r5, 2 - add r2, r9 - lsls r2, 1 - movs r1, 0x1 - eors r1, r4 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 4 - adds r2, r0 - add r2, r8 - ldr r0, =gUnknown_0860A834 - add r0, r12 - ldr r1, [r0] - lsls r0, r6, 1 - adds r0, r1 - ldrh r0, [r0] - ldrh r1, [r2] - adds r0, r1 - strh r0, [r2] - b _0817EA6C - .pool -_0817E8CC: - lsls r1, r5, 2 - add r1, r9 - lsls r1, 1 - lsls r0, r6, 1 - adds r0, r6 - lsls r0, 4 - adds r1, r0 - add r1, r8 - ldr r0, =gUnknown_0860A834 - add r0, r12 - ldr r0, [r0] - ldrh r0, [r0] - ldrh r2, [r1] - adds r0, r2 - b _0817EA6A - .pool -_0817E8F0: - lsls r0, r3, 4 - adds r2, r7, r0 - adds r0, r2, 0 - adds r0, 0x34 - ldrb r0, [r0] - lsls r0, 29 - lsrs r1, r0, 29 - adds r4, r2, 0 - adds r4, 0x3C - ldrb r0, [r4] - lsls r0, 29 - lsrs r0, 29 - cmn r1, r0 - bne _0817E90E - b _0817EA6C -_0817E90E: - cmp r6, 0xA - beq _0817E914 - b _0817EA6C -_0817E914: - cmp r1, 0 - beq _0817E940 - subs r1, 0x1 - lsls r1, 2 - adds r0, r2, 0 - adds r0, 0x33 - ldrb r0, [r0] - lsrs r0, 6 - adds r1, r0 - lsls r1, 1 - lsls r0, r3, 1 - adds r0, r3 - lsls r0, 4 - adds r1, r0 - add r1, r8 - ldr r0, =gUnknown_0860A834 - add r0, r12 - ldr r0, [r0] - ldrh r0, [r0] - ldrh r5, [r1] - adds r0, r5 - strh r0, [r1] -_0817E940: - ldrb r0, [r4] - lsls r0, 29 - lsrs r0, 29 - cmp r0, 0 - bne _0817E94C - b _0817EA6C -_0817E94C: - subs r1, r0, 0x1 - lsls r1, 2 - adds r0, r2, 0 - adds r0, 0x3B - ldrb r0, [r0] - lsrs r0, 6 - adds r1, r0 - lsls r1, 1 - lsls r0, r3, 1 - adds r0, r3 - lsls r0, 4 - adds r1, r0 - add r1, r8 - ldr r0, =gUnknown_0860A834 - add r0, r12 - ldr r0, [r0] - ldrh r0, [r0] - ldrh r2, [r1] - adds r0, r2 - b _0817EA6A - .pool -_0817E978: - lsls r1, r3, 4 - adds r1, r7, r1 - adds r0, r1, 0 - adds r0, 0x34 - ldrb r4, [r0] - lsls r0, r4, 26 - lsrs r2, r0, 29 - adds r5, r1, 0 - adds r5, 0x3C - ldrb r0, [r5] - lsls r0, 26 - lsrs r0, 29 - cmn r2, r0 - beq _0817EA6C - cmp r6, 0xD - bne _0817EA6C - cmp r2, 0 - beq _0817E9BE - subs r1, r2, 0x1 - lsls r1, 2 - lsrs r0, r4, 6 - adds r1, r0 - lsls r1, 1 - lsls r0, r3, 1 - adds r0, r3 - lsls r0, 4 - adds r1, r0 - add r1, r8 - ldr r0, =gUnknown_0860A834 - add r0, r12 - ldr r0, [r0] - ldrh r0, [r0] - ldrh r2, [r1] - adds r0, r2 - strh r0, [r1] -_0817E9BE: - ldrb r2, [r5] - lsls r0, r2, 26 - lsrs r0, 29 - cmp r0, 0 - beq _0817EA6C - subs r1, r0, 0x1 - lsls r1, 2 - lsrs r0, r2, 6 - adds r1, r0 - lsls r1, 1 - lsls r0, r3, 1 - adds r0, r3 - lsls r0, 4 - b _0817EA5A - .pool -_0817E9E0: - cmp r6, 0x8 - bhi _0817EA6C - cmp r5, 0 - beq _0817EA6C - lsls r0, r3, 1 - adds r3, r0, r3 - lsls r0, r3, 2 - adds r2, r7, r0 - adds r0, r2, 0 - adds r0, 0x50 - ldrb r0, [r0] - lsls r0, 26 - lsrs r0, 29 - cmp r0, 0 - beq _0817EA6C - subs r1, r0, 0x1 - lsls r1, 2 - adds r0, r2, 0 - adds r0, 0x54 - ldrb r0, [r0] - lsls r0, 28 - lsrs r0, 30 - adds r1, r0 - lsls r1, 1 - lsls r0, r3, 4 - adds r1, r0 - add r1, r8 - ldr r0, =gUnknown_0860A834 - add r0, r12 - ldr r0, [r0] - ldrh r0, [r0] - ldrh r2, [r1] - adds r0, r2 - b _0817EA6A - .pool -_0817EA28: - cmp r6, 0x8 - bls _0817EA6C - cmp r5, 0 - beq _0817EA6C - lsls r0, r3, 1 - adds r3, r0, r3 - lsls r0, r3, 2 - adds r2, r7, r0 - adds r0, r2, 0 - adds r0, 0x50 - ldrh r0, [r0] - lsls r0, 23 - lsrs r0, 29 - cmp r0, 0 - beq _0817EA6C - subs r1, r0, 0x1 - lsls r1, 2 - adds r0, r2, 0 - adds r0, 0x54 - ldrb r0, [r0] - lsls r0, 26 - lsrs r0, 30 - adds r1, r0 - lsls r1, 1 - lsls r0, r3, 4 -_0817EA5A: - adds r1, r0 - add r1, r8 - ldr r0, =gUnknown_0860A834 - add r0, r12 - ldr r0, [r0] -_0817EA64: - ldrh r0, [r0] - ldrh r5, [r1] - adds r0, r5 -_0817EA6A: - strh r0, [r1] -_0817EA6C: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817E684 - - thumb_func_start sub_817EA80 -sub_817EA80: @ 817EA80 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r7, r0, 24 - ldr r0, =gBattleStruct - ldr r0, [r0] - movs r1, 0x81 - lsls r1, 2 - adds r5, r0, r1 - ldr r3, =gBattlerAttacker - mov r8, r3 - ldrb r0, [r3] - bl GetBattlerSide - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gBattlerTarget - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - lsrs r2, r0, 24 - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 2 - adds r6, r5, r0 - adds r0, r6, 0 - adds r0, 0x57 - ldrb r0, [r0] - lsrs r3, r0, 5 - lsls r0, 27 - lsrs r0, 28 - cmp r0, 0 - bne _0817EAC8 - b _0817EE50 -_0817EAC8: - subs r0, 0x1 - cmp r0, 0xE - bls _0817EAD0 - b _0817EEBC -_0817EAD0: - lsls r0, 2 - ldr r1, =_0817EAEC - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0817EAEC: - .4byte _0817EB28 - .4byte _0817EB54 - .4byte _0817EB80 - .4byte _0817EBD4 - .4byte _0817EBFE - .4byte _0817EC26 - .4byte _0817EC4E - .4byte _0817EC6C - .4byte _0817EC9A - .4byte _0817ECCC - .4byte _0817ED54 - .4byte _0817ED82 - .4byte _0817EDC2 - .4byte _0817EE1C - .4byte _0817EEBC -_0817EB28: - lsls r0, r3, 3 - lsls r1, r4, 4 - adds r0, r1 - adds r3, r5, r0 - adds r0, r3, 0 - adds r0, 0x30 - ldrb r0, [r0] - lsls r0, 29 - lsrs r1, r0, 29 - cmp r1, 0 - bne _0817EB40 - b _0817EEBC -_0817EB40: - movs r0, 0x1 - adds r2, r4, 0 - eors r2, r0 - subs r1, 0x1 - lsls r1, 2 - adds r0, r3, 0 - adds r0, 0x32 - ldrb r3, [r0] - lsls r3, 28 - b _0817EE84 -_0817EB54: - lsls r0, r3, 3 - lsls r1, r4, 4 - adds r0, r1 - adds r3, r5, r0 - adds r0, r3, 0 - adds r0, 0x30 - ldrb r0, [r0] - lsls r0, 26 - lsrs r1, r0, 29 - cmp r1, 0 - bne _0817EB6C - b _0817EEBC -_0817EB6C: - movs r0, 0x1 - adds r2, r4, 0 - eors r2, r0 - subs r1, 0x1 - lsls r1, 2 - adds r0, r3, 0 - adds r0, 0x32 - ldrb r3, [r0] - lsls r3, 26 - b _0817EE84 -_0817EB80: - lsls r0, r3, 2 - lsls r1, r4, 1 - adds r1, r4 - lsls r1, 3 - adds r0, r1 - adds r5, r0 - ldrb r0, [r5] - lsls r0, 29 - lsrs r1, r0, 29 - cmp r1, 0 - beq _0817EBB4 - movs r0, 0x1 - adds r2, r4, 0 - eors r2, r0 - subs r0, r1, 0x1 - lsls r0, 2 - ldrb r3, [r5, 0x2] - lsls r3, 28 - lsrs r3, 30 - adds r3, r0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x13 - movs r1, 0 - bl sub_817E684 -_0817EBB4: - ldrb r0, [r5] - lsls r0, 26 - lsrs r1, r0, 29 - cmp r1, 0 - bne _0817EBC0 - b _0817EEBC -_0817EBC0: - movs r0, 0x1 - adds r2, r4, 0 - eors r2, r0 - subs r0, r1, 0x1 - lsls r0, 2 - ldrb r3, [r5, 0x2] - lsls r3, 26 - lsrs r3, 30 - adds r3, r0 - b _0817EE88 -_0817EBD4: - lsls r0, r3, 2 - lsls r1, r4, 1 - adds r1, r4 - lsls r1, 3 - adds r0, r1 - adds r1, r5, r0 - ldrh r0, [r1] - lsls r0, 23 - lsrs r3, r0, 29 - cmp r3, 0 - bne _0817EBEC - b _0817EEBC -_0817EBEC: - movs r0, 0x1 - adds r2, r4, 0 - eors r2, r0 - subs r0, r3, 0x1 - lsls r0, 2 - ldrb r3, [r1, 0x2] - lsrs r3, 6 - adds r3, r0 - b _0817EE88 -_0817EBFE: - lsls r0, r3, 3 - lsls r1, r4, 4 - adds r0, r1 - adds r3, r5, r0 - ldrh r0, [r3, 0x30] - lsls r0, 23 - lsrs r1, r0, 29 - cmp r1, 0 - bne _0817EC12 - b _0817EEBC -_0817EC12: - movs r0, 0x1 - adds r2, r4, 0 - eors r2, r0 - subs r1, 0x1 - lsls r1, 2 - adds r0, r3, 0 - adds r0, 0x32 - ldrb r3, [r0] - lsrs r3, 6 - b _0817EE86 -_0817EC26: - lsls r0, r3, 3 - lsls r1, r4, 4 - adds r0, r1 - adds r3, r5, r0 - adds r0, r3, 0 - adds r0, 0x31 - ldrb r0, [r0] - lsls r0, 28 - lsrs r1, r0, 29 - cmp r1, 0 - bne _0817EC3E - b _0817EEBC -_0817EC3E: - movs r0, 0x1 - adds r2, r4, 0 - eors r2, r0 - subs r1, 0x1 - lsls r1, 2 - adds r0, r3, 0 - adds r0, 0x33 - b _0817EE80 -_0817EC4E: - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 2 - adds r3, r5, r0 - adds r0, r3, 0 - adds r0, 0x50 - ldrb r0, [r0] - lsls r0, 29 - lsrs r1, r0, 29 - cmp r1, 0 - bne _0817EC66 - b _0817EEBC -_0817EC66: - movs r0, 0x1 - adds r2, r4, 0 - b _0817EE76 -_0817EC6C: - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 2 - adds r3, r5, r0 - ldr r0, [r3, 0x50] - lsls r0, 14 - lsrs r0, 29 - cmp r0, 0 - bne _0817EC80 - b _0817EEBC -_0817EC80: - adds r2, r4, 0 - subs r1, r0, 0x1 - lsls r1, 2 - adds r0, r3, 0 - adds r0, 0x55 - ldrb r3, [r0] - lsls r3, 28 - lsrs r3, 30 - adds r3, r1 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x14 - b _0817EE8E -_0817EC9A: - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 2 - adds r3, r5, r0 - adds r0, r3, 0 - adds r0, 0x52 - ldrb r0, [r0] - lsls r0, 27 - lsrs r0, 29 - cmp r0, 0 - bne _0817ECB2 - b _0817EEBC -_0817ECB2: - adds r2, r4, 0 - subs r1, r0, 0x1 - lsls r1, 2 - adds r0, r3, 0 - adds r0, 0x55 - ldrb r3, [r0] - lsls r3, 26 - lsrs r3, 30 - adds r3, r1 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x14 - b _0817EE8E -_0817ECCC: - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 2 - adds r3, r5, r0 - adds r0, r3, 0 - adds r0, 0x58 - ldrb r0, [r0] - lsls r0, 25 - cmp r0, 0 - bge _0817ED14 - adds r0, r3, 0 - adds r0, 0x52 - ldrb r0, [r0] - lsrs r0, 5 - subs r6, r0, 0x1 - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - cmp r6, r0 - beq _0817ED14 - adds r2, r4, 0 - lsls r1, r6, 2 - adds r0, r3, 0 - adds r0, 0x55 - ldrb r3, [r0] - lsrs r3, 6 - adds r3, r1 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x13 - movs r1, 0 - bl sub_817E684 -_0817ED14: - movs r1, 0x1 - eors r1, r4 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r1, r5, r0 - adds r0, r1, 0 - adds r0, 0x58 - ldrb r0, [r0] - lsls r0, 25 - cmp r0, 0 - blt _0817ED2E - b _0817EEBC -_0817ED2E: - movs r0, 0x1 - adds r2, r4, 0 - eors r2, r0 - adds r0, r1, 0 - adds r0, 0x52 - ldrb r0, [r0] - lsrs r0, 5 - subs r0, 0x1 - lsls r0, 2 - adds r1, 0x55 - ldrb r3, [r1] - lsrs r3, 6 - adds r3, r0 - b _0817EE88 - .pool -_0817ED54: - movs r0, 0x1 - eors r0, r4 - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - adds r1, r5, r1 - adds r1, 0x56 - ldrb r0, [r1] - lsls r0, 25 - lsrs r5, r0, 29 - cmp r5, 0 - bne _0817ED6E - b _0817EEBC -_0817ED6E: - movs r0, 0x1 - adds r2, r4, 0 - eors r2, r0 - subs r0, r5, 0x1 - lsls r0, 2 - ldrh r3, [r1] - lsls r3, 23 - lsrs r3, 30 - adds r3, r0 - b _0817EE88 -_0817ED82: - lsls r2, r4, 4 - movs r1, 0x1 - adds r0, r4, 0 - eors r0, r1 - lsls r6, r0, 24 - adds r0, r5, 0 - adds r0, 0x30 - adds r4, r2, r0 - movs r5, 0x1 -_0817ED94: - ldr r0, [r4] - lsls r0, 14 - lsrs r0, 29 - cmp r0, 0 - beq _0817EDB8 - subs r0, 0x1 - lsls r0, 2 - ldrb r3, [r4, 0x3] - lsls r3, 26 - lsrs r3, 30 - adds r3, r0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x13 - movs r1, 0 - lsrs r2, r6, 24 - bl sub_817E684 -_0817EDB8: - adds r4, 0x8 - subs r5, 0x1 - cmp r5, 0 - bge _0817ED94 - b _0817EEBC -_0817EDC2: - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 2 - adds r0, r5, r0 - adds r0, 0x58 - ldrb r3, [r0] - lsls r0, r3, 31 - cmp r0, 0 - beq _0817EDF0 - adds r2, r4, 0 - lsls r0, r3, 26 - lsrs r0, 29 - subs r0, 0x1 - lsls r0, 2 - lsls r3, 29 - lsrs r3, 30 - adds r3, r0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x13 - movs r1, 0 - bl sub_817E684 -_0817EDF0: - movs r0, 0x1 - eors r0, r4 - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - adds r1, r5, r1 - adds r1, 0x58 - ldrb r1, [r1] - lsls r0, r1, 31 - cmp r0, 0 - beq _0817EEBC - movs r0, 0x1 - adds r2, r4, 0 - eors r2, r0 - lsls r0, r1, 26 - lsrs r0, 29 - subs r0, 0x1 - lsls r0, 2 - lsls r3, r1, 29 - lsrs r3, 30 - adds r3, r0 - b _0817EE88 -_0817EE1C: - cmp r7, 0x1 - bne _0817EEBC - adds r2, r4, 0 - ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - lsls r1, 2 - lsls r0, r2, 1 - adds r0, r2 - lsls r0, 2 - adds r0, r5, r0 - adds r0, 0x53 - ldrb r3, [r0] - lsrs r3, 6 - adds r3, r1 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x14 - b _0817EE8E - .pool -_0817EE50: - lsls r0, r2, 1 - adds r0, r2 - lsls r0, 2 - adds r3, r5, r0 - adds r0, r3, 0 - adds r0, 0x57 - ldrb r0, [r0] - lsls r0, 27 - lsrs r0, 28 - cmp r0, 0x7 - bne _0817EE96 - adds r0, r3, 0 - adds r0, 0x50 - ldrb r0, [r0] - lsls r0, 29 - lsrs r1, r0, 29 - cmp r1, 0 - beq _0817EEBC - movs r0, 0x1 -_0817EE76: - eors r2, r0 - subs r1, 0x1 - lsls r1, 2 - adds r0, r3, 0 - adds r0, 0x54 -_0817EE80: - ldrb r3, [r0] - lsls r3, 30 -_0817EE84: - lsrs r3, 30 -_0817EE86: - adds r3, r1 -_0817EE88: - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x13 -_0817EE8E: - movs r1, 0 - bl sub_817E684 - b _0817EEBC -_0817EE96: - adds r2, r4, 0 - ldr r1, =gBattlerPartyIndexes - mov r3, r8 - ldrb r0, [r3] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - lsls r1, 2 - adds r0, r6, 0 - adds r0, 0x53 - ldrb r3, [r0] - lsrs r3, 6 - adds r3, r1 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x14 - movs r1, 0 - bl sub_817E684 -_0817EEBC: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817EA80 - - thumb_func_start sub_817EECC -sub_817EECC: @ 817EECC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x28 - ldr r7, =gBattleTypeFlags - ldr r0, [r7] - ldr r1, =0x02000003 - ands r0, r1 - cmp r0, 0 - beq _0817EEE6 - b _0817F1FA -_0817EEE6: - ldr r4, =gBattlerAttacker - ldrb r0, [r4] - bl GetBattlerSide - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0817EEF8 - b _0817F1FA -_0817EEF8: - ldr r5, =gBattleMons - ldrb r4, [r4] - movs r1, 0x58 - adds r6, r4, 0 - muls r6, r1 - adds r0, r6, r5 - ldrb r0, [r0, 0x1E] - lsls r0, 24 - asrs r0, 24 - cmp r0, 0x5 - bgt _0817EF10 - b _0817F1FA -_0817EF10: - ldr r0, =gBattlerTarget - ldrb r0, [r0] - muls r0, r1 - adds r0, r5 - ldrb r0, [r0, 0x1F] - lsls r0, 24 - asrs r0, 24 - cmp r0, 0x6 - ble _0817EF24 - b _0817F1FA -_0817EF24: - ldr r0, =gCurrentMove - ldrh r1, [r0] - cmp r1, 0xED - bne _0817EF2E - b _0817F1FA -_0817EF2E: - ldr r0, =0x00000137 - cmp r1, r0 - bne _0817EF36 - b _0817F1FA -_0817EF36: - ldr r0, [r7] - movs r1, 0xC8 - lsls r1, 14 - ands r0, r1 - cmp r0, 0 - beq _0817EF44 - b _0817F1FA -_0817EF44: - ldr r3, =gBattleMoves - ldr r2, =gMoveSelectionCursor - adds r0, r4, r2 - ldrb r0, [r0] - lsls r0, 1 - adds r0, r6 - adds r1, r5, 0 - adds r1, 0xC - adds r0, r1 - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrb r0, [r0, 0x1] - adds r6, r2, 0 - cmp r0, 0 - bne _0817EF6A - b _0817F1FA -_0817EF6A: - movs r5, 0 - str r1, [sp, 0x24] - ldr r1, =gUnknown_0860A4AC - ldr r4, =0x0000ffff - adds r3, r1, 0 - adds r2, r1, 0 -_0817EF76: - ldr r0, [sp, 0x24] - ldrh r7, [r2] - cmp r0, r7 - beq _0817EF8A - adds r3, 0x2 - adds r2, 0x2 - adds r5, 0x1 - ldrh r0, [r3] - cmp r0, r4 - bne _0817EF76 -_0817EF8A: - lsls r0, r5, 1 - adds r0, r1 - ldrh r1, [r0] - ldr r0, =0x0000ffff - cmp r1, r0 - beq _0817EF98 - b _0817F1FA -_0817EF98: - ldr r2, =gBattlerAttacker - ldrb r0, [r2] - adds r0, r6 - ldrb r0, [r0] - lsls r0, 2 - mov r1, sp - adds r1, r0 - adds r1, 0x10 - ldr r0, =gBattleMoveDamage - ldr r0, [r0] - str r0, [r1] - ldr r0, =gCurrentMove - ldrh r1, [r0] - str r1, [sp, 0x24] - movs r5, 0 - add r3, sp, 0x20 - mov r10, r3 - mov r8, r0 - add r7, sp, 0x10 - ldr r4, =gBattlerTarget - mov r9, r4 -_0817EFC2: - lsls r1, r5, 1 - ldr r6, =gBattlerAttacker - ldrb r0, [r6] - movs r2, 0x58 - muls r0, r2 - adds r1, r0 - ldr r0, =gBattleMons - adds r0, 0xC - adds r1, r0 - ldrh r0, [r1] - mov r3, r8 - strh r0, [r3] - movs r6, 0 - mov r4, r10 - strh r6, [r4] - ldrh r0, [r3] - adds r1, r7, 0 - mov r2, r10 - bl sub_817F21C - lsls r0, 24 - cmp r0, 0 - beq _0817F0B4 - ldr r4, =gSideStatuses - mov r1, r9 - ldrb r0, [r1] - bl GetBattlerPosition - movs r1, 0x1 - ands r1, r0 - lsls r1, 1 - adds r1, r4 - ldrh r3, [r1] - ldr r2, =gBattlerAttacker - ldrb r0, [r2] - movs r4, 0x58 - muls r0, r4 - ldr r6, =gBattleMons - adds r0, r6 - mov r2, r9 - ldrb r1, [r2] - muls r1, r4 - adds r1, r6 - mov r4, r8 - ldrh r2, [r4] - mov r6, r10 - ldrh r4, [r6] - str r4, [sp] - movs r4, 0 - str r4, [sp, 0x4] - ldr r6, =gBattlerAttacker - ldrb r4, [r6] - str r4, [sp, 0x8] - mov r6, r9 - ldrb r4, [r6] - str r4, [sp, 0xC] - bl CalculateBaseDamage - adds r3, r0, 0 - ldr r4, =gBattleMoveDamage - str r3, [r4] - ldr r1, =gStatuses3 - ldr r2, =gBattlerAttacker - ldrb r0, [r2] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 2 - ands r0, r1 - cmp r0, 0 - beq _0817F06A - ldr r2, =gBattleMoves - mov r6, r8 - ldrh r1, [r6] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x2] - cmp r0, 0xD - bne _0817F06A - lsls r0, r3, 1 - str r0, [r4] -_0817F06A: - ldr r0, =gProtectStructs - ldr r6, =gBattlerAttacker - ldrb r1, [r6] - lsls r1, 4 - adds r1, r0 - ldrb r0, [r1] - lsls r0, 28 - cmp r0, 0 - bge _0817F08C - ldr r4, =gBattleMoveDamage - ldr r1, [r4] - lsls r0, r1, 4 - subs r0, r1 - movs r1, 0xA - bl __divsi3 - str r0, [r4] -_0817F08C: - mov r1, r8 - ldrh r0, [r1] - ldrb r1, [r6] - mov r3, r9 - ldrb r2, [r3] - bl TypeCalc - lsls r0, 24 - lsrs r1, r0, 24 - ldr r0, =gBattleMoveDamage - ldr r0, [r0] - str r0, [r7] - cmp r0, 0 - bne _0817F0B4 - movs r0, 0x29 - ands r0, r1 - cmp r0, 0 - bne _0817F0B4 - movs r0, 0x1 - str r0, [r7] -_0817F0B4: - adds r7, 0x4 - adds r5, 0x1 - cmp r5, 0x3 - ble _0817EFC2 - movs r5, 0 - ldr r3, =gBattlerAttacker - ldr r6, =gMoveSelectionCursor - ldr r4, =gBattlerPartyIndexes - mov r8, r4 - movs r7, 0x64 - mov r9, r7 - mov r10, r6 -_0817F0CC: - ldrb r0, [r3] - adds r0, r6 - ldrb r2, [r0] - cmp r5, r2 - bne _0817F0D8 - b _0817F1D4 -_0817F0D8: - lsls r0, r5, 2 - mov r1, sp - adds r1, r0 - adds r1, 0x10 - lsls r0, r2, 2 - add r0, sp - adds r0, 0x10 - ldr r1, [r1] - ldr r0, [r0] - cmp r1, r0 - ble _0817F1D4 - movs r7, 0x1 - cmp r2, 0 - beq _0817F0F6 - movs r7, 0 -_0817F0F6: - movs r5, 0 - ldr r4, =gBattlerTarget - ldr r6, =gEnemyParty - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - add r0, r10 - ldrb r3, [r0] - add r2, sp, 0x10 -_0817F106: - cmp r5, r3 - beq _0817F11A - lsls r0, r7, 2 - add r0, sp - adds r0, 0x10 - ldr r1, [r2] - ldr r0, [r0] - cmp r1, r0 - ble _0817F11A - adds r7, r5, 0 -_0817F11A: - adds r2, 0x4 - adds r5, 0x1 - cmp r5, 0x3 - ble _0817F106 - ldrb r0, [r4] - lsls r0, 1 - add r0, r8 - ldrh r0, [r0] - mov r1, r9 - muls r1, r0 - adds r0, r1, 0 - adds r0, r6 - movs r1, 0xB - movs r2, 0 - bl GetMonData - adds r6, r0, 0 - lsls r6, 16 - lsrs r6, 16 - ldr r2, =gBattlerAttacker - ldrb r0, [r2] - lsls r0, 1 - add r0, r8 - ldrh r0, [r0] - mov r3, r9 - muls r3, r0 - adds r0, r3, 0 - ldr r1, =gPlayerParty - adds r0, r1 - movs r1, 0xB - movs r2, 0 - bl GetMonData - adds r1, r0, 0 - lsls r1, 16 - lsrs r1, 16 - ldr r4, =gBattlerAttacker - ldrb r3, [r4] - mov r2, r10 - adds r0, r3, r2 - ldrb r2, [r0] - movs r0, 0x58 - adds r4, r3, 0 - muls r4, r0 - ldr r5, =gBattleMons + 0xC - adds r3, r4, r5 - lsls r0, r7, 1 - adds r0, r4 - adds r0, r5 - ldrh r0, [r0] - str r0, [sp] - adds r0, r6, 0 - bl sub_80EE35C - b _0817F1DC - .pool -_0817F1D4: - adds r5, 0x1 - cmp r5, 0x3 - bgt _0817F1DC - b _0817F0CC -_0817F1DC: - ldr r2, =gBattleMoveDamage - ldr r1, =gMoveSelectionCursor - ldr r0, =gBattlerAttacker - ldrb r0, [r0] - adds r0, r1 - ldrb r0, [r0] - lsls r0, 2 - add r0, sp - adds r0, 0x10 - ldr r0, [r0] - str r0, [r2] - ldr r0, =gCurrentMove - mov r3, sp - ldrh r3, [r3, 0x24] - strh r3, [r0] -_0817F1FA: - add sp, 0x28 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817EECC - thumb_func_start sub_817F21C sub_817F21C: @ 817F21C push {r4-r7,lr} diff --git a/asm/field_specials.s b/asm/field_specials.s index 29c6dc800..6200123ac 100644 --- a/asm/field_specials.s +++ b/asm/field_specials.s @@ -3388,7 +3388,7 @@ _0813980C: _0813981C: ldrh r5, [r2] adds r0, r5, 0 - bl sub_80EF370 + bl CountDigits adds r3, r0, 0 lsls r3, 24 lsrs r3, 24 @@ -3408,7 +3408,7 @@ _0813983C: adds r4, 0x4 ldrh r5, [r2] adds r0, r5, 0 - bl sub_80EF370 + bl CountDigits adds r3, r0, 0 lsls r3, 24 lsrs r3, 24 diff --git a/include/battle.h b/include/battle.h index 71e8f336d..8c819f047 100644 --- a/include/battle.h +++ b/include/battle.h @@ -368,6 +368,94 @@ struct BattleResults u8 catchAttempts[11]; // 0x36 }; +struct BattleLinkStringSide +{ + u32 spikesMonId:3; + u32 reflectMonId:3; + u32 lightScreenMonId:3; + u32 safeguardMonId:3; + u32 mistMonId:3; + u32 futureSightMonId:3; + u32 doomDesireMonId:3; + u32 perishSongMonId:3; + u32 wishMonId:3; + u32 grudgeMonId:3; + u32 field_8_6:2; + u32 spikesMoveSlot:2; + u32 reflectMoveSlot:2; + u32 lightScreenMoveSlot:2; + u32 safeguardMoveSlot:2; + u32 mistMoveSlot:2; + u32 futureSightMoveSlot:2; + u32 doomDesireMoveSlot:2; + u32 perishSongMoveSlot:2; + u32 wishMoveSlot:2; + u32 grudgeMoveSlot:2; + u32 destinyBondMonId:3; + u32 destinyBondMoveSlot:2; + u32 field_3_0:4; + u32 field_3_1:3; + u32 explosion:1; + u32 explosionMoveSlot:2; + u32 explosionMonId:3; + u32 perishSong:1; + u32 field_4_2:1; + u32 field_5_0:3; + u32 field_5_1:2; +}; + +struct BattleLinkStringPosition +{ + u32 curseMonId:3; + u32 leechSeedMonId:3; + u32 nightmareMonId:3; + u32 wrapMonId:3; + u32 attractMonId:3; + u32 confusionMonId:3; + u32 curseMoveSlot:2; + u32 leechSeedMoveSlot:2; + u32 nightmareMoveSlot:2; + u32 wrapMoveSlot:2; + u32 attractMoveSlot:2; + u32 confusionMoveSlot:2; + u32 waterSportMoveSlot:2; + u32 waterSportMonId:3; + u32 mudSportMonId:3; + u32 mudSportMoveSlot:2; + u32 ingrainMonId:3; + u32 ingrainMoveSlot:2; + u32 field_5_5:3; + u32 field_6_0:2; +}; + +struct BattleLinkStringMon +{ + u32 psnMonId:3; + u32 badPsnMonId:3; + u32 brnMonId:3; + u32 prlzMonId:3; + u32 slpMonId:3; + u32 frzMonId:3; + u32 psnMoveSlot:2; + u32 badPsnMoveSlot:2; + u32 brnMoveSlot:2; + u32 prlzMoveSlot:2; + u32 slpMoveSlot:2; + u32 frzMoveSlot:2; +}; + +struct UnknownBattleLinkStruct +{ + struct BattleLinkStringMon mon[2][6]; // [side][partyId] + struct BattleLinkStringPosition pos[2][2]; // [side][flank] + struct BattleLinkStringSide side[2]; // [side] +}; + +struct UnknownBattleLinkArrayStruct +{ + s16 unk0[2][6*4]; +}; + struct BattleStruct { u8 turnEffectsTracker; @@ -472,9 +560,9 @@ struct BattleStruct u8 wishPerishSongBattlerId; bool8 overworldWeatherDone; u8 atkCancellerTracker; - s16 field_1A4[2][PARTY_SIZE * 4]; - u8 field_204[104]; - u8 field_26C[40]; + struct UnknownBattleLinkArrayStruct field_1A4; + struct UnknownBattleLinkStruct field_204; + u8 notSureWhatFieldLol[0x28]; u8 AI_monToSwitchIntoId[MAX_BATTLERS_COUNT]; u8 field_298[8]; u8 field_2A0; @@ -493,6 +581,7 @@ struct BattleStruct #define IS_MOVE_PHYSICAL(moveType)(moveType < TYPE_MYSTERY) #define IS_MOVE_SPECIAL(moveType)(moveType > TYPE_MYSTERY) + #define GET_STAT_BUFF_ID(n)((n & 0xF)) // first four bits 0x1, 0x2, 0x4, 0x8 #define GET_STAT_BUFF_VALUE(n)(((n >> 4) & 7)) // 0x10, 0x20, 0x40 #define STAT_BUFF_NEGATIVE 0x80 // 0x80, the sign bit diff --git a/include/battle_script_commands.h b/include/battle_script_commands.h index 6c84d1f0f..142ac1f7b 100644 --- a/include/battle_script_commands.h +++ b/include/battle_script_commands.h @@ -4,16 +4,16 @@ #define WINDOW_CLEAR 0x1 #define WINDOW_x80 0x80 -void AI_CalcDmg(u8 bankAtk, u8 bankDef); -u8 TypeCalc(u16 move, u8 bankAtk, u8 bankDef); +void AI_CalcDmg(u8 battlerIdAtk, u8 battlerIdDef); +u8 TypeCalc(u16 move, u8 battlerIdAtk, u8 battlerIdDef); u8 AI_TypeCalc(u16 move, u16 targetSpecies, u8 targetAbility); -u8 GetBattlerTurnOrderNum(u8 bank); +u8 GetBattlerTurnOrderNum(u8 battlerId); void SetMoveEffect(bool8 primary, u8 certain); void BattleDestroyYesNoCursorAt(u8 cursorPosition); void BattleCreateYesNoCursorAt(u8 cursorPosition); void BufferMoveToLearnIntoBattleTextBuff2(void); void HandleBattleWindow(u8 xStart, u8 yStart, u8 xEnd, u8 yEnd, u8 flags); -bool8 UproarWakeUpCheck(u8 bank); +bool8 UproarWakeUpCheck(u8 battlerId); extern void (* const gBattleScriptingCommandsTable[])(void); extern const u8 gUnknown_0831C494[][4]; diff --git a/include/tv.h b/include/tv.h index 8235373ae..93854be56 100644 --- a/include/tv.h +++ b/include/tv.h @@ -3,19 +3,40 @@ extern u8 *const gTVStringVarPtrs[3]; -void ClearTVShowData(void); -void PutPokemonTodayCaughtOnAir(void); +void sub_80EE184(void); +void sub_80EE35C(u16 foeSpecies, u16 species, u8 moveIdx, const u16 *movePtr, u16 betterMove); +void sub_80EE8C8(u16 winStreak, u8 facility); +void DoTVShow(void); +void DoTVShowInSearchOfTrainers(void); +void sub_80EDCE8(void); +void sub_80EE2CC(void); +void sub_80EE72C(void); +void sub_80EED10(void); +void sub_80EED34(void); +void sub_80EED60(u16 delta); +void sub_80F01B8(void); +void sub_80F01E8(void *src, u32 size, u8 masterIdx); +void sub_80EE4DC(struct Pokemon *pokemon, u8 ribbonMonDataIdx); u32 GetPlayerIDAsU32(void); bool8 GetPriceReduction(u8 newsKind); -u8 GetRibbonCount(struct Pokemon *pokemon); -void TV_PutSecretBaseVisitOnTheAir(void); -void sub_80EE184(void); -void sub_80EEA70(void); void sub_80F14F8(TVShow *shows); -size_t sub_80EF370(int value); -bool8 Put3CheersForPokeblocksOnTheAir(const u8 *partnersName, u8 flavor, u8 unused, u8 sheen, u8 language); -void SetPokemonAnglerSpecies(u16 species); -void UpdateTVShowsPerDay(u16 days); -void PutBattleUpdateOnTheAir(u8 a0, u16 a1, u16 a2, u16 a3); +size_t CountDigits(int value); +u8 GetRibbonCount(struct Pokemon *pokemon); +void sub_80EDE70(u16 nCoinsSpent); +void sub_80EDE84(u16 nCoinsSpent); +void sub_80EDD78(u16 nCoinsPaidOut); +void sub_80EEA70(void); +void sub_80EDB44(void); +void sub_80EDC60(const u16 *words); +void sub_80EDA80(void); +void sub_80F0C7C(void *src, u32 size, u8 masterIdx); +void sub_80F0BB8(void); +void sub_80ED950(bool8 flag); +void sub_80EEC80(void); +void sub_80EECA4(void); +void sub_80EECC8(void); +void sub_80EECEC(void); +void sub_80F1208(TVShow *shows); +void sub_80EE44C(u8 nMonsCaught, u8 nPkblkUsed); #endif //GUARD_TV_H diff --git a/src/battle_controllers.c b/src/battle_controllers.c index 3c8b1563f..3d5ffeb3a 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -121,10 +121,10 @@ void sub_8032768(void) } for (i = 0; i < sizeof(gBattleStruct->field_1A4); i++) - *(gBattleStruct->field_1A4 + i) = 0; + *((u8*)(&gBattleStruct->field_1A4) + i) = 0; for (i = 0; i < sizeof(gBattleStruct->field_204); i++) - *(gBattleStruct->field_204 + i) = 0; + *((u8*)(&gBattleStruct->field_204) + i) = 0; } static void InitSinglePlayerBtlControllers(void) diff --git a/src/battle_link_817C95C.c b/src/battle_link_817C95C.c index c92a963eb..1a8a201aa 100644 --- a/src/battle_link_817C95C.c +++ b/src/battle_link_817C95C.c @@ -9,89 +9,6 @@ #include "battle_message.h" #include "tv.h" -struct BattleLinkStringSide -{ - u32 spikesMonId:3; - u32 reflectMoveId:3; - u32 lightScreenMonId:3; - u32 safeguardMonId:3; - u32 mistMonId:3; - u32 futureSightMonId:3; - u32 doomDesireMonId:3; - u32 perishSongMonId:3; - u32 wishMonId:3; - u32 grudgeMonId:3; - u32 field_8_6:2; - u32 spikesMoveSlot:2; - u32 reflectMoveSlot:2; - u32 lightScreenMoveSlot:2; - u32 safeguardMoveSlot:2; - u32 mistMoveSlot:2; - u32 futureSightMoveSlot:2; - u32 doomDesireMoveSlot:2; - u32 perishSongMoveSlot:2; - u32 wishMoveSlot:2; - u32 grudgeMoveSlot:2; - u32 destinyBondMonId:3; - u32 destinyBondMoveSlot:2; - u32 field_3_0:4; - u32 field_3_1:3; - u32 field_4_0_0:1; - u32 field_4_0:2; - u32 field_4_0_b:3; - u32 field_4_1:1; - u32 field_4_2:1; - u32 field_5_0:3; - u32 field_5_1:2; -}; - -struct BattleLinkStringPosition -{ - u32 curseMonId:3; - u32 leechSeedMonId:3; - u32 nightmareMonId:3; - u32 wrapMonId:3; - u32 attractMonId:3; - u32 confusionMonId:3; - u32 curseMoveSlot:2; - u32 leechSeedMoveSlot:2; - u32 nightmareMoveSlot:2; - u32 wrapMoveSlot:2; - u32 attractMoveSlot:2; - u32 confusionMoveSlot:2; - u32 waterSportMoveSlot:2; - u32 waterSportMonId:3; - u32 mudSportMonId:3; - u32 mudSportMoveSlot:2; - u32 ingrainMonId:3; - u32 ingrainMoveSlot:2; - u32 field_5_5:3; - u32 field_6_0:2; -}; - -struct BattleLinkStringMon -{ - u32 psnMonId:3; - u32 badPsnMonId:3; - u32 brnMonId:3; - u32 prlzMonId:3; - u32 slpMonId:3; - u32 frzMonId:3; - u32 psnMoveSlot:2; - u32 badPsnMoveSlot:2; - u32 brnMoveSlot:2; - u32 prlzMoveSlot:2; - u32 slpMoveSlot:2; - u32 frzMoveSlot:2; -}; - -struct UnknownBattleLinkStruct -{ - struct BattleLinkStringMon mon[2][6]; // [side][partyId] - struct BattleLinkStringPosition pos[2][2]; // [side][flank] - struct BattleLinkStringSide side[2]; // [side] -}; - extern struct StringInfoBattle *gStringInfo; extern const struct BattleMove gBattleMoves[]; @@ -102,9 +19,12 @@ void sub_817E684(u8 arg0, u16 arg1, u8 arg2, u8 arg3); void sub_817EECC(void); void sub_817EA80(u8 arg0); void sub_817F394(u16 weatherFlags, u16 moveId, u8 moveSlot); +bool8 sub_817F21C(u16 moveId, s32 *dmg, u16 *powerOverride); // const rom data +extern const u16 *const gUnknown_0860A834[]; extern const u16 gUnknown_0860A8A4[]; +extern const u16 gUnknown_0860A4AC[]; // code void sub_817C95C(u16 stringId) @@ -120,7 +40,7 @@ void sub_817C95C(u16 stringId) if (!(gBattleTypeFlags & BATTLE_TYPE_LINK) && stringId != STRINGID_ITDOESNTAFFECT && stringId != STRINGID_NOTVERYEFFECTIVE) return; - structPtr = (struct UnknownBattleLinkStruct*)(&gBattleStruct->field_204); + structPtr = &gBattleStruct->field_204; atkSide = GetBattlerSide(gBattlerAttacker); defSide = GetBattlerSide(gBattlerTarget); @@ -179,7 +99,7 @@ void sub_817C95C(u16 stringId) case STRINGID_FAINTINTHREE: structPtr->side[atkSide].perishSongMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; structPtr->side[atkSide].perishSongMoveSlot = moveSlot; - structPtr->side[atkSide].field_4_1 = 1; + structPtr->side[atkSide].perishSong = 1; break; case STRINGID_PKMNPERISHCOUNTFELL: if (*perishCount == 0) @@ -455,7 +375,7 @@ void sub_817C95C(u16 stringId) break; case STRINGID_PKMNRAISEDDEF: case STRINGID_PKMNRAISEDDEFALITTLE: - structPtr->side[atkSide].reflectMoveId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[atkSide].reflectMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; structPtr->side[atkSide].reflectMoveSlot = moveSlot; break; case STRINGID_PKMNRAISEDSPDEF: @@ -466,7 +386,7 @@ void sub_817C95C(u16 stringId) case STRINGID_PKMNSXWOREOFF: if (*finishedMoveId == MOVE_REFLECT) { - structPtr->side[atkSide].reflectMoveId = 0; + structPtr->side[atkSide].reflectMonId = 0; structPtr->side[atkSide].reflectMoveSlot = 0; } if (*finishedMoveId == MOVE_LIGHT_SCREEN) @@ -501,7 +421,7 @@ void sub_817C95C(u16 stringId) sub_817E684(16, 0, structPtr->side[defSide].mistMonId - 1, structPtr->side[defSide].mistMoveSlot); break; case STRINGID_THEWALLSHATTERED: - structPtr->side[defSide].reflectMoveId = 0; + structPtr->side[defSide].reflectMonId = 0; structPtr->side[defSide].reflectMoveSlot = 0; structPtr->side[defSide].lightScreenMonId = 0; structPtr->side[defSide].lightScreenMoveSlot = 0; @@ -548,7 +468,7 @@ void sub_817E0FC(u16 move, u16 weatherFlags, struct DisableStruct *disableStruct if (!(gBattleTypeFlags & BATTLE_TYPE_LINK)) return; - structPtr = (struct UnknownBattleLinkStruct*)(&gBattleStruct->field_204); + structPtr = &gBattleStruct->field_204; atkSide = GetBattlerSide(gBattlerAttacker); defSide = GetBattlerSide(gBattlerTarget); @@ -575,10 +495,10 @@ void sub_817E0FC(u16 move, u16 weatherFlags, struct DisableStruct *disableStruct } if (move == MOVE_SELF_DESTRUCT || move == MOVE_EXPLOSION) { - structPtr->side[atkSide ^ BIT_SIDE].field_4_0_b = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[atkSide ^ BIT_SIDE].field_4_0 = moveSlot; + structPtr->side[atkSide ^ BIT_SIDE].explosionMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + structPtr->side[atkSide ^ BIT_SIDE].explosionMoveSlot = moveSlot; structPtr->side[atkSide ^ BIT_SIDE].field_3_0 = 13; - structPtr->side[atkSide ^ BIT_SIDE].field_4_0_0 = 1; + structPtr->side[atkSide ^ BIT_SIDE].explosion = 1; } sub_817E684(13, gBattleMoves[move].type, gBattleMoves[move].power, 0); @@ -595,7 +515,7 @@ void sub_817E32C(u8 animationId) if (!(gBattleTypeFlags & BATTLE_TYPE_LINK)) return; - structPtr = (struct UnknownBattleLinkStruct*)(&gBattleStruct->field_204); + structPtr = &gBattleStruct->field_204; atkSide = GetBattlerSide(gBattlerAttacker); switch (animationId) { @@ -625,7 +545,7 @@ void sub_817E3F4(void) u16 playerBestSpecies = 0, opponentBestSpecies = 0; s16 playerBestSum = 0, opponentBestSum = SHRT_MAX; u8 playerBestMonId = 0, opponentBestMonId = 0; - s16 *array = NULL; + struct UnknownBattleLinkArrayStruct *array = NULL; u8 countPlayer = 0, countOpponent = 0; s16 sum = 0; u16 species = 0; @@ -635,7 +555,7 @@ void sub_817E3F4(void) if (gBattleStruct->field_B3) return; - array = (void*) &gBattleStruct->field_1A4[0]; + array = &gBattleStruct->field_1A4; for (i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL) != SPECIES_NONE) @@ -653,7 +573,7 @@ void sub_817E3F4(void) if (species != SPECIES_NONE && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG, NULL)) { for (sum = 0, j = 0; j < 4; j++) - sum += array[i * 4 + j]; + sum += array->unk0[0][i * 4 + j]; if (playerBestSum < sum) { @@ -666,8 +586,9 @@ void sub_817E3F4(void) species = GetMonData(&gEnemyParty[i], MON_DATA_SPECIES, NULL); if (species != SPECIES_NONE && !GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG, NULL)) { + s32 id = 1; for (sum = 0, j = 0; j < 4; j++) - sum += array[i * 4 + j]; + sum += array->unk0[id][i * 4 + j]; if (opponentBestSum == sum) { @@ -689,9 +610,9 @@ void sub_817E3F4(void) for (sum = 0, i = 0, j = 0; j < 4; j++) { - if (sum < array[playerBestMonId * 4 + j]) + if (sum < array->unk0[0][playerBestMonId * 4 + j]) { - sum = array[playerBestMonId * 4 + j]; + sum = array->unk0[0][playerBestMonId * 4 + j]; i = j; } } @@ -1041,3 +962,345 @@ _0817E670:\n\ .pool"); } #endif + +void sub_817E684(u8 caseId, u16 arg1, u8 arg2, u8 arg3) +{ + struct UnknownBattleLinkArrayStruct *array = &gBattleStruct->field_1A4; + struct UnknownBattleLinkStruct *structPtr = &gBattleStruct->field_204; + u32 atkSide = GetBattlerSide(gBattlerAttacker); + u32 defSide = GetBattlerSide(gBattlerTarget); + const u16 *ptr; + s32 i; + + switch (caseId) + { + case 0: + case 1: + case 18: + case 22 ... 27: + array->unk0[atkSide][gBattlerPartyIndexes[gBattlerAttacker] * 4 + arg1] += gUnknown_0860A834[caseId][arg2]; + break; + case 3 ... 7: + i = 0; + ptr = gUnknown_0860A834[caseId]; + do + { + if (arg1 == ptr[i]) + { + array->unk0[atkSide][gBattlerPartyIndexes[gBattlerAttacker] * 4 + arg2] += ptr[i+1]; + break; + } + i += 2; + } while (ptr[i] != 0xFFFF); + break; + case 19: + structPtr->side[arg2 ^ 1].field_3_0 = 0; + array->unk0[arg2][0 * 4 + arg3] += gUnknown_0860A834[caseId][arg1]; + break; + case 20: + structPtr->side[arg2].field_3_0 = 0; + case 2: + array->unk0[arg2][0 * 4 + arg3] += gUnknown_0860A834[caseId][arg1]; + break; + case 17: + array->unk0[atkSide][arg2 * 4 + arg3] += gUnknown_0860A834[caseId][arg1]; + break; + case 8: + case 9: + case 15: + case 16: + case 21: + array->unk0[atkSide ^ BIT_SIDE][arg2 * 4 + arg3] += gUnknown_0860A834[caseId][arg1]; + break; + case 10: + array->unk0[arg1][arg2 * 4 + arg3] += gUnknown_0860A834[caseId][0]; + break; + case 11: + if (structPtr->pos[defSide][0].waterSportMonId != -(structPtr->pos[defSide][1].waterSportMonId) && arg1 == 10) + { + if (structPtr->pos[defSide][0].waterSportMonId != 0) + { + u32 id = (structPtr->pos[defSide][0].waterSportMonId - 1) * 4; + array->unk0[defSide][id + structPtr->pos[defSide][0].waterSportMoveSlot] += gUnknown_0860A834[caseId][0]; + } + if (structPtr->pos[defSide][1].waterSportMonId != 0) + { + u32 id = (structPtr->pos[defSide][1].waterSportMonId - 1) * 4; + array->unk0[defSide][id + structPtr->pos[defSide][1].waterSportMoveSlot] += gUnknown_0860A834[caseId][0]; + } + } + break; + case 12: + if (structPtr->pos[defSide][0].mudSportMonId != -(structPtr->pos[defSide][1].mudSportMonId) && arg1 == 13) + { + if (structPtr->pos[defSide][0].mudSportMonId != 0) + { + u32 id = (structPtr->pos[defSide][0].mudSportMonId - 1) * 4; + array->unk0[defSide][id + structPtr->pos[defSide][0].mudSportMoveSlot] += gUnknown_0860A834[caseId][0]; + } + if (structPtr->pos[defSide][1].mudSportMonId != 0) + { + u32 id = (structPtr->pos[defSide][1].mudSportMonId - 1) * 4; + array->unk0[defSide][id + structPtr->pos[defSide][1].mudSportMoveSlot] += gUnknown_0860A834[caseId][0]; + } + } + break; + case 13: + if (arg1 <= 8 && arg2 != 0 && structPtr->side[defSide].reflectMonId != 0) + { + u32 id = (structPtr->side[defSide].reflectMonId - 1) * 4; + array->unk0[defSide][id + structPtr->side[defSide].reflectMoveSlot] += gUnknown_0860A834[caseId][0]; + } + break; + case 14: + if (arg1 > 8 && arg2 != 0 && structPtr->side[defSide].lightScreenMonId != 0) + { + u32 id = (structPtr->side[defSide].lightScreenMonId - 1) * 4; + array->unk0[defSide][id + structPtr->side[defSide].lightScreenMoveSlot] += gUnknown_0860A834[caseId][0]; + } + break; + break; + } +} + +void sub_817EA80(u8 arg0) +{ + struct UnknownBattleLinkStruct *structPtr = &gBattleStruct->field_204; + u32 atkSide = GetBattlerSide(gBattlerAttacker); + u32 defSide = GetBattlerSide(gBattlerTarget); + u32 atkArrId = structPtr->side[atkSide].field_3_1; + s32 i; + + if (structPtr->side[atkSide].field_3_0 != 0) + { + switch (structPtr->side[atkSide].field_3_0) + { + case 1: + if (structPtr->pos[atkSide][atkArrId].curseMonId != 0) + { + sub_817E684(19, 0, atkSide ^ BIT_SIDE, + (structPtr->pos[atkSide][atkArrId].curseMonId - 1) * 4 + structPtr->pos[atkSide][atkArrId].curseMoveSlot); + } + break; + case 2: + if (structPtr->pos[atkSide][atkArrId].leechSeedMonId != 0) + { + sub_817E684(19, 0, atkSide ^ BIT_SIDE, + (structPtr->pos[atkSide][atkArrId].leechSeedMonId - 1) * 4 + structPtr->pos[atkSide][atkArrId].leechSeedMoveSlot); + } + break; + case 3: + if (structPtr->mon[atkSide][atkArrId].psnMonId != 0) + { + sub_817E684(19, 0, atkSide ^ BIT_SIDE, + (structPtr->mon[atkSide][atkArrId].psnMonId - 1) * 4 + structPtr->mon[atkSide][atkArrId].psnMoveSlot); + } + if (structPtr->mon[atkSide][atkArrId].badPsnMonId != 0) + { + sub_817E684(19, 0, atkSide ^ BIT_SIDE, + (structPtr->mon[atkSide][atkArrId].badPsnMonId - 1) * 4 + structPtr->mon[atkSide][atkArrId].badPsnMoveSlot); + } + break; + case 4: + if (structPtr->mon[atkSide][atkArrId].brnMonId != 0) + { + sub_817E684(19, 0, atkSide ^ BIT_SIDE, + (structPtr->mon[atkSide][atkArrId].brnMonId - 1) * 4 + structPtr->mon[atkSide][atkArrId].brnMoveSlot); + } + break; + case 5: + if (structPtr->pos[atkSide][atkArrId].nightmareMonId != 0) + { + sub_817E684(19, 0, atkSide ^ BIT_SIDE, + (structPtr->pos[atkSide][atkArrId].nightmareMonId - 1) * 4 + structPtr->pos[atkSide][atkArrId].nightmareMoveSlot); + } + break; + case 6: + if (structPtr->pos[atkSide][atkArrId].wrapMonId != 0) + { + sub_817E684(19, 0, atkSide ^ BIT_SIDE, + (structPtr->pos[atkSide][atkArrId].wrapMonId - 1) * 4 + structPtr->pos[atkSide][atkArrId].wrapMoveSlot); + } + break; + case 7: + if (structPtr->side[atkSide].spikesMonId != 0) + { + sub_817E684(19, 0, atkSide ^ BIT_SIDE, + (structPtr->side[atkSide].spikesMonId - 1) * 4 + structPtr->side[atkSide].spikesMoveSlot); + } + break; + case 8: + if (structPtr->side[atkSide].futureSightMonId != 0) + { + sub_817E684(20, 0, atkSide, + (structPtr->side[atkSide].futureSightMonId - 1) * 4 + structPtr->side[atkSide].futureSightMoveSlot); + } + break; + case 9: + if (structPtr->side[atkSide].doomDesireMonId != 0) + { + sub_817E684(20, 0, atkSide, + (structPtr->side[atkSide].doomDesireMonId - 1) * 4 + structPtr->side[atkSide].doomDesireMoveSlot); + } + break; + case 10: + if (structPtr->side[atkSide].perishSong + && structPtr->side[atkSide].perishSongMonId - 1 != gBattlerPartyIndexes[gBattlerAttacker]) + { + sub_817E684(19, 0, atkSide, + (structPtr->side[atkSide].perishSongMonId - 1) * 4 + structPtr->side[atkSide].perishSongMoveSlot); + } + if (structPtr->side[atkSide ^ BIT_SIDE].perishSong) + { + sub_817E684(19, 0, atkSide ^ BIT_SIDE, + (structPtr->side[atkSide ^ BIT_SIDE].perishSongMonId - 1) * 4 + structPtr->side[atkSide ^ BIT_SIDE].perishSongMoveSlot); + } + break; + case 11: + if (structPtr->side[atkSide ^ BIT_SIDE].destinyBondMonId != 0) + { + sub_817E684(19, 0, atkSide ^ BIT_SIDE, + (structPtr->side[atkSide ^ BIT_SIDE].destinyBondMonId - 1) * 4 + structPtr->side[atkSide ^ BIT_SIDE].destinyBondMoveSlot); + } + break; + case 12: + for (i = 0; i < 2; i++) + { + if (structPtr->pos[atkSide][i].confusionMonId != 0) + { + sub_817E684(19, 0, atkSide ^ BIT_SIDE, + (structPtr->pos[atkSide][i].confusionMonId - 1) * 4 + structPtr->pos[atkSide][i].confusionMoveSlot); + } + } + break; + case 13: + if (structPtr->side[atkSide].explosion) + { + sub_817E684(19, 0, atkSide, + (structPtr->side[atkSide].explosionMonId - 1) * 4 + structPtr->side[atkSide].explosionMoveSlot); + } + if (structPtr->side[atkSide ^ BIT_SIDE].explosion) + { + sub_817E684(19, 0, atkSide ^ BIT_SIDE, + (structPtr->side[atkSide ^ BIT_SIDE].explosionMonId - 1) * 4 + structPtr->side[atkSide ^ BIT_SIDE].explosionMoveSlot); + } + break; + case 14: + if (arg0 == 1) + { + sub_817E684(20, 0, atkSide, + (gBattlerPartyIndexes[gBattlerAttacker]) * 4 + structPtr->side[atkSide].field_8_6); + } + break; + case 15: + break; + } + } + else + { + if (structPtr->side[defSide].field_3_0 == 7) + { + if (structPtr->side[defSide].spikesMonId != 0) + { + sub_817E684(19, 0, defSide ^ BIT_SIDE, + (structPtr->side[defSide].spikesMonId - 1) * 4 + structPtr->side[defSide].spikesMoveSlot); + } + } + else + { + sub_817E684(20, 0, atkSide, + (gBattlerPartyIndexes[gBattlerAttacker]) * 4 + structPtr->side[atkSide].field_8_6); + } + } +} + +void sub_817EECC(void) +{ + s32 i; + s32 dmgByMove[4]; + u16 powerOverride; + u16 currMoveSaved; + + if (gBattleTypeFlags & (BATTLE_TYPE_DOUBLE | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + return; + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT) + return; + if (gBattleMons[gBattlerAttacker].statStages[STAT_ACC] <= 5) + return; + if (gBattleMons[gBattlerTarget].statStages[STAT_EVASION] > 6) + return; + if (gCurrentMove == MOVE_HIDDEN_POWER || gCurrentMove == MOVE_WEATHER_BALL) + return; + if (gBattleTypeFlags & (BATTLE_TYPE_PALACE | BATTLE_TYPE_PIKE | BATTLE_TYPE_PYRAMID)) + return; + if (gBattleMoves[gBattleMons[gBattlerAttacker].moves[gMoveSelectionCursor[gBattlerAttacker]]].power == 0) + return; + + i = 0; + currMoveSaved = gBattleMons[gBattlerAttacker].moves[gMoveSelectionCursor[gBattlerAttacker]]; + while (1) + { + if (currMoveSaved == gUnknown_0860A4AC[i]) + break; + i++; + if (gUnknown_0860A4AC[i] == 0xFFFF) + break; + } + + if (gUnknown_0860A4AC[i] != 0xFFFF) + return; + + dmgByMove[gMoveSelectionCursor[gBattlerAttacker]] = gBattleMoveDamage; + currMoveSaved = gCurrentMove; + for (i = 0; i < 4; i++) + { + gCurrentMove = gBattleMons[gBattlerAttacker].moves[i]; + powerOverride = 0; + if (sub_817F21C(gCurrentMove, &dmgByMove[i], &powerOverride)) + { + u8 moveResultFlags; + u16 sideStatus = gSideStatuses[GET_BATTLER_SIDE(gBattlerTarget)]; + gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattlerAttacker], &gBattleMons[gBattlerTarget], gCurrentMove, + sideStatus, powerOverride, + 0, gBattlerAttacker, gBattlerTarget); + + if (gStatuses3[gBattlerAttacker] & STATUS3_CHARGED_UP && gBattleMoves[gCurrentMove].type == TYPE_ELECTRIC) + gBattleMoveDamage *= 2; + if (gProtectStructs[gBattlerAttacker].helpingHand) + gBattleMoveDamage = gBattleMoveDamage * 15 / 10; + + moveResultFlags = TypeCalc(gCurrentMove, gBattlerAttacker, gBattlerTarget); + dmgByMove[i] = gBattleMoveDamage; + if (dmgByMove[i] == 0 && !(moveResultFlags & MOVE_RESULT_NO_EFFECT)) + dmgByMove[i] = 1; + } + } + + for (i = 0; i < 4; i++) + { + if (i != gMoveSelectionCursor[gBattlerAttacker] && dmgByMove[i] > dmgByMove[gMoveSelectionCursor[gBattlerAttacker]]) + { + u16 opponentSpecies, playerSpecies; + s32 bestMoveId; + + if (gMoveSelectionCursor[gBattlerAttacker] != 0) + bestMoveId = 0; + else + bestMoveId = 1; + + for (i = 0; i < 4; i++) + { + if (i != gMoveSelectionCursor[gBattlerAttacker] && dmgByMove[i] > dmgByMove[bestMoveId]) + bestMoveId = i; + } + + opponentSpecies = GetMonData(&gEnemyParty [gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_SPECIES, NULL); + playerSpecies = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_SPECIES, NULL); + sub_80EE35C(opponentSpecies, playerSpecies, gMoveSelectionCursor[gBattlerAttacker], gBattleMons[gBattlerAttacker].moves, gBattleMons[gBattlerAttacker].moves[bestMoveId]); + break; + } + } + + gBattleMoveDamage = dmgByMove[gMoveSelectionCursor[gBattlerAttacker]]; + gCurrentMove = currMoveSaved; +} diff --git a/src/pokemon.c b/src/pokemon.c index 25d532204..9c55fb84d 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -2196,7 +2196,7 @@ void DeleteFirstMoveAndGiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move) (var) /= (gStatStageRatios)[(mon)->statStages[(statIndex)]][1]; \ } -s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *defender, u32 move, u16 sideStatus, u16 powerOverride, u8 typeOverride, u8 bankAtk, u8 bankDef) +s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *defender, u32 move, u16 sideStatus, u16 powerOverride, u8 typeOverride, u8 battlerIdAtk, u8 battlerIdDef) { u32 i; s32 damage = 0; @@ -2226,8 +2226,8 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de if (attacker->item == ITEM_ENIGMA_BERRY) { - attackerHoldEffect = gEnigmaBerries[bankAtk].holdEffect; - attackerHoldEffectParam = gEnigmaBerries[bankAtk].holdEffectParam; + attackerHoldEffect = gEnigmaBerries[battlerIdAtk].holdEffect; + attackerHoldEffectParam = gEnigmaBerries[battlerIdAtk].holdEffectParam; } else { @@ -2237,8 +2237,8 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de if (defender->item == ITEM_ENIGMA_BERRY) { - defenderHoldEffect = gEnigmaBerries[bankDef].holdEffect; - defenderHoldEffectParam = gEnigmaBerries[bankDef].holdEffectParam; + defenderHoldEffect = gEnigmaBerries[battlerIdDef].holdEffect; + defenderHoldEffectParam = gEnigmaBerries[battlerIdDef].holdEffectParam; } else { @@ -2249,13 +2249,13 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de if (attacker->ability == ABILITY_HUGE_POWER || attacker->ability == ABILITY_PURE_POWER) attack *= 2; - if (ShouldGetStatBadgeBoost(FLAG_BADGE01_GET, bankAtk)) + if (ShouldGetStatBadgeBoost(FLAG_BADGE01_GET, battlerIdAtk)) attack = (110 * attack) / 100; - if (ShouldGetStatBadgeBoost(FLAG_BADGE05_GET, bankDef)) + if (ShouldGetStatBadgeBoost(FLAG_BADGE05_GET, battlerIdDef)) defense = (110 * defense) / 100; - if (ShouldGetStatBadgeBoost(FLAG_BADGE07_GET, bankAtk)) + if (ShouldGetStatBadgeBoost(FLAG_BADGE07_GET, battlerIdAtk)) spAttack = (110 * spAttack) / 100; - if (ShouldGetStatBadgeBoost(FLAG_BADGE07_GET, bankDef)) + if (ShouldGetStatBadgeBoost(FLAG_BADGE07_GET, battlerIdDef)) spDefense = (110 * spDefense) / 100; for (i = 0; i < ARRAY_COUNT(sHoldEffectToType); i++) @@ -2440,7 +2440,7 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de } // flash fire triggered - if ((gBattleResources->flags->flags[bankAtk] & UNKNOWN_FLAG_FLASH_FIRE) && type == TYPE_FIRE) + if ((gBattleResources->flags->flags[battlerIdAtk] & UNKNOWN_FLAG_FLASH_FIRE) && type == TYPE_FIRE) damage = (15 * damage) / 10; } diff --git a/src/scrcmd.c b/src/scrcmd.c index b7e2474d4..a29e64979 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -1612,7 +1612,7 @@ bool8 ScrCmd_buffernumberstring(struct ScriptContext *ctx) { u8 stringVarIndex = ScriptReadByte(ctx); u16 v1 = VarGet(ScriptReadHalfword(ctx)); - u8 v2 = sub_80EF370(v1); + u8 v2 = CountDigits(v1); ConvertIntToDecimalStringN(sScriptStringVars[stringVarIndex], v1, 0, v2); return FALSE; diff --git a/src/tv.c b/src/tv.c index 83cb18b3f..03d564828 100644 --- a/src/tv.c +++ b/src/tv.c @@ -36,9 +36,7 @@ #include "decoration.h" #include "secret_base.h" #include "tv.h" - -extern const u8 gSpeciesNames[][11]; -extern const u8 gMoveNames[][13]; +#include "data2.h" // Static type declarations @@ -87,101 +85,100 @@ void tv_store_id_3x(TVShow *show); void DeleteTVShowInArrayByIdx(TVShow *shows, u8 idx); s8 FindEmptyTVSlotWithinFirstFiveShowsOfArray(TVShow *shows); void FindActiveBroadcastByShowType_SetScriptResult(u8 kind); -void InterviewBefore_BravoTrainerPkmnProfile(void); -void InterviewBefore_NameRater(void); +static void InterviewBefore_BravoTrainerPkmnProfile(void); +static void InterviewBefore_NameRater(void); u16 TV_GetSomeOtherSpeciesAlreadySeenByPlayer(u16 passedSpecies); -void sub_80EFA88(void); -void sub_80EF93C(TVShow *shows); +static void sub_80EFA88(void); +static void sub_80EF93C(TVShow *shows); s8 sub_80EEE30(PokeNews *pokeNews); bool8 sub_80EF0E4(u8 newsKind); void ClearPokemonNewsI(u8 i); -void sub_80F1254(TVShow *shows); -void sub_80F12A4(TVShow *shows); -void sub_80F0358(TVShow *player1, TVShow *player2, TVShow *player3, TVShow *player4); -void sub_80F0C04(void); -void sub_80F0708(void); -void sub_80F0B64(void); -s8 sub_80F06D0(TVShow *tvShows); -bool8 sub_80F049C(TVShow *dest[], TVShow *src[], u8 idx); -bool8 sub_80F0580(TVShow *tv1, TVShow *tv2, u8 idx); -bool8 sub_80F05E8(TVShow *tv1, TVShow *tv2, u8 idx); -bool8 sub_80F0668(TVShow *tv1, TVShow *tv2, u8 idx); -void sub_80F0B00(u8 showIdx); -void sub_80F0B24(u16 species, u8 showIdx); -void sub_80F0D60(PokeNews *player1, PokeNews *player2, PokeNews *player3, PokeNews *player4); -void sub_80F0EEC(void); -void sub_80F0F24(void); -s8 sub_80F0ECC(PokeNews *pokeNews, u8 idx); -void sub_80F0E58(PokeNews *dest[], PokeNews *src[]); -bool8 sub_80F0E84(PokeNews *dest, PokeNews *src, s8 slot); +static void sub_80F1254(TVShow *shows); +static void sub_80F12A4(TVShow *shows); +static void sub_80F0358(TVShow *player1, TVShow *player2, TVShow *player3, TVShow *player4); +static void sub_80F0C04(void); +static void sub_80F0708(void); +static void sub_80F0B64(void); +static s8 sub_80F06D0(TVShow *tvShows); +static bool8 sub_80F049C(TVShow *dest[], TVShow *src[], u8 idx); +static bool8 sub_80F0580(TVShow *tv1, TVShow *tv2, u8 idx); +static bool8 sub_80F05E8(TVShow *tv1, TVShow *tv2, u8 idx); +static bool8 sub_80F0668(TVShow *tv1, TVShow *tv2, u8 idx); +void SetTvShowInactive(u8 showIdx); +static void sub_80F0B24(u16 species, u8 showIdx); +static void sub_80F0D60(PokeNews *player1, PokeNews *player2, PokeNews *player3, PokeNews *player4); +static void sub_80F0EEC(void); +static void sub_80F0F24(void); +static s8 sub_80F0ECC(PokeNews *pokeNews, u8 idx); +static void sub_80F0E58(PokeNews *dest[], PokeNews *src[]); +static bool8 sub_80F0E84(PokeNews *dest, PokeNews *src, s8 slot); void TVShowDone(void); -void InterviewAfter_FanClubLetter(void); -void InterviewAfter_RecentHappenings(void); -void InterviewAfter_PkmnFanClubOpinions(void); -void InterviewAfter_DummyShow4(void); -void InterviewAfter_BravoTrainerPokemonProfile(void); -void InterviewAfter_BravoTrainerBattleTowerProfile(void); -void InterviewAfter_ContestLiveUpdates(void); +static void InterviewAfter_FanClubLetter(void); +static void InterviewAfter_RecentHappenings(void); +static void InterviewAfter_PkmnFanClubOpinions(void); +static void InterviewAfter_DummyShow4(void); +static void InterviewAfter_BravoTrainerPokemonProfile(void); +static void InterviewAfter_BravoTrainerBattleTowerProfile(void); +static void InterviewAfter_ContestLiveUpdates(void); void UpdateWorldOfMastersAndPutItOnTheAir(void); void PutPokemonTodayFailedOnTheAir(void); -void sub_80ED718(void); -void sub_80EED88(void); +static void sub_80ED718(void); +static void sub_80EED88(void); void TV_SortPurchasesByQuantity(void); -void sub_80ED8B4(u16 days); +static void sub_80ED8B4(u16 days); void UpdateMassOutbreakTimeLeft(u16 days); -void sub_80EF120(u16 days); -void sub_80EDA48(u16 days); -void sub_80EEB98(u16 days); +static void sub_80EF120(u16 days); +static void sub_80EDA48(u16 days); +static void sub_80EEB98(u16 days); void PutFishingAdviceShowOnTheAir(void); -void sub_80EDA80(void); u8 TV_MonDataIdxToRibbon(u8 monDataIdx); -void sub_80EEBF4(u8 actionIdx); +static void sub_80EEBF4(u8 actionIdx); bool8 IsPriceDiscounted(u8 newsKind); -void InterviewBefore_FanClubLetter(void); -void InterviewBefore_RecentHappenings(void); -void InterviewBefore_PkmnFanClubOpinions(void); -void InterviewBefore_Dummy(void); -void InterviewBefore_BravoTrainerBTProfile(void); -void InterviewBefore_ContestLiveUpdates(void); -void InterviewBefore_3CheersForPokeblocks(void); -void InterviewBefore_FanClubSpecial(void); +static void InterviewBefore_FanClubLetter(void); +static void InterviewBefore_RecentHappenings(void); +static void InterviewBefore_PkmnFanClubOpinions(void); +static void InterviewBefore_Dummy(void); +static void InterviewBefore_BravoTrainerBTProfile(void); +static void InterviewBefore_ContestLiveUpdates(void); +static void InterviewBefore_3CheersForPokeblocks(void); +static void InterviewBefore_FanClubSpecial(void); void ChangeBoxPokemonNickname_CB(void); -void DoTVShowPokemonFanClubLetter(void); -void DoTVShowRecentHappenings(void); -void DoTVShowPokemonFanClubOpinions(void); -void DoTVShowDummiedOut(void); -void DoTVShowPokemonNewsMassOutbreak(void); -void DoTVShowBravoTrainerPokemonProfile(void); -void DoTVShowBravoTrainerBattleTower(void); -void DoTVShowPokemonTodaySuccessfulCapture(void); -void DoTVShowTodaysSmartShopper(void); -void DoTVShowTheNameRaterShow(void); -void DoTVShowPokemonContestLiveUpdates(void); -void DoTVShowPokemonBattleUpdate(void); -void DoTVShow3CheersForPokeblocks(void); -void DoTVShowPokemonTodayFailedCapture(void); -void DoTVShowPokemonAngler(void); -void DoTVShowTheWorldOfMasters(void); -void DoTVShowTodaysRivalTrainer(void); -void DoTVShowDewfordTrendWatcherNetwork(void); -void DoTVShowHoennTreasureInvestigators(void); -void DoTVShowFindThatGamer(void); -void DoTVShowBreakingNewsTV(void); -void DoTVShowSecretBaseVisit(void); -void DoTVShowPokemonLotteryWinnerFlashReport(void); -void DoTVShowThePokemonBattleSeminar(void); -void DoTVShowTrainerFanClubSpecial(void); -void DoTVShowTrainerFanClub(void); -void DoTVShowSpotTheCuties(void); -void DoTVShowPokemonNewsBattleFrontier(void); -void DoTVShowWhatsNo1InHoennToday(void); -void DoTVShowSecretBaseSecrets(void); -void DoTVShowSafariFanClub(void); -void DoTVShowPokemonContestLiveUpdates2(void); +static void DoTVShowPokemonFanClubLetter(void); +static void DoTVShowRecentHappenings(void); +static void DoTVShowPokemonFanClubOpinions(void); +static void DoTVShowDummiedOut(void); +static void DoTVShowPokemonNewsMassOutbreak(void); +static void DoTVShowBravoTrainerPokemonProfile(void); +static void DoTVShowBravoTrainerBattleTower(void); +static void DoTVShowPokemonTodaySuccessfulCapture(void); +static void DoTVShowTodaysSmartShopper(void); +static void DoTVShowTheNameRaterShow(void); +static void DoTVShowPokemonContestLiveUpdates(void); +static void DoTVShowPokemonBattleUpdate(void); +static void DoTVShow3CheersForPokeblocks(void); +static void DoTVShowPokemonTodayFailedCapture(void); +static void DoTVShowPokemonAngler(void); +static void DoTVShowTheWorldOfMasters(void); +static void DoTVShowTodaysRivalTrainer(void); +static void DoTVShowDewfordTrendWatcherNetwork(void); +static void DoTVShowHoennTreasureInvestigators(void); +static void DoTVShowFindThatGamer(void); +static void DoTVShowBreakingNewsTV(void); +static void DoTVShowSecretBaseVisit(void); +static void DoTVShowPokemonLotteryWinnerFlashReport(void); +static void DoTVShowThePokemonBattleSeminar(void); +static void DoTVShowTrainerFanClubSpecial(void); +static void DoTVShowTrainerFanClub(void); +static void DoTVShowSpotTheCuties(void); +static void DoTVShowPokemonNewsBattleFrontier(void); +static void DoTVShowWhatsNo1InHoennToday(void); +static void DoTVShowSecretBaseSecrets(void); +static void DoTVShowSafariFanClub(void); +static void DoTVShowPokemonContestLiveUpdates2(void); // .rodata -const struct { +static const struct { u16 species; u16 moves[4]; u8 level; @@ -214,8 +211,7 @@ const struct { } }; -// TODO: Figure out what these are, and define constants in include/flags.h -const u16 sGoldSymbolFlags[] = { +static const u16 sGoldSymbolFlags[] = { FLAG_SYS_TOWER_GOLD, FLAG_SYS_DOME_GOLD, FLAG_SYS_PALACE_GOLD, @@ -225,7 +221,7 @@ const u16 sGoldSymbolFlags[] = { FLAG_SYS_PYRAMID_GOLD }; -const u16 sSilverSymbolFlags[] = { +static const u16 sSilverSymbolFlags[] = { FLAG_SYS_TOWER_SILVER, FLAG_SYS_DOME_SILVER, FLAG_SYS_PALACE_SILVER, @@ -235,8 +231,7 @@ const u16 sSilverSymbolFlags[] = { FLAG_SYS_PYRAMID_SILVER }; -// TODO: Figure out what these are, and define constants in include/vars.h -const u16 sNumberOneVarsAndThresholds[][2] = { +static const u16 sNumberOneVarsAndThresholds[][2] = { {VAR_DAILY_SLOTS, 100}, {VAR_DAILY_ROULETTE, 50}, {VAR_DAILY_WILDS, 100}, @@ -246,7 +241,7 @@ const u16 sNumberOneVarsAndThresholds[][2] = { {VAR_DAILY_BP, 30} }; -const u8 *const sPokeNewsTextGroup_Upcoming[] = { +static const u8 *const sPokeNewsTextGroup_Upcoming[] = { NULL, gPokeNewsTextSlateport_Upcoming, gPokeNewsTextGameCorner_Upcoming, @@ -254,7 +249,7 @@ const u8 *const sPokeNewsTextGroup_Upcoming[] = { gPokeNewsTextBlendMaster_Upcoming }; -const u8 *const sPokeNewsTextGroup_Ongoing[] = { +static const u8 *const sPokeNewsTextGroup_Ongoing[] = { NULL, gPokeNewsTextSlateport_Ongoing, gPokeNewsTextGameCorner_Ongoing, @@ -262,7 +257,7 @@ const u8 *const sPokeNewsTextGroup_Ongoing[] = { gPokeNewsTextBlendMaster_Ongoing }; -const u8 *const sPokeNewsTextGroup_Ending[] = { +static const u8 *const sPokeNewsTextGroup_Ending[] = { NULL, gPokeNewsTextSlateport_Ending, gPokeNewsTextGameCorner_Ending, @@ -276,7 +271,7 @@ u8 *const gTVStringVarPtrs[] = { gStringVar3 }; -const u8 *const sTVFanClubTextGroup[] = { +static const u8 *const sTVFanClubTextGroup[] = { gTVFanClubText00, gTVFanClubText01, gTVFanClubText02, @@ -287,7 +282,7 @@ const u8 *const sTVFanClubTextGroup[] = { gTVFanClubText07 }; -const u8 *const sTVRecentHappeninssTextGroup[] = { +static const u8 *const sTVRecentHappeninssTextGroup[] = { gTVRecentHappeningsText00, gTVRecentHappeningsText01, gTVRecentHappeningsText02, @@ -296,7 +291,7 @@ const u8 *const sTVRecentHappeninssTextGroup[] = { gTVRecentHappeningsText05 }; -const u8 *const sTVFanClubOpinionsTextGroup[] = { +static const u8 *const sTVFanClubOpinionsTextGroup[] = { gTVFanClubOpinionsText00, gTVFanClubOpinionsText01, gTVFanClubOpinionsText02, @@ -304,11 +299,11 @@ const u8 *const sTVFanClubOpinionsTextGroup[] = { gTVFanClubOpinionsText04 }; -const u8 *const sTVMassOutbreakTextGroup[] = { +static const u8 *const sTVMassOutbreakTextGroup[] = { gTVMassOutbreakText00 }; -const u8 *const sTVPokemonTodaySuccessfulTextGroup[] = { +static const u8 *const sTVPokemonTodaySuccessfulTextGroup[] = { gTVPokemonTodaySuccessfulText00, gTVPokemonTodaySuccessfulText01, gTVPokemonTodaySuccessfulText02, @@ -323,7 +318,7 @@ const u8 *const sTVPokemonTodaySuccessfulTextGroup[] = { gTVPokemonTodaySuccessfulText11 }; -const u8 *const sTVTodaysSmartShopperTextGroup[] = { +static const u8 *const sTVTodaysSmartShopperTextGroup[] = { gTVTodaysSmartShopperText00, gTVTodaysSmartShopperText01, gTVTodaysSmartShopperText02, @@ -339,7 +334,7 @@ const u8 *const sTVTodaysSmartShopperTextGroup[] = { gTVTodaysSmartShopperText12 }; -const u8 *const sTVBravoTrainerTextGroup[] = { +static const u8 *const sTVBravoTrainerTextGroup[] = { gTVBravoTrainerText00, gTVBravoTrainerText01, gTVBravoTrainerText02, @@ -351,7 +346,7 @@ const u8 *const sTVBravoTrainerTextGroup[] = { gTVBravoTrainerText08 }; -const u8 *const sTV3CheersForPokeblocksTextGroup[] = { +static const u8 *const sTV3CheersForPokeblocksTextGroup[] = { gTV3CheersForPokeblocksText00, gTV3CheersForPokeblocksText01, gTV3CheersForPokeblocksText02, @@ -360,7 +355,7 @@ const u8 *const sTV3CheersForPokeblocksTextGroup[] = { gTV3CheersForPokeblocksText05 }; -const u8 *const sTVBravoTrainerBattleTowerTextGroup[] = { +static const u8 *const sTVBravoTrainerBattleTowerTextGroup[] = { gTVBravoTrainerBattleTowerText00, gTVBravoTrainerBattleTowerText01, gTVBravoTrainerBattleTowerText02, @@ -378,7 +373,7 @@ const u8 *const sTVBravoTrainerBattleTowerTextGroup[] = { gTVBravoTrainerBattleTowerText14 }; -const u8 *const sTVContestLiveUpdatesTextGroup[] = { +static const u8 *const sTVContestLiveUpdatesTextGroup[] = { gTVContestLiveUpdatesText00, gTVContestLiveUpdatesText01, gTVContestLiveUpdatesText02, @@ -414,7 +409,7 @@ const u8 *const sTVContestLiveUpdatesTextGroup[] = { gTVContestLiveUpdatesText32 }; -const u8 *const sTVPokemonBattleUpdateTextGroup[] = { +static const u8 *const sTVPokemonBattleUpdateTextGroup[] = { gTVPokemonBattleUpdateText00, gTVPokemonBattleUpdateText01, gTVPokemonBattleUpdateText02, @@ -425,7 +420,7 @@ const u8 *const sTVPokemonBattleUpdateTextGroup[] = { gTVPokemonBattleUpdateText07 }; -const u8 *const sTVTrainerFanClubSpecialTextGroup[] = { +static const u8 *const sTVTrainerFanClubSpecialTextGroup[] = { gTVTrainerFanClubSpecialText00, gTVTrainerFanClubSpecialText01, gTVTrainerFanClubSpecialText02, @@ -434,7 +429,7 @@ const u8 *const sTVTrainerFanClubSpecialTextGroup[] = { gTVTrainerFanClubSpecialText05 }; -const u8 *const sTVNameRaterTextGroup[] = { +static const u8 *const sTVNameRaterTextGroup[] = { gTVNameRaterText00, gTVNameRaterText01, gTVNameRaterText02, @@ -456,14 +451,14 @@ const u8 *const sTVNameRaterTextGroup[] = { gTVNameRaterText18 }; -const u8 *const sTVPokemonContestLiveUpdates2TextGroup[] = { +static const u8 *const sTVPokemonContestLiveUpdates2TextGroup[] = { gTVPokemonContestLiveUpdates2Text00, gTVPokemonContestLiveUpdates2Text01, gTVPokemonContestLiveUpdates2Text02, gTVPokemonContestLiveUpdates2Text03 }; -const u8 *const sTVPokemonTodayFailedTextGroup[] = { +static const u8 *const sTVPokemonTodayFailedTextGroup[] = { gTVPokemonTodayFailedText00, gTVPokemonTodayFailedText01, gTVPokemonTodayFailedText02, @@ -473,18 +468,18 @@ const u8 *const sTVPokemonTodayFailedTextGroup[] = { gTVPokemonTodayFailedText06 }; -const u8 *const sTVPokemonAnslerTextGroup[] = { +static const u8 *const sTVPokemonAnslerTextGroup[] = { gTVPokemonAnglerText00, gTVPokemonAnglerText01 }; -const u8 *const sTVWorldOfMastersTextGroup[] = { +static const u8 *const sTVWorldOfMastersTextGroup[] = { gTVWorldOfMastersText00, gTVWorldOfMastersText01, gTVWorldOfMastersText02 }; -const u8 *const sTVTodaysRivalTrainerTextGroup[] = { +static const u8 *const sTVTodaysRivalTrainerTextGroup[] = { gTVTodaysRivalTrainerText00, gTVTodaysRivalTrainerText01, gTVTodaysRivalTrainerText02, @@ -498,7 +493,7 @@ const u8 *const sTVTodaysRivalTrainerTextGroup[] = { gTVTodaysRivalTrainerText10 }; -const u8 *const sTVDewfordTrendWatcherNetworkTextGroup[] = { +static const u8 *const sTVDewfordTrendWatcherNetworkTextGroup[] = { gTVDewfordTrendWatcherNetworkText00, gTVDewfordTrendWatcherNetworkText01, gTVDewfordTrendWatcherNetworkText02, @@ -508,20 +503,20 @@ const u8 *const sTVDewfordTrendWatcherNetworkTextGroup[] = { gTVDewfordTrendWatcherNetworkText06 }; -const u8 *const sTVHoennTreasureInvestisatorsTextGroup[] = { +static const u8 *const sTVHoennTreasureInvestisatorsTextGroup[] = { gTVHoennTreasureInvestigatorsText00, gTVHoennTreasureInvestigatorsText01, gTVHoennTreasureInvestigatorsText02 }; -const u8 *const sTVFindThatGamerTextGroup[] = { +static const u8 *const sTVFindThatGamerTextGroup[] = { gTVFindThatGamerText00, gTVFindThatGamerText01, gTVFindThatGamerText02, gTVFindThatGamerText03 }; -const u8 *const sTVBreakinsNewsTextGroup[] = { +static const u8 *const sTVBreakinsNewsTextGroup[] = { gTVBreakingNewsText00, gTVBreakingNewsText01, gTVBreakingNewsText02, @@ -537,7 +532,7 @@ const u8 *const sTVBreakinsNewsTextGroup[] = { gTVBreakingNewsText12 }; -const u8 *const sTVSecretBaseVisitTextGroup[] = { +static const u8 *const sTVSecretBaseVisitTextGroup[] = { gTVSecretBaseVisitText00, gTVSecretBaseVisitText01, gTVSecretBaseVisitText02, @@ -554,11 +549,11 @@ const u8 *const sTVSecretBaseVisitTextGroup[] = { gTVSecretBaseVisitText13 }; -const u8 *const sTVPokemonLotteryWinnerFlashReportTextGroup[] = { +static const u8 *const sTVPokemonLotteryWinnerFlashReportTextGroup[] = { gTVPokemonLotteryWinnerFlashReportText00 }; -const u8 *const sTVThePokemonBattleSeminarTextGroup[] = { +static const u8 *const sTVThePokemonBattleSeminarTextGroup[] = { gTVThePokemonBattleSeminarText00, gTVThePokemonBattleSeminarText01, gTVThePokemonBattleSeminarText02, @@ -568,7 +563,7 @@ const u8 *const sTVThePokemonBattleSeminarTextGroup[] = { gTVThePokemonBattleSeminarText06 }; -const u8 *const sTVTrainerFanClubTextGroup[] = { +static const u8 *const sTVTrainerFanClubTextGroup[] = { gTVTrainerFanClubText00, gTVTrainerFanClubText01, gTVTrainerFanClubText02, @@ -583,7 +578,7 @@ const u8 *const sTVTrainerFanClubTextGroup[] = { gTVTrainerFanClubText11 }; -const u8 *const sTVCutiesTextGroup[] = { +static const u8 *const sTVCutiesTextGroup[] = { gTVCutiesText00, gTVCutiesText01, gTVCutiesText02, @@ -602,7 +597,7 @@ const u8 *const sTVCutiesTextGroup[] = { gTVCutiesText15 }; -const u8 *const sTVPokemonNewsBattleFrontierTextGroup[] = { +static const u8 *const sTVPokemonNewsBattleFrontierTextGroup[] = { gTVPokemonNewsBattleFrontierText00, gTVPokemonNewsBattleFrontierText01, gTVPokemonNewsBattleFrontierText02, @@ -624,7 +619,7 @@ const u8 *const sTVPokemonNewsBattleFrontierTextGroup[] = { gTVPokemonNewsBattleFrontierText18 }; -const u8 *const sTVWhatsNo1InHoennTodayTextGroup[] = { +static const u8 *const sTVWhatsNo1InHoennTodayTextGroup[] = { gTVWhatsNo1InHoennTodayText00, gTVWhatsNo1InHoennTodayText01, gTVWhatsNo1InHoennTodayText02, @@ -636,7 +631,7 @@ const u8 *const sTVWhatsNo1InHoennTodayTextGroup[] = { gTVWhatsNo1InHoennTodayText08 }; -const u8 *const sTVSecretBaseSecretsTextGroup[] = { +static const u8 *const sTVSecretBaseSecretsTextGroup[] = { gTVSecretBaseSecretsText00, gTVSecretBaseSecretsText01, gTVSecretBaseSecretsText02, @@ -682,7 +677,7 @@ const u8 *const sTVSecretBaseSecretsTextGroup[] = { gTVSecretBaseSecretsText42 }; -const u8 *const sTVSafariFanClubTextGroup[] = { +static const u8 *const sTVSafariFanClubTextGroup[] = { gTVSafariFanClubText00, gTVSafariFanClubText01, gTVSafariFanClubText02, @@ -696,7 +691,7 @@ const u8 *const sTVSafariFanClubTextGroup[] = { gTVSafariFanClubText10 }; -const u8 *const sTVInSearchOfTrainersTextGroup[] = { +static const u8 *const sTVInSearchOfTrainersTextGroup[] = { gTVInSearchOfTrainersText00, gTVInSearchOfTrainersText01, gTVInSearchOfTrainersText02, @@ -1253,7 +1248,7 @@ void tv_store_id_2x(TVShow *show) show->common.trainerIdHi = id >> 8; } -void InterviewAfter_ContestLiveUpdates(void) +static void InterviewAfter_ContestLiveUpdates(void) { TVShow *show; TVShow *show2; @@ -1472,7 +1467,7 @@ void ContestLiveUpdates_BeforeInterview_5(u8 a0, u8 a1) } } -void InterviewAfter_BravoTrainerPokemonProfile(void) +static void InterviewAfter_BravoTrainerPokemonProfile(void) { TVShow *show; TVShow *show2; @@ -1538,7 +1533,7 @@ void BravoTrainerPokemonProfile_BeforeInterview2(u8 a0) } } -void InterviewAfter_BravoTrainerBattleTowerProfile(void) +static void InterviewAfter_BravoTrainerBattleTowerProfile(void) { TVShow *show; @@ -1671,7 +1666,7 @@ void PutLilycoveContestLadyShowOnTheAir(void) } } -void InterviewAfter_FanClubLetter(void) +static void InterviewAfter_FanClubLetter(void) { TVShow *show; @@ -1684,7 +1679,7 @@ void InterviewAfter_FanClubLetter(void) show->fanclubLetter.language = gGameLanguage; } -void InterviewAfter_RecentHappenings(void) +static void InterviewAfter_RecentHappenings(void) { TVShow *show; @@ -1697,7 +1692,7 @@ void InterviewAfter_RecentHappenings(void) show->recentHappenings.language = gGameLanguage; } -void InterviewAfter_PkmnFanClubOpinions(void) +static void InterviewAfter_PkmnFanClubOpinions(void) { TVShow *show; @@ -1722,14 +1717,14 @@ void InterviewAfter_PkmnFanClubOpinions(void) } } -void InterviewAfter_DummyShow4() +static void InterviewAfter_DummyShow4(void) { TVShow *show; show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; } -void sub_80ED718(void) +static void sub_80ED718(void) { u8 i; u16 outbreakIdx; @@ -1802,7 +1797,7 @@ void UpdateTVShowsPerDay(u16 days) sub_80EEB98(days); } -void sub_80ED8B4(u16 days) +static void sub_80ED8B4(u16 days) { u8 i; TVShow *show; @@ -1872,7 +1867,7 @@ void PutFishingAdviceShowOnTheAir(void) { TVShow *show; - sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); + sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_FISHING_ADVICE, FALSE) != TRUE) { show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot]; @@ -1892,7 +1887,7 @@ void SetPokemonAnglerSpecies(u16 species) sPokemonAnglerSpecies = species; } -void sub_80EDA48(u16 days) +static void sub_80EDA48(u16 days) { TVShow *show; @@ -2088,7 +2083,7 @@ void sub_80EDE84(u16 nCoinsSpent) sFindThatGamerCoinsSpent = nCoinsSpent; } -void sub_80EDE98(TVShow *show) +static void sub_80EDE98(TVShow *show) { u8 i; u8 j; @@ -2153,7 +2148,7 @@ void sub_80EDE98(TVShow *show) } } -void sub_80EDFB4(TVShow *show) +static void sub_80EDFB4(TVShow *show) { u8 i; u16 move; @@ -2590,7 +2585,7 @@ void sub_80EEA70(void) } } -void sub_80EEB98(u16 days) +static void sub_80EEB98(u16 days) { u8 i; @@ -2608,7 +2603,7 @@ void sub_80EEB98(u16 days) } } -void sub_80EEBF4(u8 actionIdx) +static void sub_80EEBF4(u8 actionIdx) { TVShow *show; @@ -2664,7 +2659,7 @@ void sub_80EED60(u16 delta) // PokeNews -void sub_80EED88(void) +static void sub_80EED88(void) { u8 newsKind; @@ -2715,7 +2710,7 @@ void ClearPokemonNewsI(u8 i) gSaveBlock1Ptr->pokeNews[i].days = 0; } -void sub_80EEEB8(void) +static void sub_80EEEB8(void) { u8 i; u8 j; @@ -2845,7 +2840,7 @@ bool8 sub_80EF0E4(u8 newsKind) return FALSE; } -void sub_80EF120(u16 days) +static void sub_80EF120(u16 days) { u8 i; @@ -2923,48 +2918,25 @@ void TV_PrintIntToStringVar(u8 varIdx, int value) { int nDigits; - nDigits = sub_80EF370(value); + nDigits = CountDigits(value); ConvertIntToDecimalStringN(gTVStringVarPtrs[varIdx], value, STR_CONV_MODE_LEFT_ALIGN, nDigits); } -size_t sub_80EF370(int value) +size_t CountDigits(int value) { - if (value / 10 == 0) - { - return 1; - } - if (value / 100 == 0) - { - return 2; - } - if (value / 1000 == 0) - { - return 3; - } - if (value / 10000 == 0) - { - return 4; - } - if (value / 100000 == 0) - { - return 5; - } - if (value / 1000000 == 0) - { - return 6; - } - if (value / 10000000 == 0) - { - return 7; - } - if (value / 100000000 == 0) - { - return 8; - } + if (value / 10 == 0) return 1; + if (value / 100 == 0) return 2; + if (value / 1000 == 0) return 3; + if (value / 10000 == 0) return 4; + if (value / 100000 == 0) return 5; + if (value / 1000000 == 0) return 6; + if (value / 10000000 == 0) return 7; + if (value / 100000000 == 0) return 8; + return 1; } -void sub_80EF40C(u8 varIdx, TVShow *show) +static void sub_80EF40C(u8 varIdx, TVShow *show) { u8 i; int price; @@ -3095,7 +3067,7 @@ void InterviewBefore(void) } } -void InterviewBefore_FanClubLetter(void) +static void InterviewBefore_FanClubLetter(void) { FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_FAN_CLUB_LETTER); if (!gSpecialVar_Result) @@ -3105,7 +3077,7 @@ void InterviewBefore_FanClubLetter(void) } } -void InterviewBefore_RecentHappenings(void) +static void InterviewBefore_RecentHappenings(void) { FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_RECENT_HAPPENINGS); if (!gSpecialVar_Result) @@ -3114,7 +3086,7 @@ void InterviewBefore_RecentHappenings(void) } } -void InterviewBefore_PkmnFanClubOpinions(void) +static void InterviewBefore_PkmnFanClubOpinions(void) { FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_PKMN_FAN_CLUB_OPINIONS); if (!gSpecialVar_Result) @@ -3126,17 +3098,17 @@ void InterviewBefore_PkmnFanClubOpinions(void) } } -void InterviewBefore_Dummy(void) +static void InterviewBefore_Dummy(void) { gSpecialVar_Result = TRUE; } -void InterviewBefore_NameRater(void) +static void InterviewBefore_NameRater(void) { FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_NAME_RATER_SHOW); } -void InterviewBefore_BravoTrainerPkmnProfile(void) +static void InterviewBefore_BravoTrainerPkmnProfile(void) { FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_BRAVO_TRAINER_POKEMON_PROFILE); if (!gSpecialVar_Result) @@ -3145,17 +3117,17 @@ void InterviewBefore_BravoTrainerPkmnProfile(void) } } -void InterviewBefore_ContestLiveUpdates(void) +static void InterviewBefore_ContestLiveUpdates(void) { FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_CONTEST_LIVE_UPDATES); } -void InterviewBefore_3CheersForPokeblocks(void) +static void InterviewBefore_3CheersForPokeblocks(void) { FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_3_CHEERS_FOR_POKEBLOCKS); } -void InterviewBefore_BravoTrainerBTProfile(void) +static void InterviewBefore_BravoTrainerBTProfile(void) { FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_BRAVO_TRAINER_BATTLE_TOWER_PROFILE); if (!gSpecialVar_Result) @@ -3164,7 +3136,7 @@ void InterviewBefore_BravoTrainerBTProfile(void) } } -void InterviewBefore_FanClubSpecial(void) +static void InterviewBefore_FanClubSpecial(void) { FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_FAN_CLUB_SPECIAL); if (!gSpecialVar_Result) @@ -3205,7 +3177,7 @@ void DeleteTVShowInArrayByIdx(TVShow *shows, u8 idx) } } -void sub_80EF93C(TVShow *shows) +static void sub_80EF93C(TVShow *shows) { u8 i; u8 j; @@ -3277,7 +3249,7 @@ u16 TV_GetSomeOtherSpeciesAlreadySeenByPlayer(u16 passedSpecies) return species; } -void sub_80EFA88(void) +static void sub_80EFA88(void) { sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); gSpecialVar_0x8006 = sCurTVShowSlot; @@ -3686,7 +3658,7 @@ void sub_80F01E8(void *src, u32 size, u8 masterIdx) } } -void sub_80F0358(TVShow player1[25], TVShow player2[25], TVShow player3[25], TVShow player4[25]) +static void sub_80F0358(TVShow player1[25], TVShow player2[25], TVShow player3[25], TVShow player4[25]) { u8 i; u8 j; @@ -3734,7 +3706,7 @@ void sub_80F0358(TVShow player1[25], TVShow player2[25], TVShow player3[25], TVS } } -bool8 sub_80F049C(TVShow *dest[25], TVShow *src[25], u8 idx) +static bool8 sub_80F049C(TVShow *dest[25], TVShow *src[25], u8 idx) { u8 value; u8 switchval; @@ -3765,7 +3737,7 @@ bool8 sub_80F049C(TVShow *dest[25], TVShow *src[25], u8 idx) return FALSE; } -u8 sub_80F0580(TVShow *tv1, TVShow *tv2, u8 idx) +static bool8 sub_80F0580(TVShow *tv1, TVShow *tv2, u8 idx) { u32 linkTrainerId = GetLinkPlayerTrainerId(idx); @@ -3782,7 +3754,7 @@ u8 sub_80F0580(TVShow *tv1, TVShow *tv2, u8 idx) return TRUE; } -u8 sub_80F05E8(TVShow *tv1, TVShow *tv2, u8 idx) +static bool8 sub_80F05E8(TVShow *tv1, TVShow *tv2, u8 idx) { u32 linkTrainerId = GetLinkPlayerTrainerId(idx); if ((linkTrainerId & 0xFF) == tv2->common.srcTrainerIdLo && ((linkTrainerId >> 8) & 0xFF) == tv2->common.srcTrainerIdHi) @@ -3802,7 +3774,7 @@ u8 sub_80F05E8(TVShow *tv1, TVShow *tv2, u8 idx) return TRUE; } -u8 sub_80F0668(TVShow *tv1, TVShow *tv2, u8 idx) +static bool8 sub_80F0668(TVShow *tv1, TVShow *tv2, u8 idx) { u32 linkTrainerId = GetLinkPlayerTrainerId(idx); if ((linkTrainerId & 0xFF) == tv2->common.trainerIdLo && ((linkTrainerId >> 8) & 0xFF) == tv2->common.trainerIdHi) @@ -3819,7 +3791,7 @@ u8 sub_80F0668(TVShow *tv1, TVShow *tv2, u8 idx) return TRUE; } -s8 sub_80F06D0(TVShow *tvShows) +static s8 sub_80F06D0(TVShow *tvShows) { u8 i; @@ -3834,7 +3806,7 @@ s8 sub_80F06D0(TVShow *tvShows) } #ifdef NONMATCHING -void sub_80F0708(void) // FIXME: register allocation shenanigans +static void sub_80F0708(void) // FIXME: register allocation shenanigans { u16 i; TVShow *show; @@ -3954,13 +3926,13 @@ void sub_80F0708(void) // FIXME: register allocation shenanigans break; default: - sub_80F0B00(i); + SetTvShowInactive(i); break; } } } #else -ASM_DIRECT void sub_80F0708(void) +ASM_DIRECT static void sub_80F0708(void) { asm_unified("\tpush {r4-r7,lr}\n" "\tmov r7, r9\n" @@ -4377,7 +4349,7 @@ ASM_DIRECT void sub_80F0708(void) "\tmov r2, r9\n" "\tlsls r0, r2, 24\n" "\tlsrs r0, 24\n" - "\tbl sub_80F0B00\n" + "\tbl SetTvShowInactive\n" "_080F0AE2_break:\n" "\tmov r0, r9\n" "\tadds r0, 0x1\n" @@ -4398,12 +4370,12 @@ ASM_DIRECT void sub_80F0708(void) } #endif -void sub_80F0B00(u8 showIdx) +void SetTvShowInactive(u8 showIdx) { gSaveBlock1Ptr->tvShows[showIdx].common.active = FALSE; } -void sub_80F0B24(u16 species, u8 showIdx) +static void sub_80F0B24(u16 species, u8 showIdx) { if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(species), 0) == 0) { @@ -4411,7 +4383,7 @@ void sub_80F0B24(u16 species, u8 showIdx) } } -void sub_80F0B64(void) +static void sub_80F0B64(void) { u16 i; @@ -4444,7 +4416,7 @@ void sub_80F0BB8(void) } } -void sub_80F0C04(void) +static void sub_80F0C04(void) { s8 i; s8 ct; @@ -4498,7 +4470,7 @@ void sub_80F0C7C(void *src, u32 size, u8 masterIdx) } } -void sub_80F0D60(PokeNews player1[16], PokeNews player2[16], PokeNews player3[16], PokeNews player4[16]) +static void sub_80F0D60(PokeNews player1[16], PokeNews player2[16], PokeNews player3[16], PokeNews player4[16]) { u8 i; u8 j; @@ -4530,7 +4502,7 @@ void sub_80F0D60(PokeNews player1[16], PokeNews player2[16], PokeNews player3[16 } } -void sub_80F0E58(PokeNews *dest[16], PokeNews *src[16]) +static void sub_80F0E58(PokeNews *dest[16], PokeNews *src[16]) { PokeNews *ptr1; PokeNews *ptr2; @@ -4541,7 +4513,7 @@ void sub_80F0E58(PokeNews *dest[16], PokeNews *src[16]) sub_80F0E84(ptr1, ptr2, sCurTVShowSlot); } -bool8 sub_80F0E84(PokeNews *dest, PokeNews *src, s8 slot) +static bool8 sub_80F0E84(PokeNews *dest, PokeNews *src, s8 slot) { u8 i; u8 kind; @@ -4563,7 +4535,7 @@ bool8 sub_80F0E84(PokeNews *dest, PokeNews *src, s8 slot) return TRUE; } -s8 sub_80F0ECC(PokeNews *pokeNews, u8 idx) +static s8 sub_80F0ECC(PokeNews *pokeNews, u8 idx) { if (pokeNews[idx].kind == POKENEWS_NONE) { @@ -4572,7 +4544,7 @@ s8 sub_80F0ECC(PokeNews *pokeNews, u8 idx) return idx; } -void sub_80F0EEC(void) +static void sub_80F0EEC(void) { u8 i; @@ -4586,7 +4558,7 @@ void sub_80F0EEC(void) sub_80EEEB8(); } -void sub_80F0F24(void) +static void sub_80F0F24(void) { u8 i; @@ -4609,7 +4581,7 @@ else \ (langptr) = langfix; \ } -void sub_80F0F64(TVShow *show, u32 language) +static void sub_80F0F64(TVShow *show, u32 language) { int i; TVShow **r4; @@ -4691,7 +4663,7 @@ void sub_80F1208(TVShow *shows) } } -void sub_80F1254(TVShow *shows) +static void sub_80F1254(TVShow *shows) { TVShow *curShow; @@ -4716,7 +4688,7 @@ u8 TV_GetStringLanguage(u8 *str) return IsStringJapanese(str) ? LANGUAGE_JAPANESE : LANGUAGE_ENGLISH; } -void sub_80F12A4(TVShow *shows) +static void sub_80F12A4(TVShow *shows) { TVShow *curShow; @@ -4956,7 +4928,7 @@ void DoTVShow(void) } } -void DoTVShowBravoTrainerPokemonProfile(void) +static void DoTVShowBravoTrainerPokemonProfile(void) { TVShow *show; u8 state; @@ -5028,7 +5000,7 @@ void DoTVShowBravoTrainerPokemonProfile(void) ShowFieldMessage(sTVBravoTrainerTextGroup[state]); } -void DoTVShowBravoTrainerBattleTower(void) +static void DoTVShowBravoTrainerBattleTower(void) { TVShow *show; u8 state; @@ -5125,7 +5097,7 @@ void DoTVShowBravoTrainerBattleTower(void) ShowFieldMessage(sTVBravoTrainerBattleTowerTextGroup[state]); } -void DoTVShowTodaysSmartShopper(void) +static void DoTVShowTodaysSmartShopper(void) { TVShow *show; u8 state; @@ -5248,7 +5220,7 @@ void DoTVShowTodaysSmartShopper(void) ShowFieldMessage(sTVTodaysSmartShopperTextGroup[state]); } -void DoTVShowTheNameRaterShow(void) +static void DoTVShowTheNameRaterShow(void) { TVShow *show; u8 state; @@ -5346,7 +5318,7 @@ void DoTVShowTheNameRaterShow(void) ShowFieldMessage(sTVNameRaterTextGroup[state]); } -void DoTVShowPokemonTodaySuccessfulCapture(void) +static void DoTVShowPokemonTodaySuccessfulCapture(void) { TVShow *show; u8 state; @@ -5424,7 +5396,7 @@ void DoTVShowPokemonTodaySuccessfulCapture(void) ShowFieldMessage(sTVPokemonTodaySuccessfulTextGroup[state]); } -void DoTVShowPokemonTodayFailedCapture(void) +static void DoTVShowPokemonTodayFailedCapture(void) { TVShow *show; u8 state; @@ -5477,7 +5449,7 @@ void DoTVShowPokemonTodayFailedCapture(void) ShowFieldMessage(sTVPokemonTodayFailedTextGroup[state]); } -void DoTVShowPokemonFanClubLetter(void) +static void DoTVShowPokemonFanClubLetter(void) { TVShow *show; u8 state; @@ -5531,7 +5503,7 @@ void DoTVShowPokemonFanClubLetter(void) ShowFieldMessage(sTVFanClubTextGroup[state]); } -void DoTVShowRecentHappenings(void) +static void DoTVShowRecentHappenings(void) { TVShow *show; u8 state; @@ -5566,7 +5538,7 @@ void DoTVShowRecentHappenings(void) ShowFieldMessage(sTVRecentHappeninssTextGroup[state]); } -void DoTVShowPokemonFanClubOpinions(void) +static void DoTVShowPokemonFanClubOpinions(void) { TVShow *show; u8 state; @@ -5599,12 +5571,12 @@ void DoTVShowPokemonFanClubOpinions(void) ShowFieldMessage(sTVFanClubOpinionsTextGroup[state]); } -void DoTVShowDummiedOut(void) +static void DoTVShowDummiedOut(void) { } -void DoTVShowPokemonNewsMassOutbreak(void) +static void DoTVShowPokemonNewsMassOutbreak(void) { TVShow *show; @@ -5616,7 +5588,7 @@ void DoTVShowPokemonNewsMassOutbreak(void) ShowFieldMessage(sTVMassOutbreakTextGroup[sTVShowState]); } -void DoTVShowPokemonContestLiveUpdates(void) +static void DoTVShowPokemonContestLiveUpdates(void) { TVShow *show; u8 state; @@ -5963,7 +5935,7 @@ void DoTVShowPokemonContestLiveUpdates(void) ShowFieldMessage(sTVContestLiveUpdatesTextGroup[state]); } -void DoTVShowPokemonBattleUpdate(void) +static void DoTVShowPokemonBattleUpdate(void) { TVShow *show; u8 state; @@ -6035,7 +6007,7 @@ void DoTVShowPokemonBattleUpdate(void) ShowFieldMessage(sTVPokemonBattleUpdateTextGroup[state]); } -void DoTVShow3CheersForPokeblocks(void) +static void DoTVShow3CheersForPokeblocks(void) { TVShow *show; u8 state; @@ -6206,7 +6178,7 @@ void DoTVShowInSearchOfTrainers(void) ShowFieldMessage(sTVInSearchOfTrainersTextGroup[state]); } -void DoTVShowPokemonAngler(void) +static void DoTVShowPokemonAngler(void) { TVShow *show; u8 state; @@ -6240,7 +6212,7 @@ void DoTVShowPokemonAngler(void) ShowFieldMessage(sTVPokemonAnslerTextGroup[state]); } -void DoTVShowTheWorldOfMasters(void) +static void DoTVShowTheWorldOfMasters(void) { TVShow *show; u8 state; @@ -6270,7 +6242,7 @@ void DoTVShowTheWorldOfMasters(void) ShowFieldMessage(sTVWorldOfMastersTextGroup[state]); } -void DoTVShowTodaysRivalTrainer(void) +static void DoTVShowTodaysRivalTrainer(void) { TVShow *show; u8 state; @@ -6419,7 +6391,7 @@ void DoTVShowTodaysRivalTrainer(void) ShowFieldMessage(sTVTodaysRivalTrainerTextGroup[state]); } -void DoTVShowDewfordTrendWatcherNetwork(void) +static void DoTVShowDewfordTrendWatcherNetwork(void) { TVShow *show; u8 state; @@ -6475,7 +6447,7 @@ void DoTVShowDewfordTrendWatcherNetwork(void) ShowFieldMessage(sTVDewfordTrendWatcherNetworkTextGroup[state]); } -void DoTVShowHoennTreasureInvestigators(void) +static void DoTVShowHoennTreasureInvestigators(void) { TVShow *show; u8 state; @@ -6519,7 +6491,7 @@ void DoTVShowHoennTreasureInvestigators(void) ShowFieldMessage(sTVHoennTreasureInvestisatorsTextGroup[state]); } -void DoTVShowFindThatGamer(void) +static void DoTVShowFindThatGamer(void) { TVShow *show; u8 state; @@ -6593,7 +6565,7 @@ void DoTVShowFindThatGamer(void) ShowFieldMessage(sTVFindThatGamerTextGroup[state]); } -void DoTVShowBreakingNewsTV(void) +static void DoTVShowBreakingNewsTV(void) { TVShow *show; u8 state; @@ -6696,7 +6668,7 @@ void DoTVShowBreakingNewsTV(void) ShowFieldMessage(sTVBreakinsNewsTextGroup[state]); } -void DoTVShowSecretBaseVisit(void) +static void DoTVShowSecretBaseVisit(void) { TVShow *show; u8 state; @@ -6792,7 +6764,7 @@ void DoTVShowSecretBaseVisit(void) ShowFieldMessage(sTVSecretBaseVisitTextGroup[state]); } -void DoTVShowPokemonLotteryWinnerFlashReport(void) +static void DoTVShowPokemonLotteryWinnerFlashReport(void) { TVShow *show; u8 state; @@ -6822,7 +6794,7 @@ void DoTVShowPokemonLotteryWinnerFlashReport(void) ShowFieldMessage(sTVPokemonLotteryWinnerFlashReportTextGroup[state]); } -void DoTVShowThePokemonBattleSeminar(void) +static void DoTVShowThePokemonBattleSeminar(void) { TVShow *show; u8 state; @@ -6886,7 +6858,7 @@ void DoTVShowThePokemonBattleSeminar(void) ShowFieldMessage(sTVThePokemonBattleSeminarTextGroup[state]); } -void DoTVShowTrainerFanClubSpecial(void) +static void DoTVShowTrainerFanClubSpecial(void) { TVShow *show; u8 state; @@ -6951,7 +6923,7 @@ void DoTVShowTrainerFanClubSpecial(void) ShowFieldMessage(sTVTrainerFanClubSpecialTextGroup[state]); } -void DoTVShowTrainerFanClub(void) +static void DoTVShowTrainerFanClub(void) { TVShow *show; u8 state; @@ -7038,7 +7010,7 @@ void DoTVShowTrainerFanClub(void) ShowFieldMessage(sTVTrainerFanClubTextGroup[state]); } -void DoTVShowSpotTheCuties(void) +static void DoTVShowSpotTheCuties(void) { TVShow *show; u8 state; @@ -7143,7 +7115,7 @@ void DoTVShowSpotTheCuties(void) ShowFieldMessage(sTVCutiesTextGroup[state]); } -void DoTVShowPokemonNewsBattleFrontier(void) +static void DoTVShowPokemonNewsBattleFrontier(void) { TVShow *show; u8 state; @@ -7292,7 +7264,7 @@ void DoTVShowPokemonNewsBattleFrontier(void) ShowFieldMessage(sTVPokemonNewsBattleFrontierTextGroup[state]); } -void DoTVShowWhatsNo1InHoennToday(void) +static void DoTVShowWhatsNo1InHoennToday(void) { TVShow *show; u8 state; @@ -7407,7 +7379,7 @@ u8 sub_80F51AC(TVShow *show, u8 a1) return 0; } -void DoTVShowSecretBaseSecrets(void) +static void DoTVShowSecretBaseSecrets(void) { TVShow *show; u8 state; @@ -7645,7 +7617,7 @@ void DoTVShowSecretBaseSecrets(void) ShowFieldMessage(sTVSecretBaseSecretsTextGroup[state]); } -void DoTVShowSafariFanClub(void) +static void DoTVShowSafariFanClub(void) { TVShow *show; u8 state; @@ -7732,7 +7704,7 @@ void DoTVShowSafariFanClub(void) ShowFieldMessage(sTVSafariFanClubTextGroup[state]); } -void DoTVShowPokemonContestLiveUpdates2(void) +static void DoTVShowPokemonContestLiveUpdates2(void) { TVShow *show; u8 state; From 59ff4aec9b792acacbdf6978ba4e9f63543af41f Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 27 Feb 2018 20:40:09 +0100 Subject: [PATCH 08/10] decompile and document battle tv --- asm/battle_link_817C95C.s | 246 ---- data/battle_link_817C95C.s | 174 --- include/battle.h | 37 +- include/battle_link_817C95C.h | 11 - include/battle_tv.h | 11 + include/global.tv.h | 4 +- include/tv.h | 1 + ld_script.txt | 5 +- src/battle_controller_link_opponent.c | 8 +- src/battle_controller_link_partner.c | 8 +- src/battle_controller_opponent.c | 2 +- src/battle_controller_player.c | 14 +- src/battle_controller_recorded_opponent.c | 2 +- src/battle_controller_wally.c | 2 +- src/battle_link_817C95C.c | 1306 ----------------- src/battle_tv.c | 1585 +++++++++++++++++++++ src/tv.c | 26 +- 17 files changed, 1649 insertions(+), 1793 deletions(-) delete mode 100644 asm/battle_link_817C95C.s delete mode 100644 data/battle_link_817C95C.s delete mode 100644 include/battle_link_817C95C.h create mode 100644 include/battle_tv.h delete mode 100644 src/battle_link_817C95C.c create mode 100644 src/battle_tv.c diff --git a/asm/battle_link_817C95C.s b/asm/battle_link_817C95C.s deleted file mode 100644 index 91406075d..000000000 --- a/asm/battle_link_817C95C.s +++ /dev/null @@ -1,246 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_817F21C -sub_817F21C: @ 817F21C - push {r4-r7,lr} - adds r6, r1, 0 - mov r12, r2 - lsls r0, 16 - lsrs r2, r0, 16 - ldr r1, =gBattleMoves - lsls r0, r2, 1 - adds r0, r2 - lsls r0, 2 - adds r0, r1 - ldrb r0, [r0, 0x1] - cmp r0, 0 - beq _0817F286 - movs r4, 0 - ldr r5, =gUnknown_0860A4AC - ldr r7, =0x0000ffff - adds r3, r5, 0 - adds r1, r5, 0 -_0817F240: - ldrh r0, [r1] - cmp r2, r0 - beq _0817F252 - adds r3, 0x2 - adds r1, 0x2 - adds r4, 0x1 - ldrh r0, [r3] - cmp r0, r7 - bne _0817F240 -_0817F252: - lsls r0, r4, 1 - adds r0, r5 - ldrh r1, [r0] - ldr r0, =0x0000ffff - cmp r1, r0 - beq _0817F270 - movs r0, 0 - str r0, [r6] - b _0817F2A0 - .pool -_0817F270: - cmp r2, 0x95 - bne _0817F294 - ldr r2, =gBattleMons - ldr r0, =gBattlerAttacker - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - adds r0, 0x2A - ldrb r0, [r0] - asrs r0, 1 -_0817F286: - str r0, [r6] - movs r0, 0 - b _0817F2A0 - .pool -_0817F294: - cmp r2, 0xDE - bne _0817F29E - movs r0, 0xA - mov r1, r12 - strh r0, [r1] -_0817F29E: - movs r0, 0x1 -_0817F2A0: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_817F21C - - thumb_func_start sub_817F2A8 -sub_817F2A8: @ 817F2A8 - push {r4,r5,lr} - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0817F324 - ldr r0, =gBattleStruct - ldr r3, [r0] - ldr r0, =0x0000025b - adds r4, r3, r0 - ldrb r2, [r4] - subs r1, 0x21 - adds r0, r1, 0 - ands r0, r2 - strb r0, [r4] - ldr r0, =0x00000267 - adds r2, r3, r0 - ldrb r0, [r2] - ands r1, r0 - strb r1, [r2] - ldrb r5, [r4] - movs r1, 0x1F - adds r0, r1, 0 - ands r0, r5 - strb r0, [r4] - ldrb r0, [r2] - ands r1, r0 - strb r1, [r2] - movs r0, 0x97 - lsls r0, 2 - adds r4, r3, r0 - ldrb r2, [r4] - movs r1, 0x39 - negs r1, r1 - adds r0, r1, 0 - ands r0, r2 - strb r0, [r4] - movs r0, 0x9A - lsls r0, 2 - adds r3, r0 - ldrb r0, [r3] - ands r1, r0 - strb r1, [r3] - ldrb r2, [r4] - movs r1, 0x7 - negs r1, r1 - adds r0, r1, 0 - ands r0, r2 - strb r0, [r4] - ldrb r0, [r3] - ands r1, r0 - strb r1, [r3] - ldrb r2, [r4] - movs r1, 0x2 - negs r1, r1 - adds r0, r1, 0 - ands r0, r2 - strb r0, [r4] - ldrb r0, [r3] - ands r1, r0 - strb r1, [r3] -_0817F324: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817F2A8 - - thumb_func_start GetBattlerMoveSlotId -GetBattlerMoveSlotId: @ 817F33C - push {r4-r7,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r1, 16 - lsrs r7, r1, 16 - adds r0, r5, 0 - bl GetBattlerSide - lsls r0, 24 - ldr r6, =gEnemyParty - cmp r0, 0 - bne _0817F356 - ldr r6, =gPlayerParty -_0817F356: - movs r4, 0 - ldr r1, =gBattlerPartyIndexes - lsls r0, r5, 1 - adds r5, r0, r1 - b _0817F36E - .pool -_0817F36C: - adds r4, 0x1 -_0817F36E: - cmp r4, 0x3 - bgt _0817F388 - ldrh r1, [r5] - movs r0, 0x64 - muls r0, r1 - adds r0, r6, r0 - adds r1, r4, 0 - adds r1, 0xD - movs r2, 0 - bl GetMonData - cmp r0, r7 - bne _0817F36C -_0817F388: - lsls r0, r4, 24 - lsrs r0, 24 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end GetBattlerMoveSlotId - - thumb_func_start sub_817F394 -sub_817F394: @ 817F394 - push {r4-r6,lr} - lsls r0, 16 - lsrs r3, r0, 16 - adds r4, r3, 0 - lsls r1, 16 - lsrs r1, 16 - adds r6, r1, 0 - lsls r2, 24 - lsrs r2, 24 - adds r5, r2, 0 - movs r0, 0x7 - ands r0, r3 - cmp r0, 0 - beq _0817F3B4 - movs r0, 0x3 - b _0817F3CA -_0817F3B4: - movs r0, 0x60 - ands r0, r3 - cmp r0, 0 - beq _0817F3C0 - movs r0, 0x4 - b _0817F3CA -_0817F3C0: - movs r0, 0x18 - ands r0, r3 - cmp r0, 0 - beq _0817F3D2 - movs r0, 0x5 -_0817F3CA: - movs r3, 0 - bl sub_817E684 - b _0817F3E6 -_0817F3D2: - movs r0, 0x80 - ands r4, r0 - cmp r4, 0 - beq _0817F3E6 - movs r0, 0x6 - adds r1, r6, 0 - adds r2, r5, 0 - movs r3, 0 - bl sub_817E684 -_0817F3E6: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_817F394 - - .align 2, 0 @ Don't pad with nop. diff --git a/data/battle_link_817C95C.s b/data/battle_link_817C95C.s deleted file mode 100644 index 24f70c79c..000000000 --- a/data/battle_link_817C95C.s +++ /dev/null @@ -1,174 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - - .align 1 -gUnknown_0860A4AC:: @ 860A4AC - .2byte 0x0044, 0x005a, 0x0075, 0x00f3, 0x0020, 0x00af, 0x00b3, 0x00ed, 0x0149, 0x0108, 0x011c, 0x0143, 0x008a, 0x0137, 0x00ad, 0x00dc - .2byte 0x000c, 0x00da, 0x00d8, 0x011b, 0x00d9, 0x0117, 0xffff, 0x00de, 0x0095, 0xffff - - .align 1 -gUnknown_0860A4E0:: @ 860A4E0 - .2byte 0x0001, 0x0001, 0x0001, 0x0004, 0x0001, 0x0001, 0x0001, 0x0000, 0x0005, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001 - .2byte 0x0001, 0x0002, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0005, 0x0005, 0x0004, 0x0005, 0x0001, 0x0003, 0x0001 - .2byte 0x0003, 0x0005, 0x0001, 0x0007, 0x0001, 0x0007, 0x0007, 0x0001, 0x0005, 0x0002, 0x0004, 0x0001, 0x0001, 0x0001, 0x0005, 0x0001 - .2byte 0x0002, 0x0004, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001 - .2byte 0x0001, 0x0007, 0x0004, 0x0004, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0004, 0x0001, 0x0001, 0x0001, 0x0004 - .2byte 0x0005, 0x0002, 0x0004, 0x0001, 0x0004, 0x0001, 0x0007, 0x0002, 0x0001, 0x0005, 0x0007, 0x0003, 0x0003, 0x0004, 0x0003, 0x0003 - .2byte 0x0003, 0x0003, 0x0003, 0x0002, 0x0004, 0x0001, 0x0005, 0x0001, 0x0001, 0x0004, 0x0005, 0x0003, 0x0001, 0x0002, 0x0001, 0x0005 - .2byte 0x0004, 0x0003, 0x0006, 0x0004, 0x0003, 0x0003, 0x0003, 0x0002, 0x0004, 0x0001, 0x0001, 0x0001, 0x0005, 0x0001, 0x0001, 0x0007 - .2byte 0x0002, 0x0002, 0x0001, 0x0001, 0x0004, 0x0004, 0x0004, 0x0001, 0x0004, 0x0004, 0x0001, 0x0001, 0x0001, 0x0001, 0x0007, 0x0007 - .2byte 0x0006, 0x0003, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0002, 0x0003, 0x0001, 0x0001, 0x0004, 0x0004 - .2byte 0x0003, 0x0003, 0x0003, 0x0001, 0x0004, 0x0007, 0x0007, 0x0005, 0x0007, 0x0001, 0x0007, 0x0001, 0x0005, 0x0000, 0x0004, 0x0004 - .2byte 0x0004, 0x0004, 0x0004, 0x0002, 0x0002, 0x0006, 0x0003, 0x0006, 0x0004, 0x0004, 0x0002, 0x0005, 0x0002, 0x0001, 0x0001, 0x0006 - .2byte 0x0006, 0x0006, 0x0001, 0x0001, 0x0001, 0x0001, 0x0002, 0x0006, 0x0001, 0x0004, 0x0001, 0x0001, 0x0003, 0x0001, 0x0001, 0x0001 - .2byte 0x0001, 0x0001, 0x0004, 0x0001, 0x0001, 0x0003 - - .align 1 -gUnknown_0860A68C:: @ 860A68C - .2byte 0x0004, 0xfffd, 0xfffa - - .align 1 -gUnknown_0860A692:: @ 860A692 - .2byte 0x0004, 0x0004, 0x0006, 0x0006, 0x0007, 0x0006, 0x0002 - - .align 1 -gUnknown_0860A6A0:: @ 860A6A0 - .2byte 0x0091, 0x0003, 0x00fa, 0x0003, 0x00be, 0x0003, 0x0080, 0x0003, 0x006e, 0x0003, 0x0098, 0x0003, 0x0143, 0x0003, 0x0123, 0x0003 - .2byte 0x007f, 0x0003, 0x014a, 0x0003, 0x0039, 0x0003, 0x0134, 0x0003, 0x0038, 0x0003, 0x003d, 0x0003, 0x015a, 0x0000, 0x0037, 0x0003 - .2byte 0x0160, 0x0003, 0x0137, 0x0003, 0x0057, 0x0003, 0x004c, 0xfffc, 0x013b, 0xfffc, 0x00ac, 0xfffc, 0x0035, 0xfffc, 0x00dd, 0xfffc - .2byte 0x007e, 0xfffc, 0x0101, 0xfffc, 0x0034, 0xfffc, 0x0133, 0xfffc, 0x012b, 0xfffc, 0x011c, 0xfffc, 0x0053, 0xfffc, 0x0007, 0xfffc - .2byte 0x004c, 0xfffc, 0xffff, 0x0000 - - .align 1 -gUnknown_0860A728:: @ 860A728 - .2byte 0x013b, 0x0003, 0x00ac, 0x0003, 0x0035, 0x0003, 0x00dd, 0x0003, 0x007e, 0x0003, 0x0101, 0x0003, 0x0034, 0x0003, 0x0133, 0x0003 - .2byte 0x012b, 0x0003, 0x011c, 0x0003, 0x0053, 0x0003, 0x0007, 0x0003, 0x004c, 0x0005, 0x00eb, 0x0003, 0x00ea, 0x0003, 0x00ec, 0x0003 - .2byte 0x0137, 0x0003, 0xffff, 0x0000 - - .align 1 -gUnknown_0860A770:: @ 860A770 - .2byte 0x0137, 0x0003, 0x004c, 0xfffd, 0xffff, 0x0000 - - .align 1 -gUnknown_0860A77C:: @ 860A77C - .2byte 0x0137, 0x0003, 0x004c, 0xfffd, 0xffff, 0x0000 - - .align 1 -gUnknown_0860A788:: @ 860A788 - .2byte 0x0055, 0x0003, 0x0009, 0x0003, 0x00d1, 0x0003, 0x0054, 0x0003, 0x00c0, 0x0003, 0x015f, 0x0003, 0x0056, 0x0000, 0x0057, 0x0003 - .2byte 0x0158, 0x0003, 0xffff, 0x0000 - - .align 1 -gUnknown_0860A7B0:: @ 860A7B0 - .2byte 0x0005, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003 - - .align 1 -gUnknown_0860A7BE:: @ 860A7BE - .2byte 0x0005, 0x0005, 0x0005, 0x0005, 0x0005 - - .align 1 -gUnknown_0860A7C8:: @ 860A7C8 - .2byte 0x0004 - - .align 1 -gUnknown_0860A7CA:: @ 860A7CA - .2byte 0x0005 - - .align 1 -gUnknown_0860A7CC:: @ 860A7CC - .2byte 0x0005 - - .align 1 -gUnknown_0860A7CE:: @ 860A7CE - .2byte 0x0003 - - .align 1 -gUnknown_0860A7D0:: @ 860A7D0 - .2byte 0x0003 - - .align 1 -gUnknown_0860A7D2:: @ 860A7D2 - .2byte 0x0004 - - .align 1 -gUnknown_0860A7D4:: @ 860A7D4 - .2byte 0x0003 - - .align 1 -gUnknown_0860A7D6:: @ 860A7D6 - .2byte 0x0006 - - .align 1 -gUnknown_0860A7D8:: @ 860A7D8 - .2byte 0x0006 - - .align 1 -gUnknown_0860A7DA:: @ 860A7DA - .2byte 0x0006 - - .align 1 -gUnknown_0860A7DC:: @ 860A7DC - .2byte 0x0004 - - .align 1 -gUnknown_0860A7DE:: @ 860A7DE - .2byte 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002 - - .align 1 -gUnknown_0860A7EC:: @ 860A7EC - .2byte 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004 - - .align 1 -gUnknown_0860A7FA:: @ 860A7FA - .2byte 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff - - .align 1 -gUnknown_0860A808:: @ 860A808 - .2byte 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002 - - .align 1 -gUnknown_0860A816:: @ 860A816 - .2byte 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004 - - .align 1 -gUnknown_0860A824:: @ 860A824 - .2byte 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe - - .align 2 -gUnknown_0860A834:: @ 860A834 - .4byte gUnknown_0860A4E0 - .4byte gUnknown_0860A68C - .4byte gUnknown_0860A692 - .4byte gUnknown_0860A6A0 - .4byte gUnknown_0860A728 - .4byte gUnknown_0860A770 - .4byte gUnknown_0860A77C - .4byte gUnknown_0860A788 - .4byte gUnknown_0860A7B0 - .4byte gUnknown_0860A7BE - .4byte gUnknown_0860A7C8 - .4byte gUnknown_0860A7CA - .4byte gUnknown_0860A7CC - .4byte gUnknown_0860A7CE - .4byte gUnknown_0860A7D0 - .4byte gUnknown_0860A7D2 - .4byte gUnknown_0860A7D4 - .4byte gUnknown_0860A7D6 - .4byte gUnknown_0860A7D8 - .4byte gUnknown_0860A7DA - .4byte gUnknown_0860A7DA - .4byte gUnknown_0860A7DC - .4byte gUnknown_0860A7DE - .4byte gUnknown_0860A7EC - .4byte gUnknown_0860A7FA - .4byte gUnknown_0860A808 - .4byte gUnknown_0860A816 - .4byte gUnknown_0860A824 - - .align 1 -gUnknown_0860A8A4:: @ 860A8A4 - .2byte 0x0097, 0x00b2, 0x00bc, 0x008c, 0x00b4, 0x00b5, 0x0093, 0x006a, 0x0091, 0x005e, 0x0030, 0x002a, 0x0095, 0x001c, 0x001d, 0x0064 - .2byte 0x0060, 0xffff - diff --git a/include/battle.h b/include/battle.h index 8c819f047..731b5692e 100644 --- a/include/battle.h +++ b/include/battle.h @@ -368,7 +368,7 @@ struct BattleResults u8 catchAttempts[11]; // 0x36 }; -struct BattleLinkStringSide +struct BattleTv_Side { u32 spikesMonId:3; u32 reflectMonId:3; @@ -380,7 +380,7 @@ struct BattleLinkStringSide u32 perishSongMonId:3; u32 wishMonId:3; u32 grudgeMonId:3; - u32 field_8_6:2; + u32 usedMoveSlot:2; u32 spikesMoveSlot:2; u32 reflectMoveSlot:2; u32 lightScreenMoveSlot:2; @@ -393,18 +393,15 @@ struct BattleLinkStringSide u32 grudgeMoveSlot:2; u32 destinyBondMonId:3; u32 destinyBondMoveSlot:2; - u32 field_3_0:4; - u32 field_3_1:3; + u32 faintCause:4; + u32 faintCauseMonId:3; u32 explosion:1; u32 explosionMoveSlot:2; u32 explosionMonId:3; u32 perishSong:1; - u32 field_4_2:1; - u32 field_5_0:3; - u32 field_5_1:2; }; -struct BattleLinkStringPosition +struct BattleTv_Position { u32 curseMonId:3; u32 leechSeedMonId:3; @@ -424,11 +421,11 @@ struct BattleLinkStringPosition u32 mudSportMoveSlot:2; u32 ingrainMonId:3; u32 ingrainMoveSlot:2; - u32 field_5_5:3; - u32 field_6_0:2; + u32 attackedByMonId:3; + u32 attackedByMoveSlot:2; }; -struct BattleLinkStringMon +struct BattleTv_Mon { u32 psnMonId:3; u32 badPsnMonId:3; @@ -444,16 +441,16 @@ struct BattleLinkStringMon u32 frzMoveSlot:2; }; -struct UnknownBattleLinkStruct +struct BattleTv { - struct BattleLinkStringMon mon[2][6]; // [side][partyId] - struct BattleLinkStringPosition pos[2][2]; // [side][flank] - struct BattleLinkStringSide side[2]; // [side] + struct BattleTv_Mon mon[2][6]; // [side][partyId] + struct BattleTv_Position pos[2][2]; // [side][flank] + struct BattleTv_Side side[2]; // [side] }; -struct UnknownBattleLinkArrayStruct +struct BattleTvMovePoints { - s16 unk0[2][6*4]; + s16 points[2][PARTY_SIZE * 4]; }; struct BattleStruct @@ -535,7 +532,7 @@ struct BattleStruct u8 field_B0; u8 hpScale; u8 synchronizeMoveEffect; - u8 field_B3; + bool8 anyMonHasTransformed; void (*savedCallback)(void); u16 usedHeldItems[MAX_BATTLERS_COUNT]; u8 chosenItem[4]; // why is this an u8? @@ -560,8 +557,8 @@ struct BattleStruct u8 wishPerishSongBattlerId; bool8 overworldWeatherDone; u8 atkCancellerTracker; - struct UnknownBattleLinkArrayStruct field_1A4; - struct UnknownBattleLinkStruct field_204; + struct BattleTvMovePoints tvMovePoints; + struct BattleTv tv; u8 notSureWhatFieldLol[0x28]; u8 AI_monToSwitchIntoId[MAX_BATTLERS_COUNT]; u8 field_298[8]; diff --git a/include/battle_link_817C95C.h b/include/battle_link_817C95C.h deleted file mode 100644 index cb2cb0b27..000000000 --- a/include/battle_link_817C95C.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef GUARD_BATTLE_LINK_817C95C_H -#define GUARD_BATTLE_LINK_817C95C_H - -void sub_817C95C(u16 stringId); -void sub_817E0FC(u16 move, u16 weatherFlags, struct DisableStruct *disableStructPtr); -void sub_817E32C(u8 animationId); -void sub_817E3F4(void); -void sub_817F2A8(void); -u8 GetBattlerMoveSlotId(u8 bank, u16 move); - -#endif // GUARD_BATTLE_LINK_817C95C_H diff --git a/include/battle_tv.h b/include/battle_tv.h new file mode 100644 index 000000000..72466d73b --- /dev/null +++ b/include/battle_tv.h @@ -0,0 +1,11 @@ +#ifndef GUARD_BATTLE_TV_H +#define GUARD_BATTLE_TV_H + +void BattleTv_SetDataBasedOnString(u16 stringId); +void BattleTv_SetDataBasedOnMove(u16 move, u16 weatherFlags, struct DisableStruct *disableStructPtr); +void BattleTv_SetDataBasedOnAnimation(u8 animationId); +void TryPutLinkBattleTvShowOnAir(void); +void BattleTv_ClearExplosionFaintCause(void); +u8 GetBattlerMoveSlotId(u8 battlerId, u16 moveId); + +#endif // GUARD_BATTLE_TV_H diff --git a/include/global.tv.h b/include/global.tv.h index 5f65aa8e0..81f181cf3 100644 --- a/include/global.tv.h +++ b/include/global.tv.h @@ -188,11 +188,11 @@ typedef union // size = 0x24 struct { /*0x00*/ u8 kind; /*0x01*/ bool8 active; - /*0x02*/ u16 species; + /*0x02*/ u16 speciesOpponent; /*0x04*/ u8 playerName[8]; /*0x0C*/ u8 linkOpponentName[8]; /*0x14*/ u16 move; - /*0x16*/ u16 species2; + /*0x16*/ u16 speciesPlayer; /*0x18*/ u8 battleType; /*0x19*/ u8 language; /*0x1A*/ u8 linkOpponentLanguage; diff --git a/include/tv.h b/include/tv.h index 93854be56..8c7c4701e 100644 --- a/include/tv.h +++ b/include/tv.h @@ -38,5 +38,6 @@ void sub_80EECC8(void); void sub_80EECEC(void); void sub_80F1208(TVShow *shows); void sub_80EE44C(u8 nMonsCaught, u8 nPkblkUsed); +void PutBattleUpdateOnTheAir(u8 opponentLinkPlayerId, u16 move, u16 speciesPlayer, u16 speciesOpponent); #endif //GUARD_TV_H diff --git a/ld_script.txt b/ld_script.txt index 4ae3f183a..ede1c7ad1 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -236,8 +236,7 @@ SECTIONS { src/evolution_graphics.o(.text); src/bard_music.o(.text); src/fldeff_teleport.o(.text); - src/battle_link_817C95C.o(.text); - asm/battle_link_817C95C.o(.text); + src/battle_tv.o(.text); src/pokemon_animation.o(.text); src/recorded_battle.o(.text); src/battle_controller_recorded_opponent.o(.text); @@ -512,7 +511,7 @@ SECTIONS { src/intro_credits_graphics.o(.rodata); src/evolution_graphics.o(.rodata); src/bard_music.o(.rodata); - data/battle_link_817C95C.o(.rodata); + src/battle_tv.o(.rodata); src/pokemon_animation.o(.rodata); src/battle_controller_recorded_opponent.o(.rodata); src/battle_controller_recorded_player.o(.rodata); diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c index a399adf25..6e6968786 100644 --- a/src/battle_controller_link_opponent.c +++ b/src/battle_controller_link_opponent.c @@ -6,7 +6,7 @@ #include "battle_anim.h" #include "constants/battle_anim.h" #include "battle_ai_script_commands.h" -#include "battle_link_817C95C.h" +#include "battle_tv.h" #include "pokemon.h" #include "link.h" #include "util.h" @@ -1414,7 +1414,7 @@ static void LinkOpponentHandleMoveAnimation(void) { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattlerControllerFuncs[gActiveBattler] = LinkOpponentDoMoveAnimation; - sub_817E0FC(move, gWeatherMoveAnim, gAnimDisableStructPtr); + BattleTv_SetDataBasedOnMove(move, gWeatherMoveAnim, gAnimDisableStructPtr); } } } @@ -1478,7 +1478,7 @@ static void LinkOpponentHandlePrintString(void) BufferStringBattle(*stringId); BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; - sub_817C95C(*stringId); + BattleTv_SetDataBasedOnString(*stringId); } static void LinkOpponentHandlePrintSelectionString(void) @@ -1831,7 +1831,7 @@ static void LinkOpponentHandleBattleAnimation(void) else gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation; - sub_817E32C(animationId); + BattleTv_SetDataBasedOnAnimation(animationId); } } diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c index 1734abe62..476a95ad1 100644 --- a/src/battle_controller_link_partner.c +++ b/src/battle_controller_link_partner.c @@ -6,7 +6,7 @@ #include "battle_anim.h" #include "constants/battle_anim.h" #include "battle_ai_script_commands.h" -#include "battle_link_817C95C.h" +#include "battle_tv.h" #include "pokemon.h" #include "link.h" #include "util.h" @@ -1238,7 +1238,7 @@ static void LinkPartnerHandleMoveAnimation(void) { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattlerControllerFuncs[gActiveBattler] = LinkPartnerDoMoveAnimation; - sub_817E0FC(move, gWeatherMoveAnim, gAnimDisableStructPtr); + BattleTv_SetDataBasedOnMove(move, gWeatherMoveAnim, gAnimDisableStructPtr); } } } @@ -1302,7 +1302,7 @@ static void LinkPartnerHandlePrintString(void) BufferStringBattle(*stringId); BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; - sub_817C95C(*stringId); + BattleTv_SetDataBasedOnString(*stringId); } static void LinkPartnerHandlePrintSelectionString(void) @@ -1666,7 +1666,7 @@ static void LinkPartnerHandleBattleAnimation(void) else gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation; - sub_817E32C(animationId); + BattleTv_SetDataBasedOnAnimation(animationId); } } diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 26e0191cb..54d6434a3 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -5,7 +5,7 @@ #include "battle_interface.h" #include "battle_anim.h" #include "constants/battle_anim.h" -#include "battle_link_817C95C.h" +#include "battle_tv.h" #include "battle_ai_script_commands.h" #include "pokemon.h" #include "link.h" diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 8847715f6..f25566dd5 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -5,7 +5,7 @@ #include "battle_interface.h" #include "battle_anim.h" #include "constants/battle_anim.h" -#include "battle_link_817C95C.h" +#include "battle_tv.h" #include "pokemon.h" #include "link.h" #include "util.h" @@ -881,7 +881,7 @@ static void sub_80586F8(void) gMain.callback1 = gPreBattleCallback1; SetMainCallback2(sub_8038D64); if (gBattleOutcome == B_OUTCOME_WON) - sub_817E3F4(); + TryPutLinkBattleTvShowOnAir(); FreeAllWindowBuffers(); } } @@ -894,7 +894,7 @@ static void sub_80586F8(void) gMain.callback1 = gPreBattleCallback1; SetMainCallback2(sub_8038D64); if (gBattleOutcome == B_OUTCOME_WON) - sub_817E3F4(); + TryPutLinkBattleTvShowOnAir(); FreeAllWindowBuffers(); } } @@ -2484,7 +2484,7 @@ static void PlayerHandleMoveAnimation(void) { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattlerControllerFuncs[gActiveBattler] = PlayerDoMoveAnimation; - sub_817E0FC(move, gWeatherMoveAnim, gAnimDisableStructPtr); + BattleTv_SetDataBasedOnMove(move, gWeatherMoveAnim, gAnimDisableStructPtr); } } } @@ -2548,7 +2548,7 @@ static void PlayerHandlePrintString(void) BufferStringBattle(*stringId); BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter2; - sub_817C95C(*stringId); + BattleTv_SetDataBasedOnString(*stringId); sub_81A57E4(gActiveBattler, *stringId); } @@ -2575,7 +2575,7 @@ static void PlayerHandleChooseAction(void) s32 i; gBattlerControllerFuncs[gActiveBattler] = HandleChooseActionAfterDma3; - sub_817F2A8(); + BattleTv_ClearExplosionFaintCause(); BattleHandleAddTextPrinter(gText_BattleMenu, 2); for (i = 0; i < 4; i++) @@ -3069,7 +3069,7 @@ static void PlayerHandleBattleAnimation(void) else gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation; - sub_817E32C(animationId); + BattleTv_SetDataBasedOnAnimation(animationId); } } diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index 2295c4a75..ded65828b 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -6,7 +6,7 @@ #include "battle_anim.h" #include "constants/battle_anim.h" #include "battle_ai_script_commands.h" -#include "battle_link_817C95C.h" +#include "battle_tv.h" #include "recorded_battle.h" #include "pokemon.h" #include "link.h" diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c index 445feaf7a..0d18de0e4 100644 --- a/src/battle_controller_wally.c +++ b/src/battle_controller_wally.c @@ -5,7 +5,7 @@ #include "battle_interface.h" #include "battle_anim.h" #include "constants/battle_anim.h" -#include "battle_link_817C95C.h" +#include "battle_tv.h" #include "pokemon.h" #include "link.h" #include "util.h" diff --git a/src/battle_link_817C95C.c b/src/battle_link_817C95C.c deleted file mode 100644 index 1a8a201aa..000000000 --- a/src/battle_link_817C95C.c +++ /dev/null @@ -1,1306 +0,0 @@ -#include "global.h" -#include "pokemon.h" -#include "battle.h" -#include "battle_link_817C95C.h" -#include "constants/battle_string_ids.h" -#include "constants/battle_anim.h" -#include "constants/moves.h" -#include "constants/species.h" -#include "battle_message.h" -#include "tv.h" - -extern struct StringInfoBattle *gStringInfo; - -extern const struct BattleMove gBattleMoves[]; - -// this file's functions -bool8 sub_817E0B8(u16 stringId); -void sub_817E684(u8 arg0, u16 arg1, u8 arg2, u8 arg3); -void sub_817EECC(void); -void sub_817EA80(u8 arg0); -void sub_817F394(u16 weatherFlags, u16 moveId, u8 moveSlot); -bool8 sub_817F21C(u16 moveId, s32 *dmg, u16 *powerOverride); - -// const rom data -extern const u16 *const gUnknown_0860A834[]; -extern const u16 gUnknown_0860A8A4[]; -extern const u16 gUnknown_0860A4AC[]; - -// code -void sub_817C95C(u16 stringId) -{ - struct UnknownBattleLinkStruct *structPtr; - u32 atkSide, defSide, effSide, scriptingSide; - struct Pokemon *atkMon, *defMon; - u8 moveSlot; - u32 atkFlank, defFlank, effFlank; - u8 *perishCount; - u16 *statStringId, *finishedMoveId; - - if (!(gBattleTypeFlags & BATTLE_TYPE_LINK) && stringId != STRINGID_ITDOESNTAFFECT && stringId != STRINGID_NOTVERYEFFECTIVE) - return; - - structPtr = &gBattleStruct->field_204; - - atkSide = GetBattlerSide(gBattlerAttacker); - defSide = GetBattlerSide(gBattlerTarget); - effSide = GetBattlerSide(gEffectBattler); - scriptingSide = GetBattlerSide(gStringInfo->scrActive); - - if (atkSide == B_SIDE_PLAYER) - atkMon = &gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]]; - else - atkMon = &gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker]]; - - if (defSide == B_SIDE_PLAYER) - defMon = &gPlayerParty[gBattlerPartyIndexes[gBattlerTarget]]; - else - defMon = &gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]]; - - moveSlot = GetBattlerMoveSlotId(gBattlerAttacker, gStringInfo->currentMove); - - if (moveSlot >= 4 && sub_817E0B8(stringId) && stringId > BATTLESTRINGS_ID_ADDER) - { - structPtr->side[atkSide].field_3_0 = 15; - return; - } - - perishCount = (u8 *)(gBattleTextBuff1 + 4); - statStringId = (u16 *)(gBattleTextBuff2 + 2); - finishedMoveId = (u16 *)(gBattleTextBuff1 + 2); - - atkFlank = GetBattlerPosition(gBattlerAttacker) / 2; - defFlank = GetBattlerPosition(gBattlerTarget) / 2; - effFlank = GetBattlerPosition(gEffectBattler) / 2; - - switch (stringId) - { - case STRINGID_ITDOESNTAFFECT: - sub_817E684(1, moveSlot, 2, 0); - if (!(gBattleTypeFlags & BATTLE_TYPE_LINK)) - sub_817EECC(); - break; - case STRINGID_NOTVERYEFFECTIVE: - sub_817E684(1, moveSlot, 1, 0); - if (!(gBattleTypeFlags & BATTLE_TYPE_LINK) && GetMonData(defMon, MON_DATA_HP, NULL) != 0) - sub_817EECC(); - break; - case STRINGID_SUPEREFFECTIVE: - sub_817E684(1, moveSlot, 0, 0); - break; - case STRINGID_PKMNFORESAWATTACK: - structPtr->side[atkSide].futureSightMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[atkSide].futureSightMoveSlot = moveSlot; - break; - case STRINGID_PKMNCHOSEXASDESTINY: - structPtr->side[atkSide].doomDesireMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[atkSide].doomDesireMoveSlot = moveSlot; - break; - case STRINGID_FAINTINTHREE: - structPtr->side[atkSide].perishSongMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[atkSide].perishSongMoveSlot = moveSlot; - structPtr->side[atkSide].perishSong = 1; - break; - case STRINGID_PKMNPERISHCOUNTFELL: - if (*perishCount == 0) - structPtr->side[atkSide].field_3_0 = 10; - break; - case STRINGID_PKMNWISHCAMETRUE: - if (structPtr->side[defSide].wishMonId != 0) - { - sub_817E684(2, 3, defSide, - (structPtr->side[defSide].wishMonId - 1) * 4 + structPtr->side[defSide].wishMoveSlot); - } - break; - case STRINGID_PKMNWANTSGRUDGE: - structPtr->side[atkSide].grudgeMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[atkSide].grudgeMoveSlot = moveSlot; - break; - case STRINGID_PKMNLOSTPPGRUDGE: - if (structPtr->side[defSide].grudgeMonId != 0) - { - sub_817E684(2, 4, defSide, - (structPtr->side[defSide].grudgeMonId - 1) * 4 + structPtr->side[defSide].grudgeMoveSlot); - } - break; - case STRINGID_PKMNTRYINGTOTAKEFOE: - structPtr->side[atkSide].destinyBondMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[atkSide].destinyBondMoveSlot = moveSlot; - break; - case STRINGID_PKMNTOOKFOE: - if (structPtr->side[defSide].destinyBondMonId != 0) - structPtr->side[atkSide].field_3_0 = 11; - break; - case STRINGID_PKMNPLANTEDROOTS: - structPtr->pos[atkSide][atkFlank].ingrainMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->pos[atkSide][atkFlank].ingrainMoveSlot = moveSlot; - break; - case STRINGID_PKMNABSORBEDNUTRIENTS: - if (structPtr->pos[atkSide][atkFlank].ingrainMonId != 0) - { - sub_817E684(2, 6, atkSide, - (structPtr->pos[atkSide][atkFlank].ingrainMonId - 1) * 4 + structPtr->pos[atkSide][atkFlank].ingrainMoveSlot); - } - break; - case STRINGID_PKMNANCHOREDITSELF: - if (structPtr->pos[defSide][defFlank].ingrainMonId != 0) - { - sub_817E684(2, 6, defSide, - (structPtr->pos[defSide][defFlank].ingrainMonId - 1) * 4 + structPtr->pos[defSide][defFlank].ingrainMoveSlot); - } - break; - case STRINGID_PKMNTRANSFORMEDINTO: - gBattleStruct->field_B3 = 1; - break; - case STRINGID_CRITICALHIT: - sub_817E684(0x12, moveSlot, 0, 0); - break; - case STRINGID_PKMNSSTATCHANGED: - if (gBattleTextBuff1[2] != 0) - { - if (*statStringId == STRINGID_STATSHARPLY) - sub_817E684(0x17, moveSlot, gBattleTextBuff1[2] - 1, 0); - else - sub_817E684(0x16, moveSlot, gBattleTextBuff1[2] - 1, 0); - } - break; - case STRINGID_PKMNSSTATCHANGED2: - if (gBattleTextBuff1[2] != 0) - { - if (gBattlerAttacker == gBattlerTarget) - { - if (*statStringId == STRINGID_STATSHARPLY) - sub_817E684(0x17, moveSlot, gBattleTextBuff1[2] - 1, 0); - else - sub_817E684(0x16, moveSlot, gBattleTextBuff1[2] - 1, 0); - } - else - { - sub_817E684(0x1B, moveSlot, gBattleTextBuff1[2] - 1, 0); - } - } - break; - case STRINGID_PKMNSSTATCHANGED3: - if (gBattleTextBuff1[2] != 0) - sub_817E684(0x18, moveSlot, gBattleTextBuff1[2] - 1, 0); - break; - case STRINGID_PKMNSSTATCHANGED4: - if (gBattleTextBuff1[2] != 0) - { - if (*statStringId == STRINGID_STATHARSHLY) - sub_817E684(0x1A, moveSlot, gBattleTextBuff1[2] - 1, 0); - else - sub_817E684(0x19, moveSlot, gBattleTextBuff1[2] - 1, 0); - } - break; - case STRINGID_PKMNLAIDCURSE: - structPtr->pos[defSide][defFlank].curseMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->pos[defSide][defFlank].curseMoveSlot = moveSlot; - break; - case STRINGID_PKMNAFFLICTEDBYCURSE: - if (GetMonData(atkMon, MON_DATA_HP, NULL) - && structPtr->pos[atkSide][atkFlank].curseMonId != 0) - { - sub_817E684(8, 0, structPtr->pos[atkSide][atkFlank].curseMonId - 1, structPtr->pos[atkSide][atkFlank].curseMoveSlot); - structPtr->side[atkSide].field_3_0 = 1; - structPtr->side[atkSide].field_3_1 = atkFlank; - } - break; - case STRINGID_PKMNSEEDED: - structPtr->pos[defSide][defFlank].leechSeedMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->pos[defSide][defFlank].leechSeedMoveSlot = moveSlot; - break; - case STRINGID_PKMNSAPPEDBYLEECHSEED: - if (structPtr->pos[atkSide][atkFlank].leechSeedMonId != 0) - { - sub_817E684(8, 1, structPtr->pos[atkSide][atkFlank].leechSeedMonId - 1, structPtr->pos[atkSide][atkFlank].leechSeedMoveSlot); - structPtr->side[atkSide].field_3_0 = 2; - structPtr->side[atkSide].field_3_1 = atkFlank; - } - break; - case STRINGID_PKMNFELLINTONIGHTMARE: - structPtr->pos[defSide][defFlank].nightmareMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->pos[defSide][defFlank].nightmareMoveSlot = moveSlot; - break; - case STRINGID_PKMNLOCKEDINNIGHTMARE: - if (GetMonData(atkMon, MON_DATA_HP, NULL) != 0 - && structPtr->pos[atkSide][atkFlank].nightmareMonId != 0) - { - sub_817E684(8, 5, structPtr->pos[atkSide][atkFlank].nightmareMonId - 1, structPtr->pos[atkSide][atkFlank].nightmareMoveSlot); - structPtr->side[atkSide].field_3_0 = 5; - structPtr->side[atkSide].field_3_1 = atkFlank; - } - break; - case STRINGID_PKMNSQUEEZEDBYBIND: - case STRINGID_PKMNTRAPPEDINVORTEX: - case STRINGID_PKMNWRAPPEDBY: - case STRINGID_PKMNCLAMPED: - case STRINGID_PKMNTRAPPEDBYSANDTOMB: - structPtr->pos[defSide][defFlank].wrapMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->pos[defSide][defFlank].wrapMoveSlot = moveSlot; - break; - case STRINGID_PKMNHURTBY: - if (GetMonData(atkMon, MON_DATA_HP, NULL) != 0 - && structPtr->pos[atkSide][atkFlank].wrapMonId != 0) - { - sub_817E684(8, 6, structPtr->pos[atkSide][atkFlank].wrapMonId - 1, structPtr->pos[atkSide][atkFlank].wrapMoveSlot); - structPtr->side[atkSide].field_3_0 = 6; - structPtr->side[atkSide].field_3_1 = atkFlank; - } - break; - case STRINGID_PKMNWASBURNED: - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].brnMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].brnMoveSlot = moveSlot; - break; - case STRINGID_PKMNHURTBYBURN: - if (GetMonData(atkMon, MON_DATA_HP, NULL) != 0) - { - if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].brnMonId != 0) - sub_817E684(8, 4, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].brnMonId - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].brnMoveSlot); - structPtr->side[atkSide].field_3_0 = 4; - structPtr->side[atkSide].field_3_1 = gBattlerPartyIndexes[gBattlerAttacker]; - } - break; - case STRINGID_PKMNWASPOISONED: - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].psnMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].psnMoveSlot = moveSlot; - break; - case STRINGID_PKMNBADLYPOISONED: - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].badPsnMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].badPsnMoveSlot = moveSlot; - break; - case STRINGID_PKMNHURTBYPOISON: - if (GetMonData(atkMon, MON_DATA_HP, NULL) != 0) - { - if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].psnMonId != 0) - sub_817E684(8, 2, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].psnMonId - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].psnMoveSlot); - if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].badPsnMonId != 0) - sub_817E684(8, 3, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].badPsnMonId - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].badPsnMoveSlot); - structPtr->side[atkSide].field_3_0 = 3; - structPtr->side[atkSide].field_3_1 = gBattlerPartyIndexes[gBattlerAttacker]; - } - break; - case STRINGID_PKMNFELLINLOVE: - structPtr->pos[defSide][defFlank].attractMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->pos[defSide][defFlank].attractMoveSlot = moveSlot; - break; - case STRINGID_PKMNIMMOBILIZEDBYLOVE: - if (structPtr->pos[atkSide][atkFlank].attractMonId != 0) - sub_817E684(9, 0, structPtr->pos[atkSide][atkFlank].attractMonId - 1, structPtr->pos[atkSide][atkFlank].attractMoveSlot); - break; - case STRINGID_PKMNWASPARALYZED: - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].prlzMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].prlzMoveSlot = moveSlot; - break; - case STRINGID_PKMNISPARALYZED: - if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].prlzMonId != 0) - sub_817E684(9, 2, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].prlzMonId - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].prlzMoveSlot); - break; - case STRINGID_PKMNFELLASLEEP: - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].slpMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].slpMoveSlot = moveSlot; - break; - case STRINGID_PKMNFASTASLEEP: - if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].slpMonId != 0 - && gStringInfo->currentMove != MOVE_SNORE - && gStringInfo->currentMove != MOVE_SLEEP_TALK) - sub_817E684(9, 3, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].slpMonId - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].slpMoveSlot); - break; - case STRINGID_PKMNWASFROZEN: - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].frzMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].frzMoveSlot = moveSlot; - break; - case STRINGID_PKMNISFROZEN: - if (structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].frzMonId != 0) - sub_817E684(9, 4, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].frzMonId - 1, structPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].frzMoveSlot); - break; - case STRINGID_PKMNWASCONFUSED: - structPtr->pos[effSide][effFlank].confusionMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->pos[effSide][effFlank].confusionMoveSlot = moveSlot; - break; - case STRINGID_ITHURTCONFUSION: - if (structPtr->pos[atkSide][atkFlank].confusionMonId != 0) - sub_817E684(9, 1, structPtr->pos[atkSide][atkFlank].confusionMonId - 1, structPtr->pos[atkSide][atkFlank].confusionMoveSlot); - structPtr->side[atkSide].field_3_0 = 12; - break; - case STRINGID_SPIKESSCATTERED: - structPtr->side[defSide].spikesMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[defSide].spikesMoveSlot = moveSlot; - break; - case STRINGID_PKMNHURTBYSPIKES: - if (structPtr->side[scriptingSide].spikesMonId != 0) - { - sub_817E684(10, scriptingSide ^ BIT_SIDE, structPtr->side[scriptingSide].spikesMonId - 1, structPtr->side[scriptingSide].spikesMoveSlot); - structPtr->side[scriptingSide].field_3_0 = 7; - } - break; - case STRINGID_PKMNBLEWAWAYSPIKES: - structPtr->side[atkSide].spikesMonId = 0; - structPtr->side[atkSide].spikesMoveSlot = 0; - break; - case STRINGID_FIREWEAKENED: - structPtr->pos[atkSide][atkFlank].waterSportMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->pos[atkSide][atkFlank].waterSportMoveSlot = moveSlot; - break; - case STRINGID_ELECTRICITYWEAKENED: - structPtr->pos[atkSide][atkFlank].mudSportMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->pos[atkSide][atkFlank].mudSportMoveSlot = moveSlot; - break; - case STRINGID_ATTACKERFAINTED: - sub_817EA80(0); - case STRINGID_RETURNMON: - if (structPtr->pos[atkSide][atkFlank].waterSportMonId != 0) - { - structPtr->pos[atkSide][atkFlank].waterSportMonId = 0; - structPtr->pos[atkSide][atkFlank].waterSportMoveSlot = 0; - } - if (structPtr->pos[atkSide][atkFlank].mudSportMonId != 0) - { - structPtr->pos[atkSide][atkFlank].mudSportMonId = 0; - structPtr->pos[atkSide][atkFlank].mudSportMoveSlot = 0; - } - break; - case STRINGID_TARGETFAINTED: - sub_817EA80(1); - if (structPtr->pos[atkSide][defFlank].waterSportMonId != 0) - { - structPtr->pos[atkSide][defFlank].waterSportMonId = 0; - structPtr->pos[atkSide][defFlank].waterSportMoveSlot = 0; - } - if (structPtr->pos[atkSide][defFlank].mudSportMonId != 0) - { - structPtr->pos[atkSide][defFlank].mudSportMonId = 0; - structPtr->pos[atkSide][defFlank].mudSportMoveSlot = 0; - } - break; - case STRINGID_PKMNRAISEDDEF: - case STRINGID_PKMNRAISEDDEFALITTLE: - structPtr->side[atkSide].reflectMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[atkSide].reflectMoveSlot = moveSlot; - break; - case STRINGID_PKMNRAISEDSPDEF: - case STRINGID_PKMNRAISEDSPDEFALITTLE: - structPtr->side[atkSide].lightScreenMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[atkSide].lightScreenMoveSlot = moveSlot; - break; - case STRINGID_PKMNSXWOREOFF: - if (*finishedMoveId == MOVE_REFLECT) - { - structPtr->side[atkSide].reflectMonId = 0; - structPtr->side[atkSide].reflectMoveSlot = 0; - } - if (*finishedMoveId == MOVE_LIGHT_SCREEN) - { - structPtr->side[atkSide].lightScreenMonId = 0; - structPtr->side[atkSide].lightScreenMoveSlot = 0; - } - if (*finishedMoveId == MOVE_MIST) - { - structPtr->side[atkSide].mistMonId = 0; - structPtr->side[atkSide].mistMoveSlot = 0; - } - break; - case STRINGID_PKMNCOVEREDBYVEIL: - structPtr->side[atkSide].safeguardMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[atkSide].safeguardMoveSlot = moveSlot; - break; - case STRINGID_PKMNUSEDSAFEGUARD: - if (structPtr->side[defSide].safeguardMonId != 0) - sub_817E684(15, 0, structPtr->side[defSide].safeguardMonId - 1, structPtr->side[defSide].safeguardMoveSlot); - break; - case STRINGID_PKMNSAFEGUARDEXPIRED: - structPtr->side[atkSide].safeguardMonId = 0; - structPtr->side[atkSide].safeguardMoveSlot = 0; - break; - case STRINGID_PKMNSHROUDEDINMIST: - structPtr->side[atkSide].mistMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[atkSide].mistMoveSlot = moveSlot; - break; - case STRINGID_PKMNPROTECTEDBYMIST: - if (structPtr->side[defSide].mistMonId != 0) - sub_817E684(16, 0, structPtr->side[defSide].mistMonId - 1, structPtr->side[defSide].mistMoveSlot); - break; - case STRINGID_THEWALLSHATTERED: - structPtr->side[defSide].reflectMonId = 0; - structPtr->side[defSide].reflectMoveSlot = 0; - structPtr->side[defSide].lightScreenMonId = 0; - structPtr->side[defSide].lightScreenMoveSlot = 0; - sub_817E684(17, 0, gBattlerPartyIndexes[gBattlerAttacker], moveSlot); - break; - case STRINGID_PKMNFLINCHED: - if (structPtr->pos[atkSide][0].field_5_5 != 0) - sub_817E684(21, 0, structPtr->pos[atkSide][0].field_5_5 - 1, structPtr->pos[atkSide][0].field_6_0); - if (structPtr->pos[atkSide][1].field_5_5 != 0) - sub_817E684(21, 0, structPtr->pos[atkSide][1].field_5_5 - 1, structPtr->pos[atkSide][1].field_6_0); - break; - case STRINGID_PKMNCRASHED: - case STRINGID_PKMNHITWITHRECOIL: - structPtr->side[atkSide].field_3_0 = 14; - break; - } -} - -bool8 sub_817E0B8(u16 stringId) -{ - s32 i = 0; - - while (1) - { - if (gUnknown_0860A8A4[i] == stringId) - break; - i++; - if (gUnknown_0860A8A4[i] == 0xFFFF) - break; - } - - if (gUnknown_0860A8A4[i] == 0xFFFF) - return TRUE; - else - return FALSE; -} - -void sub_817E0FC(u16 move, u16 weatherFlags, struct DisableStruct *disableStructPtr) -{ - struct UnknownBattleLinkStruct *structPtr; - u32 atkSide, defSide; - u8 moveSlot; - - if (!(gBattleTypeFlags & BATTLE_TYPE_LINK)) - return; - - structPtr = &gBattleStruct->field_204; - - atkSide = GetBattlerSide(gBattlerAttacker); - defSide = GetBattlerSide(gBattlerTarget); - moveSlot = GetBattlerMoveSlotId(gBattlerAttacker, move); - - if (moveSlot >= 4) - { - structPtr->side[atkSide].field_3_0 = 15; - return; - } - - structPtr->pos[defSide][GetBattlerPosition(gBattlerAttacker) / 2].field_5_5 = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->pos[defSide][GetBattlerPosition(gBattlerAttacker) / 2].field_6_0 = moveSlot; - structPtr->side[atkSide].field_8_6 = moveSlot; - sub_817E684(0, moveSlot, gBattleMoves[move].effect, 0); - sub_817F394(weatherFlags, move, moveSlot); - if (disableStructPtr->chargeTimer1 != 0) - sub_817E684(7, move, moveSlot, 0); - - if (move == MOVE_WISH) - { - structPtr->side[atkSide].wishMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[atkSide].wishMoveSlot = moveSlot; - } - if (move == MOVE_SELF_DESTRUCT || move == MOVE_EXPLOSION) - { - structPtr->side[atkSide ^ BIT_SIDE].explosionMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; - structPtr->side[atkSide ^ BIT_SIDE].explosionMoveSlot = moveSlot; - structPtr->side[atkSide ^ BIT_SIDE].field_3_0 = 13; - structPtr->side[atkSide ^ BIT_SIDE].explosion = 1; - } - - sub_817E684(13, gBattleMoves[move].type, gBattleMoves[move].power, 0); - sub_817E684(14, gBattleMoves[move].type, gBattleMoves[move].power, 0); - sub_817E684(11, gBattleMoves[move].type, 0, 0); - sub_817E684(12, gBattleMoves[move].type, 0, 0); -} - -void sub_817E32C(u8 animationId) -{ - struct UnknownBattleLinkStruct *structPtr; - u32 atkSide; - - if (!(gBattleTypeFlags & BATTLE_TYPE_LINK)) - return; - - structPtr = &gBattleStruct->field_204; - atkSide = GetBattlerSide(gBattlerAttacker); - switch (animationId) - { - case B_ANIM_FUTURE_SIGHT_HIT: - if (structPtr->side[atkSide].futureSightMonId != 0) - { - sub_817E684(2, 0, atkSide, - (structPtr->side[atkSide].futureSightMonId - 1) * 4 + structPtr->side[atkSide].futureSightMoveSlot); - structPtr->side[atkSide].field_3_0 = 8; - } - break; - case B_ANIM_DOOM_DESIRE_HIT: - if (structPtr->side[atkSide].doomDesireMonId != 0) - { - sub_817E684(2, 1, atkSide, - (structPtr->side[atkSide].doomDesireMonId - 1) * 4 + structPtr->side[atkSide].doomDesireMoveSlot); - structPtr->side[atkSide].field_3_0 = 9; - } - break; - } -} - -#ifdef NONMATCHING -// for loop has an unused stack variable -void sub_817E3F4(void) -{ - u16 playerBestSpecies = 0, opponentBestSpecies = 0; - s16 playerBestSum = 0, opponentBestSum = SHRT_MAX; - u8 playerBestMonId = 0, opponentBestMonId = 0; - struct UnknownBattleLinkArrayStruct *array = NULL; - u8 countPlayer = 0, countOpponent = 0; - s16 sum = 0; - u16 species = 0; - u16 moveId = 0; - s32 i, j; - - if (gBattleStruct->field_B3) - return; - - array = &gBattleStruct->field_1A4; - for (i = 0; i < PARTY_SIZE; i++) - { - if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL) != SPECIES_NONE) - countPlayer++; - if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES, NULL) != SPECIES_NONE) - countOpponent++; - } - - if (!(gBattleTypeFlags & BATTLE_TYPE_LINK) || countPlayer != countOpponent) - return; - - for (i = 0; i < PARTY_SIZE; i++) - { - species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL); - if (species != SPECIES_NONE && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG, NULL)) - { - for (sum = 0, j = 0; j < 4; j++) - sum += array->unk0[0][i * 4 + j]; - - if (playerBestSum < sum) - { - playerBestMonId = i; - playerBestSum = sum; - playerBestSpecies = species; - } - } - - species = GetMonData(&gEnemyParty[i], MON_DATA_SPECIES, NULL); - if (species != SPECIES_NONE && !GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG, NULL)) - { - s32 id = 1; - for (sum = 0, j = 0; j < 4; j++) - sum += array->unk0[id][i * 4 + j]; - - if (opponentBestSum == sum) - { - if (GetMonData(&gEnemyParty[i], MON_DATA_EXP, NULL) > GetMonData(&gEnemyParty[opponentBestMonId], MON_DATA_EXP, NULL)) - { - opponentBestMonId = i; - opponentBestSum = sum; - opponentBestSpecies = species; - } - } - else if (opponentBestSum > sum) - { - opponentBestMonId = i; - opponentBestSum = sum; - opponentBestSpecies = species; - } - } - } - - for (sum = 0, i = 0, j = 0; j < 4; j++) - { - if (sum < array->unk0[0][playerBestMonId * 4 + j]) - { - sum = array->unk0[0][playerBestMonId * 4 + j]; - i = j; - } - } - - moveId = GetMonData(&gPlayerParty[playerBestMonId], MON_DATA_MOVE1 + i, NULL); - if (playerBestSum == 0 || moveId == 0) - return; - - if (gBattleTypeFlags & BATTLE_TYPE_MULTI) - { - if ((playerBestMonId < 3 && !sub_806D82C(gBattleScripting.multiplayerId)) - || (playerBestMonId >= 3 && sub_806D82C(gBattleScripting.multiplayerId))) - { - j = (opponentBestMonId < 3) ? 0 : 1; - PutBattleUpdateOnTheAir(sub_806EF84(j, gBattleScripting.multiplayerId), moveId, playerBestSpecies, opponentBestSpecies); - } - } - else - { - PutBattleUpdateOnTheAir(gBattleScripting.multiplayerId ^ 1, moveId, playerBestSpecies, opponentBestSpecies); - } -} - -#else -ASM_DIRECT -void sub_817E3F4(void) -{ - asm_unified( - "push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0x20\n\ - movs r0, 0\n\ - str r0, [sp]\n\ - movs r1, 0\n\ - str r1, [sp, 0x4]\n\ - movs r2, 0\n\ - str r2, [sp, 0x8]\n\ - ldr r3, =0x00007fff\n\ - str r3, [sp, 0xC]\n\ - movs r4, 0\n\ - str r4, [sp, 0x10]\n\ - movs r7, 0\n\ - str r7, [sp, 0x14]\n\ - mov r8, r0\n\ - ldr r0, =gBattleStruct\n\ - ldr r1, [r0]\n\ - adds r0, r1, 0\n\ - adds r0, 0xB3\n\ - ldrb r0, [r0]\n\ - cmp r0, 0\n\ - beq _0817E42A\n\ - b _0817E670\n\ -_0817E42A:\n\ - movs r2, 0xD2\n\ - lsls r2, 1\n\ - adds r2, r1\n\ - mov r10, r2\n\ - movs r6, 0\n\ -_0817E434:\n\ - movs r0, 0x64\n\ - adds r4, r6, 0\n\ - muls r4, r0\n\ - ldr r0, =gPlayerParty\n\ - adds r0, r4, r0\n\ - movs r1, 0xB\n\ - movs r2, 0\n\ - bl GetMonData\n\ - cmp r0, 0\n\ - beq _0817E454\n\ - mov r0, r8\n\ - adds r0, 0x1\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - mov r8, r0\n\ -_0817E454:\n\ - ldr r5, =gEnemyParty\n\ - adds r0, r4, r5\n\ - movs r1, 0xB\n\ - movs r2, 0\n\ - bl GetMonData\n\ - cmp r0, 0\n\ - beq _0817E46A\n\ - adds r0, r7, 0x1\n\ - lsls r0, 24\n\ - lsrs r7, r0, 24\n\ -_0817E46A:\n\ - adds r6, 0x1\n\ - cmp r6, 0x5\n\ - ble _0817E434\n\ - ldr r0, =gBattleTypeFlags\n\ - ldr r0, [r0]\n\ - movs r1, 0x2\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - bne _0817E47E\n\ - b _0817E670\n\ -_0817E47E:\n\ - cmp r8, r7\n\ - beq _0817E484\n\ - b _0817E670\n\ -_0817E484:\n\ - movs r6, 0\n\ - lsls r3, r6, 1\n\ - str r3, [sp, 0x18]\n\ - movs r4, 0x64\n\ - mov r8, r4\n\ -_0817E48E:\n\ - mov r1, r8\n\ - muls r1, r6\n\ - ldr r0, =gPlayerParty\n\ - adds r4, r1, r0\n\ - adds r0, r4, 0\n\ - movs r1, 0xB\n\ - movs r2, 0\n\ - bl GetMonData\n\ - lsls r0, 16\n\ - lsrs r7, r0, 16\n\ - adds r0, r6, 0x1\n\ - mov r9, r0\n\ - cmp r7, 0\n\ - beq _0817E4EE\n\ - adds r0, r4, 0\n\ - movs r1, 0x2D\n\ - movs r2, 0\n\ - bl GetMonData\n\ - cmp r0, 0\n\ - bne _0817E4EE\n\ - movs r4, 0\n\ - lsls r0, r6, 3\n\ - mov r2, r10\n\ - adds r1, r0, r2\n\ - movs r3, 0x3\n\ -_0817E4C4:\n\ - lsls r0, r4, 16\n\ - asrs r0, 16\n\ - ldrh r4, [r1]\n\ - adds r0, r4\n\ - lsls r0, 16\n\ - lsrs r4, r0, 16\n\ - adds r1, 0x2\n\ - subs r3, 0x1\n\ - cmp r3, 0\n\ - bge _0817E4C4\n\ - ldr r1, [sp, 0x8]\n\ - lsls r0, r1, 16\n\ - lsls r1, r4, 16\n\ - cmp r0, r1\n\ - bge _0817E4EE\n\ - lsls r0, r6, 24\n\ - lsrs r0, 24\n\ - str r0, [sp, 0x10]\n\ - lsrs r1, 16\n\ - str r1, [sp, 0x8]\n\ - str r7, [sp]\n\ -_0817E4EE:\n\ - mov r0, r8\n\ - muls r0, r6\n\ - ldr r2, =gEnemyParty\n\ - adds r4, r0, r2\n\ - adds r0, r4, 0\n\ - movs r1, 0xB\n\ - movs r2, 0\n\ - bl GetMonData\n\ - lsls r0, 16\n\ - lsrs r7, r0, 16\n\ - ldr r3, [sp, 0x8]\n\ - lsls r3, 16\n\ - str r3, [sp, 0x1C]\n\ - cmp r7, 0\n\ - beq _0817E5A0\n\ - adds r0, r4, 0\n\ - movs r1, 0x2D\n\ - movs r2, 0\n\ - bl GetMonData\n\ - cmp r0, 0\n\ - bne _0817E5A0\n\ - movs r4, 0\n\ - ldr r0, [sp, 0xC]\n\ - lsls r2, r0, 16\n\ - movs r3, 0x1\n\ - lsls r1, r3, 1\n\ - adds r1, 0x1\n\ - lsls r1, 4\n\ - lsls r0, r6, 3\n\ - adds r0, r1\n\ - mov r3, r10\n\ - adds r1, r0, r3\n\ - movs r3, 0x3\n\ -_0817E534:\n\ - lsls r0, r4, 16\n\ - asrs r0, 16\n\ - ldrh r4, [r1]\n\ - adds r0, r4\n\ - lsls r0, 16\n\ - lsrs r4, r0, 16\n\ - adds r1, 0x2\n\ - subs r3, 0x1\n\ - cmp r3, 0\n\ - bge _0817E534\n\ - asrs r1, r2, 16\n\ - lsls r5, r4, 16\n\ - asrs r0, r5, 16\n\ - cmp r1, r0\n\ - bne _0817E590\n\ - mov r0, r8\n\ - muls r0, r6\n\ - ldr r1, =gEnemyParty\n\ - adds r0, r1\n\ - movs r1, 0x19\n\ - movs r2, 0\n\ - bl GetMonData\n\ - adds r4, r0, 0\n\ - ldr r2, [sp, 0x14]\n\ - mov r0, r8\n\ - muls r0, r2\n\ - ldr r3, =gEnemyParty\n\ - adds r0, r3\n\ - movs r1, 0x19\n\ - movs r2, 0\n\ - bl GetMonData\n\ - cmp r4, r0\n\ - bls _0817E5A0\n\ - b _0817E594\n\ - .pool\n\ -_0817E590:\n\ - cmp r1, r0\n\ - ble _0817E5A0\n\ -_0817E594:\n\ - lsls r0, r6, 24\n\ - lsrs r0, 24\n\ - str r0, [sp, 0x14]\n\ - lsrs r5, 16\n\ - str r5, [sp, 0xC]\n\ - str r7, [sp, 0x4]\n\ -_0817E5A0:\n\ - mov r6, r9\n\ - cmp r6, 0x5\n\ - bgt _0817E5A8\n\ - b _0817E48E\n\ -_0817E5A8:\n\ - movs r4, 0\n\ - movs r6, 0\n\ - movs r3, 0\n\ - ldr r5, =gPlayerParty\n\ - ldr r7, [sp, 0x10]\n\ - lsls r0, r7, 3\n\ - mov r1, r10\n\ - adds r2, r0, r1\n\ -_0817E5B8:\n\ - lsls r0, r4, 16\n\ - asrs r0, 16\n\ - movs r7, 0\n\ - ldrsh r1, [r2, r7]\n\ - cmp r0, r1\n\ - bge _0817E5C8\n\ - ldrh r4, [r2]\n\ - adds r6, r3, 0\n\ -_0817E5C8:\n\ - adds r2, 0x2\n\ - adds r3, 0x1\n\ - cmp r3, 0x3\n\ - ble _0817E5B8\n\ - movs r0, 0x64\n\ - ldr r1, [sp, 0x10]\n\ - muls r0, r1\n\ - adds r0, r5\n\ - adds r1, r6, 0\n\ - adds r1, 0xD\n\ - movs r2, 0\n\ - bl GetMonData\n\ - lsls r0, 16\n\ - lsrs r4, r0, 16\n\ - ldr r2, [sp, 0x1C]\n\ - cmp r2, 0\n\ - beq _0817E670\n\ - cmp r4, 0\n\ - beq _0817E670\n\ - ldr r0, =gBattleTypeFlags\n\ - ldr r0, [r0]\n\ - movs r1, 0x40\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _0817E65C\n\ - ldr r3, [sp, 0x10]\n\ - cmp r3, 0x2\n\ - bhi _0817E620\n\ - ldr r0, =gBattleScripting\n\ - adds r0, 0x25\n\ - ldrb r0, [r0]\n\ - bl sub_806D82C\n\ - lsls r0, 16\n\ - cmp r0, 0\n\ - beq _0817E630\n\ - b _0817E670\n\ - .pool\n\ -_0817E620:\n\ - ldr r0, =gBattleScripting\n\ - adds r0, 0x25\n\ - ldrb r0, [r0]\n\ - bl sub_806D82C\n\ - lsls r0, 16\n\ - cmp r0, 0\n\ - beq _0817E670\n\ -_0817E630:\n\ - movs r3, 0\n\ - ldr r7, [sp, 0x14]\n\ - cmp r7, 0x2\n\ - bls _0817E63A\n\ - movs r3, 0x1\n\ -_0817E63A:\n\ - lsls r0, r3, 24\n\ - lsrs r0, 24\n\ - ldr r1, =gBattleScripting\n\ - adds r1, 0x25\n\ - ldrb r1, [r1]\n\ - bl sub_806EF84\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - adds r1, r4, 0\n\ - ldr r2, [sp]\n\ - ldr r3, [sp, 0x4]\n\ - bl PutBattleUpdateOnTheAir\n\ - b _0817E670\n\ - .pool\n\ -_0817E65C:\n\ - ldr r0, =gBattleScripting\n\ - adds r0, 0x25\n\ - ldrb r1, [r0]\n\ - movs r0, 0x1\n\ - eors r0, r1\n\ - adds r1, r4, 0\n\ - ldr r2, [sp]\n\ - ldr r3, [sp, 0x4]\n\ - bl PutBattleUpdateOnTheAir\n\ -_0817E670:\n\ - add sp, 0x20\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool"); -} -#endif - -void sub_817E684(u8 caseId, u16 arg1, u8 arg2, u8 arg3) -{ - struct UnknownBattleLinkArrayStruct *array = &gBattleStruct->field_1A4; - struct UnknownBattleLinkStruct *structPtr = &gBattleStruct->field_204; - u32 atkSide = GetBattlerSide(gBattlerAttacker); - u32 defSide = GetBattlerSide(gBattlerTarget); - const u16 *ptr; - s32 i; - - switch (caseId) - { - case 0: - case 1: - case 18: - case 22 ... 27: - array->unk0[atkSide][gBattlerPartyIndexes[gBattlerAttacker] * 4 + arg1] += gUnknown_0860A834[caseId][arg2]; - break; - case 3 ... 7: - i = 0; - ptr = gUnknown_0860A834[caseId]; - do - { - if (arg1 == ptr[i]) - { - array->unk0[atkSide][gBattlerPartyIndexes[gBattlerAttacker] * 4 + arg2] += ptr[i+1]; - break; - } - i += 2; - } while (ptr[i] != 0xFFFF); - break; - case 19: - structPtr->side[arg2 ^ 1].field_3_0 = 0; - array->unk0[arg2][0 * 4 + arg3] += gUnknown_0860A834[caseId][arg1]; - break; - case 20: - structPtr->side[arg2].field_3_0 = 0; - case 2: - array->unk0[arg2][0 * 4 + arg3] += gUnknown_0860A834[caseId][arg1]; - break; - case 17: - array->unk0[atkSide][arg2 * 4 + arg3] += gUnknown_0860A834[caseId][arg1]; - break; - case 8: - case 9: - case 15: - case 16: - case 21: - array->unk0[atkSide ^ BIT_SIDE][arg2 * 4 + arg3] += gUnknown_0860A834[caseId][arg1]; - break; - case 10: - array->unk0[arg1][arg2 * 4 + arg3] += gUnknown_0860A834[caseId][0]; - break; - case 11: - if (structPtr->pos[defSide][0].waterSportMonId != -(structPtr->pos[defSide][1].waterSportMonId) && arg1 == 10) - { - if (structPtr->pos[defSide][0].waterSportMonId != 0) - { - u32 id = (structPtr->pos[defSide][0].waterSportMonId - 1) * 4; - array->unk0[defSide][id + structPtr->pos[defSide][0].waterSportMoveSlot] += gUnknown_0860A834[caseId][0]; - } - if (structPtr->pos[defSide][1].waterSportMonId != 0) - { - u32 id = (structPtr->pos[defSide][1].waterSportMonId - 1) * 4; - array->unk0[defSide][id + structPtr->pos[defSide][1].waterSportMoveSlot] += gUnknown_0860A834[caseId][0]; - } - } - break; - case 12: - if (structPtr->pos[defSide][0].mudSportMonId != -(structPtr->pos[defSide][1].mudSportMonId) && arg1 == 13) - { - if (structPtr->pos[defSide][0].mudSportMonId != 0) - { - u32 id = (structPtr->pos[defSide][0].mudSportMonId - 1) * 4; - array->unk0[defSide][id + structPtr->pos[defSide][0].mudSportMoveSlot] += gUnknown_0860A834[caseId][0]; - } - if (structPtr->pos[defSide][1].mudSportMonId != 0) - { - u32 id = (structPtr->pos[defSide][1].mudSportMonId - 1) * 4; - array->unk0[defSide][id + structPtr->pos[defSide][1].mudSportMoveSlot] += gUnknown_0860A834[caseId][0]; - } - } - break; - case 13: - if (arg1 <= 8 && arg2 != 0 && structPtr->side[defSide].reflectMonId != 0) - { - u32 id = (structPtr->side[defSide].reflectMonId - 1) * 4; - array->unk0[defSide][id + structPtr->side[defSide].reflectMoveSlot] += gUnknown_0860A834[caseId][0]; - } - break; - case 14: - if (arg1 > 8 && arg2 != 0 && structPtr->side[defSide].lightScreenMonId != 0) - { - u32 id = (structPtr->side[defSide].lightScreenMonId - 1) * 4; - array->unk0[defSide][id + structPtr->side[defSide].lightScreenMoveSlot] += gUnknown_0860A834[caseId][0]; - } - break; - break; - } -} - -void sub_817EA80(u8 arg0) -{ - struct UnknownBattleLinkStruct *structPtr = &gBattleStruct->field_204; - u32 atkSide = GetBattlerSide(gBattlerAttacker); - u32 defSide = GetBattlerSide(gBattlerTarget); - u32 atkArrId = structPtr->side[atkSide].field_3_1; - s32 i; - - if (structPtr->side[atkSide].field_3_0 != 0) - { - switch (structPtr->side[atkSide].field_3_0) - { - case 1: - if (structPtr->pos[atkSide][atkArrId].curseMonId != 0) - { - sub_817E684(19, 0, atkSide ^ BIT_SIDE, - (structPtr->pos[atkSide][atkArrId].curseMonId - 1) * 4 + structPtr->pos[atkSide][atkArrId].curseMoveSlot); - } - break; - case 2: - if (structPtr->pos[atkSide][atkArrId].leechSeedMonId != 0) - { - sub_817E684(19, 0, atkSide ^ BIT_SIDE, - (structPtr->pos[atkSide][atkArrId].leechSeedMonId - 1) * 4 + structPtr->pos[atkSide][atkArrId].leechSeedMoveSlot); - } - break; - case 3: - if (structPtr->mon[atkSide][atkArrId].psnMonId != 0) - { - sub_817E684(19, 0, atkSide ^ BIT_SIDE, - (structPtr->mon[atkSide][atkArrId].psnMonId - 1) * 4 + structPtr->mon[atkSide][atkArrId].psnMoveSlot); - } - if (structPtr->mon[atkSide][atkArrId].badPsnMonId != 0) - { - sub_817E684(19, 0, atkSide ^ BIT_SIDE, - (structPtr->mon[atkSide][atkArrId].badPsnMonId - 1) * 4 + structPtr->mon[atkSide][atkArrId].badPsnMoveSlot); - } - break; - case 4: - if (structPtr->mon[atkSide][atkArrId].brnMonId != 0) - { - sub_817E684(19, 0, atkSide ^ BIT_SIDE, - (structPtr->mon[atkSide][atkArrId].brnMonId - 1) * 4 + structPtr->mon[atkSide][atkArrId].brnMoveSlot); - } - break; - case 5: - if (structPtr->pos[atkSide][atkArrId].nightmareMonId != 0) - { - sub_817E684(19, 0, atkSide ^ BIT_SIDE, - (structPtr->pos[atkSide][atkArrId].nightmareMonId - 1) * 4 + structPtr->pos[atkSide][atkArrId].nightmareMoveSlot); - } - break; - case 6: - if (structPtr->pos[atkSide][atkArrId].wrapMonId != 0) - { - sub_817E684(19, 0, atkSide ^ BIT_SIDE, - (structPtr->pos[atkSide][atkArrId].wrapMonId - 1) * 4 + structPtr->pos[atkSide][atkArrId].wrapMoveSlot); - } - break; - case 7: - if (structPtr->side[atkSide].spikesMonId != 0) - { - sub_817E684(19, 0, atkSide ^ BIT_SIDE, - (structPtr->side[atkSide].spikesMonId - 1) * 4 + structPtr->side[atkSide].spikesMoveSlot); - } - break; - case 8: - if (structPtr->side[atkSide].futureSightMonId != 0) - { - sub_817E684(20, 0, atkSide, - (structPtr->side[atkSide].futureSightMonId - 1) * 4 + structPtr->side[atkSide].futureSightMoveSlot); - } - break; - case 9: - if (structPtr->side[atkSide].doomDesireMonId != 0) - { - sub_817E684(20, 0, atkSide, - (structPtr->side[atkSide].doomDesireMonId - 1) * 4 + structPtr->side[atkSide].doomDesireMoveSlot); - } - break; - case 10: - if (structPtr->side[atkSide].perishSong - && structPtr->side[atkSide].perishSongMonId - 1 != gBattlerPartyIndexes[gBattlerAttacker]) - { - sub_817E684(19, 0, atkSide, - (structPtr->side[atkSide].perishSongMonId - 1) * 4 + structPtr->side[atkSide].perishSongMoveSlot); - } - if (structPtr->side[atkSide ^ BIT_SIDE].perishSong) - { - sub_817E684(19, 0, atkSide ^ BIT_SIDE, - (structPtr->side[atkSide ^ BIT_SIDE].perishSongMonId - 1) * 4 + structPtr->side[atkSide ^ BIT_SIDE].perishSongMoveSlot); - } - break; - case 11: - if (structPtr->side[atkSide ^ BIT_SIDE].destinyBondMonId != 0) - { - sub_817E684(19, 0, atkSide ^ BIT_SIDE, - (structPtr->side[atkSide ^ BIT_SIDE].destinyBondMonId - 1) * 4 + structPtr->side[atkSide ^ BIT_SIDE].destinyBondMoveSlot); - } - break; - case 12: - for (i = 0; i < 2; i++) - { - if (structPtr->pos[atkSide][i].confusionMonId != 0) - { - sub_817E684(19, 0, atkSide ^ BIT_SIDE, - (structPtr->pos[atkSide][i].confusionMonId - 1) * 4 + structPtr->pos[atkSide][i].confusionMoveSlot); - } - } - break; - case 13: - if (structPtr->side[atkSide].explosion) - { - sub_817E684(19, 0, atkSide, - (structPtr->side[atkSide].explosionMonId - 1) * 4 + structPtr->side[atkSide].explosionMoveSlot); - } - if (structPtr->side[atkSide ^ BIT_SIDE].explosion) - { - sub_817E684(19, 0, atkSide ^ BIT_SIDE, - (structPtr->side[atkSide ^ BIT_SIDE].explosionMonId - 1) * 4 + structPtr->side[atkSide ^ BIT_SIDE].explosionMoveSlot); - } - break; - case 14: - if (arg0 == 1) - { - sub_817E684(20, 0, atkSide, - (gBattlerPartyIndexes[gBattlerAttacker]) * 4 + structPtr->side[atkSide].field_8_6); - } - break; - case 15: - break; - } - } - else - { - if (structPtr->side[defSide].field_3_0 == 7) - { - if (structPtr->side[defSide].spikesMonId != 0) - { - sub_817E684(19, 0, defSide ^ BIT_SIDE, - (structPtr->side[defSide].spikesMonId - 1) * 4 + structPtr->side[defSide].spikesMoveSlot); - } - } - else - { - sub_817E684(20, 0, atkSide, - (gBattlerPartyIndexes[gBattlerAttacker]) * 4 + structPtr->side[atkSide].field_8_6); - } - } -} - -void sub_817EECC(void) -{ - s32 i; - s32 dmgByMove[4]; - u16 powerOverride; - u16 currMoveSaved; - - if (gBattleTypeFlags & (BATTLE_TYPE_DOUBLE | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) - return; - if (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT) - return; - if (gBattleMons[gBattlerAttacker].statStages[STAT_ACC] <= 5) - return; - if (gBattleMons[gBattlerTarget].statStages[STAT_EVASION] > 6) - return; - if (gCurrentMove == MOVE_HIDDEN_POWER || gCurrentMove == MOVE_WEATHER_BALL) - return; - if (gBattleTypeFlags & (BATTLE_TYPE_PALACE | BATTLE_TYPE_PIKE | BATTLE_TYPE_PYRAMID)) - return; - if (gBattleMoves[gBattleMons[gBattlerAttacker].moves[gMoveSelectionCursor[gBattlerAttacker]]].power == 0) - return; - - i = 0; - currMoveSaved = gBattleMons[gBattlerAttacker].moves[gMoveSelectionCursor[gBattlerAttacker]]; - while (1) - { - if (currMoveSaved == gUnknown_0860A4AC[i]) - break; - i++; - if (gUnknown_0860A4AC[i] == 0xFFFF) - break; - } - - if (gUnknown_0860A4AC[i] != 0xFFFF) - return; - - dmgByMove[gMoveSelectionCursor[gBattlerAttacker]] = gBattleMoveDamage; - currMoveSaved = gCurrentMove; - for (i = 0; i < 4; i++) - { - gCurrentMove = gBattleMons[gBattlerAttacker].moves[i]; - powerOverride = 0; - if (sub_817F21C(gCurrentMove, &dmgByMove[i], &powerOverride)) - { - u8 moveResultFlags; - u16 sideStatus = gSideStatuses[GET_BATTLER_SIDE(gBattlerTarget)]; - gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattlerAttacker], &gBattleMons[gBattlerTarget], gCurrentMove, - sideStatus, powerOverride, - 0, gBattlerAttacker, gBattlerTarget); - - if (gStatuses3[gBattlerAttacker] & STATUS3_CHARGED_UP && gBattleMoves[gCurrentMove].type == TYPE_ELECTRIC) - gBattleMoveDamage *= 2; - if (gProtectStructs[gBattlerAttacker].helpingHand) - gBattleMoveDamage = gBattleMoveDamage * 15 / 10; - - moveResultFlags = TypeCalc(gCurrentMove, gBattlerAttacker, gBattlerTarget); - dmgByMove[i] = gBattleMoveDamage; - if (dmgByMove[i] == 0 && !(moveResultFlags & MOVE_RESULT_NO_EFFECT)) - dmgByMove[i] = 1; - } - } - - for (i = 0; i < 4; i++) - { - if (i != gMoveSelectionCursor[gBattlerAttacker] && dmgByMove[i] > dmgByMove[gMoveSelectionCursor[gBattlerAttacker]]) - { - u16 opponentSpecies, playerSpecies; - s32 bestMoveId; - - if (gMoveSelectionCursor[gBattlerAttacker] != 0) - bestMoveId = 0; - else - bestMoveId = 1; - - for (i = 0; i < 4; i++) - { - if (i != gMoveSelectionCursor[gBattlerAttacker] && dmgByMove[i] > dmgByMove[bestMoveId]) - bestMoveId = i; - } - - opponentSpecies = GetMonData(&gEnemyParty [gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_SPECIES, NULL); - playerSpecies = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_SPECIES, NULL); - sub_80EE35C(opponentSpecies, playerSpecies, gMoveSelectionCursor[gBattlerAttacker], gBattleMons[gBattlerAttacker].moves, gBattleMons[gBattlerAttacker].moves[bestMoveId]); - break; - } - } - - gBattleMoveDamage = dmgByMove[gMoveSelectionCursor[gBattlerAttacker]]; - gCurrentMove = currMoveSaved; -} diff --git a/src/battle_tv.c b/src/battle_tv.c new file mode 100644 index 000000000..bd3de548b --- /dev/null +++ b/src/battle_tv.c @@ -0,0 +1,1585 @@ +#include "global.h" +#include "pokemon.h" +#include "battle.h" +#include "battle_tv.h" +#include "constants/battle_string_ids.h" +#include "constants/battle_anim.h" +#include "constants/moves.h" +#include "constants/species.h" +#include "battle_message.h" +#include "tv.h" + +extern struct StringInfoBattle *gStringInfo; + +extern const struct BattleMove gBattleMoves[]; + +// this file's functions +static bool8 sub_817E0B8(u16 stringId); +static void AddMovePoints(u8 caseId, u16 arg1, u8 arg2, u8 arg3); +static void TrySetBattleSeminarShow(void); +static void AddPointsOnFainting(bool8 targetFainted); +static void AddPointsBasedOnWeather(u16 weatherFlags, u16 moveId, u8 moveSlot); +static bool8 ShouldCalculateDamage(u16 moveId, s32 *dmg, u16 *powerOverride); + +// const rom data +static const u16 sVariableDmgMoves[] = +{ + MOVE_COUNTER, MOVE_FISSURE, MOVE_BIDE, MOVE_MIRROR_COAT, + MOVE_HORN_DRILL, MOVE_FLAIL, MOVE_REVERSAL, MOVE_HIDDEN_POWER, + MOVE_SHEER_COLD, MOVE_FOCUS_PUNCH, MOVE_ERUPTION, + MOVE_WATER_SPOUT, MOVE_DREAM_EATER, MOVE_WEATHER_BALL, + MOVE_SNORE, MOVE_PAIN_SPLIT, MOVE_GUILLOTINE, + MOVE_FRUSTRATION, MOVE_RETURN, MOVE_ENDEAVOR, + MOVE_PRESENT, MOVE_REVENGE, 0xFFFF, + // those are handled by the function itself + MOVE_MAGNITUDE, MOVE_PSYWAVE, 0xFFFF +}; + +static const u16 sUnknown_0860A4E0[] = +{ + 0x0001, 0x0001, 0x0001, 0x0004, 0x0001, 0x0001, 0x0001, 0x0000, 0x0005, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, + 0x0001, 0x0002, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0005, 0x0005, 0x0004, 0x0005, 0x0001, 0x0003, 0x0001, + 0x0003, 0x0005, 0x0001, 0x0007, 0x0001, 0x0007, 0x0007, 0x0001, 0x0005, 0x0002, 0x0004, 0x0001, 0x0001, 0x0001, 0x0005, 0x0001, + 0x0002, 0x0004, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, + 0x0001, 0x0007, 0x0004, 0x0004, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0004, 0x0001, 0x0001, 0x0001, 0x0004, + 0x0005, 0x0002, 0x0004, 0x0001, 0x0004, 0x0001, 0x0007, 0x0002, 0x0001, 0x0005, 0x0007, 0x0003, 0x0003, 0x0004, 0x0003, 0x0003, + 0x0003, 0x0003, 0x0003, 0x0002, 0x0004, 0x0001, 0x0005, 0x0001, 0x0001, 0x0004, 0x0005, 0x0003, 0x0001, 0x0002, 0x0001, 0x0005, + 0x0004, 0x0003, 0x0006, 0x0004, 0x0003, 0x0003, 0x0003, 0x0002, 0x0004, 0x0001, 0x0001, 0x0001, 0x0005, 0x0001, 0x0001, 0x0007, + 0x0002, 0x0002, 0x0001, 0x0001, 0x0004, 0x0004, 0x0004, 0x0001, 0x0004, 0x0004, 0x0001, 0x0001, 0x0001, 0x0001, 0x0007, 0x0007, + 0x0006, 0x0003, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0002, 0x0003, 0x0001, 0x0001, 0x0004, 0x0004, + 0x0003, 0x0003, 0x0003, 0x0001, 0x0004, 0x0007, 0x0007, 0x0005, 0x0007, 0x0001, 0x0007, 0x0001, 0x0005, 0x0000, 0x0004, 0x0004, + 0x0004, 0x0004, 0x0004, 0x0002, 0x0002, 0x0006, 0x0003, 0x0006, 0x0004, 0x0004, 0x0002, 0x0005, 0x0002, 0x0001, 0x0001, 0x0006, + 0x0006, 0x0006, 0x0001, 0x0001, 0x0001, 0x0001, 0x0002, 0x0006, 0x0001, 0x0004, 0x0001, 0x0001, 0x0003, 0x0001, 0x0001, 0x0001, + 0x0001, 0x0001, 0x0004, 0x0001, 0x0001, 0x0003 +}; +static const u16 sUnknown_0860A68C[] = +{ + 0x0004, 0xfffd, 0xfffa +}; +static const u16 sUnknown_0860A692[] = +{ + 0x0004, 0x0004, 0x0006, 0x0006, 0x0007, 0x0006, 0x0002 +}; +static const u16 sUnknown_0860A6A0[] = +{ + 0x0091, 0x0003, 0x00fa, 0x0003, 0x00be, 0x0003, 0x0080, 0x0003, 0x006e, 0x0003, 0x0098, 0x0003, 0x0143, 0x0003, 0x0123, 0x0003, + 0x007f, 0x0003, 0x014a, 0x0003, 0x0039, 0x0003, 0x0134, 0x0003, 0x0038, 0x0003, 0x003d, 0x0003, 0x015a, 0x0000, 0x0037, 0x0003, + 0x0160, 0x0003, 0x0137, 0x0003, 0x0057, 0x0003, 0x004c, 0xfffc, 0x013b, 0xfffc, 0x00ac, 0xfffc, 0x0035, 0xfffc, 0x00dd, 0xfffc, + 0x007e, 0xfffc, 0x0101, 0xfffc, 0x0034, 0xfffc, 0x0133, 0xfffc, 0x012b, 0xfffc, 0x011c, 0xfffc, 0x0053, 0xfffc, 0x0007, 0xfffc, + 0x004c, 0xfffc, 0xffff, 0x0000 +}; +static const u16 sUnknown_0860A728[] = +{ + 0x013b, 0x0003, 0x00ac, 0x0003, 0x0035, 0x0003, 0x00dd, 0x0003, 0x007e, 0x0003, 0x0101, 0x0003, 0x0034, 0x0003, 0x0133, 0x0003, + 0x012b, 0x0003, 0x011c, 0x0003, 0x0053, 0x0003, 0x0007, 0x0003, 0x004c, 0x0005, 0x00eb, 0x0003, 0x00ea, 0x0003, 0x00ec, 0x0003, + 0x0137, 0x0003, 0xffff, 0x0000 +}; +static const u16 sUnknown_0860A770[] = +{ + 0x0137, 0x0003, 0x004c, 0xfffd, 0xffff, 0x0000 +}; +static const u16 sUnknown_0860A77C[] = +{ + 0x0137, 0x0003, 0x004c, 0xfffd, 0xffff, 0x0000 +}; +static const u16 sUnknown_0860A788[] = +{ + 0x0055, 0x0003, 0x0009, 0x0003, 0x00d1, 0x0003, 0x0054, 0x0003, 0x00c0, 0x0003, 0x015f, 0x0003, 0x0056, 0x0000, 0x0057, 0x0003, + 0x0158, 0x0003, 0xffff, 0x0000 +}; +static const u16 sUnknown_0860A7B0[] = +{ + 0x0005, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003 +}; +static const u16 sUnknown_0860A7BE[] = +{ + 0x0005, 0x0005, 0x0005, 0x0005, 0x0005 +}; +static const u16 sUnknown_0860A7C8[] = +{ + 0x0004 +}; +static const u16 sUnknown_0860A7CA[] = +{ + 0x0005 +}; +static const u16 sUnknown_0860A7CC[] = +{ + 0x0005 +}; +static const u16 sUnknown_0860A7CE[] = +{ + 0x0003 +}; +static const u16 sUnknown_0860A7D0[] = +{ + 0x0003 +}; +static const u16 sUnknown_0860A7D2[] = +{ + 0x0004 +}; +static const u16 sUnknown_0860A7D4[] = +{ + 0x0003 +}; +static const u16 sUnknown_0860A7D6[] = +{ + 0x0006 +}; +static const u16 sUnknown_0860A7D8[] = +{ + 0x0006 +}; +static const u16 sUnknown_0860A7DA[] = +{ + 0x0006 +}; +static const u16 sUnknown_0860A7DC[] = +{ + 0x0004 +}; +static const u16 sUnknown_0860A7DE[] = +{ + 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002 +}; +static const u16 sUnknown_0860A7EC[] = +{ + 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004 +}; +static const u16 sUnknown_0860A7FA[] = +{ + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff +}; +static const u16 sUnknown_0860A808[] = +{ + 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002 +}; +static const u16 sUnknown_0860A816[] = +{ + 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004 +}; +static const u16 sUnknown_0860A824[] = +{ + 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe +}; + +static const u16 *const sPointsArray[] = +{ + sUnknown_0860A4E0, + sUnknown_0860A68C, + sUnknown_0860A692, + sUnknown_0860A6A0, + sUnknown_0860A728, + sUnknown_0860A770, + sUnknown_0860A77C, + sUnknown_0860A788, + sUnknown_0860A7B0, + sUnknown_0860A7BE, + sUnknown_0860A7C8, + sUnknown_0860A7CA, + sUnknown_0860A7CC, + sUnknown_0860A7CE, + sUnknown_0860A7D0, + sUnknown_0860A7D2, + sUnknown_0860A7D4, + sUnknown_0860A7D6, + sUnknown_0860A7D8, + sUnknown_0860A7DA, + sUnknown_0860A7DA, + sUnknown_0860A7DC, + sUnknown_0860A7DE, + sUnknown_0860A7EC, + sUnknown_0860A7FA, + sUnknown_0860A808, + sUnknown_0860A816, + sUnknown_0860A824 +}; + +static const u16 sUnknown_0860A8A4[] = +{ + STRINGID_PKMNPERISHCOUNTFELL, STRINGID_PKMNWISHCAMETRUE, STRINGID_PKMNLOSTPPGRUDGE, + STRINGID_PKMNTOOKFOE, STRINGID_PKMNABSORBEDNUTRIENTS, STRINGID_PKMNANCHOREDITSELF, + STRINGID_PKMNAFFLICTEDBYCURSE, STRINGID_PKMNSAPPEDBYLEECHSEED, STRINGID_PKMNLOCKEDINNIGHTMARE, + STRINGID_PKMNHURTBY, STRINGID_PKMNHURTBYBURN, STRINGID_PKMNHURTBYPOISON, + STRINGID_PKMNHURTBYSPIKES, STRINGID_ATTACKERFAINTED, STRINGID_TARGETFAINTED, + STRINGID_PKMNHITWITHRECOIL, STRINGID_PKMNCRASHED, 0xFFFF +}; + +// code +void BattleTv_SetDataBasedOnString(u16 stringId) +{ + struct BattleTv *tvPtr; + u32 atkSide, defSide, effSide, scriptingSide; + struct Pokemon *atkMon, *defMon; + u8 moveSlot; + u32 atkFlank, defFlank, effFlank; + u8 *perishCount; + u16 *statStringId, *finishedMoveId; + + if (!(gBattleTypeFlags & BATTLE_TYPE_LINK) && stringId != STRINGID_ITDOESNTAFFECT && stringId != STRINGID_NOTVERYEFFECTIVE) + return; + + tvPtr = &gBattleStruct->tv; + + atkSide = GetBattlerSide(gBattlerAttacker); + defSide = GetBattlerSide(gBattlerTarget); + effSide = GetBattlerSide(gEffectBattler); + scriptingSide = GetBattlerSide(gStringInfo->scrActive); + + if (atkSide == B_SIDE_PLAYER) + atkMon = &gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]]; + else + atkMon = &gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker]]; + + if (defSide == B_SIDE_PLAYER) + defMon = &gPlayerParty[gBattlerPartyIndexes[gBattlerTarget]]; + else + defMon = &gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]]; + + moveSlot = GetBattlerMoveSlotId(gBattlerAttacker, gStringInfo->currentMove); + + if (moveSlot >= 4 && sub_817E0B8(stringId) && stringId > BATTLESTRINGS_ID_ADDER) + { + tvPtr->side[atkSide].faintCause = 15; + return; + } + + perishCount = (u8 *)(gBattleTextBuff1 + 4); + statStringId = (u16 *)(gBattleTextBuff2 + 2); + finishedMoveId = (u16 *)(gBattleTextBuff1 + 2); + + atkFlank = GetBattlerPosition(gBattlerAttacker) / 2; + defFlank = GetBattlerPosition(gBattlerTarget) / 2; + effFlank = GetBattlerPosition(gEffectBattler) / 2; + + switch (stringId) + { + case STRINGID_ITDOESNTAFFECT: + AddMovePoints(1, moveSlot, 2, 0); + if (!(gBattleTypeFlags & BATTLE_TYPE_LINK)) + TrySetBattleSeminarShow(); + break; + case STRINGID_NOTVERYEFFECTIVE: + AddMovePoints(1, moveSlot, 1, 0); + if (!(gBattleTypeFlags & BATTLE_TYPE_LINK) && GetMonData(defMon, MON_DATA_HP, NULL) != 0) + TrySetBattleSeminarShow(); + break; + case STRINGID_SUPEREFFECTIVE: + AddMovePoints(1, moveSlot, 0, 0); + break; + case STRINGID_PKMNFORESAWATTACK: + tvPtr->side[atkSide].futureSightMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->side[atkSide].futureSightMoveSlot = moveSlot; + break; + case STRINGID_PKMNCHOSEXASDESTINY: + tvPtr->side[atkSide].doomDesireMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->side[atkSide].doomDesireMoveSlot = moveSlot; + break; + case STRINGID_FAINTINTHREE: + tvPtr->side[atkSide].perishSongMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->side[atkSide].perishSongMoveSlot = moveSlot; + tvPtr->side[atkSide].perishSong = 1; + break; + case STRINGID_PKMNPERISHCOUNTFELL: + if (*perishCount == 0) + tvPtr->side[atkSide].faintCause = 10; + break; + case STRINGID_PKMNWISHCAMETRUE: + if (tvPtr->side[defSide].wishMonId != 0) + { + AddMovePoints(2, 3, defSide, + (tvPtr->side[defSide].wishMonId - 1) * 4 + tvPtr->side[defSide].wishMoveSlot); + } + break; + case STRINGID_PKMNWANTSGRUDGE: + tvPtr->side[atkSide].grudgeMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->side[atkSide].grudgeMoveSlot = moveSlot; + break; + case STRINGID_PKMNLOSTPPGRUDGE: + if (tvPtr->side[defSide].grudgeMonId != 0) + { + AddMovePoints(2, 4, defSide, + (tvPtr->side[defSide].grudgeMonId - 1) * 4 + tvPtr->side[defSide].grudgeMoveSlot); + } + break; + case STRINGID_PKMNTRYINGTOTAKEFOE: + tvPtr->side[atkSide].destinyBondMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->side[atkSide].destinyBondMoveSlot = moveSlot; + break; + case STRINGID_PKMNTOOKFOE: + if (tvPtr->side[defSide].destinyBondMonId != 0) + tvPtr->side[atkSide].faintCause = 11; + break; + case STRINGID_PKMNPLANTEDROOTS: + tvPtr->pos[atkSide][atkFlank].ingrainMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->pos[atkSide][atkFlank].ingrainMoveSlot = moveSlot; + break; + case STRINGID_PKMNABSORBEDNUTRIENTS: + if (tvPtr->pos[atkSide][atkFlank].ingrainMonId != 0) + { + AddMovePoints(2, 6, atkSide, + (tvPtr->pos[atkSide][atkFlank].ingrainMonId - 1) * 4 + tvPtr->pos[atkSide][atkFlank].ingrainMoveSlot); + } + break; + case STRINGID_PKMNANCHOREDITSELF: + if (tvPtr->pos[defSide][defFlank].ingrainMonId != 0) + { + AddMovePoints(2, 6, defSide, + (tvPtr->pos[defSide][defFlank].ingrainMonId - 1) * 4 + tvPtr->pos[defSide][defFlank].ingrainMoveSlot); + } + break; + case STRINGID_PKMNTRANSFORMEDINTO: + gBattleStruct->anyMonHasTransformed = TRUE; + break; + case STRINGID_CRITICALHIT: + AddMovePoints(0x12, moveSlot, 0, 0); + break; + case STRINGID_PKMNSSTATCHANGED: + if (gBattleTextBuff1[2] != 0) + { + if (*statStringId == STRINGID_STATSHARPLY) + AddMovePoints(0x17, moveSlot, gBattleTextBuff1[2] - 1, 0); + else + AddMovePoints(0x16, moveSlot, gBattleTextBuff1[2] - 1, 0); + } + break; + case STRINGID_PKMNSSTATCHANGED2: + if (gBattleTextBuff1[2] != 0) + { + if (gBattlerAttacker == gBattlerTarget) + { + if (*statStringId == STRINGID_STATSHARPLY) + AddMovePoints(0x17, moveSlot, gBattleTextBuff1[2] - 1, 0); + else + AddMovePoints(0x16, moveSlot, gBattleTextBuff1[2] - 1, 0); + } + else + { + AddMovePoints(0x1B, moveSlot, gBattleTextBuff1[2] - 1, 0); + } + } + break; + case STRINGID_PKMNSSTATCHANGED3: + if (gBattleTextBuff1[2] != 0) + AddMovePoints(0x18, moveSlot, gBattleTextBuff1[2] - 1, 0); + break; + case STRINGID_PKMNSSTATCHANGED4: + if (gBattleTextBuff1[2] != 0) + { + if (*statStringId == STRINGID_STATHARSHLY) + AddMovePoints(0x1A, moveSlot, gBattleTextBuff1[2] - 1, 0); + else + AddMovePoints(0x19, moveSlot, gBattleTextBuff1[2] - 1, 0); + } + break; + case STRINGID_PKMNLAIDCURSE: + tvPtr->pos[defSide][defFlank].curseMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->pos[defSide][defFlank].curseMoveSlot = moveSlot; + break; + case STRINGID_PKMNAFFLICTEDBYCURSE: + if (GetMonData(atkMon, MON_DATA_HP, NULL) + && tvPtr->pos[atkSide][atkFlank].curseMonId != 0) + { + AddMovePoints(8, 0, tvPtr->pos[atkSide][atkFlank].curseMonId - 1, tvPtr->pos[atkSide][atkFlank].curseMoveSlot); + tvPtr->side[atkSide].faintCause = 1; + tvPtr->side[atkSide].faintCauseMonId = atkFlank; + } + break; + case STRINGID_PKMNSEEDED: + tvPtr->pos[defSide][defFlank].leechSeedMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->pos[defSide][defFlank].leechSeedMoveSlot = moveSlot; + break; + case STRINGID_PKMNSAPPEDBYLEECHSEED: + if (tvPtr->pos[atkSide][atkFlank].leechSeedMonId != 0) + { + AddMovePoints(8, 1, tvPtr->pos[atkSide][atkFlank].leechSeedMonId - 1, tvPtr->pos[atkSide][atkFlank].leechSeedMoveSlot); + tvPtr->side[atkSide].faintCause = 2; + tvPtr->side[atkSide].faintCauseMonId = atkFlank; + } + break; + case STRINGID_PKMNFELLINTONIGHTMARE: + tvPtr->pos[defSide][defFlank].nightmareMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->pos[defSide][defFlank].nightmareMoveSlot = moveSlot; + break; + case STRINGID_PKMNLOCKEDINNIGHTMARE: + if (GetMonData(atkMon, MON_DATA_HP, NULL) != 0 + && tvPtr->pos[atkSide][atkFlank].nightmareMonId != 0) + { + AddMovePoints(8, 5, tvPtr->pos[atkSide][atkFlank].nightmareMonId - 1, tvPtr->pos[atkSide][atkFlank].nightmareMoveSlot); + tvPtr->side[atkSide].faintCause = 5; + tvPtr->side[atkSide].faintCauseMonId = atkFlank; + } + break; + case STRINGID_PKMNSQUEEZEDBYBIND: + case STRINGID_PKMNTRAPPEDINVORTEX: + case STRINGID_PKMNWRAPPEDBY: + case STRINGID_PKMNCLAMPED: + case STRINGID_PKMNTRAPPEDBYSANDTOMB: + tvPtr->pos[defSide][defFlank].wrapMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->pos[defSide][defFlank].wrapMoveSlot = moveSlot; + break; + case STRINGID_PKMNHURTBY: + if (GetMonData(atkMon, MON_DATA_HP, NULL) != 0 + && tvPtr->pos[atkSide][atkFlank].wrapMonId != 0) + { + AddMovePoints(8, 6, tvPtr->pos[atkSide][atkFlank].wrapMonId - 1, tvPtr->pos[atkSide][atkFlank].wrapMoveSlot); + tvPtr->side[atkSide].faintCause = 6; + tvPtr->side[atkSide].faintCauseMonId = atkFlank; + } + break; + case STRINGID_PKMNWASBURNED: + tvPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].brnMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].brnMoveSlot = moveSlot; + break; + case STRINGID_PKMNHURTBYBURN: + if (GetMonData(atkMon, MON_DATA_HP, NULL) != 0) + { + if (tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].brnMonId != 0) + AddMovePoints(8, 4, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].brnMonId - 1, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].brnMoveSlot); + tvPtr->side[atkSide].faintCause = 4; + tvPtr->side[atkSide].faintCauseMonId = gBattlerPartyIndexes[gBattlerAttacker]; + } + break; + case STRINGID_PKMNWASPOISONED: + tvPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].psnMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].psnMoveSlot = moveSlot; + break; + case STRINGID_PKMNBADLYPOISONED: + tvPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].badPsnMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].badPsnMoveSlot = moveSlot; + break; + case STRINGID_PKMNHURTBYPOISON: + if (GetMonData(atkMon, MON_DATA_HP, NULL) != 0) + { + if (tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].psnMonId != 0) + AddMovePoints(8, 2, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].psnMonId - 1, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].psnMoveSlot); + if (tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].badPsnMonId != 0) + AddMovePoints(8, 3, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].badPsnMonId - 1, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].badPsnMoveSlot); + tvPtr->side[atkSide].faintCause = 3; + tvPtr->side[atkSide].faintCauseMonId = gBattlerPartyIndexes[gBattlerAttacker]; + } + break; + case STRINGID_PKMNFELLINLOVE: + tvPtr->pos[defSide][defFlank].attractMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->pos[defSide][defFlank].attractMoveSlot = moveSlot; + break; + case STRINGID_PKMNIMMOBILIZEDBYLOVE: + if (tvPtr->pos[atkSide][atkFlank].attractMonId != 0) + AddMovePoints(9, 0, tvPtr->pos[atkSide][atkFlank].attractMonId - 1, tvPtr->pos[atkSide][atkFlank].attractMoveSlot); + break; + case STRINGID_PKMNWASPARALYZED: + tvPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].prlzMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].prlzMoveSlot = moveSlot; + break; + case STRINGID_PKMNISPARALYZED: + if (tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].prlzMonId != 0) + AddMovePoints(9, 2, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].prlzMonId - 1, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].prlzMoveSlot); + break; + case STRINGID_PKMNFELLASLEEP: + tvPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].slpMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].slpMoveSlot = moveSlot; + break; + case STRINGID_PKMNFASTASLEEP: + if (tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].slpMonId != 0 + && gStringInfo->currentMove != MOVE_SNORE + && gStringInfo->currentMove != MOVE_SLEEP_TALK) + AddMovePoints(9, 3, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].slpMonId - 1, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].slpMoveSlot); + break; + case STRINGID_PKMNWASFROZEN: + tvPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].frzMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->mon[effSide][gBattlerPartyIndexes[gEffectBattler]].frzMoveSlot = moveSlot; + break; + case STRINGID_PKMNISFROZEN: + if (tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].frzMonId != 0) + AddMovePoints(9, 4, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].frzMonId - 1, tvPtr->mon[atkSide][gBattlerPartyIndexes[gBattlerAttacker]].frzMoveSlot); + break; + case STRINGID_PKMNWASCONFUSED: + tvPtr->pos[effSide][effFlank].confusionMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->pos[effSide][effFlank].confusionMoveSlot = moveSlot; + break; + case STRINGID_ITHURTCONFUSION: + if (tvPtr->pos[atkSide][atkFlank].confusionMonId != 0) + AddMovePoints(9, 1, tvPtr->pos[atkSide][atkFlank].confusionMonId - 1, tvPtr->pos[atkSide][atkFlank].confusionMoveSlot); + tvPtr->side[atkSide].faintCause = 12; + break; + case STRINGID_SPIKESSCATTERED: + tvPtr->side[defSide].spikesMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->side[defSide].spikesMoveSlot = moveSlot; + break; + case STRINGID_PKMNHURTBYSPIKES: + if (tvPtr->side[scriptingSide].spikesMonId != 0) + { + AddMovePoints(10, scriptingSide ^ BIT_SIDE, tvPtr->side[scriptingSide].spikesMonId - 1, tvPtr->side[scriptingSide].spikesMoveSlot); + tvPtr->side[scriptingSide].faintCause = 7; + } + break; + case STRINGID_PKMNBLEWAWAYSPIKES: + tvPtr->side[atkSide].spikesMonId = 0; + tvPtr->side[atkSide].spikesMoveSlot = 0; + break; + case STRINGID_FIREWEAKENED: + tvPtr->pos[atkSide][atkFlank].waterSportMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->pos[atkSide][atkFlank].waterSportMoveSlot = moveSlot; + break; + case STRINGID_ELECTRICITYWEAKENED: + tvPtr->pos[atkSide][atkFlank].mudSportMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->pos[atkSide][atkFlank].mudSportMoveSlot = moveSlot; + break; + case STRINGID_ATTACKERFAINTED: + AddPointsOnFainting(FALSE); + case STRINGID_RETURNMON: + if (tvPtr->pos[atkSide][atkFlank].waterSportMonId != 0) + { + tvPtr->pos[atkSide][atkFlank].waterSportMonId = 0; + tvPtr->pos[atkSide][atkFlank].waterSportMoveSlot = 0; + } + if (tvPtr->pos[atkSide][atkFlank].mudSportMonId != 0) + { + tvPtr->pos[atkSide][atkFlank].mudSportMonId = 0; + tvPtr->pos[atkSide][atkFlank].mudSportMoveSlot = 0; + } + break; + case STRINGID_TARGETFAINTED: + AddPointsOnFainting(TRUE); + if (tvPtr->pos[atkSide][defFlank].waterSportMonId != 0) + { + tvPtr->pos[atkSide][defFlank].waterSportMonId = 0; + tvPtr->pos[atkSide][defFlank].waterSportMoveSlot = 0; + } + if (tvPtr->pos[atkSide][defFlank].mudSportMonId != 0) + { + tvPtr->pos[atkSide][defFlank].mudSportMonId = 0; + tvPtr->pos[atkSide][defFlank].mudSportMoveSlot = 0; + } + break; + case STRINGID_PKMNRAISEDDEF: + case STRINGID_PKMNRAISEDDEFALITTLE: + tvPtr->side[atkSide].reflectMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->side[atkSide].reflectMoveSlot = moveSlot; + break; + case STRINGID_PKMNRAISEDSPDEF: + case STRINGID_PKMNRAISEDSPDEFALITTLE: + tvPtr->side[atkSide].lightScreenMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->side[atkSide].lightScreenMoveSlot = moveSlot; + break; + case STRINGID_PKMNSXWOREOFF: + if (*finishedMoveId == MOVE_REFLECT) + { + tvPtr->side[atkSide].reflectMonId = 0; + tvPtr->side[atkSide].reflectMoveSlot = 0; + } + if (*finishedMoveId == MOVE_LIGHT_SCREEN) + { + tvPtr->side[atkSide].lightScreenMonId = 0; + tvPtr->side[atkSide].lightScreenMoveSlot = 0; + } + if (*finishedMoveId == MOVE_MIST) + { + tvPtr->side[atkSide].mistMonId = 0; + tvPtr->side[atkSide].mistMoveSlot = 0; + } + break; + case STRINGID_PKMNCOVEREDBYVEIL: + tvPtr->side[atkSide].safeguardMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->side[atkSide].safeguardMoveSlot = moveSlot; + break; + case STRINGID_PKMNUSEDSAFEGUARD: + if (tvPtr->side[defSide].safeguardMonId != 0) + AddMovePoints(15, 0, tvPtr->side[defSide].safeguardMonId - 1, tvPtr->side[defSide].safeguardMoveSlot); + break; + case STRINGID_PKMNSAFEGUARDEXPIRED: + tvPtr->side[atkSide].safeguardMonId = 0; + tvPtr->side[atkSide].safeguardMoveSlot = 0; + break; + case STRINGID_PKMNSHROUDEDINMIST: + tvPtr->side[atkSide].mistMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->side[atkSide].mistMoveSlot = moveSlot; + break; + case STRINGID_PKMNPROTECTEDBYMIST: + if (tvPtr->side[defSide].mistMonId != 0) + AddMovePoints(16, 0, tvPtr->side[defSide].mistMonId - 1, tvPtr->side[defSide].mistMoveSlot); + break; + case STRINGID_THEWALLSHATTERED: + tvPtr->side[defSide].reflectMonId = 0; + tvPtr->side[defSide].reflectMoveSlot = 0; + tvPtr->side[defSide].lightScreenMonId = 0; + tvPtr->side[defSide].lightScreenMoveSlot = 0; + AddMovePoints(17, 0, gBattlerPartyIndexes[gBattlerAttacker], moveSlot); + break; + case STRINGID_PKMNFLINCHED: + if (tvPtr->pos[atkSide][0].attackedByMonId != 0) + AddMovePoints(21, 0, tvPtr->pos[atkSide][0].attackedByMonId - 1, tvPtr->pos[atkSide][0].attackedByMoveSlot); + if (tvPtr->pos[atkSide][1].attackedByMonId != 0) + AddMovePoints(21, 0, tvPtr->pos[atkSide][1].attackedByMonId - 1, tvPtr->pos[atkSide][1].attackedByMoveSlot); + break; + case STRINGID_PKMNCRASHED: + case STRINGID_PKMNHITWITHRECOIL: + tvPtr->side[atkSide].faintCause = 14; + break; + } +} + +static bool8 sub_817E0B8(u16 stringId) +{ + s32 i = 0; + + while (1) + { + if (sUnknown_0860A8A4[i] == stringId) + break; + i++; + if (sUnknown_0860A8A4[i] == 0xFFFF) + break; + } + + if (sUnknown_0860A8A4[i] == 0xFFFF) + return TRUE; + else + return FALSE; +} + +void BattleTv_SetDataBasedOnMove(u16 move, u16 weatherFlags, struct DisableStruct *disableStructPtr) +{ + struct BattleTv *tvPtr; + u32 atkSide, defSide; + u8 moveSlot; + + if (!(gBattleTypeFlags & BATTLE_TYPE_LINK)) + return; + + tvPtr = &gBattleStruct->tv; + + atkSide = GetBattlerSide(gBattlerAttacker); + defSide = GetBattlerSide(gBattlerTarget); + moveSlot = GetBattlerMoveSlotId(gBattlerAttacker, move); + + if (moveSlot >= 4) + { + tvPtr->side[atkSide].faintCause = 15; + return; + } + + tvPtr->pos[defSide][GetBattlerPosition(gBattlerAttacker) / 2].attackedByMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->pos[defSide][GetBattlerPosition(gBattlerAttacker) / 2].attackedByMoveSlot = moveSlot; + tvPtr->side[atkSide].usedMoveSlot = moveSlot; + AddMovePoints(0, moveSlot, gBattleMoves[move].effect, 0); + AddPointsBasedOnWeather(weatherFlags, move, moveSlot); + if (disableStructPtr->chargeTimer1 != 0) + AddMovePoints(7, move, moveSlot, 0); + + if (move == MOVE_WISH) + { + tvPtr->side[atkSide].wishMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->side[atkSide].wishMoveSlot = moveSlot; + } + if (move == MOVE_SELF_DESTRUCT || move == MOVE_EXPLOSION) + { + tvPtr->side[atkSide ^ BIT_SIDE].explosionMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1; + tvPtr->side[atkSide ^ BIT_SIDE].explosionMoveSlot = moveSlot; + tvPtr->side[atkSide ^ BIT_SIDE].faintCause = 13; + tvPtr->side[atkSide ^ BIT_SIDE].explosion = 1; + } + + AddMovePoints(13, gBattleMoves[move].type, gBattleMoves[move].power, 0); + AddMovePoints(14, gBattleMoves[move].type, gBattleMoves[move].power, 0); + AddMovePoints(11, gBattleMoves[move].type, 0, 0); + AddMovePoints(12, gBattleMoves[move].type, 0, 0); +} + +void BattleTv_SetDataBasedOnAnimation(u8 animationId) +{ + struct BattleTv *tvPtr; + u32 atkSide; + + if (!(gBattleTypeFlags & BATTLE_TYPE_LINK)) + return; + + tvPtr = &gBattleStruct->tv; + atkSide = GetBattlerSide(gBattlerAttacker); + switch (animationId) + { + case B_ANIM_FUTURE_SIGHT_HIT: + if (tvPtr->side[atkSide].futureSightMonId != 0) + { + AddMovePoints(2, 0, atkSide, + (tvPtr->side[atkSide].futureSightMonId - 1) * 4 + tvPtr->side[atkSide].futureSightMoveSlot); + tvPtr->side[atkSide].faintCause = 8; + } + break; + case B_ANIM_DOOM_DESIRE_HIT: + if (tvPtr->side[atkSide].doomDesireMonId != 0) + { + AddMovePoints(2, 1, atkSide, + (tvPtr->side[atkSide].doomDesireMonId - 1) * 4 + tvPtr->side[atkSide].doomDesireMoveSlot); + tvPtr->side[atkSide].faintCause = 9; + } + break; + } +} + +#ifdef NONMATCHING +// for loop has an unused stack variable +void TryPutLinkBattleTvShowOnAir(void) +{ + u16 playerBestSpecies = 0, opponentBestSpecies = 0; + s16 playerBestSum = 0, opponentBestSum = SHRT_MAX; + u8 playerBestMonId = 0, opponentBestMonId = 0; + struct BattleTvMovePoints *movePoints = NULL; + u8 countPlayer = 0, countOpponent = 0; + s16 sum = 0; + u16 species = 0; + u16 moveId = 0; + s32 i, j; + + if (gBattleStruct->anyMonHasTransformed) + return; + + movePoints = &gBattleStruct->tvMovePoints; + for (i = 0; i < PARTY_SIZE; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL) != SPECIES_NONE) + countPlayer++; + if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES, NULL) != SPECIES_NONE) + countOpponent++; + } + + if (!(gBattleTypeFlags & BATTLE_TYPE_LINK) || countPlayer != countOpponent) + return; + + for (i = 0; i < PARTY_SIZE; i++) + { + species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL); + if (species != SPECIES_NONE && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG, NULL)) + { + for (sum = 0, j = 0; j < 4; j++) + sum += movePoints->points[0][i * 4 + j]; + + if (playerBestSum < sum) + { + playerBestMonId = i; + playerBestSum = sum; + playerBestSpecies = species; + } + } + + species = GetMonData(&gEnemyParty[i], MON_DATA_SPECIES, NULL); + if (species != SPECIES_NONE && !GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG, NULL)) + { + s32 id = 1; + for (sum = 0, j = 0; j < 4; j++) + sum += movePoints->points[id][i * 4 + j]; + + if (opponentBestSum == sum) + { + if (GetMonData(&gEnemyParty[i], MON_DATA_EXP, NULL) > GetMonData(&gEnemyParty[opponentBestMonId], MON_DATA_EXP, NULL)) + { + opponentBestMonId = i; + opponentBestSum = sum; + opponentBestSpecies = species; + } + } + else if (opponentBestSum > sum) + { + opponentBestMonId = i; + opponentBestSum = sum; + opponentBestSpecies = species; + } + } + } + + for (sum = 0, i = 0, j = 0; j < 4; j++) + { + if (sum < movePoints->points[0][playerBestMonId * 4 + j]) + { + sum = movePoints->points[0][playerBestMonId * 4 + j]; + i = j; + } + } + + moveId = GetMonData(&gPlayerParty[playerBestMonId], MON_DATA_MOVE1 + i, NULL); + if (playerBestSum == 0 || moveId == 0) + return; + + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + { + if ((playerBestMonId < 3 && !sub_806D82C(gBattleScripting.multiplayerId)) + || (playerBestMonId >= 3 && sub_806D82C(gBattleScripting.multiplayerId))) + { + j = (opponentBestMonId < 3) ? 0 : 1; + PutBattleUpdateOnTheAir(sub_806EF84(j, gBattleScripting.multiplayerId), moveId, playerBestSpecies, opponentBestSpecies); + } + } + else + { + PutBattleUpdateOnTheAir(gBattleScripting.multiplayerId ^ 1, moveId, playerBestSpecies, opponentBestSpecies); + } +} + +#else +ASM_DIRECT +void TryPutLinkBattleTvShowOnAir(void) +{ + asm_unified( + "push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x20\n\ + movs r0, 0\n\ + str r0, [sp]\n\ + movs r1, 0\n\ + str r1, [sp, 0x4]\n\ + movs r2, 0\n\ + str r2, [sp, 0x8]\n\ + ldr r3, =0x00007fff\n\ + str r3, [sp, 0xC]\n\ + movs r4, 0\n\ + str r4, [sp, 0x10]\n\ + movs r7, 0\n\ + str r7, [sp, 0x14]\n\ + mov r8, r0\n\ + ldr r0, =gBattleStruct\n\ + ldr r1, [r0]\n\ + adds r0, r1, 0\n\ + adds r0, 0xB3\n\ + ldrb r0, [r0]\n\ + cmp r0, 0\n\ + beq _0817E42A\n\ + b _0817E670\n\ +_0817E42A:\n\ + movs r2, 0xD2\n\ + lsls r2, 1\n\ + adds r2, r1\n\ + mov r10, r2\n\ + movs r6, 0\n\ +_0817E434:\n\ + movs r0, 0x64\n\ + adds r4, r6, 0\n\ + muls r4, r0\n\ + ldr r0, =gPlayerParty\n\ + adds r0, r4, r0\n\ + movs r1, 0xB\n\ + movs r2, 0\n\ + bl GetMonData\n\ + cmp r0, 0\n\ + beq _0817E454\n\ + mov r0, r8\n\ + adds r0, 0x1\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r8, r0\n\ +_0817E454:\n\ + ldr r5, =gEnemyParty\n\ + adds r0, r4, r5\n\ + movs r1, 0xB\n\ + movs r2, 0\n\ + bl GetMonData\n\ + cmp r0, 0\n\ + beq _0817E46A\n\ + adds r0, r7, 0x1\n\ + lsls r0, 24\n\ + lsrs r7, r0, 24\n\ +_0817E46A:\n\ + adds r6, 0x1\n\ + cmp r6, 0x5\n\ + ble _0817E434\n\ + ldr r0, =gBattleTypeFlags\n\ + ldr r0, [r0]\n\ + movs r1, 0x2\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _0817E47E\n\ + b _0817E670\n\ +_0817E47E:\n\ + cmp r8, r7\n\ + beq _0817E484\n\ + b _0817E670\n\ +_0817E484:\n\ + movs r6, 0\n\ + lsls r3, r6, 1\n\ + str r3, [sp, 0x18]\n\ + movs r4, 0x64\n\ + mov r8, r4\n\ +_0817E48E:\n\ + mov r1, r8\n\ + muls r1, r6\n\ + ldr r0, =gPlayerParty\n\ + adds r4, r1, r0\n\ + adds r0, r4, 0\n\ + movs r1, 0xB\n\ + movs r2, 0\n\ + bl GetMonData\n\ + lsls r0, 16\n\ + lsrs r7, r0, 16\n\ + adds r0, r6, 0x1\n\ + mov r9, r0\n\ + cmp r7, 0\n\ + beq _0817E4EE\n\ + adds r0, r4, 0\n\ + movs r1, 0x2D\n\ + movs r2, 0\n\ + bl GetMonData\n\ + cmp r0, 0\n\ + bne _0817E4EE\n\ + movs r4, 0\n\ + lsls r0, r6, 3\n\ + mov r2, r10\n\ + adds r1, r0, r2\n\ + movs r3, 0x3\n\ +_0817E4C4:\n\ + lsls r0, r4, 16\n\ + asrs r0, 16\n\ + ldrh r4, [r1]\n\ + adds r0, r4\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + adds r1, 0x2\n\ + subs r3, 0x1\n\ + cmp r3, 0\n\ + bge _0817E4C4\n\ + ldr r1, [sp, 0x8]\n\ + lsls r0, r1, 16\n\ + lsls r1, r4, 16\n\ + cmp r0, r1\n\ + bge _0817E4EE\n\ + lsls r0, r6, 24\n\ + lsrs r0, 24\n\ + str r0, [sp, 0x10]\n\ + lsrs r1, 16\n\ + str r1, [sp, 0x8]\n\ + str r7, [sp]\n\ +_0817E4EE:\n\ + mov r0, r8\n\ + muls r0, r6\n\ + ldr r2, =gEnemyParty\n\ + adds r4, r0, r2\n\ + adds r0, r4, 0\n\ + movs r1, 0xB\n\ + movs r2, 0\n\ + bl GetMonData\n\ + lsls r0, 16\n\ + lsrs r7, r0, 16\n\ + ldr r3, [sp, 0x8]\n\ + lsls r3, 16\n\ + str r3, [sp, 0x1C]\n\ + cmp r7, 0\n\ + beq _0817E5A0\n\ + adds r0, r4, 0\n\ + movs r1, 0x2D\n\ + movs r2, 0\n\ + bl GetMonData\n\ + cmp r0, 0\n\ + bne _0817E5A0\n\ + movs r4, 0\n\ + ldr r0, [sp, 0xC]\n\ + lsls r2, r0, 16\n\ + movs r3, 0x1\n\ + lsls r1, r3, 1\n\ + adds r1, 0x1\n\ + lsls r1, 4\n\ + lsls r0, r6, 3\n\ + adds r0, r1\n\ + mov r3, r10\n\ + adds r1, r0, r3\n\ + movs r3, 0x3\n\ +_0817E534:\n\ + lsls r0, r4, 16\n\ + asrs r0, 16\n\ + ldrh r4, [r1]\n\ + adds r0, r4\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + adds r1, 0x2\n\ + subs r3, 0x1\n\ + cmp r3, 0\n\ + bge _0817E534\n\ + asrs r1, r2, 16\n\ + lsls r5, r4, 16\n\ + asrs r0, r5, 16\n\ + cmp r1, r0\n\ + bne _0817E590\n\ + mov r0, r8\n\ + muls r0, r6\n\ + ldr r1, =gEnemyParty\n\ + adds r0, r1\n\ + movs r1, 0x19\n\ + movs r2, 0\n\ + bl GetMonData\n\ + adds r4, r0, 0\n\ + ldr r2, [sp, 0x14]\n\ + mov r0, r8\n\ + muls r0, r2\n\ + ldr r3, =gEnemyParty\n\ + adds r0, r3\n\ + movs r1, 0x19\n\ + movs r2, 0\n\ + bl GetMonData\n\ + cmp r4, r0\n\ + bls _0817E5A0\n\ + b _0817E594\n\ + .pool\n\ +_0817E590:\n\ + cmp r1, r0\n\ + ble _0817E5A0\n\ +_0817E594:\n\ + lsls r0, r6, 24\n\ + lsrs r0, 24\n\ + str r0, [sp, 0x14]\n\ + lsrs r5, 16\n\ + str r5, [sp, 0xC]\n\ + str r7, [sp, 0x4]\n\ +_0817E5A0:\n\ + mov r6, r9\n\ + cmp r6, 0x5\n\ + bgt _0817E5A8\n\ + b _0817E48E\n\ +_0817E5A8:\n\ + movs r4, 0\n\ + movs r6, 0\n\ + movs r3, 0\n\ + ldr r5, =gPlayerParty\n\ + ldr r7, [sp, 0x10]\n\ + lsls r0, r7, 3\n\ + mov r1, r10\n\ + adds r2, r0, r1\n\ +_0817E5B8:\n\ + lsls r0, r4, 16\n\ + asrs r0, 16\n\ + movs r7, 0\n\ + ldrsh r1, [r2, r7]\n\ + cmp r0, r1\n\ + bge _0817E5C8\n\ + ldrh r4, [r2]\n\ + adds r6, r3, 0\n\ +_0817E5C8:\n\ + adds r2, 0x2\n\ + adds r3, 0x1\n\ + cmp r3, 0x3\n\ + ble _0817E5B8\n\ + movs r0, 0x64\n\ + ldr r1, [sp, 0x10]\n\ + muls r0, r1\n\ + adds r0, r5\n\ + adds r1, r6, 0\n\ + adds r1, 0xD\n\ + movs r2, 0\n\ + bl GetMonData\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + ldr r2, [sp, 0x1C]\n\ + cmp r2, 0\n\ + beq _0817E670\n\ + cmp r4, 0\n\ + beq _0817E670\n\ + ldr r0, =gBattleTypeFlags\n\ + ldr r0, [r0]\n\ + movs r1, 0x40\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0817E65C\n\ + ldr r3, [sp, 0x10]\n\ + cmp r3, 0x2\n\ + bhi _0817E620\n\ + ldr r0, =gBattleScripting\n\ + adds r0, 0x25\n\ + ldrb r0, [r0]\n\ + bl sub_806D82C\n\ + lsls r0, 16\n\ + cmp r0, 0\n\ + beq _0817E630\n\ + b _0817E670\n\ + .pool\n\ +_0817E620:\n\ + ldr r0, =gBattleScripting\n\ + adds r0, 0x25\n\ + ldrb r0, [r0]\n\ + bl sub_806D82C\n\ + lsls r0, 16\n\ + cmp r0, 0\n\ + beq _0817E670\n\ +_0817E630:\n\ + movs r3, 0\n\ + ldr r7, [sp, 0x14]\n\ + cmp r7, 0x2\n\ + bls _0817E63A\n\ + movs r3, 0x1\n\ +_0817E63A:\n\ + lsls r0, r3, 24\n\ + lsrs r0, 24\n\ + ldr r1, =gBattleScripting\n\ + adds r1, 0x25\n\ + ldrb r1, [r1]\n\ + bl sub_806EF84\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + adds r1, r4, 0\n\ + ldr r2, [sp]\n\ + ldr r3, [sp, 0x4]\n\ + bl PutBattleUpdateOnTheAir\n\ + b _0817E670\n\ + .pool\n\ +_0817E65C:\n\ + ldr r0, =gBattleScripting\n\ + adds r0, 0x25\n\ + ldrb r1, [r0]\n\ + movs r0, 0x1\n\ + eors r0, r1\n\ + adds r1, r4, 0\n\ + ldr r2, [sp]\n\ + ldr r3, [sp, 0x4]\n\ + bl PutBattleUpdateOnTheAir\n\ +_0817E670:\n\ + add sp, 0x20\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool"); +} +#endif + +static void AddMovePoints(u8 caseId, u16 arg1, u8 arg2, u8 arg3) +{ + struct BattleTvMovePoints *movePoints = &gBattleStruct->tvMovePoints; + struct BattleTv *tvPtr = &gBattleStruct->tv; + u32 atkSide = GetBattlerSide(gBattlerAttacker); + u32 defSide = GetBattlerSide(gBattlerTarget); + const u16 *ptr; + s32 i; + + switch (caseId) + { + case 0: + case 1: + case 18: + case 22 ... 27: + movePoints->points[atkSide][gBattlerPartyIndexes[gBattlerAttacker] * 4 + arg1] += sPointsArray[caseId][arg2]; + break; + case 3 ... 7: + i = 0; + ptr = sPointsArray[caseId]; + do + { + if (arg1 == ptr[i]) + { + movePoints->points[atkSide][gBattlerPartyIndexes[gBattlerAttacker] * 4 + arg2] += ptr[i+1]; + break; + } + i += 2; + } while (ptr[i] != 0xFFFF); + break; + case 19: + tvPtr->side[arg2 ^ 1].faintCause = 0; + movePoints->points[arg2][0 * 4 + arg3] += sPointsArray[caseId][arg1]; + break; + case 20: + tvPtr->side[arg2].faintCause = 0; + case 2: + movePoints->points[arg2][0 * 4 + arg3] += sPointsArray[caseId][arg1]; + break; + case 17: + movePoints->points[atkSide][arg2 * 4 + arg3] += sPointsArray[caseId][arg1]; + break; + case 8: + case 9: + case 15: + case 16: + case 21: + movePoints->points[atkSide ^ BIT_SIDE][arg2 * 4 + arg3] += sPointsArray[caseId][arg1]; + break; + case 10: + movePoints->points[arg1][arg2 * 4 + arg3] += sPointsArray[caseId][0]; + break; + case 11: + if (tvPtr->pos[defSide][0].waterSportMonId != -(tvPtr->pos[defSide][1].waterSportMonId) && arg1 == 10) + { + if (tvPtr->pos[defSide][0].waterSportMonId != 0) + { + u32 id = (tvPtr->pos[defSide][0].waterSportMonId - 1) * 4; + movePoints->points[defSide][id + tvPtr->pos[defSide][0].waterSportMoveSlot] += sPointsArray[caseId][0]; + } + if (tvPtr->pos[defSide][1].waterSportMonId != 0) + { + u32 id = (tvPtr->pos[defSide][1].waterSportMonId - 1) * 4; + movePoints->points[defSide][id + tvPtr->pos[defSide][1].waterSportMoveSlot] += sPointsArray[caseId][0]; + } + } + break; + case 12: + if (tvPtr->pos[defSide][0].mudSportMonId != -(tvPtr->pos[defSide][1].mudSportMonId) && arg1 == 13) + { + if (tvPtr->pos[defSide][0].mudSportMonId != 0) + { + u32 id = (tvPtr->pos[defSide][0].mudSportMonId - 1) * 4; + movePoints->points[defSide][id + tvPtr->pos[defSide][0].mudSportMoveSlot] += sPointsArray[caseId][0]; + } + if (tvPtr->pos[defSide][1].mudSportMonId != 0) + { + u32 id = (tvPtr->pos[defSide][1].mudSportMonId - 1) * 4; + movePoints->points[defSide][id + tvPtr->pos[defSide][1].mudSportMoveSlot] += sPointsArray[caseId][0]; + } + } + break; + case 13: + if (arg1 <= 8 && arg2 != 0 && tvPtr->side[defSide].reflectMonId != 0) + { + u32 id = (tvPtr->side[defSide].reflectMonId - 1) * 4; + movePoints->points[defSide][id + tvPtr->side[defSide].reflectMoveSlot] += sPointsArray[caseId][0]; + } + break; + case 14: + if (arg1 > 8 && arg2 != 0 && tvPtr->side[defSide].lightScreenMonId != 0) + { + u32 id = (tvPtr->side[defSide].lightScreenMonId - 1) * 4; + movePoints->points[defSide][id + tvPtr->side[defSide].lightScreenMoveSlot] += sPointsArray[caseId][0]; + } + break; + } +} + +static void AddPointsOnFainting(bool8 targetFainted) +{ + struct BattleTv *tvPtr = &gBattleStruct->tv; + u32 atkSide = GetBattlerSide(gBattlerAttacker); + u32 defSide = GetBattlerSide(gBattlerTarget); + u32 atkArrId = tvPtr->side[atkSide].faintCauseMonId; + s32 i; + + if (tvPtr->side[atkSide].faintCause != 0) + { + switch (tvPtr->side[atkSide].faintCause) + { + case 1: + if (tvPtr->pos[atkSide][atkArrId].curseMonId != 0) + { + AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + (tvPtr->pos[atkSide][atkArrId].curseMonId - 1) * 4 + tvPtr->pos[atkSide][atkArrId].curseMoveSlot); + } + break; + case 2: + if (tvPtr->pos[atkSide][atkArrId].leechSeedMonId != 0) + { + AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + (tvPtr->pos[atkSide][atkArrId].leechSeedMonId - 1) * 4 + tvPtr->pos[atkSide][atkArrId].leechSeedMoveSlot); + } + break; + case 3: + if (tvPtr->mon[atkSide][atkArrId].psnMonId != 0) + { + AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + (tvPtr->mon[atkSide][atkArrId].psnMonId - 1) * 4 + tvPtr->mon[atkSide][atkArrId].psnMoveSlot); + } + if (tvPtr->mon[atkSide][atkArrId].badPsnMonId != 0) + { + AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + (tvPtr->mon[atkSide][atkArrId].badPsnMonId - 1) * 4 + tvPtr->mon[atkSide][atkArrId].badPsnMoveSlot); + } + break; + case 4: + if (tvPtr->mon[atkSide][atkArrId].brnMonId != 0) + { + AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + (tvPtr->mon[atkSide][atkArrId].brnMonId - 1) * 4 + tvPtr->mon[atkSide][atkArrId].brnMoveSlot); + } + break; + case 5: + if (tvPtr->pos[atkSide][atkArrId].nightmareMonId != 0) + { + AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + (tvPtr->pos[atkSide][atkArrId].nightmareMonId - 1) * 4 + tvPtr->pos[atkSide][atkArrId].nightmareMoveSlot); + } + break; + case 6: + if (tvPtr->pos[atkSide][atkArrId].wrapMonId != 0) + { + AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + (tvPtr->pos[atkSide][atkArrId].wrapMonId - 1) * 4 + tvPtr->pos[atkSide][atkArrId].wrapMoveSlot); + } + break; + case 7: + if (tvPtr->side[atkSide].spikesMonId != 0) + { + AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + (tvPtr->side[atkSide].spikesMonId - 1) * 4 + tvPtr->side[atkSide].spikesMoveSlot); + } + break; + case 8: + if (tvPtr->side[atkSide].futureSightMonId != 0) + { + AddMovePoints(20, 0, atkSide, + (tvPtr->side[atkSide].futureSightMonId - 1) * 4 + tvPtr->side[atkSide].futureSightMoveSlot); + } + break; + case 9: + if (tvPtr->side[atkSide].doomDesireMonId != 0) + { + AddMovePoints(20, 0, atkSide, + (tvPtr->side[atkSide].doomDesireMonId - 1) * 4 + tvPtr->side[atkSide].doomDesireMoveSlot); + } + break; + case 10: + if (tvPtr->side[atkSide].perishSong + && tvPtr->side[atkSide].perishSongMonId - 1 != gBattlerPartyIndexes[gBattlerAttacker]) + { + AddMovePoints(19, 0, atkSide, + (tvPtr->side[atkSide].perishSongMonId - 1) * 4 + tvPtr->side[atkSide].perishSongMoveSlot); + } + if (tvPtr->side[atkSide ^ BIT_SIDE].perishSong) + { + AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + (tvPtr->side[atkSide ^ BIT_SIDE].perishSongMonId - 1) * 4 + tvPtr->side[atkSide ^ BIT_SIDE].perishSongMoveSlot); + } + break; + case 11: + if (tvPtr->side[atkSide ^ BIT_SIDE].destinyBondMonId != 0) + { + AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + (tvPtr->side[atkSide ^ BIT_SIDE].destinyBondMonId - 1) * 4 + tvPtr->side[atkSide ^ BIT_SIDE].destinyBondMoveSlot); + } + break; + case 12: + for (i = 0; i < 2; i++) + { + if (tvPtr->pos[atkSide][i].confusionMonId != 0) + { + AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + (tvPtr->pos[atkSide][i].confusionMonId - 1) * 4 + tvPtr->pos[atkSide][i].confusionMoveSlot); + } + } + break; + case 13: + if (tvPtr->side[atkSide].explosion) + { + AddMovePoints(19, 0, atkSide, + (tvPtr->side[atkSide].explosionMonId - 1) * 4 + tvPtr->side[atkSide].explosionMoveSlot); + } + if (tvPtr->side[atkSide ^ BIT_SIDE].explosion) + { + AddMovePoints(19, 0, atkSide ^ BIT_SIDE, + (tvPtr->side[atkSide ^ BIT_SIDE].explosionMonId - 1) * 4 + tvPtr->side[atkSide ^ BIT_SIDE].explosionMoveSlot); + } + break; + case 14: + if (targetFainted == TRUE) + { + AddMovePoints(20, 0, atkSide, + (gBattlerPartyIndexes[gBattlerAttacker]) * 4 + tvPtr->side[atkSide].usedMoveSlot); + } + break; + case 15: + break; + } + } + else + { + if (tvPtr->side[defSide].faintCause == 7) + { + if (tvPtr->side[defSide].spikesMonId != 0) + { + AddMovePoints(19, 0, defSide ^ BIT_SIDE, + (tvPtr->side[defSide].spikesMonId - 1) * 4 + tvPtr->side[defSide].spikesMoveSlot); + } + } + else + { + AddMovePoints(20, 0, atkSide, + (gBattlerPartyIndexes[gBattlerAttacker]) * 4 + tvPtr->side[atkSide].usedMoveSlot); + } + } +} + +static void TrySetBattleSeminarShow(void) +{ + s32 i; + s32 dmgByMove[4]; + u16 powerOverride; + u16 currMoveSaved; + + if (gBattleTypeFlags & (BATTLE_TYPE_DOUBLE | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + return; + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT) + return; + if (gBattleMons[gBattlerAttacker].statStages[STAT_ACC] <= 5) + return; + if (gBattleMons[gBattlerTarget].statStages[STAT_EVASION] > 6) + return; + if (gCurrentMove == MOVE_HIDDEN_POWER || gCurrentMove == MOVE_WEATHER_BALL) + return; + if (gBattleTypeFlags & (BATTLE_TYPE_PALACE | BATTLE_TYPE_PIKE | BATTLE_TYPE_PYRAMID)) + return; + if (gBattleMoves[gBattleMons[gBattlerAttacker].moves[gMoveSelectionCursor[gBattlerAttacker]]].power == 0) + return; + + i = 0; + currMoveSaved = gBattleMons[gBattlerAttacker].moves[gMoveSelectionCursor[gBattlerAttacker]]; + while (1) + { + if (currMoveSaved == sVariableDmgMoves[i]) + break; + i++; + if (sVariableDmgMoves[i] == 0xFFFF) + break; + } + + if (sVariableDmgMoves[i] != 0xFFFF) + return; + + dmgByMove[gMoveSelectionCursor[gBattlerAttacker]] = gBattleMoveDamage; + currMoveSaved = gCurrentMove; + for (i = 0; i < 4; i++) + { + gCurrentMove = gBattleMons[gBattlerAttacker].moves[i]; + powerOverride = 0; + if (ShouldCalculateDamage(gCurrentMove, &dmgByMove[i], &powerOverride)) + { + u8 moveResultFlags; + u16 sideStatus = gSideStatuses[GET_BATTLER_SIDE(gBattlerTarget)]; + gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattlerAttacker], &gBattleMons[gBattlerTarget], gCurrentMove, + sideStatus, powerOverride, + 0, gBattlerAttacker, gBattlerTarget); + + if (gStatuses3[gBattlerAttacker] & STATUS3_CHARGED_UP && gBattleMoves[gCurrentMove].type == TYPE_ELECTRIC) + gBattleMoveDamage *= 2; + if (gProtectStructs[gBattlerAttacker].helpingHand) + gBattleMoveDamage = gBattleMoveDamage * 15 / 10; + + moveResultFlags = TypeCalc(gCurrentMove, gBattlerAttacker, gBattlerTarget); + dmgByMove[i] = gBattleMoveDamage; + if (dmgByMove[i] == 0 && !(moveResultFlags & MOVE_RESULT_NO_EFFECT)) + dmgByMove[i] = 1; + } + } + + for (i = 0; i < 4; i++) + { + if (i != gMoveSelectionCursor[gBattlerAttacker] && dmgByMove[i] > dmgByMove[gMoveSelectionCursor[gBattlerAttacker]]) + { + u16 opponentSpecies, playerSpecies; + s32 bestMoveId; + + if (gMoveSelectionCursor[gBattlerAttacker] != 0) + bestMoveId = 0; + else + bestMoveId = 1; + + for (i = 0; i < 4; i++) + { + if (i != gMoveSelectionCursor[gBattlerAttacker] && dmgByMove[i] > dmgByMove[bestMoveId]) + bestMoveId = i; + } + + opponentSpecies = GetMonData(&gEnemyParty [gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_SPECIES, NULL); + playerSpecies = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_SPECIES, NULL); + sub_80EE35C(opponentSpecies, playerSpecies, gMoveSelectionCursor[gBattlerAttacker], gBattleMons[gBattlerAttacker].moves, gBattleMons[gBattlerAttacker].moves[bestMoveId]); + break; + } + } + + gBattleMoveDamage = dmgByMove[gMoveSelectionCursor[gBattlerAttacker]]; + gCurrentMove = currMoveSaved; +} + +static bool8 ShouldCalculateDamage(u16 moveId, s32 *dmg, u16 *powerOverride) +{ + if (gBattleMoves[moveId].power == 0) + { + *dmg = 0; + return FALSE; + } + else + { + s32 i = 0; + while (1) + { + if (moveId == sVariableDmgMoves[i]) + break; + i++; + if (sVariableDmgMoves[i] == 0xFFFF) + break; + } + + if (sVariableDmgMoves[i] != 0xFFFF) + { + *dmg = 0; + return FALSE; + } + else if (moveId == MOVE_PSYWAVE) + { + *dmg = gBattleMons[gBattlerAttacker].level; + *dmg /= 2; + return FALSE; + } + else if (moveId == MOVE_MAGNITUDE) + { + *powerOverride = 10; + return TRUE; + } + else + { + return TRUE; + } + } +} + +void BattleTv_ClearExplosionFaintCause(void) +{ + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + struct BattleTv *tvPtr = &gBattleStruct->tv; + + tvPtr->side[B_SIDE_PLAYER].faintCause = 0; + tvPtr->side[B_SIDE_OPPONENT].faintCause = 0; + + tvPtr->side[B_SIDE_PLAYER].faintCauseMonId = 0; + tvPtr->side[B_SIDE_OPPONENT].faintCauseMonId = 0; + + tvPtr->side[B_SIDE_PLAYER].explosionMonId = 0; + tvPtr->side[B_SIDE_OPPONENT].explosionMonId = 0; + + tvPtr->side[B_SIDE_PLAYER].explosionMoveSlot = 0; + tvPtr->side[B_SIDE_OPPONENT].explosionMoveSlot = 0; + + tvPtr->side[B_SIDE_PLAYER].explosion = 0; + tvPtr->side[B_SIDE_OPPONENT].explosion = 0; + } +} + +u8 GetBattlerMoveSlotId(u8 battlerId, u16 moveId) +{ + s32 i; + struct Pokemon *party; + + if (GetBattlerSide(battlerId) == B_SIDE_PLAYER) + party = gPlayerParty; + else + party = gEnemyParty; + + i = 0; + while (1) + { + if (i >= 4) + break; + if (GetMonData(&party[gBattlerPartyIndexes[battlerId]], MON_DATA_MOVE1 + i, NULL) == moveId) + break; + i++; + } + + return i; +} + +static void AddPointsBasedOnWeather(u16 weatherFlags, u16 moveId, u8 moveSlot) +{ + if (weatherFlags & WEATHER_RAIN_ANY) + AddMovePoints(3, moveId, moveSlot, 0); + else if (weatherFlags & WEATHER_SUN_ANY) + AddMovePoints(4, moveId, moveSlot, 0); + else if (weatherFlags & WEATHER_SANDSTORM_ANY) + AddMovePoints(5, moveId, moveSlot, 0); + else if (weatherFlags & WEATHER_HAIL_ANY) + AddMovePoints(6, moveId, moveSlot, 0); +} diff --git a/src/tv.c b/src/tv.c index 03d564828..fbbc10801 100644 --- a/src/tv.c +++ b/src/tv.c @@ -1276,7 +1276,7 @@ static void InterviewAfter_ContestLiveUpdates(void) } } -void PutBattleUpdateOnTheAir(u8 a0, u16 a1, u16 a2, u16 a3) +void PutBattleUpdateOnTheAir(u8 opponentLinkPlayerId, u16 move, u16 speciesPlayer, u16 speciesOpponent) { TVShow *show; u8 name[32]; @@ -1303,21 +1303,21 @@ void PutBattleUpdateOnTheAir(u8 a0, u16 a1, u16 a2, u16 a3) { show->battleUpdate.battleType = 0; } - show->battleUpdate.move = a1; - show->battleUpdate.species2 = a2; - show->battleUpdate.species = a3; - StringCopy(name, gLinkPlayers[a0].name); + show->battleUpdate.move = move; + show->battleUpdate.speciesPlayer = speciesPlayer; + show->battleUpdate.speciesOpponent = speciesOpponent; + StringCopy(name, gLinkPlayers[opponentLinkPlayerId].name); StripExtCtrlCodes(name); StringCopy(show->battleUpdate.linkOpponentName, name); tv_store_id_2x(show); show->battleUpdate.language = gGameLanguage; - if (show->battleUpdate.language == LANGUAGE_JAPANESE || gLinkPlayers[a0].language == LANGUAGE_JAPANESE) + if (show->battleUpdate.language == LANGUAGE_JAPANESE || gLinkPlayers[opponentLinkPlayerId].language == LANGUAGE_JAPANESE) { show->battleUpdate.linkOpponentLanguage = LANGUAGE_JAPANESE; } else { - show->battleUpdate.linkOpponentLanguage = gLinkPlayers[a0].language; + show->battleUpdate.linkOpponentLanguage = gLinkPlayers[opponentLinkPlayerId].language; } } } @@ -3822,8 +3822,8 @@ static void sub_80F0708(void) // FIXME: register allocation shenanigans case TVSHOW_3_CHEERS_FOR_POKEBLOCKS: break; case TVSHOW_BATTLE_UPDATE: - sub_80F0B24((&gSaveBlock1Ptr->tvShows[i])->battleUpdate.species2, i); - sub_80F0B24((&gSaveBlock1Ptr->tvShows[i])->battleUpdate.species, i); + sub_80F0B24((&gSaveBlock1Ptr->tvShows[i])->battleUpdate.speciesPlayer, i); + sub_80F0B24((&gSaveBlock1Ptr->tvShows[i])->battleUpdate.speciesOpponent, i); break; case TVSHOW_FAN_CLUB_SPECIAL: break; @@ -5972,13 +5972,13 @@ static void DoTVShowPokemonBattleUpdate(void) break; case 2: TVShowConvertInternationalString(gStringVar1, show->battleUpdate.playerName, show->battleUpdate.language); - StringCopy(gStringVar2, gSpeciesNames[show->battleUpdate.species2]); + StringCopy(gStringVar2, gSpeciesNames[show->battleUpdate.speciesPlayer]); StringCopy(gStringVar3, gMoveNames[show->battleUpdate.move]); sTVShowState = 3; break; case 3: TVShowConvertInternationalString(gStringVar1, show->battleUpdate.linkOpponentName, show->battleUpdate.linkOpponentLanguage); - StringCopy(gStringVar2, gSpeciesNames[show->battleUpdate.species]); + StringCopy(gStringVar2, gSpeciesNames[show->battleUpdate.speciesOpponent]); sTVShowState = 4; break; case 4: @@ -5993,14 +5993,14 @@ static void DoTVShowPokemonBattleUpdate(void) break; case 6: TVShowConvertInternationalString(gStringVar1, show->battleUpdate.playerName, show->battleUpdate.language); - StringCopy(gStringVar2, gSpeciesNames[show->battleUpdate.species2]); + StringCopy(gStringVar2, gSpeciesNames[show->battleUpdate.speciesPlayer]); StringCopy(gStringVar3, gMoveNames[show->battleUpdate.move]); sTVShowState = 7; break; case 7: TVShowConvertInternationalString(gStringVar1, show->battleUpdate.playerName, show->battleUpdate.language); TVShowConvertInternationalString(gStringVar2, show->battleUpdate.linkOpponentName, show->battleUpdate.linkOpponentLanguage); - StringCopy(gStringVar3, gSpeciesNames[show->battleUpdate.species]); + StringCopy(gStringVar3, gSpeciesNames[show->battleUpdate.speciesOpponent]); TVShowDone(); break; } From d29b9d268fe46322c740fe5ac440641834686f9d Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Wed, 28 Feb 2018 00:18:59 +0100 Subject: [PATCH 09/10] make it compile --- include/tv.h | 6 ++++++ src/battle_controllers.c | 9 ++++----- src/battle_tv.c | 3 +-- src/tv.c | 1 - 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/tv.h b/include/tv.h index 8c7c4701e..19c900ba8 100644 --- a/include/tv.h +++ b/include/tv.h @@ -3,6 +3,7 @@ extern u8 *const gTVStringVarPtrs[3]; +void ClearTVShowData(void); void sub_80EE184(void); void sub_80EE35C(u16 foeSpecies, u16 species, u8 moveIdx, const u16 *movePtr, u16 betterMove); void sub_80EE8C8(u16 winStreak, u8 facility); @@ -38,6 +39,11 @@ void sub_80EECC8(void); void sub_80EECEC(void); void sub_80F1208(TVShow *shows); void sub_80EE44C(u8 nMonsCaught, u8 nPkblkUsed); +void SetPokemonAnglerSpecies(u16 species); +void UpdateTVShowsPerDay(u16 days); +void PutPokemonTodayCaughtOnAir(void); +void TV_PutSecretBaseVisitOnTheAir(void); +bool8 Put3CheersForPokeblocksOnTheAir(const u8 *partnersName, u8 flavor, u8 unused, u8 sheen, u8 language); void PutBattleUpdateOnTheAir(u8 opponentLinkPlayerId, u16 move, u16 speciesPlayer, u16 speciesOpponent); #endif //GUARD_TV_H diff --git a/src/battle_controllers.c b/src/battle_controllers.c index 3d5ffeb3a..97f82ed0c 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -97,7 +97,6 @@ void SetUpBattleVarsAndBirchZigzagoon(void) void sub_8032768(void) { s32 i; - u8 *data; if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED)) sub_8184DA4(1); @@ -120,11 +119,11 @@ void sub_8032768(void) sub_81B8D64(i, 0); } - for (i = 0; i < sizeof(gBattleStruct->field_1A4); i++) - *((u8*)(&gBattleStruct->field_1A4) + i) = 0; + for (i = 0; i < sizeof(gBattleStruct->tvMovePoints); i++) + *((u8*)(&gBattleStruct->tvMovePoints) + i) = 0; - for (i = 0; i < sizeof(gBattleStruct->field_204); i++) - *((u8*)(&gBattleStruct->field_204) + i) = 0; + for (i = 0; i < sizeof(gBattleStruct->tv); i++) + *((u8*)(&gBattleStruct->tv) + i) = 0; } static void InitSinglePlayerBtlControllers(void) diff --git a/src/battle_tv.c b/src/battle_tv.c index bd3de548b..e23fba2c4 100644 --- a/src/battle_tv.c +++ b/src/battle_tv.c @@ -766,9 +766,8 @@ void TryPutLinkBattleTvShowOnAir(void) species = GetMonData(&gEnemyParty[i], MON_DATA_SPECIES, NULL); if (species != SPECIES_NONE && !GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG, NULL)) { - s32 id = 1; for (sum = 0, j = 0; j < 4; j++) - sum += movePoints->points[id][i * 4 + j]; + sum += movePoints->points[1][i * 4 + j]; if (opponentBestSum == sum) { diff --git a/src/tv.c b/src/tv.c index fbbc10801..b7c2812fe 100644 --- a/src/tv.c +++ b/src/tv.c @@ -1789,7 +1789,6 @@ void EndMassOutbreak(void) void UpdateTVShowsPerDay(u16 days) { - sub_80ED8B4(days); UpdateMassOutbreakTimeLeft(days); sub_80EF120(days); From 20baa1bc7a8cdf7ba5e88384b26b352e0f488afa Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 1 Mar 2018 01:05:34 +0100 Subject: [PATCH 10/10] battle tv review changes --- src/battle_tv.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/battle_tv.c b/src/battle_tv.c index e23fba2c4..777b4846f 100644 --- a/src/battle_tv.c +++ b/src/battle_tv.c @@ -11,8 +11,6 @@ extern struct StringInfoBattle *gStringInfo; -extern const struct BattleMove gBattleMoves[]; - // this file's functions static bool8 sub_817E0B8(u16 stringId); static void AddMovePoints(u8 caseId, u16 arg1, u8 arg2, u8 arg3); @@ -624,14 +622,12 @@ static bool8 sub_817E0B8(u16 stringId) { s32 i = 0; - while (1) + do { if (sUnknown_0860A8A4[i] == stringId) break; i++; - if (sUnknown_0860A8A4[i] == 0xFFFF) - break; - } + } while (sUnknown_0860A8A4[i] != 0xFFFF); if (sUnknown_0860A8A4[i] == 0xFFFF) return TRUE; @@ -1401,29 +1397,27 @@ static void TrySetBattleSeminarShow(void) if (gBattleTypeFlags & (BATTLE_TYPE_DOUBLE | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) return; - if (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT) + else if (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT) return; - if (gBattleMons[gBattlerAttacker].statStages[STAT_ACC] <= 5) + else if (gBattleMons[gBattlerAttacker].statStages[STAT_ACC] <= 5) return; - if (gBattleMons[gBattlerTarget].statStages[STAT_EVASION] > 6) + else if (gBattleMons[gBattlerTarget].statStages[STAT_EVASION] > 6) return; - if (gCurrentMove == MOVE_HIDDEN_POWER || gCurrentMove == MOVE_WEATHER_BALL) + else if (gCurrentMove == MOVE_HIDDEN_POWER || gCurrentMove == MOVE_WEATHER_BALL) return; - if (gBattleTypeFlags & (BATTLE_TYPE_PALACE | BATTLE_TYPE_PIKE | BATTLE_TYPE_PYRAMID)) + else if (gBattleTypeFlags & (BATTLE_TYPE_PALACE | BATTLE_TYPE_PIKE | BATTLE_TYPE_PYRAMID)) return; - if (gBattleMoves[gBattleMons[gBattlerAttacker].moves[gMoveSelectionCursor[gBattlerAttacker]]].power == 0) + else if (gBattleMoves[gBattleMons[gBattlerAttacker].moves[gMoveSelectionCursor[gBattlerAttacker]]].power == 0) return; i = 0; currMoveSaved = gBattleMons[gBattlerAttacker].moves[gMoveSelectionCursor[gBattlerAttacker]]; - while (1) + do { if (currMoveSaved == sVariableDmgMoves[i]) break; i++; - if (sVariableDmgMoves[i] == 0xFFFF) - break; - } + } while (sVariableDmgMoves[i] != 0xFFFF); if (sVariableDmgMoves[i] != 0xFFFF) return; @@ -1493,14 +1487,12 @@ static bool8 ShouldCalculateDamage(u16 moveId, s32 *dmg, u16 *powerOverride) else { s32 i = 0; - while (1) + do { if (moveId == sVariableDmgMoves[i]) break; i++; - if (sVariableDmgMoves[i] == 0xFFFF) - break; - } + } while (sVariableDmgMoves[i] != 0xFFFF); if (sVariableDmgMoves[i] != 0xFFFF) {