From 78d7c292909e7760bbb476297ab67891318db731 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 5 Jan 2019 16:00:57 +0100 Subject: [PATCH] Move buffers to allocated reousrces, get rid of old type effectiveness table --- include/battle.h | 4 +- include/battle_main.h | 12 - src/battle_controller_link_opponent.c | 226 ++++++++--------- src/battle_controller_link_partner.c | 222 ++++++++-------- src/battle_controller_opponent.c | 226 ++++++++--------- src/battle_controller_player.c | 294 +++++++++++----------- src/battle_controller_player_partner.c | 222 ++++++++-------- src/battle_controller_recorded_opponent.c | 220 ++++++++-------- src/battle_controller_recorded_player.c | 216 ++++++++-------- src/battle_controller_safari.c | 26 +- src/battle_controller_wally.c | 190 +++++++------- src/battle_controllers.c | 8 +- src/battle_dome.c | 272 +------------------- src/battle_gfx_sfx_util.c | 2 +- src/battle_main.c | 188 +++----------- src/battle_message.c | 4 +- src/battle_script_commands.c | 81 +++--- src/battle_util.c | 4 +- 18 files changed, 1009 insertions(+), 1408 deletions(-) diff --git a/include/battle.h b/include/battle.h index 52ceb5939..2cda45f36 100644 --- a/include/battle.h +++ b/include/battle.h @@ -349,6 +349,8 @@ struct BattleResources struct AI_ThinkingStruct *ai; struct BattleHistory *battleHistory; struct BattleScriptsStack *AI_ScriptsStack; + u8 bufferA[MAX_BATTLERS_COUNT][0x200]; + u8 bufferB[MAX_BATTLERS_COUNT][0x200]; }; struct BattleResults @@ -766,8 +768,6 @@ extern u8 gBattleTerrain; extern u32 gUnknown_02022FF4; extern u8 *gUnknown_0202305C; extern u8 *gUnknown_02023060; -extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; -extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; extern u8 gActiveBattler; extern u32 gBattleControllerExecFlags; extern u8 gBattlersCount; diff --git a/include/battle_main.h b/include/battle_main.h index 08401289b..583b0ae39 100644 --- a/include/battle_main.h +++ b/include/battle_main.h @@ -24,17 +24,6 @@ struct UnknownPokemonStruct4 #define TYPE_NAME_LENGTH 6 #define ABILITY_NAME_LENGTH 12 -// defines for the u8 array gTypeEffectiveness -#define TYPE_EFFECT_ATK_TYPE(i)((gTypeEffectiveness[i + 0])) -#define TYPE_EFFECT_DEF_TYPE(i)((gTypeEffectiveness[i + 1])) -#define TYPE_EFFECT_MULTIPLIER(i)((gTypeEffectiveness[i + 2])) - -// defines for the gTypeEffectiveness multipliers -#define TYPE_MUL_NO_EFFECT 0 -#define TYPE_MUL_NOT_EFFECTIVE 5 -#define TYPE_MUL_NORMAL 10 -#define TYPE_MUL_SUPER_EFFECTIVE 20 - // special type table Ids #define TYPE_FORESIGHT 0xFE #define TYPE_ENDTABLE 0xFF @@ -92,7 +81,6 @@ extern struct UnknownPokemonStruct4 gUnknown_02022FF8[3]; extern const struct SpriteTemplate gUnknown_0831AC88; extern const struct OamData gOamData_831ACA8; extern const struct OamData gOamData_831ACB0; -extern const u8 gTypeEffectiveness[336]; extern const u8 gTypeNames[][TYPE_NAME_LENGTH + 1]; extern const struct TrainerMoney gTrainerMoneyTable[]; extern const u8 gAbilityNames[][ABILITY_NAME_LENGTH + 1]; diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c index e3d1fd71a..0f714b6c8 100644 --- a/src/battle_controller_link_opponent.c +++ b/src/battle_controller_link_opponent.c @@ -182,8 +182,8 @@ static void LinkOpponentBufferRunCommand(void) { if (gBattleControllerExecFlags & gBitTable[gActiveBattler]) { - if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sLinkOpponentBufferCommands)) - sLinkOpponentBufferCommands[gBattleBufferA[gActiveBattler][0]](); + if (gBattleResources->bufferA[gActiveBattler][0] < ARRAY_COUNT(sLinkOpponentBufferCommands)) + sLinkOpponentBufferCommands[gBattleResources->bufferA[gActiveBattler][0]](); else LinkOpponentBufferExecCompleted(); } @@ -535,7 +535,7 @@ static void LinkOpponentBufferExecCompleted(void) u8 playerId = GetMultiplayerId(); PrepareBufferDataTransferLink(2, 4, &playerId); - gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; + gBattleResources->bufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else { @@ -550,13 +550,13 @@ static void LinkOpponentHandleGetMonData(void) u8 monToCheck; s32 i; - if (gBattleBufferA[gActiveBattler][2] == 0) + if (gBattleResources->bufferA[gActiveBattler][2] == 0) { size += CopyLinkOpponentMonData(gBattlerPartyIndexes[gActiveBattler], monData); } else { - monToCheck = gBattleBufferA[gActiveBattler][2]; + monToCheck = gBattleResources->bufferA[gActiveBattler][2]; for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) @@ -578,7 +578,7 @@ static u32 CopyLinkOpponentMonData(u8 monId, u8 *dst) u32 data32; s32 size = 0; - switch (gBattleBufferA[gActiveBattler][1]) + switch (gBattleResources->bufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: battleMon.species = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES); @@ -644,7 +644,7 @@ static u32 CopyLinkOpponentMonData(u8 monId, u8 *dst) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - data16 = GetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); + data16 = GetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); dst[0] = data16; dst[1] = data16 >> 8; size = 2; @@ -659,7 +659,7 @@ static u32 CopyLinkOpponentMonData(u8 monId, u8 *dst) case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); + dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); size = 1; break; case REQUEST_OTID_BATTLE: @@ -884,13 +884,13 @@ static void LinkOpponentHandleSetMonData(void) u8 monToCheck; u8 i; - if (gBattleBufferA[gActiveBattler][2] == 0) + if (gBattleResources->bufferA[gActiveBattler][2] == 0) { SetLinkOpponentMonData(gBattlerPartyIndexes[gActiveBattler]); } else { - monToCheck = gBattleBufferA[gActiveBattler][2]; + monToCheck = gBattleResources->bufferA[gActiveBattler][2]; for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) @@ -903,11 +903,11 @@ static void LinkOpponentHandleSetMonData(void) static void SetLinkOpponentMonData(u8 monId) { - struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBattler][3]; - struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBattler][3]; + struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleResources->bufferA[gActiveBattler][3]; + struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleResources->bufferA[gActiveBattler][3]; s32 i; - switch (gBattleBufferA[gActiveBattler][1]) + switch (gBattleResources->bufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: { @@ -948,10 +948,10 @@ static void SetLinkOpponentMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HELD_ITEM, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < MAX_MON_MOVES; i++) @@ -965,165 +965,165 @@ static void SetLinkOpponentMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBattler][4]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBattler][5]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBattler][6]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBattler][7]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP1, &gBattleResources->bufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP2, &gBattleResources->bufferA[gActiveBattler][4]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP3, &gBattleResources->bufferA[gActiveBattler][5]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP4, &gBattleResources->bufferA[gActiveBattler][6]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP_BONUSES, &gBattleResources->bufferA[gActiveBattler][7]); break; case REQUEST_PPMOVE1_BATTLE: case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_OTID_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_OT_ID, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_EXP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_EXP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HP_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_FRIENDSHIP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_FRIENDSHIP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_POKERUS_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_POKERUS, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_LOCATION_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MET_LOCATION, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_LEVEL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MET_LEVEL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_GAME_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MET_GAME, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_POKEBALL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_POKEBALL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ALL_IVS_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); - SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][4]); - SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][5]); - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][6]); - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][7]); - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][8]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleResources->bufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleResources->bufferA[gActiveBattler][4]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleResources->bufferA[gActiveBattler][5]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleResources->bufferA[gActiveBattler][6]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleResources->bufferA[gActiveBattler][7]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleResources->bufferA[gActiveBattler][8]); break; case REQUEST_HP_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_PERSONALITY, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_CHECKSUM, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_STATUS, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_LEVEL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MAX_HP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_COOL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CUTE_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_CUTE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SMART_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SMART, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SHEEN_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SHEEN, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_COOL_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_COOL_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CUTE_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_CUTE_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SMART_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SMART_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; } } static void LinkOpponentHandleSetRawMonData(void) { - u8 *dst = (u8 *)&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; + u8 *dst = (u8 *)&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleResources->bufferA[gActiveBattler][1]; u8 i; - for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) - dst[i] = gBattleBufferA[gActiveBattler][3 + i]; + for (i = 0; i < gBattleResources->bufferA[gActiveBattler][2]; i++) + dst[i] = gBattleResources->bufferA[gActiveBattler][3 + i]; LinkOpponentBufferExecCompleted(); } @@ -1152,8 +1152,8 @@ static void LinkOpponentHandleLoadMonSprite(void) static void LinkOpponentHandleSwitchInAnim(void) { - gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1]; - sub_8066494(gActiveBattler, gBattleBufferA[gActiveBattler][2]); + gBattlerPartyIndexes[gActiveBattler] = gBattleResources->bufferA[gActiveBattler][1]; + sub_8066494(gActiveBattler, gBattleResources->bufferA[gActiveBattler][2]); gBattlerControllerFuncs[gActiveBattler] = sub_8064F40; } @@ -1162,7 +1162,7 @@ static void sub_8066494(u8 battlerId, bool8 dontClearSubstituteBit) u16 species; ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit); - gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1]; + gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1]; species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId); @@ -1191,7 +1191,7 @@ static void sub_8066494(u8 battlerId, bool8 dontClearSubstituteBit) static void LinkOpponentHandleReturnMonToBall(void) { - if (gBattleBufferA[gActiveBattler][1] == 0) + if (gBattleResources->bufferA[gActiveBattler][1] == 0) { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattlerControllerFuncs[gActiveBattler] = DoSwitchOutAnimation; @@ -1394,14 +1394,14 @@ static void LinkOpponentHandleMoveAnimation(void) { if (!mplay_80342A4(gActiveBattler)) { - u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); + u16 move = gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8); - gAnimMoveTurn = gBattleBufferA[gActiveBattler][3]; - gAnimMovePower = gBattleBufferA[gActiveBattler][4] | (gBattleBufferA[gActiveBattler][5] << 8); - gAnimMoveDmg = gBattleBufferA[gActiveBattler][6] | (gBattleBufferA[gActiveBattler][7] << 8) | (gBattleBufferA[gActiveBattler][8] << 16) | (gBattleBufferA[gActiveBattler][9] << 24); - gAnimFriendship = gBattleBufferA[gActiveBattler][10]; - gWeatherMoveAnim = gBattleBufferA[gActiveBattler][12] | (gBattleBufferA[gActiveBattler][13] << 8); - gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBattler][16]; + gAnimMoveTurn = gBattleResources->bufferA[gActiveBattler][3]; + gAnimMovePower = gBattleResources->bufferA[gActiveBattler][4] | (gBattleResources->bufferA[gActiveBattler][5] << 8); + gAnimMoveDmg = gBattleResources->bufferA[gActiveBattler][6] | (gBattleResources->bufferA[gActiveBattler][7] << 8) | (gBattleResources->bufferA[gActiveBattler][8] << 16) | (gBattleResources->bufferA[gActiveBattler][9] << 24); + gAnimFriendship = gBattleResources->bufferA[gActiveBattler][10]; + gWeatherMoveAnim = gBattleResources->bufferA[gActiveBattler][12] | (gBattleResources->bufferA[gActiveBattler][13] << 8); + gAnimDisableStructPtr = (struct DisableStruct *)&gBattleResources->bufferA[gActiveBattler][16]; gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality; if (IsMoveWithoutAnimation(move, gAnimMoveTurn)) // always returns FALSE { @@ -1418,8 +1418,8 @@ static void LinkOpponentHandleMoveAnimation(void) static void LinkOpponentDoMoveAnimation(void) { - u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); - u8 multihit = gBattleBufferA[gActiveBattler][11]; + u16 move = gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8); + u8 multihit = gBattleResources->bufferA[gActiveBattler][11]; switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { @@ -1457,7 +1457,7 @@ static void LinkOpponentDoMoveAnimation(void) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { CopyAllBattleSpritesInvisibilities(); - TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; LinkOpponentBufferExecCompleted(); } @@ -1471,7 +1471,7 @@ static void LinkOpponentHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); + stringId = (u16*)(&gBattleResources->bufferA[gActiveBattler][2]); BufferStringBattle(*stringId); BattlePutTextOnWindow(gDisplayedStringBattle, 0); gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; @@ -1518,7 +1518,7 @@ static void LinkOpponentHandleHealthBarUpdate(void) s16 hpVal; LoadBattleBarGfx(0); - hpVal = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); + hpVal = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8); if (hpVal != INSTANT_HP_BAR_DROP) { @@ -1559,8 +1559,8 @@ static void LinkOpponentHandleStatusAnimation(void) { if (!mplay_80342A4(gActiveBattler)) { - InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], - gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); + InitAndLaunchChosenStatusAnimation(gBattleResources->bufferA[gActiveBattler][1], + gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8) | (gBattleResources->bufferA[gActiveBattler][4] << 16) | (gBattleResources->bufferA[gActiveBattler][5] << 24)); gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; } } @@ -1618,7 +1618,7 @@ static void LinkOpponentHandleCmd37(void) static void LinkOpponentHandleCmd38(void) { - gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBattler][1]; + gUnknown_02022D0C.field_0 = gBattleResources->bufferA[gActiveBattler][1]; LinkOpponentBufferExecCompleted(); } @@ -1663,20 +1663,20 @@ static void LinkOpponentHandlePlaySE(void) else pan = SOUND_PAN_TARGET; - PlaySE12WithPanning(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8), pan); + PlaySE12WithPanning(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8), pan); LinkOpponentBufferExecCompleted(); } static void LinkOpponentHandlePlayFanfareOrBGM(void) { - if (gBattleBufferA[gActiveBattler][3]) + if (gBattleResources->bufferA[gActiveBattler][3]) { BattleStopLowHpSound(); - PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + PlayBGM(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); } else { - PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + PlayFanfare(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); } LinkOpponentBufferExecCompleted(); @@ -1692,7 +1692,7 @@ static void LinkOpponentHandleFaintingCry(void) static void LinkOpponentHandleIntroSlide(void) { - HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); + HandleIntroSlide(gBattleResources->bufferA[gActiveBattler][1]); gIntroSlideFlags |= 1; LinkOpponentBufferExecCompleted(); } @@ -1728,15 +1728,15 @@ static void sub_8067618(u8 taskId) gActiveBattler = gTasks[taskId].data[0]; if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; sub_8066494(gActiveBattler, FALSE); } else { - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; sub_8066494(gActiveBattler, FALSE); gActiveBattler = BATTLE_PARTNER(gActiveBattler); - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; sub_8066494(gActiveBattler, FALSE); gActiveBattler = BATTLE_PARTNER(gActiveBattler); } @@ -1754,7 +1754,7 @@ static void sub_80676FC(struct Sprite *sprite) static void LinkOpponentHandleDrawPartyStatusSummary(void) { - if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) + if (gBattleResources->bufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { LinkOpponentBufferExecCompleted(); } @@ -1762,7 +1762,7 @@ static void LinkOpponentHandleDrawPartyStatusSummary(void) { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1; - if (gBattleBufferA[gActiveBattler][2] != 0) + if (gBattleResources->bufferA[gActiveBattler][2] != 0) { if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1E < 2) { @@ -1775,10 +1775,10 @@ static void LinkOpponentHandleDrawPartyStatusSummary(void) } } - gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); + gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleResources->bufferA[gActiveBattler][4], gBattleResources->bufferA[gActiveBattler][1], gBattleResources->bufferA[gActiveBattler][2]); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; - if (gBattleBufferA[gActiveBattler][2] != 0) + if (gBattleResources->bufferA[gActiveBattler][2] != 0) gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; gBattlerControllerFuncs[gActiveBattler] = sub_806782C; @@ -1810,7 +1810,7 @@ static void LinkOpponentHandleSpriteInvisibility(void) { if (IsBattlerSpritePresent(gActiveBattler)) { - gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1]; + gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleResources->bufferA[gActiveBattler][1]; CopyBattleSpriteInvisibility(gActiveBattler); } LinkOpponentBufferExecCompleted(); @@ -1820,8 +1820,8 @@ static void LinkOpponentHandleBattleAnimation(void) { if (!mplay_80342A4(gActiveBattler)) { - u8 animationId = gBattleBufferA[gActiveBattler][1]; - u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); + u8 animationId = gBattleResources->bufferA[gActiveBattler][1]; + u16 argument = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8); if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) LinkOpponentBufferExecCompleted(); @@ -1834,7 +1834,7 @@ static void LinkOpponentHandleBattleAnimation(void) static void LinkOpponentHandleLinkStandbyMsg(void) { - sub_81851A8(&gBattleBufferA[gActiveBattler][2]); + sub_81851A8(&gBattleResources->bufferA[gActiveBattler][2]); LinkOpponentBufferExecCompleted(); } @@ -1845,14 +1845,14 @@ static void LinkOpponentHandleResetActionMoveSelection(void) static void LinkOpponentHandleCmd55(void) { - sub_81851A8(&gBattleBufferA[gActiveBattler][4]); + sub_81851A8(&gBattleResources->bufferA[gActiveBattler][4]); - if (gBattleBufferA[gActiveBattler][1] == B_OUTCOME_DREW) - gBattleOutcome = gBattleBufferA[gActiveBattler][1]; + if (gBattleResources->bufferA[gActiveBattler][1] == B_OUTCOME_DREW) + gBattleOutcome = gBattleResources->bufferA[gActiveBattler][1]; else - gBattleOutcome = gBattleBufferA[gActiveBattler][1] ^ B_OUTCOME_DREW; + gBattleOutcome = gBattleResources->bufferA[gActiveBattler][1] ^ B_OUTCOME_DREW; - gSaveBlock2Ptr->frontier.field_CA9_b = gBattleBufferA[gActiveBattler][2]; + gSaveBlock2Ptr->frontier.field_CA9_b = gBattleResources->bufferA[gActiveBattler][2]; FadeOutMapMusic(5); BeginFastPaletteFade(3); LinkOpponentBufferExecCompleted(); diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c index f23701799..99f869012 100644 --- a/src/battle_controller_link_partner.c +++ b/src/battle_controller_link_partner.c @@ -179,8 +179,8 @@ static void LinkPartnerBufferRunCommand(void) { if (gBattleControllerExecFlags & gBitTable[gActiveBattler]) { - if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sLinkPartnerBufferCommands)) - sLinkPartnerBufferCommands[gBattleBufferA[gActiveBattler][0]](); + if (gBattleResources->bufferA[gActiveBattler][0] < ARRAY_COUNT(sLinkPartnerBufferCommands)) + sLinkPartnerBufferCommands[gBattleResources->bufferA[gActiveBattler][0]](); else LinkPartnerBufferExecCompleted(); } @@ -408,7 +408,7 @@ static void LinkPartnerBufferExecCompleted(void) u8 playerId = GetMultiplayerId(); PrepareBufferDataTransferLink(2, 4, &playerId); - gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; + gBattleResources->bufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else { @@ -435,13 +435,13 @@ static void LinkPartnerHandleGetMonData(void) u8 monToCheck; s32 i; - if (gBattleBufferA[gActiveBattler][2] == 0) + if (gBattleResources->bufferA[gActiveBattler][2] == 0) { size += CopyLinkPartnerMonData(gBattlerPartyIndexes[gActiveBattler], monData); } else { - monToCheck = gBattleBufferA[gActiveBattler][2]; + monToCheck = gBattleResources->bufferA[gActiveBattler][2]; for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) @@ -463,7 +463,7 @@ static u32 CopyLinkPartnerMonData(u8 monId, u8 *dst) u32 data32; s32 size = 0; - switch (gBattleBufferA[gActiveBattler][1]) + switch (gBattleResources->bufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: battleMon.species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES); @@ -529,7 +529,7 @@ static u32 CopyLinkPartnerMonData(u8 monId, u8 *dst) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); + data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); dst[0] = data16; dst[1] = data16 >> 8; size = 2; @@ -544,7 +544,7 @@ static u32 CopyLinkPartnerMonData(u8 monId, u8 *dst) case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); size = 1; break; case REQUEST_OTID_BATTLE: @@ -769,13 +769,13 @@ static void LinkPartnerHandleSetMonData(void) u8 monToCheck; u8 i; - if (gBattleBufferA[gActiveBattler][2] == 0) + if (gBattleResources->bufferA[gActiveBattler][2] == 0) { SetLinkPartnerMonData(gBattlerPartyIndexes[gActiveBattler]); } else { - monToCheck = gBattleBufferA[gActiveBattler][2]; + monToCheck = gBattleResources->bufferA[gActiveBattler][2]; for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) @@ -788,11 +788,11 @@ static void LinkPartnerHandleSetMonData(void) static void SetLinkPartnerMonData(u8 monId) { - struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBattler][3]; - struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBattler][3]; + struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleResources->bufferA[gActiveBattler][3]; + struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleResources->bufferA[gActiveBattler][3]; s32 i; - switch (gBattleBufferA[gActiveBattler][1]) + switch (gBattleResources->bufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: { @@ -833,10 +833,10 @@ static void SetLinkPartnerMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < MAX_MON_MOVES; i++) @@ -850,154 +850,154 @@ static void SetLinkPartnerMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBattler][4]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBattler][5]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBattler][6]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBattler][7]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleResources->bufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP2, &gBattleResources->bufferA[gActiveBattler][4]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP3, &gBattleResources->bufferA[gActiveBattler][5]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP4, &gBattleResources->bufferA[gActiveBattler][6]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &gBattleResources->bufferA[gActiveBattler][7]); break; case REQUEST_PPMOVE1_BATTLE: case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_OTID_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_EXP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HP_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_FRIENDSHIP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_POKERUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_LOCATION_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_LEVEL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_GAME_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_POKEBALL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ALL_IVS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][4]); - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][5]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][6]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][7]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][8]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleResources->bufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleResources->bufferA[gActiveBattler][4]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleResources->bufferA[gActiveBattler][5]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleResources->bufferA[gActiveBattler][6]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleResources->bufferA[gActiveBattler][7]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleResources->bufferA[gActiveBattler][8]); break; case REQUEST_HP_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CUTE_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SMART_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SHEEN_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_COOL_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CUTE_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SMART_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; } @@ -1006,11 +1006,11 @@ static void SetLinkPartnerMonData(u8 monId) static void LinkPartnerHandleSetRawMonData(void) { - u8 *dst = (u8 *)&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; + u8 *dst = (u8 *)&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleResources->bufferA[gActiveBattler][1]; u8 i; - for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) - dst[i] = gBattleBufferA[gActiveBattler][3 + i]; + for (i = 0; i < gBattleResources->bufferA[gActiveBattler][2]; i++) + dst[i] = gBattleResources->bufferA[gActiveBattler][3 + i]; LinkPartnerBufferExecCompleted(); } @@ -1036,10 +1036,10 @@ static void LinkPartnerHandleLoadMonSprite(void) static void LinkPartnerHandleSwitchInAnim(void) { - ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleBufferA[gActiveBattler][2]); - gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1]; + ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleResources->bufferA[gActiveBattler][2]); + gBattlerPartyIndexes[gActiveBattler] = gBattleResources->bufferA[gActiveBattler][1]; BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); - sub_814CC98(gActiveBattler, gBattleBufferA[gActiveBattler][2]); + sub_814CC98(gActiveBattler, gBattleResources->bufferA[gActiveBattler][2]); gBattlerControllerFuncs[gActiveBattler] = sub_814B69C; } @@ -1048,7 +1048,7 @@ static void sub_814CC98(u8 battlerId, bool8 dontClearSubstituteBit) u16 species; ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit); - gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1]; + gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1]; species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714); SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); @@ -1076,7 +1076,7 @@ static void sub_814CC98(u8 battlerId, bool8 dontClearSubstituteBit) static void LinkPartnerHandleReturnMonToBall(void) { - if (gBattleBufferA[gActiveBattler][1] == 0) + if (gBattleResources->bufferA[gActiveBattler][1] == 0) { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattlerControllerFuncs[gActiveBattler] = DoSwitchOutAnimation; @@ -1218,14 +1218,14 @@ static void LinkPartnerHandleMoveAnimation(void) { if (!mplay_80342A4(gActiveBattler)) { - u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); + u16 move = gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8); - gAnimMoveTurn = gBattleBufferA[gActiveBattler][3]; - gAnimMovePower = gBattleBufferA[gActiveBattler][4] | (gBattleBufferA[gActiveBattler][5] << 8); - gAnimMoveDmg = gBattleBufferA[gActiveBattler][6] | (gBattleBufferA[gActiveBattler][7] << 8) | (gBattleBufferA[gActiveBattler][8] << 16) | (gBattleBufferA[gActiveBattler][9] << 24); - gAnimFriendship = gBattleBufferA[gActiveBattler][10]; - gWeatherMoveAnim = gBattleBufferA[gActiveBattler][12] | (gBattleBufferA[gActiveBattler][13] << 8); - gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBattler][16]; + gAnimMoveTurn = gBattleResources->bufferA[gActiveBattler][3]; + gAnimMovePower = gBattleResources->bufferA[gActiveBattler][4] | (gBattleResources->bufferA[gActiveBattler][5] << 8); + gAnimMoveDmg = gBattleResources->bufferA[gActiveBattler][6] | (gBattleResources->bufferA[gActiveBattler][7] << 8) | (gBattleResources->bufferA[gActiveBattler][8] << 16) | (gBattleResources->bufferA[gActiveBattler][9] << 24); + gAnimFriendship = gBattleResources->bufferA[gActiveBattler][10]; + gWeatherMoveAnim = gBattleResources->bufferA[gActiveBattler][12] | (gBattleResources->bufferA[gActiveBattler][13] << 8); + gAnimDisableStructPtr = (struct DisableStruct *)&gBattleResources->bufferA[gActiveBattler][16]; gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality; if (IsMoveWithoutAnimation(move, gAnimMoveTurn)) // always returns FALSE { @@ -1242,8 +1242,8 @@ static void LinkPartnerHandleMoveAnimation(void) static void LinkPartnerDoMoveAnimation(void) { - u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); - u8 multihit = gBattleBufferA[gActiveBattler][11]; + u16 move = gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8); + u8 multihit = gBattleResources->bufferA[gActiveBattler][11]; switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { @@ -1281,7 +1281,7 @@ static void LinkPartnerDoMoveAnimation(void) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { CopyAllBattleSpritesInvisibilities(); - TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; LinkPartnerBufferExecCompleted(); } @@ -1295,7 +1295,7 @@ static void LinkPartnerHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); + stringId = (u16*)(&gBattleResources->bufferA[gActiveBattler][2]); BufferStringBattle(*stringId); BattlePutTextOnWindow(gDisplayedStringBattle, 0); gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; @@ -1342,7 +1342,7 @@ static void LinkPartnerHandleHealthBarUpdate(void) s16 hpVal; LoadBattleBarGfx(0); - hpVal = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); + hpVal = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8); if (hpVal != INSTANT_HP_BAR_DROP) { @@ -1383,8 +1383,8 @@ static void LinkPartnerHandleStatusAnimation(void) { if (!mplay_80342A4(gActiveBattler)) { - InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], - gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); + InitAndLaunchChosenStatusAnimation(gBattleResources->bufferA[gActiveBattler][1], + gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8) | (gBattleResources->bufferA[gActiveBattler][4] << 16) | (gBattleResources->bufferA[gActiveBattler][5] << 24)); gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; } } @@ -1442,7 +1442,7 @@ static void LinkPartnerHandleCmd37(void) static void LinkPartnerHandleCmd38(void) { - gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBattler][1]; + gUnknown_02022D0C.field_0 = gBattleResources->bufferA[gActiveBattler][1]; LinkPartnerBufferExecCompleted(); } @@ -1487,20 +1487,20 @@ static void LinkPartnerHandlePlaySE(void) else pan = SOUND_PAN_TARGET; - PlaySE12WithPanning(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8), pan); + PlaySE12WithPanning(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8), pan); LinkPartnerBufferExecCompleted(); } static void LinkPartnerHandlePlayFanfareOrBGM(void) { - if (gBattleBufferA[gActiveBattler][3]) + if (gBattleResources->bufferA[gActiveBattler][3]) { BattleStopLowHpSound(); - PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + PlayBGM(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); } else { - PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + PlayFanfare(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); } LinkPartnerBufferExecCompleted(); @@ -1516,7 +1516,7 @@ static void LinkPartnerHandleFaintingCry(void) static void LinkPartnerHandleIntroSlide(void) { - HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); + HandleIntroSlide(gBattleResources->bufferA[gActiveBattler][1]); gIntroSlideFlags |= 1; LinkPartnerBufferExecCompleted(); } @@ -1582,15 +1582,15 @@ static void sub_814DCCC(u8 taskId) gActiveBattler = gTasks[taskId].data[0]; if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; sub_814CC98(gActiveBattler, FALSE); } else { - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; sub_814CC98(gActiveBattler, FALSE); gActiveBattler ^= BIT_FLANK; - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); sub_814CC98(gActiveBattler, FALSE); gActiveBattler ^= BIT_FLANK; @@ -1603,17 +1603,17 @@ static void sub_814DCCC(u8 taskId) static void LinkPartnerHandleDrawPartyStatusSummary(void) { - if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) + if (gBattleResources->bufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { LinkPartnerBufferExecCompleted(); } else { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1; - gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); + gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleResources->bufferA[gActiveBattler][4], gBattleResources->bufferA[gActiveBattler][1], gBattleResources->bufferA[gActiveBattler][2]); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; - if (gBattleBufferA[gActiveBattler][2] != 0) + if (gBattleResources->bufferA[gActiveBattler][2] != 0) gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; gBattlerControllerFuncs[gActiveBattler] = sub_814DE9C; @@ -1645,7 +1645,7 @@ static void LinkPartnerHandleSpriteInvisibility(void) { if (IsBattlerSpritePresent(gActiveBattler)) { - gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1]; + gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleResources->bufferA[gActiveBattler][1]; CopyBattleSpriteInvisibility(gActiveBattler); } LinkPartnerBufferExecCompleted(); @@ -1655,8 +1655,8 @@ static void LinkPartnerHandleBattleAnimation(void) { if (!mplay_80342A4(gActiveBattler)) { - u8 animationId = gBattleBufferA[gActiveBattler][1]; - u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); + u8 animationId = gBattleResources->bufferA[gActiveBattler][1]; + u16 argument = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8); if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) LinkPartnerBufferExecCompleted(); @@ -1669,7 +1669,7 @@ static void LinkPartnerHandleBattleAnimation(void) static void LinkPartnerHandleLinkStandbyMsg(void) { - sub_81851A8(&gBattleBufferA[gActiveBattler][2]); + sub_81851A8(&gBattleResources->bufferA[gActiveBattler][2]); LinkPartnerBufferExecCompleted(); } @@ -1680,9 +1680,9 @@ static void LinkPartnerHandleResetActionMoveSelection(void) static void LinkPartnerHandleCmd55(void) { - sub_81851A8(&gBattleBufferA[gActiveBattler][4]); - gBattleOutcome = gBattleBufferA[gActiveBattler][1]; - gSaveBlock2Ptr->frontier.field_CA9_b = gBattleBufferA[gActiveBattler][2]; + sub_81851A8(&gBattleResources->bufferA[gActiveBattler][4]); + gBattleOutcome = gBattleResources->bufferA[gActiveBattler][1]; + gSaveBlock2Ptr->frontier.field_CA9_b = gBattleResources->bufferA[gActiveBattler][2]; FadeOutMapMusic(5); BeginFastPaletteFade(3); LinkPartnerBufferExecCompleted(); diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 234c47144..4a44d9ed8 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -190,8 +190,8 @@ static void OpponentBufferRunCommand(void) { if (gBattleControllerExecFlags & gBitTable[gActiveBattler]) { - if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sOpponentBufferCommands)) - sOpponentBufferCommands[gBattleBufferA[gActiveBattler][0]](); + if (gBattleResources->bufferA[gActiveBattler][0] < ARRAY_COUNT(sOpponentBufferCommands)) + sOpponentBufferCommands[gBattleResources->bufferA[gActiveBattler][0]](); else OpponentBufferExecCompleted(); } @@ -518,7 +518,7 @@ static void OpponentBufferExecCompleted(void) u8 playerId = GetMultiplayerId(); PrepareBufferDataTransferLink(2, 4, &playerId); - gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; + gBattleResources->bufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else { @@ -533,13 +533,13 @@ static void OpponentHandleGetMonData(void) u8 monToCheck; s32 i; - if (gBattleBufferA[gActiveBattler][2] == 0) + if (gBattleResources->bufferA[gActiveBattler][2] == 0) { size += GetOpponentMonData(gBattlerPartyIndexes[gActiveBattler], monData); } else { - monToCheck = gBattleBufferA[gActiveBattler][2]; + monToCheck = gBattleResources->bufferA[gActiveBattler][2]; for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) @@ -561,7 +561,7 @@ static u32 GetOpponentMonData(u8 monId, u8 *dst) u32 data32; s32 size = 0; - switch (gBattleBufferA[gActiveBattler][1]) + switch (gBattleResources->bufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: battleMon.species = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES); @@ -627,7 +627,7 @@ static u32 GetOpponentMonData(u8 monId, u8 *dst) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - data16 = GetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); + data16 = GetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); dst[0] = data16; dst[1] = data16 >> 8; size = 2; @@ -642,7 +642,7 @@ static u32 GetOpponentMonData(u8 monId, u8 *dst) case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); + dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); size = 1; break; case REQUEST_OTID_BATTLE: @@ -860,14 +860,14 @@ static u32 GetOpponentMonData(u8 monId, u8 *dst) static void OpponentHandleGetRawMonData(void) { struct BattlePokemon battleMon; - u8 *src = (u8 *)&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; - u8 *dst = (u8 *)&battleMon + gBattleBufferA[gActiveBattler][1]; + u8 *src = (u8 *)&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleResources->bufferA[gActiveBattler][1]; + u8 *dst = (u8 *)&battleMon + gBattleResources->bufferA[gActiveBattler][1]; u8 i; - for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) + for (i = 0; i < gBattleResources->bufferA[gActiveBattler][2]; i++) dst[i] = src[i]; - BtlController_EmitDataTransfer(1, gBattleBufferA[gActiveBattler][2], dst); + BtlController_EmitDataTransfer(1, gBattleResources->bufferA[gActiveBattler][2], dst); OpponentBufferExecCompleted(); } @@ -876,13 +876,13 @@ static void OpponentHandleSetMonData(void) u8 monToCheck; u8 i; - if (gBattleBufferA[gActiveBattler][2] == 0) + if (gBattleResources->bufferA[gActiveBattler][2] == 0) { SetOpponentMonData(gBattlerPartyIndexes[gActiveBattler]); } else { - monToCheck = gBattleBufferA[gActiveBattler][2]; + monToCheck = gBattleResources->bufferA[gActiveBattler][2]; for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) @@ -895,11 +895,11 @@ static void OpponentHandleSetMonData(void) static void SetOpponentMonData(u8 monId) { - struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBattler][3]; - struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBattler][3]; + struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleResources->bufferA[gActiveBattler][3]; + struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleResources->bufferA[gActiveBattler][3]; s32 i; - switch (gBattleBufferA[gActiveBattler][1]) + switch (gBattleResources->bufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: { @@ -940,10 +940,10 @@ static void SetOpponentMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HELD_ITEM, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < MAX_MON_MOVES; i++) @@ -957,165 +957,165 @@ static void SetOpponentMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBattler][4]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBattler][5]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBattler][6]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBattler][7]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP1, &gBattleResources->bufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP2, &gBattleResources->bufferA[gActiveBattler][4]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP3, &gBattleResources->bufferA[gActiveBattler][5]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP4, &gBattleResources->bufferA[gActiveBattler][6]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP_BONUSES, &gBattleResources->bufferA[gActiveBattler][7]); break; case REQUEST_PPMOVE1_BATTLE: case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_OTID_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_OT_ID, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_EXP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_EXP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HP_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_FRIENDSHIP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_FRIENDSHIP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_POKERUS_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_POKERUS, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_LOCATION_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MET_LOCATION, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_LEVEL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MET_LEVEL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_GAME_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MET_GAME, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_POKEBALL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_POKEBALL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ALL_IVS_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); - SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][4]); - SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][5]); - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][6]); - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][7]); - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][8]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleResources->bufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleResources->bufferA[gActiveBattler][4]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleResources->bufferA[gActiveBattler][5]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleResources->bufferA[gActiveBattler][6]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleResources->bufferA[gActiveBattler][7]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleResources->bufferA[gActiveBattler][8]); break; case REQUEST_HP_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_PERSONALITY, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_CHECKSUM, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_STATUS, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_LEVEL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MAX_HP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_COOL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CUTE_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_CUTE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SMART_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SMART, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SHEEN_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SHEEN, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_COOL_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_COOL_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CUTE_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_CUTE_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SMART_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SMART_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; } } static void OpponentHandleSetRawMonData(void) { - u8 *dst = (u8 *)&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; + u8 *dst = (u8 *)&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleResources->bufferA[gActiveBattler][1]; u8 i; - for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) - dst[i] = gBattleBufferA[gActiveBattler][3 + i]; + for (i = 0; i < gBattleResources->bufferA[gActiveBattler][2]; i++) + dst[i] = gBattleResources->bufferA[gActiveBattler][3 + i]; OpponentBufferExecCompleted(); } @@ -1146,8 +1146,8 @@ static void OpponentHandleLoadMonSprite(void) static void OpponentHandleSwitchInAnim(void) { *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = 6; - gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1]; - sub_80613DC(gActiveBattler, gBattleBufferA[gActiveBattler][2]); + gBattlerPartyIndexes[gActiveBattler] = gBattleResources->bufferA[gActiveBattler][1]; + sub_80613DC(gActiveBattler, gBattleResources->bufferA[gActiveBattler][2]); gBattlerControllerFuncs[gActiveBattler] = sub_805FDF0; } @@ -1156,7 +1156,7 @@ static void sub_80613DC(u8 battlerId, bool8 dontClearSubstituteBit) u16 species; ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit); - gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1]; + gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1]; species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId); @@ -1185,7 +1185,7 @@ static void sub_80613DC(u8 battlerId, bool8 dontClearSubstituteBit) static void OpponentHandleReturnMonToBall(void) { - if (gBattleBufferA[gActiveBattler][1] == 0) + if (gBattleResources->bufferA[gActiveBattler][1] == 0) { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattlerControllerFuncs[gActiveBattler] = DoSwitchOutAnimation; @@ -1431,14 +1431,14 @@ static void OpponentHandleMoveAnimation(void) { if (!mplay_80342A4(gActiveBattler)) { - u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); + u16 move = gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8); - gAnimMoveTurn = gBattleBufferA[gActiveBattler][3]; - gAnimMovePower = gBattleBufferA[gActiveBattler][4] | (gBattleBufferA[gActiveBattler][5] << 8); - gAnimMoveDmg = gBattleBufferA[gActiveBattler][6] | (gBattleBufferA[gActiveBattler][7] << 8) | (gBattleBufferA[gActiveBattler][8] << 16) | (gBattleBufferA[gActiveBattler][9] << 24); - gAnimFriendship = gBattleBufferA[gActiveBattler][10]; - gWeatherMoveAnim = gBattleBufferA[gActiveBattler][12] | (gBattleBufferA[gActiveBattler][13] << 8); - gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBattler][16]; + gAnimMoveTurn = gBattleResources->bufferA[gActiveBattler][3]; + gAnimMovePower = gBattleResources->bufferA[gActiveBattler][4] | (gBattleResources->bufferA[gActiveBattler][5] << 8); + gAnimMoveDmg = gBattleResources->bufferA[gActiveBattler][6] | (gBattleResources->bufferA[gActiveBattler][7] << 8) | (gBattleResources->bufferA[gActiveBattler][8] << 16) | (gBattleResources->bufferA[gActiveBattler][9] << 24); + gAnimFriendship = gBattleResources->bufferA[gActiveBattler][10]; + gWeatherMoveAnim = gBattleResources->bufferA[gActiveBattler][12] | (gBattleResources->bufferA[gActiveBattler][13] << 8); + gAnimDisableStructPtr = (struct DisableStruct *)&gBattleResources->bufferA[gActiveBattler][16]; gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality; if (IsMoveWithoutAnimation(move, gAnimMoveTurn)) // always returns FALSE { @@ -1454,8 +1454,8 @@ static void OpponentHandleMoveAnimation(void) static void OpponentDoMoveAnimation(void) { - u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); - u8 multihit = gBattleBufferA[gActiveBattler][11]; + u16 move = gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8); + u8 multihit = gBattleResources->bufferA[gActiveBattler][11]; switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { @@ -1493,7 +1493,7 @@ static void OpponentDoMoveAnimation(void) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { CopyAllBattleSpritesInvisibilities(); - TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; OpponentBufferExecCompleted(); } @@ -1507,7 +1507,7 @@ static void OpponentHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); + stringId = (u16*)(&gBattleResources->bufferA[gActiveBattler][2]); BufferStringBattle(*stringId); BattlePutTextOnWindow(gDisplayedStringBattle, 0); gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; @@ -1540,7 +1540,7 @@ static void OpponentHandleChooseMove(void) else { u8 chosenMoveId; - struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]); + struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleResources->bufferA[gActiveBattler][4]); if (gBattleTypeFlags & (BATTLE_TYPE_TRAINER | BATTLE_TYPE_FIRST_BATTLE | BATTLE_TYPE_SAFARI | BATTLE_TYPE_ROAMER)) { @@ -1669,7 +1669,7 @@ static void OpponentHandleHealthBarUpdate(void) s16 hpVal; LoadBattleBarGfx(0); - hpVal = (gBattleBufferA[gActiveBattler][3] << 8) | gBattleBufferA[gActiveBattler][2]; + hpVal = (gBattleResources->bufferA[gActiveBattler][3] << 8) | gBattleResources->bufferA[gActiveBattler][2]; if (hpVal != INSTANT_HP_BAR_DROP) { @@ -1710,8 +1710,8 @@ static void OpponentHandleStatusAnimation(void) { if (!mplay_80342A4(gActiveBattler)) { - InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], - gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); + InitAndLaunchChosenStatusAnimation(gBattleResources->bufferA[gActiveBattler][1], + gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8) | (gBattleResources->bufferA[gActiveBattler][4] << 16) | (gBattleResources->bufferA[gActiveBattler][5] << 24)); gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; } } @@ -1769,7 +1769,7 @@ static void OpponentHandleCmd37(void) static void OpponentHandleCmd38(void) { - gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBattler][1]; + gUnknown_02022D0C.field_0 = gBattleResources->bufferA[gActiveBattler][1]; OpponentBufferExecCompleted(); } @@ -1814,20 +1814,20 @@ static void OpponentHandlePlaySE(void) else pan = SOUND_PAN_TARGET; - PlaySE12WithPanning(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8), pan); + PlaySE12WithPanning(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8), pan); OpponentBufferExecCompleted(); } static void OpponentHandlePlayFanfareOrBGM(void) { - if (gBattleBufferA[gActiveBattler][3]) + if (gBattleResources->bufferA[gActiveBattler][3]) { BattleStopLowHpSound(); - PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + PlayBGM(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); } else { - PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + PlayFanfare(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); } OpponentBufferExecCompleted(); @@ -1843,7 +1843,7 @@ static void OpponentHandleFaintingCry(void) static void OpponentHandleIntroSlide(void) { - HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); + HandleIntroSlide(gBattleResources->bufferA[gActiveBattler][1]); gIntroSlideFlags |= 1; OpponentBufferExecCompleted(); } @@ -1886,20 +1886,20 @@ static void sub_8062828(u8 taskId) gActiveBattler = gTasks[taskId].data[0]; if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; sub_80613DC(gActiveBattler, FALSE); } else if ((gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)) { - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; sub_80613DC(gActiveBattler, FALSE); } else { - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; sub_80613DC(gActiveBattler, FALSE); gActiveBattler ^= BIT_FLANK; - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; sub_80613DC(gActiveBattler, FALSE); gActiveBattler ^= BIT_FLANK; } @@ -1910,7 +1910,7 @@ static void sub_8062828(u8 taskId) static void OpponentHandleDrawPartyStatusSummary(void) { - if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) + if (gBattleResources->bufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { OpponentBufferExecCompleted(); } @@ -1918,7 +1918,7 @@ static void OpponentHandleDrawPartyStatusSummary(void) { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1; - if (gBattleBufferA[gActiveBattler][2] != 0) + if (gBattleResources->bufferA[gActiveBattler][2] != 0) { if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1E < 2) { @@ -1931,10 +1931,10 @@ static void OpponentHandleDrawPartyStatusSummary(void) } } - gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); + gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleResources->bufferA[gActiveBattler][4], gBattleResources->bufferA[gActiveBattler][1], gBattleResources->bufferA[gActiveBattler][2]); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; - if (gBattleBufferA[gActiveBattler][2] != 0) + if (gBattleResources->bufferA[gActiveBattler][2] != 0) gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; gBattlerControllerFuncs[gActiveBattler] = sub_8062A2C; @@ -1966,7 +1966,7 @@ static void OpponentHandleSpriteInvisibility(void) { if (IsBattlerSpritePresent(gActiveBattler)) { - gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1]; + gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleResources->bufferA[gActiveBattler][1]; CopyBattleSpriteInvisibility(gActiveBattler); } OpponentBufferExecCompleted(); @@ -1976,8 +1976,8 @@ static void OpponentHandleBattleAnimation(void) { if (!mplay_80342A4(gActiveBattler)) { - u8 animationId = gBattleBufferA[gActiveBattler][1]; - u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); + u8 animationId = gBattleResources->bufferA[gActiveBattler][1]; + u16 argument = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8); if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) OpponentBufferExecCompleted(); diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 8a892c0c1..69e8e65ff 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -215,7 +215,7 @@ static void PlayerBufferExecCompleted(void) u8 playerId = GetMultiplayerId(); PrepareBufferDataTransferLink(2, 4, &playerId); - gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; + gBattleResources->bufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else { @@ -227,8 +227,8 @@ static void PlayerBufferRunCommand(void) { if (gBattleControllerExecFlags & gBitTable[gActiveBattler]) { - if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sPlayerBufferCommands)) - sPlayerBufferCommands[gBattleBufferA[gActiveBattler][0]](); + if (gBattleResources->bufferA[gActiveBattler][0] < ARRAY_COUNT(sPlayerBufferCommands)) + sPlayerBufferCommands[gBattleResources->bufferA[gActiveBattler][0]](); else PlayerBufferExecCompleted(); } @@ -242,7 +242,7 @@ static void CompleteOnBankSpritePosX_0(void) static void HandleInputChooseAction(void) { - u16 itemId = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); + u16 itemId = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8); DoBounceEffect(gActiveBattler, BOUNCE_HEALTHBOX, 7, 1); DoBounceEffect(gActiveBattler, BOUNCE_MON, 7, 1); @@ -320,7 +320,7 @@ static void HandleInputChooseAction(void) && !(gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]) && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - if (gBattleBufferA[gActiveBattler][1] == B_ACTION_USE_ITEM) + if (gBattleResources->bufferA[gActiveBattler][1] == B_ACTION_USE_ITEM) { // Add item to bag if it is a ball if (itemId <= ITEM_PREMIER_BALL) @@ -502,7 +502,7 @@ static void HandleInputChooseTarget(void) static void HandleInputChooseMove(void) { bool32 canSelectTarget = FALSE; - struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]); + struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleResources->bufferA[gActiveBattler][4]); if (gMain.heldKeys & DPAD_ANY && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A) gPlayerDpadHoldFrames++; @@ -531,9 +531,9 @@ static void HandleInputChooseMove(void) else gMultiUsePlayerCursor = GetBattlerAtPosition((GetBattlerPosition(gActiveBattler) & BIT_SIDE) ^ BIT_SIDE); - if (!gBattleBufferA[gActiveBattler][1]) // not a double battle + if (!gBattleResources->bufferA[gActiveBattler][1]) // not a double battle { - if (moveTarget & MOVE_TARGET_USER_OR_SELECTED && !gBattleBufferA[gActiveBattler][2]) + if (moveTarget & MOVE_TARGET_USER_OR_SELECTED && !gBattleResources->bufferA[gActiveBattler][2]) canSelectTarget++; } else // double battle @@ -724,7 +724,7 @@ static void HandleMoveSwitching(void) if (gMoveSelectionCursor[gActiveBattler] != gMultiUsePlayerCursor) { - struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]); + struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleResources->bufferA[gActiveBattler][4]); s32 i; // swap moves and pp @@ -1396,7 +1396,7 @@ static void WaitForMonSelection(void) else BtlController_EmitChosenMonReturnValue(1, 6, NULL); - if ((gBattleBufferA[gActiveBattler][1] & 0xF) == 1) + if ((gBattleResources->bufferA[gActiveBattler][1] & 0xF) == 1) PrintLinkStandbyMsg(); PlayerBufferExecCompleted(); @@ -1487,7 +1487,7 @@ static void PlayerHandleUnknownYesNoInput(void) static void MoveSelectionDisplayMoveNames(void) { s32 i; - struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]); + struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleResources->bufferA[gActiveBattler][4]); gNumberOfMovesToChoose = 0; for (i = 0; i < MAX_MON_MOVES; i++) @@ -1511,11 +1511,11 @@ static void MoveSelectionDisplayPpNumber(void) u8 *txtPtr; struct ChooseMoveStruct *moveInfo; - if (gBattleBufferA[gActiveBattler][2] == TRUE) // check if we didn't want to display pp number + if (gBattleResources->bufferA[gActiveBattler][2] == TRUE) // check if we didn't want to display pp number return; SetPpNumbersPaletteInMoveSelection(); - moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]); + moveInfo = (struct ChooseMoveStruct*)(&gBattleResources->bufferA[gActiveBattler][4]); txtPtr = ConvertIntToDecimalStringN(gDisplayedStringBattle, moveInfo->currentPp[gMoveSelectionCursor[gActiveBattler]], STR_CONV_MODE_RIGHT_ALIGN, 2); txtPtr[0] = CHAR_SLASH; txtPtr++; @@ -1527,7 +1527,7 @@ static void MoveSelectionDisplayPpNumber(void) static void MoveSelectionDisplayMoveType(void) { u8 *txtPtr; - struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]); + struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleResources->bufferA[gActiveBattler][4]); txtPtr = StringCopy(gDisplayedStringBattle, gText_MoveInterfaceType); txtPtr[0] = EXT_CTRL_CODE_BEGIN; @@ -1620,13 +1620,13 @@ static void PlayerHandleGetMonData(void) u8 monToCheck; s32 i; - if (gBattleBufferA[gActiveBattler][2] == 0) + if (gBattleResources->bufferA[gActiveBattler][2] == 0) { size += CopyPlayerMonData(gBattlerPartyIndexes[gActiveBattler], monData); } else { - monToCheck = gBattleBufferA[gActiveBattler][2]; + monToCheck = gBattleResources->bufferA[gActiveBattler][2]; for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) @@ -1648,7 +1648,7 @@ static u32 CopyPlayerMonData(u8 monId, u8 *dst) u32 data32; s32 size = 0; - switch (gBattleBufferA[gActiveBattler][1]) + switch (gBattleResources->bufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: battleMon.species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES); @@ -1714,7 +1714,7 @@ static u32 CopyPlayerMonData(u8 monId, u8 *dst) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); + data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); dst[0] = data16; dst[1] = data16 >> 8; size = 2; @@ -1729,7 +1729,7 @@ static u32 CopyPlayerMonData(u8 monId, u8 *dst) case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); size = 1; break; case REQUEST_OTID_BATTLE: @@ -1947,14 +1947,14 @@ static u32 CopyPlayerMonData(u8 monId, u8 *dst) void PlayerHandleGetRawMonData(void) { struct BattlePokemon battleMon; - u8 *src = (u8 *)&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; - u8 *dst = (u8 *)&battleMon + gBattleBufferA[gActiveBattler][1]; + u8 *src = (u8 *)&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleResources->bufferA[gActiveBattler][1]; + u8 *dst = (u8 *)&battleMon + gBattleResources->bufferA[gActiveBattler][1]; u8 i; - for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) + for (i = 0; i < gBattleResources->bufferA[gActiveBattler][2]; i++) dst[i] = src[i]; - BtlController_EmitDataTransfer(1, gBattleBufferA[gActiveBattler][2], dst); + BtlController_EmitDataTransfer(1, gBattleResources->bufferA[gActiveBattler][2], dst); PlayerBufferExecCompleted(); } @@ -1963,13 +1963,13 @@ static void PlayerHandleSetMonData(void) u8 monToCheck; u8 i; - if (gBattleBufferA[gActiveBattler][2] == 0) + if (gBattleResources->bufferA[gActiveBattler][2] == 0) { SetPlayerMonData(gBattlerPartyIndexes[gActiveBattler]); } else { - monToCheck = gBattleBufferA[gActiveBattler][2]; + monToCheck = gBattleResources->bufferA[gActiveBattler][2]; for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) @@ -1982,11 +1982,11 @@ static void PlayerHandleSetMonData(void) static void SetPlayerMonData(u8 monId) { - struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBattler][3]; - struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBattler][3]; + struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleResources->bufferA[gActiveBattler][3]; + struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleResources->bufferA[gActiveBattler][3]; s32 i; - switch (gBattleBufferA[gActiveBattler][1]) + switch (gBattleResources->bufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: { @@ -2027,10 +2027,10 @@ static void SetPlayerMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < MAX_MON_MOVES; i++) @@ -2044,154 +2044,154 @@ static void SetPlayerMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBattler][4]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBattler][5]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBattler][6]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBattler][7]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleResources->bufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP2, &gBattleResources->bufferA[gActiveBattler][4]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP3, &gBattleResources->bufferA[gActiveBattler][5]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP4, &gBattleResources->bufferA[gActiveBattler][6]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &gBattleResources->bufferA[gActiveBattler][7]); break; case REQUEST_PPMOVE1_BATTLE: case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_OTID_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_EXP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HP_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_FRIENDSHIP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_POKERUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_LOCATION_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_LEVEL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_GAME_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_POKEBALL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ALL_IVS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][4]); - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][5]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][6]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][7]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][8]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleResources->bufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleResources->bufferA[gActiveBattler][4]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleResources->bufferA[gActiveBattler][5]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleResources->bufferA[gActiveBattler][6]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleResources->bufferA[gActiveBattler][7]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleResources->bufferA[gActiveBattler][8]); break; case REQUEST_HP_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CUTE_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SMART_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SHEEN_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_COOL_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CUTE_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SMART_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; } @@ -2200,11 +2200,11 @@ static void SetPlayerMonData(u8 monId) static void PlayerHandleSetRawMonData(void) { - u8 *dst = (u8 *)&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; + u8 *dst = (u8 *)&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleResources->bufferA[gActiveBattler][1]; u8 i; - for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) - dst[i] = gBattleBufferA[gActiveBattler][3 + i]; + for (i = 0; i < gBattleResources->bufferA[gActiveBattler][2]; i++) + dst[i] = gBattleResources->bufferA[gActiveBattler][3 + i]; PlayerBufferExecCompleted(); } @@ -2218,12 +2218,12 @@ static void PlayerHandleLoadMonSprite(void) static void PlayerHandleSwitchInAnim(void) { - ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleBufferA[gActiveBattler][2]); - gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1]; + ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleResources->bufferA[gActiveBattler][2]); + gBattlerPartyIndexes[gActiveBattler] = gBattleResources->bufferA[gActiveBattler][1]; BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); gActionSelectionCursor[gActiveBattler] = 0; gMoveSelectionCursor[gActiveBattler] = 0; - sub_805B258(gActiveBattler, gBattleBufferA[gActiveBattler][2]); + sub_805B258(gActiveBattler, gBattleResources->bufferA[gActiveBattler][2]); gBattlerControllerFuncs[gActiveBattler] = sub_805902C; } @@ -2232,7 +2232,7 @@ static void sub_805B258(u8 battlerId, bool8 dontClearSubstituteBit) u16 species; ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit); - gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1]; + gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1]; species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714); SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); @@ -2260,7 +2260,7 @@ static void sub_805B258(u8 battlerId, bool8 dontClearSubstituteBit) static void PlayerHandleReturnMonToBall(void) { - if (gBattleBufferA[gActiveBattler][1] == 0) + if (gBattleResources->bufferA[gActiveBattler][1] == 0) { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattlerControllerFuncs[gActiveBattler] = DoSwitchOutAnimation; @@ -2470,7 +2470,7 @@ static void PlayerHandleSuccessBallThrowAnim(void) static void PlayerHandleBallThrowAnim(void) { - u8 ballThrowCaseId = gBattleBufferA[gActiveBattler][1]; + u8 ballThrowCaseId = gBattleResources->bufferA[gActiveBattler][1]; gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId; gDoingBattleAnim = TRUE; @@ -2480,7 +2480,7 @@ static void PlayerHandleBallThrowAnim(void) static void PlayerHandlePause(void) { - u8 var = gBattleBufferA[gActiveBattler][1]; + u8 var = gBattleResources->bufferA[gActiveBattler][1]; // WTF is this?? while (var != 0) @@ -2493,14 +2493,14 @@ static void PlayerHandleMoveAnimation(void) { if (!mplay_80342A4(gActiveBattler)) { - u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); + u16 move = gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8); - gAnimMoveTurn = gBattleBufferA[gActiveBattler][3]; - gAnimMovePower = gBattleBufferA[gActiveBattler][4] | (gBattleBufferA[gActiveBattler][5] << 8); - gAnimMoveDmg = gBattleBufferA[gActiveBattler][6] | (gBattleBufferA[gActiveBattler][7] << 8) | (gBattleBufferA[gActiveBattler][8] << 16) | (gBattleBufferA[gActiveBattler][9] << 24); - gAnimFriendship = gBattleBufferA[gActiveBattler][10]; - gWeatherMoveAnim = gBattleBufferA[gActiveBattler][12] | (gBattleBufferA[gActiveBattler][13] << 8); - gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBattler][16]; + gAnimMoveTurn = gBattleResources->bufferA[gActiveBattler][3]; + gAnimMovePower = gBattleResources->bufferA[gActiveBattler][4] | (gBattleResources->bufferA[gActiveBattler][5] << 8); + gAnimMoveDmg = gBattleResources->bufferA[gActiveBattler][6] | (gBattleResources->bufferA[gActiveBattler][7] << 8) | (gBattleResources->bufferA[gActiveBattler][8] << 16) | (gBattleResources->bufferA[gActiveBattler][9] << 24); + gAnimFriendship = gBattleResources->bufferA[gActiveBattler][10]; + gWeatherMoveAnim = gBattleResources->bufferA[gActiveBattler][12] | (gBattleResources->bufferA[gActiveBattler][13] << 8); + gAnimDisableStructPtr = (struct DisableStruct *)&gBattleResources->bufferA[gActiveBattler][16]; gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality; if (IsMoveWithoutAnimation(move, gAnimMoveTurn)) // Always returns FALSE. { @@ -2517,8 +2517,8 @@ static void PlayerHandleMoveAnimation(void) static void PlayerDoMoveAnimation(void) { - u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); - u8 multihit = gBattleBufferA[gActiveBattler][11]; + u16 move = gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8); + u8 multihit = gBattleResources->bufferA[gActiveBattler][11]; switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { @@ -2556,7 +2556,7 @@ static void PlayerDoMoveAnimation(void) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { CopyAllBattleSpritesInvisibilities(); - TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; PlayerBufferExecCompleted(); } @@ -2570,7 +2570,7 @@ static void PlayerHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); + stringId = (u16*)(&gBattleResources->bufferA[gActiveBattler][2]); BufferStringBattle(*stringId); BattlePutTextOnWindow(gDisplayedStringBattle, 0); gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter2; @@ -2688,7 +2688,7 @@ static void PlayerHandleChooseItem(void) gBattlerInMenuId = gActiveBattler; for (i = 0; i < 3; i++) - gUnknown_0203CF00[i] = gBattleBufferA[gActiveBattler][1 + i]; + gUnknown_0203CF00[i] = gBattleResources->bufferA[gActiveBattler][1 + i]; } static void PlayerHandleChoosePokemon(void) @@ -2696,9 +2696,9 @@ static void PlayerHandleChoosePokemon(void) s32 i; for (i = 0; i < 3; i++) - gUnknown_0203CF00[i] = gBattleBufferA[gActiveBattler][4 + i]; + gUnknown_0203CF00[i] = gBattleResources->bufferA[gActiveBattler][4 + i]; - if (gBattleTypeFlags & BATTLE_TYPE_ARENA && (gBattleBufferA[gActiveBattler][1] & 0xF) != PARTY_CANT_SWITCH) + if (gBattleTypeFlags & BATTLE_TYPE_ARENA && (gBattleResources->bufferA[gActiveBattler][1] & 0xF) != PARTY_CANT_SWITCH) { BtlController_EmitChosenMonReturnValue(1, gBattlerPartyIndexes[gActiveBattler] + 1, gUnknown_0203CF00); PlayerBufferExecCompleted(); @@ -2706,10 +2706,10 @@ static void PlayerHandleChoosePokemon(void) else { gUnknown_03005D7C[gActiveBattler] = CreateTask(TaskDummy, 0xFF); - gTasks[gUnknown_03005D7C[gActiveBattler]].data[0] = gBattleBufferA[gActiveBattler][1] & 0xF; - *(&gBattleStruct->battlerPreventingSwitchout) = gBattleBufferA[gActiveBattler][1] >> 4; - *(&gBattleStruct->field_8B) = gBattleBufferA[gActiveBattler][2]; - *(&gBattleStruct->abilityPreventingSwitchout) = gBattleBufferA[gActiveBattler][3]; + gTasks[gUnknown_03005D7C[gActiveBattler]].data[0] = gBattleResources->bufferA[gActiveBattler][1] & 0xF; + *(&gBattleStruct->battlerPreventingSwitchout) = gBattleResources->bufferA[gActiveBattler][1] >> 4; + *(&gBattleStruct->field_8B) = gBattleResources->bufferA[gActiveBattler][2]; + *(&gBattleStruct->abilityPreventingSwitchout) = gBattleResources->bufferA[gActiveBattler][3]; BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0); gBattlerControllerFuncs[gActiveBattler] = OpenPartyMenuToChooseMon; gBattlerInMenuId = gActiveBattler; @@ -2728,7 +2728,7 @@ static void PlayerHandleHealthBarUpdate(void) s16 hpVal; LoadBattleBarGfx(0); - hpVal = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); + hpVal = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8); if (hpVal > 0) gUnknown_0203CD70 += hpVal; @@ -2753,7 +2753,7 @@ static void PlayerHandleHealthBarUpdate(void) static void PlayerHandleExpUpdate(void) { - u8 monId = gBattleBufferA[gActiveBattler][1]; + u8 monId = gBattleResources->bufferA[gActiveBattler][1]; if (GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL) >= MAX_LEVEL) { @@ -2766,7 +2766,7 @@ static void PlayerHandleExpUpdate(void) LoadBattleBarGfx(1); GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES); // Unused return value. - expPointsToGive = T1_READ_16(&gBattleBufferA[gActiveBattler][2]); + expPointsToGive = T1_READ_16(&gBattleResources->bufferA[gActiveBattler][2]); taskId = CreateTask(Task_GiveExpToMon, 10); gTasks[taskId].tExpTask_monId = monId; gTasks[taskId].tExpTask_gainedExp = expPointsToGive; @@ -2797,15 +2797,15 @@ static void PlayerHandleStatusAnimation(void) { if (!mplay_80342A4(gActiveBattler)) { - InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], - gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); + InitAndLaunchChosenStatusAnimation(gBattleResources->bufferA[gActiveBattler][1], + gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8) | (gBattleResources->bufferA[gActiveBattler][4] << 16) | (gBattleResources->bufferA[gActiveBattler][5] << 24)); gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; } } static void PlayerHandleStatusXor(void) { - u8 val = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_STATUS) ^ gBattleBufferA[gActiveBattler][1]; + u8 val = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_STATUS) ^ gBattleResources->bufferA[gActiveBattler][1]; SetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_STATUS, &val); PlayerBufferExecCompleted(); @@ -2818,13 +2818,13 @@ static void PlayerHandleDataTransfer(void) static void PlayerHandleDMA3Transfer(void) { - u32 dstArg = gBattleBufferA[gActiveBattler][1] - | (gBattleBufferA[gActiveBattler][2] << 8) - | (gBattleBufferA[gActiveBattler][3] << 16) - | (gBattleBufferA[gActiveBattler][4] << 24); - u16 sizeArg = gBattleBufferA[gActiveBattler][5] | (gBattleBufferA[gActiveBattler][6] << 8); + u32 dstArg = gBattleResources->bufferA[gActiveBattler][1] + | (gBattleResources->bufferA[gActiveBattler][2] << 8) + | (gBattleResources->bufferA[gActiveBattler][3] << 16) + | (gBattleResources->bufferA[gActiveBattler][4] << 24); + u16 sizeArg = gBattleResources->bufferA[gActiveBattler][5] | (gBattleResources->bufferA[gActiveBattler][6] << 8); - const u8 *src = &gBattleBufferA[gActiveBattler][7]; + const u8 *src = &gBattleResources->bufferA[gActiveBattler][7]; u8 *dst = (u8*)(dstArg); u32 size = sizeArg; @@ -2845,7 +2845,7 @@ static void PlayerHandleDMA3Transfer(void) static void PlayerHandlePlayBGM(void) { - PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + PlayBGM(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); PlayerBufferExecCompleted(); } @@ -2886,7 +2886,7 @@ static void PlayerHandleCmd37(void) static void PlayerHandleCmd38(void) { - gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBattler][1]; + gUnknown_02022D0C.field_0 = gBattleResources->bufferA[gActiveBattler][1]; PlayerBufferExecCompleted(); } @@ -2931,20 +2931,20 @@ static void PlayerHandlePlaySE(void) else pan = SOUND_PAN_TARGET; - PlaySE12WithPanning(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8), pan); + PlaySE12WithPanning(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8), pan); PlayerBufferExecCompleted(); } static void PlayerHandlePlayFanfareOrBGM(void) { - if (gBattleBufferA[gActiveBattler][3]) + if (gBattleResources->bufferA[gActiveBattler][3]) { BattleStopLowHpSound(); - PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + PlayBGM(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); } else { - PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + PlayFanfare(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); } PlayerBufferExecCompleted(); @@ -2960,7 +2960,7 @@ static void PlayerHandleFaintingCry(void) static void PlayerHandleIntroSlide(void) { - HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); + HandleIntroSlide(gBattleResources->bufferA[gActiveBattler][1]); gIntroSlideFlags |= 1; PlayerBufferExecCompleted(); } @@ -3019,15 +3019,15 @@ static void task05_08033660(u8 taskId) gActiveBattler = gTasks[taskId].data[0]; if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; sub_805B258(gActiveBattler, FALSE); } else { - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; sub_805B258(gActiveBattler, FALSE); gActiveBattler ^= BIT_FLANK; - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); sub_805B258(gActiveBattler, FALSE); gActiveBattler ^= BIT_FLANK; @@ -3040,17 +3040,17 @@ static void task05_08033660(u8 taskId) static void PlayerHandleDrawPartyStatusSummary(void) { - if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) + if (gBattleResources->bufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { PlayerBufferExecCompleted(); } else { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1; - gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); + gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleResources->bufferA[gActiveBattler][4], gBattleResources->bufferA[gActiveBattler][1], gBattleResources->bufferA[gActiveBattler][2]); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; - if (gBattleBufferA[gActiveBattler][2] != 0) + if (gBattleResources->bufferA[gActiveBattler][2] != 0) gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; gBattlerControllerFuncs[gActiveBattler] = sub_805CE38; @@ -3084,7 +3084,7 @@ static void PlayerHandleSpriteInvisibility(void) { if (IsBattlerSpritePresent(gActiveBattler)) { - gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1]; + gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleResources->bufferA[gActiveBattler][1]; CopyBattleSpriteInvisibility(gActiveBattler); } PlayerBufferExecCompleted(); @@ -3094,8 +3094,8 @@ static void PlayerHandleBattleAnimation(void) { if (!mplay_80342A4(gActiveBattler)) { - u8 animationId = gBattleBufferA[gActiveBattler][1]; - u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); + u8 animationId = gBattleResources->bufferA[gActiveBattler][1]; + u16 argument = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8); if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) PlayerBufferExecCompleted(); @@ -3108,8 +3108,8 @@ static void PlayerHandleBattleAnimation(void) static void PlayerHandleLinkStandbyMsg(void) { - sub_81851A8(&gBattleBufferA[gActiveBattler][2]); - switch (gBattleBufferA[gActiveBattler][1]) + sub_81851A8(&gBattleResources->bufferA[gActiveBattler][2]); + switch (gBattleResources->bufferA[gActiveBattler][1]) { case 0: PrintLinkStandbyMsg(); @@ -3127,7 +3127,7 @@ static void PlayerHandleLinkStandbyMsg(void) static void PlayerHandleResetActionMoveSelection(void) { - switch (gBattleBufferA[gActiveBattler][1]) + switch (gBattleResources->bufferA[gActiveBattler][1]) { case RESET_ACTION_MOVE_SELECTION: gActionSelectionCursor[gActiveBattler] = 0; @@ -3145,9 +3145,9 @@ static void PlayerHandleResetActionMoveSelection(void) static void PlayerHandleCmd55(void) { - sub_81851A8(&gBattleBufferA[gActiveBattler][4]); - gBattleOutcome = gBattleBufferA[gActiveBattler][1]; - gSaveBlock2Ptr->frontier.field_CA9_b = gBattleBufferA[gActiveBattler][2]; + sub_81851A8(&gBattleResources->bufferA[gActiveBattler][4]); + gBattleOutcome = gBattleResources->bufferA[gActiveBattler][1]; + gSaveBlock2Ptr->frontier.field_CA9_b = gBattleResources->bufferA[gActiveBattler][2]; FadeOutMapMusic(5); BeginFastPaletteFade(3); PlayerBufferExecCompleted(); diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c index 06a7f9b30..d1762ed3f 100644 --- a/src/battle_controller_player_partner.c +++ b/src/battle_controller_player_partner.c @@ -194,8 +194,8 @@ static void PlayerPartnerBufferRunCommand(void) { if (gBattleControllerExecFlags & gBitTable[gActiveBattler]) { - if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sPlayerPartnerBufferCommands)) - sPlayerPartnerBufferCommands[gBattleBufferA[gActiveBattler][0]](); + if (gBattleResources->bufferA[gActiveBattler][0] < ARRAY_COUNT(sPlayerPartnerBufferCommands)) + sPlayerPartnerBufferCommands[gBattleResources->bufferA[gActiveBattler][0]](); else PlayerPartnerBufferExecCompleted(); } @@ -595,7 +595,7 @@ static void PlayerPartnerBufferExecCompleted(void) u8 playerId = GetMultiplayerId(); PrepareBufferDataTransferLink(2, 4, &playerId); - gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; + gBattleResources->bufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else { @@ -622,13 +622,13 @@ static void PlayerPartnerHandleGetMonData(void) u8 monToCheck; s32 i; - if (gBattleBufferA[gActiveBattler][2] == 0) + if (gBattleResources->bufferA[gActiveBattler][2] == 0) { size += CopyPlayerPartnerMonData(gBattlerPartyIndexes[gActiveBattler], monData); } else { - monToCheck = gBattleBufferA[gActiveBattler][2]; + monToCheck = gBattleResources->bufferA[gActiveBattler][2]; for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) @@ -650,7 +650,7 @@ static u32 CopyPlayerPartnerMonData(u8 monId, u8 *dst) u32 data32; s32 size = 0; - switch (gBattleBufferA[gActiveBattler][1]) + switch (gBattleResources->bufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: battleMon.species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES); @@ -716,7 +716,7 @@ static u32 CopyPlayerPartnerMonData(u8 monId, u8 *dst) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); + data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); dst[0] = data16; dst[1] = data16 >> 8; size = 2; @@ -731,7 +731,7 @@ static u32 CopyPlayerPartnerMonData(u8 monId, u8 *dst) case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); size = 1; break; case REQUEST_OTID_BATTLE: @@ -956,13 +956,13 @@ static void PlayerPartnerHandleSetMonData(void) u8 monToCheck; u8 i; - if (gBattleBufferA[gActiveBattler][2] == 0) + if (gBattleResources->bufferA[gActiveBattler][2] == 0) { SetPlayerPartnerMonData(gBattlerPartyIndexes[gActiveBattler]); } else { - monToCheck = gBattleBufferA[gActiveBattler][2]; + monToCheck = gBattleResources->bufferA[gActiveBattler][2]; for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) @@ -975,11 +975,11 @@ static void PlayerPartnerHandleSetMonData(void) static void SetPlayerPartnerMonData(u8 monId) { - struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBattler][3]; - struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBattler][3]; + struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleResources->bufferA[gActiveBattler][3]; + struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleResources->bufferA[gActiveBattler][3]; s32 i; - switch (gBattleBufferA[gActiveBattler][1]) + switch (gBattleResources->bufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: { @@ -1020,10 +1020,10 @@ static void SetPlayerPartnerMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < MAX_MON_MOVES; i++) @@ -1037,154 +1037,154 @@ static void SetPlayerPartnerMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBattler][4]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBattler][5]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBattler][6]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBattler][7]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleResources->bufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP2, &gBattleResources->bufferA[gActiveBattler][4]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP3, &gBattleResources->bufferA[gActiveBattler][5]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP4, &gBattleResources->bufferA[gActiveBattler][6]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &gBattleResources->bufferA[gActiveBattler][7]); break; case REQUEST_PPMOVE1_BATTLE: case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_OTID_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_EXP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HP_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_FRIENDSHIP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_POKERUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_LOCATION_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_LEVEL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_GAME_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_POKEBALL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ALL_IVS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][4]); - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][5]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][6]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][7]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][8]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleResources->bufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleResources->bufferA[gActiveBattler][4]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleResources->bufferA[gActiveBattler][5]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleResources->bufferA[gActiveBattler][6]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleResources->bufferA[gActiveBattler][7]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleResources->bufferA[gActiveBattler][8]); break; case REQUEST_HP_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CUTE_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SMART_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SHEEN_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_COOL_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CUTE_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SMART_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; } @@ -1193,11 +1193,11 @@ static void SetPlayerPartnerMonData(u8 monId) static void PlayerPartnerHandleSetRawMonData(void) { - u8 *dst = (u8 *)&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; + u8 *dst = (u8 *)&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleResources->bufferA[gActiveBattler][1]; u8 i; - for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) - dst[i] = gBattleBufferA[gActiveBattler][3 + i]; + for (i = 0; i < gBattleResources->bufferA[gActiveBattler][2]; i++) + dst[i] = gBattleResources->bufferA[gActiveBattler][3 + i]; PlayerPartnerBufferExecCompleted(); } @@ -1223,10 +1223,10 @@ static void PlayerPartnerHandleLoadMonSprite(void) static void PlayerPartnerHandleSwitchInAnim(void) { - ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleBufferA[gActiveBattler][2]); - gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1]; + ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleResources->bufferA[gActiveBattler][2]); + gBattlerPartyIndexes[gActiveBattler] = gBattleResources->bufferA[gActiveBattler][1]; BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); - sub_81BD0E4(gActiveBattler, gBattleBufferA[gActiveBattler][2]); + sub_81BD0E4(gActiveBattler, gBattleResources->bufferA[gActiveBattler][2]); gBattlerControllerFuncs[gActiveBattler] = sub_81BBAE8; } @@ -1235,7 +1235,7 @@ static void sub_81BD0E4(u8 battlerId, bool8 dontClearSubstituteBit) u16 species; ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit); - gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1]; + gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1]; species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714); SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); @@ -1263,7 +1263,7 @@ static void sub_81BD0E4(u8 battlerId, bool8 dontClearSubstituteBit) static void PlayerPartnerHandleReturnMonToBall(void) { - if (gBattleBufferA[gActiveBattler][1] == 0) + if (gBattleResources->bufferA[gActiveBattler][1] == 0) { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattlerControllerFuncs[gActiveBattler] = DoSwitchOutAnimation; @@ -1418,14 +1418,14 @@ static void PlayerPartnerHandleMoveAnimation(void) { if (!mplay_80342A4(gActiveBattler)) { - u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); + u16 move = gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8); - gAnimMoveTurn = gBattleBufferA[gActiveBattler][3]; - gAnimMovePower = gBattleBufferA[gActiveBattler][4] | (gBattleBufferA[gActiveBattler][5] << 8); - gAnimMoveDmg = gBattleBufferA[gActiveBattler][6] | (gBattleBufferA[gActiveBattler][7] << 8) | (gBattleBufferA[gActiveBattler][8] << 16) | (gBattleBufferA[gActiveBattler][9] << 24); - gAnimFriendship = gBattleBufferA[gActiveBattler][10]; - gWeatherMoveAnim = gBattleBufferA[gActiveBattler][12] | (gBattleBufferA[gActiveBattler][13] << 8); - gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBattler][16]; + gAnimMoveTurn = gBattleResources->bufferA[gActiveBattler][3]; + gAnimMovePower = gBattleResources->bufferA[gActiveBattler][4] | (gBattleResources->bufferA[gActiveBattler][5] << 8); + gAnimMoveDmg = gBattleResources->bufferA[gActiveBattler][6] | (gBattleResources->bufferA[gActiveBattler][7] << 8) | (gBattleResources->bufferA[gActiveBattler][8] << 16) | (gBattleResources->bufferA[gActiveBattler][9] << 24); + gAnimFriendship = gBattleResources->bufferA[gActiveBattler][10]; + gWeatherMoveAnim = gBattleResources->bufferA[gActiveBattler][12] | (gBattleResources->bufferA[gActiveBattler][13] << 8); + gAnimDisableStructPtr = (struct DisableStruct *)&gBattleResources->bufferA[gActiveBattler][16]; gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality; if (IsMoveWithoutAnimation(move, gAnimMoveTurn)) // always returns FALSE { @@ -1441,8 +1441,8 @@ static void PlayerPartnerHandleMoveAnimation(void) static void PlayerPartnerDoMoveAnimation(void) { - u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); - u8 multihit = gBattleBufferA[gActiveBattler][11]; + u16 move = gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8); + u8 multihit = gBattleResources->bufferA[gActiveBattler][11]; switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { @@ -1480,7 +1480,7 @@ static void PlayerPartnerDoMoveAnimation(void) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { CopyAllBattleSpritesInvisibilities(); - TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; PlayerPartnerBufferExecCompleted(); } @@ -1494,7 +1494,7 @@ static void PlayerPartnerHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); + stringId = (u16*)(&gBattleResources->bufferA[gActiveBattler][2]); BufferStringBattle(*stringId); BattlePutTextOnWindow(gDisplayedStringBattle, 0); gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter2; @@ -1519,7 +1519,7 @@ static void PlayerPartnerHandleUnknownYesNoBox(void) static void PlayerPartnerHandleChooseMove(void) { u8 chosenMoveId; - struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]); + struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleResources->bufferA[gActiveBattler][4]); BattleAI_SetupAIData(0xF); chosenMoveId = BattleAI_ChooseMoveOrAction(); @@ -1577,7 +1577,7 @@ static void PlayerPartnerHandleHealthBarUpdate(void) s16 hpVal; LoadBattleBarGfx(0); - hpVal = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); + hpVal = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8); if (hpVal != INSTANT_HP_BAR_DROP) { @@ -1598,7 +1598,7 @@ static void PlayerPartnerHandleHealthBarUpdate(void) static void PlayerPartnerHandleExpUpdate(void) { - u8 monId = gBattleBufferA[gActiveBattler][1]; + u8 monId = gBattleResources->bufferA[gActiveBattler][1]; if (GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL) >= MAX_LEVEL) { @@ -1611,7 +1611,7 @@ static void PlayerPartnerHandleExpUpdate(void) LoadBattleBarGfx(1); GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES); // unused return value - expPointsToGive = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); + expPointsToGive = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8); taskId = CreateTask(Task_GiveExpToMon, 10); gTasks[taskId].tExpTask_monId = monId; gTasks[taskId].tExpTask_gainedExp = expPointsToGive; @@ -1642,8 +1642,8 @@ static void PlayerPartnerHandleStatusAnimation(void) { if (!mplay_80342A4(gActiveBattler)) { - InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], - gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); + InitAndLaunchChosenStatusAnimation(gBattleResources->bufferA[gActiveBattler][1], + gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8) | (gBattleResources->bufferA[gActiveBattler][4] << 16) | (gBattleResources->bufferA[gActiveBattler][5] << 24)); gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; } } @@ -1701,7 +1701,7 @@ static void PlayerPartnerHandleCmd37(void) static void PlayerPartnerHandleCmd38(void) { - gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBattler][1]; + gUnknown_02022D0C.field_0 = gBattleResources->bufferA[gActiveBattler][1]; PlayerPartnerBufferExecCompleted(); } @@ -1746,20 +1746,20 @@ static void PlayerPartnerHandlePlaySE(void) else pan = SOUND_PAN_TARGET; - PlaySE12WithPanning(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8), pan); + PlaySE12WithPanning(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8), pan); PlayerPartnerBufferExecCompleted(); } static void PlayerPartnerHandlePlayFanfareOrBGM(void) { - if (gBattleBufferA[gActiveBattler][3]) + if (gBattleResources->bufferA[gActiveBattler][3]) { BattleStopLowHpSound(); - PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + PlayBGM(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); } else { - PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + PlayFanfare(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); } PlayerPartnerBufferExecCompleted(); @@ -1775,7 +1775,7 @@ static void PlayerPartnerHandleFaintingCry(void) static void PlayerPartnerHandleIntroSlide(void) { - HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); + HandleIntroSlide(gBattleResources->bufferA[gActiveBattler][1]); gIntroSlideFlags |= 1; PlayerPartnerBufferExecCompleted(); } @@ -1839,15 +1839,15 @@ static void sub_81BE2C8(u8 taskId) gActiveBattler = gTasks[taskId].data[0]; if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; sub_81BD0E4(gActiveBattler, FALSE); } else { - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; sub_81BD0E4(gActiveBattler, FALSE); gActiveBattler ^= BIT_FLANK; - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); sub_81BD0E4(gActiveBattler, FALSE); gActiveBattler ^= BIT_FLANK; @@ -1860,17 +1860,17 @@ static void sub_81BE2C8(u8 taskId) static void PlayerPartnerHandleDrawPartyStatusSummary(void) { - if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) + if (gBattleResources->bufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { PlayerPartnerBufferExecCompleted(); } else { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1; - gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); + gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleResources->bufferA[gActiveBattler][4], gBattleResources->bufferA[gActiveBattler][1], gBattleResources->bufferA[gActiveBattler][2]); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; - if (gBattleBufferA[gActiveBattler][2] != 0) + if (gBattleResources->bufferA[gActiveBattler][2] != 0) gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; gBattlerControllerFuncs[gActiveBattler] = sub_81BE498; @@ -1902,7 +1902,7 @@ static void PlayerPartnerHandleSpriteInvisibility(void) { if (IsBattlerSpritePresent(gActiveBattler)) { - gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1]; + gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleResources->bufferA[gActiveBattler][1]; CopyBattleSpriteInvisibility(gActiveBattler); } PlayerPartnerBufferExecCompleted(); @@ -1912,8 +1912,8 @@ static void PlayerPartnerHandleBattleAnimation(void) { if (!mplay_80342A4(gActiveBattler)) { - u8 animationId = gBattleBufferA[gActiveBattler][1]; - u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); + u8 animationId = gBattleResources->bufferA[gActiveBattler][1]; + u16 argument = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8); if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) PlayerPartnerBufferExecCompleted(); @@ -1934,7 +1934,7 @@ static void PlayerPartnerHandleResetActionMoveSelection(void) static void PlayerPartnerHandleCmd55(void) { - gBattleOutcome = gBattleBufferA[gActiveBattler][1]; + gBattleOutcome = gBattleResources->bufferA[gActiveBattler][1]; FadeOutMapMusic(5); BeginFastPaletteFade(3); PlayerPartnerBufferExecCompleted(); diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index 392d79dad..a379567d0 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -183,8 +183,8 @@ static void RecordedOpponentBufferRunCommand(void) { if (gBattleControllerExecFlags & gBitTable[gActiveBattler]) { - if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sRecordedOpponentBufferCommands)) - sRecordedOpponentBufferCommands[gBattleBufferA[gActiveBattler][0]](); + if (gBattleResources->bufferA[gActiveBattler][0] < ARRAY_COUNT(sRecordedOpponentBufferCommands)) + sRecordedOpponentBufferCommands[gBattleResources->bufferA[gActiveBattler][0]](); else RecordedOpponentBufferExecCompleted(); } @@ -518,7 +518,7 @@ static void RecordedOpponentBufferExecCompleted(void) u8 playerId = GetMultiplayerId(); PrepareBufferDataTransferLink(2, 4, &playerId); - gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; + gBattleResources->bufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else { @@ -533,13 +533,13 @@ static void RecordedOpponentHandleGetMonData(void) u8 monToCheck; s32 i; - if (gBattleBufferA[gActiveBattler][2] == 0) + if (gBattleResources->bufferA[gActiveBattler][2] == 0) { size += CopyRecordedOpponentMonData(gBattlerPartyIndexes[gActiveBattler], monData); } else { - monToCheck = gBattleBufferA[gActiveBattler][2]; + monToCheck = gBattleResources->bufferA[gActiveBattler][2]; for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) @@ -561,7 +561,7 @@ static u32 CopyRecordedOpponentMonData(u8 monId, u8 *dst) u32 data32; s32 size = 0; - switch (gBattleBufferA[gActiveBattler][1]) + switch (gBattleResources->bufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: battleMon.species = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES); @@ -627,7 +627,7 @@ static u32 CopyRecordedOpponentMonData(u8 monId, u8 *dst) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - data16 = GetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); + data16 = GetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); dst[0] = data16; dst[1] = data16 >> 8; size = 2; @@ -642,7 +642,7 @@ static u32 CopyRecordedOpponentMonData(u8 monId, u8 *dst) case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); + dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); size = 1; break; case REQUEST_OTID_BATTLE: @@ -867,13 +867,13 @@ static void RecordedOpponentHandleSetMonData(void) u8 monToCheck; u8 i; - if (gBattleBufferA[gActiveBattler][2] == 0) + if (gBattleResources->bufferA[gActiveBattler][2] == 0) { SetRecordedOpponentMonData(gBattlerPartyIndexes[gActiveBattler]); } else { - monToCheck = gBattleBufferA[gActiveBattler][2]; + monToCheck = gBattleResources->bufferA[gActiveBattler][2]; for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) @@ -886,11 +886,11 @@ static void RecordedOpponentHandleSetMonData(void) static void SetRecordedOpponentMonData(u8 monId) { - struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBattler][3]; - struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBattler][3]; + struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleResources->bufferA[gActiveBattler][3]; + struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleResources->bufferA[gActiveBattler][3]; s32 i; - switch (gBattleBufferA[gActiveBattler][1]) + switch (gBattleResources->bufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: { @@ -931,10 +931,10 @@ static void SetRecordedOpponentMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HELD_ITEM, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < MAX_MON_MOVES; i++) @@ -948,165 +948,165 @@ static void SetRecordedOpponentMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBattler][4]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBattler][5]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBattler][6]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBattler][7]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP1, &gBattleResources->bufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP2, &gBattleResources->bufferA[gActiveBattler][4]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP3, &gBattleResources->bufferA[gActiveBattler][5]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP4, &gBattleResources->bufferA[gActiveBattler][6]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP_BONUSES, &gBattleResources->bufferA[gActiveBattler][7]); break; case REQUEST_PPMOVE1_BATTLE: case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_OTID_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_OT_ID, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_EXP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_EXP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HP_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_FRIENDSHIP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_FRIENDSHIP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_POKERUS_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_POKERUS, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_LOCATION_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MET_LOCATION, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_LEVEL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MET_LEVEL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_GAME_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MET_GAME, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_POKEBALL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_POKEBALL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ALL_IVS_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); - SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][4]); - SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][5]); - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][6]); - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][7]); - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][8]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleResources->bufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleResources->bufferA[gActiveBattler][4]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleResources->bufferA[gActiveBattler][5]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleResources->bufferA[gActiveBattler][6]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleResources->bufferA[gActiveBattler][7]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleResources->bufferA[gActiveBattler][8]); break; case REQUEST_HP_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_PERSONALITY, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_CHECKSUM, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_STATUS, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_LEVEL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MAX_HP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_COOL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CUTE_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_CUTE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SMART_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SMART, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SHEEN_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SHEEN, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_COOL_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_COOL_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CUTE_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_CUTE_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SMART_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SMART_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; } } static void RecordedOpponentHandleSetRawMonData(void) { - u8 *dst = (u8 *)&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; + u8 *dst = (u8 *)&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleResources->bufferA[gActiveBattler][1]; u8 i; - for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) - dst[i] = gBattleBufferA[gActiveBattler][3 + i]; + for (i = 0; i < gBattleResources->bufferA[gActiveBattler][2]; i++) + dst[i] = gBattleResources->bufferA[gActiveBattler][3 + i]; RecordedOpponentBufferExecCompleted(); } @@ -1135,8 +1135,8 @@ static void RecordedOpponentHandleLoadMonSprite(void) static void RecordedOpponentHandleSwitchInAnim(void) { - gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1]; - sub_81885D8(gActiveBattler, gBattleBufferA[gActiveBattler][2]); + gBattlerPartyIndexes[gActiveBattler] = gBattleResources->bufferA[gActiveBattler][1]; + sub_81885D8(gActiveBattler, gBattleResources->bufferA[gActiveBattler][2]); gBattlerControllerFuncs[gActiveBattler] = sub_8187084; } @@ -1145,7 +1145,7 @@ static void sub_81885D8(u8 battlerId, bool8 dontClearSubstituteBit) u16 species; ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit); - gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1]; + gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1]; species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battlerId]], battlerId); @@ -1173,7 +1173,7 @@ static void sub_81885D8(u8 battlerId, bool8 dontClearSubstituteBit) static void RecordedOpponentHandleReturnMonToBall(void) { - if (gBattleBufferA[gActiveBattler][1] == 0) + if (gBattleResources->bufferA[gActiveBattler][1] == 0) { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattlerControllerFuncs[gActiveBattler] = DoSwitchOutAnimation; @@ -1322,14 +1322,14 @@ static void RecordedOpponentHandleMoveAnimation(void) { if (!mplay_80342A4(gActiveBattler)) { - u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); + u16 move = gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8); - gAnimMoveTurn = gBattleBufferA[gActiveBattler][3]; - gAnimMovePower = gBattleBufferA[gActiveBattler][4] | (gBattleBufferA[gActiveBattler][5] << 8); - gAnimMoveDmg = gBattleBufferA[gActiveBattler][6] | (gBattleBufferA[gActiveBattler][7] << 8) | (gBattleBufferA[gActiveBattler][8] << 16) | (gBattleBufferA[gActiveBattler][9] << 24); - gAnimFriendship = gBattleBufferA[gActiveBattler][10]; - gWeatherMoveAnim = gBattleBufferA[gActiveBattler][12] | (gBattleBufferA[gActiveBattler][13] << 8); - gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBattler][16]; + gAnimMoveTurn = gBattleResources->bufferA[gActiveBattler][3]; + gAnimMovePower = gBattleResources->bufferA[gActiveBattler][4] | (gBattleResources->bufferA[gActiveBattler][5] << 8); + gAnimMoveDmg = gBattleResources->bufferA[gActiveBattler][6] | (gBattleResources->bufferA[gActiveBattler][7] << 8) | (gBattleResources->bufferA[gActiveBattler][8] << 16) | (gBattleResources->bufferA[gActiveBattler][9] << 24); + gAnimFriendship = gBattleResources->bufferA[gActiveBattler][10]; + gWeatherMoveAnim = gBattleResources->bufferA[gActiveBattler][12] | (gBattleResources->bufferA[gActiveBattler][13] << 8); + gAnimDisableStructPtr = (struct DisableStruct *)&gBattleResources->bufferA[gActiveBattler][16]; gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality; if (IsMoveWithoutAnimation(move, gAnimMoveTurn)) // always returns FALSE { @@ -1345,8 +1345,8 @@ static void RecordedOpponentHandleMoveAnimation(void) static void RecordedOpponentDoMoveAnimation(void) { - u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); - u8 multihit = gBattleBufferA[gActiveBattler][11]; + u16 move = gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8); + u8 multihit = gBattleResources->bufferA[gActiveBattler][11]; switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { @@ -1384,7 +1384,7 @@ static void RecordedOpponentDoMoveAnimation(void) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { CopyAllBattleSpritesInvisibilities(); - TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; RecordedOpponentBufferExecCompleted(); } @@ -1398,7 +1398,7 @@ static void RecordedOpponentHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); + stringId = (u16*)(&gBattleResources->bufferA[gActiveBattler][2]); BufferStringBattle(*stringId); BattlePutTextOnWindow(gDisplayedStringBattle, 0); gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; @@ -1458,7 +1458,7 @@ static void RecordedOpponentHandleHealthBarUpdate(void) s16 hpVal; LoadBattleBarGfx(0); - hpVal = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); + hpVal = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8); if (hpVal != INSTANT_HP_BAR_DROP) { @@ -1499,8 +1499,8 @@ static void RecordedOpponentHandleStatusAnimation(void) { if (!mplay_80342A4(gActiveBattler)) { - InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], - gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); + InitAndLaunchChosenStatusAnimation(gBattleResources->bufferA[gActiveBattler][1], + gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8) | (gBattleResources->bufferA[gActiveBattler][4] << 16) | (gBattleResources->bufferA[gActiveBattler][5] << 24)); gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; } } @@ -1558,7 +1558,7 @@ static void RecordedOpponentHandleCmd37(void) static void RecordedOpponentHandleCmd38(void) { - gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBattler][1]; + gUnknown_02022D0C.field_0 = gBattleResources->bufferA[gActiveBattler][1]; RecordedOpponentBufferExecCompleted(); } @@ -1603,20 +1603,20 @@ static void RecordedOpponentHandlePlaySE(void) else pan = SOUND_PAN_TARGET; - PlaySE12WithPanning(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8), pan); + PlaySE12WithPanning(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8), pan); RecordedOpponentBufferExecCompleted(); } static void RecordedOpponentHandlePlayFanfareOrBGM(void) { - if (gBattleBufferA[gActiveBattler][3]) + if (gBattleResources->bufferA[gActiveBattler][3]) { BattleStopLowHpSound(); - PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + PlayBGM(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); } else { - PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + PlayFanfare(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); } RecordedOpponentBufferExecCompleted(); @@ -1632,7 +1632,7 @@ static void RecordedOpponentHandleFaintingCry(void) static void RecordedOpponentHandleIntroSlide(void) { - HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); + HandleIntroSlide(gBattleResources->bufferA[gActiveBattler][1]); gIntroSlideFlags |= 1; RecordedOpponentBufferExecCompleted(); } @@ -1668,15 +1668,15 @@ static void sub_8189548(u8 taskId) gActiveBattler = gTasks[taskId].data[0]; if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; sub_81885D8(gActiveBattler, FALSE); } else { - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; sub_81885D8(gActiveBattler, FALSE); gActiveBattler ^= BIT_FLANK; - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; sub_81885D8(gActiveBattler, FALSE); gActiveBattler ^= BIT_FLANK; } @@ -1694,7 +1694,7 @@ static void sub_818962C(struct Sprite *sprite) static void RecordedOpponentHandleDrawPartyStatusSummary(void) { - if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) + if (gBattleResources->bufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { RecordedOpponentBufferExecCompleted(); } @@ -1702,7 +1702,7 @@ static void RecordedOpponentHandleDrawPartyStatusSummary(void) { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1; - if (gBattleBufferA[gActiveBattler][2] != 0) + if (gBattleResources->bufferA[gActiveBattler][2] != 0) { if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1E < 2) { @@ -1715,10 +1715,10 @@ static void RecordedOpponentHandleDrawPartyStatusSummary(void) } } - gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); + gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleResources->bufferA[gActiveBattler][4], gBattleResources->bufferA[gActiveBattler][1], gBattleResources->bufferA[gActiveBattler][2]); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; - if (gBattleBufferA[gActiveBattler][2] != 0) + if (gBattleResources->bufferA[gActiveBattler][2] != 0) gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; gBattlerControllerFuncs[gActiveBattler] = sub_818975C; @@ -1750,7 +1750,7 @@ static void RecordedOpponentHandleSpriteInvisibility(void) { if (IsBattlerSpritePresent(gActiveBattler)) { - gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1]; + gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleResources->bufferA[gActiveBattler][1]; CopyBattleSpriteInvisibility(gActiveBattler); } RecordedOpponentBufferExecCompleted(); @@ -1760,8 +1760,8 @@ static void RecordedOpponentHandleBattleAnimation(void) { if (!mplay_80342A4(gActiveBattler)) { - u8 animationId = gBattleBufferA[gActiveBattler][1]; - u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); + u8 animationId = gBattleResources->bufferA[gActiveBattler][1]; + u16 argument = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8); if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) RecordedOpponentBufferExecCompleted(); @@ -1782,10 +1782,10 @@ static void RecordedOpponentHandleResetActionMoveSelection(void) static void RecordedOpponentHandleCmd55(void) { - if (gBattleBufferA[gActiveBattler][1] == B_OUTCOME_DREW) - gBattleOutcome = gBattleBufferA[gActiveBattler][1]; + if (gBattleResources->bufferA[gActiveBattler][1] == B_OUTCOME_DREW) + gBattleOutcome = gBattleResources->bufferA[gActiveBattler][1]; else - gBattleOutcome = gBattleBufferA[gActiveBattler][1] ^ B_OUTCOME_DREW; + gBattleOutcome = gBattleResources->bufferA[gActiveBattler][1] ^ B_OUTCOME_DREW; FadeOutMapMusic(5); BeginFastPaletteFade(3); diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index 9055fc16b..99f50b7ba 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -176,8 +176,8 @@ static void RecordedPlayerBufferRunCommand(void) { if (gBattleControllerExecFlags & gBitTable[gActiveBattler]) { - if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sRecordedPlayerBufferCommands)) - sRecordedPlayerBufferCommands[gBattleBufferA[gActiveBattler][0]](); + if (gBattleResources->bufferA[gActiveBattler][0] < ARRAY_COUNT(sRecordedPlayerBufferCommands)) + sRecordedPlayerBufferCommands[gBattleResources->bufferA[gActiveBattler][0]](); else RecordedPlayerBufferExecCompleted(); } @@ -487,7 +487,7 @@ static void RecordedPlayerBufferExecCompleted(void) u8 playerId = GetMultiplayerId(); PrepareBufferDataTransferLink(2, 4, &playerId); - gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; + gBattleResources->bufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else { @@ -514,13 +514,13 @@ static void RecordedPlayerHandleGetMonData(void) u8 monToCheck; s32 i; - if (gBattleBufferA[gActiveBattler][2] == 0) + if (gBattleResources->bufferA[gActiveBattler][2] == 0) { size += CopyRecordedPlayerMonData(gBattlerPartyIndexes[gActiveBattler], monData); } else { - monToCheck = gBattleBufferA[gActiveBattler][2]; + monToCheck = gBattleResources->bufferA[gActiveBattler][2]; for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) @@ -542,7 +542,7 @@ static u32 CopyRecordedPlayerMonData(u8 monId, u8 *dst) u32 data32; s32 size = 0; - switch (gBattleBufferA[gActiveBattler][1]) + switch (gBattleResources->bufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: battleMon.species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES); @@ -608,7 +608,7 @@ static u32 CopyRecordedPlayerMonData(u8 monId, u8 *dst) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); + data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); dst[0] = data16; dst[1] = data16 >> 8; size = 2; @@ -623,7 +623,7 @@ static u32 CopyRecordedPlayerMonData(u8 monId, u8 *dst) case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); size = 1; break; case REQUEST_OTID_BATTLE: @@ -848,13 +848,13 @@ static void RecordedPlayerHandleSetMonData(void) u8 monToCheck; u8 i; - if (gBattleBufferA[gActiveBattler][2] == 0) + if (gBattleResources->bufferA[gActiveBattler][2] == 0) { SetRecordedPlayerMonData(gBattlerPartyIndexes[gActiveBattler]); } else { - monToCheck = gBattleBufferA[gActiveBattler][2]; + monToCheck = gBattleResources->bufferA[gActiveBattler][2]; for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) @@ -867,11 +867,11 @@ static void RecordedPlayerHandleSetMonData(void) static void SetRecordedPlayerMonData(u8 monId) { - struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBattler][3]; - struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBattler][3]; + struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleResources->bufferA[gActiveBattler][3]; + struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleResources->bufferA[gActiveBattler][3]; s32 i; - switch (gBattleBufferA[gActiveBattler][1]) + switch (gBattleResources->bufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: { @@ -912,10 +912,10 @@ static void SetRecordedPlayerMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < MAX_MON_MOVES; i++) @@ -929,154 +929,154 @@ static void SetRecordedPlayerMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBattler][4]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBattler][5]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBattler][6]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBattler][7]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleResources->bufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP2, &gBattleResources->bufferA[gActiveBattler][4]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP3, &gBattleResources->bufferA[gActiveBattler][5]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP4, &gBattleResources->bufferA[gActiveBattler][6]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &gBattleResources->bufferA[gActiveBattler][7]); break; case REQUEST_PPMOVE1_BATTLE: case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_OTID_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_EXP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HP_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_FRIENDSHIP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_POKERUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_LOCATION_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_LEVEL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_GAME_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_POKEBALL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ALL_IVS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][4]); - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][5]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][6]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][7]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][8]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleResources->bufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleResources->bufferA[gActiveBattler][4]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleResources->bufferA[gActiveBattler][5]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleResources->bufferA[gActiveBattler][6]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleResources->bufferA[gActiveBattler][7]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleResources->bufferA[gActiveBattler][8]); break; case REQUEST_HP_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CUTE_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SMART_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SHEEN_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_COOL_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CUTE_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SMART_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; } @@ -1085,11 +1085,11 @@ static void SetRecordedPlayerMonData(u8 monId) static void RecordedPlayerHandleSetRawMonData(void) { - u8 *dst = (u8 *)&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; + u8 *dst = (u8 *)&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleResources->bufferA[gActiveBattler][1]; u8 i; - for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) - dst[i] = gBattleBufferA[gActiveBattler][3 + i]; + for (i = 0; i < gBattleResources->bufferA[gActiveBattler][2]; i++) + dst[i] = gBattleResources->bufferA[gActiveBattler][3 + i]; RecordedPlayerBufferExecCompleted(); } @@ -1115,10 +1115,10 @@ static void RecordedPlayerHandleLoadMonSprite(void) static void RecordedPlayerHandleSwitchInAnim(void) { - ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleBufferA[gActiveBattler][2]); - gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1]; + ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleResources->bufferA[gActiveBattler][2]); + gBattlerPartyIndexes[gActiveBattler] = gBattleResources->bufferA[gActiveBattler][1]; BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); - sub_818BA6C(gActiveBattler, gBattleBufferA[gActiveBattler][2]); + sub_818BA6C(gActiveBattler, gBattleResources->bufferA[gActiveBattler][2]); gBattlerControllerFuncs[gActiveBattler] = sub_818A470; } @@ -1127,7 +1127,7 @@ static void sub_818BA6C(u8 battlerId, bool8 dontClearSubstituteBit) u16 species; ClearTemporarySpeciesSpriteData(battlerId, dontClearSubstituteBit); - gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1]; + gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1]; species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714); SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); @@ -1155,7 +1155,7 @@ static void sub_818BA6C(u8 battlerId, bool8 dontClearSubstituteBit) static void RecordedPlayerHandleReturnMonToBall(void) { - if (gBattleBufferA[gActiveBattler][1] == 0) + if (gBattleResources->bufferA[gActiveBattler][1] == 0) { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattlerControllerFuncs[gActiveBattler] = DoSwitchOutAnimation; @@ -1324,14 +1324,14 @@ static void RecordedPlayerHandleMoveAnimation(void) { if (!mplay_80342A4(gActiveBattler)) { - u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); + u16 move = gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8); - gAnimMoveTurn = gBattleBufferA[gActiveBattler][3]; - gAnimMovePower = gBattleBufferA[gActiveBattler][4] | (gBattleBufferA[gActiveBattler][5] << 8); - gAnimMoveDmg = gBattleBufferA[gActiveBattler][6] | (gBattleBufferA[gActiveBattler][7] << 8) | (gBattleBufferA[gActiveBattler][8] << 16) | (gBattleBufferA[gActiveBattler][9] << 24); - gAnimFriendship = gBattleBufferA[gActiveBattler][10]; - gWeatherMoveAnim = gBattleBufferA[gActiveBattler][12] | (gBattleBufferA[gActiveBattler][13] << 8); - gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBattler][16]; + gAnimMoveTurn = gBattleResources->bufferA[gActiveBattler][3]; + gAnimMovePower = gBattleResources->bufferA[gActiveBattler][4] | (gBattleResources->bufferA[gActiveBattler][5] << 8); + gAnimMoveDmg = gBattleResources->bufferA[gActiveBattler][6] | (gBattleResources->bufferA[gActiveBattler][7] << 8) | (gBattleResources->bufferA[gActiveBattler][8] << 16) | (gBattleResources->bufferA[gActiveBattler][9] << 24); + gAnimFriendship = gBattleResources->bufferA[gActiveBattler][10]; + gWeatherMoveAnim = gBattleResources->bufferA[gActiveBattler][12] | (gBattleResources->bufferA[gActiveBattler][13] << 8); + gAnimDisableStructPtr = (struct DisableStruct *)&gBattleResources->bufferA[gActiveBattler][16]; gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality; if (IsMoveWithoutAnimation(move, gAnimMoveTurn)) // always returns FALSE { @@ -1347,8 +1347,8 @@ static void RecordedPlayerHandleMoveAnimation(void) static void RecordedPlayerDoMoveAnimation(void) { - u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); - u8 multihit = gBattleBufferA[gActiveBattler][11]; + u16 move = gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8); + u8 multihit = gBattleResources->bufferA[gActiveBattler][11]; switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { @@ -1386,7 +1386,7 @@ static void RecordedPlayerDoMoveAnimation(void) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { CopyAllBattleSpritesInvisibilities(); - TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; RecordedPlayerBufferExecCompleted(); } @@ -1400,7 +1400,7 @@ static void RecordedPlayerHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); + stringId = (u16*)(&gBattleResources->bufferA[gActiveBattler][2]); BufferStringBattle(*stringId); BattlePutTextOnWindow(gDisplayedStringBattle, 0); gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; @@ -1476,7 +1476,7 @@ static void RecordedPlayerHandleHealthBarUpdate(void) s16 hpVal; LoadBattleBarGfx(0); - hpVal = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); + hpVal = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8); if (hpVal != INSTANT_HP_BAR_DROP) { @@ -1518,8 +1518,8 @@ static void RecordedPlayerHandleStatusAnimation(void) { if (!mplay_80342A4(gActiveBattler)) { - InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], - gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); + InitAndLaunchChosenStatusAnimation(gBattleResources->bufferA[gActiveBattler][1], + gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8) | (gBattleResources->bufferA[gActiveBattler][4] << 16) | (gBattleResources->bufferA[gActiveBattler][5] << 24)); gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; } } @@ -1577,7 +1577,7 @@ static void RecordedPlayerHandleCmd37(void) static void RecordedPlayerHandleCmd38(void) { - gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBattler][1]; + gUnknown_02022D0C.field_0 = gBattleResources->bufferA[gActiveBattler][1]; RecordedPlayerBufferExecCompleted(); } @@ -1622,20 +1622,20 @@ static void RecordedPlayerHandlePlaySE(void) else pan = SOUND_PAN_TARGET; - PlaySE12WithPanning(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8), pan); + PlaySE12WithPanning(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8), pan); RecordedPlayerBufferExecCompleted(); } static void RecordedPlayerHandlePlayFanfareOrBGM(void) { - if (gBattleBufferA[gActiveBattler][3]) + if (gBattleResources->bufferA[gActiveBattler][3]) { BattleStopLowHpSound(); - PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + PlayBGM(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); } else { - PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + PlayFanfare(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); } RecordedPlayerBufferExecCompleted(); @@ -1651,7 +1651,7 @@ static void RecordedPlayerHandleFaintingCry(void) static void RecordedPlayerHandleIntroSlide(void) { - HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); + HandleIntroSlide(gBattleResources->bufferA[gActiveBattler][1]); gIntroSlideFlags |= 1; RecordedPlayerBufferExecCompleted(); } @@ -1706,15 +1706,15 @@ static void sub_818CC24(u8 taskId) gActiveBattler = gTasks[taskId].data[0]; if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; sub_818BA6C(gActiveBattler, FALSE); } else { - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; sub_818BA6C(gActiveBattler, FALSE); gActiveBattler ^= BIT_FLANK; - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); sub_818BA6C(gActiveBattler, FALSE); gActiveBattler ^= BIT_FLANK; @@ -1727,17 +1727,17 @@ static void sub_818CC24(u8 taskId) static void RecordedPlayerHandleDrawPartyStatusSummary(void) { - if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) + if (gBattleResources->bufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { RecordedPlayerBufferExecCompleted(); } else { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1; - gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); + gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleResources->bufferA[gActiveBattler][4], gBattleResources->bufferA[gActiveBattler][1], gBattleResources->bufferA[gActiveBattler][2]); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; - if (gBattleBufferA[gActiveBattler][2] != 0) + if (gBattleResources->bufferA[gActiveBattler][2] != 0) gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; gBattlerControllerFuncs[gActiveBattler] = sub_818CDF4; @@ -1769,7 +1769,7 @@ static void RecordedPlayerHandleSpriteInvisibility(void) { if (IsBattlerSpritePresent(gActiveBattler)) { - gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1]; + gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleResources->bufferA[gActiveBattler][1]; CopyBattleSpriteInvisibility(gActiveBattler); } RecordedPlayerBufferExecCompleted(); @@ -1779,8 +1779,8 @@ static void RecordedPlayerHandleBattleAnimation(void) { if (!mplay_80342A4(gActiveBattler)) { - u8 animationId = gBattleBufferA[gActiveBattler][1]; - u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); + u8 animationId = gBattleResources->bufferA[gActiveBattler][1]; + u16 argument = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8); if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) RecordedPlayerBufferExecCompleted(); @@ -1801,7 +1801,7 @@ static void RecordedPlayerHandleResetActionMoveSelection(void) static void RecordedPlayerHandleCmd55(void) { - gBattleOutcome = gBattleBufferA[gActiveBattler][1]; + gBattleOutcome = gBattleResources->bufferA[gActiveBattler][1]; FadeOutMapMusic(5); BeginFastPaletteFade(3); RecordedPlayerBufferExecCompleted(); diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c index 04ca2ce46..eeccfedd7 100644 --- a/src/battle_controller_safari.c +++ b/src/battle_controller_safari.c @@ -166,8 +166,8 @@ static void SafariBufferRunCommand(void) { if (gBattleControllerExecFlags & gBitTable[gActiveBattler]) { - if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sSafariBufferCommands)) - sSafariBufferCommands[gBattleBufferA[gActiveBattler][0]](); + if (gBattleResources->bufferA[gActiveBattler][0] < ARRAY_COUNT(sSafariBufferCommands)) + sSafariBufferCommands[gBattleResources->bufferA[gActiveBattler][0]](); else SafariBufferExecCompleted(); } @@ -305,7 +305,7 @@ static void SafariBufferExecCompleted(void) u8 playerId = GetMultiplayerId(); PrepareBufferDataTransferLink(2, 4, &playerId); - gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; + gBattleResources->bufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else { @@ -400,7 +400,7 @@ static void SafariHandleSuccessBallThrowAnim(void) static void SafariHandleBallThrowAnim(void) { - u8 ballThrowCaseId = gBattleBufferA[gActiveBattler][1]; + u8 ballThrowCaseId = gBattleResources->bufferA[gActiveBattler][1]; gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId; gDoingBattleAnim = TRUE; @@ -424,7 +424,7 @@ static void SafariHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); + stringId = (u16*)(&gBattleResources->bufferA[gActiveBattler][2]); BufferStringBattle(*stringId); BattlePutTextOnWindow(gDisplayedStringBattle, 0); gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; @@ -597,20 +597,20 @@ static void SafariHandlePlaySE(void) else pan = SOUND_PAN_TARGET; - PlaySE12WithPanning(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8), pan); + PlaySE12WithPanning(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8), pan); SafariBufferExecCompleted(); } static void SafariHandlePlayFanfareOrBGM(void) { - if (gBattleBufferA[gActiveBattler][3]) + if (gBattleResources->bufferA[gActiveBattler][3]) { BattleStopLowHpSound(); - PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + PlayBGM(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); } else { - PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + PlayFanfare(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); } SafariBufferExecCompleted(); @@ -626,7 +626,7 @@ static void SafariHandleFaintingCry(void) static void SafariHandleIntroSlide(void) { - HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); + HandleIntroSlide(gBattleResources->bufferA[gActiveBattler][1]); gIntroSlideFlags |= 1; SafariBufferExecCompleted(); } @@ -661,8 +661,8 @@ static void SafariHandleSpriteInvisibility(void) static void SafariHandleBattleAnimation(void) { - u8 animationId = gBattleBufferA[gActiveBattler][1]; - u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); + u8 animationId = gBattleResources->bufferA[gActiveBattler][1]; + u16 argument = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8); if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) SafariBufferExecCompleted(); @@ -682,7 +682,7 @@ static void SafariHandleResetActionMoveSelection(void) static void SafariHandleCmd55(void) { - gBattleOutcome = gBattleBufferA[gActiveBattler][1]; + gBattleOutcome = gBattleResources->bufferA[gActiveBattler][1]; FadeOutMapMusic(5); BeginFastPaletteFade(3); SafariBufferExecCompleted(); diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c index dc3554597..90ded9a91 100644 --- a/src/battle_controller_wally.c +++ b/src/battle_controller_wally.c @@ -183,8 +183,8 @@ static void WallyBufferRunCommand(void) { if (gBattleControllerExecFlags & gBitTable[gActiveBattler]) { - if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sWallyBufferCommands)) - sWallyBufferCommands[gBattleBufferA[gActiveBattler][0]](); + if (gBattleResources->bufferA[gActiveBattler][0] < ARRAY_COUNT(sWallyBufferCommands)) + sWallyBufferCommands[gBattleResources->bufferA[gActiveBattler][0]](); else WallyBufferExecCompleted(); } @@ -411,7 +411,7 @@ static void WallyBufferExecCompleted(void) u8 playerId = GetMultiplayerId(); PrepareBufferDataTransferLink(2, 4, &playerId); - gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; + gBattleResources->bufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else { @@ -432,13 +432,13 @@ static void WallyHandleGetMonData(void) u8 monToCheck; s32 i; - if (gBattleBufferA[gActiveBattler][2] == 0) + if (gBattleResources->bufferA[gActiveBattler][2] == 0) { size += CopyWallyMonData(gBattlerPartyIndexes[gActiveBattler], monData); } else { - monToCheck = gBattleBufferA[gActiveBattler][2]; + monToCheck = gBattleResources->bufferA[gActiveBattler][2]; for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) @@ -460,7 +460,7 @@ static u32 CopyWallyMonData(u8 monId, u8 *dst) u32 data32; s32 size = 0; - switch (gBattleBufferA[gActiveBattler][1]) + switch (gBattleResources->bufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: battleMon.species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES); @@ -526,7 +526,7 @@ static u32 CopyWallyMonData(u8 monId, u8 *dst) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); + data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); dst[0] = data16; dst[1] = data16 >> 8; size = 2; @@ -541,7 +541,7 @@ static u32 CopyWallyMonData(u8 monId, u8 *dst) case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); size = 1; break; case REQUEST_OTID_BATTLE: @@ -766,13 +766,13 @@ static void WallyHandleSetMonData(void) u8 monToCheck; u8 i; - if (gBattleBufferA[gActiveBattler][2] == 0) + if (gBattleResources->bufferA[gActiveBattler][2] == 0) { SetWallyMonData(gBattlerPartyIndexes[gActiveBattler]); } else { - monToCheck = gBattleBufferA[gActiveBattler][2]; + monToCheck = gBattleResources->bufferA[gActiveBattler][2]; for (i = 0; i < PARTY_SIZE; i++) { if (monToCheck & 1) @@ -785,11 +785,11 @@ static void WallyHandleSetMonData(void) static void SetWallyMonData(u8 monId) { - struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBattler][3]; - struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBattler][3]; + struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleResources->bufferA[gActiveBattler][3]; + struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleResources->bufferA[gActiveBattler][3]; s32 i; - switch (gBattleBufferA[gActiveBattler][1]) + switch (gBattleResources->bufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: { @@ -830,10 +830,10 @@ static void SetWallyMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < MAX_MON_MOVES; i++) @@ -847,154 +847,154 @@ static void SetWallyMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBattler][4]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBattler][5]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBattler][6]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBattler][7]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleResources->bufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP2, &gBattleResources->bufferA[gActiveBattler][4]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP3, &gBattleResources->bufferA[gActiveBattler][5]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP4, &gBattleResources->bufferA[gActiveBattler][6]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &gBattleResources->bufferA[gActiveBattler][7]); break; case REQUEST_PPMOVE1_BATTLE: case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleResources->bufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_OTID_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_EXP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HP_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_FRIENDSHIP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_POKERUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_LOCATION_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_LEVEL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MET_GAME_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_POKEBALL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ALL_IVS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][4]); - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][5]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][6]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][7]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][8]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleResources->bufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleResources->bufferA[gActiveBattler][4]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleResources->bufferA[gActiveBattler][5]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleResources->bufferA[gActiveBattler][6]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleResources->bufferA[gActiveBattler][7]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleResources->bufferA[gActiveBattler][8]); break; case REQUEST_HP_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CUTE_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SMART_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SHEEN_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_COOL_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_CUTE_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_SMART_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleResources->bufferA[gActiveBattler][3]); break; } @@ -1018,7 +1018,7 @@ static void WallyHandleSwitchInAnim(void) static void WallyHandleReturnMonToBall(void) { - if (gBattleBufferA[gActiveBattler][1] == 0) + if (gBattleResources->bufferA[gActiveBattler][1] == 0) { InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON); gBattlerControllerFuncs[gActiveBattler] = sub_8168A20; @@ -1087,7 +1087,7 @@ static void WallyHandleSuccessBallThrowAnim(void) static void WallyHandleBallThrowAnim(void) { - u8 ballThrowCaseId = gBattleBufferA[gActiveBattler][1]; + u8 ballThrowCaseId = gBattleResources->bufferA[gActiveBattler][1]; gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId; gDoingBattleAnim = TRUE; @@ -1102,14 +1102,14 @@ static void WallyHandlePause(void) static void WallyHandleMoveAnimation(void) { - u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); + u16 move = gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8); - gAnimMoveTurn = gBattleBufferA[gActiveBattler][3]; - gAnimMovePower = gBattleBufferA[gActiveBattler][4] | (gBattleBufferA[gActiveBattler][5] << 8); - gAnimMoveDmg = gBattleBufferA[gActiveBattler][6] | (gBattleBufferA[gActiveBattler][7] << 8) | (gBattleBufferA[gActiveBattler][8] << 16) | (gBattleBufferA[gActiveBattler][9] << 24); - gAnimFriendship = gBattleBufferA[gActiveBattler][10]; - gWeatherMoveAnim = gBattleBufferA[gActiveBattler][12] | (gBattleBufferA[gActiveBattler][13] << 8); - gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBattler][16]; + gAnimMoveTurn = gBattleResources->bufferA[gActiveBattler][3]; + gAnimMovePower = gBattleResources->bufferA[gActiveBattler][4] | (gBattleResources->bufferA[gActiveBattler][5] << 8); + gAnimMoveDmg = gBattleResources->bufferA[gActiveBattler][6] | (gBattleResources->bufferA[gActiveBattler][7] << 8) | (gBattleResources->bufferA[gActiveBattler][8] << 16) | (gBattleResources->bufferA[gActiveBattler][9] << 24); + gAnimFriendship = gBattleResources->bufferA[gActiveBattler][10]; + gWeatherMoveAnim = gBattleResources->bufferA[gActiveBattler][12] | (gBattleResources->bufferA[gActiveBattler][13] << 8); + gAnimDisableStructPtr = (struct DisableStruct *)&gBattleResources->bufferA[gActiveBattler][16]; gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality; if (IsMoveWithoutAnimation(move, gAnimMoveTurn)) // always returns FALSE { @@ -1125,7 +1125,7 @@ static void WallyHandleMoveAnimation(void) static void WallyDoMoveAnimation(void) { - u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); + u16 move = gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8); switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { @@ -1160,7 +1160,7 @@ static void WallyDoMoveAnimation(void) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { CopyAllBattleSpritesInvisibilities(); - TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; WallyBufferExecCompleted(); } @@ -1174,7 +1174,7 @@ static void WallyHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); + stringId = (u16*)(&gBattleResources->bufferA[gActiveBattler][2]); BufferStringBattle(*stringId); BattlePutTextOnWindow(gDisplayedStringBattle, 0); gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; @@ -1268,7 +1268,7 @@ static void WallyHandleHealthBarUpdate(void) s16 hpVal; LoadBattleBarGfx(0); - hpVal = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); + hpVal = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8); if (hpVal != INSTANT_HP_BAR_DROP) { @@ -1390,20 +1390,20 @@ static void WallyHandleCmd42(void) static void WallyHandlePlaySE(void) { - PlaySE(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + PlaySE(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); WallyBufferExecCompleted(); } static void WallyHandlePlayFanfareOrBGM(void) { - if (gBattleBufferA[gActiveBattler][3]) + if (gBattleResources->bufferA[gActiveBattler][3]) { BattleStopLowHpSound(); - PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + PlayBGM(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); } else { - PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + PlayFanfare(gBattleResources->bufferA[gActiveBattler][1] | (gBattleResources->bufferA[gActiveBattler][2] << 8)); } WallyBufferExecCompleted(); @@ -1419,7 +1419,7 @@ static void WallyHandleFaintingCry(void) static void WallyHandleIntroSlide(void) { - HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); + HandleIntroSlide(gBattleResources->bufferA[gActiveBattler][1]); gIntroSlideFlags |= 1; WallyBufferExecCompleted(); } @@ -1459,7 +1459,7 @@ static void sub_816AA80(u8 battlerId) u16 species; gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies = 0; - gBattlerPartyIndexes[battlerId] = gBattleBufferA[battlerId][1]; + gBattlerPartyIndexes[battlerId] = gBattleResources->bufferA[battlerId][1]; species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES); gUnknown_03005D7C[battlerId] = CreateInvisibleSpriteWithCallback(sub_805D714); SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battlerId)); @@ -1492,7 +1492,7 @@ static void sub_816AC04(u8 taskId) u8 savedActiveBank = gActiveBattler; gActiveBattler = gTasks[taskId].data[0]; - gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; + gBattleResources->bufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; sub_816AA80(gActiveBattler); gBattlerControllerFuncs[gActiveBattler] = sub_816864C; gActiveBattler = savedActiveBank; @@ -1502,14 +1502,14 @@ static void sub_816AC04(u8 taskId) static void WallyHandleDrawPartyStatusSummary(void) { - if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) + if (gBattleResources->bufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { WallyBufferExecCompleted(); } else { gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown = 1; - gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); + gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleResources->bufferA[gActiveBattler][4], gBattleResources->bufferA[gActiveBattler][1], gBattleResources->bufferA[gActiveBattler][2]); WallyBufferExecCompleted(); } } @@ -1531,8 +1531,8 @@ static void WallyHandleSpriteInvisibility(void) static void WallyHandleBattleAnimation(void) { - u8 animationId = gBattleBufferA[gActiveBattler][1]; - u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); + u8 animationId = gBattleResources->bufferA[gActiveBattler][1]; + u16 argument = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8); if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) WallyBufferExecCompleted(); @@ -1552,7 +1552,7 @@ static void WallyHandleResetActionMoveSelection(void) static void WallyHandleCmd55(void) { - gBattleOutcome = gBattleBufferA[gActiveBattler][1]; + gBattleOutcome = gBattleResources->bufferA[gActiveBattler][1]; FadeOutMapMusic(5); BeginFastPaletteFade(3); WallyBufferExecCompleted(); diff --git a/src/battle_controllers.c b/src/battle_controllers.c index 675d4edb4..166fc6119 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -665,14 +665,14 @@ static void PrepareBufferDataTransfer(u8 bufferId, u8 *data, u16 size) case 0: for (i = 0; i < size; i++) { - gBattleBufferA[gActiveBattler][i] = *data; + gBattleResources->bufferA[gActiveBattler][i] = *data; data++; } break; case 1: for (i = 0; i < size; i++) { - gBattleBufferB[gActiveBattler][i] = *data; + gBattleResources->bufferB[gActiveBattler][i] = *data; data++; } break; @@ -887,7 +887,7 @@ static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId) if (gBattleControllerExecFlags & gBitTable[battlerId]) return; - memcpy(gBattleBufferA[battlerId], &gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_DATA], blockSize); + memcpy(gBattleResources->bufferA[battlerId], &gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_DATA], blockSize); sub_803F850(battlerId); if (!(gBattleTypeFlags & BATTLE_TYPE_IS_MASTER)) @@ -899,7 +899,7 @@ static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId) } break; case 1: - memcpy(gBattleBufferB[battlerId], &gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_DATA], blockSize); + memcpy(gBattleResources->bufferB[battlerId], &gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_DATA], blockSize); break; case 2: var = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + LINK_BUFF_DATA]; diff --git a/src/battle_dome.c b/src/battle_dome.c index 696bebb91..da4666cfc 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -3010,8 +3010,6 @@ static s32 sub_818FEB4(s32 *arr, bool8 arg1) #define TYPE_x2 40 #define TYPE_x4 80 -// Functionally equivalent, while loop is impossible to match. -#ifdef NONMATCHING static s32 GetTypeEffectivenessPoints(s32 move, s32 targetSpecies, s32 arg2) { s32 defType1, defType2, defAbility, moveType; @@ -3033,26 +3031,15 @@ static s32 GetTypeEffectivenessPoints(s32 move, s32 targetSpecies, s32 arg2) } else { - while (gTypeEffectiveness[i + 0] != TYPE_ENDTABLE) - { - if (gTypeEffectiveness[i + 0] == TYPE_FORESIGHT) - { - i += 3; - } - else - { - u8 val = gTypeEffectiveness[i + 0]; - if (val == moveType) - { - // BUG: * 2 is not necessary and makes the condition always false if the ability is wonder guard. - if (gTypeEffectiveness[i + 1] == defType1 && (defAbility != ABILITY_WONDER_GUARD || gTypeEffectiveness[i + 2] == TYPE_MUL_SUPER_EFFECTIVE * 2)) - typePower = (gTypeEffectiveness[i + 2] * typePower) / 10; - if (gTypeEffectiveness[i + 1] == defType2 && defType1 != defType2 && (defAbility != ABILITY_WONDER_GUARD || gTypeEffectiveness[i + 2] == TYPE_MUL_SUPER_EFFECTIVE * 2)) - typePower = (gTypeEffectiveness[i + 2] * typePower) / 10; - } - i += 3; - } - } + u32 typeEffectiveness1 = UQ_4_12_TO_INT(GetTypeModifier(moveType, defType1) * 2) * 5; + u32 typeEffectiveness2 = UQ_4_12_TO_INT(GetTypeModifier(moveType, defType2) * 2) * 5; + + typePower = (typeEffectiveness1 * typePower) / 10; + if (defType2 != defType1) + typePower = (typeEffectiveness2 * typePower) / 10; + + if (defAbility == ABILITY_WONDER_GUARD && typeEffectiveness1 != 20 && typeEffectiveness2 != 20) + typePower = 0; } switch (arg2) @@ -3129,247 +3116,6 @@ static s32 GetTypeEffectivenessPoints(s32 move, s32 targetSpecies, s32 arg2) return typePower; } -#else -NAKED -static s32 GetTypeEffectivenessPoints(s32 move, s32 species, s32 arg2) -{ - asm_unified("\n\ - push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0x8\n\ - adds r3, r0, 0\n\ - adds r4, r1, 0\n\ - str r2, [sp]\n\ - movs r6, 0\n\ - movs r2, 0x14\n\ - cmp r3, 0\n\ - beq _0818FFF0\n\ - ldr r0, =0x0000ffff\n\ - cmp r3, r0\n\ - beq _0818FFF0\n\ - ldr r0, =gBattleMoves\n\ - lsls r1, r3, 1\n\ - adds r1, r3\n\ - lsls r1, 2\n\ - adds r3, r1, r0\n\ - ldrb r0, [r3, 0x1]\n\ - cmp r0, 0\n\ - bne _0818FFFC\n\ -_0818FFF0:\n\ - movs r0, 0\n\ - b _08190156\n\ - .pool\n\ -_0818FFFC:\n\ - ldr r1, =gBaseStats\n\ - lsls r0, r4, 3\n\ - subs r0, r4\n\ - lsls r0, 2\n\ - adds r0, r1\n\ - ldrb r1, [r0, 0x6]\n\ - mov r10, r1\n\ - ldrb r1, [r0, 0x7]\n\ - mov r9, r1\n\ - ldrb r0, [r0, 0x16]\n\ - mov r8, r0\n\ - ldrb r3, [r3, 0x2]\n\ - str r3, [sp, 0x4]\n\ - cmp r0, 0x1A\n\ - bne _0819002C\n\ - cmp r3, 0x4\n\ - bne _0819002C\n\ - ldr r0, [sp]\n\ - cmp r0, 0x1\n\ - bne _081900AA\n\ - movs r2, 0x8\n\ - b _081900A4\n\ - .pool\n\ -_0819002C:\n\ - ldr r0, =gTypeEffectiveness\n\ - adds r1, r6, r0\n\ - ldrb r0, [r1]\n\ - ldr r7, =gTypeEffectiveness\n\ - cmp r0, 0xFF\n\ - beq _081900A4\n\ - adds r4, r1, 0\n\ -_0819003A:\n\ - ldrb r0, [r4]\n\ - cmp r0, 0xFE\n\ - beq _08190096\n\ - ldrb r0, [r4]\n\ - ldr r1, [sp, 0x4]\n\ - cmp r0, r1\n\ - bne _08190096\n\ - ldrb r0, [r4, 0x1]\n\ - adds r5, r6, 0x1\n\ - cmp r0, r10\n\ - bne _0819006C\n\ - adds r1, r6, 0x2\n\ - mov r0, r8\n\ - cmp r0, 0x19\n\ - bne _0819005E\n\ - ldrb r0, [r4, 0x2]\n\ - cmp r0, 0x28\n\ - bne _0819006C\n\ -_0819005E:\n\ - adds r0, r1, r7\n\ - ldrb r0, [r0]\n\ - muls r0, r2\n\ - movs r1, 0xA\n\ - bl __divsi3\n\ - adds r2, r0, 0\n\ -_0819006C:\n\ - adds r0, r5, r7\n\ - ldrb r0, [r0]\n\ - cmp r0, r9\n\ - bne _08190096\n\ - cmp r10, r9\n\ - beq _08190096\n\ - adds r1, r6, 0x2\n\ - mov r0, r8\n\ - cmp r0, 0x19\n\ - bne _08190088\n\ - adds r0, r1, r7\n\ - ldrb r0, [r0]\n\ - cmp r0, 0x28\n\ - bne _08190096\n\ -_08190088:\n\ - adds r0, r1, r7\n\ - ldrb r0, [r0]\n\ - muls r0, r2\n\ - movs r1, 0xA\n\ - bl __divsi3\n\ - adds r2, r0, 0\n\ -_08190096:\n\ - adds r4, 0x3\n\ - adds r6, 0x3\n\ - ldr r1, =gTypeEffectiveness\n\ - adds r0, r6, r1\n\ - ldrb r0, [r0]\n\ - cmp r0, 0xFF\n\ - bne _0819003A\n\ -_081900A4:\n\ - ldr r0, [sp]\n\ - cmp r0, 0x1\n\ - beq _081900E0\n\ -_081900AA:\n\ - ldr r1, [sp]\n\ - cmp r1, 0x1\n\ - bgt _081900BC\n\ - cmp r1, 0\n\ - beq _081900C4\n\ - b _08190154\n\ - .pool\n\ -_081900BC:\n\ - ldr r0, [sp]\n\ - cmp r0, 0x2\n\ - beq _08190114\n\ - b _08190154\n\ -_081900C4:\n\ - cmp r2, 0xA\n\ - beq _08190146\n\ - cmp r2, 0xA\n\ - ble _08190146\n\ - cmp r2, 0x28\n\ - beq _0819014A\n\ - cmp r2, 0x28\n\ - bgt _081900DA\n\ - cmp r2, 0x14\n\ - beq _08190104\n\ - b _08190146\n\ -_081900DA:\n\ - cmp r2, 0x50\n\ - bne _08190146\n\ - b _08190100\n\ -_081900E0:\n\ - cmp r2, 0xA\n\ - beq _08190104\n\ - cmp r2, 0xA\n\ - bgt _081900F2\n\ - cmp r2, 0\n\ - beq _08190100\n\ - cmp r2, 0x5\n\ - beq _0819014A\n\ - b _08190146\n\ -_081900F2:\n\ - cmp r2, 0x28\n\ - beq _08190108\n\ - cmp r2, 0x28\n\ - ble _08190146\n\ - cmp r2, 0x50\n\ - beq _0819010E\n\ - b _08190146\n\ -_08190100:\n\ - movs r2, 0x8\n\ - b _08190154\n\ -_08190104:\n\ - movs r2, 0x2\n\ - b _08190154\n\ -_08190108:\n\ - movs r2, 0x2\n\ - negs r2, r2\n\ - b _08190154\n\ -_0819010E:\n\ - movs r2, 0x4\n\ - negs r2, r2\n\ - b _08190154\n\ -_08190114:\n\ - cmp r2, 0xA\n\ - beq _08190146\n\ - cmp r2, 0xA\n\ - bgt _08190126\n\ - cmp r2, 0\n\ - beq _0819013A\n\ - cmp r2, 0x5\n\ - beq _08190140\n\ - b _08190146\n\ -_08190126:\n\ - cmp r2, 0x28\n\ - beq _0819014E\n\ - cmp r2, 0x28\n\ - bgt _08190134\n\ - cmp r2, 0x14\n\ - beq _0819014A\n\ - b _08190146\n\ -_08190134:\n\ - cmp r2, 0x50\n\ - beq _08190152\n\ - b _08190146\n\ -_0819013A:\n\ - movs r2, 0x10\n\ - negs r2, r2\n\ - b _08190154\n\ -_08190140:\n\ - movs r2, 0x8\n\ - negs r2, r2\n\ - b _08190154\n\ -_08190146:\n\ - movs r2, 0\n\ - b _08190154\n\ -_0819014A:\n\ - movs r2, 0x4\n\ - b _08190154\n\ -_0819014E:\n\ - movs r2, 0xC\n\ - b _08190154\n\ -_08190152:\n\ - movs r2, 0x14\n\ -_08190154:\n\ - adds r0, r2, 0\n\ -_08190156:\n\ - add sp, 0x8\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r1}\n\ - bx r1\n\ - "); -} -#endif // NONMATCHING static u8 GetDomeTrainerMonIvs(u16 trainerId) { diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index e4a0ff76f..0cd7bd4c2 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -120,7 +120,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void) { s32 i, var1, var2; s32 chosenMoveId = -1; - struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]); + struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleResources->bufferA[gActiveBattler][4]); u8 unusableMovesBits = CheckMoveLimitations(gActiveBattler, 0, 0xFF); s32 percent = Random() % 100; diff --git a/src/battle_main.c b/src/battle_main.c index 6202eadce..d7c47ea78 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -158,8 +158,6 @@ EWRAM_DATA struct UnknownPokemonStruct4 gUnknown_02022FF8[3] = {0}; // what is i EWRAM_DATA struct UnknownPokemonStruct4* gUnknown_02023058 = NULL; // what is it used for? EWRAM_DATA u8 *gUnknown_0202305C = NULL; EWRAM_DATA u8 *gUnknown_02023060 = NULL; -EWRAM_DATA u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200] = {0}; -EWRAM_DATA u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200] = {0}; EWRAM_DATA u8 gActiveBattler = 0; EWRAM_DATA u32 gBattleControllerExecFlags = 0; EWRAM_DATA u8 gBattlersCount = 0; @@ -327,128 +325,6 @@ static const u16 *const gUnknown_0831ACDC = gUnknown_0831ACC4; static const s8 gUnknown_0831ACE0[] ={-32, -16, -16, -32, -32, 0, 0, 0}; -// format: attacking type, defending type, damage multiplier -// the multiplier is a (decimal) fixed-point number: -// 20 is ×2.0 TYPE_MUL_SUPER_EFFECTIVE -// 10 is ×1.0 TYPE_MUL_NORMAL -// 05 is ×0.5 TYPE_MUL_NOT_EFFECTIVE -// 00 is ×0.0 TYPE_MUL_NO_EFFECT -const u8 gTypeEffectiveness[336] = -{ - TYPE_NORMAL, TYPE_ROCK, TYPE_MUL_NOT_EFFECTIVE, - TYPE_NORMAL, TYPE_STEEL, TYPE_MUL_NOT_EFFECTIVE, - TYPE_FIRE, TYPE_FIRE, TYPE_MUL_NOT_EFFECTIVE, - TYPE_FIRE, TYPE_WATER, TYPE_MUL_NOT_EFFECTIVE, - TYPE_FIRE, TYPE_GRASS, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_FIRE, TYPE_ICE, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_FIRE, TYPE_BUG, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_FIRE, TYPE_ROCK, TYPE_MUL_NOT_EFFECTIVE, - TYPE_FIRE, TYPE_DRAGON, TYPE_MUL_NOT_EFFECTIVE, - TYPE_FIRE, TYPE_STEEL, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_WATER, TYPE_FIRE, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_WATER, TYPE_WATER, TYPE_MUL_NOT_EFFECTIVE, - TYPE_WATER, TYPE_GRASS, TYPE_MUL_NOT_EFFECTIVE, - TYPE_WATER, TYPE_GROUND, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_WATER, TYPE_ROCK, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_WATER, TYPE_DRAGON, TYPE_MUL_NOT_EFFECTIVE, - TYPE_ELECTRIC, TYPE_WATER, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_ELECTRIC, TYPE_ELECTRIC, TYPE_MUL_NOT_EFFECTIVE, - TYPE_ELECTRIC, TYPE_GRASS, TYPE_MUL_NOT_EFFECTIVE, - TYPE_ELECTRIC, TYPE_GROUND, TYPE_MUL_NO_EFFECT, - TYPE_ELECTRIC, TYPE_FLYING, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_ELECTRIC, TYPE_DRAGON, TYPE_MUL_NOT_EFFECTIVE, - TYPE_GRASS, TYPE_FIRE, TYPE_MUL_NOT_EFFECTIVE, - TYPE_GRASS, TYPE_WATER, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_GRASS, TYPE_GRASS, TYPE_MUL_NOT_EFFECTIVE, - TYPE_GRASS, TYPE_POISON, TYPE_MUL_NOT_EFFECTIVE, - TYPE_GRASS, TYPE_GROUND, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_GRASS, TYPE_FLYING, TYPE_MUL_NOT_EFFECTIVE, - TYPE_GRASS, TYPE_BUG, TYPE_MUL_NOT_EFFECTIVE, - TYPE_GRASS, TYPE_ROCK, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_GRASS, TYPE_DRAGON, TYPE_MUL_NOT_EFFECTIVE, - TYPE_GRASS, TYPE_STEEL, TYPE_MUL_NOT_EFFECTIVE, - TYPE_ICE, TYPE_WATER, TYPE_MUL_NOT_EFFECTIVE, - TYPE_ICE, TYPE_GRASS, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_ICE, TYPE_ICE, TYPE_MUL_NOT_EFFECTIVE, - TYPE_ICE, TYPE_GROUND, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_ICE, TYPE_FLYING, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_ICE, TYPE_DRAGON, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_ICE, TYPE_STEEL, TYPE_MUL_NOT_EFFECTIVE, - TYPE_ICE, TYPE_FIRE, TYPE_MUL_NOT_EFFECTIVE, - TYPE_FIGHTING, TYPE_NORMAL, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_FIGHTING, TYPE_ICE, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_FIGHTING, TYPE_POISON, TYPE_MUL_NOT_EFFECTIVE, - TYPE_FIGHTING, TYPE_FLYING, TYPE_MUL_NOT_EFFECTIVE, - TYPE_FIGHTING, TYPE_PSYCHIC, TYPE_MUL_NOT_EFFECTIVE, - TYPE_FIGHTING, TYPE_BUG, TYPE_MUL_NOT_EFFECTIVE, - TYPE_FIGHTING, TYPE_ROCK, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_FIGHTING, TYPE_DARK, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_FIGHTING, TYPE_STEEL, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_POISON, TYPE_GRASS, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_POISON, TYPE_POISON, TYPE_MUL_NOT_EFFECTIVE, - TYPE_POISON, TYPE_GROUND, TYPE_MUL_NOT_EFFECTIVE, - TYPE_POISON, TYPE_ROCK, TYPE_MUL_NOT_EFFECTIVE, - TYPE_POISON, TYPE_GHOST, TYPE_MUL_NOT_EFFECTIVE, - TYPE_POISON, TYPE_STEEL, TYPE_MUL_NO_EFFECT, - TYPE_GROUND, TYPE_FIRE, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_GROUND, TYPE_ELECTRIC, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_GROUND, TYPE_GRASS, TYPE_MUL_NOT_EFFECTIVE, - TYPE_GROUND, TYPE_POISON, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_GROUND, TYPE_FLYING, TYPE_MUL_NO_EFFECT, - TYPE_GROUND, TYPE_BUG, TYPE_MUL_NOT_EFFECTIVE, - TYPE_GROUND, TYPE_ROCK, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_GROUND, TYPE_STEEL, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_FLYING, TYPE_ELECTRIC, TYPE_MUL_NOT_EFFECTIVE, - TYPE_FLYING, TYPE_GRASS, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_FLYING, TYPE_FIGHTING, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_FLYING, TYPE_BUG, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_FLYING, TYPE_ROCK, TYPE_MUL_NOT_EFFECTIVE, - TYPE_FLYING, TYPE_STEEL, TYPE_MUL_NOT_EFFECTIVE, - TYPE_PSYCHIC, TYPE_FIGHTING, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_PSYCHIC, TYPE_POISON, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_PSYCHIC, TYPE_PSYCHIC, TYPE_MUL_NOT_EFFECTIVE, - TYPE_PSYCHIC, TYPE_DARK, TYPE_MUL_NO_EFFECT, - TYPE_PSYCHIC, TYPE_STEEL, TYPE_MUL_NOT_EFFECTIVE, - TYPE_BUG, TYPE_FIRE, TYPE_MUL_NOT_EFFECTIVE, - TYPE_BUG, TYPE_GRASS, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_BUG, TYPE_FIGHTING, TYPE_MUL_NOT_EFFECTIVE, - TYPE_BUG, TYPE_POISON, TYPE_MUL_NOT_EFFECTIVE, - TYPE_BUG, TYPE_FLYING, TYPE_MUL_NOT_EFFECTIVE, - TYPE_BUG, TYPE_PSYCHIC, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_BUG, TYPE_GHOST, TYPE_MUL_NOT_EFFECTIVE, - TYPE_BUG, TYPE_DARK, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_BUG, TYPE_STEEL, TYPE_MUL_NOT_EFFECTIVE, - TYPE_ROCK, TYPE_FIRE, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_ROCK, TYPE_ICE, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_ROCK, TYPE_FIGHTING, TYPE_MUL_NOT_EFFECTIVE, - TYPE_ROCK, TYPE_GROUND, TYPE_MUL_NOT_EFFECTIVE, - TYPE_ROCK, TYPE_FLYING, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_ROCK, TYPE_BUG, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_ROCK, TYPE_STEEL, TYPE_MUL_NOT_EFFECTIVE, - TYPE_GHOST, TYPE_NORMAL, TYPE_MUL_NO_EFFECT, - TYPE_GHOST, TYPE_PSYCHIC, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_GHOST, TYPE_DARK, TYPE_MUL_NOT_EFFECTIVE, - TYPE_GHOST, TYPE_STEEL, TYPE_MUL_NOT_EFFECTIVE, - TYPE_GHOST, TYPE_GHOST, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_DRAGON, TYPE_DRAGON, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_DRAGON, TYPE_STEEL, TYPE_MUL_NOT_EFFECTIVE, - TYPE_DARK, TYPE_FIGHTING, TYPE_MUL_NOT_EFFECTIVE, - TYPE_DARK, TYPE_PSYCHIC, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_DARK, TYPE_GHOST, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_DARK, TYPE_DARK, TYPE_MUL_NOT_EFFECTIVE, - TYPE_DARK, TYPE_STEEL, TYPE_MUL_NOT_EFFECTIVE, - TYPE_STEEL, TYPE_FIRE, TYPE_MUL_NOT_EFFECTIVE, - TYPE_STEEL, TYPE_WATER, TYPE_MUL_NOT_EFFECTIVE, - TYPE_STEEL, TYPE_ELECTRIC, TYPE_MUL_NOT_EFFECTIVE, - TYPE_STEEL, TYPE_ICE, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_STEEL, TYPE_ROCK, TYPE_MUL_SUPER_EFFECTIVE, - TYPE_STEEL, TYPE_STEEL, TYPE_MUL_NOT_EFFECTIVE, - TYPE_FORESIGHT, TYPE_FORESIGHT, TYPE_MUL_NO_EFFECT, - TYPE_NORMAL, TYPE_GHOST, TYPE_MUL_NO_EFFECT, - TYPE_FIGHTING, TYPE_GHOST, TYPE_MUL_NO_EFFECT, - TYPE_ENDTABLE, TYPE_ENDTABLE, TYPE_MUL_NO_EFFECT -}; - const u8 gTypeNames[][TYPE_NAME_LENGTH + 1] = { _("NORMAL"), @@ -3382,7 +3258,7 @@ static void DoBattleIntro(void) } else { - memcpy(&gBattleMons[gActiveBattler], &gBattleBufferB[gActiveBattler][4], sizeof(struct BattlePokemon)); + memcpy(&gBattleMons[gActiveBattler], &gBattleResources->bufferB[gActiveBattler][4], sizeof(struct BattlePokemon)); gBattleMons[gActiveBattler].type1 = gBaseStats[gBattleMons[gActiveBattler].species].type1; gBattleMons[gActiveBattler].type2 = gBaseStats[gBattleMons[gActiveBattler].species].type2; gBattleMons[gActiveBattler].type3 = TYPE_MYSTERY; @@ -4001,7 +3877,7 @@ static void HandleTurnActionSelectionState(void) } else { - BtlController_EmitChooseAction(0, gChosenActionByBattler[0], gBattleBufferB[0][1] | (gBattleBufferB[0][2] << 8)); + BtlController_EmitChooseAction(0, gChosenActionByBattler[0], gBattleResources->bufferB[0][1] | (gBattleResources->bufferB[0][2] << 8)); MarkBattlerForControllerExec(gActiveBattler); gBattleCommunication[gActiveBattler]++; } @@ -4011,10 +3887,10 @@ static void HandleTurnActionSelectionState(void) case STATE_WAIT_ACTION_CHOSEN: // Try to perform an action. if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler]) | (0xF0000000) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 0xC)))) { - RecordedBattle_SetBattlerAction(gActiveBattler, gBattleBufferB[gActiveBattler][1]); - gChosenActionByBattler[gActiveBattler] = gBattleBufferB[gActiveBattler][1]; + RecordedBattle_SetBattlerAction(gActiveBattler, gBattleResources->bufferB[gActiveBattler][1]); + gChosenActionByBattler[gActiveBattler] = gBattleResources->bufferB[gActiveBattler][1]; - switch (gBattleBufferB[gActiveBattler][1]) + switch (gBattleResources->bufferB[gActiveBattler][1]) { case B_ACTION_USE_MOVE: if (AreAllMovesUnusable()) @@ -4022,7 +3898,7 @@ static void HandleTurnActionSelectionState(void) gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT; *(gBattleStruct->selectionScriptFinished + gActiveBattler) = FALSE; *(gBattleStruct->stateIdAfterSelScript + gActiveBattler) = STATE_WAIT_ACTION_CONFIRMED_STANDBY; - *(gBattleStruct->moveTarget + gActiveBattler) = gBattleBufferB[gActiveBattler][3]; + *(gBattleStruct->moveTarget + gActiveBattler) = gBattleResources->bufferB[gActiveBattler][3]; return; } else if (gDisableStructs[gActiveBattler].encoredMove != 0) @@ -4165,7 +4041,7 @@ static void HandleTurnActionSelectionState(void) if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_TRAINER_HILL) - && gBattleBufferB[gActiveBattler][1] == B_ACTION_RUN) + && gBattleResources->bufferB[gActiveBattler][1] == B_ACTION_RUN) { gSelectionBattleScripts[gActiveBattler] = BattleScript_AskIfWantsToForfeitMatch; gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT_MAY_RUN; @@ -4175,13 +4051,13 @@ static void HandleTurnActionSelectionState(void) } else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) - && gBattleBufferB[gActiveBattler][1] == B_ACTION_RUN) + && gBattleResources->bufferB[gActiveBattler][1] == B_ACTION_RUN) { BattleScriptExecute(BattleScript_PrintCantRunFromTrainer); gBattleCommunication[gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN; } else if (IsRunningFromBattleImpossible() - && gBattleBufferB[gActiveBattler][1] == B_ACTION_RUN) + && gBattleResources->bufferB[gActiveBattler][1] == B_ACTION_RUN) { gSelectionBattleScripts[gActiveBattler] = BattleScript_PrintCantEscapeFromBattle; gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT; @@ -4201,7 +4077,7 @@ static void HandleTurnActionSelectionState(void) switch (gChosenActionByBattler[gActiveBattler]) { case B_ACTION_USE_MOVE: - switch (gBattleBufferB[gActiveBattler][1]) + switch (gBattleResources->bufferB[gActiveBattler][1]) { case 3: case 4: @@ -4210,7 +4086,7 @@ static void HandleTurnActionSelectionState(void) case 7: case 8: case 9: - gChosenActionByBattler[gActiveBattler] = gBattleBufferB[gActiveBattler][1]; + gChosenActionByBattler[gActiveBattler] = gBattleResources->bufferB[gActiveBattler][1]; return; case 15: gChosenActionByBattler[gActiveBattler] = B_ACTION_SWITCH; @@ -4218,7 +4094,7 @@ static void HandleTurnActionSelectionState(void) return; default: sub_818603C(2); - if ((gBattleBufferB[gActiveBattler][2] | (gBattleBufferB[gActiveBattler][3] << 8)) == 0xFFFF) + if ((gBattleResources->bufferB[gActiveBattler][2] | (gBattleResources->bufferB[gActiveBattler][3] << 8)) == 0xFFFF) { gBattleCommunication[gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN; RecordedBattle_ClearBattlerAction(gActiveBattler, 1); @@ -4228,7 +4104,7 @@ static void HandleTurnActionSelectionState(void) RecordedBattle_ClearBattlerAction(gActiveBattler, 1); gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT; *(gBattleStruct->selectionScriptFinished + gActiveBattler) = FALSE; - gBattleBufferB[gActiveBattler][1] = 0; + gBattleResources->bufferB[gActiveBattler][1] = 0; *(gBattleStruct->stateIdAfterSelScript + gActiveBattler) = STATE_WAIT_ACTION_CHOSEN; return; } @@ -4236,13 +4112,13 @@ static void HandleTurnActionSelectionState(void) { if (!(gBattleTypeFlags & BATTLE_TYPE_PALACE)) { - RecordedBattle_SetBattlerAction(gActiveBattler, gBattleBufferB[gActiveBattler][2]); - RecordedBattle_SetBattlerAction(gActiveBattler, gBattleBufferB[gActiveBattler][3]); + RecordedBattle_SetBattlerAction(gActiveBattler, gBattleResources->bufferB[gActiveBattler][2]); + RecordedBattle_SetBattlerAction(gActiveBattler, gBattleResources->bufferB[gActiveBattler][3]); } - *(gBattleStruct->chosenMovePositions + gActiveBattler) = gBattleBufferB[gActiveBattler][2] & ~(RET_MEGA_EVOLUTION); + *(gBattleStruct->chosenMovePositions + gActiveBattler) = gBattleResources->bufferB[gActiveBattler][2] & ~(RET_MEGA_EVOLUTION); gChosenMoveByBattler[gActiveBattler] = gBattleMons[gActiveBattler].moves[*(gBattleStruct->chosenMovePositions + gActiveBattler)]; - *(gBattleStruct->moveTarget + gActiveBattler) = gBattleBufferB[gActiveBattler][3]; - if (gBattleBufferB[gActiveBattler][2] & RET_MEGA_EVOLUTION) + *(gBattleStruct->moveTarget + gActiveBattler) = gBattleResources->bufferB[gActiveBattler][3]; + if (gBattleResources->bufferB[gActiveBattler][2] & RET_MEGA_EVOLUTION) gBattleStruct->mega.toEvolve |= gBitTable[gActiveBattler]; gBattleCommunication[gActiveBattler]++; } @@ -4250,20 +4126,20 @@ static void HandleTurnActionSelectionState(void) } break; case B_ACTION_USE_ITEM: - if ((gBattleBufferB[gActiveBattler][1] | (gBattleBufferB[gActiveBattler][2] << 8)) == 0) + if ((gBattleResources->bufferB[gActiveBattler][1] | (gBattleResources->bufferB[gActiveBattler][2] << 8)) == 0) { gBattleCommunication[gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN; } else { - gLastUsedItem = (gBattleBufferB[gActiveBattler][1] | (gBattleBufferB[gActiveBattler][2] << 8)); + gLastUsedItem = (gBattleResources->bufferB[gActiveBattler][1] | (gBattleResources->bufferB[gActiveBattler][2] << 8)); if (ItemId_GetPocket(gLastUsedItem) == POCKET_POKE_BALLS) gBattleStruct->throwingPokeBall = TRUE; gBattleCommunication[gActiveBattler]++; } break; case B_ACTION_SWITCH: - if (gBattleBufferB[gActiveBattler][1] == PARTY_SIZE) + if (gBattleResources->bufferB[gActiveBattler][1] == PARTY_SIZE) { gBattleCommunication[gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN; RecordedBattle_ClearBattlerAction(gActiveBattler, 1); @@ -4285,7 +4161,7 @@ static void HandleTurnActionSelectionState(void) gBattleCommunication[gActiveBattler]++; break; case B_ACTION_SAFARI_POKEBLOCK: - if ((gBattleBufferB[gActiveBattler][1] | (gBattleBufferB[gActiveBattler][2] << 8)) != 0) + if ((gBattleResources->bufferB[gActiveBattler][1] | (gBattleResources->bufferB[gActiveBattler][2] << 8)) != 0) { gBattleCommunication[gActiveBattler]++; } @@ -4363,7 +4239,7 @@ static void HandleTurnActionSelectionState(void) case STATE_SELECTION_SCRIPT_MAY_RUN: if (*(gBattleStruct->selectionScriptFinished + gActiveBattler)) { - if (gBattleBufferB[gActiveBattler][1] == 13) + if (gBattleResources->bufferB[gActiveBattler][1] == 13) { gHitMarker |= HITMARKER_RUN; gChosenActionByBattler[gActiveBattler] = B_ACTION_RUN; @@ -4424,18 +4300,18 @@ static bool8 AllAtActionConfirmed(void) static void sub_803CDF8(void) { - *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = gBattleBufferB[gActiveBattler][1]; - RecordedBattle_SetBattlerAction(gActiveBattler, gBattleBufferB[gActiveBattler][1]); + *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = gBattleResources->bufferB[gActiveBattler][1]; + RecordedBattle_SetBattlerAction(gActiveBattler, gBattleResources->bufferB[gActiveBattler][1]); if (gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleTypeFlags & BATTLE_TYPE_MULTI) { *(gActiveBattler * 3 + (u8*)(gBattleStruct->field_60) + 0) &= 0xF; - *(gActiveBattler * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleBufferB[gActiveBattler][2] & 0xF0); - *(gActiveBattler * 3 + (u8*)(gBattleStruct->field_60) + 1) = gBattleBufferB[gActiveBattler][3]; + *(gActiveBattler * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleResources->bufferB[gActiveBattler][2] & 0xF0); + *(gActiveBattler * 3 + (u8*)(gBattleStruct->field_60) + 1) = gBattleResources->bufferB[gActiveBattler][3]; *((gActiveBattler ^ BIT_FLANK) * 3 + (u8*)(gBattleStruct->field_60) + 0) &= (0xF0); - *((gActiveBattler ^ BIT_FLANK) * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleBufferB[gActiveBattler][2] & 0xF0) >> 4; - *((gActiveBattler ^ BIT_FLANK) * 3 + (u8*)(gBattleStruct->field_60) + 2) = gBattleBufferB[gActiveBattler][3]; + *((gActiveBattler ^ BIT_FLANK) * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleResources->bufferB[gActiveBattler][2] & 0xF0) >> 4; + *((gActiveBattler ^ BIT_FLANK) * 3 + (u8*)(gBattleStruct->field_60) + 2) = gBattleResources->bufferB[gActiveBattler][3]; } } @@ -5544,7 +5420,7 @@ static void HandleAction_UseItem(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; ClearFuryCutterDestinyBondGrudge(gBattlerAttacker); - gLastUsedItem = gBattleBufferB[gBattlerAttacker][1] | (gBattleBufferB[gBattlerAttacker][2] << 8); + gLastUsedItem = gBattleResources->bufferB[gBattlerAttacker][1] | (gBattleResources->bufferB[gBattlerAttacker][2] << 8); if (gLastUsedItem <= ITEM_PREMIER_BALL) // is ball { @@ -5777,8 +5653,8 @@ static void HandleAction_ThrowPokeblock(void) gBattlerAttacker = gBattlerByTurnOrder[gCurrentTurnActionNumber]; gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - gBattleCommunication[MULTISTRING_CHOOSER] = gBattleBufferB[gBattlerAttacker][1] - 1; - gLastUsedItem = gBattleBufferB[gBattlerAttacker][2]; + gBattleCommunication[MULTISTRING_CHOOSER] = gBattleResources->bufferB[gBattlerAttacker][1] - 1; + gLastUsedItem = gBattleResources->bufferB[gBattlerAttacker][2]; if (gBattleResults.pokeblockThrows < 0xFF) gBattleResults.pokeblockThrows++; diff --git a/src/battle_message.c b/src/battle_message.c index 26ef9a615..d08e52cf2 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -2255,7 +2255,7 @@ void BufferStringBattle(u16 stringID) s32 i; const u8 *stringPtr = NULL; - gBattleMsgDataPtr = (struct BattleMsgData*)(&gBattleBufferA[gActiveBattler][4]); + gBattleMsgDataPtr = (struct BattleMsgData*)(&gBattleResources->bufferA[gActiveBattler][4]); gLastUsedItem = gBattleMsgDataPtr->lastItem; gLastUsedAbility = gBattleMsgDataPtr->lastAbility; gBattleScripting.battler = gBattleMsgDataPtr->scrActive; @@ -3420,7 +3420,7 @@ void BattlePutTextOnWindow(const u8 *text, u8 windowId) void SetPpNumbersPaletteInMoveSelection(void) { - struct ChooseMoveStruct *chooseMoveStruct = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]); + struct ChooseMoveStruct *chooseMoveStruct = (struct ChooseMoveStruct*)(&gBattleResources->bufferA[gActiveBattler][4]); const u16 *palPtr = gUnknown_08D85620; u8 var = GetCurrentPpToMaxPpState(chooseMoveStruct->currentPp[gMoveSelectionCursor[gActiveBattler]], chooseMoveStruct->maxPp[gMoveSelectionCursor[gActiveBattler]]); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 41b9d1c4e..dcea26322 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3288,7 +3288,7 @@ static void atk23_getexp(void) case 3: // Set stats and give exp if (gBattleControllerExecFlags == 0) { - gBattleBufferB[gBattleStruct->expGetterBattlerId][0] = 0; + gBattleResources->bufferB[gBattleStruct->expGetterBattlerId][0] = 0; if (GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_HP) && GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL) != MAX_LEVEL) { gBattleResources->statsBeforeLvlUp->hp = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_MAX_HP); @@ -3309,7 +3309,7 @@ static void atk23_getexp(void) if (gBattleControllerExecFlags == 0) { gActiveBattler = gBattleStruct->expGetterBattlerId; - if (gBattleBufferB[gActiveBattler][0] == CONTROLLER_TWORETURNVALUES && gBattleBufferB[gActiveBattler][1] == RET_VALUE_LEVELED_UP) + if (gBattleResources->bufferB[gActiveBattler][0] == CONTROLLER_TWORETURNVALUES && gBattleResources->bufferB[gActiveBattler][1] == RET_VALUE_LEVELED_UP) { u16 temp, battlerId = 0xFF; if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && gBattlerPartyIndexes[gActiveBattler] == gBattleStruct->expGetterMonId) @@ -3322,7 +3322,7 @@ static void atk23_getexp(void) BattleScriptPushCursor(); gLeveledUpInBattle |= gBitTable[gBattleStruct->expGetterMonId]; gBattlescriptCurrInstr = BattleScript_LevelUp; - gBattleMoveDamage = (gBattleBufferB[gActiveBattler][2] | (gBattleBufferB[gActiveBattler][3] << 8)); + gBattleMoveDamage = (gBattleResources->bufferB[gActiveBattler][2] | (gBattleResources->bufferB[gActiveBattler][3] << 8)); AdjustFriendship(&gPlayerParty[gBattleStruct->expGetterMonId], 0); // update battle mon structure after level up @@ -4487,7 +4487,7 @@ static void atk4D_switchindataupdate(void) for (i = 0; i < sizeof(struct BattlePokemon); i++) { - monData[i] = gBattleBufferB[gActiveBattler][4 + i]; + monData[i] = gBattleResources->bufferB[gActiveBattler][4 + i]; } gBattleMons[gActiveBattler].type1 = gBaseStats[gBattleMons[gActiveBattler].species].type1; @@ -4893,7 +4893,7 @@ static void atk50_openpartyscreen(void) if (gBitTable[2] & hitmarkerFaintBits && gBitTable[0] & hitmarkerFaintBits) { gActiveBattler = 2; - if (HasNoMonsToSwitch(2, gBattleBufferB[0][1], 6)) + if (HasNoMonsToSwitch(2, gBattleResources->bufferB[0][1], 6)) { gAbsentBattlerFlags |= gBitTable[gActiveBattler]; gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); @@ -4909,7 +4909,7 @@ static void atk50_openpartyscreen(void) if (gBitTable[3] & hitmarkerFaintBits && hitmarkerFaintBits & gBitTable[1]) { gActiveBattler = 3; - if (HasNoMonsToSwitch(3, gBattleBufferB[1][1], 6)) + if (HasNoMonsToSwitch(3, gBattleResources->bufferB[1][1], 6)) { gAbsentBattlerFlags |= gBitTable[gActiveBattler]; gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); @@ -5020,12 +5020,12 @@ static void atk51_switchhandleorder(void) case 0: for (i = 0; i < gBattlersCount; i++) { - if (gBattleBufferB[i][0] == 0x22) + if (gBattleResources->bufferB[i][0] == 0x22) { - *(gBattleStruct->monToSwitchIntoId + i) = gBattleBufferB[i][1]; + *(gBattleStruct->monToSwitchIntoId + i) = gBattleResources->bufferB[i][1]; if (!(gBattleStruct->field_93 & gBitTable[i])) { - RecordedBattle_SetBattlerAction(i, gBattleBufferB[i][1]); + RecordedBattle_SetBattlerAction(i, gBattleResources->bufferB[i][1]); gBattleStruct->field_93 |= gBitTable[i]; } } @@ -5038,23 +5038,23 @@ static void atk51_switchhandleorder(void) case 2: if (!(gBattleStruct->field_93 & gBitTable[gActiveBattler])) { - RecordedBattle_SetBattlerAction(gActiveBattler, gBattleBufferB[gActiveBattler][1]); + RecordedBattle_SetBattlerAction(gActiveBattler, gBattleResources->bufferB[gActiveBattler][1]); gBattleStruct->field_93 |= gBitTable[gActiveBattler]; } // fall through case 3: - gBattleCommunication[0] = gBattleBufferB[gActiveBattler][1]; - *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = gBattleBufferB[gActiveBattler][1]; + gBattleCommunication[0] = gBattleResources->bufferB[gActiveBattler][1]; + *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = gBattleResources->bufferB[gActiveBattler][1]; if (gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleTypeFlags & BATTLE_TYPE_MULTI) { *(gActiveBattler * 3 + (u8*)(gBattleStruct->field_60) + 0) &= 0xF; - *(gActiveBattler * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleBufferB[gActiveBattler][2] & 0xF0); - *(gActiveBattler * 3 + (u8*)(gBattleStruct->field_60) + 1) = gBattleBufferB[gActiveBattler][3]; + *(gActiveBattler * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleResources->bufferB[gActiveBattler][2] & 0xF0); + *(gActiveBattler * 3 + (u8*)(gBattleStruct->field_60) + 1) = gBattleResources->bufferB[gActiveBattler][3]; *((gActiveBattler ^ BIT_FLANK) * 3 + (u8*)(gBattleStruct->field_60) + 0) &= (0xF0); - *((gActiveBattler ^ BIT_FLANK) * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleBufferB[gActiveBattler][2] & 0xF0) >> 4; - *((gActiveBattler ^ BIT_FLANK) * 3 + (u8*)(gBattleStruct->field_60) + 2) = gBattleBufferB[gActiveBattler][3]; + *((gActiveBattler ^ BIT_FLANK) * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleResources->bufferB[gActiveBattler][2] & 0xF0) >> 4; + *((gActiveBattler ^ BIT_FLANK) * 3 + (u8*)(gBattleStruct->field_60) + 2) = gBattleResources->bufferB[gActiveBattler][3]; } else if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) { @@ -5066,7 +5066,7 @@ static void atk51_switchhandleorder(void) } PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBattlerAttacker].species) - PREPARE_MON_NICK_BUFFER(gBattleTextBuff2, gActiveBattler, gBattleBufferB[gActiveBattler][1]) + PREPARE_MON_NICK_BUFFER(gBattleTextBuff2, gActiveBattler, gBattleResources->bufferB[gActiveBattler][1]) break; } @@ -5571,7 +5571,7 @@ static void atk5E(void) if (gBattleControllerExecFlags == 0) { s32 i; - struct BattlePokemon *bufferPoke = (struct BattlePokemon*) &gBattleBufferB[gActiveBattler][4]; + struct BattlePokemon *bufferPoke = (struct BattlePokemon*) &gBattleResources->bufferB[gActiveBattler][4]; for (i = 0; i < MAX_MON_MOVES; i++) { gBattleMons[gActiveBattler].moves[i] = bufferPoke->moves[i]; @@ -8823,45 +8823,36 @@ static void atkA6_settypetorandomresistance(void) // conversion 2 } else { - s32 i, j, rands; + u32 i, resistTypes = 0; + u32 hitByType = gLastHitByType[gBattlerAttacker]; - for (rands = 0; rands < 1000; rands++) + for (i = 0; i < NUMBER_OF_MON_TYPES; i++) // Find all types that resist. { - while (((i = (Random() & 0x7F)) > sizeof(gTypeEffectiveness) / 3)); - - i *= 3; - - if (TYPE_EFFECT_ATK_TYPE(i) == gLastHitByType[gBattlerAttacker] - && TYPE_EFFECT_MULTIPLIER(i) <= TYPE_MUL_NOT_EFFECTIVE - && !IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_EFFECT_DEF_TYPE(i))) + switch (GetTypeModifier(hitByType, i)) { - SET_BATTLER_TYPE(gBattlerAttacker, TYPE_EFFECT_DEF_TYPE(i)); - PREPARE_TYPE_BUFFER(gBattleTextBuff1, TYPE_EFFECT_DEF_TYPE(i)); - - gBattlescriptCurrInstr += 5; - return; + case UQ_4_12(0): + case UQ_4_12(0.5): + resistTypes |= gBitTable[i]; + break; } } - for (j = 0, rands = 0; rands < sizeof(gTypeEffectiveness); j += 3, rands += 3) + while (resistTypes != 0) { - switch (TYPE_EFFECT_ATK_TYPE(j)) + i = Random() % NUMBER_OF_MON_TYPES; + if (resistTypes & gBitTable[i]) { - case TYPE_ENDTABLE: - case TYPE_FORESIGHT: - break; - default: - if (TYPE_EFFECT_ATK_TYPE(j) == gLastHitByType[gBattlerAttacker] - && TYPE_EFFECT_MULTIPLIER(j) <= 5 - && !IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_EFFECT_DEF_TYPE(i))) + if (IS_BATTLER_OF_TYPE(gBattlerAttacker, i)) { - SET_BATTLER_TYPE(gBattlerAttacker, TYPE_EFFECT_DEF_TYPE(rands)); - PREPARE_TYPE_BUFFER(gBattleTextBuff1, TYPE_EFFECT_DEF_TYPE(rands)) - + resistTypes &= ~(gBitTable[i]); // Type resists, but the user is already of this type. + } + else + { + SET_BATTLER_TYPE(gBattlerAttacker, i); + PREPARE_TYPE_BUFFER(gBattleTextBuff1, i); gBattlescriptCurrInstr += 5; return; } - break; } } diff --git a/src/battle_util.c b/src/battle_util.c index 4201f59a0..5dca40426 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -629,7 +629,7 @@ static bool32 IsHealBlockPreventingMove(u8 battler, u32 move) u8 TrySetCantSelectMoveBattleScript(void) { u8 limitations = 0; - u8 moveId = gBattleBufferB[gActiveBattler][2] & ~(RET_MEGA_EVOLUTION); + u8 moveId = gBattleResources->bufferB[gActiveBattler][2] & ~(RET_MEGA_EVOLUTION); u32 move = gBattleMons[gActiveBattler].moves[moveId]; u32 holdEffect = GetBattlerHoldEffect(gActiveBattler, TRUE); u16* choicedMove = &gBattleStruct->choicedMove[gActiveBattler]; @@ -5735,7 +5735,7 @@ bool32 CanMegaEvolve(u8 battlerId) struct Pokemon *mon; u8 battlerPosition = GetBattlerPosition(battlerId); u8 partnerPosition = GetBattlerPosition(BATTLE_PARTNER(battlerId)); - struct MegaEvolutionData *mega = &(((struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]))->mega); + struct MegaEvolutionData *mega = &(((struct ChooseMoveStruct*)(&gBattleResources->bufferA[gActiveBattler][4]))->mega); // Check if trainer already mega evolved a pokemon. if (mega->alreadyEvolved[battlerPosition])