document battle bars

This commit is contained in:
DizzyEggg 2018-06-19 00:43:15 +02:00
parent caa36b530a
commit 94752d4207
15 changed files with 468 additions and 446 deletions

View File

@ -692,9 +692,9 @@ struct BattleBarInfo
{ {
u8 healthboxSpriteId; u8 healthboxSpriteId;
s32 maxValue; s32 maxValue;
s32 currentValue; s32 oldValue;
s32 receivedValue; s32 receivedValue;
s32 field_10; s32 currValue;
}; };
struct BattleSpriteData struct BattleSpriteData

View File

@ -35,7 +35,7 @@ void ClearBehindSubstituteBit(u8 battlerId);
void HandleLowHpMusicChange(struct Pokemon *mon, u8 battlerId); void HandleLowHpMusicChange(struct Pokemon *mon, u8 battlerId);
void BattleStopLowHpSound(void); void BattleStopLowHpSound(void);
u8 GetMonHPBarLevel(struct Pokemon *mon); u8 GetMonHPBarLevel(struct Pokemon *mon);
void sub_805EAE8(void); void HandleBattleLowHpMusicChange(void);
void sub_805EB9C(u8 affineMode); void sub_805EB9C(u8 affineMode);
void LoadAndCreateEnemyShadowSprites(void); void LoadAndCreateEnemyShadowSprites(void);
void SpriteCB_SetInvisible(struct Sprite *sprite); void SpriteCB_SetInvisible(struct Sprite *sprite);
@ -45,6 +45,6 @@ void sub_805EF14(void);
void ClearTemporarySpeciesSpriteData(u8 battlerId, bool8 dontClearSubstitute); void ClearTemporarySpeciesSpriteData(u8 battlerId, bool8 dontClearSubstitute);
void AllocateMonSpritesGfx(void); void AllocateMonSpritesGfx(void);
void FreeMonSpritesGfx(void); void FreeMonSpritesGfx(void);
bool32 ShouldPlayNormalPokeCry(struct Pokemon *mon); bool32 ShouldPlayNormalMonCry(struct Pokemon *mon);
#endif // GUARD_BATTLE_GFX_SFX_UTIL #endif // GUARD_BATTLE_GFX_SFX_UTIL

View File

@ -29,12 +29,18 @@ enum
#define TAG_HEALTHBOX_OPPONENT1_TILE 0xD701 #define TAG_HEALTHBOX_OPPONENT1_TILE 0xD701
#define TAG_HEALTHBOX_OPPONENT2_TILE 0xD702 #define TAG_HEALTHBOX_OPPONENT2_TILE 0xD702
#define TAG_HEALTHBAR_PLAYER1_TILE 0xD704
#define TAG_HEALTHBAR_OPPONENT1_TILE 0xD705
#define TAG_HEALTHBAR_PLAYER2_TILE 0xD706
#define TAG_HEALTHBAR_OPPONENT2_TILE 0xD707
#define TAG_HEALTHBOX_SAFARI_TILE 0xD70B #define TAG_HEALTHBOX_SAFARI_TILE 0xD70B
#define TAG_STATUS_SUMMARY_BAR_TILE 0xD70C #define TAG_STATUS_SUMMARY_BAR_TILE 0xD70C
#define TAG_STATUS_SUMMARY_BALLS_TILE 0xD714 #define TAG_STATUS_SUMMARY_BALLS_TILE 0xD714
#define TAG_HEALTHBOX_PAL 0xD6FF #define TAG_HEALTHBOX_PAL 0xD6FF
#define TAG_HEALTHBAR_PAL 0xD704
#define TAG_STATUS_SUMMARY_BAR_PAL 0xD710 #define TAG_STATUS_SUMMARY_BAR_PAL 0xD710
#define TAG_STATUS_SUMMARY_BALLS_PAL 0xD712 #define TAG_STATUS_SUMMARY_BALLS_PAL 0xD712
@ -68,7 +74,7 @@ void SwapHpBarsWithHpText(void);
u8 CreatePartyStatusSummarySprites(u8 bank, struct HpAndStatus *partyInfo, u8 arg2, bool8 isBattleStart); u8 CreatePartyStatusSummarySprites(u8 bank, struct HpAndStatus *partyInfo, u8 arg2, bool8 isBattleStart);
void sub_8073C30(u8 taskId); void sub_8073C30(u8 taskId);
void UpdateHealthboxAttribute(u8 healthboxSpriteId, struct Pokemon *mon, u8 elementId); void UpdateHealthboxAttribute(u8 healthboxSpriteId, struct Pokemon *mon, u8 elementId);
s32 sub_8074AA0(u8 bank, u8 healthboxSpriteId, u8 whichBar, u8 arg3); s32 MoveBattleBar(u8 bank, u8 healthboxSpriteId, u8 whichBar, u8 arg3);
u8 GetScaledHPFraction(s16 hp, s16 maxhp, u8 scale); u8 GetScaledHPFraction(s16 hp, s16 maxhp, u8 scale);
u8 GetHPBarLevel(s16 hp, s16 maxhp); u8 GetHPBarLevel(s16 hp, s16 maxhp);

