diff options
Diffstat (limited to 'gba/source/serialize.c')
| -rw-r--r-- | gba/source/serialize.c | 51 |
1 files changed, 20 insertions, 31 deletions
| diff --git a/gba/source/serialize.c b/gba/source/serialize.c index ddb156c..5c4ff8d 100644 --- a/gba/source/serialize.c +++ b/gba/source/serialize.c | |||
| @@ -10,21 +10,7 @@ | |||
| 10 | #include "basestats.h" | 10 | #include "basestats.h" |
| 11 | #include "exptables.h" | 11 | #include "exptables.h" |
| 12 | #include "dexorder.h" | 12 | #include "dexorder.h" |
| 13 | #include "sha2.h" | 13 | #include "blake2.h" |
| 14 | |||
| 15 | // See pokemon.h for more information about this. | ||
| 16 | struct HashDeterminer { | ||
| 17 | u32 otId; | ||
| 18 | u32 personality; | ||
| 19 | u32 hpIV:5; | ||
| 20 | u32 attackIV:5; | ||
| 21 | u32 defenseIV:5; | ||
| 22 | u32 speedIV:5; | ||
| 23 | u32 spAttackIV:5; | ||
| 24 | u32 spDefenseIV:5; | ||
| 25 | u32 isShedinja:1; | ||
| 26 | u32 zero:1; | ||
| 27 | }; | ||
| 28 | 14 | ||
| 29 | u32 CalculateStat( | 15 | u32 CalculateStat( |
| 30 | u8 base, | 16 | u8 base, |
| @@ -64,22 +50,25 @@ void PokemonIntermediateInit( | |||
| 64 | struct PokemonSubstruct2* sub2 = GetBoxPokemonSubstruct2(bpkm); | 50 | struct PokemonSubstruct2* sub2 = GetBoxPokemonSubstruct2(bpkm); |
| 65 | struct PokemonSubstruct3* sub3 = GetBoxPokemonSubstruct3(bpkm); | 51 | struct PokemonSubstruct3* sub3 = GetBoxPokemonSubstruct3(bpkm); |
| 66 | 52 | ||
| 67 | struct HashDeterminer identifier; | 53 | u8 identifier[16]; |
| 68 | identifier.otId = bpkm->otId; | 54 | identifier[0] = bpkm->otId & 0x000000FF; |
| 69 | identifier.personality = bpkm->personality; | 55 | identifier[1] = (bpkm->otId >> 8) & 0x000000FF; |
| 70 | identifier.hpIV = sub3->hpIV; | 56 | identifier[2] = (bpkm->otId >> 16) & 0x000000FF; |
| 71 | identifier.attackIV = sub3->attackIV; | 57 | identifier[3] = (bpkm->otId >> 24) & 0x000000FF; |
| 72 | identifier.defenseIV = sub3->defenseIV; | 58 | identifier[4] = bpkm->personality & 0x000000FF; |
| 73 | identifier.speedIV = sub3->speedIV; | 59 | identifier[5] = (bpkm->personality >> 8) & 0x000000FF; |
| 74 | identifier.spAttackIV = sub3->spAttackIV; | 60 | identifier[6] = (bpkm->personality >> 16) & 0x000000FF; |
| 75 | identifier.spDefenseIV = sub3->spDefenseIV; | 61 | identifier[7] = (bpkm->personality >> 24) & 0x000000FF; |
| 76 | identifier.isShedinja = (sub0->species == SHEDINJA_SPECIES_INDEX) ? 1 : 0; | 62 | identifier[8] = sub3->hpIV; |
| 77 | identifier.zero = 0; | 63 | identifier[9] = sub3->attackIV; |
| 78 | 64 | identifier[10] = sub3->defenseIV; | |
| 79 | sha224( | 65 | identifier[11] = sub3->speedIV; |
| 80 | (const unsigned char*)&identifier, | 66 | identifier[12] = sub3->spAttackIV; |
| 81 | 12, | 67 | identifier[13] = sub3->spDefenseIV; |
| 82 | (unsigned char*)pki->key); | 68 | identifier[14] = (sub0->species == SHEDINJA_SPECIES_INDEX) ? 1 : 0; |
| 69 | identifier[15] = 0; | ||
| 70 | |||
| 71 | blake2s((u8*)pki->key, 28, identifier, 16, 0, 0); | ||
| 83 | 72 | ||
| 84 | const struct SmallBaseStats* baseStats = BaseStatsForSpecies(sub0->species); | 73 | const struct SmallBaseStats* baseStats = BaseStatsForSpecies(sub0->species); |
| 85 | 74 | ||
