about summary refs log tree commit diff stats
path: root/gba/source/gamedata.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-08-18 13:49:00 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-08-18 13:49:00 -0400
commit08dfb0aa80668b80c4a31bd064f5f2d729e5b7f6 (patch)
treeb46baa9353c0919efaed4349d2207958fa0bfaf5 /gba/source/gamedata.h
parenta19507262602fa31f9f14a9e4f4e03e375bca111 (diff)
downloadgen3uploader-08dfb0aa80668b80c4a31bd064f5f2d729e5b7f6.tar.gz
gen3uploader-08dfb0aa80668b80c4a31bd064f5f2d729e5b7f6.tar.bz2
gen3uploader-08dfb0aa80668b80c4a31bd064f5f2d729e5b7f6.zip
Started working on serializing pokemon data
The GBA program now sends serialized data about the first pokemon in the
player's party over to the Wii. This data doesn't yet include all of the
information that we will eventually want. It does, however, not transfer
any private data, specifically IVs, EVs, and the personality value. It
does this by deriving the public information (stats, nature, gender,
shiny) before sending the pokemon over. Because of this, lookup tables
for things such as base stats were needed, and given that these are
large tables, it was easier to use the tables already existent in the
game's ROM. Thus, the addresses of the three lookup tables that are now
used are necessary for each ROM that this tool supports.

I derived the addresses for version 1 of English Pokemon LeafGreen by dumping
my own copy and searching through it with a text editor. Thus, at the current
time, that cartridge is the only one that is supported. I will supplement this
soon with addresses for the other four gen 3 carts that I have, but that will
still not provide a very large amount of coverage. I have not yet decided how
to address this issue.

