Fix Castfrom ability pop-up and refactor one function

This commit is contained in:
DizzyEggg 2019-06-14 12:58:29 +02:00
parent 594b363730
commit aaea5398f4
2 changed files with 74 additions and 122 deletions

View File

@ -6257,6 +6257,7 @@ BattleScript_CastformChange::
end3 end3
BattleScript_82DB4AF:: BattleScript_82DB4AF::
copybyte gBattlerAbility, sBATTLER
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
docastformchangeanimation docastformchangeanimation
waitstate waitstate

View File

@ -505,16 +505,12 @@ bool8 mplay_80342A4(u8 battlerId)
return TRUE; return TRUE;
} }
void BattleLoadOpponentMonSpriteGfx(struct Pokemon *mon, u8 battlerId) static void BattleLoadMonSpriteGfx(struct Pokemon *mon, u32 battlerId, bool32 opponent)
{ {
u32 monsPersonality, currentPersonality, otId; u32 monsPersonality, currentPersonality, otId, species, paletteOffset, position;
u16 species;
u8 position;
u16 paletteOffset;
const void *lzPaletteData; const void *lzPaletteData;
monsPersonality = GetMonData(mon, MON_DATA_PERSONALITY); monsPersonality = GetMonData(mon, MON_DATA_PERSONALITY);
if (gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies == SPECIES_NONE) if (gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies == SPECIES_NONE)
{ {
species = GetMonData(mon, MON_DATA_SPECIES); species = GetMonData(mon, MON_DATA_SPECIES);
@ -528,60 +524,14 @@ void BattleLoadOpponentMonSpriteGfx(struct Pokemon *mon, u8 battlerId)
otId = GetMonData(mon, MON_DATA_OT_ID); otId = GetMonData(mon, MON_DATA_OT_ID);
position = GetBattlerPosition(battlerId); position = GetBattlerPosition(battlerId);
if (opponent)
{
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species], HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species],
gMonSpritesGfxPtr->sprites[position], gMonSpritesGfxPtr->sprites[position],
species, currentPersonality); species, currentPersonality);
paletteOffset = 0x100 + battlerId * 16;
if (gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies == SPECIES_NONE)
lzPaletteData = GetMonFrontSpritePal(mon);
else
lzPaletteData = GetFrontSpritePalFromSpeciesAndPersonality(species, otId, monsPersonality);
LZDecompressWram(lzPaletteData, gDecompressionBuffer);
LoadPalette(gDecompressionBuffer, paletteOffset, 0x20);
LoadPalette(gDecompressionBuffer, 0x80 + battlerId * 16, 0x20);
if (species == SPECIES_CASTFORM)
{
paletteOffset = 0x100 + battlerId * 16;
LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette[0]);
LoadPalette(gBattleStruct->castformPalette[gBattleMonForms[battlerId]], paletteOffset, 0x20);
}
// transform's pink color
if (gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies != SPECIES_NONE)
{
BlendPalette(paletteOffset, 16, 6, RGB_WHITE);
CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32);
}
}
void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 battlerId)
{
u32 monsPersonality, currentPersonality, otId;
u16 species;
u8 position;
u16 paletteOffset;
const void *lzPaletteData;
monsPersonality = GetMonData(mon, MON_DATA_PERSONALITY);
if (gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies == SPECIES_NONE)
{
species = GetMonData(mon, MON_DATA_SPECIES);
currentPersonality = monsPersonality;
} }
else else
{ {
species = gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies;
currentPersonality = gTransformedPersonalities[battlerId];
}
otId = GetMonData(mon, MON_DATA_OT_ID);
position = GetBattlerPosition(battlerId);
if (sub_80688F8(1, battlerId) == 1 || gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies != SPECIES_NONE) if (sub_80688F8(1, battlerId) == 1 || gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies != SPECIES_NONE)
{ {
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[species], HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[species],
@ -594,6 +544,7 @@ void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 battlerId)
gMonSpritesGfxPtr->sprites[position], gMonSpritesGfxPtr->sprites[position],
species, currentPersonality); species, currentPersonality);
} }
}
paletteOffset = 0x100 + battlerId * 16; paletteOffset = 0x100 + battlerId * 16;
@ -621,8 +572,14 @@ void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 battlerId)
} }
} }
void nullsub_23(void) void BattleLoadOpponentMonSpriteGfx(struct Pokemon *mon, u8 battlerId)
{ {
BattleLoadMonSpriteGfx(mon, battlerId, TRUE);
}
void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 battlerId)
{
BattleLoadMonSpriteGfx(mon, battlerId, FALSE);
} }
void nullsub_24(u16 species) void nullsub_24(u16 species)
@ -849,30 +806,9 @@ void CopyBattleSpriteInvisibility(u8 battlerId)
void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool8 notTransform, bool32 megaEvo) void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool8 notTransform, bool32 megaEvo)
{ {
u16 paletteOffset; u32 personalityValue, otId, position, paletteOffset, targetSpecies;
u32 personalityValue; const void *lzPaletteData, *src;
u32 otId;
u8 position;
const u32 *lzPaletteData;
if (notTransform)
{
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerAtk]], gBattleSpritesDataPtr->animationData->animArg);
paletteOffset = 0x100 + battlerAtk * 16;
LoadPalette(gBattleStruct->castformPalette[gBattleSpritesDataPtr->animationData->animArg], paletteOffset, 32);
gBattleMonForms[battlerAtk] = gBattleSpritesDataPtr->animationData->animArg;
if (gBattleSpritesDataPtr->battlerData[battlerAtk].transformSpecies != SPECIES_NONE)
{
BlendPalette(paletteOffset, 16, 6, RGB_WHITE);
CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32);
}
gSprites[gBattlerSpriteIds[battlerAtk]].pos1.y = GetBattlerSpriteDefault_Y(battlerAtk);
}
else
{
const void *src;
void *dst; void *dst;
u16 targetSpecies;
if (IsContest()) if (IsContest())
{ {
@ -917,6 +853,21 @@ void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool8 notTransform
} }
} }
if (notTransform)
{
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battlerAtk]], gBattleSpritesDataPtr->animationData->animArg);
paletteOffset = 0x100 + battlerAtk * 16;
LoadPalette(gBattleStruct->castformPalette[gBattleSpritesDataPtr->animationData->animArg], paletteOffset, 32);
gBattleMonForms[battlerAtk] = gBattleSpritesDataPtr->animationData->animArg;
if (gBattleSpritesDataPtr->battlerData[battlerAtk].transformSpecies != SPECIES_NONE)
{
BlendPalette(paletteOffset, 16, 6, RGB_WHITE);
CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32);
}
gSprites[gBattlerSpriteIds[battlerAtk]].pos1.y = GetBattlerSpriteDefault_Y(battlerAtk);
}
else
{
src = gMonSpritesGfxPtr->sprites[position]; src = gMonSpritesGfxPtr->sprites[position];
dst = (void *)(VRAM + 0x10000 + gSprites[gBattlerSpriteIds[battlerAtk]].oam.tileNum * 32); dst = (void *)(VRAM + 0x10000 + gSprites[gBattlerSpriteIds[battlerAtk]].oam.tileNum * 32);
DmaCopy32(3, src, dst, 0x800); DmaCopy32(3, src, dst, 0x800);