diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2020-06-14 21:18:07 -0400 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2020-06-14 21:18:07 -0400 |
commit | 62e926d5217f1f4cd8efd610e7d38374535836e1 (patch) | |
tree | 4c75cbe68c95e1973c6dfa47c417165097479a92 /arm9/src | |
parent | 670efff0ec376f9445d9cf552f6b51465b56ac06 (diff) |
through FUN_0206A998
Diffstat (limited to 'arm9/src')
-rw-r--r-- | arm9/src/pokemon.c | 80 |
1 files changed, 73 insertions, 7 deletions
diff --git a/arm9/src/pokemon.c b/arm9/src/pokemon.c index 4376285e..4fba962b 100644 --- a/arm9/src/pokemon.c +++ b/arm9/src/pokemon.c @@ -3523,25 +3523,27 @@ u16 CalcMonChecksum(u16 * data, u32 size) return ret; } -#define SUBSTRUCT_CASE(v1, v2, v3, v4)({ \ - PokemonDataBlock *substructs = boxMon->substructs; \ +#define SUBSTRUCT_CASE(v1, v2, v3, v4) \ +{ \ + PokemonDataBlock *substructs = boxMon->substructs; \ switch (substructType) \ { \ case 0: \ - result = &substructs[v1]; \ + result = &substructs[v1]; \ break; \ case 1: \ - result = &substructs[v2]; \ + result = &substructs[v2]; \ break; \ case 2: \ - result = &substructs[v3]; \ + result = &substructs[v3]; \ break; \ case 3: \ - result = &substructs[v4]; \ + result = &substructs[v4]; \ break; \ } \ -});\ + \ break; \ +} PokemonDataBlock *GetSubstruct(struct BoxPokemon *boxMon, u32 personality, u8 substructType) { @@ -3608,3 +3610,67 @@ PokemonDataBlock *GetSubstruct(struct BoxPokemon *boxMon, u32 personality, u8 su } return result; } + +int ResolveMonForme(int species, int forme) +{ + switch (species) + { + case SPECIES_DEOXYS: + if (forme != 0 && forme <= 3) + return SPECIES_DEOXYS_ATK + forme - 1; + break; + case SPECIES_WORMADAM: + if (forme != 0 && forme <= 2) + return SPECIES_WORMADAM_SANDY + forme - 1; + break; + } + return species; +} + +u32 MaskOfFlagNo(int flagno) +{ + // This is completely inane. + int i; + u32 ret = 1; + GF_ASSERT(flagno < 32); + for (i = 0; i < flagno; i++) + ret <<= 1; + return ret; +} + +int LowestFlagNo(u32 mask) +{ + int i; + u32 bit = 1; + for (i = 0; i < 32; i++) + { + if (mask & bit) + break; + bit <<= 1; + } + return i; +} + +BOOL IsPokemonLegendaryOrMythical(u16 species) +{ + int i; + for (i = 0; i < NELEMS(sLegendaryMonsList); i++) + { + if (species == sLegendaryMonsList[i]) + return TRUE; + } + return FALSE; +} + +u16 GetLegendaryMon(u32 idx) +{ + if (idx >= NELEMS(sLegendaryMonsList)) + idx = 0; + return sLegendaryMonsList[idx]; +} + +BOOL FUN_0206A998(struct Pokemon * pokemon) +{ + u16 species = GetMonData(pokemon, MON_DATA_SPECIES, NULL); + return IsPokemonLegendaryOrMythical(species); +} |