From dc5259ed3fbf5352186db5d4a4be28e19d8b2b4e Mon Sep 17 00:00:00 2001 From: BuffelSaft Date: Sat, 11 Sep 2021 16:59:39 +1200 Subject: [PATCH 1/2] PSS supports gender differences (kinda) Update the PSS to show gender-specific icons for mons that have them. Comes with a small but harmless bug - could use some suggestions for fixing it! --- src/pokemon_storage_system.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 92f45cb28a..c88658da79 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -151,6 +151,7 @@ enum { }; #define MENU_WALLPAPER_SETS_START MENU_SCENERY_1 #define MENU_WALLPAPERS_START MENU_FOREST +#define GENDER_MASK 0x7FFF // Return IDs for input handlers enum { @@ -5105,6 +5106,10 @@ 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 (SpeciesHasGenderDifference[species] && GetGenderFromSpeciesAndPersonality(species, personality) == MON_FEMALE) + species |= 0x8000; // 1 << 15 + // Search icon list for this species for (i = 0; i < MAX_MON_ICONS; i++) { @@ -5131,6 +5136,7 @@ static u16 TryLoadMonIconTiles(u16 species, u32 personality) sStorage->iconSpeciesList[i] = species; sStorage->numIconsPerSpecies[i]++; offset = 16 * i; + species &= GENDER_MASK; CpuCopy32(GetMonIconTiles(species, personality), (void*)(OBJ_VRAM0) + offset * 32, 0x200); return offset; @@ -5142,7 +5148,11 @@ static void RemoveSpeciesFromIconList(u16 species) for (i = 0; i < MAX_MON_ICONS; i++) { - if (sStorage->iconSpeciesList[i] == species) + /* This is flawed - if a male mon with gender differeneces has its icon removed from the list, + * but a female mon of the same species is still visible, its icon will also be cleared from the list. + * This may create a small but noticable visual bug when switching boxes. + */ + if (sStorage->iconSpeciesList[i] == species || sStorage->iconSpeciesList[i] == (species | 0x8000)) { if (--sStorage->numIconsPerSpecies[i] == 0) sStorage->iconSpeciesList[i] = SPECIES_NONE; @@ -5158,7 +5168,15 @@ static struct Sprite *CreateMonIconSprite(u16 species, u32 personality, s16 x, s struct SpriteTemplate template = sSpriteTemplate_MonIcon; species = GetIconSpecies(species, personality); - template.paletteTag = PALTAG_MON_ICON_0 + gMonIconPaletteIndices[species]; + if (SpeciesHasGenderDifference[species] && GetGenderFromSpeciesAndPersonality(species, personality) == MON_FEMALE) + { + template.paletteTag = PALTAG_MON_ICON_0 + gMonIconPaletteIndicesFemale[species]; + } + else + { + template.paletteTag = PALTAG_MON_ICON_0 + gMonIconPaletteIndices[species]; + } + tileNum = TryLoadMonIconTiles(species, personality); if (tileNum == 0xFFFF) return NULL; From 7610a9abad7df875f3bc1f07f1bcd80a510f8d23 Mon Sep 17 00:00:00 2001 From: BuffelSaft Date: Fri, 15 Oct 2021 16:17:08 +1300 Subject: [PATCH 2/2] Fix bug with female icon sprites Thanks to AsparagusEduardo for this code! --- src/pokemon_storage_system.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index c88658da79..679240fbaf 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -5145,14 +5145,20 @@ static u16 TryLoadMonIconTiles(u16 species, u32 personality) static void RemoveSpeciesFromIconList(u16 species) { u16 i; + bool8 hasFemale = FALSE; for (i = 0; i < MAX_MON_ICONS; i++) { - /* This is flawed - if a male mon with gender differeneces has its icon removed from the list, - * but a female mon of the same species is still visible, its icon will also be cleared from the list. - * This may create a small but noticable visual bug when switching boxes. - */ - if (sStorage->iconSpeciesList[i] == species || sStorage->iconSpeciesList[i] == (species | 0x8000)) + if (sStorage->iconSpeciesList[i] == (species | 0x8000)) + { + hasFemale = TRUE; + break; + } + } + + for (i = 0; i < MAX_MON_ICONS; i++) + { + if (sStorage->iconSpeciesList[i] == species && !hasFemale) { if (--sStorage->numIconsPerSpecies[i] == 0) sStorage->iconSpeciesList[i] = SPECIES_NONE;