Merge pull request #1648 from BuffelSaft/genders-in-PSS

PSS supports gender differences (kinda)
This commit is contained in:
Eduardo Quezada D'Ottone 2021-10-15 08:55:44 -03:00 committed by GitHub
commit 2e8ad12857
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;
@ -5139,10 +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++)
{
if (sStorage->iconSpeciesList[i] == species)
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;
@ -5158,7 +5174,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;