Calculate pokemon substruct size, missing MON_PIC_SIZE

This commit is contained in:
GriffinR
2021-10-11 10:35:53 -04:00
parent d8e65fc4b6
commit b8a44bf10a
3 changed files with 14 additions and 5 deletions

View File

@@ -76,13 +76,22 @@ struct PokemonSubstruct3
/* 0x0B */ u32 eventLegal:1; // controls Mew & Deoxys obedience; if set, Pokémon is a fateful encounter in Gen 4+; set for in-game event island legendaries, some distributed events, and Pokémon from XD: Gale of Darkness.
};
// Number of bytes in the largest Pokémon substruct.
// They are assumed to be the same size, and will be padded to
// the largest size by the union.
// By default they are all 12 bytes.
#define NUM_SUBSTRUCT_BYTES (max(sizeof(struct PokemonSubstruct0), \
max(sizeof(struct PokemonSubstruct1), \
max(sizeof(struct PokemonSubstruct2), \
sizeof(struct PokemonSubstruct3)))))
union PokemonSubstruct
{
struct PokemonSubstruct0 type0;
struct PokemonSubstruct1 type1;
struct PokemonSubstruct2 type2;
struct PokemonSubstruct3 type3;
u16 raw[6];
u16 raw[NUM_SUBSTRUCT_BYTES / 2]; // /2 because it's u16, not u8
};
struct BoxPokemon
@@ -102,7 +111,7 @@ struct BoxPokemon
union
{
u32 raw[12];
u32 raw[(NUM_SUBSTRUCT_BYTES * 4) / 4]; // *4 because there are 4 substructs, /4 because it's u32, not u8
union PokemonSubstruct substructs[4];
} secure;
};