There is one current bug with the serialized data: the Wii doesn't seem
to see the original trainer ID. Will fix.
Diffstat (limited to 'gba/source/gamedata.h')
-rw-r--r--gba/source/gamedata.h191
1 files changed, 187 insertions, 4 deletions
diff --git a/gba/source/gamedata.h b/gba/source/gamedata.h index 4d0a2a9..247626a 100644 --- a/gba/source/gamedata.h +++ b/gba/source/gamedata.h
@@ -21,9 +21,192 @@
21 21
22#define LANG_JAPAN ((*(u8*)(0x80000AF)) == 'J') 22#define LANG_JAPAN ((*(u8*)(0x80000AF)) == 'J')
23 23
24bool initSaveData( 24typedef const u32 (*ExperienceTables)[101];
25 pSaveBlock1* SaveBlock1, 25
26 pSaveBlock2* SaveBlock2, 26struct GameData {
27 pSaveBlock3* SaveBlock3); 27 pSaveBlock1 SaveBlock1;
28 pSaveBlock2 SaveBlock2;
29 pSaveBlock3 SaveBlock3;
30 struct BaseStats* baseStats;
31 ExperienceTables expTables;
32 const u16* natOrder;
33};
34
35bool initSaveData(struct GameData* gameData);
36
37/**
38 * Decrypts the substructures of a Pokémon structure, so they can be viewed or
39 * modified easily.
40 *
41 * Remember to call EncryptPokemon() afterwards.
42 *
43 * @param pkm The Pokémon to decrypt the substructures of.
44 */
45void DecryptPokemon(struct Pokemon* pkm);
46
47/**
48 * Decrypts the substructures of a core Pokémon structure, so they can be viewed
49 * or modified easily.
50 *
51 * Used by DecryptPokemon().
52 *
53 * Remember to call EncryptPokemon() afterwards.
54 *
55 * @param pkm The BoxPokemon to decrypt the substructures of.
56 */
57void DecryptBoxPokemon(struct BoxPokemon* pkm);
58
59/**
60 * Encrypts the substructures of a Pokémon structure, and fixes the checksum.
61 *
62 * Must be used after DecryptPokemon() has been called, otherwise the Pokémon
63 * you decrypted and forgot to re-encrypt will become a Bad Egg.
64 *
65 * @param pkm The Pokémon to encrypt the substructures and fix
66 * the checksum of.
67 */
68void EncryptPokemon(struct Pokemon* pkm);
69
70/**
71 * Encrypts the substructures of a core Pokémon structure, and fixes the
72 * checksum.
73 *
74 * Must be used after DecryptBoxPokemon() has been called, otherwise the Pokémon
75 * you decrypted and forgot to re-encrypt will become a Bad Egg.
76 *
77 * @param pkm The BoxPokemon to encrypt the substructures and fix the checksum
78 * of.
79 */
80void EncryptBoxPokemon(struct BoxPokemon* pkm);
81
82/**
83 * Gets a substructure of a Pokémon structure.
84 *
85 * Call DecryptPokemon() first or the substructure data will be encrypted.
86 *
87 * @param pkm The Pokemon to get a substructure of.
88 * @param substructId The substructure to get.
89 *
90 * @return The substructure.
91 */
92union PokemonSubstruct* GetPokemonSubstruct(struct Pokemon* pkm,u8 substructId);
93
94/**
95 * Gets a substructure of a core Pokémon structure.
96 *
97 * Call DecryptBoxPokemon() first or the substructure data will be encrypted.
98 *
99 * @param pkm The Pokemon to get a substructure of.
100 * @param substructId The substructure to get.
101 *
102 * @return The substructure.
103 */
104union PokemonSubstruct* GetBoxPokemonSubstruct(
105 struct BoxPokemon* pkm,
106 u8 substructId);
107
108/**
109 * Gets the checksum of a core Pokémon structure.
110 *
111 * @param pkm The BoxPokemon to calculate the checksum of.
112 *
113 * @return The checksum.
114 */
115u16 CalculateBoxPokemonChecksum(struct BoxPokemon* pkm);
116
117/**
118 * Fixes the checksum of a core Pokémon structure.
119 *
120 * @param pkm The BoxPokemon to fix the checksum of.
121 */
122void FixBoxPokemonChecksum(struct BoxPokemon* pkm);
123
124/**
125 * Gets the zeroth substructure ("Growth") of a Pokémon structure.
126 *
127 * Call DecryptPokemon() first or the substructure data will be encrypted.
128 *
129 * @param pkm The Pokémon to get a substructure of.
130 *
131 * @return The substructure.
132 */
133struct PokemonSubstruct0* GetPokemonSubstruct0(struct Pokemon* pkm);
134
135/**
136 * Gets the zeroth substructure ("Growth") of a core Pokémon structure.
137 *
138 * Call DecryptBoxPokemon() first or the substructure data will be encrypted.
139 *
140 * @param pkm The BoxPokemon to get the substructure of.
141 *
142 * @return The substructure.
143 */
144struct PokemonSubstruct0* GetBoxPokemonSubstruct0(struct BoxPokemon* pkm);
145
146/**
147 * Gets the first substructure ("Attacks") of a Pokémon structure.
148 *
149 * Call DecryptPokemon() first or the substructure data will be encrypted.
150 *
151 * @param pkm The Pokémon to get a substructure of.
152 *
153 * @return The substructure.
154 */
155struct PokemonSubstruct1* GetPokemonSubstruct1(struct Pokemon* pkm);
156
157/**
158 * Gets the first substructure ("Attacks") of a core Pokémon structure.
159 *
160 * Call DecryptBoxPokemon() first or the substructure data will be encrypted.
161 *
162 * @param pkm The BoxPokemon to get the substructure of.
163 *
164 * @return The substructure.
165 */
166struct PokemonSubstruct1* GetBoxPokemonSubstruct1(struct BoxPokemon* pkm);
167
168/**
169 * Gets the second substructure ("EVs & Condition") of a Pokémon structure.
170 *
171 * Call DecryptPokemon() first or the substructure data will be encrypted.
172 *
173 * @param pkm The Pokémon to get a substructure of.
174 *
175 * @return The substructure.
176 */
177struct PokemonSubstruct2* GetPokemonSubstruct2(struct Pokemon* pkm);
178
179/**
180 * Gets the second substructure ("EVs & Condition") of a core Pokémon structure.
181 *
182 * Call DecryptBoxPokemon() first or the substructure data will be encrypted.
183 *
184 * @param pkm The BoxPokemon to get the substructure of.
185 *
186 * @return The substructure.
187 */
188struct PokemonSubstruct2* GetBoxPokemonSubstruct2(struct BoxPokemon* pkm);
189
190/**
191 * Gets the third substructure ("Miscellaneous") of a Pokémon structure.
192 *
193 * Call DecryptPokemon() first or the substructure data will be encrypted.
194 *
195 * @param pkm The Pokémon to get a substructure of.
196 *
197 * @return The substructure.
198 */
199struct PokemonSubstruct3* GetPokemonSubstruct3(struct Pokemon* pkm);
200
201/**
202 * Gets the third substructure ("Miscellaneous") of a core Pokémon structure.
203 *
204 * Call DecryptBoxPokemon() first or the substructure data will be encrypted.
205 *
206 * @param pkm The BoxPokemon to get the substructure of.
207 *
208 * @return The substructure.
209 */
210struct PokemonSubstruct3* GetBoxPokemonSubstruct3(struct BoxPokemon* pkm);
28 211
29#endif 212#endif