diff options
-rw-r--r-- | gba/source/savestructs.h | 14 | ||||
-rw-r--r-- | gba/source/serialize.c | 20 | ||||
-rw-r--r-- | include/pokemon.h | 19 | ||||
-rw-r--r-- | source/deserialize.c | 67 |
4 files changed, 113 insertions, 7 deletions
diff --git a/gba/source/savestructs.h b/gba/source/savestructs.h index fb8ef36..a5aff4e 100644 --- a/gba/source/savestructs.h +++ b/gba/source/savestructs.h | |||
@@ -342,13 +342,13 @@ struct PokemonSubstruct3 | |||
342 | /* 0x0A */ u32 victoryRibbon:1; | 342 | /* 0x0A */ u32 victoryRibbon:1; |
343 | /* 0x0A */ u32 artistRibbon:1; | 343 | /* 0x0A */ u32 artistRibbon:1; |
344 | /* 0x0A */ u32 effortRibbon:1; | 344 | /* 0x0A */ u32 effortRibbon:1; |
345 | /* 0x0A */ u32 giftRibbon1:1; | 345 | /* 0x0A */ u32 marineRibbon:1; |
346 | /* 0x0A */ u32 giftRibbon2:1; | 346 | /* 0x0A */ u32 landRibbon:1; |
347 | /* 0x0A */ u32 giftRibbon3:1; | 347 | /* 0x0A */ u32 skyRibbon:1; |
348 | /* 0x0A */ u32 giftRibbon4:1; | 348 | /* 0x0A */ u32 countryRibbon:1; |
349 | /* 0x0B */ u32 giftRibbon5:1; | 349 | /* 0x0B */ u32 nationalRibbon:1; |
350 | /* 0x0B */ u32 giftRibbon6:1; | 350 | /* 0x0B */ u32 earthRibbon:1; |
351 | /* 0x0B */ u32 giftRibbon7:1; | 351 | /* 0x0B */ u32 worldRibbon:1; |
352 | /* 0x0B */ u32 fatefulEncounter:5; // unused in Ruby/Sapphire, but the high bit must be set for Mew/Deoxys to obey in FR/LG/Emerald | 352 | /* 0x0B */ u32 fatefulEncounter:5; // unused in Ruby/Sapphire, but the high bit must be set for Mew/Deoxys to obey in FR/LG/Emerald |
353 | }; | 353 | }; |
354 | 354 | ||
diff --git a/gba/source/serialize.c b/gba/source/serialize.c index 5c4ff8d..4cb95ac 100644 --- a/gba/source/serialize.c +++ b/gba/source/serialize.c | |||
@@ -101,6 +101,26 @@ void PokemonIntermediateInit( | |||
101 | pki->language = bpkm->language & 7; | 101 | pki->language = bpkm->language & 7; |
102 | pki->orre = (sub3->metGame == 15); | 102 | pki->orre = (sub3->metGame == 15); |
103 | 103 | ||
104 | pki->coolRibbons = sub3->coolRibbon; | ||
105 | pki->beautyRibbons = sub3->beautyRibbon; | ||
106 | pki->cuteRibbons = sub3->cuteRibbon; | ||
107 | pki->smartRibbons = sub3->smartRibbon; | ||
108 | pki->toughRibbons = sub3->toughRibbon; | ||
109 | |||
110 | pki->miscRibbons = | ||
111 | (CHAMPION_RIBBON * sub3->championRibbon) | ||
112 | | (WINNING_RIBBON * sub3->winningRibbon) | ||
113 | | (VICTORY_RIBBON * sub3->victoryRibbon) | ||
114 | | (ARTIST_RIBBON * sub3->artistRibbon) | ||
115 | | (EFFORT_RIBBON * sub3->effortRibbon) | ||
116 | | (MARINE_RIBBON * sub3->marineRibbon) | ||
117 | | (LAND_RIBBON * sub3->landRibbon) | ||
118 | | (SKY_RIBBON * sub3->skyRibbon) | ||
119 | | (COUNTRY_RIBBON * sub3->countryRibbon) | ||
120 | | (NATIONAL_RIBBON * sub3->nationalRibbon) | ||
121 | | (EARTH_RIBBON * sub3->earthRibbon) | ||
122 | | (WORLD_RIBBON * sub3->worldRibbon); | ||
123 | |||
104 | // Derive nature from the personality value. | 124 | // Derive nature from the personality value. |
105 | pki->nature = (bpkm->personality % 25); | 125 | pki->nature = (bpkm->personality % 25); |
106 | 126 | ||
diff --git a/include/pokemon.h b/include/pokemon.h index dbf0d41..ce961ed 100644 --- a/include/pokemon.h +++ b/include/pokemon.h | |||
@@ -20,6 +20,19 @@ enum PokemonLanguage { | |||
20 | Spanish = 7 | 20 | Spanish = 7 |
21 | }; | 21 | }; |
22 | 22 | ||
23 | #define CHAMPION_RIBBON (1 << 0) | ||
24 | #define WINNING_RIBBON (1 << 1) | ||
25 | #define VICTORY_RIBBON (1 << 2) | ||
26 | #define ARTIST_RIBBON (1 << 3) | ||
27 | #define EFFORT_RIBBON (1 << 4) | ||
28 | #define MARINE_RIBBON (1 << 5) | ||
29 | #define LAND_RIBBON (1 << 6) | ||
30 | #define SKY_RIBBON (1 << 7) | ||
31 | #define COUNTRY_RIBBON (1 << 8) | ||
32 | #define NATIONAL_RIBBON (1 << 9) | ||
33 | #define EARTH_RIBBON (1 << 10) | ||
34 | #define WORLD_RIBBON (1 << 11) | ||
35 | |||
23 | struct __attribute__((aligned(4))) PokemonIntermediate { | 36 | struct __attribute__((aligned(4))) PokemonIntermediate { |
24 | // a hash that can be used to identify the Pokémon. because the games do not | 37 | // a hash that can be used to identify the Pokémon. because the games do not |
25 | // naturally generate unique identifiers for Pokémon, this hash is generated | 38 | // naturally generate unique identifiers for Pokémon, this hash is generated |
@@ -59,7 +72,13 @@ struct __attribute__((aligned(4))) PokemonIntermediate { | |||
59 | u16 heldItem; | 72 | u16 heldItem; |
60 | u16 moves[4]; | 73 | u16 moves[4]; |
61 | u16 otId; // only the lower 2 bytes, because the upper 2 are secret | 74 | u16 otId; // only the lower 2 bytes, because the upper 2 are secret |
75 | u16 miscRibbons; | ||
62 | 76 | ||
77 | u8 coolRibbons; | ||
78 | u8 beautyRibbons; | ||
79 | u8 cuteRibbons; | ||
80 | u8 smartRibbons; | ||
81 | u8 toughRibbons; | ||
63 | u8 ppBonuses; | 82 | u8 ppBonuses; |
64 | u8 otGender; | 83 | u8 otGender; |
65 | u8 metLevel; | 84 | u8 metLevel; |
diff --git a/source/deserialize.c b/source/deserialize.c index da2d919..b37cb72 100644 --- a/source/deserialize.c +++ b/source/deserialize.c | |||
@@ -211,5 +211,72 @@ cJSON* pokemonToJson(const struct PokemonIntermediate* pki) | |||
211 | pki->unownLetter); | 211 | pki->unownLetter); |
212 | } | 212 | } |
213 | 213 | ||
214 | cJSON_AddNumberToObject(jPoke, "coolRibbons", pki->coolRibbons); | ||
215 | cJSON_AddNumberToObject(jPoke, "beautyRibbons", pki->beautyRibbons); | ||
216 | cJSON_AddNumberToObject(jPoke, "cuteRibbons", pki->cuteRibbons); | ||
217 | cJSON_AddNumberToObject(jPoke, "smartRibbons", pki->smartRibbons); | ||
218 | cJSON_AddNumberToObject(jPoke, "toughRibbons", pki->toughRibbons); | ||
219 | |||
220 | u16 miscRibbons = __builtin_bswap16(pki->miscRibbons); | ||
221 | if (miscRibbons & CHAMPION_RIBBON) | ||
222 | { | ||
223 | cJSON_AddBoolToObject(jPoke, "championRibbon", true); | ||
224 | } | ||
225 | |||
226 | if (miscRibbons & WINNING_RIBBON) | ||
227 | { | ||
228 | cJSON_AddBoolToObject(jPoke, "winningRibbon", true); | ||
229 | } | ||
230 | |||
231 | if (miscRibbons & VICTORY_RIBBON) | ||
232 | { | ||
233 | cJSON_AddBoolToObject(jPoke, "victoryRibbon", true); | ||
234 | } | ||
235 | |||
236 | if (miscRibbons & ARTIST_RIBBON) | ||
237 | { | ||
238 | cJSON_AddBoolToObject(jPoke, "artistRibbon", true); | ||
239 | } | ||
240 | |||
241 | if (miscRibbons & EFFORT_RIBBON) | ||
242 | { | ||
243 | cJSON_AddBoolToObject(jPoke, "effortRibbon", true); | ||
244 | } | ||
245 | |||
246 | if (miscRibbons & MARINE_RIBBON) | ||
247 | { | ||
248 | cJSON_AddBoolToObject(jPoke, "marineRibbon", true); | ||
249 | } | ||
250 | |||
251 | if (miscRibbons & LAND_RIBBON) | ||
252 | { | ||
253 | cJSON_AddBoolToObject(jPoke, "landRibbon", true); | ||
254 | } | ||
255 | |||
256 | if (miscRibbons & SKY_RIBBON) | ||
257 | { | ||
258 | cJSON_AddBoolToObject(jPoke, "skyRibbon", true); | ||
259 | } | ||
260 | |||
261 | if (miscRibbons & COUNTRY_RIBBON) | ||
262 | { | ||
263 | cJSON_AddBoolToObject(jPoke, "countryRibbon", true); | ||
264 | } | ||
265 | |||
266 | if (miscRibbons & NATIONAL_RIBBON) | ||
267 | { | ||
268 | cJSON_AddBoolToObject(jPoke, "nationalRibbon", true); | ||
269 | } | ||
270 | |||
271 | if (miscRibbons & EARTH_RIBBON) | ||
272 | { | ||
273 | cJSON_AddBoolToObject(jPoke, "earthRibbon", true); | ||
274 | } | ||
275 | |||
276 | if (miscRibbons & WORLD_RIBBON) | ||
277 | { | ||
278 | cJSON_AddBoolToObject(jPoke, "worldRibbon", true); | ||
279 | } | ||
280 | |||
214 | return jPoke; | 281 | return jPoke; |
215 | } | 282 | } |