View File

@ -395,7 +395,7 @@ static void sub_8064B04(void)
static void CompleteOnHealthbarDone(void) static void CompleteOnHealthbarDone(void)
{ {
s16 hpValue = sub_8074AA0(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0); s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);

View File

@ -279,7 +279,7 @@ static void sub_814B290(void)
static void CompleteOnHealthbarDone(void) static void CompleteOnHealthbarDone(void)
{ {
s16 hpValue = sub_8074AA0(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0); s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);

View File

@ -391,7 +391,7 @@ static void sub_805F994(void)
static void CompleteOnHealthbarDone(void) static void CompleteOnHealthbarDone(void)
{ {
s16 hpValue = sub_8074AA0(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0); s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1) if (hpValue != -1)
{ {

View File

@ -1120,7 +1120,7 @@ void c3_0802FDF4(u8 taskId)
static void CompleteOnHealthbarDone(void) static void CompleteOnHealthbarDone(void)
{ {
s16 hpValue = sub_8074AA0(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0); s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
@ -1224,7 +1224,7 @@ static void sub_8059400(u8 taskId)
u8 battlerId = gTasks[taskId].tExpTask_bank; u8 battlerId = gTasks[taskId].tExpTask_bank;
s16 r4; s16 r4;
r4 = sub_8074AA0(battlerId, gHealthboxSpriteIds[battlerId], EXP_BAR, 0); r4 = MoveBattleBar(battlerId, gHealthboxSpriteIds[battlerId], EXP_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battlerId]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[battlerId]);
if (r4 == -1) if (r4 == -1)
{ {

View File

@ -294,7 +294,7 @@ static void sub_81BB1D4(void)
static void CompleteOnHealthbarDone(void) static void CompleteOnHealthbarDone(void)
{ {
s16 hpValue = sub_8074AA0(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0); s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
@ -399,7 +399,7 @@ static void sub_81BB4E4(u8 taskId)
u8 battlerId = gTasks[taskId].tExpTask_bank; u8 battlerId = gTasks[taskId].tExpTask_bank;
s16 r4; s16 r4;
r4 = sub_8074AA0(battlerId, gHealthboxSpriteIds[battlerId], EXP_BAR, 0); r4 = MoveBattleBar(battlerId, gHealthboxSpriteIds[battlerId], EXP_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battlerId]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[battlerId]);
if (r4 == -1) if (r4 == -1)
{ {

View File

@ -377,7 +377,7 @@ static void sub_8186C48(void)
static void CompleteOnHealthbarDone(void) static void CompleteOnHealthbarDone(void)
{ {
s16 hpValue = sub_8074AA0(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0); s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);

View File

@ -363,7 +363,7 @@ static void sub_818A064(void)
static void CompleteOnHealthbarDone(void) static void CompleteOnHealthbarDone(void)
{ {
s16 hpValue = sub_8074AA0(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0); s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);

View File

@ -349,7 +349,7 @@ static void sub_8168818(void)
static void CompleteOnHealthbarDone(void) static void CompleteOnHealthbarDone(void)
{ {
s16 hpValue = sub_8074AA0(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0); s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);

View File

@ -587,7 +587,7 @@ static void SetBattlePartyIds(void)
{ {
for (i = 0; i < gBattlersCount; i++) for (i = 0; i < gBattlersCount; i++)
{ {
for (j = 0; j < 6; j++) for (j = 0; j < PARTY_SIZE; j++)
{ {
if (i < 2) if (i < 2)
{ {

View File

@ -67,7 +67,7 @@ static void sub_805D7EC(struct Sprite *sprite);
static bool8 ShouldAnimBeDoneRegardlessOfSubsitute(u8 animId); static bool8 ShouldAnimBeDoneRegardlessOfSubsitute(u8 animId);
static void Task_ClearBitWhenBattleTableAnimDone(u8 taskId); static void Task_ClearBitWhenBattleTableAnimDone(u8 taskId);
static void Task_ClearBitWhenSpecialAnimDone(u8 taskId); static void Task_ClearBitWhenSpecialAnimDone(u8 taskId);
static void ClearSpritesBankHealthboxAnimData(void); static void ClearSpritesBattlerHealthboxAnimData(void);
// const rom data // const rom data
static const struct CompressedSpriteSheet gUnknown_0832C0D0 = static const struct CompressedSpriteSheet gUnknown_0832C0D0 =
@ -411,35 +411,35 @@ void InitAndLaunchChosenStatusAnimation(bool8 isStatus2, u32 status)
#define tBattlerId data[0] #define tBattlerId data[0]
bool8 TryHandleLaunchBattleTableAnimation(u8 activeBank, u8 atkBank, u8 defBank, u8 tableId, u16 argument) bool8 TryHandleLaunchBattleTableAnimation(u8 activeBattler, u8 atkBattler, u8 defBattler, u8 tableId, u16 argument)
{ {
u8 taskId; u8 taskId;
if (tableId == B_ANIM_CASTFORM_CHANGE && (argument & 0x80)) if (tableId == B_ANIM_CASTFORM_CHANGE && (argument & 0x80))
{ {
gBattleMonForms[activeBank] = (argument & ~(0x80)); gBattleMonForms[activeBattler] = (argument & ~(0x80));
return TRUE; return TRUE;
} }
if (gBattleSpritesDataPtr->battlerData[activeBank].behindSubstitute if (gBattleSpritesDataPtr->battlerData[activeBattler].behindSubstitute
&& !ShouldAnimBeDoneRegardlessOfSubsitute(tableId)) && !ShouldAnimBeDoneRegardlessOfSubsitute(tableId))
{ {
return TRUE; return TRUE;
} }
if (gBattleSpritesDataPtr->battlerData[activeBank].behindSubstitute if (gBattleSpritesDataPtr->battlerData[activeBattler].behindSubstitute
&& tableId == B_ANIM_SUBSTITUTE_FADE && tableId == B_ANIM_SUBSTITUTE_FADE
&& gSprites[gBattlerSpriteIds[activeBank]].invisible) && gSprites[gBattlerSpriteIds[activeBattler]].invisible)
{ {
LoadBattleMonGfxAndAnimate(activeBank, TRUE, gBattlerSpriteIds[activeBank]); LoadBattleMonGfxAndAnimate(activeBattler, TRUE, gBattlerSpriteIds[activeBattler]);
ClearBehindSubstituteBit(activeBank); ClearBehindSubstituteBit(activeBattler);
return TRUE; return TRUE;
} }
gBattleAnimAttacker = atkBank; gBattleAnimAttacker = atkBattler;
gBattleAnimTarget = defBank; gBattleAnimTarget = defBattler;
gBattleSpritesDataPtr->animationData->animArg = argument; gBattleSpritesDataPtr->animationData->animArg = argument;
LaunchBattleAnimation(gBattleAnims_VariousTable, tableId, FALSE); LaunchBattleAnimation(gBattleAnims_VariousTable, tableId, FALSE);
taskId = CreateTask(Task_ClearBitWhenBattleTableAnimDone, 10); taskId = CreateTask(Task_ClearBitWhenBattleTableAnimDone, 10);
gTasks[taskId].tBattlerId = activeBank; gTasks[taskId].tBattlerId = activeBattler;
gBattleSpritesDataPtr->healthBoxesData[gTasks[taskId].tBattlerId].animFromTableActive = 1; gBattleSpritesDataPtr->healthBoxesData[gTasks[taskId].tBattlerId].animFromTableActive = 1;
return FALSE; return FALSE;
@ -475,15 +475,15 @@ static bool8 ShouldAnimBeDoneRegardlessOfSubsitute(u8 animId)
#define tBattlerId data[0] #define tBattlerId data[0]
void InitAndLaunchSpecialAnimation(u8 activeBank, u8 atkBank, u8 defBank, u8 tableId) void InitAndLaunchSpecialAnimation(u8 activeBattler, u8 atkBattler, u8 defBattler, u8 tableId)
{ {
u8 taskId; u8 taskId;
gBattleAnimAttacker = atkBank; gBattleAnimAttacker = atkBattler;
gBattleAnimTarget = defBank; gBattleAnimTarget = defBattler;
LaunchBattleAnimation(gBattleAnims_Special, tableId, FALSE); LaunchBattleAnimation(gBattleAnims_Special, tableId, FALSE);
taskId = CreateTask(Task_ClearBitWhenSpecialAnimDone, 10); taskId = CreateTask(Task_ClearBitWhenSpecialAnimDone, 10);
gTasks[taskId].tBattlerId = activeBank; gTasks[taskId].tBattlerId = activeBattler;
gBattleSpritesDataPtr->healthBoxesData[gTasks[taskId].tBattlerId].specialAnimActive = 1; gBattleSpritesDataPtr->healthBoxesData[gTasks[taskId].tBattlerId].specialAnimActive = 1;
} }
@ -681,7 +681,7 @@ void FreeTrainerFrontPicPalette(u16 frontPicId)
void sub_805DFFC(void) void sub_805DFFC(void)
{ {
u8 numberOfBanks = 0; u8 numberOfBattlers = 0;
u8 i; u8 i;
LoadSpritePalette(&gUnknown_0832C128[0]); LoadSpritePalette(&gUnknown_0832C128[0]);
@ -690,7 +690,7 @@ void sub_805DFFC(void)
{ {
LoadCompressedObjectPic(&gUnknown_0832C0D0); LoadCompressedObjectPic(&gUnknown_0832C0D0);
LoadCompressedObjectPic(&gUnknown_0832C0D8); LoadCompressedObjectPic(&gUnknown_0832C0D8);
numberOfBanks = 2; numberOfBattlers = 2;
} }
else else
{ {
@ -698,9 +698,9 @@ void sub_805DFFC(void)
LoadCompressedObjectPic(&gUnknown_0832C0E0[1]); LoadCompressedObjectPic(&gUnknown_0832C0E0[1]);
LoadCompressedObjectPic(&gUnknown_0832C0F0[0]); LoadCompressedObjectPic(&gUnknown_0832C0F0[0]);
LoadCompressedObjectPic(&gUnknown_0832C0F0[1]); LoadCompressedObjectPic(&gUnknown_0832C0F0[1]);
numberOfBanks = 4; numberOfBattlers = 4;
} }
for (i = 0; i < numberOfBanks; i++) for (i = 0; i < numberOfBattlers; i++)
LoadCompressedObjectPic(&gUnknown_0832C108[gBattlerPositions[i]]); LoadCompressedObjectPic(&gUnknown_0832C108[gBattlerPositions[i]]);
} }
@ -771,7 +771,7 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *battlerId)
switch (*state1) switch (*state1)
{ {
case 0: case 0:
ClearSpritesBankHealthboxAnimData(); ClearSpritesBattlerHealthboxAnimData();
(*state1)++; (*state1)++;
break; break;
case 1: case 1:
@ -849,7 +849,7 @@ void ClearSpritesHealthboxAnimData(void)
memset(gBattleSpritesDataPtr->animationData, 0, sizeof(struct BattleAnimationInfo)); memset(gBattleSpritesDataPtr->animationData, 0, sizeof(struct BattleAnimationInfo));
} }
static void ClearSpritesBankHealthboxAnimData(void) static void ClearSpritesBattlerHealthboxAnimData(void)
{ {
ClearSpritesHealthboxAnimData(); ClearSpritesHealthboxAnimData();
memset(gBattleSpritesDataPtr->battlerData, 0, sizeof(struct BattleSpriteInfo) * MAX_BATTLERS_COUNT); memset(gBattleSpritesDataPtr->battlerData, 0, sizeof(struct BattleSpriteInfo) * MAX_BATTLERS_COUNT);
@ -868,7 +868,7 @@ void CopyBattleSpriteInvisibility(u8 battlerId)
gBattleSpritesDataPtr->battlerData[battlerId].invisible = gSprites[gBattlerSpriteIds[battlerId]].invisible; gBattleSpritesDataPtr->battlerData[battlerId].invisible = gSprites[gBattlerSpriteIds[battlerId]].invisible;
} }
void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform) void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool8 notTransform)
{ {
u16 paletteOffset; u16 paletteOffset;
u32 personalityValue; u32 personalityValue;
@ -878,16 +878,16 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
if (notTransform) if (notTransform)
{ {
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bankAtk]], gBattleSpritesDataPtr->animationData->animArg); StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerAtk]], gBattleSpritesDataPtr->animationData->animArg);
paletteOffset = 0x100 + bankAtk * 16; paletteOffset = 0x100 + battlerAtk * 16;
LoadPalette(gBattleStruct->castformPalette[gBattleSpritesDataPtr->animationData->animArg], paletteOffset, 32); LoadPalette(gBattleStruct->castformPalette[gBattleSpritesDataPtr->animationData->animArg], paletteOffset, 32);
gBattleMonForms[bankAtk] = gBattleSpritesDataPtr->animationData->animArg; gBattleMonForms[battlerAtk] = gBattleSpritesDataPtr->animationData->animArg;
if (gBattleSpritesDataPtr->battlerData[bankAtk].transformSpecies != SPECIES_NONE) if (gBattleSpritesDataPtr->battlerData[battlerAtk].transformSpecies != SPECIES_NONE)
{ {
BlendPalette(paletteOffset, 16, 6, RGB_WHITE); BlendPalette(paletteOffset, 16, 6, RGB_WHITE);
CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32); CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32);
} }
gSprites[gBattlerSpriteIds[bankAtk]].pos1.y = GetBattlerSpriteDefault_Y(bankAtk); gSprites[gBattlerSpriteIds[battlerAtk]].pos1.y = GetBattlerSpriteDefault_Y(battlerAtk);
} }
else else
{ {
@ -909,48 +909,48 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
} }
else else
{ {
position = GetBattlerPosition(bankAtk); position = GetBattlerPosition(battlerAtk);
if (GetBattlerSide(bankDef) == B_SIDE_OPPONENT) if (GetBattlerSide(battlerDef) == B_SIDE_OPPONENT)
targetSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bankDef]], MON_DATA_SPECIES); targetSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerDef]], MON_DATA_SPECIES);
else else
targetSpecies = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bankDef]], MON_DATA_SPECIES); targetSpecies = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerDef]], MON_DATA_SPECIES);
if (GetBattlerSide(bankAtk) == B_SIDE_PLAYER) if (GetBattlerSide(battlerAtk) == B_SIDE_PLAYER)
{ {
personalityValue = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bankAtk]], MON_DATA_PERSONALITY); personalityValue = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerAtk]], MON_DATA_PERSONALITY);
otId = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bankAtk]], MON_DATA_OT_ID); otId = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerAtk]], MON_DATA_OT_ID);
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[targetSpecies], HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[targetSpecies],
gMonSpritesGfxPtr->sprites[position], gMonSpritesGfxPtr->sprites[position],
targetSpecies, targetSpecies,
gTransformedPersonalities[bankAtk]); gTransformedPersonalities[battlerAtk]);
} }
else else
{ {
personalityValue = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bankAtk]], MON_DATA_PERSONALITY); personalityValue = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerAtk]], MON_DATA_PERSONALITY);
otId = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bankAtk]], MON_DATA_OT_ID); otId = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerAtk]], MON_DATA_OT_ID);
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[targetSpecies], HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[targetSpecies],
gMonSpritesGfxPtr->sprites[position], gMonSpritesGfxPtr->sprites[position],
targetSpecies, targetSpecies,
gTransformedPersonalities[bankAtk]); gTransformedPersonalities[battlerAtk]);
} }
} }
src = gMonSpritesGfxPtr->sprites[position]; src = gMonSpritesGfxPtr->sprites[position];
dst = (void *)(VRAM + 0x10000 + gSprites[gBattlerSpriteIds[bankAtk]].oam.tileNum * 32); dst = (void *)(VRAM + 0x10000 + gSprites[gBattlerSpriteIds[battlerAtk]].oam.tileNum * 32);
DmaCopy32(3, src, dst, 0x800); DmaCopy32(3, src, dst, 0x800);
paletteOffset = 0x100 + bankAtk * 16; paletteOffset = 0x100 + battlerAtk * 16;
lzPaletteData = GetFrontSpritePalFromSpeciesAndPersonality(targetSpecies, otId, personalityValue); lzPaletteData = GetFrontSpritePalFromSpeciesAndPersonality(targetSpecies, otId, personalityValue);
LZDecompressWram(lzPaletteData, gDecompressionBuffer); LZDecompressWram(lzPaletteData, gDecompressionBuffer);
LoadPalette(gDecompressionBuffer, paletteOffset, 32); LoadPalette(gDecompressionBuffer, paletteOffset, 32);
if (targetSpecies == SPECIES_CASTFORM) if (targetSpecies == SPECIES_CASTFORM)
{ {
gSprites[gBattlerSpriteIds[bankAtk]].anims = gMonAnimationsSpriteAnimsPtrTable[targetSpecies]; gSprites[gBattlerSpriteIds[battlerAtk]].anims = gMonAnimationsSpriteAnimsPtrTable[targetSpecies];
LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette[0]); LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette[0]);
LoadPalette(gBattleStruct->castformPalette[0] + gBattleMonForms[bankDef] * 16, paletteOffset, 32); LoadPalette(gBattleStruct->castformPalette[0] + gBattleMonForms[battlerDef] * 16, paletteOffset, 32);
} }
BlendPalette(paletteOffset, 16, 6, RGB_WHITE); BlendPalette(paletteOffset, 16, 6, RGB_WHITE);
@ -958,12 +958,12 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
if (!IsContest()) if (!IsContest())
{ {
gBattleSpritesDataPtr->battlerData[bankAtk].transformSpecies = targetSpecies; gBattleSpritesDataPtr->battlerData[battlerAtk].transformSpecies = targetSpecies;
gBattleMonForms[bankAtk] = gBattleMonForms[bankDef]; gBattleMonForms[battlerAtk] = gBattleMonForms[battlerDef];
} }
gSprites[gBattlerSpriteIds[bankAtk]].pos1.y = GetBattlerSpriteDefault_Y(bankAtk); gSprites[gBattlerSpriteIds[battlerAtk]].pos1.y = GetBattlerSpriteDefault_Y(battlerAtk);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bankAtk]], gBattleMonForms[bankAtk]); StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerAtk]], gBattleMonForms[battlerAtk]);
} }
} }
@ -1068,11 +1068,11 @@ void HandleLowHpMusicChange(struct Pokemon *mon, u8 battlerId)
void BattleStopLowHpSound(void) void BattleStopLowHpSound(void)
{ {
u8 playerBank = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); u8 playerBattler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
gBattleSpritesDataPtr->battlerData[playerBank].lowHpSong = 0; gBattleSpritesDataPtr->battlerData[playerBattler].lowHpSong = 0;
if (IsDoubleBattle()) if (IsDoubleBattle())
gBattleSpritesDataPtr->battlerData[playerBank ^ BIT_FLANK].lowHpSong = 0; gBattleSpritesDataPtr->battlerData[playerBattler ^ BIT_FLANK].lowHpSong = 0;
m4aSongNumStop(SE_HINSI); m4aSongNumStop(SE_HINSI);
} }
@ -1085,19 +1085,19 @@ u8 GetMonHPBarLevel(struct Pokemon *mon)
return GetHPBarLevel(hp, maxHP); return GetHPBarLevel(hp, maxHP);
} }
void sub_805EAE8(void) void HandleBattleLowHpMusicChange(void)
{ {
if (gMain.inBattle) if (gMain.inBattle)
{ {
u8 playerBank1 = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); u8 playerBattler1 = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
u8 playerBank2 = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); u8 playerBattler2 = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
u8 bank1PartyId = pokemon_order_func(gBattlerPartyIndexes[playerBank1]); u8 battler1PartyId = pokemon_order_func(gBattlerPartyIndexes[playerBattler1]);
u8 bank2PartyId = pokemon_order_func(gBattlerPartyIndexes[playerBank2]); u8 battler2PartyId = pokemon_order_func(gBattlerPartyIndexes[playerBattler2]);
if (GetMonData(&gPlayerParty[bank1PartyId], MON_DATA_HP) != 0) if (GetMonData(&gPlayerParty[battler1PartyId], MON_DATA_HP) != 0)
HandleLowHpMusicChange(&gPlayerParty[bank1PartyId], playerBank1); HandleLowHpMusicChange(&gPlayerParty[battler1PartyId], playerBattler1);
if (IsDoubleBattle() && GetMonData(&gPlayerParty[bank2PartyId], MON_DATA_HP) != 0) if (IsDoubleBattle() && GetMonData(&gPlayerParty[battler2PartyId], MON_DATA_HP) != 0)
HandleLowHpMusicChange(&gPlayerParty[bank2PartyId], playerBank2); HandleLowHpMusicChange(&gPlayerParty[battler2PartyId], playerBattler2);
} }
} }
@ -1147,14 +1147,14 @@ void SpriteCB_EnemyShadow(struct Sprite *shadowSprite)
{ {
bool8 invisible = FALSE; bool8 invisible = FALSE;
u8 battlerId = shadowSprite->tBattlerId; u8 battlerId = shadowSprite->tBattlerId;
struct Sprite *bankSprite = &gSprites[gBattlerSpriteIds[battlerId]]; struct Sprite *battlerSprite = &gSprites[gBattlerSpriteIds[battlerId]];
if (!bankSprite->inUse || !IsBattlerSpritePresent(battlerId)) if (!battlerSprite->inUse || !IsBattlerSpritePresent(battlerId))
{ {
shadowSprite->callback = SpriteCB_SetInvisible; shadowSprite->callback = SpriteCB_SetInvisible;
return; return;
} }
if (gAnimScriptActive || bankSprite->invisible) if (gAnimScriptActive || battlerSprite->invisible)
invisible = TRUE; invisible = TRUE;
else if (gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies != SPECIES_NONE else if (gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies != SPECIES_NONE
&& gEnemyMonElevation[gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies] == 0) && gEnemyMonElevation[gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies] == 0)
@ -1163,8 +1163,8 @@ void SpriteCB_EnemyShadow(struct Sprite *shadowSprite)
if (gBattleSpritesDataPtr->battlerData[battlerId].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[battlerId].behindSubstitute)
invisible = TRUE; invisible = TRUE;
shadowSprite->pos1.x = bankSprite->pos1.x; shadowSprite->pos1.x = battlerSprite->pos1.x;
shadowSprite->pos2.x = bankSprite->pos2.x; shadowSprite->pos2.x = battlerSprite->pos2.x;
shadowSprite->invisible = invisible; shadowSprite->invisible = invisible;
} }
@ -1177,7 +1177,7 @@ void SpriteCB_SetInvisible(struct Sprite *sprite)
void SetBattlerShadowSpriteCallback(u8 battlerId, u16 species) void SetBattlerShadowSpriteCallback(u8 battlerId, u16 species)
{ {
// The player's shadow is never seen // The player's shadow is never seen.
if (GetBattlerSide(battlerId) == B_SIDE_PLAYER) if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
return; return;
@ -1270,7 +1270,7 @@ void FreeMonSpritesGfx(void)
FREE_AND_SET_NULL(gMonSpritesGfxPtr); FREE_AND_SET_NULL(gMonSpritesGfxPtr);
} }
bool32 ShouldPlayNormalPokeCry(struct Pokemon *mon) bool32 ShouldPlayNormalMonCry(struct Pokemon *mon)
{ {
s16 hp, maxHP; s16 hp, maxHP;
s32 barLevel; s32 barLevel;

File diff suppressed because it is too large Load Diff

View File

@ -665,7 +665,7 @@ static void Task_PlayCryWhenReleasedFromBall(u8 taskId)
gTasks[taskId].tCryTaskState = wantedCry + 1; gTasks[taskId].tCryTaskState = wantedCry + 1;
break; break;
case 1: case 1:
if (ShouldPlayNormalPokeCry(mon) == TRUE) if (ShouldPlayNormalMonCry(mon) == TRUE)
PlayCry3(species, pan, 0); PlayCry3(species, pan, 0);
else else
PlayCry3(species, pan, 11); PlayCry3(species, pan, 11);
@ -680,7 +680,7 @@ static void Task_PlayCryWhenReleasedFromBall(u8 taskId)
case 20: case 20:
if (gTasks[taskId].tCryTaskFrames == 0) if (gTasks[taskId].tCryTaskFrames == 0)
{ {
if (ShouldPlayNormalPokeCry(mon) == TRUE) if (ShouldPlayNormalMonCry(mon) == TRUE)
PlayCry4(species, pan, 1); PlayCry4(species, pan, 1);
else else
PlayCry4(species, pan, 12); PlayCry4(species, pan, 12);
@ -719,7 +719,7 @@ static void Task_PlayCryWhenReleasedFromBall(u8 taskId)
gTasks[taskId].tCryTaskFrames--; gTasks[taskId].tCryTaskFrames--;
break; break;
} }
if (ShouldPlayNormalPokeCry(mon) == TRUE) if (ShouldPlayNormalMonCry(mon) == TRUE)
PlayCry4(species, pan, 0); PlayCry4(species, pan, 0);
else else
PlayCry4(species, pan, 11); PlayCry4(species, pan, 11);