diff --git a/include/battle.h b/include/battle.h index 01d4654ff..e4e1cb425 100644 --- a/include/battle.h +++ b/include/battle.h @@ -385,10 +385,10 @@ struct BattleStruct /* 0x2000000 */ /*0x160A5*/ u8 animArg2; /*0x160A6*/ u8 unk160A6; // related to gAbsentBattlerFlags, possibly absent flags turn ago? /*0x160A7*/ u8 unk160A7; - /*0x160A8*/ u8 unk160A8; - /*0x160A9*/ u8 unk160A9; - /*0x160AA*/ u8 unk160AA; - /*0x160AB*/ u8 unk160AB; + /*0x160A8*/ u8 wallyBattleState; + /*0x160A9*/ u8 wallyMovesState; + /*0x160AA*/ u8 wallyWaitFrames; + /*0x160AB*/ u8 wallyMoveFrames; /*0x160AC*/ u16 lastTakenMove[2 * 2 * 2]; /*0x160BC*/ u16 HP_OnSwitchout[2]; /*0x160C0*/ u8 abilityPreventingSwitchout; @@ -443,27 +443,27 @@ struct BattleSpriteInfo { u8 invisible:1; u8 lowHpSong:1; - u8 substituteSprite:1; + u8 behindSubstitute:1; u8 flag_x8:1; u8 hpNumbersNoBars:1; - u16 transformedSpecies; + u16 transformSpecies; }; -struct Struct2017810 +struct BattleHealthboxInfo { - /*0x00*/ u8 unk0_0:1; + /*0x00*/ u8 partyStatusSummaryShown:1; /*0x00*/ u8 unk0_1:1; /*0x00*/ u8 unk0_2:1; - /*0x00*/ u8 unk0_3:1; - /*0x00*/ u8 unk0_4:1; - /*0x00*/ u8 unk0_5:1; - /*0x00*/ u8 unk0_6:1; - /*0x00*/ u8 unk0_7:1; - /*0x01*/ u8 unk1_0:1; + /*0x00*/ u8 ballAnimActive:1; + /*0x00*/ u8 statusAnimActive:1; + /*0x00*/ u8 animFromTableActive:1; + /*0x00*/ u8 specialAnimActive:1; + /*0x00*/ u8 triedShinyMonAnim:1; + /*0x01*/ u8 finishedShinyMonAnim:1; /*0x01*/ u8 unk1_1:5; /*0x02*/ u8 unk2; /*0x03*/ u8 unk3; - /*0x04*/ u8 unk4; + /*0x04*/ u8 animationState; /*0x05*/ u8 unk5; /*0x06*/ u8 unk6; /*0x07*/ u8 unk7; @@ -685,20 +685,20 @@ u8 TypeCalc(u16 move, u8 bank_atk, u8 bank_def); u8 GetBattlerTurnOrderNum(u8 bank); // asm/battle_5.o -void nullsub_91(void); +void BattleControllerDummy(void); void SetBankFuncToPlayerBufferRunCommand(void); void sub_802C098(); -void c3_0802FDF4(u8); +void Task_PlayerController_RestoreBgmAfterCry(u8); void sub_802E3E4(u8, int); void nullsub_8(u8); void sub_802E414(void); void sub_802E424(void); // asm/battle_7.o -void move_anim_start_t4(u8 a, u8 b, u8 c, u8 d); +void InitAndLaunchSpecialAnimation(u8 a, u8 b, u8 c, u8 d); void nullsub_9(u16); void nullsub_10(int); -void load_gfxc_health_bar(u8); +void LoadBattleBarGfx(u8); u8 battle_load_something(); void sub_8031F88(u8); void HandleLowHpMusicChange(struct Pokemon *, u8); diff --git a/include/battle_anim_8137220.h b/include/battle_anim_8137220.h index 73bf0d883..c1e692e0f 100644 --- a/include/battle_anim_8137220.h +++ b/include/battle_anim_8137220.h @@ -1,6 +1,6 @@ #ifndef GUARD_BATTLE_ANIM_8137220_H #define GUARD_BATTLE_ANIM_8137220_H -void SetBankFuncToWallyBufferRunCommand(void); +void SetControllerToWally(void); #endif // GUARD_BATTLE_ANIM_8137220_H diff --git a/include/battle_anim_special.h b/include/battle_anim_special.h index fea5d186d..cf2e937b5 100644 --- a/include/battle_anim_special.h +++ b/include/battle_anim_special.h @@ -1,7 +1,7 @@ #ifndef GUARD_BATTLE_ANIM_813F0F4_H #define GUARD_BATTLE_ANIM_813F0F4_H -void sub_8141828(u8, struct Pokemon *); +void TryShinyAnimation(u8, struct Pokemon *); u8 ball_number_to_ball_processing_index(u16); u8 AnimateBallOpenParticles(u8, u8, u8, u8, u8); u8 sub_8141314(u8, u8, u32, u8); diff --git a/include/battle_controllers.h b/include/battle_controllers.h index ea11d5d73..99905602a 100644 --- a/include/battle_controllers.h +++ b/include/battle_controllers.h @@ -1,8 +1,7 @@ #ifndef GUARD_BATTLE_CONTROLLERS_H #define GUARD_BATTLE_CONTROLLERS_H -enum -{ +enum { REQUEST_ALL_BATTLE, REQUEST_SPECIES_BATTLE, REQUEST_HELDITEM_BATTLE, @@ -65,6 +64,38 @@ enum REQUEST_TOUGH_RIBBON_BATTLE, }; +enum { + // For commands sent from the core battle engine to a controller. + B_COMM_TO_CONTROLLER, // gBattleBufferA + + // For replies sent from a controller to the core battle engine. + B_COMM_TO_ENGINE, // gBattleBufferB + + // During local play, a controller must directly mark itself as + // inactive when it's done processing, whether or not it sends + // a reply. During multiplayer, it must NOT directly mark itself + // as inactive, but instead send one of these, with the player's + // multiplayer ID as data. + B_COMM_CONTROLLER_IS_DONE +}; + +enum { + BALL_NO_SHAKES, + BALL_1_SHAKE, + BALL_2_SHAKES, + BALL_3_SHAKES_FAIL, + BALL_3_SHAKES_SUCCESS, + BALL_TRAINER_BLOCK, +}; + +#define INSTANT_HP_BAR_DROP 0x7FFF + +struct HpAndStatus +{ + u16 hp; + u32 status; +}; + enum { CONTROLLER_GETMONDATA, @@ -86,7 +117,7 @@ enum CONTROLLER_PRINTSTRING, CONTROLLER_PRINTSTRINGPLAYERONLY, CONTROLLER_CHOOSEACTION, - CONTROLLER_UNKNOWNYESNOBOX, + CONTROLLER_YESNOBOX, CONTROLLER_CHOOSEMOVE, CONTROLLER_OPENBAG, CONTROLLER_CHOOSEPOKEMON, @@ -98,19 +129,19 @@ enum CONTROLLER_STATUSXOR, CONTROLLER_DATATRANSFER, CONTROLLER_DMA3TRANSFER, - CONTROLLER_31, + CONTROLLER_PLAYBGM, CONTROLLER_32, CONTROLLER_TWORETURNVALUES, CONTROLLER_CHOSENMONRETURNVALUE, CONTROLLER_ONERETURNVALUE, CONTROLLER_ONERETURNVALUE_DUPLICATE, - CONTROLLER_37, - CONTROLLER_38, - CONTROLLER_39, - CONTROLLER_40, + CONTROLLER_CLEARUNKVAR, + CONTROLLER_SETUNKVAR, + CONTROLLER_CLEARUNKFLAG, + CONTROLLER_TOGGLEUNKFLAG, CONTROLLER_HITANIMATION, - CONTROLLER_42, - CONTROLLER_EFFECTIVENESSSOUND, + CONTROLLER_CANTSWITCH, + CONTROLLER_PLAYSE, CONTROLLER_PLAYFANFAREORBGM, CONTROLLER_FAINTINGCRY, CONTROLLER_INTROSLIDE, @@ -122,18 +153,12 @@ enum CONTROLLER_BATTLEANIMATION, CONTROLLER_LINKSTANDBYMSG, CONTROLLER_RESETACTIONMOVESELECTION, - CONTROLLER_55, + CONTROLLER_ENDLINKBATTLE, /*new controllers should go here*/ CONTROLLER_TERMINATOR_NOP, CONTROLLER_CMDS_COUNT }; -struct HpAndStatus -{ - u16 hp; - u32 status; -}; - struct DisableStruct; // emitters diff --git a/include/battle_interface.h b/include/battle_interface.h index 6ad92d54f..5b5570f4a 100644 --- a/include/battle_interface.h +++ b/include/battle_interface.h @@ -12,22 +12,50 @@ struct BattleInterfaceStruct1 u32 unk10; }; +enum +{ + HP_CURRENT, + HP_MAX +}; + +enum +{ + HEALTH_BAR, + EXP_BAR +}; + +enum +{ + HEALTHBOX_ALL, + HEALTHBOX_CURRENT_HP, + HEALTHBOX_MAX_HP, + HEALTHBOX_LEVEL, + HEALTHBOX_NICK, + HEALTHBOX_HEALTH_BAR, + HEALTHBOX_EXP_BAR, + HEALTHBOX_UNUSED_7, + HEALTHBOX_UNUSED_8, + HEALTHBOX_STATUS_ICON, + HEALTHBOX_SAFARI_ALL_TEXT, + HEALTHBOX_SAFARI_BALLS_TEXT +}; + u8 battle_make_oam_normal_battle(u8); u8 battle_make_oam_safari_battle(void); -void sub_8043D84(u8, u8, u32, u32, u32); -void sub_8043DB0(u8); -void sub_8043DFC(u8); +void SetBattleBarStruct(u8, u8, u32, u32, u32); +void SetHealthboxSpriteInvisible(u8); +void SetHealthboxSpriteVisible(u8); void nullsub_11(); void UpdateOamPriorityInAllHealthboxes(u8); void sub_8043F44(u8); void sub_804454C(void); u8 CreatePartyStatusSummarySprites(u8, const struct HpAndStatus *, u8, u8); void sub_8044CA0(u8); -void sub_8045A5C(u8, struct Pokemon *, u8); -s32 sub_8045C78(u8, u8, u8, u8); +void UpdateHealthboxAttribute(u8, struct Pokemon *, u8); +s32 MoveBattleBar(u8, u8, u8, u8); s16 sub_80460C8(struct BattleInterfaceStruct1 *, int *, u16 *, int); u8 GetScaledHPFraction(s16, s16, u8); u8 GetHPBarLevel(s16, s16); -void sub_80440EC(u8 a, s16 b, u8 c); +void UpdateHpTextInHealthbox(u8 a, s16 b, u8 c); #endif // GUARD_BATTLE_INTERFACE_H diff --git a/include/constants/battle.h b/include/constants/battle.h index 29feb7022..71a360a33 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -289,6 +289,10 @@ #define BATTLE_ENVIRONMENT_BUILDING 8 #define BATTLE_ENVIRONMENT_PLAIN 9 +#define B_WAIT_TIME_LONG 64 +#define B_WAIT_TIME_MED 48 +#define B_WAIT_TIME_SHORT 32 + #define TARGET_SELECTED_POKEMON 0 #define TARGET_SPECIAL (1 << 0) #define TARGET_UNK2 (1 << 1) @@ -385,15 +389,6 @@ #define B_ANIM_INGRAIN_HEAL 0x15 #define B_ANIM_WISH_HEAL 0x16 -// special animation table -#define B_ANIM_LVL_UP 0x0 -#define B_ANIM_SWITCH_OUT_PLAYER_MON 0x1 -#define B_ANIM_SWITCH_OUT_OPPONENT_MON 0x2 -#define B_ANIM_BALL_THROW 0x3 -#define B_ANIM_SAFARI_BALL_THROW 0x4 -#define B_ANIM_SUBSTITUTE_TO_MON 0x5 -#define B_ANIM_MON_TO_SUBSTITUTE 0x6 - // AI switch items #define AI_ITEM_FULL_RESTORE 1 #define AI_ITEM_HEAL_HP 2 diff --git a/include/constants/battle_anim.h b/include/constants/battle_anim.h index f437a08a6..14711b36d 100644 --- a/include/constants/battle_anim.h +++ b/include/constants/battle_anim.h @@ -380,7 +380,7 @@ #define B_ANIM_SWITCH_OUT_PLAYER_MON 0x1 #define B_ANIM_SWITCH_OUT_OPPONENT_MON 0x2 #define B_ANIM_BALL_THROW 0x3 -#define B_ANIM_SAFARI_BALL_THROW 0x4 +#define B_ANIM_BALL_THROW_WITH_TRAINER 0x4 #define B_ANIM_SUBSTITUTE_TO_MON 0x5 #define B_ANIM_MON_TO_SUBSTITUTE 0x6 diff --git a/include/trainer.h b/include/constants/trainers.h similarity index 98% rename from include/trainer.h rename to include/constants/trainers.h index 96143245a..e070f97b1 100644 --- a/include/trainer.h +++ b/include/constants/trainers.h @@ -190,6 +190,12 @@ enum { TRAINER_PIC_DRAKE, }; +enum { + TRAINER_BACK_PIC_BRENDAN, + TRAINER_BACK_PIC_MAY, + TRAINER_BACK_PIC_WALLY, +}; + enum { TRAINER_CLASS_POKEMON_TRAINER_1, TRAINER_CLASS_POKEMON_TRAINER_2, diff --git a/include/ewram.h b/include/ewram.h index e1639e4a9..e29f9a51b 100644 --- a/include/ewram.h +++ b/include/ewram.h @@ -35,18 +35,18 @@ extern u8 gSharedMem[]; #define ewram16400 (gSharedMem + 0x16400) // gBattleResources -#define AI_THINKING_STRUCT ((struct AI_ThinkingStruct *)(gSharedMem + 0x16800)) -#define AI_BATTLE_HISTORY ((struct BattleHistory *) (gSharedMem + 0x16A00)) -#define AI_STACK ((struct AI_Stack *) (gSharedMem + 0x16C00)) -#define eSecretBaseRecord ((struct SecretBaseRecord *)(gSharedMem + 0x17000)) -#define eBattleFlagsArr (*(struct ResourceFlags *)(gSharedMem + 0x17100)) -#define B_BATTLESCRIPTS_STACK ((struct BattleScriptsStack *) (gSharedMem + 0x17110)) -#define B_FUNCTION_STACK ((struct BattleCallbacksStack *) (gSharedMem + 0x17140)) +#define AI_THINKING_STRUCT ((struct AI_ThinkingStruct *)(gSharedMem + 0x16800)) +#define AI_BATTLE_HISTORY ((struct BattleHistory *) (gSharedMem + 0x16A00)) +#define AI_STACK ((struct AI_Stack *) (gSharedMem + 0x16C00)) +#define eSecretBaseRecord ((struct SecretBaseRecord *)(gSharedMem + 0x17000)) +#define eBattleFlagsArr (*(struct ResourceFlags *)(gSharedMem + 0x17100)) +#define B_BATTLESCRIPTS_STACK ((struct BattleScriptsStack *) (gSharedMem + 0x17110)) +#define B_FUNCTION_STACK ((struct BattleCallbacksStack *) (gSharedMem + 0x17140)) #define gBattleResources_statsBeforeLvlUp ((struct StatsArray *)(gSharedMem + 0x17180)) -#define gBattleSpriteInfo ((struct BattleSpriteInfo *) (gSharedMem + 0x17800)) -#define ewram17810 ((struct Struct2017810 *) (gSharedMem + 0x17810)) -#define ewram17840 (*(struct Struct2017840 *) (gSharedMem + 0x17840)) -#define eBattleBars ((struct BattleBar *)(gSharedMem + 0x17850)) +#define gBattleSpriteInfo ((struct BattleSpriteInfo *) (gSharedMem + 0x17800)) +#define gBattleHealthBoxInfo ((struct BattleHealthboxInfo *) (gSharedMem + 0x17810)) +#define ewram17840 (*(struct Struct2017840 *) (gSharedMem + 0x17840)) +#define eBattleBars ((struct BattleBar *)(gSharedMem + 0x17850)) #define eBattleAnimPalBackup_Battle ((u16 *)(gSharedMem + 0x18000)) // also: shop.c, battle_anim.c diff --git a/include/global.h b/include/global.h index faa9c9a52..e0bf992b2 100644 --- a/include/global.h +++ b/include/global.h @@ -55,6 +55,7 @@ #define POKEMON_SLOTS_NUMBER 412 #define POKEMON_NAME_LENGTH 10 +#define POKEMON_NAME_BUFFER_SIZE max(20, POKEMON_NAME_LENGTH + 1) // Frequently used buffer size. Larger than necessary #define OT_NAME_LENGTH 7 #define min(a, b) ((a) < (b) ? (a) : (b)) diff --git a/include/pokeball.h b/include/pokeball.h index e814718c0..3ba1071ba 100644 --- a/include/pokeball.h +++ b/include/pokeball.h @@ -3,8 +3,11 @@ extern const struct SpriteTemplate gBallSpriteTemplates[]; +#define POKEBALL_PLAYER_SENDOUT 0xFF +#define POKEBALL_OPPONENT_SENDOUT 0xFE + void CreatePokeballSprite(u8 r0, u8 r1, u8 r2, u8 r3, u8 s1, u8 s2, u8 s3, u32 s4); -void sub_804777C(u8); +void StartHealthboxSlideIn(u8); void LoadBallGraphics(u8); void FreeBallGraphics(u8); u8 sub_8047580(u8, u8, u8, u8, u8, u8, u8, u32); diff --git a/include/pokemon.h b/include/pokemon.h index 1b1bbf54c..565512dda 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -435,8 +435,8 @@ u8 sub_803C434(u8 a1); u8 GetMonGender(struct Pokemon *mon); u8 GetBoxMonGender(struct BoxPokemon *boxMon); u8 GetGenderFromSpeciesAndPersonality(u16 species, u32 personality); -void GetMonSpriteTemplate_803C56C(u16 species, u8 a2); -void GetMonSpriteTemplate_803C5A0(u16 species, u8 a2); +void SetMultiuseSpriteTemplateToPokemon(u16 species, u8 a2); +void SetMultiuseSpriteTemplateToTrainerBack(u16 species, u8 a2); void EncryptBoxMon(struct BoxPokemon *boxMon); void DecryptBoxMon(struct BoxPokemon *boxMon); union PokemonSubstruct *GetSubstruct(struct BoxPokemon *boxMon, u32 personality, u8 substructType); diff --git a/include/rom_8077ABC.h b/include/rom_8077ABC.h index c4cdfd7ad..b8508f3c1 100644 --- a/include/rom_8077ABC.h +++ b/include/rom_8077ABC.h @@ -63,7 +63,7 @@ void *sub_8079BFC(s16 bottom, s16 top); void sub_8079C08(struct Task *task, u8 a2, s16 a3, s16 a4, s16 a5, s16 a6, u16 a7); u8 sub_8079C74(struct Task *task); void UpdateBattlerSpritePriorities(); -u8 GetBattlerSubpriority(u8 bank); +u8 GetBattlerSpriteSubpriority(u8 bank); u8 GetBattlerPosition_permutated(u8 slot); void sub_807A784(u8 taskId); void sub_807A850(struct Task *task, u8 taskId); @@ -107,7 +107,7 @@ u8 sub_8077FC0(u8 slot); void DestroySpriteAndMatrix(struct Sprite *sprite); bool8 TranslateAnimArc(struct Sprite *sprite); bool8 sub_8078CE8(struct Sprite *sprite); -void oamt_add_pos2_onto_pos1(struct Sprite *sprite); +void SetSpritePrimaryCoordsFromSecondaryCoords(struct Sprite *sprite); void sub_8078BD4(struct Sprite *sprite); void TranslateAnimSpriteToTargetMonLocation(struct Sprite *sprite); void sub_80789D4(bool8 a1); diff --git a/include/sound.h b/include/sound.h index d883fd9c7..d7be836cb 100644 --- a/include/sound.h +++ b/include/sound.h @@ -25,7 +25,7 @@ bool8 IsBGMPausedOrStopped(void); void FadeInBGM(u8 speed); void FadeOutBGM(u8 speed); bool8 IsBGMStopped(void); -void PlayCry1(u16 species, s8 pan); +void PlayCry_Normal(u16 species, s8 pan); void PlayCry2(u16 species, s8 pan, s8 volume, u8 priority); void PlayCry3(u16 species, s8 pan, u8 mode); void PlayCry4(u16 species, s8 pan, u8 mode); diff --git a/src/battle/anim/battle_intro.c b/src/battle/anim/battle_intro.c index 8d257c5e1..d7897c1e7 100644 --- a/src/battle/anim/battle_intro.c +++ b/src/battle/anim/battle_intro.c @@ -40,7 +40,7 @@ static const TaskFunc sBattleIntroTaskFuncs[] = #define tBgXOffset data[2] #define tFramesUntilBg1Slide data[3] -void StartBattleIntroAnim(u8 a) +void HandleIntroSlide(u8 a) { u8 taskId; diff --git a/src/battle/anim/current.c b/src/battle/anim/current.c index 8c5bfbef1..9b6b8fb7c 100644 --- a/src/battle/anim/current.c +++ b/src/battle/anim/current.c @@ -1086,7 +1086,7 @@ void sub_80D759C(u8 taskId) } task->data[13] = GetBattlerSpriteCoord(gBattleAnimTarget, 2); - task->data[12] = GetBattlerSubpriority(gBattleAnimTarget) - 2; + task->data[12] = GetBattlerSpriteSubpriority(gBattleAnimTarget) - 2; task->data[0]++; break; case 1: diff --git a/src/battle/anim/devil.c b/src/battle/anim/devil.c index b083241e0..00f3cd24e 100644 --- a/src/battle/anim/devil.c +++ b/src/battle/anim/devil.c @@ -45,7 +45,7 @@ void sub_80D2ABC(struct Sprite *sprite) sprite->x += gBattleAnimArgs[0]; sprite->y += gBattleAnimArgs[1]; StartSpriteAnim(sprite, 0); - sprite->subpriority = GetBattlerSubpriority(gBattleAnimTarget) - 1; + sprite->subpriority = GetBattlerSpriteSubpriority(gBattleAnimTarget) - 1; sprite->data[2] = 1; } sprite->data[0] += sprite->data[2]; diff --git a/src/battle/anim/energy_wave.c b/src/battle/anim/energy_wave.c index 6e29ccc31..6673354f4 100644 --- a/src/battle/anim/energy_wave.c +++ b/src/battle/anim/energy_wave.c @@ -232,7 +232,7 @@ void sub_80D3698(struct Sprite *sprite) sprite->y = GetBattlerSpriteCoord(gBattleAnimAttacker, 1); sprite->y2 = -10; - subpriority = GetBattlerSubpriority(gBattleAnimAttacker); + subpriority = GetBattlerSpriteSubpriority(gBattleAnimAttacker); if (!IsContest()) { diff --git a/src/battle/anim/flying_path.c b/src/battle/anim/flying_path.c index 4723dc3cb..1d4e9b287 100644 --- a/src/battle/anim/flying_path.c +++ b/src/battle/anim/flying_path.c @@ -84,7 +84,7 @@ void sub_80CBDF4(u8 taskId) { struct Task *task = &gTasks[taskId]; - task->data[4] = GetBattlerSubpriority(gBattleAnimTarget) - 1; + task->data[4] = GetBattlerSpriteSubpriority(gBattleAnimTarget) - 1; task->data[6] = GetBattlerSpriteCoord(gBattleAnimTarget, 2); task->data[7] = GetBattlerSpriteCoord(gBattleAnimTarget, 3); task->data[10] = GetBattlerSpriteCoordAttr(gBattleAnimTarget, 1); diff --git a/src/battle/anim/ghost.c b/src/battle/anim/ghost.c index d7ac9882b..1ec56c2c1 100644 --- a/src/battle/anim/ghost.c +++ b/src/battle/anim/ghost.c @@ -1177,7 +1177,7 @@ void sub_80DF1A4(u8 taskId) task->data[11] = (GetBattlerSpriteCoordAttr(gBattleAnimAttacker, 1) / 2) + 8; task->data[7] = 0; task->data[5] = GetBattlerSpriteBGPriority(gBattleAnimAttacker); - task->data[6] = GetBattlerSubpriority(gBattleAnimAttacker) - 2; + task->data[6] = GetBattlerSpriteSubpriority(gBattleAnimAttacker) - 2; task->data[3] = 0; task->data[4] = 16; REG_BLDCNT = 0x3F40; diff --git a/src/battle/anim/hidden_power_orbit.c b/src/battle/anim/hidden_power_orbit.c index 4da3b3839..c5965a99c 100644 --- a/src/battle/anim/hidden_power_orbit.c +++ b/src/battle/anim/hidden_power_orbit.c @@ -58,7 +58,7 @@ void AnimOrbitFast(struct Sprite* sprite) sprite->affineAnimPaused = 1; sprite->data[0] = gBattleAnimArgs[0]; sprite->data[1] = gBattleAnimArgs[1]; - sprite->data[7] = GetBattlerSubpriority(gBattleAnimAttacker); + sprite->data[7] = GetBattlerSpriteSubpriority(gBattleAnimAttacker); sprite->callback = AnimOrbitFastStep; sprite->callback(sprite); } diff --git a/src/battle/anim/note_spin.c b/src/battle/anim/note_spin.c index 6b80d4880..26c0f7e76 100644 --- a/src/battle/anim/note_spin.c +++ b/src/battle/anim/note_spin.c @@ -116,7 +116,7 @@ void sub_80D2EC8(struct Sprite *sprite) sprite->callback = sub_80D2F80; sprite->data[0] = 0; - oamt_add_pos2_onto_pos1(sprite); + SetSpritePrimaryCoordsFromSecondaryCoords(sprite); sprite->data[2] = 5; sprite->data[4] = 0; sprite->data[3] = 0; diff --git a/src/battle/anim/orbit.c b/src/battle/anim/orbit.c index ad021900e..5fc135ae0 100644 --- a/src/battle/anim/orbit.c +++ b/src/battle/anim/orbit.c @@ -172,11 +172,11 @@ static void sub_80CADA8(struct Sprite* sprite) sprite->y2 += Cos(sprite->data[5], -5); if ((u16)(sprite->data[5] - 0x40) < 0x80) { - sprite->subpriority = GetBattlerSubpriority(gBattleAnimAttacker) - 1; + sprite->subpriority = GetBattlerSpriteSubpriority(gBattleAnimAttacker) - 1; } else { - sprite->subpriority = GetBattlerSubpriority(gBattleAnimAttacker) + 1; + sprite->subpriority = GetBattlerSpriteSubpriority(gBattleAnimAttacker) + 1; } sprite->data[5] = (sprite->data[5] + 5) & 0xFF; diff --git a/src/battle/anim/orbs.c b/src/battle/anim/orbs.c index 4041c8e10..e40e95d52 100644 --- a/src/battle/anim/orbs.c +++ b/src/battle/anim/orbs.c @@ -235,11 +235,11 @@ static void sub_80CA8B4(struct Sprite* sprite) { if (sprite->data[5] > 0x7F) { - sprite->subpriority = GetBattlerSubpriority(gBattleAnimTarget) + 1; + sprite->subpriority = GetBattlerSpriteSubpriority(gBattleAnimTarget) + 1; } else { - sprite->subpriority = GetBattlerSubpriority(gBattleAnimTarget) + 6; + sprite->subpriority = GetBattlerSpriteSubpriority(gBattleAnimTarget) + 6; } sprite->x2 += Sin(sprite->data[5], 5); sprite->y2 += Cos(sprite->data[5], 14); @@ -258,7 +258,7 @@ void sub_80CA928(u8 taskId) gBattleAnimArgs[1] = 0; gBattleAnimArgs[2] = 80; gBattleAnimArgs[3] = 0; - CreateSpriteAndAnimate(&gSpriteTemplate_83D631C, 0, 0, GetBattlerSubpriority(gBattleAnimTarget) + 1); + CreateSpriteAndAnimate(&gSpriteTemplate_83D631C, 0, 0, GetBattlerSpriteSubpriority(gBattleAnimTarget) + 1); } if (gTasks[taskId].data[1] == 15) diff --git a/src/battle/anim/sfx.c b/src/battle/anim/sfx.c index 349716e74..88a569485 100644 --- a/src/battle/anim/sfx.c +++ b/src/battle/anim/sfx.c @@ -182,7 +182,7 @@ void sub_812B18C(u8 taskId) { s16 mode = gBattleAnimArgs[1]; if (mode == 0xFF) - PlayCry1(species, pan); + PlayCry_Normal(species, pan); else PlayCry3(species, pan, mode); } diff --git a/src/battle/anim/shadow_minimize.c b/src/battle/anim/shadow_minimize.c index cb4841177..353be8bb3 100644 --- a/src/battle/anim/shadow_minimize.c +++ b/src/battle/anim/shadow_minimize.c @@ -27,7 +27,7 @@ void AnimTask_Minimize(u8 taskId) task->data[4] = 0x100; task->data[5] = 0; task->data[6] = 0; - task->data[7] = GetBattlerSubpriority(gBattleAnimAttacker); + task->data[7] = GetBattlerSpriteSubpriority(gBattleAnimAttacker); task->func = AnimTask_Minimize_Step; } diff --git a/src/battle/anim/sonic.c b/src/battle/anim/sonic.c index 2ece3c602..aaf3554a1 100644 --- a/src/battle/anim/sonic.c +++ b/src/battle/anim/sonic.c @@ -347,12 +347,12 @@ void sub_80CFB04(u8 taskId) gBattleAnimArgs[4] ^= 0x80; if (gBattleAnimArgs[4] >= 64) { - u16 var = GetBattlerSubpriority(gBattleAnimTarget) + (gBattleAnimArgs[4] - 64); + u16 var = GetBattlerSpriteSubpriority(gBattleAnimTarget) + (gBattleAnimArgs[4] - 64); gTasks[taskId].data[2] = var; } else { - u16 var = GetBattlerSubpriority(gBattleAnimTarget) - gBattleAnimArgs[4]; + u16 var = GetBattlerSpriteSubpriority(gBattleAnimTarget) - gBattleAnimArgs[4]; gTasks[taskId].data[2] = var; } } @@ -360,12 +360,12 @@ void sub_80CFB04(u8 taskId) { if (gBattleAnimArgs[4] >= 64) { - u16 var = GetBattlerSubpriority(gBattleAnimTarget) + (gBattleAnimArgs[4] - 64); + u16 var = GetBattlerSpriteSubpriority(gBattleAnimTarget) + (gBattleAnimArgs[4] - 64); gTasks[taskId].data[2] = var; } else { - u16 var = GetBattlerSubpriority(gBattleAnimTarget) - gBattleAnimArgs[4]; + u16 var = GetBattlerSpriteSubpriority(gBattleAnimTarget) - gBattleAnimArgs[4]; gTasks[taskId].data[2] = var; } } diff --git a/src/battle/anim/tile.c b/src/battle/anim/tile.c index 6696b3daf..5128c609d 100644 --- a/src/battle/anim/tile.c +++ b/src/battle/anim/tile.c @@ -198,10 +198,10 @@ void unref_sub_80CE260(u8 taskId) for (i = 0; i < gBattlersCount; i++) { if (gBattleAnimArgs[0] == 1 && GetBattlerSide(i) == 0) - sub_8043DB0(gHealthboxSpriteIds[i]); + SetHealthboxSpriteInvisible(gHealthboxSpriteIds[i]); if (gBattleAnimArgs[1] == 1 && GetBattlerSide(i) == 1) - sub_8043DB0(gHealthboxSpriteIds[i]); + SetHealthboxSpriteInvisible(gHealthboxSpriteIds[i]); } DestroyAnimVisualTask(taskId); @@ -212,7 +212,7 @@ void unref_sub_80CE2D4(u8 taskId) u8 i; for (i = 0; i < gBattlersCount; i++) { - sub_8043DFC(gHealthboxSpriteIds[i]); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[i]); } DestroyAnimVisualTask(taskId); diff --git a/src/battle/anim/water.c b/src/battle/anim/water.c index 9b7fcf317..583a60514 100644 --- a/src/battle/anim/water.c +++ b/src/battle/anim/water.c @@ -661,7 +661,7 @@ void sub_80D4418(struct Task *task, u8 taskId) s16 attackerCoordX = GetBattlerSpriteCoord(gBattleAnimAttacker, 2); s16 attackerCoordY = GetBattlerSpriteCoord(gBattleAnimAttacker, 3); s16 trigIndex = 172; - u8 subpriority = GetBattlerSubpriority(gBattleAnimAttacker) - 1; + u8 subpriority = GetBattlerSpriteSubpriority(gBattleAnimAttacker) - 1; s16 increment = 4 - task->data[1]; u8 spriteId; @@ -1060,7 +1060,7 @@ void sub_80D4D64(struct Sprite *sprite, s32 xDiff, s32 yDiff) spriteId = CreateSprite(&gSpriteTemplate_83D9420, combinedX, combinedY + something, 130); gSprites[spriteId].data[0] = 20; gSprites[spriteId].data[1] = randomSomethingY; - gSprites[spriteId].subpriority = GetBattlerSubpriority(gBattleAnimAttacker) - 1; + gSprites[spriteId].subpriority = GetBattlerSpriteSubpriority(gBattleAnimAttacker) - 1; if (randomSomethingX < 0) gSprites[spriteId].data[2] = -randomSomethingX; else @@ -1071,7 +1071,7 @@ void sub_80D4D64(struct Sprite *sprite, s32 xDiff, s32 yDiff) spriteId = CreateSprite(&gSpriteTemplate_83D9420, combinedX, combinedY - something, 130); gSprites[spriteId].data[0] = 20; gSprites[spriteId].data[1] = randomSomethingY; - gSprites[spriteId].subpriority = GetBattlerSubpriority(gBattleAnimAttacker) - 1; + gSprites[spriteId].subpriority = GetBattlerSpriteSubpriority(gBattleAnimAttacker) - 1; if (randomSomethingX > 0) gSprites[spriteId].data[2] = -randomSomethingX; else diff --git a/src/battle/battle_1.c b/src/battle/battle_1.c index 9ab9e08c5..920045d9e 100644 --- a/src/battle/battle_1.c +++ b/src/battle/battle_1.c @@ -2,13 +2,13 @@ #include "data2.h" #include "battle_setup.h" #include "battle.h" -#include "trainer.h" #include "graphics.h" #include "gba/types.h" #include "constants/species.h" #include "constants/moves.h" #include "constants/items.h" #include "constants/opponents.h" +#include "constants/trainers.h" const struct MonCoords gTrainerBackPicCoords[] = { {8, 4}, diff --git a/src/battle_anim.c b/src/battle_anim.c index 3c9062165..e5b3eb769 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -1660,7 +1660,7 @@ static void ScriptCmd_createsprite(void) else argVar *= -1; - subpriority = GetBattlerSubpriority(gBattleAnimTarget) + (s8)(argVar); + subpriority = GetBattlerSpriteSubpriority(gBattleAnimTarget) + (s8)(argVar); } else { @@ -1669,7 +1669,7 @@ static void ScriptCmd_createsprite(void) else argVar *= -1; - subpriority = GetBattlerSubpriority(gBattleAnimAttacker) + (s8)(argVar); + subpriority = GetBattlerSpriteSubpriority(gBattleAnimAttacker) + (s8)(argVar); } if (subpriority < 3) @@ -2526,7 +2526,7 @@ static void ScriptCmd_changebg(void) s8 BattleAnimAdjustPanning(s8 pan) { - if (!IsContest() && ewram17810[gBattleAnimAttacker].unk0_4) + if (!IsContest() && gBattleHealthBoxInfo[gBattleAnimAttacker].statusAnimActive) { if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) pan = SOUND_PAN_TARGET; @@ -2568,7 +2568,7 @@ s8 BattleAnimAdjustPanning(s8 pan) s8 BattleAnimAdjustPanning2(s8 pan) { - if (!IsContest() && ewram17810[gBattleAnimAttacker].unk0_4) + if (!IsContest() && gBattleHealthBoxInfo[gBattleAnimAttacker].statusAnimActive) { if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) pan = SOUND_PAN_TARGET; diff --git a/src/battle_anim_effects_3.c b/src/battle_anim_effects_3.c index a50f47ace..4d1e2a8a2 100644 --- a/src/battle_anim_effects_3.c +++ b/src/battle_anim_effects_3.c @@ -2360,7 +2360,7 @@ void sub_812D7E8(u8 taskId) if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_OPPONENT) { if (gTasks[taskId].data[10] == 0) - sub_8032984(gBattleAnimAttacker, gBattleSpriteInfo[gBattleAnimAttacker].transformedSpecies); + sub_8032984(gBattleAnimAttacker, gBattleSpriteInfo[gBattleAnimAttacker].transformSpecies); } } @@ -3146,9 +3146,9 @@ static void sub_812EEEC(struct Sprite *sprite) sprite->data[1] = (sprite->data[1] + 9) & 0xFF; if ((u16)sprite->data[1] < 64 || sprite->data[1] > 195) - sprite->subpriority = GetBattlerSubpriority(gBattleAnimAttacker) - 1; + sprite->subpriority = GetBattlerSpriteSubpriority(gBattleAnimAttacker) - 1; else - sprite->subpriority = GetBattlerSubpriority(gBattleAnimAttacker) + 1; + sprite->subpriority = GetBattlerSpriteSubpriority(gBattleAnimAttacker) + 1; if (sprite->data[5] == 0) { @@ -3200,7 +3200,7 @@ void AnimTask_RolePlaySilhouette(u8 taskId) isBackPic = 0; personality = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimTarget]], MON_DATA_PERSONALITY); otId = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimTarget]], MON_DATA_OT_ID); - if (gBattleSpriteInfo[gBattleAnimTarget].transformedSpecies == SPECIES_NONE) + if (gBattleSpriteInfo[gBattleAnimTarget].transformSpecies == SPECIES_NONE) { if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_PLAYER) species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimTarget]], MON_DATA_SPECIES); @@ -3209,7 +3209,7 @@ void AnimTask_RolePlaySilhouette(u8 taskId) } else { - species = gBattleSpriteInfo[gBattleAnimTarget].transformedSpecies; + species = gBattleSpriteInfo[gBattleAnimTarget].transformSpecies; } xOffset = 20; @@ -3220,7 +3220,7 @@ void AnimTask_RolePlaySilhouette(u8 taskId) isBackPic = 1; personality = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleAnimTarget]], MON_DATA_PERSONALITY); otId = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleAnimTarget]], MON_DATA_OT_ID); - if (gBattleSpriteInfo[gBattleAnimTarget].transformedSpecies == SPECIES_NONE) + if (gBattleSpriteInfo[gBattleAnimTarget].transformSpecies == SPECIES_NONE) { if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_PLAYER) species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimTarget]], MON_DATA_SPECIES); @@ -3229,7 +3229,7 @@ void AnimTask_RolePlaySilhouette(u8 taskId) } else { - species = gBattleSpriteInfo[gBattleAnimTarget].transformedSpecies; + species = gBattleSpriteInfo[gBattleAnimTarget].transformSpecies; } xOffset = -20; @@ -3716,7 +3716,7 @@ void sub_812FD7C(u8 taskId) task->data[4] = GetBattlerSpriteCoord(battler, 0); task->data[5] = GetBattlerSpriteCoord(battler, 1); - task->data[6] = GetBattlerSubpriority(battler); + task->data[6] = GetBattlerSpriteSubpriority(battler); task->data[15] = GetAnimBattlerSpriteId(gBattleAnimArgs[0]); PrepareAffineAnimInTaskData(task, task->data[15], &gUnknown_084028AC); task->func = sub_812FE20; @@ -4045,7 +4045,7 @@ void sub_8130554(u8 taskId) task->data[12] = GetBattlerSpriteCoord(gBattleAnimAttacker, 3); task->data[13] = GetBattlerSpriteCoord(gBattleAnimTarget, 2); task->data[14] = GetBattlerSpriteCoord(gBattleAnimTarget, 3) + GetBattlerSpriteCoordAttr(gBattleAnimTarget, 0) / 4; - task->data[15] = CreateSprite(&gSpriteTemplate_84029AC, task->data[11], task->data[12], GetBattlerSubpriority(gBattleAnimTarget) - 5); + task->data[15] = CreateSprite(&gSpriteTemplate_84029AC, task->data[11], task->data[12], GetBattlerSpriteSubpriority(gBattleAnimTarget) - 5); if (task->data[15] != MAX_SPRITES) { gSprites[task->data[15]].data[0] = 16; @@ -4737,12 +4737,12 @@ static void sub_8131564(struct Sprite *sprite) if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_PLAYER) { - sprite->subpriority = GetBattlerSubpriority(gBattleAnimTarget) - 2; + sprite->subpriority = GetBattlerSpriteSubpriority(gBattleAnimTarget) - 2; y2 = -144; } else { - sprite->subpriority = GetBattlerSubpriority(gBattleAnimTarget) + 2; + sprite->subpriority = GetBattlerSpriteSubpriority(gBattleAnimTarget) + 2; y2 = -96; } @@ -4951,7 +4951,7 @@ void AnimTask_SnatchOpposingMonMove(u8 taskId) personality = gContestResources__moveAnim.personality; otId = gContestResources__moveAnim.otId; species = gContestResources__moveAnim.targetSpecies; - subpriority = GetBattlerSubpriority(gBattleAnimAttacker); + subpriority = GetBattlerSpriteSubpriority(gBattleAnimAttacker); isBackPic = 0; x = -32; } @@ -4961,10 +4961,10 @@ void AnimTask_SnatchOpposingMonMove(u8 taskId) { personality = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_PERSONALITY); otId = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_OT_ID); - if (gBattleSpriteInfo[gBattleAnimTarget].transformedSpecies == SPECIES_NONE) + if (gBattleSpriteInfo[gBattleAnimTarget].transformSpecies == SPECIES_NONE) species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_SPECIES); else - species = gBattleSpriteInfo[gBattleAnimTarget].transformedSpecies; + species = gBattleSpriteInfo[gBattleAnimTarget].transformSpecies; subpriority = gSprites[GetAnimBattlerSpriteId(ANIM_BATTLER_TARGET)].subpriority + 1; isBackPic = 0; @@ -4974,10 +4974,10 @@ void AnimTask_SnatchOpposingMonMove(u8 taskId) { personality = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_PERSONALITY); otId = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_OT_ID); - if (gBattleSpriteInfo[gBattleAnimTarget].transformedSpecies == SPECIES_NONE) + if (gBattleSpriteInfo[gBattleAnimTarget].transformSpecies == SPECIES_NONE) species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_SPECIES); else - species = gBattleSpriteInfo[gBattleAnimTarget].transformedSpecies; + species = gBattleSpriteInfo[gBattleAnimTarget].transformSpecies; subpriority = gSprites[GetAnimBattlerSpriteId(ANIM_BATTLER_TARGET)].subpriority - 1; isBackPic = 1; @@ -4986,7 +4986,7 @@ void AnimTask_SnatchOpposingMonMove(u8 taskId) } spriteId2 = sub_8079F44(species, isBackPic, 0, x, GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y), subpriority, personality, otId); - if (gBattleSpriteInfo[gBattleAnimTarget].transformedSpecies != SPECIES_NONE) + if (gBattleSpriteInfo[gBattleAnimTarget].transformSpecies != SPECIES_NONE) BlendPalette((gSprites[spriteId2].oam.paletteNum * 16) | 0x100, 16, 6, RGB_WHITE); gTasks[taskId].data[15] = spriteId2; @@ -5201,7 +5201,7 @@ _08131A44:\n\ ldrh r5, [r0]\n\ ldr r0, _08131A70 @ =gBattleAnimAttacker\n\ ldrb r0, [r0]\n\ - bl GetBattlerSubpriority\n\ + bl GetBattlerSpriteSubpriority\n\ lsls r0, 24\n\ lsrs r4, r0, 24\n\ movs r7, 0\n\ diff --git a/src/battle_anim_special.c b/src/battle_anim_special.c index 23401b694..3d52e6479 100755 --- a/src/battle_anim_special.c +++ b/src/battle_anim_special.c @@ -721,7 +721,7 @@ void sub_813FBB8(u8 taskId) } ballIndex = ball_number_to_ball_processing_index(gLastUsedItem); - subpriority = GetBattlerSubpriority(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT)) + 1; + subpriority = GetBattlerSpriteSubpriority(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT)) + 1; spriteId = CreateSprite(&gBallSpriteTemplates[ballIndex], x + 32, y | 80, subpriority); gSprites[spriteId].data[0] = 34; gSprites[spriteId].data[1] = GetBattlerSpriteCoord(gBattleAnimTarget, 0); @@ -1843,7 +1843,7 @@ void sub_81416C4(u8 taskId) void sub_81417D8(u8 taskId) { - gBattleAnimArgs[7] = gBattleSpriteInfo[gBattleAnimAttacker].substituteSprite; + gBattleAnimArgs[7] = gBattleSpriteInfo[gBattleAnimAttacker].behindSubstitute; DestroyAnimVisualTask(taskId); } @@ -1853,7 +1853,7 @@ void sub_8141808(u8 taskId) DestroyAnimVisualTask(taskId); } -void sub_8141828(u8 battler, struct Pokemon *mon) +void TryShinyAnimation(u8 battler, struct Pokemon *mon) { int isShiny; u32 otId, personality; @@ -1861,7 +1861,7 @@ void sub_8141828(u8 battler, struct Pokemon *mon) u8 taskId1, taskId2; isShiny = 0; - ewram17810[battler].unk0_7 = 1; + gBattleHealthBoxInfo[battler].triedShinyMonAnim = TRUE; otId = GetMonData(mon, MON_DATA_OT_ID); personality = GetMonData(mon, MON_DATA_PERSONALITY); @@ -1889,7 +1889,7 @@ void sub_8141828(u8 battler, struct Pokemon *mon) } } - ewram17810[battler].unk1_0 = 1; + gBattleHealthBoxInfo[battler].finishedShinyMonAnim = TRUE; } static void sub_814191C(u8 taskId) @@ -1970,7 +1970,7 @@ static void sub_8141AD8(u8 taskId) if (gTasks[taskId].data[1] == 1) { battler = gTasks[taskId].data[0]; - ewram17810[battler].unk1_0 = 1; + gBattleHealthBoxInfo[battler].finishedShinyMonAnim = TRUE; } DestroyTask(taskId); diff --git a/src/battle_anim_status_effects.c b/src/battle_anim_status_effects.c index 9f90365cf..8439f4ce0 100644 --- a/src/battle_anim_status_effects.c +++ b/src/battle_anim_status_effects.c @@ -348,7 +348,7 @@ static void sub_807BDAC(u8 taskId) gAnimScriptCallback(); if (!gAnimScriptActive) { - ewram17810[gTasks[taskId].data[0]].unk0_4 = 0; + gBattleHealthBoxInfo[gTasks[taskId].data[0]].statusAnimActive = 0; DestroyTask(taskId); } } diff --git a/src/battle_bg.c b/src/battle_bg.c index 2eb37b954..33acf07d3 100644 --- a/src/battle_bg.c +++ b/src/battle_bg.c @@ -9,12 +9,11 @@ #include "task.h" #include "text.h" #include "text_window.h" -#include "trainer.h" #include "trig.h" #include "sound.h" #include "constants/map_types.h" #include "constants/songs.h" - +#include "constants/trainers.h" extern u16 gBattleTypeFlags; extern u8 gBattleOutcome; diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c index bbcf85d54..f4bb1b130 100644 --- a/src/battle_controller_link_opponent.c +++ b/src/battle_controller_link_opponent.c @@ -9,6 +9,7 @@ #include "m4a.h" #include "main.h" #include "palette.h" +#include "pokeball.h" #include "rom_8077ABC.h" #include "constants/songs.h" #include "sound.h" @@ -45,30 +46,30 @@ extern u8 gDisplayedStringBattle[]; extern bool8 gDoingBattleAnim; extern u8 gBattleOutcome; extern u16 gIntroSlideFlags; -extern u8 gUnknown_02024E68[]; +extern u8 gBattlerStatusSummaryTaskId[]; extern struct SpriteTemplate gCreatingSpriteTemplate; extern u8 gAnimMoveTurn; extern struct Window gWindowTemplate_Contest_MoveDescription; -extern u8 gUnknown_0300434C[]; +extern u8 gBattleControllerData[]; extern u32 gBattleControllerExecFlags; extern MainCallback gPreBattleCallback1; extern struct MusicPlayerInfo gMPlayInfo_BGM; -extern u8 sub_8077F68(); +extern u8 GetBattlerSpriteDefault_Y(); extern u8 GetBattlerPosition(u8); extern void BattleLoadOpponentMonSprite(struct Pokemon *, u8); extern void sub_8037A74(void); extern void sub_8032984(u8, u16); extern void sub_8037E30(void); -extern void sub_80312F0(struct Sprite *); -extern u8 StartSendOutMonAnimation(); +extern void SpriteCB_WaitForBattlerBallReleaseAnim(struct Sprite *); +extern u8 DoPokeballSendOutAnimation(); extern void sub_8032A08(); extern void sub_8037BBC(void); extern s32 sub_803FC34(u16); extern void sub_8031A6C(u16, u8); -extern void sub_80313A0(struct Sprite *); +extern void SpriteCB_TrainerSlideIn(struct Sprite *); extern void sub_803757C(void); -extern void oamt_add_pos2_onto_pos1(); +extern void SetSpritePrimaryCoordsFromSecondaryCoords(); extern void StoreSpriteCallbackInData(); extern void StartAnimLinearTranslation(struct Sprite *); extern void sub_80375B4(void); @@ -76,29 +77,28 @@ extern void sub_8010384(struct Sprite *); extern void sub_8037B78(void); extern u8 IsMoveWithoutAnimation(); extern bool8 mplay_80342A4(u8); -extern void sub_80326EC(); -extern void sub_8031F24(void); -extern void sub_80324BC(); +extern void SetBattlerSpriteAffineMode(); +extern void CopyAllBattleSpritesInvisibilities(void); +extern void TrySetBehindSubstituteSpriteBit(); extern void BufferStringBattle(); extern void sub_8037C2C(void); extern void sub_8037B24(void); extern void sub_8037FAC(void); extern void move_anim_start_t2_for_situation(); extern void dp01t_0F_4_move_anim(void); -extern void sub_8047858(); +extern void DoHitAnimHealthboxEffect(); extern u8 GetBattlerSide(u8); -extern void StartBattleIntroAnim(); +extern void HandleIntroSlide(); extern void sub_803A3A8(struct Sprite *); extern void sub_8044CA0(u8); extern void nullsub_47(void); extern bool8 IsDoubleBattle(void); extern void sub_8037840(void); extern void sub_8031B74(); -extern u8 move_anim_start_t3(); +extern u8 TryHandleLaunchBattleTableAnimation(); extern void sub_8037FD8(void); extern void sub_8037F34(void); extern void LinkOpponentBufferExecCompleted(void); -extern void sub_804777C(); // this file's functions @@ -276,9 +276,9 @@ void sub_80375B4(void) void sub_8037644(void) { - if ((--ewram17810[gActiveBattler].unk9) == 0xFF) + if ((--gBattleHealthBoxInfo[gActiveBattler].unk9) == 0xFF) { - ewram17810[gActiveBattler].unk9 = 0; + gBattleHealthBoxInfo[gActiveBattler].unk9 = 0; LinkOpponentBufferExecCompleted(); } } @@ -305,12 +305,12 @@ void sub_8037680(void) { if (GetBattlerPosition(gActiveBattler) == 1) { - if (!ewram17810[gActiveBattler].unk1_0 || !ewram17810[gActiveBattler ^ 2].unk1_0) + if (!gBattleHealthBoxInfo[gActiveBattler].finishedShinyMonAnim || !gBattleHealthBoxInfo[gActiveBattler ^ 2].finishedShinyMonAnim) return; - ewram17810[gActiveBattler].unk0_7 = 0; - ewram17810[gActiveBattler].unk1_0 = 0; - ewram17810[gActiveBattler ^ 2].unk0_7 = 0; - ewram17810[gActiveBattler ^ 2].unk1_0 = 0; + gBattleHealthBoxInfo[gActiveBattler].triedShinyMonAnim = FALSE; + gBattleHealthBoxInfo[gActiveBattler].finishedShinyMonAnim = FALSE; + gBattleHealthBoxInfo[gActiveBattler ^ 2].triedShinyMonAnim = FALSE; + gBattleHealthBoxInfo[gActiveBattler ^ 2].finishedShinyMonAnim = FALSE; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); } @@ -323,45 +323,45 @@ void sub_8037680(void) { m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 256); } - ewram17810[gActiveBattler].unk9 = 3; + gBattleHealthBoxInfo[gActiveBattler].unk9 = 3; gBattlerControllerFuncs[gActiveBattler] = sub_8037644; } } void sub_8037840(void) { - if (!ewram17810[gActiveBattler].unk0_3 && !ewram17810[gActiveBattler].unk0_7) - sub_8141828(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]); - if (!ewram17810[gActiveBattler ^ 2].unk0_3 && !ewram17810[gActiveBattler ^ 2].unk0_7) - sub_8141828(gActiveBattler ^ 2, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ 2]]); - if (!ewram17810[gActiveBattler].unk0_3 && !ewram17810[gActiveBattler ^ 2].unk0_3) + if (!gBattleHealthBoxInfo[gActiveBattler].ballAnimActive && !gBattleHealthBoxInfo[gActiveBattler].triedShinyMonAnim) + TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]); + if (!gBattleHealthBoxInfo[gActiveBattler ^ 2].ballAnimActive && !gBattleHealthBoxInfo[gActiveBattler ^ 2].triedShinyMonAnim) + TryShinyAnimation(gActiveBattler ^ 2, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ 2]]); + if (!gBattleHealthBoxInfo[gActiveBattler].ballAnimActive && !gBattleHealthBoxInfo[gActiveBattler ^ 2].ballAnimActive) { if ((gBattleTypeFlags & BATTLE_TYPE_MULTI) && GetBattlerPosition(gActiveBattler) == 3) { - if (++ewram17810[gActiveBattler].unk9 == 1) + if (++gBattleHealthBoxInfo[gActiveBattler].unk9 == 1) return; - ewram17810[gActiveBattler].unk9 = 0; + gBattleHealthBoxInfo[gActiveBattler].unk9 = 0; } if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - DestroySprite(&gSprites[gUnknown_0300434C[gActiveBattler ^ 2]]); - sub_8045A5C( + DestroySprite(&gSprites[gBattleControllerData[gActiveBattler ^ 2]]); + UpdateHealthboxAttribute( gHealthboxSpriteIds[gActiveBattler ^ 2], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ 2]], 0); - sub_804777C(gActiveBattler ^ 2); - sub_8043DFC(gHealthboxSpriteIds[gActiveBattler ^ 2]); + StartHealthboxSlideIn(gActiveBattler ^ 2); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ 2]); sub_8032984( gActiveBattler ^ 2, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ 2]], MON_DATA_SPECIES)); } - DestroySprite(&gSprites[gUnknown_0300434C[gActiveBattler]]); - sub_8045A5C( + DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]); + UpdateHealthboxAttribute( gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], 0); - sub_804777C(gActiveBattler); - sub_8043DFC(gHealthboxSpriteIds[gActiveBattler]); + StartHealthboxSlideIn(gActiveBattler); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); sub_8032984( gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES)); @@ -376,15 +376,15 @@ void sub_8037A74(void) if (gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded == TRUE && gSprites[gBattlerSpriteIds[gActiveBattler]].x2 == 0) { - if (!ewram17810[gActiveBattler].unk0_7) + if (!gBattleHealthBoxInfo[gActiveBattler].triedShinyMonAnim) { - sub_8141828(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]); + TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]); return; } - if (ewram17810[gActiveBattler].unk1_0) + if (gBattleHealthBoxInfo[gActiveBattler].finishedShinyMonAnim) { - ewram17810[gActiveBattler].unk0_7 = 0; - ewram17810[gActiveBattler].unk1_0 = 0; + gBattleHealthBoxInfo[gActiveBattler].triedShinyMonAnim = FALSE; + gBattleHealthBoxInfo[gActiveBattler].finishedShinyMonAnim = FALSE; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); LinkOpponentBufferExecCompleted(); @@ -395,11 +395,11 @@ void sub_8037A74(void) void sub_8037B24(void) { - s16 r4 = sub_8045C78(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], 0, 0); + s16 r4 = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], 0, 0); - sub_8043DFC(gHealthboxSpriteIds[gActiveBattler]); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); if (r4 != -1) - sub_80440EC(gHealthboxSpriteIds[gActiveBattler], r4, 0); + UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], r4, 0); else LinkOpponentBufferExecCompleted(); } @@ -408,19 +408,19 @@ void sub_8037B78(void) { if (!gSprites[gBattlerSpriteIds[gActiveBattler]].inUse) { - sub_8043DB0(gHealthboxSpriteIds[gActiveBattler]); + SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]); LinkOpponentBufferExecCompleted(); } } void sub_8037BBC(void) { - if (!ewram17810[gActiveBattler].unk0_6) + if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) { FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]); sub_8032A08(gActiveBattler); - sub_8043DB0(gHealthboxSpriteIds[gActiveBattler]); + SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]); LinkOpponentBufferExecCompleted(); } } @@ -454,36 +454,36 @@ void sub_8037CC0(void) { if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { - if (gBattleSpriteInfo[gActiveBattler].substituteSprite) - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 6); + if (gBattleSpriteInfo[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 6); gBattlerControllerFuncs[gActiveBattler] = sub_8037D2C; } } void sub_8037D2C(void) { - if (!ewram17810[gActiveBattler].unk0_6) + if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) { - CreateTask(c3_0802FDF4, 10); + CreateTask(Task_PlayerController_RestoreBgmAfterCry, 10); LinkOpponentBufferExecCompleted(); } } void sub_8037D64(void) { - if (ewram17810[gActiveBattler].unk1_0) + if (gBattleHealthBoxInfo[gActiveBattler].finishedShinyMonAnim) { - ewram17810[gActiveBattler].unk0_7 = 0; - ewram17810[gActiveBattler].unk1_0 = 0; + gBattleHealthBoxInfo[gActiveBattler].triedShinyMonAnim = FALSE; + gBattleHealthBoxInfo[gActiveBattler].finishedShinyMonAnim = FALSE; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0); - sub_8045A5C( + UpdateHealthboxAttribute( gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], 0); - sub_804777C(gActiveBattler); - sub_8043DFC(gHealthboxSpriteIds[gActiveBattler]); + StartHealthboxSlideIn(gActiveBattler); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); sub_8031F88(gActiveBattler); gBattlerControllerFuncs[gActiveBattler] = sub_8037CC0; } @@ -491,12 +491,12 @@ void sub_8037D64(void) void sub_8037E30(void) { - if (!ewram17810[gActiveBattler].unk0_3 && !ewram17810[gActiveBattler].unk0_7) - sub_8141828(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]); - if (gSprites[gUnknown_0300434C[gActiveBattler]].callback == SpriteCallbackDummy - && !ewram17810[gActiveBattler].unk0_3) + if (!gBattleHealthBoxInfo[gActiveBattler].ballAnimActive && !gBattleHealthBoxInfo[gActiveBattler].triedShinyMonAnim) + TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]); + if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy + && !gBattleHealthBoxInfo[gActiveBattler].ballAnimActive) { - DestroySprite(&gSprites[gUnknown_0300434C[gActiveBattler]]); + DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]); sub_8032984(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES)); gBattlerControllerFuncs[gActiveBattler] = sub_8037D64; } @@ -534,13 +534,13 @@ void sub_8037F34(void) void sub_8037FAC(void) { - if (!ewram17810[gActiveBattler].unk0_4) + if (!gBattleHealthBoxInfo[gActiveBattler].statusAnimActive) LinkOpponentBufferExecCompleted(); } void sub_8037FD8(void) { - if (!ewram17810[gActiveBattler].unk0_5) + if (!gBattleHealthBoxInfo[gActiveBattler].animFromTableActive) LinkOpponentBufferExecCompleted(); } @@ -1146,12 +1146,12 @@ void LinkOpponentHandleLoadPokeSprite(void) u16 species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES); BattleLoadOpponentMonSprite(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); - GetMonSpriteTemplate_803C56C(species, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite( &gCreatingSpriteTemplate, GetBattlerSpriteCoord(gActiveBattler, 2), - sub_8077F68(gActiveBattler), - GetBattlerSubpriority(gActiveBattler)); + GetBattlerSpriteDefault_Y(gActiveBattler), + GetBattlerSpriteSubpriority(gActiveBattler)); gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = -240; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; @@ -1174,29 +1174,29 @@ void sub_8039430(u8 a, u8 b) sub_8032AA8(a, b); gBattlerPartyIndexes[a] = gBattleBufferA[a][1]; species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[a]], MON_DATA_SPECIES); - gUnknown_0300434C[a] = CreateInvisibleSpriteWithCallback(sub_80312F0); + gBattleControllerData[a] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); BattleLoadOpponentMonSprite(&gEnemyParty[gBattlerPartyIndexes[a]], a); - GetMonSpriteTemplate_803C56C(species, GetBattlerPosition(a)); + SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(a)); gBattlerSpriteIds[a] = CreateSprite( &gCreatingSpriteTemplate, GetBattlerSpriteCoord(a, 2), - sub_8077F68(a), - GetBattlerSubpriority(a)); - gSprites[gUnknown_0300434C[a]].data[1] = gBattlerSpriteIds[a]; + GetBattlerSpriteDefault_Y(a), + GetBattlerSpriteSubpriority(a)); + gSprites[gBattleControllerData[a]].data[1] = gBattlerSpriteIds[a]; gSprites[gBattlerSpriteIds[a]].data[0] = a; gSprites[gBattlerSpriteIds[a]].data[2] = species; gSprites[gBattlerSpriteIds[a]].oam.paletteNum = a; StartSpriteAnim(&gSprites[gBattlerSpriteIds[a]], gBattleMonForms[a]); gSprites[gBattlerSpriteIds[a]].invisible = TRUE; gSprites[gBattlerSpriteIds[a]].callback = SpriteCallbackDummy; - gSprites[gUnknown_0300434C[a]].data[0] = StartSendOutMonAnimation(0, 0xFE); + gSprites[gBattleControllerData[a]].data[0] = DoPokeballSendOutAnimation(0, 0xFE); } void LinkOpponentHandleReturnPokeToBall(void) { if (gBattleBufferA[gActiveBattler][1] == 0) { - ewram17810[gActiveBattler].unk4 = 0; + gBattleHealthBoxInfo[gActiveBattler].animationState = 0; gBattlerControllerFuncs[gActiveBattler] = sub_8039648; } else @@ -1204,25 +1204,25 @@ void LinkOpponentHandleReturnPokeToBall(void) FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]); sub_8032A08(gActiveBattler); - sub_8043DB0(gHealthboxSpriteIds[gActiveBattler]); + SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]); LinkOpponentBufferExecCompleted(); } } void sub_8039648(void) { - switch (ewram17810[gActiveBattler].unk4) + switch (gBattleHealthBoxInfo[gActiveBattler].animationState) { case 0: - if (gBattleSpriteInfo[gActiveBattler].substituteSprite) - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 5); - ewram17810[gActiveBattler].unk4 = 1; + if (gBattleSpriteInfo[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 5); + gBattleHealthBoxInfo[gActiveBattler].animationState = 1; break; case 1: - if (!ewram17810[gActiveBattler].unk0_6) + if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) { - ewram17810[gActiveBattler].unk4 = 0; - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 2); + gBattleHealthBoxInfo[gActiveBattler].animationState = 0; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 2); gBattlerControllerFuncs[gActiveBattler] = sub_8037BBC; } break; @@ -1248,18 +1248,18 @@ void LinkOpponentHandleTrainerThrow(void) gender = gLinkPlayers[GetMultiplayerId() ^ 1].gender; } sub_8031A6C(gender, gActiveBattler); - GetMonSpriteTemplate_803C5A0(gender, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToTrainerBack(gender, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite( &gCreatingSpriteTemplate, 176 + xOffset, 40 + 4 * (8 - gTrainerFrontPicCoords[gender].coords), - GetBattlerSubpriority(gActiveBattler)); + GetBattlerSpriteSubpriority(gActiveBattler)); gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = -240; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 2; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[gender].tag); gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gSprites[gBattlerSpriteIds[gActiveBattler]].oam.tileNum; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.tileNum = GetSpriteTileStartByTag(gTrainerFrontPicTable[gender].tag); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = gender; - gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_80313A0; + gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn; gBattlerControllerFuncs[gActiveBattler] = sub_803757C; } @@ -1270,7 +1270,7 @@ void LinkOpponentHandleTrainerSlide(void) void LinkOpponentHandleTrainerSlideBack(void) { - oamt_add_pos2_onto_pos1(&gSprites[gBattlerSpriteIds[gActiveBattler]]); + SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 280; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].y; @@ -1281,15 +1281,15 @@ void LinkOpponentHandleTrainerSlideBack(void) void LinkOpponentHandlecmd10(void) { - if (ewram17810[gActiveBattler].unk4 == 0) + if (gBattleHealthBoxInfo[gActiveBattler].animationState == 0) { - if (gBattleSpriteInfo[gActiveBattler].substituteSprite) - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 5); - ewram17810[gActiveBattler].unk4++; + if (gBattleSpriteInfo[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 5); + gBattleHealthBoxInfo[gActiveBattler].animationState++; } - else if (!ewram17810[gActiveBattler].unk0_6) + else if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) { - ewram17810[gActiveBattler].unk4 = 0; + gBattleHealthBoxInfo[gActiveBattler].animationState = 0; PlaySE12WithPanning(SE_FAINT, 63); gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_8010384; gBattlerControllerFuncs[gActiveBattler] = sub_8037B78; @@ -1343,7 +1343,7 @@ void LinkOpponentHandleMoveAnimation(void) } else { - ewram17810[gActiveBattler].unk4 = 0; + gBattleHealthBoxInfo[gActiveBattler].animationState = 0; gBattlerControllerFuncs[gActiveBattler] = sub_8039B64; } } @@ -1355,45 +1355,45 @@ void sub_8039B64(void) | (gBattleBufferA[gActiveBattler][2] << 8); u8 r7 = gBattleBufferA[gActiveBattler][11]; - switch (ewram17810[gActiveBattler].unk4) + switch (gBattleHealthBoxInfo[gActiveBattler].animationState) { case 0: - if (gBattleSpriteInfo[gActiveBattler].substituteSprite && !gBattleSpriteInfo[gActiveBattler].flag_x8) + if (gBattleSpriteInfo[gActiveBattler].behindSubstitute && !gBattleSpriteInfo[gActiveBattler].flag_x8) { gBattleSpriteInfo[gActiveBattler].flag_x8 = 1; - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 5); + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 5); } - ewram17810[gActiveBattler].unk4 = 1; + gBattleHealthBoxInfo[gActiveBattler].animationState = 1; break; case 1: - if (!ewram17810[gActiveBattler].unk0_6) + if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) { - sub_80326EC(0); + SetBattlerSpriteAffineMode(0); DoMoveAnim(r4); - ewram17810[gActiveBattler].unk4 = 2; + gBattleHealthBoxInfo[gActiveBattler].animationState = 2; } break; case 2: gAnimScriptCallback(); if (!gAnimScriptActive) { - sub_80326EC(1); - if ((gBattleSpriteInfo[gActiveBattler].substituteSprite) && r7 <= 1) + SetBattlerSpriteAffineMode(1); + if ((gBattleSpriteInfo[gActiveBattler].behindSubstitute) && r7 <= 1) { - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 6); + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 6); gBattleSpriteInfo[gActiveBattler].flag_x8 = 0; } - ewram17810[gActiveBattler].unk4 = 3; + gBattleHealthBoxInfo[gActiveBattler].animationState = 3; } break; case 3: - if (!ewram17810[gActiveBattler].unk0_6) + if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) { - sub_8031F24(); - sub_80324BC( + CopyAllBattleSpritesInvisibilities(); + TrySetBehindSubstituteSpriteBit( gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); - ewram17810[gActiveBattler].unk4 = 0; + gBattleHealthBoxInfo[gActiveBattler].animationState = 0; LinkOpponentBufferExecCompleted(); } break; @@ -1448,20 +1448,20 @@ void LinkOpponentHandleHealthBarUpdate(void) { s16 r7; - load_gfxc_health_bar(0); + LoadBattleBarGfx(0); r7 = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); if (r7 != 0x7FFF) { u32 maxHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP); u32 hp = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP); - sub_8043D84(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, hp, r7); + SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, hp, r7); } else { u32 maxHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP); - sub_8043D84(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, r7); + SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, r7); } gBattlerControllerFuncs[gActiveBattler] = sub_8037B24; } @@ -1475,8 +1475,8 @@ void LinkOpponentHandleStatusIconUpdate(void) { if (mplay_80342A4(gActiveBattler) == 0) { - sub_8045A5C(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], 9); - ewram17810[gActiveBattler].unk0_4 = 0; + UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], 9); + gBattleHealthBoxInfo[gActiveBattler].statusAnimActive = 0; gBattlerControllerFuncs[gActiveBattler] = sub_8037FAC; } } @@ -1574,7 +1574,7 @@ void LinkOpponentHandleHitAnimation(void) { gDoingBattleAnim = TRUE; gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0; - sub_8047858(gActiveBattler); + DoHitAnimHealthboxEffect(gActiveBattler); gBattlerControllerFuncs[gActiveBattler] = dp01t_0F_4_move_anim; } } @@ -1612,7 +1612,7 @@ void LinkOpponentHandleFaintingCry(void) void LinkOpponentHandleIntroSlide(void) { - StartBattleIntroAnim(gBattleBufferA[gActiveBattler][1]); + HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); gIntroSlideFlags |= 1; LinkOpponentBufferExecCompleted(); } @@ -1621,7 +1621,7 @@ void LinkOpponentHandleTrainerBallThrow(void) { u8 taskId; - oamt_add_pos2_onto_pos1(&gSprites[gBattlerSpriteIds[gActiveBattler]]); + SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 280; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].y; @@ -1629,8 +1629,8 @@ void LinkOpponentHandleTrainerBallThrow(void) StoreSpriteCallbackInData(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_803A3A8); taskId = CreateTask(sub_803A2C4, 5); gTasks[taskId].data[0] = gActiveBattler; - if (ewram17810[gActiveBattler].unk0_0) - gTasks[gUnknown_02024E68[gActiveBattler]].func = sub_8044CA0; + if (gBattleHealthBoxInfo[gActiveBattler].partyStatusSummaryShown) + gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = sub_8044CA0; ewram17840.unk9_0 = 1; gBattlerControllerFuncs[gActiveBattler] = nullsub_47; } @@ -1676,43 +1676,43 @@ void LinkOpponentHandlecmd48(void) return; } - ewram17810[gActiveBattler].unk0_0 = 1; + gBattleHealthBoxInfo[gActiveBattler].partyStatusSummaryShown = 1; if (gBattleBufferA[gActiveBattler][2] != 0) { - if (ewram17810[gActiveBattler].unk1_1 < 2) + if (gBattleHealthBoxInfo[gActiveBattler].unk1_1 < 2) { - ewram17810[gActiveBattler].unk1_1++; + gBattleHealthBoxInfo[gActiveBattler].unk1_1++; return; } else { - ewram17810[gActiveBattler].unk1_1 = 0; + gBattleHealthBoxInfo[gActiveBattler].unk1_1 = 0; } } - gUnknown_02024E68[gActiveBattler] = CreatePartyStatusSummarySprites( + gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites( gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); - ewram17810[gActiveBattler].unk5 = 0; + gBattleHealthBoxInfo[gActiveBattler].unk5 = 0; if (gBattleBufferA[gActiveBattler][2] != 0) - ewram17810[gActiveBattler].unk5 = 0x5D; + gBattleHealthBoxInfo[gActiveBattler].unk5 = 0x5D; gBattlerControllerFuncs[gActiveBattler] = sub_803A4E0; } void sub_803A4E0(void) { - if (ewram17810[gActiveBattler].unk5++ >= 93) + if (gBattleHealthBoxInfo[gActiveBattler].unk5++ >= 93) { - ewram17810[gActiveBattler].unk5 = 0; + gBattleHealthBoxInfo[gActiveBattler].unk5 = 0; LinkOpponentBufferExecCompleted(); } } void LinkOpponentHandlecmd49(void) { - if (ewram17810[gActiveBattler].unk0_0) - gTasks[gUnknown_02024E68[gActiveBattler]].func = sub_8044CA0; + if (gBattleHealthBoxInfo[gActiveBattler].partyStatusSummaryShown) + gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = sub_8044CA0; LinkOpponentBufferExecCompleted(); } @@ -1738,7 +1738,7 @@ void LinkOpponentHandleBattleAnimation(void) u8 r3 = gBattleBufferA[gActiveBattler][1]; u16 r4 = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); - if (move_anim_start_t3(gActiveBattler, gActiveBattler, gActiveBattler, r3, r4) != 0) + if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, r3, r4) != 0) LinkOpponentBufferExecCompleted(); else gBattlerControllerFuncs[gActiveBattler] = sub_8037FD8; diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c index 8725790d1..dde9c1d5c 100644 --- a/src/battle_controller_link_partner.c +++ b/src/battle_controller_link_partner.c @@ -39,7 +39,7 @@ extern u16 gBattlerPartyIndexes[]; extern u8 gBattlerSpriteIds[]; extern u8 gBattleOutcome; extern u16 gIntroSlideFlags; -extern u8 gUnknown_02024E68[]; +extern u8 gBattlerStatusSummaryTaskId[]; extern u8 gDoingBattleAnim; extern u32 gTransformedPersonalities[]; extern struct SpriteTemplate gCreatingSpriteTemplate; @@ -52,38 +52,38 @@ extern struct Window gWindowTemplate_Contest_MoveDescription; extern MainCallback gPreBattleCallback1; extern void (*gBattlerControllerFuncs[])(void); extern u8 gHealthboxSpriteIds[]; -extern u8 gUnknown_0300434C[]; +extern u8 gBattleControllerData[]; extern u8 gBattleMonForms[]; extern u8 gAnimScriptActive; extern void (*gAnimScriptCallback)(void); -extern u8 move_anim_start_t3(); +extern u8 TryHandleLaunchBattleTableAnimation(); extern void sub_8044CA0(u8); -extern void sub_8030E38(struct Sprite *); -extern void StartBattleIntroAnim(); -extern void sub_8047858(); +extern void SpriteCB_FreePlayerSpriteLoadMonSprite(struct Sprite *); +extern void HandleIntroSlide(); +extern void DoHitAnimHealthboxEffect(); extern void move_anim_start_t2_for_situation(); extern void BufferStringBattle(); -extern void sub_8031F24(void); -extern void sub_80326EC(); -extern void sub_80324BC(); +extern void CopyAllBattleSpritesInvisibilities(void); +extern void SetBattlerSpriteAffineMode(); +extern void TrySetBehindSubstituteSpriteBit(); extern u8 IsMoveWithoutAnimation(); extern u8 mplay_80342A4(); -extern void oamt_add_pos2_onto_pos1(); +extern void SetSpritePrimaryCoordsFromSecondaryCoords(); extern void StoreSpriteCallbackInData(); extern void StartAnimLinearTranslation(struct Sprite *); extern void sub_80105EC(struct Sprite *); extern s32 sub_803FC34(u16); -extern void LoadPlayerTrainerBankSprite(); -extern void sub_80313A0(struct Sprite *); -extern u8 StartSendOutMonAnimation(); -extern void sub_80312F0(struct Sprite *); +extern void DecompressTrainerBackPic(); +extern void SpriteCB_TrainerSlideIn(struct Sprite *); +extern u8 DoPokeballSendOutAnimation(); +extern void SpriteCB_WaitForBattlerBallReleaseAnim(struct Sprite *); extern u8 CreateInvisibleSpriteWithCallback(); extern void BattleLoadPlayerMonSprite(); -extern u8 sub_8077F68(); +extern u8 GetBattlerSpriteDefault_Y(); extern void nullsub_10(); extern void nullsub_9(u16); -extern void c3_0802FDF4(u8); +extern void Task_PlayerController_RestoreBgmAfterCry(u8); extern void c2_8011A1C(void); // this file's functions @@ -260,9 +260,9 @@ void sub_811DB1C(void) void sub_811DB84(void) { - if ((--ewram17810[gActiveBattler].unk9) == 0xFF) + if ((--gBattleHealthBoxInfo[gActiveBattler].unk9) == 0xFF) { - ewram17810[gActiveBattler].unk9 = 0; + gBattleHealthBoxInfo[gActiveBattler].unk9 = 0; LinkPartnerBufferExecCompleted(); } } @@ -286,7 +286,7 @@ void sub_811DBC0(void) r6 = FALSE; if (r6) { - ewram17810[gActiveBattler].unk9 = 3; + gBattleHealthBoxInfo[gActiveBattler].unk9 = 3; gBattlerControllerFuncs[gActiveBattler] = sub_811DB84; } } @@ -295,25 +295,25 @@ void sub_811DCA0(void) { u8 r2; - if (!ewram17810[gActiveBattler].unk0_3) + if (!gBattleHealthBoxInfo[gActiveBattler].ballAnimActive) { // I couldn't get it to work as a bitfield here - r2 = *((u8 *)&ewram17810[gActiveBattler ^ 2]) & 8; - if (!r2 && (++ewram17810[gActiveBattler].unk9) != 1) + r2 = *((u8 *)&gBattleHealthBoxInfo[gActiveBattler ^ 2]) & 8; + if (!r2 && (++gBattleHealthBoxInfo[gActiveBattler].unk9) != 1) { - ewram17810[gActiveBattler].unk9 = r2; + gBattleHealthBoxInfo[gActiveBattler].unk9 = r2; if (IsDoubleBattle() && !(gBattleTypeFlags & 0x40)) { - DestroySprite(&gSprites[gUnknown_0300434C[gActiveBattler ^ 2]]); - sub_8045A5C(gHealthboxSpriteIds[gActiveBattler ^ 2], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ 2]], 0); - sub_804777C(gActiveBattler ^ 2); - sub_8043DFC(gHealthboxSpriteIds[gActiveBattler ^ 2]); + DestroySprite(&gSprites[gBattleControllerData[gActiveBattler ^ 2]]); + UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ 2], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ 2]], 0); + StartHealthboxSlideIn(gActiveBattler ^ 2); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ 2]); } - DestroySprite(&gSprites[gUnknown_0300434C[gActiveBattler]]); - sub_8045A5C(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], 0); - sub_804777C(gActiveBattler); - sub_8043DFC(gHealthboxSpriteIds[gActiveBattler]); - ewram17810[4].unk9 = (s8)ewram17810[4].unk9 & ~1; + DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]); + UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], 0); + StartHealthboxSlideIn(gActiveBattler); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); + gBattleHealthBoxInfo[4].unk9 = (s8)gBattleHealthBoxInfo[4].unk9 & ~1; gBattlerControllerFuncs[gActiveBattler] = sub_811DBC0; } } @@ -330,11 +330,11 @@ void bx_t3_healthbar_update(void) { s16 r4; - r4 = sub_8045C78(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], 0, 0); - sub_8043DFC(gHealthboxSpriteIds[gActiveBattler]); + r4 = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], 0, 0); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); if (r4 != -1) { - sub_80440EC(gHealthboxSpriteIds[gActiveBattler], r4, 0); + UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], r4, 0); } else { @@ -350,18 +350,18 @@ void sub_811DE98(void) nullsub_9(GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES)); FreeOamMatrix(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.matrixNum); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]); - sub_8043DB0(gHealthboxSpriteIds[gActiveBattler]); + SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]); LinkPartnerBufferExecCompleted(); } } void sub_811DF34(void) { - if (!ewram17810[gActiveBattler].unk0_6) + if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) { FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]); - sub_8043DB0(gHealthboxSpriteIds[gActiveBattler]); + SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]); LinkPartnerBufferExecCompleted(); } } @@ -396,32 +396,32 @@ void sub_811E034(void) { if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { - if (gBattleSpriteInfo[gActiveBattler].substituteSprite) - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 6); + if (gBattleSpriteInfo[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 6); gBattlerControllerFuncs[gActiveBattler] = sub_811E0A0; } } void sub_811E0A0(void) { - if (!ewram17810[gActiveBattler].unk0_6) + if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) LinkPartnerBufferExecCompleted(); } void sub_811E0CC(void) { - if (ewram17810[gActiveBattler].unk1_0) + if (gBattleHealthBoxInfo[gActiveBattler].finishedShinyMonAnim) { - ewram17810[gActiveBattler].unk0_7 = 0; - ewram17810[gActiveBattler].unk1_0 = 0; + gBattleHealthBoxInfo[gActiveBattler].triedShinyMonAnim = FALSE; + gBattleHealthBoxInfo[gActiveBattler].finishedShinyMonAnim = FALSE; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); - CreateTask(c3_0802FDF4, 10); + CreateTask(Task_PlayerController_RestoreBgmAfterCry, 10); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0); - sub_8045A5C(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], 0); - sub_804777C(gActiveBattler); - sub_8043DFC(gHealthboxSpriteIds[gActiveBattler]); + UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], 0); + StartHealthboxSlideIn(gActiveBattler); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); sub_8031F88(gActiveBattler); gBattlerControllerFuncs[gActiveBattler] = sub_811E034; } @@ -429,12 +429,12 @@ void sub_811E0CC(void) void sub_811E1BC(void) { - if (!ewram17810[gActiveBattler].unk0_3 && !ewram17810[gActiveBattler].unk0_7) - sub_8141828(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]); - if (gSprites[gUnknown_0300434C[gActiveBattler]].callback == SpriteCallbackDummy - && !ewram17810[gActiveBattler].unk0_3) + if (!gBattleHealthBoxInfo[gActiveBattler].ballAnimActive && !gBattleHealthBoxInfo[gActiveBattler].triedShinyMonAnim) + TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]); + if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy + && !gBattleHealthBoxInfo[gActiveBattler].ballAnimActive) { - DestroySprite(&gSprites[gUnknown_0300434C[gActiveBattler]]); + DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]); gBattlerControllerFuncs[gActiveBattler] = sub_811E0CC; } } @@ -488,13 +488,13 @@ void LinkPartnerBufferExecCompleted(void) void sub_811E38C(void) { - if (!ewram17810[gActiveBattler].unk0_4) + if (!gBattleHealthBoxInfo[gActiveBattler].statusAnimActive) LinkPartnerBufferExecCompleted(); } void sub_811E3B8(void) { - if (!ewram17810[gActiveBattler].unk0_5) + if (!gBattleHealthBoxInfo[gActiveBattler].animFromTableActive) LinkPartnerBufferExecCompleted(); } @@ -1084,14 +1084,14 @@ void LinkPartnerHandlecmd3(void) void LinkPartnerHandleLoadPokeSprite(void) { BattleLoadPlayerMonSprite(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); - GetMonSpriteTemplate_803C56C( + SetMultiuseSpriteTemplateToPokemon( GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES), GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite( &gCreatingSpriteTemplate, GetBattlerSpriteCoord(gActiveBattler, 2), - sub_8077F68(gActiveBattler), - GetBattlerSubpriority(gActiveBattler)); + GetBattlerSpriteDefault_Y(gActiveBattler), + GetBattlerSpriteSubpriority(gActiveBattler)); gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = -240; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; @@ -1115,53 +1115,53 @@ void sub_811F864(u8 a, u8 b) sub_8032AA8(a, b); gBattlerPartyIndexes[a] = gBattleBufferA[a][1]; species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[a]], MON_DATA_SPECIES); - gUnknown_0300434C[a] = CreateInvisibleSpriteWithCallback(sub_80312F0); - GetMonSpriteTemplate_803C56C(species, GetBattlerPosition(a)); + gBattleControllerData[a] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); + SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(a)); gBattlerSpriteIds[a] = CreateSprite( &gCreatingSpriteTemplate, GetBattlerSpriteCoord(a, 2), - sub_8077F68(a), - GetBattlerSubpriority(a)); - gSprites[gUnknown_0300434C[a]].data[1] = gBattlerSpriteIds[a]; + GetBattlerSpriteDefault_Y(a), + GetBattlerSpriteSubpriority(a)); + gSprites[gBattleControllerData[a]].data[1] = gBattlerSpriteIds[a]; gSprites[gBattlerSpriteIds[a]].data[0] = a; gSprites[gBattlerSpriteIds[a]].data[2] = species; gSprites[gBattlerSpriteIds[a]].oam.paletteNum = a; StartSpriteAnim(&gSprites[gBattlerSpriteIds[a]], gBattleMonForms[a]); gSprites[gBattlerSpriteIds[a]].invisible = TRUE; gSprites[gBattlerSpriteIds[a]].callback = SpriteCallbackDummy; - gSprites[gUnknown_0300434C[a]].data[0] = StartSendOutMonAnimation(0, 0xFF); + gSprites[gBattleControllerData[a]].data[0] = DoPokeballSendOutAnimation(0, 0xFF); } void LinkPartnerHandleReturnPokeToBall(void) { if (gBattleBufferA[gActiveBattler][1] == 0) { - ewram17810[gActiveBattler].unk4 = 0; + gBattleHealthBoxInfo[gActiveBattler].animationState = 0; gBattlerControllerFuncs[gActiveBattler] = sub_811FA5C; } else { FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]); - sub_8043DB0(gHealthboxSpriteIds[gActiveBattler]); + SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]); LinkPartnerBufferExecCompleted(); } } void sub_811FA5C(void) { - switch (ewram17810[gActiveBattler].unk4) + switch (gBattleHealthBoxInfo[gActiveBattler].animationState) { case 0: - if (gBattleSpriteInfo[gActiveBattler].substituteSprite) - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 5); - ewram17810[gActiveBattler].unk4 = 1; + if (gBattleSpriteInfo[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 5); + gBattleHealthBoxInfo[gActiveBattler].animationState = 1; break; case 1: - if (!ewram17810[gActiveBattler].unk0_6) + if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) { - ewram17810[gActiveBattler].unk4 = 0; - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 1); + gBattleHealthBoxInfo[gActiveBattler].animationState = 0; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 1); gBattlerControllerFuncs[gActiveBattler] = sub_811DF34; } break; @@ -1186,16 +1186,16 @@ void LinkPartnerHandleTrainerThrow(void) xOffset = 0; gender = gLinkPlayers[GetMultiplayerId() ^ 1].gender; } - LoadPlayerTrainerBankSprite(gender, gActiveBattler); - GetMonSpriteTemplate_803C5A0(gender, GetBattlerPosition(gActiveBattler)); + DecompressTrainerBackPic(gender, gActiveBattler); + SetMultiuseSpriteTemplateToTrainerBack(gender, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite( &gCreatingSpriteTemplate, 80 + xOffset, 80 + 4 * (8 - gTrainerBackPicCoords[gender].coords), - GetBattlerSubpriority(gActiveBattler)); + GetBattlerSpriteSubpriority(gActiveBattler)); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = 240; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2; - gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_80313A0; + gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn; gBattlerControllerFuncs[gActiveBattler] = sub_811DAE4; } @@ -1206,7 +1206,7 @@ void LinkPartnerHandleTrainerSlide(void) void LinkPartnerHandleTrainerSlideBack(void) { - oamt_add_pos2_onto_pos1(&gSprites[gBattlerSpriteIds[gActiveBattler]]); + SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].y; @@ -1217,15 +1217,15 @@ void LinkPartnerHandleTrainerSlideBack(void) void LinkPartnerHandlecmd10(void) { - if (ewram17810[gActiveBattler].unk4 == 0) + if (gBattleHealthBoxInfo[gActiveBattler].animationState == 0) { - if (gBattleSpriteInfo[gActiveBattler].substituteSprite) - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 5); - ewram17810[gActiveBattler].unk4++; + if (gBattleSpriteInfo[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 5); + gBattleHealthBoxInfo[gActiveBattler].animationState++; } - else if (!ewram17810[gActiveBattler].unk0_6) + else if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) { - ewram17810[gActiveBattler].unk4 = 0; + gBattleHealthBoxInfo[gActiveBattler].animationState = 0; HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); PlaySE12WithPanning(SE_FAINT, -64); gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0; @@ -1279,7 +1279,7 @@ void LinkPartnerHandleMoveAnimation(void) LinkPartnerBufferExecCompleted(); else { - ewram17810[gActiveBattler].unk4 = 0; + gBattleHealthBoxInfo[gActiveBattler].animationState = 0; gBattlerControllerFuncs[gActiveBattler] = sub_811FF30; } } @@ -1291,45 +1291,45 @@ void sub_811FF30(void) | (gBattleBufferA[gActiveBattler][2] << 8); u8 r7 = gBattleBufferA[gActiveBattler][11]; - switch (ewram17810[gActiveBattler].unk4) + switch (gBattleHealthBoxInfo[gActiveBattler].animationState) { case 0: - if (gBattleSpriteInfo[gActiveBattler].substituteSprite && !gBattleSpriteInfo[gActiveBattler].flag_x8) + if (gBattleSpriteInfo[gActiveBattler].behindSubstitute && !gBattleSpriteInfo[gActiveBattler].flag_x8) { gBattleSpriteInfo[gActiveBattler].flag_x8 = 1; - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 5); + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 5); } - ewram17810[gActiveBattler].unk4 = 1; + gBattleHealthBoxInfo[gActiveBattler].animationState = 1; break; case 1: - if (!ewram17810[gActiveBattler].unk0_6) + if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) { - sub_80326EC(0); + SetBattlerSpriteAffineMode(0); DoMoveAnim(r4); - ewram17810[gActiveBattler].unk4 = 2; + gBattleHealthBoxInfo[gActiveBattler].animationState = 2; } break; case 2: gAnimScriptCallback(); if (!gAnimScriptActive) { - sub_80326EC(1); - if ((gBattleSpriteInfo[gActiveBattler].substituteSprite) && r7 <= 1) + SetBattlerSpriteAffineMode(1); + if ((gBattleSpriteInfo[gActiveBattler].behindSubstitute) && r7 <= 1) { - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 6); + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 6); gBattleSpriteInfo[gActiveBattler].flag_x8 = 0; } - ewram17810[gActiveBattler].unk4 = 3; + gBattleHealthBoxInfo[gActiveBattler].animationState = 3; } break; case 3: - if (!ewram17810[gActiveBattler].unk0_6) + if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) { - sub_8031F24(); - sub_80324BC( + CopyAllBattleSpritesInvisibilities(); + TrySetBehindSubstituteSpriteBit( gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); - ewram17810[gActiveBattler].unk4 = 0; + gBattleHealthBoxInfo[gActiveBattler].animationState = 0; LinkPartnerBufferExecCompleted(); } break; @@ -1384,20 +1384,20 @@ void LinkPartnerHandleHealthBarUpdate(void) { s16 r7; - load_gfxc_health_bar(0); + LoadBattleBarGfx(0); r7 = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); if (r7 != 0x7FFF) { u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP); u32 hp = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP); - sub_8043D84(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, hp, r7); + SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, hp, r7); } else { u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP); - sub_8043D84(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, r7); + SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, r7); } gBattlerControllerFuncs[gActiveBattler] = bx_t3_healthbar_update; } @@ -1411,8 +1411,8 @@ void LinkPartnerHandleStatusIconUpdate(void) { if (mplay_80342A4(gActiveBattler) == 0) { - sub_8045A5C(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], 9); - ewram17810[gActiveBattler].unk0_4 = 0; + UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], 9); + gBattleHealthBoxInfo[gActiveBattler].statusAnimActive = 0; gBattlerControllerFuncs[gActiveBattler] = sub_811E38C; } } @@ -1510,7 +1510,7 @@ void LinkPartnerHandleHitAnimation(void) { gDoingBattleAnim = TRUE; gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0; - sub_8047858(gActiveBattler); + DoHitAnimHealthboxEffect(gActiveBattler); gBattlerControllerFuncs[gActiveBattler] = bx_blink_t3; } } @@ -1548,7 +1548,7 @@ void LinkPartnerHandleFaintingCry(void) void LinkPartnerHandleIntroSlide(void) { - StartBattleIntroAnim(gBattleBufferA[gActiveBattler][1]); + HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); gIntroSlideFlags |= 1; LinkPartnerBufferExecCompleted(); } @@ -1558,13 +1558,13 @@ void LinkPartnerHandleTrainerBallThrow(void) u8 r4; u8 taskId; - oamt_add_pos2_onto_pos1(&gSprites[gBattlerSpriteIds[gActiveBattler]]); + SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 50; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].y; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation; gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gActiveBattler; - StoreSpriteCallbackInData(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_8030E38); + StoreSpriteCallbackInData(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCB_FreePlayerSpriteLoadMonSprite); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1); r4 = AllocSpritePalette(0xD6F9); LoadCompressedPalette( @@ -1573,8 +1573,8 @@ void LinkPartnerHandleTrainerBallThrow(void) gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = r4; taskId = CreateTask(sub_812071C, 5); gTasks[taskId].data[0] = gActiveBattler; - if (ewram17810[gActiveBattler].unk0_0) - gTasks[gUnknown_02024E68[gActiveBattler]].func = sub_8044CA0; + if (gBattleHealthBoxInfo[gActiveBattler].partyStatusSummaryShown) + gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = sub_8044CA0; ewram17840.unk9_0 = 1; gBattlerControllerFuncs[gActiveBattler] = nullsub_74; } @@ -1619,31 +1619,31 @@ void LinkPartnerHandlecmd48(void) return; } - ewram17810[gActiveBattler].unk0_0 = 1; - gUnknown_02024E68[gActiveBattler] = CreatePartyStatusSummarySprites( + gBattleHealthBoxInfo[gActiveBattler].partyStatusSummaryShown = 1; + gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites( gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); - ewram17810[gActiveBattler].unk5 = 0; + gBattleHealthBoxInfo[gActiveBattler].unk5 = 0; if (gBattleBufferA[gActiveBattler][2] != 0) - ewram17810[gActiveBattler].unk5 = 0x5D; + gBattleHealthBoxInfo[gActiveBattler].unk5 = 0x5D; gBattlerControllerFuncs[gActiveBattler] = sub_81208E0; } void sub_81208E0(void) { - if (ewram17810[gActiveBattler].unk5++ >= 93) + if (gBattleHealthBoxInfo[gActiveBattler].unk5++ >= 93) { - ewram17810[gActiveBattler].unk5 = 0; + gBattleHealthBoxInfo[gActiveBattler].unk5 = 0; LinkPartnerBufferExecCompleted(); } } void LinkPartnerHandlecmd49(void) { - if (ewram17810[gActiveBattler].unk0_0) - gTasks[gUnknown_02024E68[gActiveBattler]].func = sub_8044CA0; + if (gBattleHealthBoxInfo[gActiveBattler].partyStatusSummaryShown) + gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = sub_8044CA0; LinkPartnerBufferExecCompleted(); } @@ -1669,7 +1669,7 @@ void LinkPartnerHandleBattleAnimation(void) u8 r3 = gBattleBufferA[gActiveBattler][1]; u16 r4 = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); - if (move_anim_start_t3(gActiveBattler, gActiveBattler, gActiveBattler, r3, r4) != 0) + if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, r3, r4) != 0) LinkPartnerBufferExecCompleted(); else gBattlerControllerFuncs[gActiveBattler] = sub_811E3B8; diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 83f261501..091c2c0ca 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -42,7 +42,7 @@ extern u8 gBattlerSpriteIds[]; extern u8 gBattleMonForms[]; extern struct SpriteTemplate gCreatingSpriteTemplate; extern void (*gBattlerControllerFuncs[])(void); -extern u8 gUnknown_0300434C[]; +extern u8 gBattleControllerData[]; extern u8 gHealthboxSpriteIds[]; extern u16 gBattleTypeFlags; extern u16 gTrainerBattleOpponent; @@ -60,39 +60,39 @@ extern u8 gBattlerTarget; extern u8 gAbsentBattlerFlags; extern bool8 gDoingBattleAnim; extern u16 gIntroSlideFlags; -extern u8 gUnknown_02024E68[]; +extern u8 gBattlerStatusSummaryTaskId[]; extern MainCallback gPreBattleCallback1; extern struct MusicPlayerInfo gMPlayInfo_SE1; extern struct MusicPlayerInfo gMPlayInfo_SE2; extern struct MusicPlayerInfo gMPlayInfo_BGM; extern u32 gBattleControllerExecFlags; -extern u8 sub_8077F68(); +extern u8 GetBattlerSpriteDefault_Y(); extern void sub_8033018(void); extern void BattleLoadOpponentMonSprite(); extern u8 GetBattlerPosition(u8); extern void sub_8032984(u8, u16); extern void sub_80333D4(void); -extern void sub_80312F0(struct Sprite *); -extern u8 StartSendOutMonAnimation(); +extern void SpriteCB_WaitForBattlerBallReleaseAnim(struct Sprite *); +extern u8 DoPokeballSendOutAnimation(); extern void sub_8032A08(); extern void sub_8033160(void); extern u8 get_trainer_class_pic_index(void); -extern void sub_80313A0(struct Sprite *); +extern void SpriteCB_TrainerSlideIn(struct Sprite *); extern void sub_8032B4C(void); extern void sub_8031A6C(u16, u8); extern void sub_8032B84(void); extern void StartAnimLinearTranslation(struct Sprite *); extern void sub_8032BBC(void); -extern void oamt_add_pos2_onto_pos1(); +extern void SetSpritePrimaryCoordsFromSecondaryCoords(); extern void StoreSpriteCallbackInData(); extern void sub_803311C(void); extern void sub_8010384(struct Sprite *); extern bool8 mplay_80342A4(u8); extern u8 IsMoveWithoutAnimation(); -extern void sub_80326EC(); -extern void sub_8031F24(void); -extern void sub_80324BC(); +extern void SetBattlerSpriteAffineMode(); +extern void CopyAllBattleSpritesInvisibilities(void); +extern void TrySetBehindSubstituteSpriteBit(); extern void BufferStringBattle(); extern void sub_80331D0(void); extern void AI_TrySwitchOrUseItem(void); @@ -101,15 +101,15 @@ extern void sub_80330C8(void); void sub_8033494(void); extern void move_anim_start_t2_for_situation(); extern void bx_blink_t7(void); -extern void sub_8047858(); +extern void DoHitAnimHealthboxEffect(); extern u8 GetBattlerSide(u8); -extern void StartBattleIntroAnim(); +extern void HandleIntroSlide(); extern void sub_8044CA0(u8); extern void nullsub_45(void); extern void sub_8031B74(); extern bool8 IsDoubleBattle(void); extern void sub_8032E2C(void); -extern u8 move_anim_start_t3(); +extern u8 TryHandleLaunchBattleTableAnimation(); extern void sub_80334C0(void); // this file's functions @@ -298,9 +298,9 @@ void sub_8032BBC(void) void sub_8032C4C(void) { - if ((--ewram17810[gActiveBattler].unk9) == 0xFF) + if ((--gBattleHealthBoxInfo[gActiveBattler].unk9) == 0xFF) { - ewram17810[gActiveBattler].unk9 = 0; + gBattleHealthBoxInfo[gActiveBattler].unk9 = 0; OpponentBufferExecCompleted(); } } @@ -323,51 +323,51 @@ void sub_8032C88(void) if (IsCryPlayingOrClearCrySongs()) r6 = FALSE; - if (r6 && ewram17810[gActiveBattler].unk1_0 && ewram17810[gActiveBattler ^ 2].unk1_0) + if (r6 && gBattleHealthBoxInfo[gActiveBattler].finishedShinyMonAnim && gBattleHealthBoxInfo[gActiveBattler ^ 2].finishedShinyMonAnim) { - ewram17810[gActiveBattler].unk0_7 = 0; - ewram17810[gActiveBattler].unk1_0 = 0; - ewram17810[gActiveBattler ^ 2].unk0_7 = 0; - ewram17810[gActiveBattler ^ 2].unk1_0 = 0; + gBattleHealthBoxInfo[gActiveBattler].triedShinyMonAnim = FALSE; + gBattleHealthBoxInfo[gActiveBattler].finishedShinyMonAnim = FALSE; + gBattleHealthBoxInfo[gActiveBattler ^ 2].triedShinyMonAnim = FALSE; + gBattleHealthBoxInfo[gActiveBattler ^ 2].finishedShinyMonAnim = FALSE; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); if (gBattleTypeFlags & BATTLE_TYPE_MULTI) m4aMPlayContinue(&gMPlayInfo_BGM); else m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 256); - ewram17810[gActiveBattler].unk9 = 3; + gBattleHealthBoxInfo[gActiveBattler].unk9 = 3; gBattlerControllerFuncs[gActiveBattler] = sub_8032C4C; } } void sub_8032E2C(void) { - if (!ewram17810[gActiveBattler].unk0_3 && !ewram17810[gActiveBattler].unk0_7) - sub_8141828(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]); - if (!ewram17810[gActiveBattler ^ 2].unk0_3 && !ewram17810[gActiveBattler ^ 2].unk0_7) - sub_8141828(gActiveBattler ^ 2, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ 2]]); - if (!ewram17810[gActiveBattler].unk0_3 && !ewram17810[gActiveBattler ^ 2].unk0_3) + if (!gBattleHealthBoxInfo[gActiveBattler].ballAnimActive && !gBattleHealthBoxInfo[gActiveBattler].triedShinyMonAnim) + TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]); + if (!gBattleHealthBoxInfo[gActiveBattler ^ 2].ballAnimActive && !gBattleHealthBoxInfo[gActiveBattler ^ 2].triedShinyMonAnim) + TryShinyAnimation(gActiveBattler ^ 2, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ 2]]); + if (!gBattleHealthBoxInfo[gActiveBattler].ballAnimActive && !gBattleHealthBoxInfo[gActiveBattler ^ 2].ballAnimActive) { if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - DestroySprite(&gSprites[gUnknown_0300434C[gActiveBattler ^ 2]]); - sub_8045A5C( + DestroySprite(&gSprites[gBattleControllerData[gActiveBattler ^ 2]]); + UpdateHealthboxAttribute( gHealthboxSpriteIds[gActiveBattler ^ 2], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ 2]], 0); - sub_804777C(gActiveBattler ^ 2); - sub_8043DFC(gHealthboxSpriteIds[gActiveBattler ^ 2]); + StartHealthboxSlideIn(gActiveBattler ^ 2); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ 2]); sub_8032984( gActiveBattler ^ 2, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ 2]], MON_DATA_SPECIES)); } - DestroySprite(&gSprites[gUnknown_0300434C[gActiveBattler]]); - sub_8045A5C( + DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]); + UpdateHealthboxAttribute( gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], 0); - sub_804777C(gActiveBattler); - sub_8043DFC(gHealthboxSpriteIds[gActiveBattler]); + StartHealthboxSlideIn(gActiveBattler); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); sub_8032984( gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES)); @@ -382,15 +382,15 @@ void sub_8033018(void) if (gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded == TRUE && gSprites[gBattlerSpriteIds[gActiveBattler]].x2 == 0) { - if (!ewram17810[gActiveBattler].unk0_7) + if (!gBattleHealthBoxInfo[gActiveBattler].triedShinyMonAnim) { - sub_8141828(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]); + TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]); return; } - if (ewram17810[gActiveBattler].unk1_0) + if (gBattleHealthBoxInfo[gActiveBattler].finishedShinyMonAnim) { - ewram17810[gActiveBattler].unk0_7 = 0; - ewram17810[gActiveBattler].unk1_0 = 0; + gBattleHealthBoxInfo[gActiveBattler].triedShinyMonAnim = FALSE; + gBattleHealthBoxInfo[gActiveBattler].finishedShinyMonAnim = FALSE; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); OpponentBufferExecCompleted(); @@ -401,11 +401,11 @@ void sub_8033018(void) void sub_80330C8(void) { - s16 r4 = sub_8045C78(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], 0, 0); + s16 r4 = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], 0, 0); - sub_8043DFC(gHealthboxSpriteIds[gActiveBattler]); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); if (r4 != -1) - sub_80440EC(gHealthboxSpriteIds[gActiveBattler], r4, 0); + UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], r4, 0); else OpponentBufferExecCompleted(); } @@ -414,19 +414,19 @@ void sub_803311C(void) { if (!gSprites[gBattlerSpriteIds[gActiveBattler]].inUse) { - sub_8043DB0(gHealthboxSpriteIds[gActiveBattler]); + SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]); OpponentBufferExecCompleted(); } } void sub_8033160(void) { - if (!ewram17810[gActiveBattler].unk0_6) + if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) { FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]); sub_8032A08(gActiveBattler); - sub_8043DB0(gHealthboxSpriteIds[gActiveBattler]); + SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]); OpponentBufferExecCompleted(); } } @@ -460,36 +460,36 @@ void sub_8033264(void) { if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { - if (gBattleSpriteInfo[gActiveBattler].substituteSprite) - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 6); + if (gBattleSpriteInfo[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 6); gBattlerControllerFuncs[gActiveBattler] = sub_80332D0; } } void sub_80332D0(void) { - if (!ewram17810[gActiveBattler].unk0_6) + if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) { - CreateTask(c3_0802FDF4, 10); + CreateTask(Task_PlayerController_RestoreBgmAfterCry, 10); OpponentBufferExecCompleted(); } } void sub_8033308(void) { - if (ewram17810[gActiveBattler].unk1_0) + if (gBattleHealthBoxInfo[gActiveBattler].finishedShinyMonAnim) { - ewram17810[gActiveBattler].unk0_7 = 0; - ewram17810[gActiveBattler].unk1_0 = 0; + gBattleHealthBoxInfo[gActiveBattler].triedShinyMonAnim = FALSE; + gBattleHealthBoxInfo[gActiveBattler].finishedShinyMonAnim = FALSE; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0); - sub_8045A5C( + UpdateHealthboxAttribute( gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], 0); - sub_804777C(gActiveBattler); - sub_8043DFC(gHealthboxSpriteIds[gActiveBattler]); + StartHealthboxSlideIn(gActiveBattler); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); sub_8031F88(gActiveBattler); gBattlerControllerFuncs[gActiveBattler] = sub_8033264; } @@ -497,12 +497,12 @@ void sub_8033308(void) void sub_80333D4(void) { - if (!ewram17810[gActiveBattler].unk0_3 && !ewram17810[gActiveBattler].unk0_7) - sub_8141828(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]); - if (gSprites[gUnknown_0300434C[gActiveBattler]].callback == SpriteCallbackDummy - && !ewram17810[gActiveBattler].unk0_3) + if (!gBattleHealthBoxInfo[gActiveBattler].ballAnimActive && !gBattleHealthBoxInfo[gActiveBattler].triedShinyMonAnim) + TryShinyAnimation(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]); + if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy + && !gBattleHealthBoxInfo[gActiveBattler].ballAnimActive) { - DestroySprite(&gSprites[gUnknown_0300434C[gActiveBattler]]); + DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]); sub_8032984(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES)); gBattlerControllerFuncs[gActiveBattler] = sub_8033308; } @@ -510,13 +510,13 @@ void sub_80333D4(void) void sub_8033494(void) { - if (!ewram17810[gActiveBattler].unk0_4) + if (!gBattleHealthBoxInfo[gActiveBattler].statusAnimActive) OpponentBufferExecCompleted(); } void sub_80334C0(void) { - if (!ewram17810[gActiveBattler].unk0_5) + if (!gBattleHealthBoxInfo[gActiveBattler].animFromTableActive) OpponentBufferExecCompleted(); } @@ -1118,12 +1118,12 @@ void OpponentHandleLoadPokeSprite(void) u16 species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES); BattleLoadOpponentMonSprite(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); - GetMonSpriteTemplate_803C56C(species, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite( &gCreatingSpriteTemplate, GetBattlerSpriteCoord(gActiveBattler, 2), - sub_8077F68(gActiveBattler), - GetBattlerSubpriority(gActiveBattler)); + GetBattlerSpriteDefault_Y(gActiveBattler), + GetBattlerSpriteSubpriority(gActiveBattler)); gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = -240; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = species; @@ -1148,29 +1148,29 @@ void sub_803495C(u8 a, u8 b) sub_8032AA8(a, b); gBattlerPartyIndexes[a] = gBattleBufferA[a][1]; species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[a]], MON_DATA_SPECIES); - gUnknown_0300434C[a] = CreateInvisibleSpriteWithCallback(sub_80312F0); + gBattleControllerData[a] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); BattleLoadOpponentMonSprite(&gEnemyParty[gBattlerPartyIndexes[a]], a); - GetMonSpriteTemplate_803C56C(species, GetBattlerPosition(a)); + SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(a)); gBattlerSpriteIds[a] = CreateSprite( &gCreatingSpriteTemplate, GetBattlerSpriteCoord(a, 2), - sub_8077F68(a), - GetBattlerSubpriority(a)); + GetBattlerSpriteDefault_Y(a), + GetBattlerSpriteSubpriority(a)); gSprites[gBattlerSpriteIds[a]].data[0] = a; gSprites[gBattlerSpriteIds[a]].data[2] = species; - gSprites[gUnknown_0300434C[a]].data[1] = gBattlerSpriteIds[a]; + gSprites[gBattleControllerData[a]].data[1] = gBattlerSpriteIds[a]; gSprites[gBattlerSpriteIds[a]].oam.paletteNum = a; StartSpriteAnim(&gSprites[gBattlerSpriteIds[a]], gBattleMonForms[a]); gSprites[gBattlerSpriteIds[a]].invisible = TRUE; gSprites[gBattlerSpriteIds[a]].callback = SpriteCallbackDummy; - gSprites[gUnknown_0300434C[a]].data[0] = StartSendOutMonAnimation(0, 0xFE); + gSprites[gBattleControllerData[a]].data[0] = DoPokeballSendOutAnimation(0, 0xFE); } void OpponentHandleReturnPokeToBall(void) { if (gBattleBufferA[gActiveBattler][1] == 0) { - ewram17810[gActiveBattler].unk4 = 0; + gBattleHealthBoxInfo[gActiveBattler].animationState = 0; gBattlerControllerFuncs[gActiveBattler] = sub_8034B74; } else @@ -1178,25 +1178,25 @@ void OpponentHandleReturnPokeToBall(void) FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]); sub_8032A08(gActiveBattler); - sub_8043DB0(gHealthboxSpriteIds[gActiveBattler]); + SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]); OpponentBufferExecCompleted(); } } void sub_8034B74(void) { - switch (ewram17810[gActiveBattler].unk4) + switch (gBattleHealthBoxInfo[gActiveBattler].animationState) { case 0: - if (gBattleSpriteInfo[gActiveBattler].substituteSprite) - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 5); - ewram17810[gActiveBattler].unk4 = 1; + if (gBattleSpriteInfo[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 5); + gBattleHealthBoxInfo[gActiveBattler].animationState = 1; break; case 1: - if (!ewram17810[gActiveBattler].unk0_6) + if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) { - ewram17810[gActiveBattler].unk4 = 0; - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 2); + gBattleHealthBoxInfo[gActiveBattler].animationState = 0; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 2); gBattlerControllerFuncs[gActiveBattler] = sub_8033160; } break; @@ -1226,19 +1226,19 @@ void OpponentHandleTrainerThrow(void) } sub_8031A6C(trainerPicIndex, gActiveBattler); - GetMonSpriteTemplate_803C5A0(trainerPicIndex, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToTrainerBack(trainerPicIndex, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite( &gCreatingSpriteTemplate, 0xB0, 40 + 4 * (8 - gTrainerFrontPicCoords[trainerPicIndex].coords), - GetBattlerSubpriority(gActiveBattler)); + GetBattlerSpriteSubpriority(gActiveBattler)); gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = -240; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 2; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicIndex].tag); gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gSprites[gBattlerSpriteIds[gActiveBattler]].oam.tileNum; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.tileNum = GetSpriteTileStartByTag(gTrainerFrontPicTable[trainerPicIndex].tag); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicIndex; - gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_80313A0; + gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn; gBattlerControllerFuncs[gActiveBattler] = sub_8032B4C; } @@ -1256,7 +1256,7 @@ void OpponentHandleTrainerSlide(void) trainerPicIndex = gTrainers[gTrainerBattleOpponent].trainerPic; sub_8031A6C(trainerPicIndex, gActiveBattler); - GetMonSpriteTemplate_803C5A0(trainerPicIndex, GetBattlerPosition(gActiveBattler)); + SetMultiuseSpriteTemplateToTrainerBack(trainerPicIndex, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite( &gCreatingSpriteTemplate, 0xB0, @@ -1269,13 +1269,13 @@ void OpponentHandleTrainerSlide(void) gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gSprites[gBattlerSpriteIds[gActiveBattler]].oam.tileNum; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.tileNum = GetSpriteTileStartByTag(gTrainerFrontPicTable[trainerPicIndex].tag); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicIndex; - gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_80313A0; + gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn; gBattlerControllerFuncs[gActiveBattler] = sub_8032B84; } void OpponentHandleTrainerSlideBack(void) { - oamt_add_pos2_onto_pos1(&gSprites[gBattlerSpriteIds[gActiveBattler]]); + SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 280; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].y; @@ -1286,15 +1286,15 @@ void OpponentHandleTrainerSlideBack(void) void OpponentHandlecmd10(void) { - if (ewram17810[gActiveBattler].unk4 == 0) + if (gBattleHealthBoxInfo[gActiveBattler].animationState == 0) { - if (gBattleSpriteInfo[gActiveBattler].substituteSprite) - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 5); - ewram17810[gActiveBattler].unk4++; + if (gBattleSpriteInfo[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 5); + gBattleHealthBoxInfo[gActiveBattler].animationState++; } - else if (!ewram17810[gActiveBattler].unk0_6) + else if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) { - ewram17810[gActiveBattler].unk4 = 0; + gBattleHealthBoxInfo[gActiveBattler].animationState = 0; PlaySE12WithPanning(SE_FAINT, 63); gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_8010384; gBattlerControllerFuncs[gActiveBattler] = sub_803311C; @@ -1348,7 +1348,7 @@ void OpponentHandleMoveAnimation(void) } else { - ewram17810[gActiveBattler].unk4 = 0; + gBattleHealthBoxInfo[gActiveBattler].animationState = 0; gBattlerControllerFuncs[gActiveBattler] = sub_8035238; } } @@ -1360,45 +1360,45 @@ void sub_8035238(void) | (gBattleBufferA[gActiveBattler][2] << 8); u8 r7 = gBattleBufferA[gActiveBattler][11]; - switch (ewram17810[gActiveBattler].unk4) + switch (gBattleHealthBoxInfo[gActiveBattler].animationState) { case 0: - if (gBattleSpriteInfo[gActiveBattler].substituteSprite && !gBattleSpriteInfo[gActiveBattler].flag_x8) + if (gBattleSpriteInfo[gActiveBattler].behindSubstitute && !gBattleSpriteInfo[gActiveBattler].flag_x8) { gBattleSpriteInfo[gActiveBattler].flag_x8 = 1; - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 5); + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 5); } - ewram17810[gActiveBattler].unk4 = 1; + gBattleHealthBoxInfo[gActiveBattler].animationState = 1; break; case 1: - if (!ewram17810[gActiveBattler].unk0_6) + if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) { - sub_80326EC(0); + SetBattlerSpriteAffineMode(0); DoMoveAnim(r4); - ewram17810[gActiveBattler].unk4 = 2; + gBattleHealthBoxInfo[gActiveBattler].animationState = 2; } break; case 2: gAnimScriptCallback(); if (!gAnimScriptActive) { - sub_80326EC(1); - if ((gBattleSpriteInfo[gActiveBattler].substituteSprite) && r7 <= 1) + SetBattlerSpriteAffineMode(1); + if ((gBattleSpriteInfo[gActiveBattler].behindSubstitute) && r7 <= 1) { - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 6); + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 6); gBattleSpriteInfo[gActiveBattler].flag_x8 = 0; } - ewram17810[gActiveBattler].unk4 = 3; + gBattleHealthBoxInfo[gActiveBattler].animationState = 3; } break; case 3: - if (!ewram17810[gActiveBattler].unk0_6) + if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) { - sub_8031F24(); - sub_80324BC( + CopyAllBattleSpritesInvisibilities(); + TrySetBehindSubstituteSpriteBit( gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); - ewram17810[gActiveBattler].unk4 = 0; + gBattleHealthBoxInfo[gActiveBattler].animationState = 0; OpponentBufferExecCompleted(); } break; @@ -1597,20 +1597,20 @@ void OpponentHandleHealthBarUpdate(void) { s16 r7; - load_gfxc_health_bar(0); + LoadBattleBarGfx(0); r7 = (gBattleBufferA[gActiveBattler][3] << 8) | gBattleBufferA[gActiveBattler][2]; if (r7 != 0x7FFF) { u32 maxHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP); u32 hp = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP); - sub_8043D84(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, hp, r7); + SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, hp, r7); } else { u32 maxHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP); - sub_8043D84(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, r7); + SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, r7); } gBattlerControllerFuncs[gActiveBattler] = sub_80330C8; } @@ -1624,8 +1624,8 @@ void OpponentHandleStatusIconUpdate(void) { if (mplay_80342A4(gActiveBattler) == 0) { - sub_8045A5C(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], 9); - ewram17810[gActiveBattler].unk0_4 = 0; + UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], 9); + gBattleHealthBoxInfo[gActiveBattler].statusAnimActive = 0; gBattlerControllerFuncs[gActiveBattler] = sub_8033494; } } @@ -1723,7 +1723,7 @@ void OpponentHandleHitAnimation(void) { gDoingBattleAnim = TRUE; gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0; - sub_8047858(gActiveBattler); + DoHitAnimHealthboxEffect(gActiveBattler); gBattlerControllerFuncs[gActiveBattler] = bx_blink_t7; } } @@ -1761,7 +1761,7 @@ void OpponentHandleFaintingCry(void) void OpponentHandleIntroSlide(void) { - StartBattleIntroAnim(gBattleBufferA[gActiveBattler][1]); + HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); gIntroSlideFlags |= 1; OpponentBufferExecCompleted(); } @@ -1770,7 +1770,7 @@ void OpponentHandleTrainerBallThrow(void) { u8 taskId; - oamt_add_pos2_onto_pos1(&gSprites[gBattlerSpriteIds[gActiveBattler]]); + SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 280; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].y; @@ -1778,8 +1778,8 @@ void OpponentHandleTrainerBallThrow(void) StoreSpriteCallbackInData(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_8035C10); taskId = CreateTask(sub_8035C44, 5); gTasks[taskId].data[0] = gActiveBattler; - if (ewram17810[gActiveBattler].unk0_0) - gTasks[gUnknown_02024E68[gActiveBattler]].func = sub_8044CA0; + if (gBattleHealthBoxInfo[gActiveBattler].partyStatusSummaryShown) + gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = sub_8044CA0; ewram17840.unk9_0 = 1; gBattlerControllerFuncs[gActiveBattler] = nullsub_45; } @@ -1825,43 +1825,43 @@ void OpponentHandlecmd48(void) return; } - ewram17810[gActiveBattler].unk0_0 = 1; + gBattleHealthBoxInfo[gActiveBattler].partyStatusSummaryShown = 1; if (gBattleBufferA[gActiveBattler][2] != 0) { - if (ewram17810[gActiveBattler].unk1_1 < 2) + if (gBattleHealthBoxInfo[gActiveBattler].unk1_1 < 2) { - ewram17810[gActiveBattler].unk1_1++; + gBattleHealthBoxInfo[gActiveBattler].unk1_1++; return; } else { - ewram17810[gActiveBattler].unk1_1 = 0; + gBattleHealthBoxInfo[gActiveBattler].unk1_1 = 0; } } - gUnknown_02024E68[gActiveBattler] = CreatePartyStatusSummarySprites( + gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites( gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); - ewram17810[gActiveBattler].unk5 = 0; + gBattleHealthBoxInfo[gActiveBattler].unk5 = 0; if (gBattleBufferA[gActiveBattler][2] != 0) - ewram17810[gActiveBattler].unk5 = 0x5D; + gBattleHealthBoxInfo[gActiveBattler].unk5 = 0x5D; gBattlerControllerFuncs[gActiveBattler] = sub_8035E2C; } void sub_8035E2C(void) { - if (ewram17810[gActiveBattler].unk5++ >= 93) + if (gBattleHealthBoxInfo[gActiveBattler].unk5++ >= 93) { - ewram17810[gActiveBattler].unk5 = 0; + gBattleHealthBoxInfo[gActiveBattler].unk5 = 0; OpponentBufferExecCompleted(); } } void OpponentHandlecmd49(void) { - if (ewram17810[gActiveBattler].unk0_0) - gTasks[gUnknown_02024E68[gActiveBattler]].func = sub_8044CA0; + if (gBattleHealthBoxInfo[gActiveBattler].partyStatusSummaryShown) + gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = sub_8044CA0; OpponentBufferExecCompleted(); } @@ -1887,7 +1887,7 @@ void OpponentHandleBattleAnimation(void) u8 r3 = gBattleBufferA[gActiveBattler][1]; u16 r4 = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); - if (move_anim_start_t3(gActiveBattler, gActiveBattler, gActiveBattler, r3, r4) != 0) + if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, r3, r4) != 0) OpponentBufferExecCompleted(); else gBattlerControllerFuncs[gActiveBattler] = sub_80334C0; diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 7062b9694..b6f645920 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -1,27 +1,28 @@ #include "global.h" -#include "data2.h" -#include "battle.h" -#include "battle_anim.h" #include "battle_anim_special.h" +#include "battle_anim.h" #include "battle_controllers.h" #include "battle_interface.h" #include "battle_message.h" +#include "battle.h" +#include "data2.h" +#include "ewram.h" #include "item.h" -#include "constants/items.h" #include "link.h" #include "m4a.h" #include "main.h" #include "menu_cursor.h" -#include "constants/moves.h" #include "palette.h" +#include "pokeball.h" #include "pokemon.h" -#include "constants/songs.h" #include "sound.h" #include "string_util.h" #include "task.h" #include "text.h" #include "util.h" -#include "ewram.h" +#include "constants/items.h" +#include "constants/moves.h" +#include "constants/songs.h" struct MovePpInfo { @@ -49,7 +50,7 @@ extern u8 gActionSelectionCursor[]; extern u8 gDisplayedStringBattle[]; extern u8 gMoveSelectionCursor[]; extern u8 gBattleBufferA[][0x200]; -extern u8 gBankInMenu; +extern u8 gBattlerInMenuId; extern u16 gBattlerPartyIndexes[]; extern u8 gHealthboxSpriteIds[]; extern u8 gDoingBattleAnim; @@ -65,12 +66,12 @@ extern u16 gWeatherMoveAnim; extern u32 gTransformedPersonalities[]; extern u8 gBattleMonForms[]; extern u16 gIntroSlideFlags; -extern u8 gUnknown_02024E68[]; +extern u8 gBattlerStatusSummaryTaskId[]; extern struct SpriteTemplate gCreatingSpriteTemplate; extern u8 gAnimMoveTurn; extern u8 gBattlePartyCurrentOrder[]; extern u8 gUnknown_03004344; -extern u8 gUnknown_0300434C[]; +extern u8 gBattleControllerData[]; extern const u8 BattleText_OtherMenu[]; extern const u8 BattleText_MenuOptions[]; @@ -84,30 +85,30 @@ extern void sub_802DF30(void); extern void BattleStopLowHpSound(void); extern void PlayerBufferExecCompleted(void); extern void bx_t1_healthbar_update(void); -extern void nullsub_91(void); +extern void BattleControllerDummy(void); extern void sub_802D924(u8); extern void sub_802E434(void); extern bool8 mplay_80342A4(u8); extern void move_anim_start_t2_for_situation(); extern void bx_blink_t1(void); -extern void sub_8047858(); +extern void DoHitAnimHealthboxEffect(); extern u8 GetBattlerSide(u8); -extern void StartBattleIntroAnim(); -extern void oamt_add_pos2_onto_pos1(); +extern void HandleIntroSlide(); +extern void SetSpritePrimaryCoordsFromSecondaryCoords(); extern void StartAnimLinearTranslation(struct Sprite *); extern void StoreSpriteCallbackInData(); extern void BattleLoadPlayerMonSprite(); extern bool8 IsDoubleBattle(void); extern void sub_802D500(void); extern bool8 IsBankSpritePresent(u8); -extern bool8 move_anim_start_t3(); +extern bool8 TryHandleLaunchBattleTableAnimation(); extern void sub_802E460(void); extern void b_link_standby_message(void); extern void sub_802D18C(void); extern void sub_802DF18(void); -extern void sub_80326EC(); -extern void sub_8031F24(void); -extern void sub_80324BC(); +extern void SetBattlerSpriteAffineMode(); +extern void CopyAllBattleSpritesInvisibilities(void); +extern void TrySetBehindSubstituteSpriteBit(); extern u8 IsMoveWithoutAnimation(); extern void bx_wait_t1(void); extern u8 GetBattlerAtPosition(u8); @@ -116,15 +117,15 @@ extern void sub_80105EC(struct Sprite *); extern void sub_802D274(void); extern void sub_802D23C(void); extern u8 GetBattlerPosition(u8); -extern void LoadPlayerTrainerBankSprite(); -extern void sub_80313A0(struct Sprite *); +extern void DecompressTrainerBackPic(); +extern void SpriteCB_TrainerSlideIn(struct Sprite *); extern void sub_802D204(void); -extern u8 GetBattlerSubpriority(); +extern u8 GetBattlerSpriteSubpriority(); extern void sub_802DEAC(void); -extern void sub_80312F0(struct Sprite *); +extern void SpriteCB_WaitForBattlerBallReleaseAnim(struct Sprite *); extern u8 GetBattlerSpriteCoord(); -extern u8 sub_8077F68(); -extern u8 StartSendOutMonAnimation(); +extern u8 GetBattlerSpriteDefault_Y(); +extern u8 DoPokeballSendOutAnimation(); extern void sub_802D798(void); extern void bx_0802E404(void); extern u8 gActiveBattler; @@ -147,7 +148,7 @@ extern struct BattlePokemon gBattleMons[]; extern MainCallback gPreBattleCallback1; extern u8 gHealthboxSpriteIds[]; extern struct MusicPlayerInfo gMPlayInfo_BGM; -extern u8 gUnknown_0300434C[]; +extern u8 gBattleControllerData[]; extern u8 gUnknown_0202E8F4; extern u8 gUnknown_0202E8F5; extern u8 gBattlePartyCurrentOrder[]; @@ -162,14 +163,13 @@ extern void dp11b_obj_free(u8, u8); extern void sub_8010520(struct Sprite *); extern void sub_8010574(struct Sprite *); extern bool8 IsDoubleBattle(); -extern void sub_804777C(); extern void sub_8094E20(u8); -extern void nullsub_14(void); +extern void ReshowBattleScreenDummy(void); extern void sub_80A6DCC(void); extern void ReshowBattleScreenAfterMenu(void); void PlayerHandleGetAttributes(void); -void PlayerHandlecmd1(void); +void PlayerHandleGetRawMonData(void); void PlayerHandleSetAttributes(void); void PlayerHandlecmd3(void); void PlayerHandleLoadPokeSprite(void); @@ -231,7 +231,7 @@ const u8 gString_TurnJP[] = _("ターン"); void (*const gPlayerBufferCommands[])(void) = { PlayerHandleGetAttributes, - PlayerHandlecmd1, + PlayerHandleGetRawMonData, PlayerHandleSetAttributes, PlayerHandlecmd3, PlayerHandleLoadPokeSprite, @@ -314,11 +314,11 @@ void sub_802F934(u8, u8); void sub_802FB2C(void); void sub_8030190(void); void sub_80304A8(void); -void sub_8030E38(struct Sprite *); +void SpriteCB_FreePlayerSpriteLoadMonSprite(struct Sprite *); void task05_08033660(u8); void sub_8031064(void); -void nullsub_91(void) +void BattleControllerDummy(void) { } @@ -1002,7 +1002,7 @@ void debug_sub_8030C24(void) gBattlerTarget = GetBattlerAtPosition(3); else gBattlerTarget = GetBattlerAtPosition(1); - sub_80326EC(0); + SetBattlerSpriteAffineMode(0); DoMoveAnim(move); gBattlerControllerFuncs[gActiveBattler] = debug_sub_803107C; break; @@ -1016,7 +1016,7 @@ void debug_sub_8030C24(void) gBattlerAttacker = GetBattlerAtPosition(3); else gBattlerAttacker = GetBattlerAtPosition(1); - sub_80326EC(0); + SetBattlerSpriteAffineMode(0); DoMoveAnim(move); gBattlerControllerFuncs[gActiveBattler] = debug_sub_803107C; break; @@ -1027,7 +1027,7 @@ void debug_sub_8030C24(void) dp11b_obj_free(gActiveBattler, 0); gBattlerAttacker = GetBattlerAtPosition(3); gBattlerTarget = GetBattlerAtPosition(1); - sub_80326EC(0); + SetBattlerSpriteAffineMode(0); DoMoveAnim(move); gBattlerControllerFuncs[gActiveBattler] = debug_sub_803107C; } @@ -1052,7 +1052,7 @@ void debug_sub_8030C24(void) dp11b_obj_free(gActiveBattler, 0); gBattlerAttacker = GetBattlerAtPosition(1); gBattlerTarget = GetBattlerAtPosition(3); - sub_80326EC(0); + SetBattlerSpriteAffineMode(0); DoMoveAnim(move); gBattlerControllerFuncs[gActiveBattler] = debug_sub_803107C; } @@ -1112,7 +1112,7 @@ void debug_sub_803107C(void) { s32 i; - sub_80326EC(1); + SetBattlerSpriteAffineMode(1); dp11b_obj_instanciate(gActiveBattler, 1, 7, 1); dp11b_obj_instanciate(gActiveBattler, 0, 7, 1); @@ -1168,9 +1168,9 @@ void sub_802D274(void) void sub_802D2E0(void) { - if (--ewram17810[gActiveBattler].unk9 == 0xFF) + if (--gBattleHealthBoxInfo[gActiveBattler].unk9 == 0xFF) { - ewram17810[gActiveBattler].unk9 = 0; + gBattleHealthBoxInfo[gActiveBattler].unk9 = 0; PlayerBufferExecCompleted(); } } @@ -1193,12 +1193,12 @@ void sub_802D31C(void) if (IsCryPlayingOrClearCrySongs()) r6 = FALSE; - if (r6 && ewram17810[gActiveBattler].unk1_0 && ewram17810[gActiveBattler ^ 2].unk1_0) + if (r6 && gBattleHealthBoxInfo[gActiveBattler].finishedShinyMonAnim && gBattleHealthBoxInfo[gActiveBattler ^ 2].finishedShinyMonAnim) { - ewram17810[gActiveBattler].unk0_7 = 0; - ewram17810[gActiveBattler].unk1_0 = 0; - ewram17810[gActiveBattler ^ 2].unk0_7 = 0; - ewram17810[gActiveBattler ^ 2].unk1_0 = 0; + gBattleHealthBoxInfo[gActiveBattler].triedShinyMonAnim = FALSE; + gBattleHealthBoxInfo[gActiveBattler].finishedShinyMonAnim = FALSE; + gBattleHealthBoxInfo[gActiveBattler ^ 2].triedShinyMonAnim = FALSE; + gBattleHealthBoxInfo[gActiveBattler ^ 2].finishedShinyMonAnim = FALSE; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); if (gBattleTypeFlags & BATTLE_TYPE_MULTI) @@ -1208,36 +1208,36 @@ void sub_802D31C(void) HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); if (IsDoubleBattle()) HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ 2]], gActiveBattler ^ 2); - ewram17810[gActiveBattler].unk9 = 3; + gBattleHealthBoxInfo[gActiveBattler].unk9 = 3; gBattlerControllerFuncs[gActiveBattler] = sub_802D2E0; } } void sub_802D500(void) { - if (!ewram17810[gActiveBattler].unk0_3 && !ewram17810[gActiveBattler].unk0_7) - sub_8141828(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]); - if (!ewram17810[gActiveBattler ^ 2].unk0_3 && !ewram17810[gActiveBattler ^ 2].unk0_7) - sub_8141828(gActiveBattler ^ 2, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ 2]]); - if (!ewram17810[gActiveBattler].unk0_3 && !ewram17810[gActiveBattler ^ 2].unk0_3) + if (!gBattleHealthBoxInfo[gActiveBattler].ballAnimActive && !gBattleHealthBoxInfo[gActiveBattler].triedShinyMonAnim) + TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]); + if (!gBattleHealthBoxInfo[gActiveBattler ^ 2].ballAnimActive && !gBattleHealthBoxInfo[gActiveBattler ^ 2].triedShinyMonAnim) + TryShinyAnimation(gActiveBattler ^ 2, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ 2]]); + if (!gBattleHealthBoxInfo[gActiveBattler].ballAnimActive && !gBattleHealthBoxInfo[gActiveBattler ^ 2].ballAnimActive) { if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - DestroySprite(&gSprites[gUnknown_0300434C[gActiveBattler ^ 2]]); - sub_8045A5C( + DestroySprite(&gSprites[gBattleControllerData[gActiveBattler ^ 2]]); + UpdateHealthboxAttribute( gHealthboxSpriteIds[gActiveBattler ^ 2], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ 2]], 0); - sub_804777C(gActiveBattler ^ 2); - sub_8043DFC(gHealthboxSpriteIds[gActiveBattler ^ 2]); + StartHealthboxSlideIn(gActiveBattler ^ 2); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ 2]); } - DestroySprite(&gSprites[gUnknown_0300434C[gActiveBattler]]); - sub_8045A5C( + DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]); + UpdateHealthboxAttribute( gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], 0); - sub_804777C(gActiveBattler); - sub_8043DFC(gHealthboxSpriteIds[gActiveBattler]); + StartHealthboxSlideIn(gActiveBattler); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); ewram17840.unk9_0 = 0; gBattlerControllerFuncs[gActiveBattler] = sub_802D31C; } @@ -1246,21 +1246,21 @@ void sub_802D500(void) void sub_802D680(void) { if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy - && ewram17810[gActiveBattler].unk1_0) + && gBattleHealthBoxInfo[gActiveBattler].finishedShinyMonAnim) { - ewram17810[gActiveBattler].unk0_7 = 0; - ewram17810[gActiveBattler].unk1_0 = 0; + gBattleHealthBoxInfo[gActiveBattler].triedShinyMonAnim = FALSE; + gBattleHealthBoxInfo[gActiveBattler].finishedShinyMonAnim = FALSE; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); - if (gBattleSpriteInfo[gActiveBattler].substituteSprite) - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 6); + if (gBattleSpriteInfo[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 6); gBattlerControllerFuncs[gActiveBattler] = sub_802D730; } } void sub_802D730(void) { - if (!ewram17810[gActiveBattler].unk0_6 && !IsCryPlayingOrClearCrySongs()) + if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive && !IsCryPlayingOrClearCrySongs()) { m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); @@ -1270,21 +1270,21 @@ void sub_802D730(void) void sub_802D798(void) { - if (!ewram17810[gActiveBattler].unk0_3 && !ewram17810[gActiveBattler].unk0_7) - sub_8141828(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]); - if (gSprites[gUnknown_0300434C[gActiveBattler]].callback == SpriteCallbackDummy - && !ewram17810[gActiveBattler].unk0_3) + if (!gBattleHealthBoxInfo[gActiveBattler].ballAnimActive && !gBattleHealthBoxInfo[gActiveBattler].triedShinyMonAnim) + TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]); + if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy + && !gBattleHealthBoxInfo[gActiveBattler].ballAnimActive) { - DestroySprite(&gSprites[gUnknown_0300434C[gActiveBattler]]); - sub_8045A5C(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], 0); - sub_804777C(gActiveBattler); - sub_8043DFC(gHealthboxSpriteIds[gActiveBattler]); + DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]); + UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], 0); + StartHealthboxSlideIn(gActiveBattler); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); sub_8031F88(gActiveBattler); gBattlerControllerFuncs[gActiveBattler] = sub_802D680; } } -void c3_0802FDF4(u8 taskId) +void Task_PlayerController_RestoreBgmAfterCry(u8 taskId) { if (!IsCryPlayingOrClearCrySongs()) { @@ -1295,12 +1295,12 @@ void c3_0802FDF4(u8 taskId) void bx_t1_healthbar_update(void) { - s16 r4 = sub_8045C78(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], 0, 0); + s16 r4 = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], 0, 0); - sub_8043DFC(gHealthboxSpriteIds[gActiveBattler]); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); if (r4 != -1) { - sub_80440EC(gHealthboxSpriteIds[gActiveBattler], r4, 0); + UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], r4, 0); } else { @@ -1376,7 +1376,7 @@ void sub_802DA9C(u8 taskId) exp -= currLvlExp; expToNextLvl = gExperienceTables[gBaseStats[species].growthRate][level + 1] - currLvlExp; - sub_8043D84(bank, gHealthboxSpriteIds[bank], expToNextLvl, exp, -r9); + SetBattleBarStruct(bank, gHealthboxSpriteIds[bank], expToNextLvl, exp, -r9); PlaySE(SE_EXP); gTasks[taskId].func = sub_802DB6C; } @@ -1394,8 +1394,8 @@ void sub_802DB6C(u8 taskId) u8 battlerId = gTasks[taskId].data[2]; s16 newExpPoints; - newExpPoints = sub_8045C78(battlerId, gHealthboxSpriteIds[battlerId], 1, 0); - sub_8043DFC(gHealthboxSpriteIds[battlerId]); + newExpPoints = MoveBattleBar(battlerId, gHealthboxSpriteIds[battlerId], 1, 0); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[battlerId]); if (newExpPoints == -1) { u8 level; @@ -1440,7 +1440,7 @@ void sub_802DCB0(u8 taskId) if (IsDoubleBattle() == TRUE && pkmnIndex == gBattlerPartyIndexes[bank ^ 2]) bank ^= 2; - move_anim_start_t4(bank, bank, bank, 0); + InitAndLaunchSpecialAnimation(bank, bank, bank, 0); gTasks[taskId].func = sub_802DD10; } @@ -1448,15 +1448,15 @@ void sub_802DD10(u8 taskId) { u8 bank = gTasks[taskId].data[2]; - if (!ewram17810[bank].unk0_6) + if (!gBattleHealthBoxInfo[bank].specialAnimActive) { u8 pkmnIndex = gTasks[taskId].data[0]; GetMonData(&gPlayerParty[pkmnIndex], MON_DATA_LEVEL); // Unused return value if (IsDoubleBattle() == TRUE && pkmnIndex == gBattlerPartyIndexes[bank ^ 2]) - sub_8045A5C(gHealthboxSpriteIds[bank ^ 2], &gPlayerParty[pkmnIndex], 0); + UpdateHealthboxAttribute(gHealthboxSpriteIds[bank ^ 2], &gPlayerParty[pkmnIndex], 0); else - sub_8045A5C(gHealthboxSpriteIds[bank], &gPlayerParty[pkmnIndex], 0); + UpdateHealthboxAttribute(gHealthboxSpriteIds[bank], &gPlayerParty[pkmnIndex], 0); gTasks[taskId].func = sub_802DDC4; } } @@ -1482,18 +1482,18 @@ void sub_802DE10(void) nullsub_9(species); FreeOamMatrix(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.matrixNum); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]); - sub_8043DB0(gHealthboxSpriteIds[gActiveBattler]); + SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]); PlayerBufferExecCompleted(); } } void sub_802DEAC(void) { - if (!ewram17810[gActiveBattler].unk0_6) + if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) { FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]); - sub_8043DB0(gHealthboxSpriteIds[gActiveBattler]); + SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]); PlayerBufferExecCompleted(); } } @@ -1512,8 +1512,8 @@ void sub_802DF30(void) u8 r4; gBattlerControllerFuncs[gActiveBattler] = sub_802DF88; - r4 = gTasks[gUnknown_0300434C[gActiveBattler]].data[0]; - DestroyTask(gUnknown_0300434C[gActiveBattler]); + r4 = gTasks[gBattleControllerData[gActiveBattler]].data[0]; + DestroyTask(gBattleControllerData[gActiveBattler]); sub_8094E20(r4); } } @@ -1537,7 +1537,7 @@ void sub_802E004(void) if (!gPaletteFade.active) { gBattlerControllerFuncs[gActiveBattler] = sub_802E03C; - nullsub_14(); + ReshowBattleScreenDummy(); sub_80A6DCC(); } } @@ -1553,7 +1553,7 @@ void sub_802E03C(void) void bx_wait_t1(void) { - if (!gDoingBattleAnim || !ewram17810[gActiveBattler].unk0_6) + if (!gDoingBattleAnim || !gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) PlayerBufferExecCompleted(); } @@ -1706,13 +1706,13 @@ void sub_802E424(void) void sub_802E434(void) { - if (!ewram17810[gActiveBattler].unk0_4) + if (!gBattleHealthBoxInfo[gActiveBattler].statusAnimActive) PlayerBufferExecCompleted(); } void sub_802E460(void) { - if (!ewram17810[gActiveBattler].unk0_5) + if (!gBattleHealthBoxInfo[gActiveBattler].animFromTableActive) PlayerBufferExecCompleted(); } @@ -2053,7 +2053,7 @@ u32 dp01_getattr_by_ch1_for_player_pokemon_(u8 a, u8 *buffer) return size; } -void PlayerHandlecmd1(void) +void PlayerHandleGetRawMonData(void) { struct BattlePokemon battleMon; u8 i; @@ -2341,53 +2341,53 @@ void sub_802F934(u8 bank, u8 b) sub_8032AA8(bank, b); gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1]; species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES); - gUnknown_0300434C[bank] = CreateInvisibleSpriteWithCallback(sub_80312F0); - GetMonSpriteTemplate_803C56C(species, GetBattlerPosition(bank)); + gBattleControllerData[bank] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); + SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(bank)); gBattlerSpriteIds[bank] = CreateSprite( &gCreatingSpriteTemplate, GetBattlerSpriteCoord(bank, 2), - sub_8077F68(bank), - GetBattlerSubpriority(bank)); - gSprites[gUnknown_0300434C[bank]].data[1] = gBattlerSpriteIds[bank]; + GetBattlerSpriteDefault_Y(bank), + GetBattlerSpriteSubpriority(bank)); + gSprites[gBattleControllerData[bank]].data[1] = gBattlerSpriteIds[bank]; gSprites[gBattlerSpriteIds[bank]].data[0] = bank; gSprites[gBattlerSpriteIds[bank]].data[2] = species; gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank; StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]); gSprites[gBattlerSpriteIds[bank]].invisible = TRUE; gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy; - gSprites[gUnknown_0300434C[bank]].data[0] = StartSendOutMonAnimation(0, 0xFF); + gSprites[gBattleControllerData[bank]].data[0] = DoPokeballSendOutAnimation(0, 0xFF); } void PlayerHandleReturnPokeToBall(void) { if (gBattleBufferA[gActiveBattler][1] == 0) { - ewram17810[gActiveBattler].unk4 = 0; + gBattleHealthBoxInfo[gActiveBattler].animationState = 0; gBattlerControllerFuncs[gActiveBattler] = sub_802FB2C; } else { FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]); - sub_8043DB0(gHealthboxSpriteIds[gActiveBattler]); + SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]); PlayerBufferExecCompleted(); } } void sub_802FB2C(void) { - switch (ewram17810[gActiveBattler].unk4) + switch (gBattleHealthBoxInfo[gActiveBattler].animationState) { case 0: - if (gBattleSpriteInfo[gActiveBattler].substituteSprite) - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 5); - ewram17810[gActiveBattler].unk4 = 1; + if (gBattleSpriteInfo[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 5); + gBattleHealthBoxInfo[gActiveBattler].animationState = 1; break; case 1: - if (!ewram17810[gActiveBattler].unk0_6) + if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) { - ewram17810[gActiveBattler].unk4 = 0; - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 1); + gBattleHealthBoxInfo[gActiveBattler].animationState = 0; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 1); gBattlerControllerFuncs[gActiveBattler] = sub_802DEAC; } } @@ -2408,24 +2408,24 @@ void PlayerHandleTrainerThrow(void) { r7 = 0; } - LoadPlayerTrainerBankSprite(gSaveBlock2.playerGender, gActiveBattler); - GetMonSpriteTemplate_803C5A0(gSaveBlock2.playerGender, GetBattlerPosition(gActiveBattler)); + DecompressTrainerBackPic(gSaveBlock2.playerGender, gActiveBattler); + SetMultiuseSpriteTemplateToTrainerBack(gSaveBlock2.playerGender, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite( &gCreatingSpriteTemplate, r7 + 80, (8 - gTrainerBackPicCoords[gSaveBlock2.playerGender].coords) * 4 + 80, - GetBattlerSubpriority(gActiveBattler)); + GetBattlerSpriteSubpriority(gActiveBattler)); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = 240; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2; - gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_80313A0; + gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn; gBattlerControllerFuncs[gActiveBattler] = sub_802D204; } void PlayerHandleTrainerSlide(void) { - LoadPlayerTrainerBankSprite(gSaveBlock2.playerGender, gActiveBattler); - GetMonSpriteTemplate_803C5A0(gSaveBlock2.playerGender, GetBattlerPosition(gActiveBattler)); + DecompressTrainerBackPic(gSaveBlock2.playerGender, gActiveBattler); + SetMultiuseSpriteTemplateToTrainerBack(gSaveBlock2.playerGender, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite( &gCreatingSpriteTemplate, 80, @@ -2434,13 +2434,13 @@ void PlayerHandleTrainerSlide(void) gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = -96; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 2; - gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_80313A0; + gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn; gBattlerControllerFuncs[gActiveBattler] = sub_802D23C; } void PlayerHandleTrainerSlideBack(void) { - oamt_add_pos2_onto_pos1(&gSprites[gBattlerSpriteIds[gActiveBattler]]); + SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 50; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].y; @@ -2452,17 +2452,17 @@ void PlayerHandleTrainerSlideBack(void) void PlayerHandlecmd10(void) { - if (ewram17810[gActiveBattler].unk4 == 0) + if (gBattleHealthBoxInfo[gActiveBattler].animationState == 0) { - if (gBattleSpriteInfo[gActiveBattler].substituteSprite) - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 5); - ewram17810[gActiveBattler].unk4++; + if (gBattleSpriteInfo[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 5); + gBattleHealthBoxInfo[gActiveBattler].animationState++; } else { - if (ewram17810[gActiveBattler].unk0_6 == 0) + if (gBattleHealthBoxInfo[gActiveBattler].specialAnimActive == 0) { - ewram17810[gActiveBattler].unk4 = 0; + gBattleHealthBoxInfo[gActiveBattler].animationState = 0; HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); PlaySE12WithPanning(SE_FAINT, -64); gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0; @@ -2483,7 +2483,7 @@ void PlayerHandlecmd12(void) { ewram17840.unk8 = 4; gDoingBattleAnim = 1; - move_anim_start_t4(gActiveBattler, gActiveBattler, GetBattlerAtPosition(1), 3); + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(1), 3); gBattlerControllerFuncs[gActiveBattler] = bx_wait_t1; } @@ -2493,7 +2493,7 @@ void PlayerHandleBallThrow(void) ewram17840.unk8 = var; gDoingBattleAnim = 1; - move_anim_start_t4(gActiveBattler, gActiveBattler, GetBattlerAtPosition(1), 3); + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(1), 3); gBattlerControllerFuncs[gActiveBattler] = bx_wait_t1; } @@ -2528,7 +2528,7 @@ void PlayerHandleMoveAnimation(void) } else { - ewram17810[gActiveBattler].unk4 = 0; + gBattleHealthBoxInfo[gActiveBattler].animationState = 0; gBattlerControllerFuncs[gActiveBattler] = sub_8030190; } } @@ -2539,44 +2539,44 @@ void sub_8030190(void) u16 r4 = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); u8 r7 = gBattleBufferA[gActiveBattler][11]; - switch (ewram17810[gActiveBattler].unk4) + switch (gBattleHealthBoxInfo[gActiveBattler].animationState) { case 0: - if (gBattleSpriteInfo[gActiveBattler].substituteSprite == 1 && + if (gBattleSpriteInfo[gActiveBattler].behindSubstitute == 1 && gBattleSpriteInfo[gActiveBattler].flag_x8 == 0) { gBattleSpriteInfo[gActiveBattler].flag_x8 = 1; - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 5); + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 5); } - ewram17810[gActiveBattler].unk4 = 1; + gBattleHealthBoxInfo[gActiveBattler].animationState = 1; break; case 1: - if (ewram17810[gActiveBattler].unk0_6 == 0) + if (gBattleHealthBoxInfo[gActiveBattler].specialAnimActive == 0) { - sub_80326EC(0); + SetBattlerSpriteAffineMode(0); DoMoveAnim(r4); - ewram17810[gActiveBattler].unk4 = 2; + gBattleHealthBoxInfo[gActiveBattler].animationState = 2; } break; case 2: gAnimScriptCallback(); if (!gAnimScriptActive) { - sub_80326EC(1); - if (gBattleSpriteInfo[gActiveBattler].substituteSprite == 1 && r7 < 2) + SetBattlerSpriteAffineMode(1); + if (gBattleSpriteInfo[gActiveBattler].behindSubstitute == 1 && r7 < 2) { - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 6); + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 6); gBattleSpriteInfo[gActiveBattler].flag_x8 = 0; } - ewram17810[gActiveBattler].unk4 = 3; + gBattleHealthBoxInfo[gActiveBattler].animationState = 3; } break; case 3: - if (ewram17810[gActiveBattler].unk0_6 == 0) + if (gBattleHealthBoxInfo[gActiveBattler].specialAnimActive == 0) { - sub_8031F24(); - sub_80324BC(gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); - ewram17810[gActiveBattler].unk4 = 0; + CopyAllBattleSpritesInvisibilities(); + TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + gBattleHealthBoxInfo[gActiveBattler].animationState = 0; PlayerBufferExecCompleted(); } break; @@ -2658,7 +2658,7 @@ void PlayerHandleOpenBag(void) BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); gBattlerControllerFuncs[gActiveBattler] = sub_802E004; - gBankInMenu = gActiveBattler; + gBattlerInMenuId = gActiveBattler; for (i = 0; i < 3; i++) gBattlePartyCurrentOrder[i] = gBattleBufferA[gActiveBattler][1 + i]; } @@ -2667,8 +2667,8 @@ void PlayerHandlecmd22(void) { s32 i; - gUnknown_0300434C[gActiveBattler] = CreateTask(TaskDummy, 0xFF); - gTasks[gUnknown_0300434C[gActiveBattler]].data[0] = gBattleBufferA[gActiveBattler][1] & 0xF; + gBattleControllerData[gActiveBattler] = CreateTask(TaskDummy, 0xFF); + gTasks[gBattleControllerData[gActiveBattler]].data[0] = gBattleBufferA[gActiveBattler][1] & 0xF; gBattleStruct->battlerPreventingSwitchout = gBattleBufferA[gActiveBattler][1] >> 4; gBattleStruct->unk1609D = gBattleBufferA[gActiveBattler][2]; gBattleStruct->abilityPreventingSwitchout = gBattleBufferA[gActiveBattler][3]; @@ -2676,7 +2676,7 @@ void PlayerHandlecmd22(void) gBattlePartyCurrentOrder[i] = gBattleBufferA[gActiveBattler][4 + i]; BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); gBattlerControllerFuncs[gActiveBattler] = sub_802DF30; - gBankInMenu = gActiveBattler; + gBattlerInMenuId = gActiveBattler; } void PlayerHandlecmd23(void) @@ -2690,21 +2690,21 @@ void PlayerHandleHealthBarUpdate(void) { s16 r7; - load_gfxc_health_bar(0); + LoadBattleBarGfx(0); r7 = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); if (r7 != 0x7FFF) { u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP); u32 curHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP); - sub_8043D84(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, r7); + SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, r7); } else { u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP); - sub_8043D84(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, r7); - sub_80440EC(gHealthboxSpriteIds[gActiveBattler], 0, 0); + SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, r7); + UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], 0, 0); } gBattlerControllerFuncs[gActiveBattler] = bx_t1_healthbar_update; } @@ -2722,14 +2722,14 @@ void PlayerHandleExpBarUpdate(void) u16 r4; u8 taskId; - load_gfxc_health_bar(1); + LoadBattleBarGfx(1); GetMonData(&gPlayerParty[r7], MON_DATA_SPECIES); // unused return value r4 = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); taskId = CreateTask(sub_802D924, 10); gTasks[taskId].data[0] = r7; gTasks[taskId].data[1] = r4; gTasks[taskId].data[2] = gActiveBattler; - gBattlerControllerFuncs[gActiveBattler] = nullsub_91; + gBattlerControllerFuncs[gActiveBattler] = BattleControllerDummy; } } @@ -2737,8 +2737,8 @@ void PlayerHandleStatusIconUpdate(void) { if (!mplay_80342A4(gActiveBattler)) { - sub_8045A5C(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], 9); - ewram17810[gActiveBattler].unk0_4 = 0; + UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], 9); + gBattleHealthBoxInfo[gActiveBattler].statusAnimActive = 0; gBattlerControllerFuncs[gActiveBattler] = sub_802E434; } } @@ -2848,7 +2848,7 @@ void PlayerHandleHitAnimation(void) { gDoingBattleAnim = 1; gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0; - sub_8047858(gActiveBattler); + DoHitAnimHealthboxEffect(gActiveBattler); gBattlerControllerFuncs[gActiveBattler] = bx_blink_t1; } } @@ -2886,7 +2886,7 @@ void PlayerHandleFaintingCry(void) void PlayerHandleIntroSlide(void) { - StartBattleIntroAnim(gBattleBufferA[gActiveBattler][1]); + HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); gIntroSlideFlags |= 1; PlayerBufferExecCompleted(); } @@ -2896,26 +2896,26 @@ void PlayerHandleTrainerBallThrow(void) u8 paletteNum; u8 taskId; - oamt_add_pos2_onto_pos1(&gSprites[gBattlerSpriteIds[gActiveBattler]]); + SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 50; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].y; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation; gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gActiveBattler; - StoreSpriteCallbackInData(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_8030E38); + StoreSpriteCallbackInData(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCB_FreePlayerSpriteLoadMonSprite); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1); paletteNum = AllocSpritePalette(0xD6F8); LoadCompressedPalette(gTrainerBackPicPaletteTable[gSaveBlock2.playerGender].data, 0x100 + paletteNum * 16, 32); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum; taskId = CreateTask(task05_08033660, 5); gTasks[taskId].data[0] = gActiveBattler; - if (ewram17810[gActiveBattler].unk0_0) - gTasks[gUnknown_02024E68[gActiveBattler]].func = sub_8044CA0; - ewram17810[4].unk9 |= 1; - gBattlerControllerFuncs[gActiveBattler] = nullsub_91; + if (gBattleHealthBoxInfo[gActiveBattler].partyStatusSummaryShown) + gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = sub_8044CA0; + gBattleHealthBoxInfo[4].unk9 |= 1; + gBattlerControllerFuncs[gActiveBattler] = BattleControllerDummy; } -void sub_8030E38(struct Sprite *sprite) +void SpriteCB_FreePlayerSpriteLoadMonSprite(struct Sprite *sprite) { u8 r4 = sprite->data[5]; @@ -2966,28 +2966,28 @@ void PlayerHandlecmd48(void) } else { - ewram17810[gActiveBattler].unk0_0 = 1; - gUnknown_02024E68[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); - ewram17810[gActiveBattler].unk5 = 0; + gBattleHealthBoxInfo[gActiveBattler].partyStatusSummaryShown = 1; + gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); + gBattleHealthBoxInfo[gActiveBattler].unk5 = 0; if (gBattleBufferA[gActiveBattler][2] != 0) - ewram17810[gActiveBattler].unk5 = 0x5D; + gBattleHealthBoxInfo[gActiveBattler].unk5 = 0x5D; gBattlerControllerFuncs[gActiveBattler] = sub_8031064; } } void sub_8031064(void) { - if (ewram17810[gActiveBattler].unk5++ > 0x5C) + if (gBattleHealthBoxInfo[gActiveBattler].unk5++ > 0x5C) { - ewram17810[gActiveBattler].unk5 = 0; + gBattleHealthBoxInfo[gActiveBattler].unk5 = 0; PlayerBufferExecCompleted(); } } void PlayerHandlecmd49(void) { - if (ewram17810[gActiveBattler].unk0_0) - gTasks[gUnknown_02024E68[gActiveBattler]].func = sub_8044CA0; + if (gBattleHealthBoxInfo[gActiveBattler].partyStatusSummaryShown) + gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = sub_8044CA0; PlayerBufferExecCompleted(); } @@ -3015,7 +3015,7 @@ void PlayerHandleBattleAnimation(void) u8 val2 = gBattleBufferA[gActiveBattler][1]; u16 val = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); - if (move_anim_start_t3(gActiveBattler, gActiveBattler, gActiveBattler, val2, val)) + if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, val2, val)) PlayerBufferExecCompleted(); else gBattlerControllerFuncs[gActiveBattler] = sub_802E460; diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c index 678f49909..355a96e0b 100644 --- a/src/battle_controller_safari.c +++ b/src/battle_controller_safari.c @@ -1,19 +1,20 @@ #include "global.h" #include "battle_anim_81258BC.h" -#include "battle.h" #include "battle_controllers.h" #include "battle_interface.h" #include "battle_message.h" +#include "battle.h" #include "data2.h" +#include "ewram.h" #include "link.h" #include "main.h" #include "menu_cursor.h" #include "palette.h" -#include "constants/songs.h" +#include "pokeball.h" #include "sound.h" #include "text.h" #include "util.h" -#include "ewram.h" +#include "constants/songs.h" extern struct Window gWindowTemplate_Contest_MoveDescription; extern u8 gDisplayedStringBattle[]; @@ -32,7 +33,7 @@ extern u16 gBattleTypeFlags; extern u32 gBattleControllerExecFlags; extern u16 gSpecialVar_ItemId; extern MainCallback gPreBattleCallback1; -extern u8 gBankInMenu; +extern u8 gBattlerInMenuId; extern u8 gHealthboxSpriteIds[]; extern u16 gBattlerPartyIndexes[]; extern u16 gIntroSlideFlags; @@ -41,13 +42,12 @@ extern u8 gBattleOutcome; extern u8 GetBattlerSide(u8); extern u8 GetBattlerAtPosition(u8); extern u8 GetBattlerPosition(u8); -extern void LoadPlayerTrainerBankSprite(); -extern u8 GetBattlerSubpriority(); -extern void sub_80313A0(struct Sprite *); +extern void DecompressTrainerBackPic(); +extern u8 GetBattlerSpriteSubpriority(); +extern void SpriteCB_TrainerSlideIn(struct Sprite *); extern void sub_810BADC(void); -extern void StartBattleIntroAnim(); -extern void sub_804777C(); -extern bool8 move_anim_start_t3(); +extern void HandleIntroSlide(); +extern bool8 TryHandleLaunchBattleTableAnimation(); #if ENGLISH #define SUB_812BB10_TILE_DATA_OFFSET 440 @@ -272,8 +272,8 @@ void bx_battle_menu_t6_2(void) #if DEBUG else if (JOY_NEW(R_BUTTON)) { - if (!ewram17810[gActiveBattler].unk0_5) - move_anim_start_t3(gActiveBattler, gActiveBattler, gActiveBattler, 4, 0); + if (!gBattleHealthBoxInfo[gActiveBattler].animFromTableActive) + TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 4, 0); } else if (JOY_NEW(START_BUTTON)) { @@ -306,7 +306,7 @@ void sub_812B6AC(void) void bx_wait_t6(void) { - if (!gDoingBattleAnim || !ewram17810[gActiveBattler].unk0_6) + if (!gDoingBattleAnim || !gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) SafariBufferExecCompleted(); } @@ -330,7 +330,7 @@ void sub_812B758(void) void sub_812B794(void) { - if (!ewram17810[gActiveBattler].unk0_5) + if (!gBattleHealthBoxInfo[gActiveBattler].animFromTableActive) SafariBufferExecCompleted(); } @@ -352,7 +352,7 @@ void SafariBufferExecCompleted(void) void unref_sub_812B838(void) { - if (!ewram17810[gActiveBattler].unk0_4) + if (!gBattleHealthBoxInfo[gActiveBattler].statusAnimActive) SafariBufferExecCompleted(); } @@ -393,8 +393,8 @@ void SafariHandleReturnPokeToBall(void) void SafariHandleTrainerThrow(void) { - LoadPlayerTrainerBankSprite(gSaveBlock2.playerGender, gActiveBattler); - GetMonSpriteTemplate_803C5A0(gSaveBlock2.playerGender, GetBattlerPosition(gActiveBattler)); + DecompressTrainerBackPic(gSaveBlock2.playerGender, gActiveBattler); + SetMultiuseSpriteTemplateToTrainerBack(gSaveBlock2.playerGender, GetBattlerPosition(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite( &gCreatingSpriteTemplate, 80, @@ -403,7 +403,7 @@ void SafariHandleTrainerThrow(void) gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = 240; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2; - gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_80313A0; + gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn; gBattlerControllerFuncs[gActiveBattler] = sub_812B65C; } @@ -431,7 +431,7 @@ void SafariHandlecmd12(void) { ewram17840.unk8 = 4; gDoingBattleAnim = 1; - move_anim_start_t4(gActiveBattler, gActiveBattler, GetBattlerAtPosition(1), 4); + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(1), 4); gBattlerControllerFuncs[gActiveBattler] = bx_wait_t6; } @@ -441,7 +441,7 @@ void SafariHandleBallThrow(void) ewram17840.unk8 = var; gDoingBattleAnim = 1; - move_anim_start_t4(gActiveBattler, gActiveBattler, GetBattlerAtPosition(1), 4); + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(1), 4); gBattlerControllerFuncs[gActiveBattler] = bx_wait_t6; } @@ -512,7 +512,7 @@ void SafariHandleOpenBag(void) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); gBattlerControllerFuncs[gActiveBattler] = sub_812B724; - gBankInMenu = gActiveBattler; + gBattlerInMenuId = gActiveBattler; } void SafariHandlecmd22(void) @@ -537,7 +537,7 @@ void SafariHandleExpBarUpdate(void) void SafariHandleStatusIconUpdate(void) { - sub_8045A5C(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], 11); + UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], 11); SafariBufferExecCompleted(); } @@ -643,22 +643,22 @@ void SafariHandleFaintingCry(void) { u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES); - PlayCry1(species, 25); + PlayCry_Normal(species, 25); SafariBufferExecCompleted(); } void SafariHandleIntroSlide(void) { - StartBattleIntroAnim(gBattleBufferA[gActiveBattler][1]); + HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); gIntroSlideFlags |= 1; SafariBufferExecCompleted(); } void SafariHandleTrainerBallThrow(void) { - sub_8045A5C(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], 10); - sub_804777C(gActiveBattler); - sub_8043DFC(gHealthboxSpriteIds[gActiveBattler]); + UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], 10); + StartHealthboxSlideIn(gActiveBattler); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SafariBufferExecCompleted(); } @@ -687,7 +687,7 @@ void SafariHandleBattleAnimation(void) u8 r3 = gBattleBufferA[gActiveBattler][1]; u16 r4 = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); - if (move_anim_start_t3(gActiveBattler, gActiveBattler, gActiveBattler, r3, r4) != 0) + if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, r3, r4) != 0) SafariBufferExecCompleted(); else gBattlerControllerFuncs[gActiveBattler] = sub_812B794; diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c index 8af1c5345..9c36a29f6 100644 --- a/src/battle_controller_wally.c +++ b/src/battle_controller_wally.c @@ -10,8 +10,8 @@ #include "main.h" #include "menu_cursor.h" #include "palette.h" +#include "pokeball.h" #include "pokemon.h" -#include "constants/songs.h" #include "sound.h" #include "sprite.h" #include "item_use.h" @@ -20,6 +20,8 @@ #include "text.h" #include "util.h" #include "ewram.h" +#include "constants/songs.h" +#include "constants/trainers.h" struct MovePpInfo { @@ -46,289 +48,278 @@ extern u32 gTransformedPersonalities[]; extern void (*gAnimScriptCallback)(void); extern bool8 gAnimScriptActive; extern u8 gDisplayedStringBattle[]; -extern u8 gBankInMenu; +extern u8 gBattlerInMenuId; extern u8 gBattleMonForms[]; extern u8 gBattleOutcome; extern u16 gIntroSlideFlags; -extern u8 gUnknown_02024E68[]; +extern u8 gBattlerStatusSummaryTaskId[]; extern struct SpriteTemplate gCreatingSpriteTemplate; extern u8 gAnimMoveTurn; extern struct Window gWindowTemplate_Contest_MoveDescription; -extern u8 gUnknown_0300434C[]; +extern u8 gBattleControllerData[]; extern const u8 BattleText_WallyMenu[]; extern const u8 BattleText_MenuOptions[]; extern void BtlController_EmitTwoReturnValues(u8, u8, u16); extern void BtlController_EmitOneReturnValue(u8, u16); -extern void nullsub_14(void); -extern void PrepareBagForWallyTutorial(void); -extern void sub_804777C(); +extern void ReshowBattleScreenDummy(void); +extern void DoWallyTutorialBagMenu(void); extern bool8 IsDoubleBattle(void); -extern void c3_0802FDF4(u8); -extern void PlayerHandlecmd1(void); -extern void LoadPlayerTrainerBankSprite(); +extern void Task_PlayerController_RestoreBgmAfterCry(u8); +extern void PlayerHandleGetRawMonData(void); +extern void DecompressTrainerBackPic(); extern u8 GetBattlerPosition(u8); -extern void sub_80313A0(struct Sprite *); +extern void SpriteCB_TrainerSlideIn(struct Sprite *); extern u8 GetBattlerAtPosition(u8); extern u8 IsMoveWithoutAnimation(); -extern void sub_80326EC(); -extern void sub_8031F24(void); -extern void sub_80324BC(); +extern void SetBattlerSpriteAffineMode(); +extern void CopyAllBattleSpritesInvisibilities(void); +extern void TrySetBehindSubstituteSpriteBit(); extern u8 GetBattlerSide(u8); extern void sub_80304A8(void); -extern void sub_8047858(); -extern void StartBattleIntroAnim(); -extern void oamt_add_pos2_onto_pos1(); +extern void DoHitAnimHealthboxEffect(); +extern void HandleIntroSlide(); +extern void SetSpritePrimaryCoordsFromSecondaryCoords(); extern void StartAnimLinearTranslation(struct Sprite *); -extern void sub_8030E38(struct Sprite *); +extern void SpriteCB_FreePlayerSpriteLoadMonSprite(struct Sprite *); extern void StoreSpriteCallbackInData(); -extern u8 StartSendOutMonAnimation(); +extern u8 DoPokeballSendOutAnimation(); extern u8 GetBattlerSpriteCoord(); -extern u8 sub_8077F68(); -extern u8 GetBattlerSubpriority(); -extern void sub_80312F0(struct Sprite *); -extern bool8 move_anim_start_t3(); +extern u8 GetBattlerSpriteDefault_Y(); +extern u8 GetBattlerSpriteSubpriority(); +extern void SpriteCB_WaitForBattlerBallReleaseAnim(struct Sprite *); +extern bool8 TryHandleLaunchBattleTableAnimation(); // this file's functions +static void WallyHandleGetMonData(void); +static void WallyHandleGetRawMonData(void); +static void WallyHandleSetMonData(void); +static void WallyHandleSetRawMonData(void); +static void WallyHandleLoadMonSprite(void); +static void WallyHandleSwitchInAnim(void); +static void WallyHandleReturnMonToBall(void); +static void WallyHandleDrawTrainerPic(void); +static void WallyHandleTrainerSlide(void); +static void WallyHandleTrainerSlideBack(void); +static void WallyHandleFaintAnimation(void); +static void WallyHandlePaletteFade(void); +static void WallyHandleSuccessBallThrowAnim(void); +static void WallyHandleBallThrowAnim(void); +static void WallyHandlePause(void); +static void WallyHandleMoveAnimation(void); +static void WallyHandlePrintString(void); +static void WallyHandlePrintSelectionString(void); +static void WallyHandleChooseAction(void); +static void WallyHandleYesNoBox(void); +static void WallyHandleChooseMove(void); +static void WallyHandleChooseItem(void); +static void WallyHandleChoosePokemon(void); +static void WallyHandleCmd23(void); +static void WallyHandleHealthBarUpdate(void); +static void WallyHandleExpUpdate(void); +static void WallyHandleStatusIconUpdate(void); +static void WallyHandleStatusAnimation(void); +static void WallyHandleStatusXor(void); +static void WallyHandleDataTransfer(void); +static void WallyHandleDMA3Transfer(void); +static void WallyHandlePlayBGM(void); +static void WallyHandleCmd32(void); +static void WallyHandleTwoReturnValues(void); +static void WallyHandleChosenMonReturnValue(void); +static void WallyHandleOneReturnValue(void); +static void WallyHandleOneReturnValue_Duplicate(void); +static void WallyHandleClearUnkVar(void); +static void WallyHandleSetUnkVar(void); +static void WallyHandleClearUnkFlag(void); +static void WallyHandleToggleUnkFlag(void); +static void WallyHandleHitAnimation(void); +static void WallyHandleCantSwitch(void); +static void WallyHandlePlaySE(void); +static void WallyHandlePlayFanfareOrBGM(void); +static void WallyHandleFaintingCry(void); +static void WallyHandleIntroSlide(void); +static void WallyHandleIntroTrainerBallThrow(void); +static void WallyHandleDrawPartyStatusSummary(void); +static void WallyHandleHidePartyStatusSummary(void); +static void WallyHandleEndBounceEffect(void); +static void WallyHandleSpriteInvisibility(void); +static void WallyHandleBattleAnimation(void); +static void WallyHandleLinkStandbyMsg(void); +static void WallyHandleResetActionMoveSelection(void); +static void WallyHandleEndLinkBattle(void); +static void WallyCmdEnd(void); -void WallyBufferRunCommand(void); -void sub_81374FC(void); -void sub_81376B8(void); -void WallyBufferExecCompleted(void); -u32 sub_8137A84(u8, u8 *); -void sub_8138294(u8); -void sub_81390D0(void); -void sub_8139A2C(u8); - -void WallyHandleGetAttributes(void); -void WallyHandlecmd1(void); -void WallyHandleSetAttributes(void); -void WallyHandlecmd3(void); -void WallyHandleLoadPokeSprite(void); -void WallyHandleSendOutPoke(void); -void WallyHandleReturnPokeToBall(void); -void WallyHandleTrainerThrow(void); -void WallyHandleTrainerSlide(void); -void WallyHandleTrainerSlideBack(void); -void WallyHandleFaintAnimation(void); -void WallyHandlePaletteFade(void); -void WallyHandleSuccessBallThrowAnim(void); -void WallyHandleBallThrowAnim(void); -void WallyHandlePuase(void); -void WallyHandleMoveAnimation(void); -void WallyHandlePrintString(void); -void WallyHandlePrintStringPlayerOnly(void); -void WallyHandlecmd18(void); -void WallyHandlecmd19(void); -void WallyHandlecmd20(void); -void WallyHandleOpenBag(void); -void WallyHandlecmd22(void); -void WallyHandlecmd23(void); -void WallyHandleHealthBarUpdate(void); -void WallyHandleExpBarUpdate(void); -void WallyHandleStatusIconUpdate(void); -void WallyHandleStatusAnimation(void); -void WallyHandleStatusXor(void); -void WallyHandlecmd29(void); -void WallyHandleDMATransfer(void); -void WallyHandlecmd31(void); -void WallyHandlecmd32(void); -void WallyHandlecmd33(void); -void WallyHandlecmd34(void); -void WallyHandlecmd35(void); -void WallyHandlecmd36(void); -void WallyHandlecmd37(void); -void WallyHandlecmd38(void); -void WallyHandlecmd39(void); -void WallyHandlecmd40(void); -void WallyHandleHitAnimation(void); -void WallyHandlecmd42(void); -void WallyHandleEffectivenessSound(void); -void WallyHandlecmd44(void); -void WallyHandleFaintingCry(void); -void WallyHandleIntroSlide(void); -void WallyHandleTrainerBallThrow(void); -void WallyHandlecmd48(void); -void WallyHandlecmd49(void); -void WallyHandlecmd50(void); -void WallyHandleSpriteInvisibility(void); -void WallyHandleBattleAnimation(void); -void WallyHandleLinkStandbyMsg(void); -void WallyHandleResetActionMoveSelection(void); -void WallyHandlecmd55(void); -void WallyHandlecmd56(void); - -// const data +static void WallyBufferRunCommand(void); +static void WallyBufferExecCompleted(void); +static void CompleteOnChosenItem(void); +static void Intro_WaitForShinyAnimAndHealthbox(void); +static u32 CopyWallyMonData(u8 monId, u8 *dst); +static void SetWallyMonData(u8 monId); +static void WallyDoMoveAnimation(void); +static void Task_StartSendOutAnim(u8 taskId); typedef void (*BattleBufferCmd) (void); -static const BattleBufferCmd gWallyBufferCommands[] = +static const BattleBufferCmd sWallyBufferCommands[CONTROLLER_CMDS_COUNT] = { - WallyHandleGetAttributes, - WallyHandlecmd1, - WallyHandleSetAttributes, - WallyHandlecmd3, - WallyHandleLoadPokeSprite, - WallyHandleSendOutPoke, - WallyHandleReturnPokeToBall, - WallyHandleTrainerThrow, - WallyHandleTrainerSlide, - WallyHandleTrainerSlideBack, - WallyHandleFaintAnimation, - WallyHandlePaletteFade, - WallyHandleSuccessBallThrowAnim, - WallyHandleBallThrowAnim, - WallyHandlePuase, - WallyHandleMoveAnimation, - WallyHandlePrintString, - WallyHandlePrintStringPlayerOnly, - WallyHandlecmd18, - WallyHandlecmd19, - WallyHandlecmd20, - WallyHandleOpenBag, - WallyHandlecmd22, - WallyHandlecmd23, - WallyHandleHealthBarUpdate, - WallyHandleExpBarUpdate, - WallyHandleStatusIconUpdate, - WallyHandleStatusAnimation, - WallyHandleStatusXor, - WallyHandlecmd29, - WallyHandleDMATransfer, - WallyHandlecmd31, - WallyHandlecmd32, - WallyHandlecmd33, - WallyHandlecmd34, - WallyHandlecmd35, - WallyHandlecmd36, - WallyHandlecmd37, - WallyHandlecmd38, - WallyHandlecmd39, - WallyHandlecmd40, - WallyHandleHitAnimation, - WallyHandlecmd42, - WallyHandleEffectivenessSound, - WallyHandlecmd44, - WallyHandleFaintingCry, - WallyHandleIntroSlide, - WallyHandleTrainerBallThrow, - WallyHandlecmd48, - WallyHandlecmd49, - WallyHandlecmd50, - WallyHandleSpriteInvisibility, - WallyHandleBattleAnimation, - WallyHandleLinkStandbyMsg, - WallyHandleResetActionMoveSelection, - WallyHandlecmd55, - WallyHandlecmd56, + [CONTROLLER_GETMONDATA] = WallyHandleGetMonData, + [CONTROLLER_GETRAWMONDATA] = WallyHandleGetRawMonData, + [CONTROLLER_SETMONDATA] = WallyHandleSetMonData, + [CONTROLLER_SETRAWMONDATA] = WallyHandleSetRawMonData, + [CONTROLLER_LOADMONSPRITE] = WallyHandleLoadMonSprite, + [CONTROLLER_SWITCHINANIM] = WallyHandleSwitchInAnim, + [CONTROLLER_RETURNMONTOBALL] = WallyHandleReturnMonToBall, + [CONTROLLER_DRAWTRAINERPIC] = WallyHandleDrawTrainerPic, + [CONTROLLER_TRAINERSLIDE] = WallyHandleTrainerSlide, + [CONTROLLER_TRAINERSLIDEBACK] = WallyHandleTrainerSlideBack, + [CONTROLLER_FAINTANIMATION] = WallyHandleFaintAnimation, + [CONTROLLER_PALETTEFADE] = WallyHandlePaletteFade, + [CONTROLLER_SUCCESSBALLTHROWANIM] = WallyHandleSuccessBallThrowAnim, + [CONTROLLER_BALLTHROWANIM] = WallyHandleBallThrowAnim, + [CONTROLLER_PAUSE] = WallyHandlePause, + [CONTROLLER_MOVEANIMATION] = WallyHandleMoveAnimation, + [CONTROLLER_PRINTSTRING] = WallyHandlePrintString, + [CONTROLLER_PRINTSTRINGPLAYERONLY] = WallyHandlePrintSelectionString, + [CONTROLLER_CHOOSEACTION] = WallyHandleChooseAction, + [CONTROLLER_YESNOBOX] = WallyHandleYesNoBox, + [CONTROLLER_CHOOSEMOVE] = WallyHandleChooseMove, + [CONTROLLER_OPENBAG] = WallyHandleChooseItem, + [CONTROLLER_CHOOSEPOKEMON] = WallyHandleChoosePokemon, + [CONTROLLER_23] = WallyHandleCmd23, + [CONTROLLER_HEALTHBARUPDATE] = WallyHandleHealthBarUpdate, + [CONTROLLER_EXPUPDATE] = WallyHandleExpUpdate, + [CONTROLLER_STATUSICONUPDATE] = WallyHandleStatusIconUpdate, + [CONTROLLER_STATUSANIMATION] = WallyHandleStatusAnimation, + [CONTROLLER_STATUSXOR] = WallyHandleStatusXor, + [CONTROLLER_DATATRANSFER] = WallyHandleDataTransfer, + [CONTROLLER_DMA3TRANSFER] = WallyHandleDMA3Transfer, + [CONTROLLER_PLAYBGM] = WallyHandlePlayBGM, + [CONTROLLER_32] = WallyHandleCmd32, + [CONTROLLER_TWORETURNVALUES] = WallyHandleTwoReturnValues, + [CONTROLLER_CHOSENMONRETURNVALUE] = WallyHandleChosenMonReturnValue, + [CONTROLLER_ONERETURNVALUE] = WallyHandleOneReturnValue, + [CONTROLLER_ONERETURNVALUE_DUPLICATE] = WallyHandleOneReturnValue_Duplicate, + [CONTROLLER_CLEARUNKVAR] = WallyHandleClearUnkVar, + [CONTROLLER_SETUNKVAR] = WallyHandleSetUnkVar, + [CONTROLLER_CLEARUNKFLAG] = WallyHandleClearUnkFlag, + [CONTROLLER_TOGGLEUNKFLAG] = WallyHandleToggleUnkFlag, + [CONTROLLER_HITANIMATION] = WallyHandleHitAnimation, + [CONTROLLER_CANTSWITCH] = WallyHandleCantSwitch, + [CONTROLLER_PLAYSE] = WallyHandlePlaySE, + [CONTROLLER_PLAYFANFAREORBGM] = WallyHandlePlayFanfareOrBGM, + [CONTROLLER_FAINTINGCRY] = WallyHandleFaintingCry, + [CONTROLLER_INTROSLIDE] = WallyHandleIntroSlide, + [CONTROLLER_INTROTRAINERBALLTHROW] = WallyHandleIntroTrainerBallThrow, + [CONTROLLER_DRAWPARTYSTATUSSUMMARY] = WallyHandleDrawPartyStatusSummary, + [CONTROLLER_HIDEPARTYSTATUSSUMMARY] = WallyHandleHidePartyStatusSummary, + [CONTROLLER_ENDBOUNCE] = WallyHandleEndBounceEffect, + [CONTROLLER_SPRITEINVISIBILITY] = WallyHandleSpriteInvisibility, + [CONTROLLER_BATTLEANIMATION] = WallyHandleBattleAnimation, + [CONTROLLER_LINKSTANDBYMSG] = WallyHandleLinkStandbyMsg, + [CONTROLLER_RESETACTIONMOVESELECTION] = WallyHandleResetActionMoveSelection, + [CONTROLLER_ENDLINKBATTLE] = WallyHandleEndLinkBattle, + [CONTROLLER_TERMINATOR_NOP] = WallyCmdEnd, }; -// code - -void unref_sub_8137220(void) +static void UNUSED SpriteCB_Null7(void) { } -void SetBankFuncToWallyBufferRunCommand(void) +void SetControllerToWally(void) { gBattlerControllerFuncs[gActiveBattler] = WallyBufferRunCommand; - gBattleStruct->unk160A8 = 0; - gBattleStruct->unk160A9 = 0; - gBattleStruct->unk160AA = 0; - gBattleStruct->unk160AB = 0; + gBattleStruct->wallyBattleState = 0; + gBattleStruct->wallyMovesState = 0; + gBattleStruct->wallyWaitFrames = 0; + gBattleStruct->wallyMoveFrames = 0; } -void WallyBufferRunCommand(void) +static void WallyBufferRunCommand(void) { if (gBattleControllerExecFlags & gBitTable[gActiveBattler]) { - if (gBattleBufferA[gActiveBattler][0] < 0x39) - gWallyBufferCommands[gBattleBufferA[gActiveBattler][0]](); + if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sWallyBufferCommands)) + sWallyBufferCommands[gBattleBufferA[gActiveBattler][0]](); else WallyBufferExecCompleted(); } } -void sub_81372BC(void) +static void WallyHandleActions(void) { - u8 r4; - - switch (gBattleStruct->unk160A8) + switch (gBattleStruct->wallyBattleState) { case 0: - gBattleStruct->unk160AA = 64; - gBattleStruct->unk160A8++; + gBattleStruct->wallyWaitFrames = B_WAIT_TIME_LONG; + gBattleStruct->wallyBattleState++; // fall through case 1: - r4 = --gBattleStruct->unk160AA; - if (r4 == 0) + if (--gBattleStruct->wallyWaitFrames == 0) { PlaySE(SE_SELECT); - BtlController_EmitTwoReturnValues(1, 0, 0); + BtlController_EmitTwoReturnValues(B_COMM_TO_ENGINE, B_ACTION_USE_MOVE, 0); WallyBufferExecCompleted(); - gBattleStruct->unk160A8++; - gBattleStruct->unk160A9 = r4; - gBattleStruct->unk160AA = 64; + gBattleStruct->wallyBattleState++; + gBattleStruct->wallyMovesState = 0; + gBattleStruct->wallyWaitFrames = B_WAIT_TIME_LONG; } break; case 2: - r4 = --gBattleStruct->unk160AA; - if (r4 == 0) + if (--gBattleStruct->wallyWaitFrames == 0) { PlaySE(SE_SELECT); - BtlController_EmitTwoReturnValues(1, 0, 0); + BtlController_EmitTwoReturnValues(B_COMM_TO_ENGINE, B_ACTION_USE_MOVE, 0); WallyBufferExecCompleted(); - gBattleStruct->unk160A8++; - gBattleStruct->unk160A9 = r4; - gBattleStruct->unk160AA = 64; + gBattleStruct->wallyBattleState++; + gBattleStruct->wallyMovesState = 0; + gBattleStruct->wallyWaitFrames = B_WAIT_TIME_LONG; } break; case 3: - r4 = --gBattleStruct->unk160AA; - if (r4 == 0) + if (--gBattleStruct->wallyWaitFrames == 0) { - BtlController_EmitTwoReturnValues(1, 9, 0); + BtlController_EmitTwoReturnValues(B_COMM_TO_ENGINE, B_ACTION_WALLY_THROW, 0); WallyBufferExecCompleted(); - gBattleStruct->unk160A8++; - gBattleStruct->unk160A9 = r4; - gBattleStruct->unk160AA = 64; + gBattleStruct->wallyBattleState++; + gBattleStruct->wallyMovesState = 0; + gBattleStruct->wallyWaitFrames = B_WAIT_TIME_LONG; } break; case 4: - if (--gBattleStruct->unk160AA == 0) + if (--gBattleStruct->wallyWaitFrames == 0) { PlaySE(SE_SELECT); nullsub_8(0); sub_802E3E4(1, 0); - gBattleStruct->unk160AA = 64; - gBattleStruct->unk160A8++; + gBattleStruct->wallyWaitFrames = B_WAIT_TIME_LONG; + gBattleStruct->wallyBattleState++; } break; case 5: - if (--gBattleStruct->unk160AA == 0) + if (--gBattleStruct->wallyWaitFrames == 0) { PlaySE(SE_SELECT); DestroyMenuCursor(); - BtlController_EmitTwoReturnValues(1, 1, 0); + BtlController_EmitTwoReturnValues(B_COMM_TO_ENGINE, B_ACTION_USE_ITEM, 0); WallyBufferExecCompleted(); } break; } } -void sub_813741C(void) +static void CompleteOnBattlerSpriteCallbackDummy(void) { if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) WallyBufferExecCompleted(); } -void sub_8137454(void) +static void CompleteOnInactiveTextPrinter(void) { if (gWindowTemplate_Contest_MoveDescription.state == 0) WallyBufferExecCompleted(); } -void sub_813746C(void) +void WallySetBattleEndCallbacks(void) { if (!gPaletteFade.active) { @@ -338,87 +329,96 @@ void sub_813746C(void) } } -void CompleteOnFinishedAnimation(void) +static void CompleteOnFinishedAnimation(void) { if (!gDoingBattleAnim) WallyBufferExecCompleted(); } -void sub_81374C4(void) +static void OpenBagAfterPaletteFade(void) { if (!gPaletteFade.active) { - gBattlerControllerFuncs[gActiveBattler] = sub_81374FC; - nullsub_14(); - PrepareBagForWallyTutorial(); + gBattlerControllerFuncs[gActiveBattler] = CompleteOnChosenItem; + ReshowBattleScreenDummy(); + DoWallyTutorialBagMenu(); } } -void sub_81374FC(void) +static void CompleteOnChosenItem(void) { - if (gMain.callback2 == BattleMainCB2 - && !gPaletteFade.active) + if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active) { - BtlController_EmitOneReturnValue(1, gSpecialVar_ItemId); + BtlController_EmitOneReturnValue(B_COMM_TO_ENGINE, gSpecialVar_ItemId); WallyBufferExecCompleted(); } } -void sub_8137538(void) +static void Intro_TryShinyAnimShowHealthbox(void) { - if (!ewram17810[gActiveBattler].unk0_3 && !ewram17810[gActiveBattler].unk0_7) - sub_8141828(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]); + if (!gBattleHealthBoxInfo[gActiveBattler].triedShinyMonAnim + && !gBattleHealthBoxInfo[gActiveBattler].ballAnimActive) + TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]); - if (!ewram17810[gActiveBattler ^ 2].unk0_3 && !ewram17810[gActiveBattler ^ 2].unk0_7) - sub_8141828(gActiveBattler ^ 2, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ 2]]); + if (!gBattleHealthBoxInfo[BATTLE_PARTNER(gActiveBattler)].triedShinyMonAnim + && !gBattleHealthBoxInfo[BATTLE_PARTNER(gActiveBattler)].ballAnimActive) + TryShinyAnimation(BATTLE_PARTNER(gActiveBattler), &gPlayerParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]]); - if (!ewram17810[gActiveBattler].unk0_3 && !ewram17810[gActiveBattler ^ 2].unk0_3) + if (!gBattleHealthBoxInfo[gActiveBattler].ballAnimActive + && !gBattleHealthBoxInfo[BATTLE_PARTNER(gActiveBattler)].ballAnimActive) { if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - DestroySprite(&gSprites[gUnknown_0300434C[gActiveBattler ^ 2]]); - sub_8045A5C(gHealthboxSpriteIds[gActiveBattler ^ 2], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ 2]], 0); - sub_804777C(gActiveBattler ^ 2); - sub_8043DFC(gHealthboxSpriteIds[gActiveBattler ^ 2]); + DestroySprite(&gSprites[gBattleControllerData[BATTLE_PARTNER(gActiveBattler)]]); + UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)], &gPlayerParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]], HEALTHBOX_ALL); + StartHealthboxSlideIn(BATTLE_PARTNER(gActiveBattler)); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]); } - DestroySprite(&gSprites[gUnknown_0300434C[gActiveBattler]]); - sub_8045A5C(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], 0); - sub_804777C(gActiveBattler); - sub_8043DFC(gHealthboxSpriteIds[gActiveBattler]); - ewram17840.unk9_0 = 0; - gBattlerControllerFuncs[gActiveBattler] = sub_81376B8; + DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]); + UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL); + StartHealthboxSlideIn(gActiveBattler); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); + + ewram17840.unk9_0 = FALSE; + gBattlerControllerFuncs[gActiveBattler] = Intro_WaitForShinyAnimAndHealthbox; } } -void sub_81376B8(void) +static void Intro_WaitForShinyAnimAndHealthbox(void) { - bool8 r4 = FALSE; + bool32 healthboxAnimDone = FALSE; if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) - r4 = TRUE; - if (r4 && ewram17810[gActiveBattler].unk1_0 && ewram17810[gActiveBattler ^ 2].unk1_0) + healthboxAnimDone = TRUE; + + if (healthboxAnimDone && gBattleHealthBoxInfo[gActiveBattler].finishedShinyMonAnim + && gBattleHealthBoxInfo[BATTLE_PARTNER(gActiveBattler)].finishedShinyMonAnim) { - ewram17810[gActiveBattler].unk0_7 = 0; - ewram17810[gActiveBattler].unk1_0 = 0; - ewram17810[gActiveBattler ^ 2].unk0_7 = 0; - ewram17810[gActiveBattler ^ 2].unk1_0 = 0; - FreeSpriteTilesByTag(0x27F9); - FreeSpritePaletteByTag(0x27F9); - CreateTask(c3_0802FDF4, 10); + gBattleHealthBoxInfo[gActiveBattler].triedShinyMonAnim = FALSE; + gBattleHealthBoxInfo[gActiveBattler].finishedShinyMonAnim = FALSE; + + gBattleHealthBoxInfo[BATTLE_PARTNER(gActiveBattler)].triedShinyMonAnim = FALSE; + gBattleHealthBoxInfo[BATTLE_PARTNER(gActiveBattler)].finishedShinyMonAnim = FALSE; + + FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS); + FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS); + + CreateTask(Task_PlayerController_RestoreBgmAfterCry, 10); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); + WallyBufferExecCompleted(); } } -void sub_81377B0(void) +static void CompleteOnHealthbarDone(void) { - s16 r4; + s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0); - r4 = sub_8045C78(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], 0, 0); - sub_8043DFC(gHealthboxSpriteIds[gActiveBattler]); - if (r4 != -1) + SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); + + if (hpValue != -1) { - sub_80440EC(gHealthboxSpriteIds[gActiveBattler], r4, 0); + UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT); } else { @@ -427,7 +427,7 @@ void sub_81377B0(void) } } -void bx_blink_t5(void) +static void DoHitAnimBlinkSpriteEffect(void) { u8 spriteId = gBattlerSpriteIds[gActiveBattler]; @@ -446,39 +446,38 @@ void bx_blink_t5(void) } } -void sub_813789C(void) +static void DoSwitchOutAnimation(void) { - if (!ewram17810[gActiveBattler].unk0_6) + if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) { FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]); - sub_8043DB0(gHealthboxSpriteIds[gActiveBattler]); + SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]); WallyBufferExecCompleted(); } } -// Duplicate of sub_813741C -void CompleteOnBankSpriteCallbackDummy2(void) +static void CompleteOnBankSpriteCallbackDummy2(void) { if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) WallyBufferExecCompleted(); } -void sub_8137940(void) +static void CompleteOnFinishedBattleAnimation(void) { - if (!ewram17810[gActiveBattler].unk0_5) + if (!gBattleHealthBoxInfo[gActiveBattler].animFromTableActive) WallyBufferExecCompleted(); } -void WallyBufferExecCompleted(void) +static void WallyBufferExecCompleted(void) { gBattlerControllerFuncs[gActiveBattler] = WallyBufferRunCommand; if (gBattleTypeFlags & BATTLE_TYPE_LINK) { - u8 multiplayerId = GetMultiplayerId(); + u8 playerId = GetMultiplayerId(); - PrepareBufferDataTransferLink(2, 4, &multiplayerId); - gBattleBufferA[gActiveBattler][0] = 0x38; + PrepareBufferDataTransferLink(B_COMM_CONTROLLER_IS_DONE, 4, &playerId); + gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else { @@ -486,42 +485,42 @@ void WallyBufferExecCompleted(void) } } -void unref_sub_81379E4(void) +static void UNUSED CompleteOnFinishedStatusAnimation(void) { - if (!ewram17810[gActiveBattler].unk0_4) + if (!gBattleHealthBoxInfo[gActiveBattler].statusAnimActive) WallyBufferExecCompleted(); } -void WallyHandleGetAttributes(void) +static void WallyHandleGetMonData(void) { - u8 arr[0x100]; - u32 r6 = 0; - u8 r4; + u8 monData[sizeof(struct Pokemon) * 2 + 56]; // this allows to get full data of two Pokémon, trying to get more will result in overwriting data + u32 size = 0; + u8 monToCheck; s32 i; if (gBattleBufferA[gActiveBattler][2] == 0) { - r6 = sub_8137A84(gBattlerPartyIndexes[gActiveBattler], arr); + size += CopyWallyMonData(gBattlerPartyIndexes[gActiveBattler], monData); } else { - r4 = gBattleBufferA[gActiveBattler][2]; - for (i = 0; i < 6; i++) + monToCheck = gBattleBufferA[gActiveBattler][2]; + for (i = 0; i < PARTY_SIZE; i++) { - if (r4 & 1) - r6 += sub_8137A84(i, arr + r6); - r4 >>= 1; + if (monToCheck & 1) + size += CopyWallyMonData(i, monData + size); + monToCheck >>= 1; } } - BtlController_EmitDataTransfer(1, r6, arr); + BtlController_EmitDataTransfer(B_COMM_TO_ENGINE, size, monData); WallyBufferExecCompleted(); } -u32 sub_8137A84(u8 a, u8 *buffer) +static u32 CopyWallyMonData(u8 monId, u8 *dst) { - struct BattlePokemon battlePokemon; + struct BattlePokemon battleMon; struct MovePpInfo moveData; - u8 nickname[20]; + u8 nickname[POKEMON_NAME_BUFFER_SIZE]; u8 *src; s16 data16; u32 data32; @@ -529,323 +528,324 @@ u32 sub_8137A84(u8 a, u8 *buffer) switch (gBattleBufferA[gActiveBattler][1]) { - case 0: - battlePokemon.species = GetMonData(&gPlayerParty[a], MON_DATA_SPECIES); - battlePokemon.item = GetMonData(&gPlayerParty[a], MON_DATA_HELD_ITEM); - for (size = 0; size < 4; size++) + case REQUEST_ALL_BATTLE: + battleMon.species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES); + battleMon.item = GetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM); + for (size = 0; size < MAX_MON_MOVES; size++) { - battlePokemon.moves[size] = GetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + size); - battlePokemon.pp[size] = GetMonData(&gPlayerParty[a], MON_DATA_PP1 + size); + battleMon.moves[size] = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + size); + battleMon.pp[size] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + size); } - battlePokemon.ppBonuses = GetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES); - battlePokemon.friendship = GetMonData(&gPlayerParty[a], MON_DATA_FRIENDSHIP); - battlePokemon.experience = GetMonData(&gPlayerParty[a], MON_DATA_EXP); - battlePokemon.hpIV = GetMonData(&gPlayerParty[a], MON_DATA_HP_IV); - battlePokemon.attackIV = GetMonData(&gPlayerParty[a], MON_DATA_ATK_IV); - battlePokemon.defenseIV = GetMonData(&gPlayerParty[a], MON_DATA_DEF_IV); - battlePokemon.speedIV = GetMonData(&gPlayerParty[a], MON_DATA_SPEED_IV); - battlePokemon.spAttackIV = GetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV); - battlePokemon.spDefenseIV = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV); - battlePokemon.personality = GetMonData(&gPlayerParty[a], MON_DATA_PERSONALITY); - battlePokemon.status1 = GetMonData(&gPlayerParty[a], MON_DATA_STATUS); - battlePokemon.level = GetMonData(&gPlayerParty[a], MON_DATA_LEVEL); - battlePokemon.hp = GetMonData(&gPlayerParty[a], MON_DATA_HP); - battlePokemon.maxHP = GetMonData(&gPlayerParty[a], MON_DATA_MAX_HP); - battlePokemon.attack = GetMonData(&gPlayerParty[a], MON_DATA_ATK); - battlePokemon.defense = GetMonData(&gPlayerParty[a], MON_DATA_DEF); - battlePokemon.speed = GetMonData(&gPlayerParty[a], MON_DATA_SPEED); - battlePokemon.spAttack = GetMonData(&gPlayerParty[a], MON_DATA_SPATK); - battlePokemon.spDefense = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF); - battlePokemon.isEgg = GetMonData(&gPlayerParty[a], MON_DATA_IS_EGG); - battlePokemon.altAbility = GetMonData(&gPlayerParty[a], MON_DATA_ALT_ABILITY); - battlePokemon.otId = GetMonData(&gPlayerParty[a], MON_DATA_OT_ID); - GetMonData(&gPlayerParty[a], MON_DATA_NICKNAME, nickname); - StringCopy10(battlePokemon.nickname, nickname); - GetMonData(&gPlayerParty[a], MON_DATA_OT_NAME, battlePokemon.otName); - MEMCPY_ALT(&battlePokemon, buffer, sizeof(battlePokemon), size, src); + battleMon.ppBonuses = GetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES); + battleMon.friendship = GetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP); + battleMon.experience = GetMonData(&gPlayerParty[monId], MON_DATA_EXP); + battleMon.hpIV = GetMonData(&gPlayerParty[monId], MON_DATA_HP_IV); + battleMon.attackIV = GetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV); + battleMon.defenseIV = GetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV); + battleMon.speedIV = GetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV); + battleMon.spAttackIV = GetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV); + battleMon.spDefenseIV = GetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV); + battleMon.personality = GetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY); + battleMon.status1 = GetMonData(&gPlayerParty[monId], MON_DATA_STATUS); + battleMon.level = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL); + battleMon.hp = GetMonData(&gPlayerParty[monId], MON_DATA_HP); + battleMon.maxHP = GetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP); + battleMon.attack = GetMonData(&gPlayerParty[monId], MON_DATA_ATK); + battleMon.defense = GetMonData(&gPlayerParty[monId], MON_DATA_DEF); + battleMon.speed = GetMonData(&gPlayerParty[monId], MON_DATA_SPEED); + battleMon.spAttack = GetMonData(&gPlayerParty[monId], MON_DATA_SPATK); + battleMon.spDefense = GetMonData(&gPlayerParty[monId], MON_DATA_SPDEF); + battleMon.isEgg = GetMonData(&gPlayerParty[monId], MON_DATA_IS_EGG); + battleMon.altAbility = GetMonData(&gPlayerParty[monId], MON_DATA_ALT_ABILITY); + battleMon.otId = GetMonData(&gPlayerParty[monId], MON_DATA_OT_ID); + GetMonData(&gPlayerParty[monId], MON_DATA_NICKNAME, nickname); + StringCopy10(battleMon.nickname, nickname); + GetMonData(&gPlayerParty[monId], MON_DATA_OT_NAME, battleMon.otName); + MEMCPY_ALT(&battleMon, dst, sizeof(battleMon), size, src); break; - case 1: - data16 = GetMonData(&gPlayerParty[a], MON_DATA_SPECIES); - buffer[0] = data16; - buffer[1] = data16 >> 8; + case REQUEST_SPECIES_BATTLE: + data16 = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES); + dst[0] = data16; + dst[1] = data16 >> 8; size = 2; break; - case 2: - data16 = GetMonData(&gPlayerParty[a], MON_DATA_HELD_ITEM); - buffer[0] = data16; - buffer[1] = data16 >> 8; + case REQUEST_HELDITEM_BATTLE: + data16 = GetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM); + dst[0] = data16; + dst[1] = data16 >> 8; size = 2; break; - case 3: - for (size = 0; size < 4; size++) + case REQUEST_MOVES_PP_BATTLE: + for (size = 0; size < MAX_MON_MOVES; size++) { - moveData.moves[size] = GetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + size); - moveData.pp[size] = GetMonData(&gPlayerParty[a], MON_DATA_PP1 + size); + moveData.moves[size] = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + size); + moveData.pp[size] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + size); } - moveData.ppBonuses = GetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES); - MEMCPY_ALT(&moveData, buffer, sizeof(moveData), size, src); + moveData.ppBonuses = GetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES); + MEMCPY_ALT(&moveData, dst, sizeof(moveData), size, src); break; - case 4: - case 5: - case 6: - case 7: - data16 = GetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - 4); - buffer[0] = data16; - buffer[1] = data16 >> 8; + case REQUEST_MOVE1_BATTLE: + 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); + dst[0] = data16; + dst[1] = data16 >> 8; size = 2; break; - case 8: - for (size = 0; size < 4; size++) - buffer[size] = GetMonData(&gPlayerParty[a], MON_DATA_PP1 + size); - buffer[size] = GetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES); + case REQUEST_PP_DATA_BATTLE: + for (size = 0; size < MAX_MON_MOVES; size++) + dst[size] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + size); + dst[size] = GetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES); size++; break; - case 9: - case 10: - case 11: - case 12: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - 9); + case REQUEST_PPMOVE1_BATTLE: + 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); size = 1; break; - case 17: - data32 = GetMonData(&gPlayerParty[a], MON_DATA_OT_ID); - buffer[0] = (data32 & 0x000000FF); - buffer[1] = (data32 & 0x0000FF00) >> 8; - buffer[2] = (data32 & 0x00FF0000) >> 16; + case REQUEST_OTID_BATTLE: + data32 = GetMonData(&gPlayerParty[monId], MON_DATA_OT_ID); + dst[0] = (data32 & 0x000000FF); + dst[1] = (data32 & 0x0000FF00) >> 8; + dst[2] = (data32 & 0x00FF0000) >> 16; size = 3; break; - case 18: - data32 = GetMonData(&gPlayerParty[a], MON_DATA_EXP); - buffer[0] = (data32 & 0x000000FF); - buffer[1] = (data32 & 0x0000FF00) >> 8; - buffer[2] = (data32 & 0x00FF0000) >> 16; + case REQUEST_EXP_BATTLE: + data32 = GetMonData(&gPlayerParty[monId], MON_DATA_EXP); + dst[0] = (data32 & 0x000000FF); + dst[1] = (data32 & 0x0000FF00) >> 8; + dst[2] = (data32 & 0x00FF0000) >> 16; size = 3; break; - case 19: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_HP_EV); + case REQUEST_HP_EV_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_HP_EV); size = 1; break; - case 20: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_ATK_EV); + case REQUEST_ATK_EV_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV); size = 1; break; - case 21: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_DEF_EV); + case REQUEST_DEF_EV_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV); size = 1; break; - case 22: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPEED_EV); + case REQUEST_SPEED_EV_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV); size = 1; break; - case 23: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPATK_EV); + case REQUEST_SPATK_EV_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV); size = 1; break; - case 24: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF_EV); + case REQUEST_SPDEF_EV_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV); size = 1; break; - case 25: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_FRIENDSHIP); + case REQUEST_FRIENDSHIP_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP); size = 1; break; - case 26: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_POKERUS); + case REQUEST_POKERUS_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_POKERUS); size = 1; break; - case 27: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_MET_LOCATION); + case REQUEST_MET_LOCATION_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION); size = 1; break; - case 28: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_MET_LEVEL); + case REQUEST_MET_LEVEL_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL); size = 1; break; - case 29: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_MET_GAME); + case REQUEST_MET_GAME_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME); size = 1; break; - case 30: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_POKEBALL); + case REQUEST_POKEBALL_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL); size = 1; break; - case 31: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_HP_IV); - buffer[1] = GetMonData(&gPlayerParty[a], MON_DATA_ATK_IV); - buffer[2] = GetMonData(&gPlayerParty[a], MON_DATA_DEF_IV); - buffer[3] = GetMonData(&gPlayerParty[a], MON_DATA_SPEED_IV); - buffer[4] = GetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV); - buffer[5] = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV); + case REQUEST_ALL_IVS_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_HP_IV); + dst[1] = GetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV); + dst[2] = GetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV); + dst[3] = GetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV); + dst[4] = GetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV); + dst[5] = GetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV); size = 6; break; - case 32: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_HP_IV); + case REQUEST_HP_IV_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_HP_IV); size = 1; break; - case 33: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_ATK_IV); + case REQUEST_ATK_IV_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV); size = 1; break; - case 34: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_DEF_IV); + case REQUEST_DEF_IV_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV); size = 1; break; - case 35: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPEED_IV); + case REQUEST_SPEED_IV_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV); size = 1; break; - case 36: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV); + case REQUEST_SPATK_IV_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV); size = 1; break; - case 37: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV); + case REQUEST_SPDEF_IV_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV); size = 1; break; - case 38: - data32 = GetMonData(&gPlayerParty[a], MON_DATA_PERSONALITY); - buffer[0] = (data32 & 0x000000FF); - buffer[1] = (data32 & 0x0000FF00) >> 8; - buffer[2] = (data32 & 0x00FF0000) >> 16; - buffer[3] = (data32 & 0xFF000000) >> 24; + case REQUEST_PERSONALITY_BATTLE: + data32 = GetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY); + dst[0] = (data32 & 0x000000FF); + dst[1] = (data32 & 0x0000FF00) >> 8; + dst[2] = (data32 & 0x00FF0000) >> 16; + dst[3] = (data32 & 0xFF000000) >> 24; size = 4; break; - case 39: - data16 = GetMonData(&gPlayerParty[a], MON_DATA_CHECKSUM); - buffer[0] = data16; - buffer[1] = data16 >> 8; + case REQUEST_CHECKSUM_BATTLE: + data16 = GetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM); + dst[0] = data16; + dst[1] = data16 >> 8; size = 2; break; - case 40: - data32 = GetMonData(&gPlayerParty[a], MON_DATA_STATUS); - buffer[0] = (data32 & 0x000000FF); - buffer[1] = (data32 & 0x0000FF00) >> 8; - buffer[2] = (data32 & 0x00FF0000) >> 16; - buffer[3] = (data32 & 0xFF000000) >> 24; + case REQUEST_STATUS_BATTLE: + data32 = GetMonData(&gPlayerParty[monId], MON_DATA_STATUS); + dst[0] = (data32 & 0x000000FF); + dst[1] = (data32 & 0x0000FF00) >> 8; + dst[2] = (data32 & 0x00FF0000) >> 16; + dst[3] = (data32 & 0xFF000000) >> 24; size = 4; break; - case 41: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_LEVEL); + case REQUEST_LEVEL_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL); size = 1; break; - case 42: - data16 = GetMonData(&gPlayerParty[a], MON_DATA_HP); - buffer[0] = data16; - buffer[1] = data16 >> 8; + case REQUEST_HP_BATTLE: + data16 = GetMonData(&gPlayerParty[monId], MON_DATA_HP); + dst[0] = data16; + dst[1] = data16 >> 8; size = 2; break; - case 43: - data16 = GetMonData(&gPlayerParty[a], MON_DATA_MAX_HP); - buffer[0] = data16; - buffer[1] = data16 >> 8; + case REQUEST_MAX_HP_BATTLE: + data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP); + dst[0] = data16; + dst[1] = data16 >> 8; size = 2; break; - case 44: - data16 = GetMonData(&gPlayerParty[a], MON_DATA_ATK); - buffer[0] = data16; - buffer[1] = data16 >> 8; + case REQUEST_ATK_BATTLE: + data16 = GetMonData(&gPlayerParty[monId], MON_DATA_ATK); + dst[0] = data16; + dst[1] = data16 >> 8; size = 2; break; - case 45: - data16 = GetMonData(&gPlayerParty[a], MON_DATA_DEF); - buffer[0] = data16; - buffer[1] = data16 >> 8; + case REQUEST_DEF_BATTLE: + data16 = GetMonData(&gPlayerParty[monId], MON_DATA_DEF); + dst[0] = data16; + dst[1] = data16 >> 8; size = 2; break; - case 46: - data16 = GetMonData(&gPlayerParty[a], MON_DATA_SPEED); - buffer[0] = data16; - buffer[1] = data16 >> 8; + case REQUEST_SPEED_BATTLE: + data16 = GetMonData(&gPlayerParty[monId], MON_DATA_SPEED); + dst[0] = data16; + dst[1] = data16 >> 8; size = 2; break; - case 47: - data16 = GetMonData(&gPlayerParty[a], MON_DATA_SPATK); - buffer[0] = data16; - buffer[1] = data16 >> 8; + case REQUEST_SPATK_BATTLE: + data16 = GetMonData(&gPlayerParty[monId], MON_DATA_SPATK); + dst[0] = data16; + dst[1] = data16 >> 8; size = 2; break; - case 48: - data16 = GetMonData(&gPlayerParty[a], MON_DATA_SPDEF); - buffer[0] = data16; - buffer[1] = data16 >> 8; + case REQUEST_SPDEF_BATTLE: + data16 = GetMonData(&gPlayerParty[monId], MON_DATA_SPDEF); + dst[0] = data16; + dst[1] = data16 >> 8; size = 2; break; - case 49: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_COOL); + case REQUEST_COOL_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_COOL); size = 1; break; - case 50: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_BEAUTY); + case REQUEST_BEAUTY_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY); size = 1; break; - case 51: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_CUTE); + case REQUEST_CUTE_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_CUTE); size = 1; break; - case 52: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SMART); + case REQUEST_SMART_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SMART); size = 1; break; - case 53: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_TOUGH); + case REQUEST_TOUGH_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_TOUGH); size = 1; break; - case 54: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SHEEN); + case REQUEST_SHEEN_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SHEEN); size = 1; break; - case 55: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_COOL_RIBBON); + case REQUEST_COOL_RIBBON_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON); size = 1; break; - case 56: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_BEAUTY_RIBBON); + case REQUEST_BEAUTY_RIBBON_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON); size = 1; break; - case 57: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_CUTE_RIBBON); + case REQUEST_CUTE_RIBBON_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON); size = 1; break; - case 58: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_SMART_RIBBON); + case REQUEST_SMART_RIBBON_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON); size = 1; break; - case 59: - buffer[0] = GetMonData(&gPlayerParty[a], MON_DATA_TOUGH_RIBBON); + case REQUEST_TOUGH_RIBBON_BATTLE: + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON); size = 1; break; } + return size; } -void WallyHandlecmd1(void) +static void WallyHandleGetRawMonData(void) { - PlayerHandlecmd1(); + PlayerHandleGetRawMonData(); } -void WallyHandleSetAttributes(void) +static void WallyHandleSetMonData(void) { - u8 r4; + u8 monToCheck; u8 i; if (gBattleBufferA[gActiveBattler][2] == 0) { - sub_8138294(gBattlerPartyIndexes[gActiveBattler]); + SetWallyMonData(gBattlerPartyIndexes[gActiveBattler]); } else { - r4 = gBattleBufferA[gActiveBattler][2]; - for (i = 0; i < 6; i++) + monToCheck = gBattleBufferA[gActiveBattler][2]; + for (i = 0; i < PARTY_SIZE; i++) { - if (r4 & 1) - sub_8138294(i); - r4 >>= 1; + if (monToCheck & 1) + SetWallyMonData(i); + monToCheck >>= 1; } } WallyBufferExecCompleted(); } -void sub_8138294(u8 a) +static void SetWallyMonData(u8 monId) { struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBattler][3]; struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBattler][3]; @@ -853,315 +853,320 @@ void sub_8138294(u8 a) switch (gBattleBufferA[gActiveBattler][1]) { - case 0: + case REQUEST_ALL_BATTLE: { u8 iv; - SetMonData(&gPlayerParty[a], MON_DATA_SPECIES, &battlePokemon->species); - SetMonData(&gPlayerParty[a], MON_DATA_HELD_ITEM, &battlePokemon->item); - for (i = 0; i < 4; i++) + SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &battlePokemon->species); + SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &battlePokemon->item); + for (i = 0; i < MAX_MON_MOVES; i++) { - SetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + i, &battlePokemon->moves[i]); - SetMonData(&gPlayerParty[a], MON_DATA_PP1 + i, &battlePokemon->pp[i]); + SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + i, &battlePokemon->moves[i]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + i, &battlePokemon->pp[i]); } - SetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES, &battlePokemon->ppBonuses); - SetMonData(&gPlayerParty[a], MON_DATA_FRIENDSHIP, &battlePokemon->friendship); - SetMonData(&gPlayerParty[a], MON_DATA_EXP, &battlePokemon->experience); + SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &battlePokemon->ppBonuses); + SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &battlePokemon->friendship); + SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &battlePokemon->experience); iv = battlePokemon->hpIV; - SetMonData(&gPlayerParty[a], MON_DATA_HP_IV, &iv); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &iv); iv = battlePokemon->attackIV; - SetMonData(&gPlayerParty[a], MON_DATA_ATK_IV, &iv); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &iv); iv = battlePokemon->defenseIV; - SetMonData(&gPlayerParty[a], MON_DATA_DEF_IV, &iv); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &iv); iv = battlePokemon->speedIV; - SetMonData(&gPlayerParty[a], MON_DATA_SPEED_IV, &iv); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &iv); iv = battlePokemon->spAttackIV; - SetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV, &iv); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &iv); iv = battlePokemon->spDefenseIV; - SetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV, &iv); - SetMonData(&gPlayerParty[a], MON_DATA_PERSONALITY, &battlePokemon->personality); - SetMonData(&gPlayerParty[a], MON_DATA_STATUS, &battlePokemon->status1); - SetMonData(&gPlayerParty[a], MON_DATA_LEVEL, &battlePokemon->level); - SetMonData(&gPlayerParty[a], MON_DATA_HP, &battlePokemon->hp); - SetMonData(&gPlayerParty[a], MON_DATA_MAX_HP, &battlePokemon->maxHP); - SetMonData(&gPlayerParty[a], MON_DATA_ATK, &battlePokemon->attack); - SetMonData(&gPlayerParty[a], MON_DATA_DEF, &battlePokemon->defense); - SetMonData(&gPlayerParty[a], MON_DATA_SPEED, &battlePokemon->speed); - SetMonData(&gPlayerParty[a], MON_DATA_SPATK, &battlePokemon->spAttack); - SetMonData(&gPlayerParty[a], MON_DATA_SPDEF, &battlePokemon->spDefense); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &iv); + SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &battlePokemon->personality); + SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &battlePokemon->status1); + SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &battlePokemon->level); + SetMonData(&gPlayerParty[monId], MON_DATA_HP, &battlePokemon->hp); + SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &battlePokemon->maxHP); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &battlePokemon->attack); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &battlePokemon->defense); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &battlePokemon->speed); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &battlePokemon->spAttack); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &battlePokemon->spDefense); } break; - case 1: - SetMonData(&gPlayerParty[a], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_SPECIES_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); break; - case 2: - SetMonData(&gPlayerParty[a], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_HELDITEM_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); break; - case 3: - for (i = 0; i < 4; i++) + case REQUEST_MOVES_PP_BATTLE: + for (i = 0; i < MAX_MON_MOVES; i++) { - SetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + i, &moveData->moves[i]); - SetMonData(&gPlayerParty[a], MON_DATA_PP1 + i, &moveData->pp[i]); + SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + i, &moveData->moves[i]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + i, &moveData->pp[i]); } - SetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES, &moveData->ppBonuses); + SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &moveData->ppBonuses); break; - case 4: - case 5: - case 6: - case 7: - SetMonData(&gPlayerParty[a], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - 4, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_MOVE1_BATTLE: + 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]); break; - case 8: - SetMonData(&gPlayerParty[a], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); - SetMonData(&gPlayerParty[a], MON_DATA_PP2, &gBattleBufferA[gActiveBattler][4]); - SetMonData(&gPlayerParty[a], MON_DATA_PP3, &gBattleBufferA[gActiveBattler][5]); - SetMonData(&gPlayerParty[a], MON_DATA_PP4, &gBattleBufferA[gActiveBattler][6]); - SetMonData(&gPlayerParty[a], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBattler][7]); + 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]); break; - case 9: - case 10: - case 11: - case 12: - SetMonData(&gPlayerParty[a], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - 9, &gBattleBufferA[gActiveBattler][3]); + 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]); break; - case 17: - SetMonData(&gPlayerParty[a], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_OTID_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]); break; - case 18: - SetMonData(&gPlayerParty[a], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_EXP_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]); break; - case 19: - SetMonData(&gPlayerParty[a], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_HP_EV_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]); break; - case 20: - SetMonData(&gPlayerParty[a], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_ATK_EV_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBattler][3]); break; - case 21: - SetMonData(&gPlayerParty[a], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_DEF_EV_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBattler][3]); break; - case 22: - SetMonData(&gPlayerParty[a], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_SPEED_EV_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBattler][3]); break; - case 23: - SetMonData(&gPlayerParty[a], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_SPATK_EV_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBattler][3]); break; - case 24: - SetMonData(&gPlayerParty[a], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_SPDEF_EV_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBattler][3]); break; - case 25: - SetMonData(&gPlayerParty[a], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_FRIENDSHIP_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBattler][3]); break; - case 26: - SetMonData(&gPlayerParty[a], MON_DATA_POKERUS, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_POKERUS_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBattler][3]); break; - case 27: - SetMonData(&gPlayerParty[a], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_MET_LOCATION_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBattler][3]); break; - case 28: - SetMonData(&gPlayerParty[a], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_MET_LEVEL_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; - case 29: - SetMonData(&gPlayerParty[a], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_MET_GAME_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBattler][3]); break; - case 30: - SetMonData(&gPlayerParty[a], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_POKEBALL_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBattler][3]); break; - case 31: - SetMonData(&gPlayerParty[a], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); - SetMonData(&gPlayerParty[a], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][4]); - SetMonData(&gPlayerParty[a], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][5]); - SetMonData(&gPlayerParty[a], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][6]); - SetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][7]); - SetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][8]); + 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]); break; - case 32: - SetMonData(&gPlayerParty[a], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_HP_IV_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); break; - case 33: - SetMonData(&gPlayerParty[a], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_ATK_IV_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][3]); break; - case 34: - SetMonData(&gPlayerParty[a], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_DEF_IV_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][3]); break; - case 35: - SetMonData(&gPlayerParty[a], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_SPEED_IV_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][3]); break; - case 36: - SetMonData(&gPlayerParty[a], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_SPATK_IV_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][3]); break; - case 37: - SetMonData(&gPlayerParty[a], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_SPDEF_IV_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); break; - case 38: - SetMonData(&gPlayerParty[a], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_PERSONALITY_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); break; - case 39: - SetMonData(&gPlayerParty[a], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_CHECKSUM_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); break; - case 40: - SetMonData(&gPlayerParty[a], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_STATUS_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); break; - case 41: - SetMonData(&gPlayerParty[a], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_LEVEL_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; - case 42: - SetMonData(&gPlayerParty[a], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_HP_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); break; - case 43: - SetMonData(&gPlayerParty[a], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_MAX_HP_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); break; - case 44: - SetMonData(&gPlayerParty[a], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_ATK_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); break; - case 45: - SetMonData(&gPlayerParty[a], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_DEF_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); break; - case 46: - SetMonData(&gPlayerParty[a], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_SPEED_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); break; - case 47: - SetMonData(&gPlayerParty[a], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_SPATK_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); break; - case 48: - SetMonData(&gPlayerParty[a], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_SPDEF_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); break; - case 49: - SetMonData(&gPlayerParty[a], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_COOL_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); break; - case 50: - SetMonData(&gPlayerParty[a], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_BEAUTY_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBattler][3]); break; - case 51: - SetMonData(&gPlayerParty[a], MON_DATA_CUTE, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_CUTE_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBattler][3]); break; - case 52: - SetMonData(&gPlayerParty[a], MON_DATA_SMART, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_SMART_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBattler][3]); break; - case 53: - SetMonData(&gPlayerParty[a], MON_DATA_TOUGH, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_TOUGH_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBattler][3]); break; - case 54: - SetMonData(&gPlayerParty[a], MON_DATA_SHEEN, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_SHEEN_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBattler][3]); break; - case 55: - SetMonData(&gPlayerParty[a], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_COOL_RIBBON_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; - case 56: - SetMonData(&gPlayerParty[a], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_BEAUTY_RIBBON_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; - case 57: - SetMonData(&gPlayerParty[a], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_CUTE_RIBBON_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; - case 58: - SetMonData(&gPlayerParty[a], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_SMART_RIBBON_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; - case 59: - SetMonData(&gPlayerParty[a], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBattler][3]); + case REQUEST_TOUGH_RIBBON_BATTLE: + SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; } + HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler); } -void WallyHandlecmd3(void) +static void WallyHandleSetRawMonData(void) { WallyBufferExecCompleted(); } -void WallyHandleLoadPokeSprite(void) +static void WallyHandleLoadMonSprite(void) { WallyBufferExecCompleted(); } -void WallyHandleSendOutPoke(void) +static void WallyHandleSwitchInAnim(void) { WallyBufferExecCompleted(); } -void WallyHandleReturnPokeToBall(void) +static void WallyHandleReturnMonToBall(void) { if (gBattleBufferA[gActiveBattler][1] == 0) { - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 1); - gBattlerControllerFuncs[gActiveBattler] = sub_813789C; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON); + gBattlerControllerFuncs[gActiveBattler] = DoSwitchOutAnimation; } else { FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]); - sub_8043DB0(gHealthboxSpriteIds[gActiveBattler]); + SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]); WallyBufferExecCompleted(); } } -void WallyHandleTrainerThrow(void) +#define sSpeedX data[0] + +static void WallyHandleDrawTrainerPic(void) { - LoadPlayerTrainerBankSprite(2, gActiveBattler); - GetMonSpriteTemplate_803C5A0(2, GetBattlerPosition(gActiveBattler)); - gBattlerSpriteIds[gActiveBattler] = CreateSprite( - &gCreatingSpriteTemplate, - 80, 80 + 4 * (8 - gTrainerBackPicCoords[2].coords), - 30); + DecompressTrainerBackPic(TRAINER_BACK_PIC_WALLY, gActiveBattler); + SetMultiuseSpriteTemplateToTrainerBack(TRAINER_BACK_PIC_WALLY, GetBattlerPosition(gActiveBattler)); + gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gCreatingSpriteTemplate, + 80, + 80 + 4 * (8 - gTrainerBackPicCoords[TRAINER_BACK_PIC_WALLY].coords), + 30); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; - gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = 240; - gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2; - gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_80313A0; - gBattlerControllerFuncs[gActiveBattler] = sub_813741C; + gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = DISPLAY_WIDTH; + gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2; + gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn; + gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy; } -void WallyHandleTrainerSlide(void) +static void WallyHandleTrainerSlide(void) { - LoadPlayerTrainerBankSprite(2, gActiveBattler); - GetMonSpriteTemplate_803C5A0(2, GetBattlerPosition(gActiveBattler)); - gBattlerSpriteIds[gActiveBattler] = CreateSprite( - &gCreatingSpriteTemplate, - 80, 80 + 4 * (8 - gTrainerBackPicCoords[2].coords), - 30); + DecompressTrainerBackPic(TRAINER_BACK_PIC_WALLY, gActiveBattler); + SetMultiuseSpriteTemplateToTrainerBack(TRAINER_BACK_PIC_WALLY, GetBattlerPosition(gActiveBattler)); + gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gCreatingSpriteTemplate, + 80, + 80 + 4 * (8 - gTrainerBackPicCoords[TRAINER_BACK_PIC_WALLY].coords), + 30); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = -96; - gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 2; - gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_80313A0; + gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 2; + gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2; } -void WallyHandleTrainerSlideBack(void) +#undef sSpeedX + +static void WallyHandleTrainerSlideBack(void) { WallyBufferExecCompleted(); } -void WallyHandleFaintAnimation(void) +static void WallyHandleFaintAnimation(void) { WallyBufferExecCompleted(); } -void WallyHandlePaletteFade(void) +static void WallyHandlePaletteFade(void) { WallyBufferExecCompleted(); } -void WallyHandleSuccessBallThrowAnim(void) +static void WallyHandleSuccessBallThrowAnim(void) { - ewram17840.unk8 = 4; + ewram17840.unk8 = BALL_3_SHAKES_SUCCESS; gDoingBattleAnim = TRUE; - move_anim_start_t4(gActiveBattler, gActiveBattler, GetBattlerAtPosition(1), 4); + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW_WITH_TRAINER); gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedAnimation; } -void WallyHandleBallThrowAnim(void) +static void WallyHandleBallThrowAnim(void) { u8 ballThrowCaseId = gBattleBufferA[gActiveBattler][1]; ewram17840.unk8 = ballThrowCaseId; gDoingBattleAnim = TRUE; - move_anim_start_t4(gActiveBattler, gActiveBattler, GetBattlerAtPosition(1), 4); + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW_WITH_TRAINER); gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedAnimation; } -void WallyHandlePuase(void) +static void WallyHandlePause(void) { WallyBufferExecCompleted(); } -void WallyHandleMoveAnimation(void) +static void WallyHandleMoveAnimation(void) { u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); @@ -1179,74 +1184,76 @@ void WallyHandleMoveAnimation(void) } else { - ewram17810[gActiveBattler].unk4 = 0; - gBattlerControllerFuncs[gActiveBattler] = sub_81390D0; + gBattleHealthBoxInfo[gActiveBattler].animationState = 0; + gBattlerControllerFuncs[gActiveBattler] = WallyDoMoveAnimation; } } -void sub_81390D0(void) +static void WallyDoMoveAnimation(void) { - u16 r4 = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); + u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); - switch (ewram17810[gActiveBattler].unk4) + switch (gBattleHealthBoxInfo[gActiveBattler].animationState) { case 0: - if (gBattleSpriteInfo[gActiveBattler].substituteSprite == 1) - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 5); - ewram17810[gActiveBattler].unk4 = 1; + if (gBattleSpriteInfo[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 5); + gBattleHealthBoxInfo[gActiveBattler].animationState = 1; break; case 1: - if (ewram17810[gActiveBattler].unk0_6) - break; - sub_80326EC(0); - DoMoveAnim(r4); - ewram17810[gActiveBattler].unk4 = 2; + if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) + { + SetBattlerSpriteAffineMode(ST_OAM_AFFINE_OFF); + DoMoveAnim(move); + gBattleHealthBoxInfo[gActiveBattler].animationState = 2; + } break; case 2: gAnimScriptCallback(); if (!gAnimScriptActive) { - sub_80326EC(1); - if (gBattleSpriteInfo[gActiveBattler].substituteSprite == 1) - move_anim_start_t4(gActiveBattler, gActiveBattler, gActiveBattler, 6); - ewram17810[gActiveBattler].unk4 = 3; + SetBattlerSpriteAffineMode(ST_OAM_AFFINE_NORMAL); + if (gBattleSpriteInfo[gActiveBattler].behindSubstitute == 1) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, 6); + gBattleHealthBoxInfo[gActiveBattler].animationState = 3; } break; case 3: - if (ewram17810[gActiveBattler].unk0_6) - break; - sub_8031F24(); - r4 = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); - sub_80324BC(gActiveBattler, r4); - ewram17810[gActiveBattler].unk4 = 0; - WallyBufferExecCompleted(); + if (!gBattleHealthBoxInfo[gActiveBattler].specialAnimActive) + { + CopyAllBattleSpritesInvisibilities(); + move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); + TrySetBehindSubstituteSpriteBit(gActiveBattler, move); + gBattleHealthBoxInfo[gActiveBattler].animationState = 0; + WallyBufferExecCompleted(); + } break; } } -void WallyHandlePrintString(void) +static void WallyHandlePrintString(void) { - u16 *ptr; + u16 *stringId; gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - ptr = (u16 *)&gBattleBufferA[gActiveBattler][2]; - if (*ptr == 2) + stringId = (u16 *)&gBattleBufferA[gActiveBattler][2]; + if (*stringId == 2) DestroyMenuCursor(); - BufferStringBattle(*ptr); + BufferStringBattle(*stringId); Contest_StartTextPrinter(&gWindowTemplate_Contest_MoveDescription, gDisplayedStringBattle, 0x90, 2, 15); - gBattlerControllerFuncs[gActiveBattler] = sub_8137454; + gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; } -void WallyHandlePrintStringPlayerOnly(void) +static void WallyHandlePrintSelectionString(void) { - if (GetBattlerSide(gActiveBattler) == 0) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) WallyHandlePrintString(); else WallyBufferExecCompleted(); } -void WallyHandlecmd18(void) +static void WallyHandleChooseAction(void) { s32 i; @@ -1255,7 +1262,7 @@ void WallyHandlecmd18(void) gWindowTemplate_Contest_MoveDescription.paletteNum = 0; Text_FillWindowRectDefPalette(&gWindowTemplate_Contest_MoveDescription, 10, 2, 15, 27, 18); Text_FillWindowRectDefPalette(&gWindowTemplate_Contest_MoveDescription, 10, 2, 35, 16, 36); - gBattlerControllerFuncs[gActiveBattler] = sub_81372BC; + gBattlerControllerFuncs[gActiveBattler] = WallyHandleActions; Text_InitWindow(&gWindowTemplate_Contest_MoveDescription, BattleText_MenuOptions, 400, 18, 35); Text_PrintWindow8002F44(&gWindowTemplate_Contest_MoveDescription); MenuCursor_Create814A5C0(0, 0xFFFF, 12, 0x2D9F, 0); @@ -1271,154 +1278,155 @@ void WallyHandlecmd18(void) Text_PrintWindow8002F44(&gWindowTemplate_Contest_MoveDescription); } -void WallyHandlecmd19(void) +static void WallyHandleYesNoBox(void) { WallyBufferExecCompleted(); } -void WallyHandlecmd20(void) +static void WallyHandleChooseMove(void) { - switch (gBattleStruct->unk160A9) + switch (gBattleStruct->wallyMovesState) { case 0: sub_80304A8(); - gBattleStruct->unk160A9++; - gBattleStruct->unk160AB = 80; + gBattleStruct->wallyMovesState++; + gBattleStruct->wallyMoveFrames = 80; // fall through case 1: - gBattleStruct->unk160AB--; - if (gBattleStruct->unk160AB == 0) + if (--gBattleStruct->wallyMoveFrames == 0) { DestroyMenuCursor(); PlaySE(SE_SELECT); - BtlController_EmitTwoReturnValues(1, 10, 256); + BtlController_EmitTwoReturnValues(B_COMM_TO_ENGINE, 10, 0x100); WallyBufferExecCompleted(); } break; } } -void WallyHandleOpenBag(void) +static void WallyHandleChooseItem(void) { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); - gBattlerControllerFuncs[gActiveBattler] = sub_81374C4; - gBankInMenu = gActiveBattler; + BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK); + gBattlerControllerFuncs[gActiveBattler] = OpenBagAfterPaletteFade; + gBattlerInMenuId = gActiveBattler; } -void WallyHandlecmd22(void) +static void WallyHandleChoosePokemon(void) { WallyBufferExecCompleted(); } -void WallyHandlecmd23(void) +static void WallyHandleCmd23(void) { WallyBufferExecCompleted(); } -void WallyHandleHealthBarUpdate(void) +static void WallyHandleHealthBarUpdate(void) { - s16 r7; + s16 hpVal; - load_gfxc_health_bar(0); - r7 = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); - if (r7 != 0x7FFF) + LoadBattleBarGfx(0); + hpVal = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); + + if (hpVal != INSTANT_HP_BAR_DROP) { u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP); u32 curHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP); - sub_8043D84(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, r7); + SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, hpVal); } else { u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP); - sub_8043D84(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, r7); - sub_80440EC(gHealthboxSpriteIds[gActiveBattler], 0, 0); + SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, hpVal); + UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], 0, HP_CURRENT); } - gBattlerControllerFuncs[gActiveBattler] = sub_81377B0; + + gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthbarDone; } -void WallyHandleExpBarUpdate(void) +static void WallyHandleExpUpdate(void) { WallyBufferExecCompleted(); } -void WallyHandleStatusIconUpdate(void) +static void WallyHandleStatusIconUpdate(void) { WallyBufferExecCompleted(); } -void WallyHandleStatusAnimation(void) +static void WallyHandleStatusAnimation(void) { WallyBufferExecCompleted(); } -void WallyHandleStatusXor(void) +static void WallyHandleStatusXor(void) { WallyBufferExecCompleted(); } -void WallyHandlecmd29(void) +static void WallyHandleDataTransfer(void) { WallyBufferExecCompleted(); } -void WallyHandleDMATransfer(void) +static void WallyHandleDMA3Transfer(void) { WallyBufferExecCompleted(); } -void WallyHandlecmd31(void) +static void WallyHandlePlayBGM(void) { WallyBufferExecCompleted(); } -void WallyHandlecmd32(void) +static void WallyHandleCmd32(void) { WallyBufferExecCompleted(); } -void WallyHandlecmd33(void) +static void WallyHandleTwoReturnValues(void) { WallyBufferExecCompleted(); } -void WallyHandlecmd34(void) +static void WallyHandleChosenMonReturnValue(void) { WallyBufferExecCompleted(); } -void WallyHandlecmd35(void) +static void WallyHandleOneReturnValue(void) { WallyBufferExecCompleted(); } -void WallyHandlecmd36(void) +static void WallyHandleOneReturnValue_Duplicate(void) { WallyBufferExecCompleted(); } -void WallyHandlecmd37(void) +static void WallyHandleClearUnkVar(void) { WallyBufferExecCompleted(); } -void WallyHandlecmd38(void) +static void WallyHandleSetUnkVar(void) { WallyBufferExecCompleted(); } -void WallyHandlecmd39(void) +static void WallyHandleClearUnkFlag(void) { WallyBufferExecCompleted(); } -void WallyHandlecmd40(void) +static void WallyHandleToggleUnkFlag(void) { WallyBufferExecCompleted(); } -void WallyHandleHitAnimation(void) +static void WallyHandleHitAnimation(void) { if (gSprites[gBattlerSpriteIds[gActiveBattler]].invisible == TRUE) { @@ -1426,92 +1434,104 @@ void WallyHandleHitAnimation(void) } else { - gDoingBattleAnim = 1; + gDoingBattleAnim = TRUE; gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0; - sub_8047858(gActiveBattler); - gBattlerControllerFuncs[gActiveBattler] = bx_blink_t5; + DoHitAnimHealthboxEffect(gActiveBattler); + gBattlerControllerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect; } } -void WallyHandlecmd42(void) +static void WallyHandleCantSwitch(void) { WallyBufferExecCompleted(); } -void WallyHandleEffectivenessSound(void) +static void WallyHandlePlaySE(void) { PlaySE(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); WallyBufferExecCompleted(); } -void WallyHandlecmd44(void) +static void WallyHandlePlayFanfareOrBGM(void) { PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); WallyBufferExecCompleted(); } -void WallyHandleFaintingCry(void) +static void WallyHandleFaintingCry(void) { - PlayCry1(GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES), 25); + u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES); + + // Seems that it doesn't bother using CRY_MODE_FAINT because + // Wally's Pokémon during the tutorial is never intended to faint. + PlayCry_Normal(species, 25); WallyBufferExecCompleted(); } -void WallyHandleIntroSlide(void) +static void WallyHandleIntroSlide(void) { - StartBattleIntroAnim(gBattleBufferA[gActiveBattler][1]); + HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); gIntroSlideFlags |= 1; WallyBufferExecCompleted(); } -void WallyHandleTrainerBallThrow(void) +static void WallyHandleIntroTrainerBallThrow(void) { u8 paletteNum; u8 taskId; - oamt_add_pos2_onto_pos1(&gSprites[gBattlerSpriteIds[gActiveBattler]]); + SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]); + gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 50; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].y; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation; gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gActiveBattler; - StoreSpriteCallbackInData(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_8030E38); + + StoreSpriteCallbackInData(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCB_FreePlayerSpriteLoadMonSprite); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1); + paletteNum = AllocSpritePalette(0xD6F8); - LoadCompressedPalette(gTrainerBackPicPaletteTable[2].data, 0x100 + paletteNum * 16, 32); + LoadCompressedPalette(gTrainerBackPicPaletteTable[TRAINER_BACK_PIC_WALLY].data, OBJ_PLTT_ID(paletteNum), PLTT_SIZE_4BPP); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum; - taskId = CreateTask(sub_8139A2C, 5); + + taskId = CreateTask(Task_StartSendOutAnim, 5); gTasks[taskId].data[0] = gActiveBattler; - if (ewram17810[gActiveBattler].unk0_0) - gTasks[gUnknown_02024E68[gActiveBattler]].func = sub_8044CA0; - ewram17810[4].unk9 |= 1; - gBattlerControllerFuncs[gActiveBattler] = nullsub_91; + + if (gBattleHealthBoxInfo[gActiveBattler].partyStatusSummaryShown) + gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = sub_8044CA0; + + gBattleHealthBoxInfo[4].unk9 |= 1; + gBattlerControllerFuncs[gActiveBattler] = BattleControllerDummy; } -void sub_81398BC(u8 bank) +static void StartSendOutAnim(u8 battler) { u16 species; - gBattleSpriteInfo[bank].transformedSpecies = 0; - gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1]; - species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES); - gUnknown_0300434C[bank] = CreateInvisibleSpriteWithCallback(sub_80312F0); - GetMonSpriteTemplate_803C56C(species, GetBattlerPosition(bank)); - gBattlerSpriteIds[bank] = CreateSprite( - &gCreatingSpriteTemplate, - GetBattlerSpriteCoord(bank, 2), - sub_8077F68(bank), - GetBattlerSubpriority(bank)); - gSprites[gUnknown_0300434C[bank]].data[1] = gBattlerSpriteIds[bank]; - gSprites[gBattlerSpriteIds[bank]].data[0] = bank; - gSprites[gBattlerSpriteIds[bank]].data[2] = species; - gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank; - StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]); - gSprites[gBattlerSpriteIds[bank]].invisible = TRUE; - gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy; - gSprites[gUnknown_0300434C[bank]].data[0] = StartSendOutMonAnimation(0, 0xFF); + gBattleSpriteInfo[battler].transformSpecies = 0; + gBattlerPartyIndexes[battler] = gBattleBufferA[battler][1]; + species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES); + gBattleControllerData[battler] = CreateInvisibleSpriteWithCallback(SpriteCB_WaitForBattlerBallReleaseAnim); + SetMultiuseSpriteTemplateToPokemon(species, GetBattlerPosition(battler)); + gBattlerSpriteIds[battler] = CreateSprite(&gCreatingSpriteTemplate, + GetBattlerSpriteCoord(battler, BATTLER_COORD_X_2), + GetBattlerSpriteDefault_Y(battler), + GetBattlerSpriteSubpriority(battler)); + + gSprites[gBattleControllerData[battler]].data[1] = gBattlerSpriteIds[battler]; + + gSprites[gBattlerSpriteIds[battler]].data[0] = battler; + gSprites[gBattlerSpriteIds[battler]].data[2] = species; + gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler; + + StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], gBattleMonForms[battler]); + gSprites[gBattlerSpriteIds[battler]].invisible = TRUE; + gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy; + gSprites[gBattleControllerData[battler]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT); } -void sub_8139A2C(u8 taskId) +static void Task_StartSendOutAnim(u8 taskId) { if (gTasks[taskId].data[1] < 31) { @@ -1523,73 +1543,74 @@ void sub_8139A2C(u8 taskId) gActiveBattler = gTasks[taskId].data[0]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; - sub_81398BC(gActiveBattler); - gBattlerControllerFuncs[gActiveBattler] = sub_8137538; + StartSendOutAnim(gActiveBattler); + gBattlerControllerFuncs[gActiveBattler] = Intro_TryShinyAnimShowHealthbox; gActiveBattler = savedActiveBank; DestroyTask(taskId); } } -void WallyHandlecmd48(void) +static void WallyHandleDrawPartyStatusSummary(void) { - if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == 0) + if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { WallyBufferExecCompleted(); } else { - ewram17810[gActiveBattler].unk0_0 = 1; - gUnknown_02024E68[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); + gBattleHealthBoxInfo[gActiveBattler].partyStatusSummaryShown = 1; + gBattlerStatusSummaryTaskId[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); WallyBufferExecCompleted(); } } -void WallyHandlecmd49(void) +static void WallyHandleHidePartyStatusSummary(void) { WallyBufferExecCompleted(); } -void WallyHandlecmd50(void) +static void WallyHandleEndBounceEffect(void) { WallyBufferExecCompleted(); } -void WallyHandleSpriteInvisibility(void) +static void WallyHandleSpriteInvisibility(void) { WallyBufferExecCompleted(); } -void WallyHandleBattleAnimation(void) +static void WallyHandleBattleAnimation(void) { - u8 val2 = gBattleBufferA[gActiveBattler][1]; - u16 val = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); + u8 animationId = gBattleBufferA[gActiveBattler][1]; + u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); - if (move_anim_start_t3(gActiveBattler, gActiveBattler, gActiveBattler, val2, val)) + if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) WallyBufferExecCompleted(); else - gBattlerControllerFuncs[gActiveBattler] = sub_8137940; + gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation; } -void WallyHandleLinkStandbyMsg(void) +static void WallyHandleLinkStandbyMsg(void) { WallyBufferExecCompleted(); } -void WallyHandleResetActionMoveSelection(void) +static void WallyHandleResetActionMoveSelection(void) { WallyBufferExecCompleted(); } -void WallyHandlecmd55(void) +static void WallyHandleEndLinkBattle(void) { gBattleOutcome = gBattleBufferA[gActiveBattler][1]; FadeOutMapMusic(5); BeginFastPaletteFade(3); WallyBufferExecCompleted(); + if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && !(gBattleTypeFlags & BATTLE_TYPE_WILD)) - gBattlerControllerFuncs[gActiveBattler] = sub_813746C; + gBattlerControllerFuncs[gActiveBattler] = WallySetBattleEndCallbacks; } -void WallyHandlecmd56(void) +static void WallyCmdEnd(void) { } diff --git a/src/battle_controllers.c b/src/battle_controllers.c index 1187218c4..77e4ed2c0 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -87,7 +87,7 @@ void SetUpBattleVarsAndBirchPoochyena(void) for (i = 0; i < MAX_BATTLERS_COUNT; i++) { - gBattlerControllerFuncs[i] = nullsub_91; + gBattlerControllerFuncs[i] = BattleControllerDummy; gBattlerPositions[i] = 0xFF; gActionSelectionCursor[i] = 0; gMoveSelectionCursor[i] = 0; @@ -145,7 +145,7 @@ static void InitSinglePlayerBtlControllers(void) if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) gBattlerControllerFuncs[0] = SetBankFuncToSafariBufferRunCommand; else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL) - gBattlerControllerFuncs[0] = SetBankFuncToWallyBufferRunCommand; + gBattlerControllerFuncs[0] = SetControllerToWally; else gBattlerControllerFuncs[0] = SetBankFuncToPlayerBufferRunCommand; gBattlerPositions[0] = 0; diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index d81752f5a..b517f077c 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -35,7 +35,7 @@ extern u32 gTransformedPersonalities[]; extern struct Window gWindowTemplate_Contest_MoveDescription; extern void (*gBattlerControllerFuncs[])(void); extern u8 gHealthboxSpriteIds[]; -extern u8 gUnknown_0300434C[]; +extern u8 gBattleControllerData[]; extern struct MusicPlayerInfo gMPlayInfo_SE1; extern struct MusicPlayerInfo gMPlayInfo_SE2; extern struct MusicPlayerInfo gMPlayInfo_BGM; @@ -93,10 +93,9 @@ const struct SpritePalette gUnknown_0820A4D4[] = { gUnknown_08D1214C, 0xD704 }, }; -extern void c3_0802FDF4(u8); -extern void sub_804777C(); +extern void Task_PlayerController_RestoreBgmAfterCry(u8); extern u8 IsBankSpritePresent(u8); -extern u8 sub_8077F68(u8); +extern u8 GetBattlerSpriteDefault_Y(u8); extern u8 sub_8077F7C(u8); extern void sub_8094958(void); extern void sub_80105DC(struct Sprite *); @@ -112,7 +111,7 @@ void sub_80327CC(void); void sub_8032978(struct Sprite *); void sub_80328A4(struct Sprite *); -void sub_80312F0(struct Sprite *sprite) +void SpriteCB_WaitForBattlerBallReleaseAnim(struct Sprite *sprite) { u8 spriteId = sprite->data[1]; @@ -140,7 +139,7 @@ void unref_sub_8031364(struct Sprite *sprite, bool8 stupid) AnimateSprite(sprite); } -void sub_80313A0(struct Sprite *sprite) +void SpriteCB_TrainerSlideIn(struct Sprite *sprite) { if (!(gIntroSlideFlags & 1)) { @@ -152,7 +151,7 @@ void sub_80313A0(struct Sprite *sprite) void move_anim_start_t2_for_situation(u8 a, u32 b) { - ewram17810[gActiveBattler].unk0_4 = 1; + gBattleHealthBoxInfo[gActiveBattler].statusAnimActive = 1; if (a == 0) { if (b == 0x20) @@ -166,7 +165,7 @@ void move_anim_start_t2_for_situation(u8 a, u32 b) else if (b == 0x40) move_anim_start_t2(gActiveBattler, 5); else - ewram17810[gActiveBattler].unk0_4 = 0; + gBattleHealthBoxInfo[gActiveBattler].statusAnimActive = 0; } else { @@ -181,11 +180,11 @@ void move_anim_start_t2_for_situation(u8 a, u32 b) else if (b & 0x0000E000) move_anim_start_t2(gActiveBattler, 9); else - ewram17810[gActiveBattler].unk0_4 = 0; + gBattleHealthBoxInfo[gActiveBattler].statusAnimActive = 0; } } -bool8 move_anim_start_t3(u8 a, u8 b, u8 c, u8 d, u16 e) +bool8 TryHandleLaunchBattleTableAnimation(u8 a, u8 b, u8 c, u8 d, u16 e) { u8 taskId; @@ -194,9 +193,9 @@ bool8 move_anim_start_t3(u8 a, u8 b, u8 c, u8 d, u16 e) gBattleMonForms[a] = e & 0x7F; return TRUE; } - if (gBattleSpriteInfo[a].substituteSprite && sub_803163C(d) == 0) + if (gBattleSpriteInfo[a].behindSubstitute && sub_803163C(d) == 0) return TRUE; - if (gBattleSpriteInfo[a].substituteSprite && d == 2 && gSprites[gBattlerSpriteIds[a]].invisible) + if (gBattleSpriteInfo[a].behindSubstitute && d == 2 && gSprites[gBattlerSpriteIds[a]].invisible) { refresh_graphics_maybe(a, 1, gBattlerSpriteIds[a]); sub_80324E0(a); @@ -208,7 +207,7 @@ bool8 move_anim_start_t3(u8 a, u8 b, u8 c, u8 d, u16 e) LaunchBattleAnimation(gBattleAnims_General, d, 0); taskId = CreateTask(sub_80315E8, 10); gTasks[taskId].data[0] = a; - ewram17810[gTasks[taskId].data[0]].unk0_5 = 1; + gBattleHealthBoxInfo[gTasks[taskId].data[0]].animFromTableActive = 1; return FALSE; } @@ -217,7 +216,7 @@ void sub_80315E8(u8 taskId) gAnimScriptCallback(); if (!gAnimScriptActive) { - ewram17810[gTasks[taskId].data[0]].unk0_5 = 0; + gBattleHealthBoxInfo[gTasks[taskId].data[0]].animFromTableActive = 0; DestroyTask(taskId); } } @@ -238,7 +237,7 @@ u8 sub_803163C(u8 a) } } -void move_anim_start_t4(u8 a, u8 b, u8 c, u8 d) +void InitAndLaunchSpecialAnimation(u8 a, u8 b, u8 c, u8 d) { u8 taskId; @@ -247,7 +246,7 @@ void move_anim_start_t4(u8 a, u8 b, u8 c, u8 d) LaunchBattleAnimation(gBattleAnims_Special, d, 0); taskId = CreateTask(sub_80316CC, 10); gTasks[taskId].data[0] = a; - ewram17810[gTasks[taskId].data[0]].unk0_6 = 1; + gBattleHealthBoxInfo[gTasks[taskId].data[0]].specialAnimActive = 1; } void sub_80316CC(u8 taskId) @@ -255,7 +254,7 @@ void sub_80316CC(u8 taskId) gAnimScriptCallback(); if (!gAnimScriptActive) { - ewram17810[gTasks[taskId].data[0]].unk0_6 = 0; + gBattleHealthBoxInfo[gTasks[taskId].data[0]].specialAnimActive = 0; DestroyTask(taskId); } } @@ -271,15 +270,15 @@ bool8 mplay_80342A4(u8 a) if (IsSEPlaying()) { - ewram17810[a].unk8++; - if (ewram17810[gActiveBattler].unk8 < 30) + gBattleHealthBoxInfo[a].unk8++; + if (gBattleHealthBoxInfo[gActiveBattler].unk8 < 30) return TRUE; m4aMPlayStop(&gMPlayInfo_SE1); m4aMPlayStop(&gMPlayInfo_SE2); } if (zero == 0) { - ewram17810[a].unk8 = 0; + gBattleHealthBoxInfo[a].unk8 = 0; return FALSE; } return TRUE; @@ -296,14 +295,14 @@ void BattleLoadOpponentMonSprite(struct Pokemon *pkmn, u8 b) const u8 *lzPaletteData; personalityValue = GetMonData(pkmn, MON_DATA_PERSONALITY); - if (gBattleSpriteInfo[b].transformedSpecies == 0) + if (gBattleSpriteInfo[b].transformSpecies == 0) { species = GetMonData(pkmn, MON_DATA_SPECIES); r7 = personalityValue; } else { - species = gBattleSpriteInfo[b].transformedSpecies; + species = gBattleSpriteInfo[b].transformSpecies; r7 = gTransformedPersonalities[b]; } otId = GetMonData(pkmn, MON_DATA_OT_ID); @@ -317,7 +316,7 @@ void BattleLoadOpponentMonSprite(struct Pokemon *pkmn, u8 b) species, r7); paletteOffset = 0x100 + b * 16; - if (gBattleSpriteInfo[b].transformedSpecies == 0) + if (gBattleSpriteInfo[b].transformSpecies == 0) lzPaletteData = GetMonSpritePal(pkmn); else lzPaletteData = GetMonSpritePalFromOtIdPersonality(species, otId, personalityValue); @@ -330,7 +329,7 @@ void BattleLoadOpponentMonSprite(struct Pokemon *pkmn, u8 b) LZDecompressWram(lzPaletteData, ewram16400); LoadPalette(ewram16400 + gBattleMonForms[b] * 32, paletteOffset, 0x20); } - if (gBattleSpriteInfo[b].transformedSpecies != 0) + if (gBattleSpriteInfo[b].transformSpecies != 0) { BlendPalette(paletteOffset, 16, 6, RGB(31, 31, 31)); CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32); @@ -348,14 +347,14 @@ void BattleLoadPlayerMonSprite(struct Pokemon *pkmn, u8 b) const u8 *lzPaletteData; personalityValue = GetMonData(pkmn, MON_DATA_PERSONALITY); - if (gBattleSpriteInfo[b].transformedSpecies == 0) + if (gBattleSpriteInfo[b].transformSpecies == 0) { species = GetMonData(pkmn, MON_DATA_SPECIES); r7 = personalityValue; } else { - species = gBattleSpriteInfo[b].transformedSpecies; + species = gBattleSpriteInfo[b].transformSpecies; r7 = gTransformedPersonalities[b]; } otId = GetMonData(pkmn, MON_DATA_OT_ID); @@ -369,7 +368,7 @@ void BattleLoadPlayerMonSprite(struct Pokemon *pkmn, u8 b) species, r7); paletteOffset = 0x100 + b * 16; - if (gBattleSpriteInfo[b].transformedSpecies == 0) + if (gBattleSpriteInfo[b].transformSpecies == 0) lzPaletteData = GetMonSpritePal(pkmn); else lzPaletteData = GetMonSpritePalFromOtIdPersonality(species, otId, personalityValue); @@ -382,7 +381,7 @@ void BattleLoadPlayerMonSprite(struct Pokemon *pkmn, u8 b) LZDecompressWram(lzPaletteData, ewram16400); LoadPalette(ewram16400 + gBattleMonForms[b] * 32, paletteOffset, 0x20); } - if (gBattleSpriteInfo[b].transformedSpecies != 0) + if (gBattleSpriteInfo[b].transformSpecies != 0) { BlendPalette(paletteOffset, 16, 6, RGB(31, 31, 31)); CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32); @@ -417,7 +416,7 @@ void sub_8031A6C(u16 a, u8 b) LoadCompressedObjectPalette(&gTrainerFrontPicPaletteTable[a]); } -void LoadPlayerTrainerBankSprite(u16 a, u8 b) +void DecompressTrainerBackPic(u16 a, u8 b) { u8 status; @@ -521,7 +520,7 @@ bool8 sub_8031C30(u8 a) return retVal; } -void load_gfxc_health_bar(u8 a) +void LoadBattleBarGfx(u8 a) { LZDecompressWram(gUnknown_08D09C48, eBattleInterfaceGfxBuffer); } @@ -579,13 +578,13 @@ u8 battle_load_something(u8 *pState, u8 *b) if (GetBattlerSide(*b) == 0) { if (!(gBattleTypeFlags & 0x80)) - sub_8045A5C(gHealthboxSpriteIds[*b], &gPlayerParty[gBattlerPartyIndexes[*b]], 0); + UpdateHealthboxAttribute(gHealthboxSpriteIds[*b], &gPlayerParty[gBattlerPartyIndexes[*b]], 0); } else { - sub_8045A5C(gHealthboxSpriteIds[*b], &gEnemyParty[gBattlerPartyIndexes[*b]], 0); + UpdateHealthboxAttribute(gHealthboxSpriteIds[*b], &gEnemyParty[gBattlerPartyIndexes[*b]], 0); } - sub_8043DB0(gHealthboxSpriteIds[*b]); + SetHealthboxSpriteInvisible(gHealthboxSpriteIds[*b]); (*b)++; if (*b == gBattlersCount) { @@ -604,7 +603,7 @@ u8 battle_load_something(u8 *pState, u8 *b) void sub_8031EE8(void) { - memset(ewram17810, 0, 0x30); + memset(gBattleHealthBoxInfo, 0, 0x30); memset(&ewram17840, 0, 0x10); } @@ -614,7 +613,7 @@ void sub_8031F0C(void) memset(gBattleSpriteInfo, 0, 0x10); } -void sub_8031F24(void) +void CopyAllBattleSpritesInvisibilities(void) { s32 i; @@ -642,12 +641,12 @@ void sub_8031FC4(u8 a, u8 b, bool8 c) paletteOffset = 0x100 + a * 16; LoadPalette(ewram16400 + ewram17840.unk0 * 32, paletteOffset, 32); gBattleMonForms[a] = ewram17840.unk0; - if (gBattleSpriteInfo[a].transformedSpecies != 0) + if (gBattleSpriteInfo[a].transformSpecies != 0) { BlendPalette(paletteOffset, 16, 6, RGB(31, 31, 31)); CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32); } - gSprites[gBattlerSpriteIds[a]].y = sub_8077F68(a); + gSprites[gBattlerSpriteIds[a]].y = GetBattlerSpriteDefault_Y(a); } else { @@ -716,10 +715,10 @@ void sub_8031FC4(u8 a, u8 b, bool8 c) CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32); if (!IsContest()) { - gBattleSpriteInfo[a].transformedSpecies = species; + gBattleSpriteInfo[a].transformSpecies = species; gBattleMonForms[a] = gBattleMonForms[b]; } - gSprites[gBattlerSpriteIds[a]].y = sub_8077F68(a); + gSprites[gBattlerSpriteIds[a]].y = GetBattlerSpriteDefault_Y(a); StartSpriteAnim(&gSprites[gBattlerSpriteIds[a]], gBattleMonForms[a]); } } @@ -771,18 +770,18 @@ void refresh_graphics_maybe(u8 a, u8 b, u8 spriteId) if (b == 0) gSprites[spriteId].y = sub_8077F7C(a); else - gSprites[spriteId].y = sub_8077F68(a); + gSprites[spriteId].y = GetBattlerSpriteDefault_Y(a); } -void sub_80324BC(u8 a, u16 b) +void TrySetBehindSubstituteSpriteBit(u8 a, u16 b) { if (b == 0xA4) - gBattleSpriteInfo[a].substituteSprite = 1; + gBattleSpriteInfo[a].behindSubstitute = 1; } void sub_80324E0(u8 a) { - gBattleSpriteInfo[a].substituteSprite = 0; + gBattleSpriteInfo[a].behindSubstitute = 0; } void HandleLowHpMusicChange(struct Pokemon *pkmn, u8 b) @@ -852,7 +851,7 @@ void sub_8032638(void) } } -void sub_80326EC(u8 a) +void SetBattlerSpriteAffineMode(u8 a) { s32 i; @@ -863,12 +862,12 @@ void sub_80326EC(u8 a) gSprites[gBattlerSpriteIds[i]].oam.affineMode = a; if (a == 0) { - ewram17810[i].unk6 = gSprites[gBattlerSpriteIds[i]].oam.matrixNum; + gBattleHealthBoxInfo[i].unk6 = gSprites[gBattlerSpriteIds[i]].oam.matrixNum; gSprites[gBattlerSpriteIds[i]].oam.matrixNum = 0; } else { - gSprites[gBattlerSpriteIds[i]].oam.matrixNum = ewram17810[i].unk6; + gSprites[gBattlerSpriteIds[i]].oam.matrixNum = gBattleHealthBoxInfo[i].unk6; } } } @@ -880,13 +879,13 @@ void sub_80327CC(void) LoadCompressedObjectPic(&gUnknown_081FAF24); r5 = GetBattlerAtPosition(1); - ewram17810[r5].unk7 = CreateSprite(&gSpriteTemplate_81FAF34, GetBattlerSpriteCoord(r5, 0), GetBattlerSpriteCoord(r5, 1) + 32, 0xC8); - gSprites[ewram17810[r5].unk7].data[0] = r5; + gBattleHealthBoxInfo[r5].unk7 = CreateSprite(&gSpriteTemplate_81FAF34, GetBattlerSpriteCoord(r5, 0), GetBattlerSpriteCoord(r5, 1) + 32, 0xC8); + gSprites[gBattleHealthBoxInfo[r5].unk7].data[0] = r5; if (IsDoubleBattle()) { r5 = GetBattlerAtPosition(3); - ewram17810[r5].unk7 = CreateSprite(&gSpriteTemplate_81FAF34, GetBattlerSpriteCoord(r5, 0), GetBattlerSpriteCoord(r5, 1) + 32, 0xC8); - gSprites[ewram17810[r5].unk7].data[0] = r5; + gBattleHealthBoxInfo[r5].unk7 = CreateSprite(&gSpriteTemplate_81FAF34, GetBattlerSpriteCoord(r5, 0), GetBattlerSpriteCoord(r5, 1) + 32, 0xC8); + gSprites[gBattleHealthBoxInfo[r5].unk7].data[0] = r5; } } @@ -903,9 +902,9 @@ void sub_80328A4(struct Sprite *sprite) } if (gAnimScriptActive || r7->invisible) invisible = TRUE; - else if (gBattleSpriteInfo[r4].transformedSpecies != 0 && gEnemyMonElevation[gBattleSpriteInfo[r4].transformedSpecies] == 0) + else if (gBattleSpriteInfo[r4].transformSpecies != 0 && gEnemyMonElevation[gBattleSpriteInfo[r4].transformSpecies] == 0) invisible = TRUE; - if (gBattleSpriteInfo[r4].substituteSprite) + if (gBattleSpriteInfo[r4].behindSubstitute) invisible = TRUE; sprite->x = r7->x; sprite->x2 = r7->x2; @@ -921,18 +920,18 @@ void sub_8032984(u8 a, u16 b) { if (GetBattlerSide(a) != 0) { - if (gBattleSpriteInfo[a].transformedSpecies != 0) - b = gBattleSpriteInfo[a].transformedSpecies; + if (gBattleSpriteInfo[a].transformSpecies != 0) + b = gBattleSpriteInfo[a].transformSpecies; if (gEnemyMonElevation[b] != 0) - gSprites[ewram17810[a].unk7].callback = sub_80328A4; + gSprites[gBattleHealthBoxInfo[a].unk7].callback = sub_80328A4; else - gSprites[ewram17810[a].unk7].callback = sub_8032978; + gSprites[gBattleHealthBoxInfo[a].unk7].callback = sub_8032978; } } void sub_8032A08(u8 a) { - gSprites[ewram17810[a].unk7].callback = sub_8032978; + gSprites[gBattleHealthBoxInfo[a].unk7].callback = sub_8032978; } void sub_8032A38(void) @@ -960,7 +959,7 @@ void sub_8032A38(void) void sub_8032AA8(u8 a, u8 b) { - gBattleSpriteInfo[a].transformedSpecies = 0; + gBattleSpriteInfo[a].transformSpecies = 0; gBattleMonForms[a] = 0; if (b == 0) sub_80324E0(a); diff --git a/src/battle_interface.c b/src/battle_interface.c index ddd3d8d18..3a1efa3c6 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -436,7 +436,7 @@ extern const u16 gBattleInterfaceStatusIcons_DynPal[]; static void sub_8043D5C(struct Sprite *); static const void *GetHealthboxElementGfxPtr(u8); -/*static*/ void sub_8044210(u8, s16, u8); +static void sub_8044210(u8, s16, u8); /*static*/ void draw_status_ailment_maybe(u8); extern void sub_8045180(struct Sprite *); static void sub_8045110(struct Sprite *); @@ -669,7 +669,7 @@ static void sub_8043D5C(struct Sprite *sprite) sprite->y2 = gSprites[data5].y2; } -void sub_8043D84(u8 a, u8 b, u32 c, u32 d, u32 e) +void SetBattleBarStruct(u8 a, u8 b, u32 c, u32 d, u32 e) { eBattleBars[a].healthboxSpriteId = b; eBattleBars[a].maxValue = c; @@ -678,18 +678,18 @@ void sub_8043D84(u8 a, u8 b, u32 c, u32 d, u32 e) eBattleBars[a].currValue = -0x8000; } -void sub_8043DB0(u8 a) +void SetHealthboxSpriteInvisible(u8 healthboxSpriteId) { - gSprites[a].invisible = TRUE; - gSprites[gSprites[a].data[5]].invisible = TRUE; - gSprites[gSprites[a].oam.affineParam].invisible = TRUE; + gSprites[healthboxSpriteId].invisible = TRUE; + gSprites[gSprites[healthboxSpriteId].data[5]].invisible = TRUE; + gSprites[gSprites[healthboxSpriteId].oam.affineParam].invisible = TRUE; } -void sub_8043DFC(u8 a) +void SetHealthboxSpriteVisible(u8 healthboxSpriteId) { - gSprites[a].invisible = FALSE; - gSprites[gSprites[a].data[5]].invisible = FALSE; - gSprites[gSprites[a].oam.affineParam].invisible = FALSE; + gSprites[healthboxSpriteId].invisible = FALSE; + gSprites[gSprites[healthboxSpriteId].data[5]].invisible = FALSE; + gSprites[gSprites[healthboxSpriteId].oam.affineParam].invisible = FALSE; } static void sub_8043E50(u8 spriteId, s16 x, s16 y) @@ -833,7 +833,7 @@ void sub_8043F44(u8 a) CpuCopy32(&eBattleInterfaceGfxBuffer[i * 64 + 32], r7[i] + gSprites[a].oam.tileNum * TILE_SIZE_4BPP, TILE_SIZE_4BPP); } -void sub_80440EC(u8 a, s16 b, u8 c) +void UpdateHpTextInHealthbox(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent) { u8 str[0x14]; u8 *ptr; @@ -844,36 +844,36 @@ void sub_80440EC(u8 a, s16 b, u8 c) // TODO: make this a local variable memcpy(str, sEmptyWhiteText_GrayHighlight, sizeof(str)); - foo = gSprites[a].data[6]; + foo = gSprites[healthboxSpriteId].data[6]; if (IsDoubleBattle() == TRUE || GetBattlerSide(foo) == 1) { //_08044136 - sub_8044210(a, b, c); + sub_8044210(healthboxSpriteId, value, maxOrCurrent); } else { // ptr = str + 6; - if (c == 0) + if (maxOrCurrent == 0) { - if (GetBattlerSide(gSprites[a].data[6]) == 0) + if (GetBattlerSide(gSprites[healthboxSpriteId].data[6]) == 0) r4 = gUnknown_0820A83C; else r4 = gUnknown_0820A848; r8 = 3; - ptr = sub_8003504(ptr, b, 19, 1); + ptr = sub_8003504(ptr, value, 19, 1); *(ptr++) = CHAR_SLASH; *(ptr++) = EOS; } else { - if (GetBattlerSide(gSprites[a].data[6]) == 0) + if (GetBattlerSide(gSprites[healthboxSpriteId].data[6]) == 0) r4 = gUnknown_0820A854; else r4 = gUnknown_0820A85C; r8 = 2; - ptr = sub_8003504(ptr, b, 15, 1); + ptr = sub_8003504(ptr, value, 15, 1); } RenderTextHandleBold(eBattleInterfaceGfxBuffer, str); //asm(""::"r"(a)); @@ -882,14 +882,14 @@ void sub_80440EC(u8 a, s16 b, u8 c) { CpuCopy32( &eBattleInterfaceGfxBuffer[i * 64 + 32], - r4[i] + gSprites[a].oam.tileNum * 32, + r4[i] + gSprites[healthboxSpriteId].oam.tileNum * 32, 0x20 ); } } } -/*static*/ void sub_8044210(u8 a, s16 b, u8 c) +static void sub_8044210(u8 a, s16 b, u8 c) { u8 str[0x14]; u8 *ptr; @@ -1039,7 +1039,7 @@ void sub_804454C(void) else { draw_status_ailment_maybe(gHealthboxSpriteIds[i]); - sub_8045A5C(gHealthboxSpriteIds[i], &gPlayerParty[gBattlerPartyIndexes[i]], 5); + UpdateHealthboxAttribute(gHealthboxSpriteIds[i], &gPlayerParty[gBattlerPartyIndexes[i]], 5); CpuCopy32(GetHealthboxElementGfxPtr(0x75), OBJ_VRAM0 + 0x680 + gSprites[gHealthboxSpriteIds[i]].oam.tileNum * 32, 32); } } @@ -1063,9 +1063,9 @@ void sub_804454C(void) else { draw_status_ailment_maybe(gHealthboxSpriteIds[i]); - sub_8045A5C(gHealthboxSpriteIds[i], &gEnemyParty[gBattlerPartyIndexes[i]], 5); + UpdateHealthboxAttribute(gHealthboxSpriteIds[i], &gEnemyParty[gBattlerPartyIndexes[i]], 5); if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) - sub_8045A5C(gHealthboxSpriteIds[i], &gEnemyParty[gBattlerPartyIndexes[i]], 4); + UpdateHealthboxAttribute(gHealthboxSpriteIds[i], &gEnemyParty[gBattlerPartyIndexes[i]], 4); } } gSprites[gHealthboxSpriteIds[i]].data[7] ^= 1; @@ -1830,7 +1830,7 @@ static u8 sub_80457E8(u8 a, u8 b) } } -void sub_8045A5C(u8 a, struct Pokemon *pkmn, u8 c) +void UpdateHealthboxAttribute(u8 a, struct Pokemon *pkmn, u8 c) { u8 r10; u32 maxhp; @@ -1842,16 +1842,16 @@ void sub_8045A5C(u8 a, struct Pokemon *pkmn, u8 c) if (c == 3 || c == 0) sub_8043FC0(a, GetMonData(pkmn, MON_DATA_LEVEL)); if (c == 1 || c == 0) - sub_80440EC(a, GetMonData(pkmn, MON_DATA_HP), 0); + UpdateHpTextInHealthbox(a, GetMonData(pkmn, MON_DATA_HP), 0); if (c == 2 || c == 0) - sub_80440EC(a, GetMonData(pkmn, MON_DATA_MAX_HP), 1); + UpdateHpTextInHealthbox(a, GetMonData(pkmn, MON_DATA_MAX_HP), 1); if (c == 5 || c == 0) { - load_gfxc_health_bar(0); + LoadBattleBarGfx(0); maxhp = GetMonData(pkmn, MON_DATA_MAX_HP); currhp = GetMonData(pkmn, MON_DATA_HP); - sub_8043D84(r10, a, maxhp, currhp, 0); - sub_8045C78(r10, a, 0, 0); + SetBattleBarStruct(r10, a, maxhp, currhp, 0); + MoveBattleBar(r10, a, 0, 0); } if (!IsDoubleBattle() && (c == 6 || c == 0)) { @@ -1862,15 +1862,15 @@ void sub_8045A5C(u8 a, struct Pokemon *pkmn, u8 c) u32 var2; u32 currLevelExp; - load_gfxc_health_bar(3); + LoadBattleBarGfx(3); species = GetMonData(pkmn, MON_DATA_SPECIES); level = GetMonData(pkmn, MON_DATA_LEVEL); exp = GetMonData(pkmn, MON_DATA_EXP); currLevelExp = gExperienceTables[gBaseStats[species].growthRate][level]; var1 = exp - currLevelExp; var2 = gExperienceTables[gBaseStats[species].growthRate][level + 1] - currLevelExp; - sub_8043D84(r10, a, var2, var1, 0); - sub_8045C78(r10, a, 1, 0); + SetBattleBarStruct(r10, a, var2, var1, 0); + MoveBattleBar(r10, a, 1, 0); } if (c == 4 || c == 0) sub_80451A0(a, pkmn); @@ -1889,18 +1889,18 @@ void sub_8045A5C(u8 a, struct Pokemon *pkmn, u8 c) if (gUnknown_020297ED == 1) { if (c == 1 || c == 0) - sub_80440EC(a, GetMonData(pkmn, MON_DATA_HP), 0); + UpdateHpTextInHealthbox(a, GetMonData(pkmn, MON_DATA_HP), 0); if (c == 2 || c == 0) - sub_80440EC(a, GetMonData(pkmn, MON_DATA_MAX_HP), 1); + UpdateHpTextInHealthbox(a, GetMonData(pkmn, MON_DATA_MAX_HP), 1); } #endif if (c == 5 || c == 0) { - load_gfxc_health_bar(0); + LoadBattleBarGfx(0); maxhp = GetMonData(pkmn, MON_DATA_MAX_HP); currhp = GetMonData(pkmn, MON_DATA_HP); - sub_8043D84(r10, a, maxhp, currhp, 0); - sub_8045C78(r10, a, 0, 0); + SetBattleBarStruct(r10, a, maxhp, currhp, 0); + MoveBattleBar(r10, a, 0, 0); } if (c == 4 || c == 0) sub_80451A0(a, pkmn); @@ -1909,30 +1909,30 @@ void sub_8045A5C(u8 a, struct Pokemon *pkmn, u8 c) } } -s32 sub_8045C78(u8 a, u8 unused1, u8 c, u8 unused2) +s32 MoveBattleBar(u8 battler, u8 unused1, u8 whichBar, u8 unused2) { s32 r6; - if (c == 0) + if (whichBar == 0) { - r6 = sub_8045F58(eBattleBars[a].maxValue, eBattleBars[a].oldValue, eBattleBars[a].receivedValue, &eBattleBars[a].currValue, 6, 1); + r6 = sub_8045F58(eBattleBars[battler].maxValue, eBattleBars[battler].oldValue, eBattleBars[battler].receivedValue, &eBattleBars[battler].currValue, 6, 1); } else { - u16 r5; + u16 expFraction; s32 r8; - r5 = GetScaledExpFraction(eBattleBars[a].oldValue, eBattleBars[a].receivedValue, eBattleBars[a].maxValue, 8); - if (r5 == 0) - r5 = 1; - r8 = eBattleBars[a].receivedValue; - r5 = ABS(r8 / r5); - r6 = sub_8045F58(eBattleBars[a].maxValue, eBattleBars[a].oldValue, r8, &eBattleBars[a].currValue, 8, r5); + expFraction = GetScaledExpFraction(eBattleBars[battler].oldValue, eBattleBars[battler].receivedValue, eBattleBars[battler].maxValue, 8); + if (expFraction == 0) + expFraction = 1; + r8 = eBattleBars[battler].receivedValue; + expFraction = ABS(r8 / expFraction); + r6 = sub_8045F58(eBattleBars[battler].maxValue, eBattleBars[battler].oldValue, r8, &eBattleBars[battler].currValue, 8, expFraction); } - if (c == 1 || (c == 0 && (!gBattleSpriteInfo[a].hpNumbersNoBars))) - sub_8045D58(a, c); + if (whichBar == 1 || (whichBar == 0 && (!gBattleSpriteInfo[battler].hpNumbersNoBars))) + sub_8045D58(battler, whichBar); if (r6 == -1) - eBattleBars[a].currValue = 0; + eBattleBars[battler].currValue = 0; return r6; } diff --git a/src/battle_main.c b/src/battle_main.c index aac466af6..8471161fd 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -41,13 +41,13 @@ #include "string_util.h" #include "task.h" #include "text.h" -#include "trainer.h" #include "trig.h" #include "tv.h" #include "scanline_effect.h" #include "util.h" #include "ewram.h" #include "battle_string_ids.h" +#include "constants/trainers.h" struct UnknownStruct7 { @@ -121,7 +121,7 @@ extern void (*gBattleMainFunc)(void); u8 gLeveledUpInBattle; void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(void); u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT]; -u8 gUnknown_0300434C[MAX_BATTLERS_COUNT]; +u8 gBattleControllerData[MAX_BATTLERS_COUNT]; extern u16 gBattleTypeFlags; extern u8 gReservedSpritePaletteCount; extern u16 gTrainerBattleOpponent; @@ -2627,7 +2627,7 @@ void debug_sub_8012688(void) gMonSpriteGfx_Sprite_ptr[1], gCurrentMove); LoadCompressedPalette(gMonPaletteTable[gCurrentMove].data, 272, 32); - GetMonSpriteTemplate_803C56C(gCurrentMove, 1); + SetMultiuseSpriteTemplateToPokemon(gCurrentMove, 1); spriteId = CreateSprite(&gCreatingSpriteTemplate, 176, 40 + gMonFrontPicCoords[gCurrentMove].y_offset, 40); gSprites[spriteId].callback = nullsub_37; gSprites[spriteId].oam.paletteNum = 1; @@ -3072,7 +3072,7 @@ void sub_8010278(struct Sprite *sprite) if (sprite->x2 == 0) { sprite->callback = sub_80102AC; - PlayCry1(sprite->data[2], 25); + PlayCry_Normal(sprite->data[2], 25); } } } @@ -3081,8 +3081,8 @@ void sub_80102AC(struct Sprite *sprite) { if (sprite->animEnded) { - sub_804777C(sprite->data[0]); - sub_8043DFC(gHealthboxSpriteIds[sprite->data[0]]); + StartHealthboxSlideIn(sprite->data[0]); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[sprite->data[0]]); sprite->callback = nullsub_37; StartSpriteAnimIfDifferent(sprite, 0); BeginNormalPaletteFade(0x00020000, 0, 10, 0, RGB(15, 15, 15)); @@ -3123,8 +3123,8 @@ void sub_8010384(struct Sprite *sprite) u16 species; u8 yOffset; - if (gBattleSpriteInfo[r6].transformedSpecies != 0) - species = gBattleSpriteInfo[r6].transformedSpecies; + if (gBattleSpriteInfo[r6].transformSpecies != 0) + species = gBattleSpriteInfo[r6].transformSpecies; else species = sprite->data[2]; @@ -3255,12 +3255,12 @@ void dp11b_obj_instanciate(u8 bank, u8 b, s8 c, s8 d) if (b) { - if (ewram17810[bank].unk0_1) + if (gBattleHealthBoxInfo[bank].unk0_1) return; } else { - if (ewram17810[bank].unk0_2) + if (gBattleHealthBoxInfo[bank].unk0_2) return; } @@ -3268,15 +3268,15 @@ void dp11b_obj_instanciate(u8 bank, u8 b, s8 c, s8 d) if (b == TRUE) { objectID = gHealthboxSpriteIds[bank]; - ewram17810[bank].unk2 = spriteId; - ewram17810[bank].unk0_1 = 1; + gBattleHealthBoxInfo[bank].unk2 = spriteId; + gBattleHealthBoxInfo[bank].unk0_1 = 1; gSprites[spriteId].data[0] = 0x80; } else { objectID = gBattlerSpriteIds[bank]; - ewram17810[bank].unk3 = spriteId; - ewram17810[bank].unk0_2 = 1; + gBattleHealthBoxInfo[bank].unk3 = spriteId; + gBattleHealthBoxInfo[bank].unk0_2 = 1; gSprites[spriteId].data[0] = 0xC0; } gSprites[spriteId].data[1] = c; @@ -3293,19 +3293,19 @@ void dp11b_obj_free(u8 a, u8 b) if (b == TRUE) { - if (!ewram17810[a].unk0_1) + if (!gBattleHealthBoxInfo[a].unk0_1) return; - r4 = gSprites[ewram17810[a].unk2].data[3]; - DestroySprite(&gSprites[ewram17810[a].unk2]); - ewram17810[a].unk0_1 = 0; + r4 = gSprites[gBattleHealthBoxInfo[a].unk2].data[3]; + DestroySprite(&gSprites[gBattleHealthBoxInfo[a].unk2]); + gBattleHealthBoxInfo[a].unk0_1 = 0; } else { - if (!ewram17810[a].unk0_2) + if (!gBattleHealthBoxInfo[a].unk0_2) return; - r4 = gSprites[ewram17810[a].unk3].data[3]; - DestroySprite(&gSprites[ewram17810[a].unk3]); - ewram17810[a].unk0_2 = 0; + r4 = gSprites[gBattleHealthBoxInfo[a].unk3].data[3]; + DestroySprite(&gSprites[gBattleHealthBoxInfo[a].unk3]); + gBattleHealthBoxInfo[a].unk0_2 = 0; } gSprites[r4].x2 = 0; gSprites[r4].y2 = 0; diff --git a/src/battle_party_menu.c b/src/battle_party_menu.c index d02155eab..636eee588 100644 --- a/src/battle_party_menu.c +++ b/src/battle_party_menu.c @@ -30,20 +30,20 @@ extern void sub_802E414(void); extern void sub_80A6DCC(void); extern u8 *sub_8040D08(); extern void SetMonPreventsSwitchingString(void); -extern void nullsub_14(); +extern void ReshowBattleScreenDummy(); extern u8 sub_803FBBC(void); extern u8 gPlayerPartyCount; extern u8 gBattlersCount; extern u16 gBattlerPartyIndexes[]; -extern u8 gBankInMenu; +extern u8 gBattlerInMenuId; extern u8 gUnknown_0202E8F4; extern u8 gUnknown_0202E8F5; extern u8 gPartyMenuMessage_IsPrinting; extern u8 gUnknown_020384F0; extern void (*gPokemonItemUseCallback)(); //don't know types yet extern struct PokemonStorage gPokemonStorage; -extern void nullsub_14(); +extern void ReshowBattleScreenDummy(); void sub_8094C98(u8, u8); u8 pokemon_order_func(u8); @@ -334,7 +334,7 @@ void sub_8094E20(u8 a) { gPaletteFade.bufferTransferDisabled = TRUE; gUnknown_02038473 = a; - nullsub_14(); + ReshowBattleScreenDummy(); pokemon_change_order(); OpenPartyMenu(PARTY_MENU_TYPE_BATTLE, 0xFF); } @@ -707,7 +707,7 @@ static void Task_BattlePartyMenuShift(u8 taskId) if (gUnknown_02038473 == 2) { u8 r0; - u8 r4 = gBankInMenu; + u8 r4 = gBattlerInMenuId; PartyMenuEraseMsgBoxAndFrame(); r0 = pokemon_order_func(gBattlerPartyIndexes[r4]); @@ -719,7 +719,7 @@ static void Task_BattlePartyMenuShift(u8 taskId) } gUnknown_0202E8F5 = sub_8094C20(partySelection); gUnknown_0202E8F4 = 1; - r4 = pokemon_order_func(gBattlerPartyIndexes[gBankInMenu]); + r4 = pokemon_order_func(gBattlerPartyIndexes[gBattlerInMenuId]); sub_8094C98(r4, partySelection); SwapPokemon(&gPlayerParty[r4], &gPlayerParty[partySelection]); gTasks[taskId].func = Task_809527C; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 30415c2c5..c270710e2 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -107,7 +107,7 @@ extern const struct TrainerReward gTrainerMoney[]; extern u16 gRandomMove; extern u8* gBattleScriptsForMoveEffects[]; extern u16 gChosenMove; //last used move in battle -extern u8 gBankInMenu; +extern u8 gBattlerInMenuId; extern u8 gActionForBanks[4]; extern u16 gLastPrintedMoves[4]; //last used moves 2, used by sketch extern u16 gLastResultingMoves[4]; //last used moves by banks, another one @@ -6013,7 +6013,7 @@ static void atk74_hpthresholds2(void) static void atk75_useitemonopponent(void) { - gBankInMenu = gBattlerAttacker; + gBattlerInMenuId = gBattlerAttacker; PokemonUseItemEffects(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker]], gLastUsedItem, gBattlerPartyIndexes[gBattlerAttacker], 0, 1); gBattlescriptCurrInstr += 1; } diff --git a/src/battle_setup.c b/src/battle_setup.c index 087fd6f43..6394f0511 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -34,7 +34,7 @@ #include "strings.h" #include "task.h" #include "text.h" -#include "trainer.h" +#include "constants/trainers.h" extern u16 gSpecialVar_Result; diff --git a/src/battle_tower.c b/src/battle_tower.c index 1d9da71ad..00817359d 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -24,8 +24,8 @@ #include "string_util.h" #include "task.h" #include "text.h" -#include "trainer.h" #include "tv.h" +#include "constants/trainers.h" #if ENGLISH #include "data/battle_tower/trainers.h" diff --git a/src/battle_transition.c b/src/battle_transition.c index e459e63be..f055ed54c 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -10,12 +10,12 @@ #include "random.h" #include "sprite.h" #include "sound.h" -#include "trainer.h" #include "field_camera.h" #include "ewram.h" #include "scanline_effect.h" #include "constants/songs.h" #include "constants/field_effects.h" +#include "constants/trainers.h" void ScanlineEffect_Clear(void); diff --git a/src/contest_2.c b/src/contest_2.c index 4ce5b1879..6b2106e64 100644 --- a/src/contest_2.c +++ b/src/contest_2.c @@ -1018,7 +1018,7 @@ u8 unref_sub_80AE908(void) gMonSpriteGfx_Sprite_ptr[1], species); LoadCompressedPalette(gMonPaletteTable[species].data, 0x110, 32); - GetMonSpriteTemplate_803C56C(gContestMons[gContestPlayerMonIndex].species, 1); + SetMultiuseSpriteTemplateToPokemon(gContestMons[gContestPlayerMonIndex].species, 1); spriteId = CreateSprite( &gCreatingSpriteTemplate, 112, 80 + (8 - gMonFrontPicCoords[gContestMons[gContestPlayerMonIndex].species].coords) * 4, @@ -1046,11 +1046,11 @@ u8 CreateContestantSprite(u16 species, u32 otId, u32 personality) personality); lzPaletteData = GetMonSpritePalFromOtIdPersonality(species, otId, personality); LoadCompressedPalette(lzPaletteData, 0x120, 32); - GetMonSpriteTemplate_803C56C(species, 0); + SetMultiuseSpriteTemplateToPokemon(species, 0); spriteId = CreateSprite(&gCreatingSpriteTemplate, 112, GetBattlerSpriteFinal_Y(2, species, 0), 30); gSprites[spriteId].oam.paletteNum = 2; gSprites[spriteId].oam.priority = 2; - gSprites[spriteId].subpriority = GetBattlerSubpriority(2); + gSprites[spriteId].subpriority = GetBattlerSpriteSubpriority(2); gSprites[spriteId].callback = SpriteCallbackDummy; gSprites[spriteId].data[0] = gSprites[spriteId].oam.paletteNum; gSprites[spriteId].data[2] = species; diff --git a/src/contest_link_util.c b/src/contest_link_util.c index 448c07265..982a4e29a 100644 --- a/src/contest_link_util.c +++ b/src/contest_link_util.c @@ -613,7 +613,7 @@ static void sub_80C2A8C(u8 taskId) HandleLoadSpecialPokePic(gMonFrontPicTable + species, gMonFrontPicCoords[species].coords, gMonFrontPicCoords[species].y_offset, (void *)gSharedMem, gMonSpriteGfx_Sprite_ptr[1], species, personality); monPal = GetMonSpritePalStructFromOtIdPersonality(species, otId, personality); LoadCompressedObjectPalette(monPal); - GetMonSpriteTemplate_803C56C(species, 1); + SetMultiuseSpriteTemplateToPokemon(species, 1); gCreatingSpriteTemplate.paletteTag = monPal->tag; spriteId = CreateSprite(&gCreatingSpriteTemplate, 0x110, 0x50, 10); gSprites[spriteId].data[1] = species; @@ -1996,7 +1996,7 @@ void sub_80C3C44(struct Sprite *sprite) { if (++sprite->data[0] == 10) { - PlayCry1(sprite->data[1], 0); + PlayCry_Normal(sprite->data[1], 0); sprite->data[1] = 0; } } diff --git a/src/contest_util.c b/src/contest_util.c index c525a3077..136b9fff7 100644 --- a/src/contest_util.c +++ b/src/contest_util.c @@ -301,7 +301,7 @@ void ShowContestEntryMonPic(void) var1); palette = GetMonSpritePalStructFromOtIdPersonality(species, var2, var1); LoadCompressedObjectPalette(palette); - GetMonSpriteTemplate_803C56C(species, 1); + SetMultiuseSpriteTemplateToPokemon(species, 1); gCreatingSpriteTemplate.paletteTag = palette->tag; spriteId = CreateSprite(&gCreatingSpriteTemplate, 0x78, 0x40, 0); gTasks[taskId].data[2] = spriteId; diff --git a/src/de_rom_8040FE0.c b/src/de_rom_8040FE0.c index 24e0fa51b..5d321b22b 100644 --- a/src/de_rom_8040FE0.c +++ b/src/de_rom_8040FE0.c @@ -2,7 +2,7 @@ #include "battle.h" #include "battle_tower.h" #include "ewram.h" -#include "trainer.h" +#include "constants/trainers.h" #if GERMAN diff --git a/src/debug/watanabe_debug_menu.c b/src/debug/watanabe_debug_menu.c index d3fb37886..a12ab4db7 100644 --- a/src/debug/watanabe_debug_menu.c +++ b/src/debug/watanabe_debug_menu.c @@ -2672,14 +2672,14 @@ void debug_80C6CB8(u8 taskId) { DecompressPicFromTable_2(gMonFrontPicTable + gUnknown_Debug_2038A20->totalPoints, gMonFrontPicCoords[gUnknown_Debug_2038A20->totalPoints].coords, gMonFrontPicCoords[gUnknown_Debug_2038A20->totalPoints].y_offset, gMonSpriteGfx_Sprite_ptr[0], gMonSpriteGfx_Sprite_ptr[1], gUnknown_Debug_2038A20->totalPoints); LoadCompressedObjectPalette(gMonPaletteTable + gUnknown_Debug_2038A20->totalPoints); - GetMonSpriteTemplate_803C56C(gUnknown_Debug_2038A20->totalPoints, 1); + SetMultiuseSpriteTemplateToPokemon(gUnknown_Debug_2038A20->totalPoints, 1); gUnknown_Debug_2038A20->excitementAppealBonus = CreateSprite(&gCreatingSpriteTemplate, 0x28, 0x28, 0); gSprites[gUnknown_Debug_2038A20->excitementAppealBonus].callback = debug_69; gSprites[gUnknown_Debug_2038A20->excitementAppealBonus].oam.priority = 0; DecompressPicFromTable_2(gMonBackPicTable + gUnknown_Debug_2038A20->totalPoints, gMonBackPicCoords[gUnknown_Debug_2038A20->totalPoints].coords, gMonBackPicCoords[gUnknown_Debug_2038A20->totalPoints].y_offset, gMonSpriteGfx_Sprite_ptr[0], gMonSpriteGfx_Sprite_ptr[2], gUnknown_Debug_2038A20->totalPoints); LoadCompressedObjectPalette(gMonPaletteTable + gUnknown_Debug_2038A20->totalPoints); - GetMonSpriteTemplate_803C56C(gUnknown_Debug_2038A20->totalPoints, 2); + SetMultiuseSpriteTemplateToPokemon(gUnknown_Debug_2038A20->totalPoints, 2); gUnknown_Debug_2038A20->unk3 = CreateSprite(&gCreatingSpriteTemplate, 0x28, 0x78, 0); gSprites[gUnknown_Debug_2038A20->unk3].callback = debug_69; gSprites[gUnknown_Debug_2038A20->unk3].oam.priority = 0; @@ -2704,7 +2704,7 @@ void debug_80C6CB8(u8 taskId) gUnknown_Debug_2038A20->unk9 = 0; StopCryAndClearCrySongs(); - PlayCry1(gUnknown_Debug_2038A20->totalPoints, 0); + PlayCry_Normal(gUnknown_Debug_2038A20->totalPoints, 0); } void debug_80C6EE8(u8 taskId) @@ -2779,7 +2779,7 @@ void debug_80C6FA8(u8 taskId) if (JOY_NEW(SELECT_BUTTON)) { StopCryAndClearCrySongs(); - PlayCry1(gUnknown_Debug_2038A20->totalPoints, 0); + PlayCry_Normal(gUnknown_Debug_2038A20->totalPoints, 0); } gUnknown_Debug_2038A20->random += 4; gUnknown_Debug_2038A20->random &= 0x1f; @@ -3049,7 +3049,7 @@ NAKED void debug_80C6FA8(u8 taskId) "\tldr\tr0, [r0]\n" "\tldrh\tr0, [r0]\n" "\tmov\tr1, #0x0\n" - "\tbl\tPlayCry1\n" + "\tbl\tPlayCry_Normal\n" "._706:\n" "\tldr\tr2, ._707 @ gUnknown_Debug_2038A20\n" "\tldr\tr1, [r2]\n" @@ -3299,7 +3299,7 @@ void debug_80C7934(u8 taskId) { DecompressPicFromTable_2(gTrainerFrontPicTable + gUnknown_Debug_2038A20->totalPoints, gTrainerFrontPicCoords[gUnknown_Debug_2038A20->totalPoints].coords, gTrainerFrontPicCoords[gUnknown_Debug_2038A20->totalPoints].y_offset, gMonSpriteGfx_Sprite_ptr[0], gMonSpriteGfx_Sprite_ptr[1], gUnknown_Debug_2038A20->totalPoints); LoadCompressedObjectPalette(gTrainerFrontPicPaletteTable + gUnknown_Debug_2038A20->totalPoints); - GetMonSpriteTemplate_803C5A0(gUnknown_Debug_2038A20->totalPoints, 1); + SetMultiuseSpriteTemplateToTrainerBack(gUnknown_Debug_2038A20->totalPoints, 1); gUnknown_Debug_2038A20->excitementAppealBonus = CreateSprite(&gCreatingSpriteTemplate, 0x28, 0x28, 0); gSprites[gUnknown_Debug_2038A20->excitementAppealBonus].callback = debug_69; gSprites[gUnknown_Debug_2038A20->excitementAppealBonus].oam.priority = 0; diff --git a/src/egg_hatch.c b/src/egg_hatch.c index 8ff9f28a7..d0bdc797f 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -361,7 +361,7 @@ static u8 EggHatchCreateMonSprite(u8 a0, u8 switchID, u8 pokeID) } break; case 1: - GetMonSpriteTemplate_803C56C(GetMonSpritePalStruct(mon)->tag, r5); + SetMultiuseSpriteTemplateToPokemon(GetMonSpritePalStruct(mon)->tag, r5); spriteID = CreateSprite(&gCreatingSpriteTemplate, 120, 70, 6); gSprites[spriteID].invisible = TRUE; gSprites[spriteID].callback = SpriteCallbackDummy; diff --git a/src/evolution_scene.c b/src/evolution_scene.c index 609dfafe1..25f267103 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -232,7 +232,7 @@ void EvolutionScene(struct Pokemon* mon, u16 speciesToEvolve, bool8 canStopEvo, pokePal = (void*) GetMonSpritePalStructFromOtIdPersonality(currSpecies, TiD, PiD); LoadCompressedPalette(*pokePal, 0x110, 0x20); - GetMonSpriteTemplate_803C56C(currSpecies, 1); + SetMultiuseSpriteTemplateToPokemon(currSpecies, 1); gCreatingSpriteTemplate.affineAnims = gDummySpriteAffineAnimTable; sEvoInfo.preEvoSpriteID = ID = CreateSprite(&gCreatingSpriteTemplate, 120, 64, 30); @@ -249,7 +249,7 @@ void EvolutionScene(struct Pokemon* mon, u16 speciesToEvolve, bool8 canStopEvo, pokePal = (void*) GetMonSpritePalStructFromOtIdPersonality(speciesToEvolve, TiD, PiD); LoadCompressedPalette(*pokePal, 0x120, 0x20); - GetMonSpriteTemplate_803C56C(speciesToEvolve, 3); + SetMultiuseSpriteTemplateToPokemon(speciesToEvolve, 3); gCreatingSpriteTemplate.affineAnims = gDummySpriteAffineAnimTable; sEvoInfo.postEvoSpriteID = ID = CreateSprite(&gCreatingSpriteTemplate, 120, 64, 30); gSprites[ID].callback = nullsub_37; @@ -329,7 +329,7 @@ static void CB2_EvolutionSceneLoadGraphics(void) pokePal = (void*) GetMonSpritePalStructFromOtIdPersonality(postEvoSpecies, TiD, PiD); LoadCompressedPalette(*pokePal, 0x120, 0x20); - GetMonSpriteTemplate_803C56C(postEvoSpecies, 3); + SetMultiuseSpriteTemplateToPokemon(postEvoSpecies, 3); gCreatingSpriteTemplate.affineAnims = gDummySpriteAffineAnimTable; sEvoInfo.postEvoSpriteID = ID = CreateSprite(&gCreatingSpriteTemplate, 120, 64, 30); @@ -405,7 +405,7 @@ static void CB2_TradeEvolutionSceneLoadGraphics(void) { u8 ID; - GetMonSpriteTemplate_803C56C(postEvoSpecies, 3); + SetMultiuseSpriteTemplateToPokemon(postEvoSpecies, 3); gCreatingSpriteTemplate.affineAnims = gDummySpriteAffineAnimTable; sEvoInfo.postEvoSpriteID = ID = CreateSprite(&gCreatingSpriteTemplate, 120, 64, 30); @@ -449,7 +449,7 @@ void TradeEvolutionScene(struct Pokemon* mon, u16 speciesToEvolve, u8 preEvoSpri pokePal = (void*) GetMonSpritePalStructFromOtIdPersonality(speciesToEvolve, TiD, PiD); LoadCompressedPalette(*pokePal, 0x120, 0x20); - GetMonSpriteTemplate_803C56C(speciesToEvolve, 1); + SetMultiuseSpriteTemplateToPokemon(speciesToEvolve, 1); gCreatingSpriteTemplate.affineAnims = gDummySpriteAffineAnimTable; sEvoInfo.postEvoSpriteID = ID = CreateSprite(&gCreatingSpriteTemplate, 120, 64, 30); @@ -556,7 +556,7 @@ static void Task_EvolutionScene(u8 taskID) case 2: // wait for string, play cry if (gWindowTemplate_Contest_MoveDescription.state == 0) { - PlayCry1(gTasks[taskID].tPreEvoSpecies, 0); + PlayCry_Normal(gTasks[taskID].tPreEvoSpecies, 0); gTasks[taskID].tState++; } break; @@ -627,7 +627,7 @@ static void Task_EvolutionScene(u8 taskID) if (IsSEPlaying()) { m4aMPlayAllStop(); - PlayCry1(gTasks[taskID].tPostEvoSpecies, 0); + PlayCry_Normal(gTasks[taskID].tPostEvoSpecies, 0); memcpy(&gPlttBufferUnfaded[0x20], (void *)(EWRAM + 0x9000), 0x60); BeginNormalPaletteFade(0x1C, 0, 16, 0, RGB(0, 0, 0)); gTasks[taskID].tState++; @@ -698,7 +698,7 @@ static void Task_EvolutionScene(u8 taskID) case 17: // play cry of the pokemon trying to evolve again, evolution has been stopped if (!gPaletteFade.active) { - PlayCry1(gTasks[taskID].tPreEvoSpecies, 0); + PlayCry_Normal(gTasks[taskID].tPreEvoSpecies, 0); gTasks[taskID].tState++; } break; @@ -909,7 +909,7 @@ static void Task_TradeEvolutionScene(u8 taskID) case 1: if (gUnknown_03004828->window.state == 0) { - PlayCry1(gTasks[taskID].tPreEvoSpecies, 0); + PlayCry_Normal(gTasks[taskID].tPreEvoSpecies, 0); gTasks[taskID].tState++; } break; @@ -981,7 +981,7 @@ static void Task_TradeEvolutionScene(u8 taskID) case 11: if (IsSEPlaying()) { - PlayCry1(gTasks[taskID].tPostEvoSpecies, 0); + PlayCry_Normal(gTasks[taskID].tPostEvoSpecies, 0); memcpy(&gPlttBufferUnfaded[0x20], (void *)(EWRAM + 0x9000), 0x60); BeginNormalPaletteFade(0x1, 0, 16, 0, RGB(0, 0, 0)); gTasks[taskID].tState++; diff --git a/src/field_effect.c b/src/field_effect.c index 9c7698ca4..a67ac6374 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -545,7 +545,7 @@ u8 CreateMonSprite_PicBox(u16 species, s16 x, s16 y, u8 subpriority) { DecompressPicFromTable_2(&gMonFrontPicTable[species], gMonFrontPicCoords[species].coords, gMonFrontPicCoords[species].y_offset, gMonSpriteGfx_Sprite_ptr[3], gMonSpriteGfx_Sprite_ptr[3], species); LoadCompressedObjectPalette(&gMonPaletteTable[species]); - GetMonSpriteTemplate_803C56C(species, 3); + SetMultiuseSpriteTemplateToPokemon(species, 3); gCreatingSpriteTemplate.paletteTag = gMonPaletteTable[0].tag; PreservePaletteInWeather(IndexOfSpritePaletteTag(gMonPaletteTable[0].tag) + 0x10); return CreateSprite(&gCreatingSpriteTemplate, x, y, subpriority); @@ -558,7 +558,7 @@ u8 CreateMonSprite_FieldMove(u16 species, u32 d, u32 g, s16 x, s16 y, u8 subprio HandleLoadSpecialPokePic(&gMonFrontPicTable[species], gMonFrontPicCoords[species].coords, gMonFrontPicCoords[species].y_offset, gMonSpriteGfx_Sprite_ptr[3] /* this is actually u8* or something, pointing to ewram */, gMonSpriteGfx_Sprite_ptr[3], species, g); spritePalette = GetMonSpritePalStructFromOtIdPersonality(species, d, g); LoadCompressedObjectPalette(spritePalette); - GetMonSpriteTemplate_803C56C(species, 3); + SetMultiuseSpriteTemplateToPokemon(species, 3); gCreatingSpriteTemplate.paletteTag = spritePalette->tag; PreservePaletteInWeather(IndexOfSpritePaletteTag(spritePalette->tag) + 0x10); return CreateSprite(&gCreatingSpriteTemplate, x, y, subpriority); @@ -2547,7 +2547,7 @@ void sub_8088890(struct Sprite *sprite) PlayCry2(sprite->data[0], 0, 0x7d, 0xa); } else { - PlayCry1(sprite->data[0], 0); + PlayCry_Normal(sprite->data[0], 0); } } } diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 50e969a04..9a8ebd365 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -624,7 +624,7 @@ static void sub_8142404(u8 taskID) if (gSprites[gTasks[taskID].tMonSpriteID(currPokeID)].data[0] != 0) { if (currMon->species != SPECIES_EGG) - PlayCry1(currMon->species, 0); + PlayCry_Normal(currMon->species, 0); HallOfFame_PrintMonInfo(currMon, 0, 14); gTasks[taskID].tFrameCount = 120; gTasks[taskID].func = sub_8142484; @@ -950,7 +950,7 @@ static void sub_8142CC8(u8 taskID) if (currMon->species != SPECIES_EGG) { StopCryAndClearCrySongs(); - PlayCry1(currMon->species, 0); + PlayCry_Normal(currMon->species, 0); } HallOfFame_PrintMonInfo(currMon, 0, 14); diff --git a/src/item_menu.c b/src/item_menu.c index 0852ce015..974519c95 100644 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -2909,7 +2909,7 @@ static void sub_80A7150(void) } } -void PrepareBagForWallyTutorial(void) +void DoWallyTutorialBagMenu(void) { u8 i; diff --git a/src/item_use.c b/src/item_use.c index 6fd6f5c33..01e30d317 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -46,7 +46,7 @@ extern void (*gPokemonItemUseCallback)(u8, u16, TaskFunc); extern u8 gPokemonItemUseType; extern u8 gLastFieldPokeMenuOpened; -extern u8 gBankInMenu; +extern u8 gBattlerInMenuId; extern u8 S_PlantBerryTreeFromBag[]; extern u8 S_WaterBerryTreeFromBag[]; @@ -905,7 +905,7 @@ void sub_80CA2BC(u8 taskId) void ItemUseInBattle_StatIncrease(u8 taskId) { - u16 partyId = gBattlerPartyIndexes[gBankInMenu]; + u16 partyId = gBattlerPartyIndexes[gBattlerInMenuId]; Menu_EraseWindowRect(0, 13, 13, 20); diff --git a/src/main_menu.c b/src/main_menu.c index a224efe3b..97696866e 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -857,7 +857,7 @@ static void Task_NewGameSpeech7(u8 taskId) gTasks[taskId].tFrameCounter++; //Play Azurill cry at frame 32 if (gTasks[taskId].tFrameCounter == 32) - PlayCry1(SPECIES_AZURILL, 0); + PlayCry_Normal(SPECIES_AZURILL, 0); } } @@ -1428,7 +1428,7 @@ u8 CreateAzurillSprite(u8 x, u8 y) gMonSpriteGfx_Sprite_ptr[1], SPECIES_AZURILL); LoadCompressedObjectPalette(&gMonPaletteTable[SPECIES_AZURILL]); - GetMonSpriteTemplate_803C56C(SPECIES_AZURILL, 1); + SetMultiuseSpriteTemplateToPokemon(SPECIES_AZURILL, 1); return CreateSprite(&gCreatingSpriteTemplate, x, y, 0); } diff --git a/src/pokeball.c b/src/pokeball.c index 34bb2bfbd..aa1f79d89 100644 --- a/src/pokeball.c +++ b/src/pokeball.c @@ -326,12 +326,12 @@ static void sub_8047830(struct Sprite *); static void oamc_804BEB4(struct Sprite *); static u16 GetBattlerBall(u8); -u8 StartSendOutMonAnimation(u16 a, u8 side) +u8 DoPokeballSendOutAnimation(u16 a, u8 side) { u8 taskId; gDoingBattleAnim = 1; - ewram17810[gActiveBattler].unk0_3 = 1; + gBattleHealthBoxInfo[gActiveBattler].ballAnimActive = 1; taskId = CreateTask(SendOutMonAnimation, 5); gTasks[taskId].data[1] = a; gTasks[taskId].data[2] = side; @@ -647,7 +647,7 @@ static void sub_8046AD0(u8 taskId) gTasks[taskId].data[15] = r6 + 1; break; case 1: - PlayCry1(species, r3); + PlayCry_Normal(species, r3); DestroyTask(taskId); break; case 2: @@ -793,12 +793,12 @@ static void sub_8046E9C(struct Sprite *sprite) gSprites[gBattlerSpriteIds[r4]].y2 = 0; gDoingBattleAnim = 0; - ewram17810[r4].unk0_3 = 0; + gBattleHealthBoxInfo[r4].ballAnimActive = 0; FreeSpriteOamMatrix(sprite); DestroySprite(sprite); for (r3 = 0, i = 0; i < 4; i++) { - if (ewram17810[i].unk0_3 == 0) + if (gBattleHealthBoxInfo[i].ballAnimActive == 0) r3++; } if (r3 == 4) @@ -830,7 +830,7 @@ static void sub_8046FBC(struct Sprite *sprite) DestroySprite(&gSprites[gBattlerSpriteIds[sprite->data[6]]]); DestroySpriteAndFreeResources(sprite); if (gMain.inBattle) - ewram17810[r7].unk0_3 = 0; + gBattleHealthBoxInfo[r7].ballAnimActive = 0; } } @@ -1101,7 +1101,7 @@ void obj_delete_and_free_associated_resources_(struct Sprite *sprite) DestroySpriteAndFreeResources(sprite); } -void sub_804777C(u8 a) +void StartHealthboxSlideIn(u8 a) { struct Sprite *sprite = &gSprites[gHealthboxSpriteIds[a]]; @@ -1140,7 +1140,7 @@ static void sub_8047830(struct Sprite *sprite) sprite->callback = SpriteCallbackDummy; } -void sub_8047858(u8 a) +void DoHitAnimHealthboxEffect(u8 a) { u8 spriteId; diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c index 28937c2fc..bbe01aff3 100644 --- a/src/pokeblock_feed.c +++ b/src/pokeblock_feed.c @@ -628,7 +628,7 @@ static bool8 sub_8147B20(struct Pokemon* mon) TiD = GetMonData(mon, MON_DATA_OT_ID); palette = GetMonSpritePalStructFromOtIdPersonality(species, TiD, PiD); LoadCompressedObjectPalette(palette); - GetMonSpriteTemplate_803C56C(palette->tag, 1); + SetMultiuseSpriteTemplateToPokemon(palette->tag, 1); ePokeblockGfxState++; } break; @@ -791,7 +791,7 @@ static void sub_8148078(struct Sprite* sprite) sprite->y += sprite->data[0]; sprite->data[0] += sprite->data[1]; if (sprite->data[0] == 0) - PlayCry1(sprite->data[2], 0); + PlayCry_Normal(sprite->data[2], 0); if (sprite->data[0] == 9) sprite->callback = SpriteCallbackDummy; } diff --git a/src/pokedex.c b/src/pokedex.c index a0270b5b2..2f440a734 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -3858,7 +3858,7 @@ static void sub_8090750(u8 taskId) case 6: if (!gPaletteFade.active) { - PlayCry1(NationalPokedexNumToSpecies(dexNum), 0); + PlayCry_Normal(NationalPokedexNumToSpecies(dexNum), 0); gTasks[taskId].data[2] = 0; gTasks[taskId].data[4] = 0; gTasks[taskId].func = sub_8090A3C; diff --git a/src/pokemon_1.c b/src/pokemon_1.c index 76f5f3dfe..a3baf8341 100644 --- a/src/pokemon_1.c +++ b/src/pokemon_1.c @@ -10,10 +10,10 @@ #include "overworld.h" #include "sprite.h" #include "string_util.h" -#include "trainer.h" #include "text.h" #include "ewram.h" #include "util.h" +#include "constants/trainers.h" extern u16 gMoveToLearn; diff --git a/src/pokemon_2.c b/src/pokemon_2.c index db31ec47a..ef1cec702 100644 --- a/src/pokemon_2.c +++ b/src/pokemon_2.c @@ -14,9 +14,9 @@ #include "string_util.h" #include "strings2.h" #include "text.h" -#include "trainer.h" #include "util.h" #include "ewram.h" +#include "constants/trainers.h" extern u8 gPlayerPartyCount; extern u8 gEnemyPartyCount; @@ -159,14 +159,14 @@ const struct SpriteTemplate gSpriteTemplate_8208288[] = gAffineAnims_BattleSpriteOpponentSide, oac_poke_opponent}, }; -void GetMonSpriteTemplate_803C56C(u16 species, u8 a2) +void SetMultiuseSpriteTemplateToPokemon(u16 species, u8 a2) { gCreatingSpriteTemplate = gSpriteTemplate_8208288[a2]; gCreatingSpriteTemplate.paletteTag = species; gCreatingSpriteTemplate.anims = (const union AnimCmd *const *)gSpriteAnimTable_81E7C64; //Why do I have to cast this? } -void GetMonSpriteTemplate_803C5A0(u16 species, u8 a2) +void SetMultiuseSpriteTemplateToTrainerBack(u16 species, u8 a2) { gCreatingSpriteTemplate = gSpriteTemplate_8208288[a2]; gCreatingSpriteTemplate.paletteTag = species; diff --git a/src/pokemon_3.c b/src/pokemon_3.c index 43c9b0d41..cc3f1e12e 100644 --- a/src/pokemon_3.c +++ b/src/pokemon_3.c @@ -24,9 +24,9 @@ #include "sprite.h" #include "string_util.h" #include "text.h" -#include "trainer.h" #include "util.h" #include "ewram.h" +#include "constants/trainers.h" extern u8 gPlayerPartyCount; extern u8 gEnemyPartyCount; @@ -43,7 +43,7 @@ extern u8 gDisplayedStringBattle[]; extern u8 gBattlerAttacker; extern u8 gBattlerTarget; extern u8 gPotentialItemEffectBattler; -extern u8 gBankInMenu; +extern u8 gBattlerInMenuId; extern struct SpindaSpot gSpindaSpotGraphics[]; extern s8 gNatureStatTable[][5]; extern u16 gTrainerBattleOpponent; @@ -197,7 +197,7 @@ const u8 gUnknown_082082F8[] = {1, 1, 3, 2, 4, 6}; void sub_803F324(int stat) { - gBattlerTarget = gBankInMenu; + gBattlerTarget = gBattlerInMenuId; StringCopy(gBattleTextBuff1, gUnknown_08400F58[gUnknown_082082F8[stat]]); StringCopy(gBattleTextBuff2, BattleText_Rose); BattleStringExpandPlaceholdersToDisplayedString(BattleText_UnknownString3); @@ -212,7 +212,7 @@ u8 *sub_803F378(u16 itemId) { if (gMain.inBattle) { - itemEffect = gEnigmaBerries[gBankInMenu].itemEffect; + itemEffect = gEnigmaBerries[gBattlerInMenuId].itemEffect; } else { @@ -224,7 +224,7 @@ u8 *sub_803F378(u16 itemId) itemEffect = gItemEffectTable[itemId - 13]; } - gPotentialItemEffectBattler = gBankInMenu; + gPotentialItemEffectBattler = gBattlerInMenuId; for (i = 0; i < 3; i++) { @@ -238,7 +238,7 @@ u8 *sub_803F378(u16 itemId) } else { - gBattlerAttacker = gBankInMenu; + gBattlerAttacker = gBattlerInMenuId; BattleStringExpandPlaceholdersToDisplayedString(BattleText_GetPumped); } } @@ -246,7 +246,7 @@ u8 *sub_803F378(u16 itemId) if (itemEffect[3] & 0x80) { - gBattlerAttacker = gBankInMenu; + gBattlerAttacker = gBattlerInMenuId; BattleStringExpandPlaceholdersToDisplayedString(BattleText_MistShroud); } @@ -1311,8 +1311,8 @@ void SetMonPreventsSwitchingString(void) gBattleTextBuff1[3] = gBattlerPartyIndexes[gBattleStruct->battlerPreventingSwitchout]; gBattleTextBuff2[0] = B_BUFF_PLACEHOLDER_BEGIN; gBattleTextBuff2[1] = B_BUFF_MON_NICK_WITH_PREFIX; - gBattleTextBuff2[2] = gBankInMenu; - gBattleTextBuff2[3] = pokemon_order_func(gBattlerPartyIndexes[gBankInMenu]); + gBattleTextBuff2[2] = gBattlerInMenuId; + gBattleTextBuff2[3] = pokemon_order_func(gBattlerPartyIndexes[gBattlerInMenuId]); gBattleTextBuff2[4] = B_BUFF_EOS; BattleStringExpandPlaceholders(BattleText_PreventedSwitch, gStringVar4); } diff --git a/src/pokemon_item_effect.c b/src/pokemon_item_effect.c index 2a2e73dc0..0bdd10ef0 100644 --- a/src/pokemon_item_effect.c +++ b/src/pokemon_item_effect.c @@ -18,7 +18,7 @@ extern s32 gBattleMoveDamage; extern u8 gAbsentBattlerFlags; -extern u8 gBankInMenu; +extern u8 gBattlerInMenuId; extern u8 gBattlersCount; extern u16 gBattlerPartyIndexes[]; extern u8 gActiveBattler; @@ -67,7 +67,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo if (heldItem == ITEM_ENIGMA_BERRY) { if (gMain.inBattle) - holdEffect = gEnigmaBerries[gBankInMenu].holdEffect; + holdEffect = gEnigmaBerries[gBattlerInMenuId].holdEffect; else holdEffect = gSaveBlock1.enigmaBerry.holdEffect; } @@ -76,10 +76,10 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo holdEffect = ItemId_GetHoldEffect(heldItem); } - gPotentialItemEffectBattler = gBankInMenu; + gPotentialItemEffectBattler = gBattlerInMenuId; if (gMain.inBattle) { - gActiveBattler = gBankInMenu; + gActiveBattler = gBattlerInMenuId; cmdIndex = (GetBattlerSide(gActiveBattler) != 0); while (cmdIndex < gBattlersCount) { diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index 3b88f03be..f62e2931e 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -1852,7 +1852,7 @@ static u8 SummaryScreen_LoadPokemonSprite(struct Pokemon *mon, u8 *state) palette = GetMonSpritePalStructFromOtIdPersonality(species, otId, personality); LoadCompressedObjectPalette(palette); - GetMonSpriteTemplate_803C56C(palette->tag, 1); + SetMultiuseSpriteTemplateToPokemon(palette->tag, 1); *state += 1; return 0xFF; } @@ -3744,7 +3744,7 @@ static void SummaryScreen_SpritePlayCry(struct Sprite *sprite) sprite->callback = SpriteCallbackDummy; if (!GetMonData(&pssData.loadedMon, MON_DATA_IS_EGG)) - PlayCry1(sprite->data[0], 0); + PlayCry_Normal(sprite->data[0], 0); } } diff --git a/src/reshow_battle_screen.c b/src/reshow_battle_screen.c index 8254921a4..671d98ee2 100644 --- a/src/reshow_battle_screen.c +++ b/src/reshow_battle_screen.c @@ -8,12 +8,13 @@ #include "rom_8077ABC.h" #include "data2.h" #include "ewram.h" +#include "constants/trainers.h" extern struct SpriteTemplate gCreatingSpriteTemplate; extern struct Window gWindowTemplate_Contest_MoveDescription; extern u8 gReservedSpritePaletteCount; extern u8 gActionSelectionCursor[4]; -extern u8 gBankInMenu; +extern u8 gBattlerInMenuId; extern u16 gBattlerPartyIndexes[4]; extern u8 gBattlersCount; extern u16 gBattleTypeFlags; @@ -30,16 +31,16 @@ void sub_800FCD4(void); void BattleLoadOpponentMonSprite(struct Pokemon *, u8 bank); void BattleLoadPlayerMonSprite(struct Pokemon *, u8 bank); void BattleLoadSubstituteSprite(u8 bank, u8 b); -void LoadPlayerTrainerBankSprite(u16 a0, u8 bank); +void DecompressTrainerBackPic(u16 a0, u8 bank); u8 sub_8077F7C(u8 bank); -u8 sub_8077F68(u8 bank); +u8 GetBattlerSpriteDefault_Y(u8 bank); void nullsub_11(u8 healthboxID, u8 a1); -void sub_8043DB0(u8 bank); +void SetHealthboxSpriteInvisible(u8 bank); u8 battle_make_oam_normal_battle(u8 bank); u8 battle_make_oam_safari_battle(void); -void sub_8045A5C(u8 healthboxID, struct Pokemon*, u8); +void UpdateHealthboxAttribute(u8 healthboxID, struct Pokemon*, u8); void sub_8043F44(u8 bank); -void sub_8043DFC(u8 healthboxID); +void SetHealthboxSpriteVisible(u8 healthboxID); // this file's functions static void CB2_ReshowBattleScreenAfterMenu(void); @@ -48,7 +49,7 @@ static void sub_807B184(u8 bank); static void sub_807B508(u8 bank); static void sub_807B06C(void); -void nullsub_14(void) +void ReshowBattleScreenDummy(void) { } @@ -173,7 +174,7 @@ static void CB2_ReshowBattleScreenAfterMenu(void) species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[opponentBank]], MON_DATA_SPECIES); sub_8032984(opponentBank, species); } - sub_802E3E4(gActionSelectionCursor[gBankInMenu], 0); + sub_802E3E4(gActionSelectionCursor[gBattlerInMenuId], 0); } break; default: @@ -201,16 +202,16 @@ static bool8 LoadAppropiateBankSprite(u8 bank) { if (GetBattlerSide(bank)) { - if (!gBattleSpriteInfo[bank].substituteSprite) + if (!gBattleSpriteInfo[bank].behindSubstitute) BattleLoadOpponentMonSprite(&gEnemyParty[gBattlerPartyIndexes[bank]], bank); else BattleLoadSubstituteSprite(bank, 0); } else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && bank == 0) - LoadPlayerTrainerBankSprite(gSaveBlock2.playerGender, 0); + DecompressTrainerBackPic(gSaveBlock2.playerGender, 0); else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && bank == 0) - LoadPlayerTrainerBankSprite(2, 0); - else if (!gBattleSpriteInfo[bank].substituteSprite) + DecompressTrainerBackPic(TRAINER_BACK_PIC_WALLY, 0); + else if (!gBattleSpriteInfo[bank].behindSubstitute) BattleLoadPlayerMonSprite(&gPlayerParty[gBattlerPartyIndexes[bank]], bank); else BattleLoadSubstituteSprite(bank, 0); @@ -226,16 +227,16 @@ static void sub_807B184(u8 bank) { u8 posY; - if (gBattleSpriteInfo[bank].substituteSprite) + if (gBattleSpriteInfo[bank].behindSubstitute) posY = sub_8077F7C(bank); else - posY = sub_8077F68(bank); + posY = GetBattlerSpriteDefault_Y(bank); if (GetBattlerSide(bank)) { if (GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_HP) == 0) return; - GetMonSpriteTemplate_803C56C(GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES), GetBattlerPosition(bank)); - gBattlerSpriteIds[bank] = CreateSprite(&gCreatingSpriteTemplate, GetBattlerSpriteCoord(bank, 2), posY, GetBattlerSubpriority(bank)); + SetMultiuseSpriteTemplateToPokemon(GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES), GetBattlerPosition(bank)); + gBattlerSpriteIds[bank] = CreateSprite(&gCreatingSpriteTemplate, GetBattlerSpriteCoord(bank, 2), posY, GetBattlerSpriteSubpriority(bank)); gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank; gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[bank]].data[0] = bank; @@ -244,20 +245,20 @@ static void sub_807B184(u8 bank) } else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && bank == 0) { - GetMonSpriteTemplate_803C5A0(gSaveBlock2.playerGender, GetBattlerPosition(0)); + SetMultiuseSpriteTemplateToTrainerBack(gSaveBlock2.playerGender, GetBattlerPosition(0)); gBattlerSpriteIds[bank] = CreateSprite(&gCreatingSpriteTemplate, 0x50, (8 - gTrainerBackPicCoords[gSaveBlock2.playerGender].coords) * 4 + 80, - GetBattlerSubpriority(0)); + GetBattlerSpriteSubpriority(0)); gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank; gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[bank]].data[0] = bank; } else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && bank == 0) { - GetMonSpriteTemplate_803C5A0(2, GetBattlerPosition(0)); + SetMultiuseSpriteTemplateToTrainerBack(TRAINER_BACK_PIC_WALLY, GetBattlerPosition(0)); gBattlerSpriteIds[bank] = CreateSprite(&gCreatingSpriteTemplate, 0x50, (8 - gTrainerBackPicCoords[2].coords) * 4 + 80, - GetBattlerSubpriority(0)); + GetBattlerSpriteSubpriority(0)); gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank; gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[bank]].data[0] = bank; @@ -266,8 +267,8 @@ static void sub_807B184(u8 bank) { if (GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_HP) == 0) return; - GetMonSpriteTemplate_803C56C(GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES), GetBattlerPosition(bank)); - gBattlerSpriteIds[bank] = CreateSprite(&gCreatingSpriteTemplate, GetBattlerSpriteCoord(bank, 2), posY, GetBattlerSubpriority(bank)); + SetMultiuseSpriteTemplateToPokemon(GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES), GetBattlerPosition(bank)); + gBattlerSpriteIds[bank] = CreateSprite(&gCreatingSpriteTemplate, GetBattlerSpriteCoord(bank, 2), posY, GetBattlerSpriteSubpriority(bank)); gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank; gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[bank]].data[0] = bank; @@ -291,13 +292,13 @@ static void sub_807B508(u8 bank) healthboxID = battle_make_oam_normal_battle(bank); gHealthboxSpriteIds[bank] = healthboxID; sub_8043F44(bank); - sub_8043DFC(healthboxID); + SetHealthboxSpriteVisible(healthboxID); if (GetBattlerSide(bank)) - sub_8045A5C(gHealthboxSpriteIds[bank], &gEnemyParty[gBattlerPartyIndexes[bank]], 0); + UpdateHealthboxAttribute(gHealthboxSpriteIds[bank], &gEnemyParty[gBattlerPartyIndexes[bank]], 0); else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) - sub_8045A5C(gHealthboxSpriteIds[bank], &gPlayerParty[gBattlerPartyIndexes[bank]], 10); + UpdateHealthboxAttribute(gHealthboxSpriteIds[bank], &gPlayerParty[gBattlerPartyIndexes[bank]], 10); else - sub_8045A5C(gHealthboxSpriteIds[bank], &gPlayerParty[gBattlerPartyIndexes[bank]], 0); + UpdateHealthboxAttribute(gHealthboxSpriteIds[bank], &gPlayerParty[gBattlerPartyIndexes[bank]], 0); if (GetBattlerPosition(bank) == 3 || GetBattlerPosition(bank) == 2) nullsub_11(gHealthboxSpriteIds[bank], 1); else @@ -305,12 +306,12 @@ static void sub_807B508(u8 bank) if (GetBattlerSide(bank)) { if (GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_HP) == 0) - sub_8043DB0(healthboxID); + SetHealthboxSpriteInvisible(healthboxID); } else if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI)) { if (GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_HP) == 0) - sub_8043DB0(healthboxID); + SetHealthboxSpriteInvisible(healthboxID); } } } diff --git a/src/rom_8077ABC.c b/src/rom_8077ABC.c index 09589184e..93d7df72a 100644 --- a/src/rom_8077ABC.c +++ b/src/rom_8077ABC.c @@ -182,18 +182,18 @@ u8 GetBattlerSpriteCoord(u8 slot, u8 a2) if (GetBattlerSide(slot)) { transform = &gBattleSpriteInfo[slot]; - if (!transform->transformedSpecies) + if (!transform->transformSpecies) species = GetMonData(&gEnemyParty[gBattleMonPartyPositions[slot]], MON_DATA_SPECIES); else - species = transform->transformedSpecies; + species = transform->transformSpecies; } else { transform = &gBattleSpriteInfo[slot]; - if (!transform->transformedSpecies) + if (!transform->transformSpecies) species = GetMonData(&gPlayerParty[gBattleMonPartyPositions[slot]], MON_DATA_SPECIES); else - species = transform->transformedSpecies; + species = transform->transformSpecies; } } if (a2 == 3) @@ -227,7 +227,7 @@ u8 sub_8077BFC(u8 slot, u16 species) else { transform = &gBattleSpriteInfo[slot]; - if (!transform->transformedSpecies) + if (!transform->transformSpecies) personality = GetMonData(&gPlayerParty[gBattleMonPartyPositions[slot]], MON_DATA_PERSONALITY); else personality = gTransformPersonalities[slot]; @@ -257,7 +257,7 @@ u8 sub_8077BFC(u8 slot, u16 species) if (species == SPECIES_UNOWN) { transform = &gBattleSpriteInfo[slot]; - if (!transform->transformedSpecies) + if (!transform->transformSpecies) personality = GetMonData(&gEnemyParty[gBattleMonPartyPositions[slot]], MON_DATA_PERSONALITY); else personality = gTransformPersonalities[slot]; @@ -343,10 +343,10 @@ u8 sub_8077EE4(u8 slot, u8 a2) else { transform = &gBattleSpriteInfo[slot]; - if (!transform->transformedSpecies) + if (!transform->transformSpecies) species = gAnimSpeciesByBanks[slot]; else - species = transform->transformedSpecies; + species = transform->transformSpecies; } if (a2 == 3) return GetBattlerSpriteFinal_Y(slot, species, 1); @@ -359,7 +359,7 @@ u8 sub_8077EE4(u8 slot, u8 a2) } } -u8 sub_8077F68(u8 slot) +u8 GetBattlerSpriteDefault_Y(u8 slot) { return GetBattlerSpriteCoord(slot, 4); } @@ -386,19 +386,19 @@ u8 sub_8077FC0(u8 slot) if (GetBattlerSide(slot) != 0) { transform = &gBattleSpriteInfo[slot]; - if (!transform->transformedSpecies) { + if (!transform->transformSpecies) { var = GetMonData(&gEnemyParty[gBattleMonPartyPositions[slot]], MON_DATA_SPECIES); } else { - var = transform->transformedSpecies; + var = transform->transformSpecies; } } else { transform = &gBattleSpriteInfo[slot]; - if (!transform->transformedSpecies) + if (!transform->transformSpecies) var = GetMonData(&gPlayerParty[gBattleMonPartyPositions[slot]], MON_DATA_SPECIES); else - var = transform->transformedSpecies; + var = transform->transformSpecies; } if (GetBattlerSide(slot) != 0) r6 -= sub_8077DD8(slot, var); @@ -778,7 +778,7 @@ bool8 TranslateAnimArc(struct Sprite *sprite) return FALSE; } -void oamt_add_pos2_onto_pos1(struct Sprite *sprite) +void SetSpritePrimaryCoordsFromSecondaryCoords(struct Sprite *sprite) { sprite->x += sprite->x2; sprite->y += sprite->y2; @@ -1168,7 +1168,7 @@ void PrepareBattlerSpriteForRotScale(u8 sprite, u8 objMode) gSprites[sprite].oam.objMode = objMode; gSprites[sprite].affineAnimPaused = TRUE; if (!IsContest() && !gSprites[sprite].oam.affineMode) - gSprites[sprite].oam.matrixNum = ewram17810[r7].unk6; + gSprites[sprite].oam.matrixNum = gBattleHealthBoxInfo[r7].unk6; gSprites[sprite].oam.affineMode = 3; CalcCenterToCornerVec(&gSprites[sprite], gSprites[sprite].oam.shape, gSprites[sprite].oam.size, gSprites[sprite].oam.affineMode); } @@ -1764,19 +1764,19 @@ u16 sub_8079B10(u8 sprite) if (!GetBattlerSide(i)) { transform = &gBattleSpriteInfo[slot]; - if (!transform->transformedSpecies) + if (!transform->transformSpecies) species = GetMonData(&gPlayerParty[gBattleMonPartyPositions[i]], MON_DATA_SPECIES); else - species = transform->transformedSpecies; + species = transform->transformSpecies; return gMonBackPicCoords[species].y_offset; } else { transform = &gBattleSpriteInfo[slot]; - if (!transform->transformedSpecies) + if (!transform->transformSpecies) species = GetMonData(&gEnemyParty[gBattleMonPartyPositions[i]], MON_DATA_SPECIES); else - species = transform->transformedSpecies; + species = transform->transformSpecies; return gMonFrontPicCoords[species].y_offset; } } @@ -1870,13 +1870,13 @@ void UpdateBattlerSpritePriorities() { if (IsAnimBankSpriteVisible(i)) { - gSprites[gBattleMonSprites[i]].subpriority = GetBattlerSubpriority(i); + gSprites[gBattleMonSprites[i]].subpriority = GetBattlerSpriteSubpriority(i); gSprites[gBattleMonSprites[i]].oam.priority = 2; } } } -u8 GetBattlerSubpriority(u8 bank) +u8 GetBattlerSpriteSubpriority(u8 bank) { u8 identity; u8 ret; @@ -2034,14 +2034,14 @@ s16 GetBattlerSpriteCoordAttr(u8 slot, u8 a2) if (!GetBattlerSide(slot)) { transform = &gBattleSpriteInfo[slot]; - if (!transform->transformedSpecies) + if (!transform->transformSpecies) { species = GetMonData(&gPlayerParty[gBattleMonPartyPositions[slot]], MON_DATA_SPECIES); personality = GetMonData(&gPlayerParty[gBattleMonPartyPositions[slot]], MON_DATA_PERSONALITY); } else { - species = transform->transformedSpecies; + species = transform->transformSpecies; personality = gTransformPersonalities[slot]; } if (species == SPECIES_UNOWN) @@ -2065,14 +2065,14 @@ s16 GetBattlerSpriteCoordAttr(u8 slot, u8 a2) else { transform = &gBattleSpriteInfo[slot]; - if (!transform->transformedSpecies) + if (!transform->transformSpecies) { species = GetMonData(&gEnemyParty[gBattleMonPartyPositions[slot]], MON_DATA_SPECIES); personality = GetMonData(&gEnemyParty[gBattleMonPartyPositions[slot]], MON_DATA_PERSONALITY); } else { - species = transform->transformedSpecies; + species = transform->transformSpecies; personality = gTransformPersonalities[slot]; } if (species == SPECIES_UNOWN) @@ -2241,7 +2241,7 @@ void sub_807A69C(u8 taskId) dest = (task->data[4] + 0x10) * 0x10; src = (gSprites[task->data[0]].oam.paletteNum + 0x10) * 0x10; - task->data[6] = GetBattlerSubpriority(gBattleAnimAttacker); + task->data[6] = GetBattlerSpriteSubpriority(gBattleAnimAttacker); if (task->data[6] == 20 || task->data[6] == 40) task->data[6] = 2; else diff --git a/src/roulette_gfx.c b/src/roulette_gfx.c index cf347f1ea..b5a489c4b 100644 --- a/src/roulette_gfx.c +++ b/src/roulette_gfx.c @@ -1667,13 +1667,13 @@ void sub_811952C(struct Sprite *sprite) if (eRoulette->var03_0) { if (sprite->data[0]) - PlayCry1(SPECIES_TAILLOW, -63); + PlayCry_Normal(SPECIES_TAILLOW, -63); else - PlayCry1(SPECIES_TAILLOW, 63); + PlayCry_Normal(SPECIES_TAILLOW, 63); } else { - PlayCry1(SPECIES_SHROOMISH, -63); + PlayCry_Normal(SPECIES_SHROOMISH, -63); } val = 2; @@ -1931,9 +1931,9 @@ void sub_8119BCC(struct Sprite *sprite) { m4aSongNumStartOrChange(SE_TAILLOW_WING_FLAP); if (eRoulette->var38->data[0] == 0) - PlayCry1(SPECIES_TAILLOW, 63); + PlayCry_Normal(SPECIES_TAILLOW, 63); else - PlayCry1(SPECIES_TAILLOW, -63); + PlayCry_Normal(SPECIES_TAILLOW, -63); StartSpriteAnim(sprite, eRoulette->var38->data[0] + 2); sprite->data[1] = 45; sprite->callback = sub_8119B24; diff --git a/src/sound.c b/src/sound.c index b365e0ca7..428751c95 100644 --- a/src/sound.c +++ b/src/sound.c @@ -294,7 +294,7 @@ bool8 IsBGMStopped(void) return FALSE; } -void PlayCry1(u16 species, s8 pan) +void PlayCry_Normal(u16 species, s8 pan) { m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 85); PlayCryInternal(species, pan, 125, 10, 0); diff --git a/src/starter_choose.c b/src/starter_choose.c index eb10294f5..1ef4f749c 100644 --- a/src/starter_choose.c +++ b/src/starter_choose.c @@ -423,7 +423,7 @@ static void Task_StarterChoose3(u8 taskId) static void Task_StarterChoose4(u8 taskId) { - PlayCry1(GetStarterPokemon(gTasks[taskId].tStarterSelection), 0); + PlayCry_Normal(GetStarterPokemon(gTasks[taskId].tStarterSelection), 0); Menu_DrawStdWindowFrame(2, 14, 27, 19); //"Do you choose this POKEMON?" Menu_PrintText(gOtherText_DoYouChoosePoke, 3, 15); @@ -575,7 +575,7 @@ static u8 CreatePokemonFrontSprite(u16 species, u8 x, u8 y) gMonSpriteGfx_Sprite_ptr[0], gMonSpriteGfx_Sprite_ptr[1], species); LoadCompressedObjectPalette(&gMonPaletteTable[species]); - GetMonSpriteTemplate_803C56C(species, 1); + SetMultiuseSpriteTemplateToPokemon(species, 1); spriteId = CreateSprite(&gCreatingSpriteTemplate, x, y, 0); gSprites[spriteId].callback = nullsub_72; gSprites[spriteId].oam.priority = 0; diff --git a/src/trade.c b/src/trade.c index b3a714da5..86f20811a 100644 --- a/src/trade.c +++ b/src/trade.c @@ -3527,7 +3527,7 @@ static void sub_804B2D0(u8 whichParty, u8 a1) gUnknown_03004828->tradeSpecies[whichParty] = species; break; case 1: - GetMonSpriteTemplate_803C56C(GetMonSpritePalStruct(pokemon)->tag, v0); + SetMultiuseSpriteTemplateToPokemon(GetMonSpritePalStruct(pokemon)->tag, v0); gUnknown_03004828->pokePicSpriteIdxs[whichParty] = CreateSprite(&gCreatingSpriteTemplate, 0x78, 0x3c, 0x6); gSprites[gUnknown_03004828->pokePicSpriteIdxs[whichParty]].invisible = TRUE; gSprites[gUnknown_03004828->pokePicSpriteIdxs[whichParty]].callback = SpriteCallbackDummy; diff --git a/sym_common.txt b/sym_common.txt index bb34a287f..3d6081baa 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -134,7 +134,7 @@ SYMBOL(gBattlerControllerFuncs, 16) SYMBOL(gHealthboxSpriteIds, 4) SYMBOL(gUnknown_03004344, 4) SYMBOL(gUnknown_03004348, 4) -SYMBOL(gUnknown_0300434C, 4) +SYMBOL(gBattleControllerData, 4) // pokemon_1.c SYMBOL(gPlayerPartyCount, 4) diff --git a/sym_ewram.txt b/sym_ewram.txt index 16cf5ca0c..c475836fd 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -261,10 +261,10 @@ gActionSelectionCursor = .; /* 2024E60 */ gMoveSelectionCursor = .; /* 2024E64 */ . += 0x4; -gUnknown_02024E68 = .; /* 2024E68 */ +gBattlerStatusSummaryTaskId = .; /* 2024E68 */ . += 0x4; -gBankInMenu = .; /* 2024E6C */ +gBattlerInMenuId = .; /* 2024E6C */ . += 0x1; gDoingBattleAnim = .; /* 2024E6D */