From 6ceeb199181d64031f4173cfbffa066f5b9796b8 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 10 Sep 2017 22:12:47 -0400 Subject: Added identifying hash to Pokémon data structure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The purpose of this hash is described in detail in pokemon.h. The hash is computed using an implementation of SHA-224. To allow the GBA sufficient time to compute this hash, a delay of 5 milliseconds was introduced on the GC side before reading a Pokémon. --- gba/source/serialize.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'gba/source/serialize.c') diff --git a/gba/source/serialize.c b/gba/source/serialize.c index c5e8570..ddd3ef2 100644 --- a/gba/source/serialize.c +++ b/gba/source/serialize.c @@ -10,6 +10,7 @@ #include "basestats.h" #include "exptables.h" #include "dexorder.h" +#include "sha2.h" u32 CalculateStat( u8 base, @@ -51,6 +52,16 @@ void PokemonIntermediateInit( struct PokemonSubstruct2* sub2 = GetBoxPokemonSubstruct2(bpkm); struct PokemonSubstruct3* sub3 = GetBoxPokemonSubstruct3(bpkm); + u32 identifier[3]; + identifier[0] = bpkm->otId; // original trainer + identifier[1] = bpkm->personality; // personality value + identifier[2] = ((const u32*)sub3)[1]; // IVs (plus two non-random bits) + + sha224( + (const unsigned char*)identifier, + 12, + (unsigned char*)pki->key); + const struct SmallBaseStats* baseStats = BaseStatsForSpecies(sub0->species); for (int i=0; iotName[i] = bpkm->otName[i]; } - pki->otId = bpkm->otId; + pki->otId = bpkm->otId & 0x0000FFFF; pki->otGender = sub3->otGender; pki->species = gSpeciesToNationalPokedexNum[sub0->species - 1]; pki->heldItem = sub0->heldItem; -- cgit 1.4.1