From af137c9b9d1ed990b8d68a5a6bb41b6bbeb7cfca Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Thu, 25 Aug 2022 03:42:41 -0400 Subject: [PATCH] Multiple changes - Simplified LoadSpecialPokePic - Changed all checks flag checks to houldShowFemaleDifferences --- include/decompress.h | 5 ++- include/pokemon.h | 1 + include/pokemon_icon.h | 1 - src/battle_anim_mons.c | 6 ++-- src/battle_gfx_sfx_util.c | 10 +++--- src/contest.c | 2 +- src/contest_painting.c | 18 +++++----- src/contest_util.c | 11 +++---- src/decompress.c | 62 ++++++++--------------------------- src/egg_hatch.c | 2 +- src/menu_specialized.c | 2 +- src/pokeblock_feed.c | 2 +- src/pokemon.c | 13 +++++--- src/pokemon_debug.c | 15 +++++---- src/pokemon_icon.c | 60 ++++----------------------------- src/pokemon_jump.c | 9 +++-- src/pokemon_storage_system.c | 6 ++-- src/pokemon_summary_screen.c | 6 ++-- src/pokenav_conditions.c | 2 +- src/trade.c | 6 ++-- src/trainer_pokemon_sprites.c | 4 +-- 21 files changed, 81 insertions(+), 162 deletions(-) diff --git a/include/decompress.h b/include/decompress.h index bea2788ab..ef2ec43b0 100644 --- a/include/decompress.h +++ b/include/decompress.h @@ -19,10 +19,9 @@ bool8 LoadCompressedSpritePaletteUsingHeap(const struct CompressedSpritePalette void DecompressPicFromTable(const struct CompressedSpriteSheet *src, void *buffer, s32 species); void DecompressPicFromTableGender(void* buffer, s32 species, u32 personality); -void HandleLoadSpecialPokePic(const struct CompressedSpriteSheet *src, void *dest, s32 species, u32 personality); -void HandleLoadSpecialPokePicCustom(const struct CompressedSpriteSheet *src, void *dest, s32 species, u32 personality, bool8 isFemale); +void HandleLoadSpecialPokePic(bool32 isFrontPic, void *dest, s32 species, u32 personality); -void LoadSpecialPokePic(const struct CompressedSpriteSheet *src, void *dest, s32 species, u32 personality, bool8 isFrontPic); +void LoadSpecialPokePic(void *dest, s32 species, u32 personality, bool8 isFrontPic); u32 GetDecompressedDataSize(const u32 *ptr); diff --git a/include/pokemon.h b/include/pokemon.h index d7de38c61..c05628a59 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -558,5 +558,6 @@ u8 GetFormIdFromFormSpeciesId(u16 formSpeciesId); u16 GetFormChangeTargetSpecies(struct Pokemon *mon, u16 method, u32 arg); u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *mon, u16 method, u32 arg); u16 MonTryLearningNewMoveEvolution(struct Pokemon *mon, bool8 firstMove); +bool32 ShouldShowFemaleDifferences(u16 species, u32 personality); #endif // GUARD_POKEMON_H diff --git a/include/pokemon_icon.h b/include/pokemon_icon.h index 952db1ed1..fba6a6740 100644 --- a/include/pokemon_icon.h +++ b/include/pokemon_icon.h @@ -21,7 +21,6 @@ u8 CreateMonIconNoPersonality(u16 species, void (*callback)(struct Sprite *), s1 void FreeMonIconPalette(u16 species); void FreeAndDestroyMonIconSprite(struct Sprite *sprite); u8 CreateMonIcon(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority, u32 personality); -u8 CreateMonIconCustom(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority, u32 personality, bool8 isFemale, bool8 isShiny); u8 UpdateMonIconFrame(struct Sprite *sprite); void LoadMonIconPalette(u16 species); void SpriteCB_MonIcon(struct Sprite *sprite); diff --git a/src/battle_anim_mons.c b/src/battle_anim_mons.c index 21a3ed902..cef93bf96 100644 --- a/src/battle_anim_mons.c +++ b/src/battle_anim_mons.c @@ -2149,8 +2149,7 @@ u8 CreateAdditionalMonSpriteForMoveAnim(u16 species, bool8 isBackpic, u8 id, s16 if (!isBackpic) { LoadCompressedPalette(GetMonSpritePalFromSpeciesAndPersonality(species, trainerId, personality), (palette * 0x10) + 0x100, 0x20); - LoadSpecialPokePic(&gMonFrontPicTable[species], - gMonSpritesGfxPtr->buffer, + LoadSpecialPokePic(gMonSpritesGfxPtr->buffer, species, personality, TRUE); @@ -2158,8 +2157,7 @@ u8 CreateAdditionalMonSpriteForMoveAnim(u16 species, bool8 isBackpic, u8 id, s16 else { LoadCompressedPalette(GetMonSpritePalFromSpeciesAndPersonality(species, trainerId, personality), (palette * 0x10) + 0x100, 0x20); - LoadSpecialPokePic(&gMonBackPicTable[species], - gMonSpritesGfxPtr->buffer, + LoadSpecialPokePic(gMonSpritesGfxPtr->buffer, species, personality, FALSE); diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index 8cd23098f..27d7c7e35 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -578,13 +578,13 @@ static void BattleLoadMonSpriteGfx(struct Pokemon *mon, u32 battlerId, bool32 op position = GetBattlerPosition(battlerId); if (opponent) { - HandleLoadSpecialPokePic(&gMonFrontPicTable[species], + HandleLoadSpecialPokePic(TRUE, gMonSpritesGfxPtr->sprites.ptr[position], species, currentPersonality); } else { - HandleLoadSpecialPokePic(&gMonBackPicTable[species], + HandleLoadSpecialPokePic(FALSE, gMonSpritesGfxPtr->sprites.ptr[position], species, currentPersonality); } @@ -860,7 +860,7 @@ void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool8 castform, bo personalityValue = gContestResources->moveAnim->personality; otId = gContestResources->moveAnim->otId; - HandleLoadSpecialPokePic(&gMonBackPicTable[targetSpecies], + HandleLoadSpecialPokePic(FALSE, gMonSpritesGfxPtr->sprites.ptr[position], targetSpecies, gContestResources->moveAnim->targetPersonality); @@ -879,7 +879,7 @@ void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool8 castform, bo personalityValue = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerAtk]], MON_DATA_PERSONALITY); otId = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerAtk]], MON_DATA_OT_ID); - HandleLoadSpecialPokePic(&gMonBackPicTable[targetSpecies], + HandleLoadSpecialPokePic(FALSE, gMonSpritesGfxPtr->sprites.ptr[position], targetSpecies, gTransformedPersonalities[battlerAtk]); @@ -889,7 +889,7 @@ void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool8 castform, bo personalityValue = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerAtk]], MON_DATA_PERSONALITY); otId = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerAtk]], MON_DATA_OT_ID); - HandleLoadSpecialPokePic(&gMonFrontPicTable[targetSpecies], + HandleLoadSpecialPokePic(TRUE, gMonSpritesGfxPtr->sprites.ptr[position], targetSpecies, gTransformedPersonalities[battlerAtk]); diff --git a/src/contest.c b/src/contest.c index 0c525ed3a..0b5eda51b 100644 --- a/src/contest.c +++ b/src/contest.c @@ -3121,7 +3121,7 @@ static u8 CreateContestantSprite(u16 species, u32 otId, u32 personality, u32 ind u8 spriteId; species = SanitizeSpecies(species); - HandleLoadSpecialPokePic(&gMonBackPicTable[species], gMonSpritesGfxPtr->sprites.ptr[B_POSITION_PLAYER_LEFT], species, personality); + HandleLoadSpecialPokePic(FALSE, gMonSpritesGfxPtr->sprites.ptr[B_POSITION_PLAYER_LEFT], species, personality); LoadCompressedPalette(GetMonSpritePalFromSpeciesAndPersonality(species, otId, personality), 0x120, 0x20); SetMultiuseSpriteTemplateToPokemon(species, B_POSITION_PLAYER_LEFT); diff --git a/src/contest_painting.c b/src/contest_painting.c index 48021e28c..f891946d6 100644 --- a/src/contest_painting.c +++ b/src/contest_painting.c @@ -367,20 +367,18 @@ static void InitContestMonPixels(u16 species, bool8 backPic) LZDecompressVram(pal, gContestPaintingMonPalette); if (!backPic) { - HandleLoadSpecialPokePic( - &gMonFrontPicTable[species], - gMonSpritesGfxPtr->sprites.ptr[B_POSITION_OPPONENT_LEFT], - species, - gContestPaintingWinner->personality); + HandleLoadSpecialPokePic(TRUE, + gMonSpritesGfxPtr->sprites.ptr[B_POSITION_OPPONENT_LEFT], + species, + gContestPaintingWinner->personality); _InitContestMonPixels(gMonSpritesGfxPtr->sprites.ptr[B_POSITION_OPPONENT_LEFT], gContestPaintingMonPalette, (void *)gContestMonPixels); } else { - HandleLoadSpecialPokePic( - &gMonBackPicTable[species], - gMonSpritesGfxPtr->sprites.ptr[B_POSITION_PLAYER_LEFT], - species, - gContestPaintingWinner->personality); + HandleLoadSpecialPokePic(FALSE, + gMonSpritesGfxPtr->sprites.ptr[B_POSITION_PLAYER_LEFT], + species, + gContestPaintingWinner->personality); _InitContestMonPixels(gMonSpritesGfxPtr->sprites.ptr[B_POSITION_PLAYER_LEFT], gContestPaintingMonPalette, (void *)gContestMonPixels); } } diff --git a/src/contest_util.c b/src/contest_util.c index 79bf09eb2..dfd69a285 100644 --- a/src/contest_util.c +++ b/src/contest_util.c @@ -892,11 +892,10 @@ static void Task_ShowWinnerMonBanner(u8 taskId) species = gContestMons[i].species; personality = gContestMons[i].personality; otId = gContestMons[i].otId; - HandleLoadSpecialPokePic( - &gMonFrontPicTable[species], - gMonSpritesGfxPtr->sprites.ptr[B_POSITION_OPPONENT_LEFT], - species, - personality); + HandleLoadSpecialPokePic(TRUE, + gMonSpritesGfxPtr->sprites.ptr[B_POSITION_OPPONENT_LEFT], + species, + personality); pokePal = GetMonSpritePalStructFromOtIdPersonality(species, otId, personality); LoadCompressedSpritePalette(pokePal); @@ -2572,7 +2571,7 @@ void ShowContestEntryMonPic(void) taskId = CreateTask(Task_ShowContestEntryMonPic, 0x50); gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = species; - HandleLoadSpecialPokePic(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites.ptr[B_POSITION_OPPONENT_LEFT], species, personality); + HandleLoadSpecialPokePic(TRUE, gMonSpritesGfxPtr->sprites.ptr[B_POSITION_OPPONENT_LEFT], species, personality); palette = GetMonSpritePalStructFromOtIdPersonality(species, otId, personality); LoadCompressedSpritePalette(palette); diff --git a/src/decompress.c b/src/decompress.c index 4f17edcf8..c94f74862 100644 --- a/src/decompress.c +++ b/src/decompress.c @@ -70,25 +70,18 @@ void DecompressPicFromTable(const struct CompressedSpriteSheet *src, void *buffe void DecompressPicFromTableGender(void* buffer, s32 species, u32 personality) { - if ((gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE) && GetGenderFromSpeciesAndPersonality(species, personality) == MON_FEMALE) + if (ShouldShowFemaleDifferences(species, personality)) DecompressPicFromTable(&gMonFrontPicTableFemale[species], buffer, species); else DecompressPicFromTable(&gMonFrontPicTable[species], buffer, species); } -void HandleLoadSpecialPokePic(const struct CompressedSpriteSheet *src, void *dest, s32 species, u32 personality) +void HandleLoadSpecialPokePic(bool32 isFrontPic, void *dest, s32 species, u32 personality) { - bool8 isFrontPic; - - if (src == &gMonFrontPicTable[species]) - isFrontPic = TRUE; // frontPic - else - isFrontPic = FALSE; // backPic - - LoadSpecialPokePic(src, dest, species, personality, isFrontPic); + LoadSpecialPokePic(dest, species, personality, isFrontPic); } -void LoadSpecialPokePic(const struct CompressedSpriteSheet *src, void *dest, s32 species, u32 personality, bool8 isFrontPic) +void LoadSpecialPokePic(void *dest, s32 species, u32 personality, bool8 isFrontPic) { if (species == SPECIES_UNOWN) { @@ -100,8 +93,13 @@ void LoadSpecialPokePic(const struct CompressedSpriteSheet *src, void *dest, s32 LZ77UnCompWram(gMonFrontPicTable[id].data, dest); } else if (species > NUM_SPECIES) // is species unknown? draw the ? icon - LZ77UnCompWram(gMonFrontPicTable[0].data, dest); - else if ((gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE) && GetGenderFromSpeciesAndPersonality(species, personality) == MON_FEMALE) + { + if (isFrontPic) + LZ77UnCompWram(gMonFrontPicTable[0].data, dest); + else + LZ77UnCompWram(gMonBackPicTable[0].data, dest); + } + else if (ShouldShowFemaleDifferences(species, personality)) { if (isFrontPic) LZ77UnCompWram(gMonFrontPicTableFemale[species].data, dest); @@ -109,49 +107,15 @@ void LoadSpecialPokePic(const struct CompressedSpriteSheet *src, void *dest, s32 LZ77UnCompWram(gMonBackPicTableFemale[species].data, dest); } else - LZ77UnCompWram(src->data, dest); - - DrawSpindaSpots(species, personality, dest, isFrontPic); -} - -#if P_ENABLE_DEBUG == TRUE -static void LoadSpecialPokePicCustom(const struct CompressedSpriteSheet *src, void *dest, s32 species, u32 personality, bool8 isFrontPic, bool8 isFemale) -{ - if (species == SPECIES_UNOWN) - { - u32 id = GetUnownSpeciesId(personality); - - if (!isFrontPic) - LZ77UnCompWram(gMonBackPicTable[id].data, dest); - else - LZ77UnCompWram(gMonFrontPicTable[id].data, dest); - } - else if (species > NUM_SPECIES) // is species unknown? draw the ? icon - LZ77UnCompWram(gMonFrontPicTable[0].data, dest); - else if ((gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE) && isFemale) { if (isFrontPic) - LZ77UnCompWram(gMonFrontPicTableFemale[species].data, dest); + LZ77UnCompWram(gMonFrontPicTable[species].data, dest); else - LZ77UnCompWram(gMonBackPicTableFemale[species].data, dest); + LZ77UnCompWram(gMonBackPicTable[species].data, dest); } - else - LZ77UnCompWram(src->data, dest); DrawSpindaSpots(species, personality, dest, isFrontPic); } -void HandleLoadSpecialPokePicCustom(const struct CompressedSpriteSheet *src, void *dest, s32 species, u32 personality, bool8 isFemale) -{ - bool8 isFrontPic; - - if (src == &gMonFrontPicTable[species]) - isFrontPic = TRUE; // frontPic - else - isFrontPic = FALSE; // backPic - - LoadSpecialPokePicCustom(src, dest, species, personality, isFrontPic, isFemale); -} -#endif void Unused_LZDecompressWramIndirect(const void **src, void *dest) { diff --git a/src/egg_hatch.c b/src/egg_hatch.c index e280ef315..b7ae2e2ce 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -444,7 +444,7 @@ static u8 EggHatchCreateMonSprite(u8 useAlt, u8 state, u8 partyId, u16 *speciesL { u16 species = GetMonData(mon, MON_DATA_SPECIES); u32 pid = GetMonData(mon, MON_DATA_PERSONALITY); - HandleLoadSpecialPokePic(&gMonFrontPicTable[species], + HandleLoadSpecialPokePic(TRUE, gMonSpritesGfxPtr->sprites.ptr[(useAlt * 2) + B_POSITION_OPPONENT_LEFT], species, pid); LoadCompressedSpritePalette(GetMonSpritePalStruct(mon)); diff --git a/src/menu_specialized.c b/src/menu_specialized.c index 42c80b5ee..7c856b516 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -1075,7 +1075,7 @@ void GetConditionMenuMonGfx(void *tilesDst, void *palDst, u16 boxId, u16 monId, u32 trainerId = GetBoxOrPartyMonData(boxId, monId, MON_DATA_OT_ID, NULL); u32 personality = GetBoxOrPartyMonData(boxId, monId, MON_DATA_PERSONALITY, NULL); - LoadSpecialPokePic(&gMonFrontPicTable[species], tilesDst, species, personality, TRUE); + LoadSpecialPokePic(tilesDst, species, personality, TRUE); LZ77UnCompWram(GetMonSpritePalFromSpeciesAndPersonality(species, trainerId, personality), palDst); } } diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c index 00597e8d3..46355e146 100644 --- a/src/pokeblock_feed.c +++ b/src/pokeblock_feed.c @@ -727,7 +727,7 @@ static bool8 LoadMonAndSceneGfx(struct Pokemon *mon) // Load mon gfx species = GetMonData(mon, MON_DATA_SPECIES2); personality = GetMonData(mon, MON_DATA_PERSONALITY); - HandleLoadSpecialPokePic(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites.ptr[B_POSITION_OPPONENT_LEFT], species, personality); + HandleLoadSpecialPokePic(TRUE, gMonSpritesGfxPtr->sprites.ptr[B_POSITION_OPPONENT_LEFT], species, personality); sPokeblockFeed->loadGfxState++; break; case 1: diff --git a/src/pokemon.c b/src/pokemon.c index c781a8007..9ebab1a46 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -7520,14 +7520,14 @@ const u32 *GetMonSpritePalFromSpeciesAndPersonality(u16 species, u32 otId, u32 p shinyValue = GET_SHINY_VALUE(otId, personality); if (shinyValue < SHINY_ODDS) { - if ((gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE) && GetGenderFromSpeciesAndPersonality(species, personality) == MON_FEMALE) + if (ShouldShowFemaleDifferences(species, personality)) return gMonShinyPaletteTableFemale[species].data; else return gMonShinyPaletteTable[species].data; } else { - if ((gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE) && GetGenderFromSpeciesAndPersonality(species, personality) == MON_FEMALE) + if (ShouldShowFemaleDifferences(species, personality)) return gMonPaletteTableFemale[species].data; else return gMonPaletteTable[species].data; @@ -7549,14 +7549,14 @@ const struct CompressedSpritePalette *GetMonSpritePalStructFromOtIdPersonality(u shinyValue = GET_SHINY_VALUE(otId, personality); if (shinyValue < SHINY_ODDS) { - if ((gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE) && GetGenderFromSpeciesAndPersonality(species, personality) == MON_FEMALE) + if (ShouldShowFemaleDifferences(species, personality)) return &gMonShinyPaletteTableFemale[species]; else return &gMonShinyPaletteTable[species]; } else { - if ((gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE) && GetGenderFromSpeciesAndPersonality(species, personality) == MON_FEMALE) + if (ShouldShowFemaleDifferences(species, personality)) return &gMonPaletteTableFemale[species]; else return &gMonPaletteTable[species]; @@ -8359,3 +8359,8 @@ void TrySpecialOverworldEvo(void) sTriedEvolving = 0; SetMainCallback2(CB2_ReturnToField); } + +bool32 ShouldShowFemaleDifferences(u16 species, u32 personality) +{ + return (gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE) && GetGenderFromSpeciesAndPersonality(species, personality) == MON_FEMALE; +} diff --git a/src/pokemon_debug.c b/src/pokemon_debug.c index fa4460ed8..8775889fd 100644 --- a/src/pokemon_debug.c +++ b/src/pokemon_debug.c @@ -1107,6 +1107,9 @@ static void ResetPokemonDebugWindows(void) } } +#define MALE_PERSONALITY 0xFE +#define FEMALE_PERSONALITY 0X0 + void CB2_Debug_Pokemon(void) { u8 taskId; @@ -1180,7 +1183,7 @@ void CB2_Debug_Pokemon(void) palette = GetMonSpritePalStructCustom(species, data->isFemale, data->isShiny); LoadCompressedSpritePalette(palette); //Front - HandleLoadSpecialPokePicCustom(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites.ptr[1], species, 0, data->isFemale); + HandleLoadSpecialPokePic(TRUE, gMonSpritesGfxPtr->sprites.ptr[1], species, (data->isFemale ? FEMALE_PERSONALITY : MALE_PERSONALITY)); data->isShiny = FALSE; data->isFemale = FALSE; BattleLoadOpponentMonSpriteGfxCustom(species, data->isFemale, data->isShiny, 1); @@ -1195,7 +1198,7 @@ void CB2_Debug_Pokemon(void) LoadAndCreateEnemyShadowSpriteCustom(data, species); //Back - HandleLoadSpecialPokePicCustom(&gMonBackPicTable[species], gMonSpritesGfxPtr->sprites.ptr[2], species, 0, data->isFemale); + HandleLoadSpecialPokePic(FALSE, gMonSpritesGfxPtr->sprites.ptr[2], species, (data->isFemale ? FEMALE_PERSONALITY : MALE_PERSONALITY)); BattleLoadOpponentMonSpriteGfxCustom(species, data->isFemale, data->isShiny, 4); SetMultiuseSpriteTemplateToPokemon(species, 2); offset_y = gMonBackPicCoords[species].y_offset; @@ -1205,7 +1208,7 @@ void CB2_Debug_Pokemon(void) gSprites[data->backspriteId].oam.priority = 0; //Icon Sprite - data->iconspriteId = CreateMonIconCustom(species, SpriteCB_MonIcon, DEBUG_ICON_X, DEBUG_ICON_Y, 4, data->isShiny, data->isFemale, data->isShiny); + data->iconspriteId = CreateMonIcon(species, SpriteCB_MonIcon, DEBUG_ICON_X, DEBUG_ICON_Y, 4, (data->isFemale ? FEMALE_PERSONALITY : MALE_PERSONALITY)); gSprites[data->iconspriteId].oam.priority = 0; //Modify Arrows @@ -1692,7 +1695,7 @@ static void ReloadPokemonSprites(struct PokemonDebugMenu *data) palette = GetMonSpritePalStructCustom(species, data->isFemale, data->isShiny); LoadCompressedSpritePalette(palette); //Front - HandleLoadSpecialPokePicCustom(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites.ptr[1], species, 0, data->isFemale); + HandleLoadSpecialPokePic(TRUE, gMonSpritesGfxPtr->sprites.ptr[1], species, (data->isFemale ? FEMALE_PERSONALITY : MALE_PERSONALITY)); BattleLoadOpponentMonSpriteGfxCustom(species, data->isFemale, data->isShiny, 1); SetMultiuseSpriteTemplateToPokemon(species, 1); gMultiuseSpriteTemplate.paletteTag = palette->tag; @@ -1705,7 +1708,7 @@ static void ReloadPokemonSprites(struct PokemonDebugMenu *data) LoadAndCreateEnemyShadowSpriteCustom(data, species); //Back - HandleLoadSpecialPokePicCustom(&gMonBackPicTable[species], gMonSpritesGfxPtr->sprites.ptr[2], species, 0, data->isFemale); + HandleLoadSpecialPokePic(FALSE, gMonSpritesGfxPtr->sprites.ptr[2], species, (data->isFemale ? FEMALE_PERSONALITY : MALE_PERSONALITY)); BattleLoadOpponentMonSpriteGfxCustom(species, data->isFemale, data->isShiny, 5); SetMultiuseSpriteTemplateToPokemon(species, 2); offset_y = gMonBackPicCoords[species].y_offset; @@ -1715,7 +1718,7 @@ static void ReloadPokemonSprites(struct PokemonDebugMenu *data) gSprites[data->backspriteId].oam.priority = 0; //Icon Sprite - data->iconspriteId = CreateMonIconCustom(species, SpriteCB_MonIcon, DEBUG_ICON_X, DEBUG_ICON_Y, 4, data->isShiny, data->isFemale, data->isShiny); + data->iconspriteId = CreateMonIcon(species, SpriteCB_MonIcon, DEBUG_ICON_X, DEBUG_ICON_Y, 4, (data->isFemale ? FEMALE_PERSONALITY : MALE_PERSONALITY)); gSprites[data->iconspriteId].oam.priority = 0; //Modify Arrows diff --git a/src/pokemon_icon.c b/src/pokemon_icon.c index 6a0c8385a..51e1809aa 100644 --- a/src/pokemon_icon.c +++ b/src/pokemon_icon.c @@ -23,10 +23,6 @@ struct MonIconSpriteTemplate static u8 CreateMonIconSprite(struct MonIconSpriteTemplate *, s16, s16, u8); static void FreeAndDestroyMonIconSprite_(struct Sprite *sprite); -#if P_ENABLE_DEBUG == TRUE -static const u8 *GetMonIconPtrCustom(u16 species, u32 personality, bool8 isFemale); -static const u8 *GetMonIconTilesCustom(u16 species, bool8 isFemale); -#endif const u8 *const gMonIconTable[] = { @@ -2596,7 +2592,7 @@ u8 CreateMonIcon(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u if (species > NUM_SPECIES) iconTemplate.paletteTag = POKE_ICON_BASE_PAL_TAG; - else if ((gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE) && GetGenderFromSpeciesAndPersonality(species, personality) == MON_FEMALE) + else if (ShouldShowFemaleDifferences(species, personality)) iconTemplate.paletteTag = POKE_ICON_BASE_PAL_TAG + gMonIconPaletteIndicesFemale[species]; spriteId = CreateMonIconSprite(&iconTemplate, x, y, subpriority); @@ -2606,32 +2602,6 @@ u8 CreateMonIcon(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u return spriteId; } -#if P_ENABLE_DEBUG == TRUE -u8 CreateMonIconCustom(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority, u32 personality, bool8 isFemale, bool8 isShiny) -{ - u8 spriteId; - struct MonIconSpriteTemplate iconTemplate = - { - .oam = &sMonIconOamData, - .image = GetMonIconPtrCustom(species, personality, isFemale), - .anims = sMonIconAnims, - .affineAnims = sMonIconAffineAnims, - .callback = callback, - .paletteTag = POKE_ICON_BASE_PAL_TAG + gMonIconPaletteIndices[species], - }; - - if (species > NUM_SPECIES) - iconTemplate.paletteTag = POKE_ICON_BASE_PAL_TAG; - else if ((gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE) && isFemale) - iconTemplate.paletteTag = POKE_ICON_BASE_PAL_TAG + gMonIconPaletteIndicesFemale[species]; - - spriteId = CreateMonIconSprite(&iconTemplate, x, y, subpriority); - - UpdateMonIconFrame(&gSprites[spriteId]); - - return spriteId; -} -#endif u8 CreateMonIconNoPersonality(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority) { @@ -2704,13 +2674,6 @@ const u8 *GetMonIconPtr(u16 species, u32 personality) return GetMonIconTiles(GetIconSpecies(species, personality), personality); } -#if P_ENABLE_DEBUG == TRUE -static const u8 *GetMonIconPtrCustom(u16 species, u32 personality, bool8 isFemale) -{ - return GetMonIconTilesCustom(GetIconSpecies(species, personality), isFemale); -} -#endif - void FreeAndDestroyMonIconSprite(struct Sprite *sprite) { FreeAndDestroyMonIconSprite_(sprite); @@ -2772,24 +2735,15 @@ void SpriteCB_MonIcon(struct Sprite *sprite) const u8 *GetMonIconTiles(u16 species, u32 personality) { - const u8 *iconSprite = gMonIconTable[species]; - if ((gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE) && GetGenderFromSpeciesAndPersonality(species, personality) == MON_FEMALE) - { + const u8 *iconSprite; + + if (ShouldShowFemaleDifferences(species, personality)) iconSprite = gMonIconTableFemale[species]; - } + else + iconSprite = gMonIconTable[species]; + return iconSprite; } -#if P_ENABLE_DEBUG == TRUE -static const u8 *GetMonIconTilesCustom(u16 species, bool8 isFemale) -{ - const u8 *iconSprite = gMonIconTable[species]; - if ((gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE) && isFemale) - { - iconSprite = gMonIconTableFemale[species]; - } - return iconSprite; -} -#endif void TryLoadAllMonIconPalettesAtOffset(u16 offset) { diff --git a/src/pokemon_jump.c b/src/pokemon_jump.c index e3ae6623c..ccd3125e4 100755 --- a/src/pokemon_jump.c +++ b/src/pokemon_jump.c @@ -2905,11 +2905,10 @@ static void CreateJumpMonSprite(struct PokemonJumpGfx *jumpGfx, struct PokemonJu if (buffer && unusedBuffer) { - HandleLoadSpecialPokePic( - &gMonFrontPicTable[monInfo->species], - buffer, - monInfo->species, - monInfo->personality); + HandleLoadSpecialPokePic(TRUE, + buffer, + monInfo->species, + monInfo->personality); spriteSheet.data = buffer; spriteSheet.tag = multiplayerId; diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 39b55463c..7f515eba7 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -3991,7 +3991,7 @@ static void LoadDisplayMonGfx(u16 species, u32 pid) if (species != SPECIES_NONE) { - LoadSpecialPokePic(&gMonFrontPicTable[species], sStorage->tileBuffer, species, pid, TRUE); + LoadSpecialPokePic(sStorage->tileBuffer, species, pid, TRUE); LZ77UnCompWram(sStorage->displayMonPalette, sStorage->displayMonPalBuffer); CpuCopy32(sStorage->tileBuffer, sStorage->displayMonTilePtr, MON_PIC_SIZE); LoadPalette(sStorage->displayMonPalBuffer, sStorage->displayMonPalOffset, 0x20); @@ -5109,7 +5109,7 @@ static u16 TryLoadMonIconTiles(u16 species, u32 personality) u16 i, offset; // Treat female mons as a seperate species as they may have a different icon than males - if ((gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE) && GetGenderFromSpeciesAndPersonality(species, personality) == MON_FEMALE) + if (ShouldShowFemaleDifferences(species, personality)) species |= 0x8000; // 1 << 15 // Search icon list for this species @@ -5176,7 +5176,7 @@ static struct Sprite *CreateMonIconSprite(u16 species, u32 personality, s16 x, s struct SpriteTemplate template = sSpriteTemplate_MonIcon; species = GetIconSpecies(species, personality); - if ((gBaseStats[species].flags & FLAG_GENDER_DIFFERENCE) && GetGenderFromSpeciesAndPersonality(species, personality) == MON_FEMALE) + if (ShouldShowFemaleDifferences(species, personality)) { template.paletteTag = PALTAG_MON_ICON_0 + gMonIconPaletteIndicesFemale[species]; } diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index 2befc159f..c124358ef 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -3980,7 +3980,7 @@ static u8 LoadMonGfxAndSprite(struct Pokemon *mon, s16 *state) case 0: if (gMain.inBattle) { - HandleLoadSpecialPokePic(&gMonFrontPicTable[summary->species2], + HandleLoadSpecialPokePic(TRUE, gMonSpritesGfxPtr->sprites.ptr[B_POSITION_OPPONENT_LEFT], summary->species2, summary->pid); @@ -3989,14 +3989,14 @@ static u8 LoadMonGfxAndSprite(struct Pokemon *mon, s16 *state) { if (gMonSpritesGfxPtr != NULL) { - HandleLoadSpecialPokePic(&gMonFrontPicTable[summary->species2], + HandleLoadSpecialPokePic(TRUE, gMonSpritesGfxPtr->sprites.ptr[B_POSITION_OPPONENT_LEFT], summary->species2, summary->pid); } else { - HandleLoadSpecialPokePic(&gMonFrontPicTable[summary->species2], + HandleLoadSpecialPokePic(TRUE, MonSpritesGfxManager_GetSpritePtr(MON_SPR_GFX_MANAGER_A, B_POSITION_OPPONENT_LEFT), summary->species2, summary->pid); diff --git a/src/pokenav_conditions.c b/src/pokenav_conditions.c index e0645bac0..0477ebbf5 100644 --- a/src/pokenav_conditions.c +++ b/src/pokenav_conditions.c @@ -534,7 +534,7 @@ static void ConditionGraphDrawMonPic(s16 listId, u8 loadId) species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES2, NULL); tid = GetBoxOrPartyMonData(boxId, monId, MON_DATA_OT_ID, NULL); personality = GetBoxOrPartyMonData(boxId, monId, MON_DATA_PERSONALITY, NULL); - LoadSpecialPokePic(&gMonFrontPicTable[species], menu->monPicGfx[loadId], species, personality, TRUE); + LoadSpecialPokePic(menu->monPicGfx[loadId], species, personality, TRUE); LZ77UnCompWram(GetMonSpritePalFromSpeciesAndPersonality(species, tid, personality), menu->monPal[loadId]); } diff --git a/src/trade.c b/src/trade.c index ad990e980..abf35f26a 100644 --- a/src/trade.c +++ b/src/trade.c @@ -2734,7 +2734,7 @@ static void LoadTradeMonPic(u8 whichParty, u8 state) species = GetMonData(mon, MON_DATA_SPECIES2); personality = GetMonData(mon, MON_DATA_PERSONALITY); - HandleLoadSpecialPokePic(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites.ptr[whichParty * 2 + B_POSITION_OPPONENT_LEFT], species, personality); + HandleLoadSpecialPokePic(TRUE, gMonSpritesGfxPtr->sprites.ptr[whichParty * 2 + B_POSITION_OPPONENT_LEFT], species, personality); LoadCompressedSpritePalette(GetMonSpritePalStruct(mon)); sTradeData->monSpecies[whichParty] = species; @@ -3727,7 +3727,7 @@ static bool8 AnimateTradeSequenceCable(void) case TS_STATE_POKEBALL_ARRIVE_WAIT: if (gSprites[sTradeData->bouncingPokeballSpriteId].callback == SpriteCallbackDummy) { - HandleLoadSpecialPokePic(&gMonFrontPicTable[sTradeData->monSpecies[TRADE_PARTNER]], gMonSpritesGfxPtr->sprites.ptr[B_POSITION_OPPONENT_RIGHT], sTradeData->monSpecies[TRADE_PARTNER], sTradeData->monPersonalities[TRADE_PARTNER]); + HandleLoadSpecialPokePic(TRUE, gMonSpritesGfxPtr->sprites.ptr[B_POSITION_OPPONENT_RIGHT], sTradeData->monSpecies[TRADE_PARTNER], sTradeData->monPersonalities[TRADE_PARTNER]); sTradeData->state++; } break; @@ -4224,7 +4224,7 @@ static bool8 AnimateTradeSequenceWireless(void) case TS_STATE_POKEBALL_ARRIVE_WAIT: if (gSprites[sTradeData->bouncingPokeballSpriteId].callback == SpriteCallbackDummy) { - HandleLoadSpecialPokePic(&gMonFrontPicTable[sTradeData->monSpecies[TRADE_PARTNER]], + HandleLoadSpecialPokePic(TRUE, gMonSpritesGfxPtr->sprites.ptr[B_POSITION_OPPONENT_RIGHT], sTradeData->monSpecies[TRADE_PARTNER], sTradeData->monPersonalities[TRADE_PARTNER]); diff --git a/src/trainer_pokemon_sprites.c b/src/trainer_pokemon_sprites.c index 36cf70dce..dcc664718 100644 --- a/src/trainer_pokemon_sprites.c +++ b/src/trainer_pokemon_sprites.c @@ -59,11 +59,11 @@ static bool16 DecompressPic(u16 species, u32 personality, bool8 isFrontPic, u8 * { if (isFrontPic) { - LoadSpecialPokePic(&gMonFrontPicTable[species], dest, species, personality, isFrontPic); + LoadSpecialPokePic(dest, species, personality, isFrontPic); } else { - LoadSpecialPokePic(&gMonBackPicTable[species], dest, species, personality, isFrontPic); + LoadSpecialPokePic(dest, species, personality, isFrontPic); } } else