From 47578fc666fb563de012d74821a54edd5ddd918d Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Thu, 18 Jan 2024 13:33:49 -0300 Subject: [PATCH] Unified loading of mon palettes --- src/pokemon.c | 23 +++-------------------- src/pokemon_debug.c | 27 ++++----------------------- 2 files changed, 7 insertions(+), 43 deletions(-) diff --git a/src/pokemon.c b/src/pokemon.c index 91b0d088e4..a0c915e5ed 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -5362,30 +5362,13 @@ const u32 *GetMonFrontSpritePal(struct Pokemon *mon) const u32 *GetMonSpritePalFromSpeciesAndPersonality(u16 species, bool32 isShiny, u32 personality) { - species = SanitizeSpeciesId(species); - - if (isShiny) - { - if (gSpeciesInfo[species].shinyPaletteFemale != NULL && IsPersonalityFemale(species, personality)) - return gSpeciesInfo[species].shinyPaletteFemale; - else if (gSpeciesInfo[species].shinyPalette != NULL) - return gSpeciesInfo[species].shinyPalette; - else - return gSpeciesInfo[SPECIES_NONE].shinyPalette; - } - else - { - if (gSpeciesInfo[species].paletteFemale != NULL && IsPersonalityFemale(species, personality)) - return gSpeciesInfo[species].paletteFemale; - else if (gSpeciesInfo[species].palette != NULL) - return gSpeciesInfo[species].palette; - else - return gSpeciesInfo[SPECIES_NONE].palette; - } + return GetMonSpritePalFromSpecies(species, isShiny, IsPersonalityFemale(species, personality)); } const u32 *GetMonSpritePalFromSpecies(u16 species, bool32 isShiny, bool32 isFemale) { + species = SanitizeSpeciesId(species); + if (isShiny) { if (gSpeciesInfo[species].shinyPaletteFemale != NULL && isFemale) diff --git a/src/pokemon_debug.c b/src/pokemon_debug.c index 806c1f6373..f2f73b412e 100644 --- a/src/pokemon_debug.c +++ b/src/pokemon_debug.c @@ -682,31 +682,12 @@ static void UpdateBattlerValue(struct PokemonDebugMenu *data) static void BattleLoadOpponentMonSpriteGfxCustom(u16 species, bool8 isFemale, bool8 isShiny, u8 battlerId) { - const void *lzPaletteData; - u16 paletteOffset = 0x100 + battlerId * 16;; - - if (isShiny) - { - if (gSpeciesInfo[species].shinyPaletteFemale != NULL && isFemale) - lzPaletteData = gSpeciesInfo[species].shinyPaletteFemale; - else if (gSpeciesInfo[species].shinyPalette != NULL) - lzPaletteData = gSpeciesInfo[species].shinyPalette; - else - lzPaletteData = gSpeciesInfo[SPECIES_NONE].shinyPalette; - } - else - { - if (gSpeciesInfo[species].paletteFemale != NULL && isFemale) - lzPaletteData = gSpeciesInfo[species].paletteFemale; - else if (gSpeciesInfo[species].palette != NULL) - lzPaletteData = gSpeciesInfo[species].palette; - else - lzPaletteData = gSpeciesInfo[SPECIES_NONE].palette; - } + const u32 *lzPaletteData = GetMonSpritePalFromSpecies(species, isShiny, isFemale); + u16 paletteOffset = OBJ_PLTT_ID(battlerId); LZDecompressWram(lzPaletteData, gDecompressionBuffer); - LoadPalette(gDecompressionBuffer, paletteOffset, 0x20); - LoadPalette(gDecompressionBuffer, 0x80 + battlerId * 16, 0x20); + LoadPalette(gDecompressionBuffer, paletteOffset, PLTT_SIZE_4BPP); + LoadPalette(gDecompressionBuffer, BG_PLTT_ID(8) + BG_PLTT_ID(battlerId), PLTT_SIZE_4BPP); } static void SetConstSpriteValues(struct PokemonDebugMenu *data)