blob: 247626aae000a705e190c6211439e49cef906e0e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
/*
* Copyright (C) 2017 hatkirby
* Copyright (C) 2017 slipstream/RoL
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
#ifndef _GAMEDATA_H_
#define _GAMEDATA_H_
#include <gba.h>
#include "saveblocks.h"
#define GAME_RUBY (((*(u32*)(0x80000AC)) << 8) == 'VXA\x00')
#define GAME_SAPP (((*(u32*)(0x80000AC)) << 8) == 'PXA\x00')
#define GAME_RS ((GAME_RUBY) || (GAME_SAPP))
#define GAME_FR (((*(u32*)(0x80000AC)) << 8) == 'RPB\x00')
#define GAME_LG (((*(u32*)(0x80000AC)) << 8) == 'GPB\x00')
#define GAME_FRLG ((GAME_FR) || (GAME_LG))
#define GAME_EM (((*(u32*)(0x80000AC)) << 8) == 'EPB\x00')
#define LANG_JAPAN ((*(u8*)(0x80000AF)) == 'J')
typedef const u32 (*ExperienceTables)[101];
struct GameData {
pSaveBlock1 SaveBlock1;
pSaveBlock2 SaveBlock2;
pSaveBlock3 SaveBlock3;
struct BaseStats* baseStats;
ExperienceTables expTables;
const u16* natOrder;
};
bool initSaveData(struct GameData* gameData);
/**
* Decrypts the substructures of a Pokémon structure, so they can be viewed or
* modified easily.
*
* Remember to call EncryptPokemon() afterwards.
*
* @param pkm The Pokémon to decrypt the substructures of.
*/
void DecryptPokemon(struct Pokemon* pkm);
/**
* Decrypts the substructures of a core Pokémon structure, so they can be viewed
* or modified easily.
*
* Used by DecryptPokemon().
*
* Remember to call EncryptPokemon() afterwards.
*
* @param pkm The BoxPokemon to decrypt the substructures of.
*/
void DecryptBoxPokemon(struct BoxPokemon* pkm);
/**
* Encrypts the substructures of a Pokémon structure, and fixes the checksum.
*
* Must be used after DecryptPokemon() has been called, otherwise the Pokémon
* you decrypted and forgot to re-encrypt will become a Bad Egg.
*
* @param pkm The Pokémon to encrypt the substructures and fix
* the checksum of.
*/
void EncryptPokemon(struct Pokemon* pkm);
/**
* Encrypts the substructures of a core Pokémon structure, and fixes the
* checksum.
*
* Must be used after DecryptBoxPokemon() has been called, otherwise the Pokémon
* you decrypted and forgot to re-encrypt will become a Bad Egg.
*
* @param pkm The BoxPokemon to encrypt the substructures and fix the checksum
* of.
*/
void EncryptBoxPokemon(struct BoxPokemon* pkm);
/**
* Gets a substructure of a Pokémon structure.
*
* Call DecryptPokemon() first or the substructure data will be encrypted.
*
* @param pkm The Pokemon to get a substructure of.
* @param substructId The substructure to get.
*
* @return The substructure.
*/
union PokemonSubstruct* GetPokemonSubstruct(struct Pokemon* pkm,u8 substructId);
/**
* Gets a substructure of a core Pokémon structure.
*
* Call DecryptBoxPokemon() first or the substructure data will be encrypted.
*
* @param pkm The Pokemon to get a substructure of.
* @param substructId The substructure to get.
*
* @return The substructure.
*/
union PokemonSubstruct* GetBoxPokemonSubstruct(
struct BoxPokemon* pkm,
u8 substructId);
/**
* Gets the checksum of a core Pokémon structure.
*
* @param pkm The BoxPokemon to calculate the checksum of.
*
* @return The checksum.
*/
u16 CalculateBoxPokemonChecksum(struct BoxPokemon* pkm);
/**
* Fixes the checksum of a core Pokémon structure.
*
* @param pkm The BoxPokemon to fix the checksum of.
*/
void FixBoxPokemonChecksum(struct BoxPokemon* pkm);
/**
* Gets the zeroth substructure ("Growth") of a Pokémon structure.
*
* Call DecryptPokemon() first or the substructure data will be encrypted.
*
* @param pkm The Pokémon to get a substructure of.
*
* @return The substructure.
*/
struct PokemonSubstruct0* GetPokemonSubstruct0(struct Pokemon* pkm);
/**
* Gets the zeroth substructure ("Growth") of a core Pokémon structure.
*
* Call DecryptBoxPokemon() first or the substructure data will be encrypted.
*
* @param pkm The BoxPokemon to get the substructure of.
*
* @return The substructure.
*/
struct PokemonSubstruct0* GetBoxPokemonSubstruct0(struct BoxPokemon* pkm);
/**
* Gets the first substructure ("Attacks") of a Pokémon structure.
*
* Call DecryptPokemon() first or the substructure data will be encrypted.
*
* @param pkm The Pokémon to get a substructure of.
*
* @return The substructure.
*/
struct PokemonSubstruct1* GetPokemonSubstruct1(struct Pokemon* pkm);
/**
* Gets the first substructure ("Attacks") of a core Pokémon structure.
*
* Call DecryptBoxPokemon() first or the substructure data will be encrypted.
*
* @param pkm The BoxPokemon to get the substructure of.
*
* @return The substructure.
*/
struct PokemonSubstruct1* GetBoxPokemonSubstruct1(struct BoxPokemon* pkm);
/**
* Gets the second substructure ("EVs & Condition") of a Pokémon structure.
*
* Call DecryptPokemon() first or the substructure data will be encrypted.
*
* @param pkm The Pokémon to get a substructure of.
*
* @return The substructure.
*/
struct PokemonSubstruct2* GetPokemonSubstruct2(struct Pokemon* pkm);
/**
* Gets the second substructure ("EVs & Condition") of a core Pokémon structure.
*
* Call DecryptBoxPokemon() first or the substructure data will be encrypted.
*
* @param pkm The BoxPokemon to get the substructure of.
*
* @return The substructure.
*/
struct PokemonSubstruct2* GetBoxPokemonSubstruct2(struct BoxPokemon* pkm);
/**
* Gets the third substructure ("Miscellaneous") of a Pokémon structure.
*
* Call DecryptPokemon() first or the substructure data will be encrypted.
*
* @param pkm The Pokémon to get a substructure of.
*
* @return The substructure.
*/
struct PokemonSubstruct3* GetPokemonSubstruct3(struct Pokemon* pkm);
/**
* Gets the third substructure ("Miscellaneous") of a core Pokémon structure.
*
* Call DecryptBoxPokemon() first or the substructure data will be encrypted.
*
* @param pkm The BoxPokemon to get the substructure of.
*
* @return The substructure.
*/
struct PokemonSubstruct3* GetBoxPokemonSubstruct3(struct BoxPokemon* pkm);
#endif
|