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!
This commit is contained in:
BuffelSaft 2021-09-11 16:59:39 +12:00
parent fd6f7eadbb
commit dc5259ed3f

View File

@ -151,6 +151,7 @@ enum {
}; };
#define MENU_WALLPAPER_SETS_START MENU_SCENERY_1 #define MENU_WALLPAPER_SETS_START MENU_SCENERY_1
#define MENU_WALLPAPERS_START MENU_FOREST #define MENU_WALLPAPERS_START MENU_FOREST
#define GENDER_MASK 0x7FFF
// Return IDs for input handlers // Return IDs for input handlers
enum { enum {
@ -5105,6 +5106,10 @@ static u16 TryLoadMonIconTiles(u16 species, u32 personality)
{ {
u16 i, offset; 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 // Search icon list for this species
for (i = 0; i < MAX_MON_ICONS; i++) for (i = 0; i < MAX_MON_ICONS; i++)
{ {
@ -5131,6 +5136,7 @@ static u16 TryLoadMonIconTiles(u16 species, u32 personality)
sStorage->iconSpeciesList[i] = species; sStorage->iconSpeciesList[i] = species;
sStorage->numIconsPerSpecies[i]++; sStorage->numIconsPerSpecies[i]++;
offset = 16 * i; offset = 16 * i;
species &= GENDER_MASK;
CpuCopy32(GetMonIconTiles(species, personality), (void*)(OBJ_VRAM0) + offset * 32, 0x200); CpuCopy32(GetMonIconTiles(species, personality), (void*)(OBJ_VRAM0) + offset * 32, 0x200);
return offset; return offset;
@ -5142,7 +5148,11 @@ static void RemoveSpeciesFromIconList(u16 species)
for (i = 0; i < MAX_MON_ICONS; i++) 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) if (--sStorage->numIconsPerSpecies[i] == 0)
sStorage->iconSpeciesList[i] = SPECIES_NONE; 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; struct SpriteTemplate template = sSpriteTemplate_MonIcon;
species = GetIconSpecies(species, personality); 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); tileNum = TryLoadMonIconTiles(species, personality);
if (tileNum == 0xFFFF) if (tileNum == 0xFFFF)
return NULL; return NULL;