Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
versioning.c
Go to the documentation of this file.
1#include "dx/versioning.h"
2#include "dx/config.h"
3#include "gcc/string.h"
4
7
10 SaveData* saveData = &gCurrentSaveFile;
11 s32 i, j;
12
13 saveData->player = gPlayerData;
14
15 saveData->areaID = gGameStatus.areaID;
16 saveData->mapID = gGameStatus.mapID;
17 saveData->entryID = gGameStatus.entryID;
18 saveData->savePos.x = gGameStatus.savedPos.x;
19 saveData->savePos.y = gGameStatus.savedPos.y;
20 saveData->savePos.z = gGameStatus.savedPos.z;
21
22 for (i = 0; i < ARRAY_COUNT(gCurrentEncounter.defeatFlags[0]); i++) {
23 for (j = 0; j < ARRAY_COUNT(gCurrentEncounter.defeatFlags); j++) {
24 saveData->enemyDefeatFlags[j][i] = gCurrentEncounter.defeatFlags[j][i];
25 }
26 }
27
32}
33
37 SaveData* saveData = &gCurrentSaveFile;
38
39 if (saveData->modName[0] == '\0') {
40 // handle loading vanilla saves here
42 } else if (strcmp(saveData->modName, DX_MOD_NAME) != 0) {
43 // handle loading saves from other mods here
44 // by default, dx assumes other mod save data format is vanilla
46 } else if (saveData->majorVersion != DX_MOD_VER_MAJOR) {
47 // handle breaking changes between major versions here
49 } else {
51 }
52
57}
58
62 SaveData* saveData = &gCurrentSaveFile;
63 s32 i, j;
64
65 // simply copy the saved player data
66 gPlayerData = saveData->player;
67
68 // copy saved game status fields to GameStatus
69 gGameStatus.areaID = saveData->areaID;
70 gGameStatus.mapID = saveData->mapID;
71 gGameStatus.entryID = saveData->entryID;
72 gGameStatus.savedPos.x = saveData->savePos.x;
73 gGameStatus.savedPos.y = saveData->savePos.y;
74 gGameStatus.savedPos.z = saveData->savePos.z;
75
76 // copy saved enemy defeat flags
77 for (i = 0; i < ARRAY_COUNT(gCurrentEncounter.defeatFlags[0]); i++) {
78 for (j = 0; j < ARRAY_COUNT(gCurrentEncounter.defeatFlags); j++) {
79 gCurrentEncounter.defeatFlags[j][i] = saveData->enemyDefeatFlags[j][i];
80 }
81 }
82}
83
84void ver_copy_s8_array(s8* dest, s8* src, s32 srcMax, s32 destMax) {
85 s32 i;
86 for (i = 0; i < srcMax; i++) {
87 dest[i] = src[i];
88 }
89 for (; i < destMax; i++) {
90 dest[i] = 0;
91 }
92}
93
94void ver_copy_s16_array(s16* dest, s16* src, s32 srcMax, s32 destMax) {
95 s32 i;
96 for (i = 0; i < srcMax; i++) {
97 dest[i] = src[i];
98 }
99 for (; i < destMax; i++) {
100 dest[i] = 0;
101 }
102}
103
104void ver_copy_s32_array(s32* dest, s32* src, s32 srcMax, s32 destMax) {
105 s32 i;
106 for (i = 0; i < srcMax; i++) {
107 dest[i] = src[i];
108 }
109 for (; i < destMax; i++) {
110 dest[i] = 0;
111 }
112}
113
114void ver_port_item_ids(s16* array, s16* mapping, s32 size, s32 mapMax) {
115 s32 i;
116
117 for (i = 0; i < size; i++) {
118 s16 old = array[i];
119 if (old < mapMax) {
120 array[i] = mapping[old];
121 } else {
122 array[i] = ITEM_NONE;
123 }
124 }
125}
126
127#define COPY_S8_ARRAY(new, old) ver_copy_s8_array(new, old, ARRAY_COUNT(old), ARRAY_COUNT(new));
128#define COPY_S16_ARRAY(new, old) ver_copy_s16_array(new, old, ARRAY_COUNT(old), ARRAY_COUNT(new));
129#define COPY_S32_ARRAY(new, old) ver_copy_s32_array(new, old, ARRAY_COUNT(old), ARRAY_COUNT(new));
130
131#define PORT_ITEM_IDS(array, map) ver_copy_s16_array(array, map, ARRAY_COUNT(array), ARRAY_COUNT(map));
132
133// Maps vanilla itemIDs to enum values which may have changed in the mod
134// If your mod removes an item, you can remap it to ITEM_NONE or something else here.
136 [0x000] ITEM_NONE,
137 [0x001] ITEM_BOOTS,
138 [0x002] ITEM_SUPER_BOOTS,
139 [0x003] ITEM_ULTRA_BOOTS,
140 [0x004] ITEM_HAMMER,
141 [0x005] ITEM_SUPER_HAMMER,
142 [0x006] ITEM_ULTRA_HAMMER,
143 [0x007] ITEM_LUCKY_STAR,
144 [0x008] ITEM_MAP,
145 [0x009] ITEM_BIG_MAP,
146 [0x00A] ITEM_FIRST_DEGREE_CARD,
147 [0x00B] ITEM_SECOND_DEGREE_CARD,
148 [0x00C] ITEM_THIRD_DEGREE_CARD,
149 [0x00D] ITEM_FOURTH_DEGREE_CARD,
150 [0x00E] ITEM_DIPLOMA,
151 [0x00F] ITEM_ULTRA_STONE,
152 [0x010] ITEM_KOOPA_FORTRESS_KEY,
153 [0x011] ITEM_RUINS_KEY,
154 [0x012] ITEM_PULSE_STONE,
155 [0x013] ITEM_TUBBA_CASTLE_KEY,
156 [0x014] ITEM_CRYSTAL_PALACE_KEY,
157 [0x015] ITEM_LUNAR_STONE,
158 [0x016] ITEM_PYRAMID_STONE,
159 [0x017] ITEM_DIAMOND_STONE,
160 [0x018] ITEM_GOLDEN_JAR,
161 [0x019] ITEM_KOOPER_SHELL,
162 [0x01A] ITEM_BOWSER_CASTLE_KEY,
163 [0x01B] ITEM_FOREST_PASS,
164 [0x01C] ITEM_BOO_WEIGHT,
165 [0x01D] ITEM_BOO_PORTRAIT,
166 [0x01E] ITEM_CRYSTAL_BERRY,
167 [0x01F] ITEM_MYSTICAL_KEY,
168 [0x020] ITEM_STOREROOM_KEY,
169 [0x021] ITEM_TOY_TRAIN,
170 [0x022] ITEM_BOO_RECORD,
171 [0x023] ITEM_FRYING_PAN,
172 [0x024] ITEM_DICTIONARY,
173 [0x025] ITEM_MYSTERY_NOTE,
174 [0x026] ITEM_SUSPICIOUS_NOTE,
175 [0x027] ITEM_CRYSTAL_BALL,
176 [0x028] ITEM_SCREWDRIVER,
177 [0x029] ITEM_COOKBOOK,
178 [0x02A] ITEM_JADE_RAVEN,
179 [0x02B] ITEM_MAGICAL_SEED1,
180 [0x02C] ITEM_MAGICAL_SEED2,
181 [0x02D] ITEM_MAGICAL_SEED3,
182 [0x02E] ITEM_MAGICAL_SEED4,
183 [0x02F] ITEM_TOAD_DOLL,
184 [0x030] ITEM_CALCULATOR,
185 [0x031] ITEM_SNOWMAN_BUCKET,
186 [0x032] ITEM_SNOWMAN_SCARF,
187 [0x033] ITEM_RED_KEY,
188 [0x034] ITEM_BLUE_KEY,
189 [0x035] ITEM_UNUSED_LETTER_1,
190 [0x036] ITEM_LETTER_TO_MERLON,
191 [0x037] ITEM_LETTER_TO_GOOMPA,
192 [0x038] ITEM_LETTER_TO_MORT_T,
193 [0x039] ITEM_LETTER_TO_RUSS_T,
194 [0x03A] ITEM_LETTER_TO_MAYOR_PENGUIN,
195 [0x03B] ITEM_LETTER_TO_MERLOW,
196 [0x03C] ITEM_LETTER_TO_FICE_T,
197 [0x03D] ITEM_LETTER_TO_NOMADIMOUSE,
198 [0x03E] ITEM_LETTER_TO_MINH_T,
199 [0x03F] ITEM_UNUSED_LETTER_2,
200 [0x040] ITEM_LETTER_CHAIN_GOOMPAPA_1,
201 [0x041] ITEM_LETTER_TO_IGOR,
202 [0x042] ITEM_UNUSED_LETTER_3,
203 [0x043] ITEM_UNUSED_LETTER_4,
204 [0x044] ITEM_UNUSED_LETTER_5,
205 [0x045] ITEM_LETTER_CHAIN_FRANKY,
206 [0x046] ITEM_LETTER_CHAIN_MUSS_T,
207 [0x047] ITEM_LETTER_CHAIN_KOOVER_1,
208 [0x048] ITEM_LETTER_CHAIN_FISHMAEL,
209 [0x049] ITEM_LETTER_CHAIN_KOOVER_2,
210 [0x04A] ITEM_LETTER_CHAIN_MR_E,
211 [0x04B] ITEM_LETTER_CHAIN_MISS_T,
212 [0x04C] ITEM_LETTER_CHAIN_LITTLE_MOUSER,
213 [0x04D] ITEM_UNUSED_LETTER_6,
214 [0x04E] ITEM_LETTER_CHAIN_DANE_T_1,
215 [0x04F] ITEM_LETTER_CHAIN_YOSHI_KID,
216 [0x050] ITEM_LETTER_CHAIN_DANE_T_2,
217 [0x051] ITEM_LETTER_CHAIN_FROST_T,
218 [0x052] ITEM_LETTER_CHAIN_GOOMPAPA_2,
219 [0x053] ITEM_ARTIFACT,
220 [0x054] ITEM_LETTER_TO_KOLORADO,
221 [0x055] ITEM_UNUSED_LETTER_7,
222 [0x056] ITEM_DOLLY,
223 [0x057] ITEM_WATER_STONE,
224 [0x058] ITEM_MAGICAL_BEAN,
225 [0x059] ITEM_FERTILE_SOIL,
226 [0x05A] ITEM_MIRACLE_WATER,
227 [0x05B] ITEM_VOLCANO_VASE,
228 [0x05C] ITEM_KOOT_THE_TAPE,
229 [0x05D] ITEM_BAKING_SUGAR,
230 [0x05E] ITEM_BAKING_SALT,
231 [0x05F] ITEM_BAKING_EGG,
232 [0x060] ITEM_BAKING_CREAM,
233 [0x061] ITEM_BAKING_STRAWBERRY,
234 [0x062] ITEM_BAKING_BUTTER,
235 [0x063] ITEM_BAKING_CLEANSER,
236 [0x064] ITEM_BAKING_WATER,
237 [0x065] ITEM_BAKING_FLOUR,
238 [0x066] ITEM_BAKING_MILK,
239 [0x067] ITEM_LYRICS,
240 [0x068] ITEM_MELODY,
241 [0x069] ITEM_MAILBAG,
242 [0x06A] ITEM_PEACH_KEY,
243 [0x06B] ITEM_ODD_KEY,
244 [0x06C] ITEM_STAR_STONE,
245 [0x06D] ITEM_SNEAKY_PARASOL,
246 [0x06E] ITEM_KOOT_KOOPA_LEGENDS,
247 [0x06F] ITEM_KOOT_LUIGI_AUTOGRAPH,
248 [0x070] ITEM_KOOT_EMPTY_WALLET,
249 [0x071] ITEM_KOOT_MERLUVLEE_AUTOGRAPH,
250 [0x072] ITEM_KOOT_SHELL,
251 [0x073] ITEM_KOOT_OLD_PHOTO,
252 [0x074] ITEM_KOOT_GLASSES,
253 [0x075] ITEM_KOOT_ALT_PHOTO,
254 [0x076] ITEM_KOOT_PACKAGE,
255 [0x077] ITEM_KOOT_RED_JAR,
256 [0x078] ITEM_UNUSED_PEACH_KEY,
257 [0x079] ITEM_WAREHOUSE_KEY,
258 [0x07A] ITEM_PRISON_KEY,
259 [0x07B] ITEM_SILVER_CREDIT,
260 [0x07C] ITEM_GOLD_CREDIT,
261 [0x07D] ITEM_UNUSED_PRISON_KEY_1,
262 [0x07E] ITEM_UNUSED_PRISON_KEY_2,
263 [0x07F] ITEM_UNUSED_PRISON_KEY_3,
264 [0x080] ITEM_FIRE_FLOWER,
265 [0x081] ITEM_SNOWMAN_DOLL,
266 [0x082] ITEM_THUNDER_RAGE,
267 [0x083] ITEM_SHOOTING_STAR,
268 [0x084] ITEM_THUNDER_BOLT,
269 [0x085] ITEM_PEBBLE,
270 [0x086] ITEM_DUSTY_HAMMER,
271 [0x087] ITEM_INSECTICIDE_HERB,
272 [0x088] ITEM_STONE_CAP,
273 [0x089] ITEM_TASTY_TONIC,
274 [0x08A] ITEM_MUSHROOM,
275 [0x08B] ITEM_VOLT_SHROOM,
276 [0x08C] ITEM_SUPER_SHROOM,
277 [0x08D] ITEM_DRIED_SHROOM,
278 [0x08E] ITEM_ULTRA_SHROOM,
279 [0x08F] ITEM_SLEEPY_SHEEP,
280 [0x090] ITEM_POW_BLOCK,
281 [0x091] ITEM_HUSTLE_DRINK,
282 [0x092] ITEM_STOP_WATCH,
283 [0x093] ITEM_WHACKAS_BUMP,
284 [0x094] ITEM_APPLE,
285 [0x095] ITEM_LIFE_SHROOM,
286 [0x096] ITEM_MYSTERY,
287 [0x097] ITEM_REPEL_GEL,
288 [0x098] ITEM_FRIGHT_JAR,
289 [0x099] ITEM_PLEASE_COME_BACK,
290 [0x09A] ITEM_DIZZY_DIAL,
291 [0x09B] ITEM_SUPER_SODA,
292 [0x09C] ITEM_LEMON,
293 [0x09D] ITEM_LIME,
294 [0x09E] ITEM_BLUE_BERRY,
295 [0x09F] ITEM_RED_BERRY,
296 [0x0A0] ITEM_YELLOW_BERRY,
297 [0x0A1] ITEM_BUBBLE_BERRY,
298 [0x0A2] ITEM_JAMMIN_JELLY,
299 [0x0A3] ITEM_MAPLE_SYRUP,
300 [0x0A4] ITEM_HONEY_SYRUP,
301 [0x0A5] ITEM_GOOMNUT,
302 [0x0A6] ITEM_KOOPA_LEAF,
303 [0x0A7] ITEM_DRIED_PASTA,
304 [0x0A8] ITEM_DRIED_FRUIT,
305 [0x0A9] ITEM_STRANGE_LEAF,
306 [0x0AA] ITEM_CAKE_MIX,
307 [0x0AB] ITEM_EGG,
308 [0x0AC] ITEM_COCONUT,
309 [0x0AD] ITEM_MELON,
310 [0x0AE] ITEM_STINKY_HERB,
311 [0x0AF] ITEM_ICED_POTATO,
312 [0x0B0] ITEM_SPICY_SOUP,
313 [0x0B1] ITEM_APPLE_PIE,
314 [0x0B2] ITEM_HONEY_ULTRA,
315 [0x0B3] ITEM_MAPLE_ULTRA,
316 [0x0B4] ITEM_JELLY_ULTRA,
317 [0x0B5] ITEM_KOOPASTA,
318 [0x0B6] ITEM_FRIED_SHROOM,
319 [0x0B7] ITEM_SHROOM_CAKE,
320 [0x0B8] ITEM_SHROOM_STEAK,
321 [0x0B9] ITEM_HOT_SHROOM,
322 [0x0BA] ITEM_SWEET_SHROOM,
323 [0x0BB] ITEM_YUMMY_MEAL,
324 [0x0BC] ITEM_HEALTHY_JUICE,
325 [0x0BD] ITEM_BLAND_MEAL,
326 [0x0BE] ITEM_DELUXE_FEAST,
327 [0x0BF] ITEM_SPECIAL_SHAKE,
328 [0x0C0] ITEM_BIG_COOKIE,
329 [0x0C1] ITEM_CAKE,
330 [0x0C2] ITEM_MISTAKE,
331 [0x0C3] ITEM_KOOPA_TEA,
332 [0x0C4] ITEM_HONEY_SUPER,
333 [0x0C5] ITEM_MAPLE_SUPER,
334 [0x0C6] ITEM_JELLY_SUPER,
335 [0x0C7] ITEM_SPAGHETTI,
336 [0x0C8] ITEM_EGG_MISSILE,
337 [0x0C9] ITEM_FRIED_EGG,
338 [0x0CA] ITEM_HONEY_SHROOM,
339 [0x0CB] ITEM_HONEY_CANDY,
340 [0x0CC] ITEM_ELECTRO_POP,
341 [0x0CD] ITEM_FIRE_POP,
342 [0x0CE] ITEM_LIME_CANDY,
343 [0x0CF] ITEM_COCO_POP,
344 [0x0D0] ITEM_LEMON_CANDY,
345 [0x0D1] ITEM_JELLY_POP,
346 [0x0D2] ITEM_STRANGE_CAKE,
347 [0x0D3] ITEM_KOOKY_COOKIE,
348 [0x0D4] ITEM_FROZEN_FRIES,
349 [0x0D5] ITEM_POTATO_SALAD,
350 [0x0D6] ITEM_NUTTY_CAKE,
351 [0x0D7] ITEM_MAPLE_SHROOM,
352 [0x0D8] ITEM_BOILED_EGG,
353 [0x0D9] ITEM_YOSHI_COOKIE,
354 [0x0DA] ITEM_JELLY_SHROOM,
355 [0x0DB] ITEM_UNUSED_JELLY_SHROOM_1,
356 [0x0DC] ITEM_UNUSED_JELLY_SHROOM_2,
357 [0x0DD] ITEM_UNUSED_JELLY_SHROOM_3,
358 [0x0DE] ITEM_UNUSED_JELLY_SHROOM_4,
359 [0x0DF] ITEM_UNUSED_JELLY_SHROOM_5,
360 [0x0E0] ITEM_SPIN_SMASH,
361 [0x0E1] ITEM_MULTIBOUNCE,
362 [0x0E2] ITEM_POWER_PLUS_A,
363 [0x0E3] ITEM_DODGE_MASTER,
364 [0x0E4] ITEM_POWER_BOUNCE,
365 [0x0E5] ITEM_SPIKE_SHIELD,
366 [0x0E6] ITEM_FIRST_ATTACK,
367 [0x0E7] ITEM_HP_PLUS_A,
368 [0x0E8] ITEM_QUAKE_HAMMER,
369 [0x0E9] ITEM_DOUBLE_DIP,
370 [0x0EA] ITEM_MYSTERY_SCROLL,
371 [0x0EB] ITEM_SLEEP_STOMP,
372 [0x0EC] ITEM_FIRE_SHIELD,
373 [0x0ED] ITEM_QUICK_CHANGE,
374 [0x0EE] ITEM_D_DOWN_POUND,
375 [0x0EF] ITEM_DIZZY_STOMP,
376 [0x0F0] ITEM_SMASH_CHARGE0,
377 [0x0F1] ITEM_PRETTY_LUCKY,
378 [0x0F2] ITEM_FEELING_FINE,
379 [0x0F3] ITEM_ATTACK_FX_A,
380 [0x0F4] ITEM_ALLOR_NOTHING,
381 [0x0F5] ITEM_HP_DRAIN,
382 [0x0F6] ITEM_JUMP_CHARGE0,
383 [0x0F7] ITEM_SLOW_GO,
384 [0x0F8] ITEM_FP_PLUS_A,
385 [0x0F9] ITEM_MEGA_RUSH,
386 [0x0FA] ITEM_ICE_POWER,
387 [0x0FB] ITEM_DEFEND_PLUS_A,
388 [0x0FC] ITEM_PAY_OFF,
389 [0x0FD] ITEM_MONEY_MONEY,
390 [0x0FE] ITEM_CHILL_OUT,
391 [0x0FF] ITEM_HAPPY_HEART_A,
392 [0x100] ITEM_ZAP_TAP,
393 [0x101] ITEM_BERSERKER,
394 [0x102] ITEM_RIGHT_ON,
395 [0x103] ITEM_RUNAWAY_PAY,
396 [0x104] ITEM_REFUND,
397 [0x105] ITEM_FLOWER_SAVER_A,
398 [0x106] ITEM_TRIPLE_DIP,
399 [0x107] ITEM_HAMMER_THROW,
400 [0x108] ITEM_MEGA_QUAKE,
401 [0x109] ITEM_SMASH_CHARGE,
402 [0x10A] ITEM_JUMP_CHARGE,
403 [0x10B] ITEM_S_SMASH_CHG,
404 [0x10C] ITEM_S_JUMP_CHG,
405 [0x10D] ITEM_POWER_RUSH,
406 [0x10E] ITEM_AUTO_JUMP,
407 [0x10F] ITEM_AUTO_SMASH,
408 [0x110] ITEM_CRAZY_HEART,
409 [0x111] ITEM_LAST_STAND,
410 [0x112] ITEM_CLOSE_CALL,
411 [0x113] ITEM_P_UP_D_DOWN,
412 [0x114] ITEM_LUCKY_DAY,
413 [0x115] ITEM_MEGA_HP_DRAIN,
414 [0x116] ITEM_P_DOWN_D_UP,
415 [0x117] ITEM_POWER_QUAKE,
416 [0x118] ITEM_AUTO_MULTIBOUNCE,
417 [0x119] ITEM_FLOWER_FANATIC,
418 [0x11A] ITEM_HEART_FINDER,
419 [0x11B] ITEM_FLOWER_FINDER,
420 [0x11C] ITEM_SPIN_ATTACK,
421 [0x11D] ITEM_DIZZY_ATTACK,
422 [0x11E] ITEM_I_SPY,
423 [0x11F] ITEM_SPEEDY_SPIN,
424 [0x120] ITEM_BUMP_ATTACK,
425 [0x121] ITEM_POWER_JUMP,
426 [0x122] ITEM_SUPER_JUMP,
427 [0x123] ITEM_MEGA_JUMP,
428 [0x124] ITEM_POWER_SMASH,
429 [0x125] ITEM_SUPER_SMASH,
430 [0x126] ITEM_MEGA_SMASH,
431 [0x127] ITEM_UNUSED_POWER_SMASH_1,
432 [0x128] ITEM_UNUSED_POWER_SMASH_2,
433 [0x129] ITEM_DEEP_FOCUS_A,
434 [0x12A] ITEM_SUPER_FOCUS,
435 [0x12B] ITEM_SHRINK_SMASH,
436 [0x12C] ITEM_SHELL_CRACK,
437 [0x12D] ITEM_KAIDEN,
438 [0x12E] ITEM_D_DOWN_JUMP,
439 [0x12F] ITEM_SHRINK_STOMP,
440 [0x130] ITEM_DAMAGE_DODGE_A,
441 [0x131] ITEM_EARTHQUAKE_JUMP,
442 [0x132] ITEM_DEEP_FOCUS_B,
443 [0x133] ITEM_DEEP_FOCUS_C,
444 [0x134] ITEM_HP_PLUS_B,
445 [0x135] ITEM_FP_PLUS_B,
446 [0x136] ITEM_HAPPY_HEART_B,
447 [0x137] ITEM_HAPPY_HEART_X,
448 [0x138] ITEM_FLOWER_SAVER_B,
449 [0x139] ITEM_FLOWER_SAVER_X,
450 [0x13A] ITEM_DAMAGE_DODGE_B,
451 [0x13B] ITEM_DAMAGE_DODGE_X,
452 [0x13C] ITEM_POWER_PLUS_B,
453 [0x13D] ITEM_POWER_PLUS_X,
454 [0x13E] ITEM_DEFEND_PLUS_X,
455 [0x13F] ITEM_DEFEND_PLUS_Y,
456 [0x140] ITEM_HAPPY_FLOWER_A,
457 [0x141] ITEM_HAPPY_FLOWER_B,
458 [0x142] ITEM_HAPPY_FLOWER_X,
459 [0x143] ITEM_GROUP_FOCUS,
460 [0x144] ITEM_PEEKABOO,
461 [0x145] ITEM_ATTACK_FX_D,
462 [0x146] ITEM_ATTACK_FX_B,
463 [0x147] ITEM_ATTACK_FX_E,
464 [0x148] ITEM_ATTACK_FX_C,
465 [0x149] ITEM_ATTACK_FX_F,
466 [0x14A] ITEM_HP_PLUS_C,
467 [0x14B] ITEM_HP_PLUS_X,
468 [0x14C] ITEM_HP_PLUS_Y,
469 [0x14D] ITEM_FP_PLUS_C,
470 [0x14E] ITEM_FP_PLUS_X,
471 [0x14F] ITEM_FP_PLUS_Y,
472 [0x150] ITEM_HEALTHY_HEALTHY,
473 [0x151] ITEM_UNUSED_ATTACK_FX_1,
474 [0x152] ITEM_UNUSED_ATTACK_FX_2,
475 [0x153] ITEM_UNUSED_ATTACK_FX_3,
476 [0x154] ITEM_UNUSED_ATTACK_FX_4,
477 [0x155] ITEM_PARTNER_ATTACK,
478 [0x156] ITEM_HEART,
479 [0x157] ITEM_COIN,
480 [0x158] ITEM_HEART_PIECE,
481 [0x159] ITEM_STAR_POINT,
482 [0x15A] ITEM_HEART_POINT,
483 [0x15B] ITEM_FLOWER_POINT,
484 [0x15C] ITEM_STAR_PIECE,
485 [0x15D] ITEM_PRESENT,
486 [0x15E] ITEM_CAKE_DONE,
487 [0x15F] ITEM_CAKE_BARE,
488 [0x160] ITEM_CAKE_PAN,
489 [0x161] ITEM_CAKE_BATTER,
490 [0x162] ITEM_CAKE_BOWL,
491 [0x163] ITEM_CAKE_MIXED,
492 [0x164] ITEM_CAKE_WITH_ICING,
493 [0x165] ITEM_CAKE_WITH_BERRIES,
494 [0x166] ITEM_MENU_HAMMER1,
495 [0x167] ITEM_MENU_HAMMER2,
496 [0x168] ITEM_MENU_HAMMER3,
497 [0x169] ITEM_MENU_BOOTS1,
498 [0x16A] ITEM_MENU_BOOTS2,
499 [0x16B] ITEM_MENU_BOOTS3,
500 [0x16C] ITEM_MENU_ITEMS,
501};
502
504 VanillaSaveData oldSave;
505 s32 i, j;
506
507 memcpy(&oldSave, newSave, sizeof(VanillaSaveData));
508 memset(newSave, 0, sizeof(SaveData));
509
510 strcpy(newSave->magicString, oldSave.magicString);
511 memcpy(newSave->modName, oldSave.version, ARRAY_COUNT(oldSave.version));
512
513 // copy metadata
514 newSave->saveSlot = oldSave.saveSlot;
515 newSave->saveCount = oldSave.saveCount;
516 memcpy(newSave->summary.filename, oldSave.summary.filename, ARRAY_COUNT(newSave->summary.filename));
517 newSave->summary.level = oldSave.summary.level;
518 newSave->summary.timePlayed = oldSave.summary.timePlayed;
519 newSave->summary.spiritsRescued = oldSave.summary.spiritsRescued;
520
521 // copy world location
522 newSave->areaID = oldSave.areaID;
523 newSave->mapID = oldSave.mapID;
524 newSave->entryID = oldSave.entryID;
525 newSave->savePos = oldSave.savePos;
526
527 // defeat flags are unchanged
528 for (i = 0; i < ARRAY_COUNT(gCurrentEncounter.defeatFlags[0]); i++) {
529 for (j = 0; j < ARRAY_COUNT(gCurrentEncounter.defeatFlags); j++) {
530 gCurrentEncounter.defeatFlags[j][i] = newSave->enemyDefeatFlags[j][i];
531 }
532 }
533
534 // saved variable arrays may have been expanded
535 COPY_S32_ARRAY(newSave->globalFlags, oldSave.globalFlags);
536 COPY_S32_ARRAY(newSave->areaFlags, oldSave.areaFlags);
537 COPY_S8_ARRAY(newSave->globalBytes, oldSave.globalBytes);
538 COPY_S8_ARRAY(newSave->areaBytes, oldSave.areaBytes);
539
540 PlayerData* newPlayer = &newSave->player;
541 VanillaPlayerData* oldPlayer = &oldSave.player;
542
543 newPlayer->curHP = oldPlayer->curHP;
544 newPlayer->curMaxHP = oldPlayer->curMaxHP;
545 newPlayer->hardMaxHP = oldPlayer->hardMaxHP;
546 newPlayer->curFP = oldPlayer->curFP;
547 newPlayer->curMaxFP = oldPlayer->curMaxFP;
548 newPlayer->hardMaxFP = oldPlayer->hardMaxFP;
549 newPlayer->maxBP = oldPlayer->maxBP;
550
551 newPlayer->level = oldPlayer->level;
552 newPlayer->starPoints = oldPlayer->starPoints;
553
554 newPlayer->bootsLevel = oldPlayer->bootsLevel;
555 newPlayer->hammerLevel = oldPlayer->hammerLevel;
556 newPlayer->hasActionCommands = oldPlayer->hasActionCommands;
557
558 newPlayer->coins = oldPlayer->coins;
559 newPlayer->starPieces = oldPlayer->starPieces;
560
561 newPlayer->curPartner = oldPlayer->curPartner;
562 for (i = 0; i < ARRAY_COUNT(oldPlayer->partners); i++) {
563 newPlayer->partners[i].enabled = oldPlayer->partners[i].enabled;
564 newPlayer->partners[i].level = oldPlayer->partners[i].level;
565 }
566
567 COPY_S16_ARRAY(newPlayer->keyItems, oldPlayer->keyItems);
568 COPY_S16_ARRAY(newPlayer->badges, oldPlayer->badges);
569 COPY_S16_ARRAY(newPlayer->invItems, oldPlayer->invItems);
570 COPY_S16_ARRAY(newPlayer->storedItems, oldPlayer->storedItems);
571 COPY_S16_ARRAY(newPlayer->equippedBadges, oldPlayer->equippedBadges);
572
578
579 newPlayer->merleeSpellType = oldPlayer->merleeSpellType;
580 newPlayer->merleeCastsLeft = oldPlayer->merleeCastsLeft;
581 newPlayer->merleeTurnCount = oldPlayer->merleeTurnCount;
582
583 newPlayer->starPower = oldPlayer->starPower;
584 newPlayer->maxStarPower = oldPlayer->maxStarPower;
585 newPlayer->starBeamLevel = oldPlayer->starBeamLevel;
586
587 newPlayer->actionCommandAttempts = oldPlayer->actionCommandAttempts;
588 newPlayer->actionCommandSuccesses = oldPlayer->actionCommandSuccesses;
589 newPlayer->hitsTaken = oldPlayer->hitsTaken;
590 newPlayer->hitsBlocked = oldPlayer->hitsBlocked;
591 newPlayer->playerFirstStrikes = oldPlayer->playerFirstStrikes;
592 newPlayer->enemyFirstStrikes = oldPlayer->enemyFirstStrikes;
593 newPlayer->powerBounces = oldPlayer->powerBounces;
594 newPlayer->battlesCount = oldPlayer->battlesCount;
595 newPlayer->battlesWon = oldPlayer->battlesWon;
596 newPlayer->fleeAttempts = oldPlayer->fleeAttempts;
597 newPlayer->battlesFled = oldPlayer->battlesFled;
598 newPlayer->trainingsDone = oldPlayer->trainingsDone;
599 newPlayer->walkingStepsTaken = oldPlayer->walkingStepsTaken;
600 newPlayer->runningStepsTaken = oldPlayer->runningStepsTaken;
601 newPlayer->totalCoinsEarned = oldPlayer->totalCoinsEarned;
602 newPlayer->idleFrameCounter = oldPlayer->idleFrameCounter;
603 newPlayer->frameCounter = oldPlayer->frameCounter;
604 newPlayer->quizzesAnswered = oldPlayer->quizzesAnswered;
605 newPlayer->quizzesCorrect = oldPlayer->quizzesCorrect;
606
608 COPY_S32_ARRAY(newPlayer->partnerUsedTime, oldPlayer->partnerUsedTime);
609
610 newPlayer->tradeEventStartTime = oldPlayer->tradeEventStartTime;
611 newPlayer->droTreeHintTime = oldPlayer->droTreeHintTime;
612 newPlayer->starPiecesCollected = oldPlayer->starPiecesCollected;
613 newPlayer->jumpGamePlays = oldPlayer->jumpGamePlays;
614 newPlayer->jumpGameTotal = oldPlayer->jumpGameTotal;
615 newPlayer->jumpGameRecord = oldPlayer->jumpGameRecord;
616 newPlayer->smashGamePlays = oldPlayer->smashGamePlays;
617 newPlayer->smashGameTotal = oldPlayer->smashGameTotal;
618 newPlayer->smashGameRecord = oldPlayer->smashGameRecord;
619}
s16 equippedBadges[64]
s16 badges[128]
s16 storedItems[32]
PartnerData partners[12]
s32 tradeEventStartTime
s32 partnerUsedTime[12]
u16 actionCommandSuccesses
u16 starPiecesCollected
s32 partnerUnlockedTime[12]
u16 actionCommandAttempts
s16 keyItems[32]
s16 invItems[10]
#define DX_MOD_VER_MAJOR
Definition config.h:8
#define DX_MOD_NAME
Creates the version string that appears on the file select menu.
Definition config.h:7
@ DEBUG_CONTACT_NONE
Definition enums.h:4267
EncounterStatus gCurrentEncounter
Definition encounter.c:176
s32 defeatFlags[60][12]
Definition npc.h:403
#define ARRAY_COUNT(arr)
Definition macros.h:40
GameStatus gGameStatus
Definition main_loop.c:21
PlayerData gPlayerData
Definition 77480.c:40
void ver_port_item_ids(s16 *array, s16 *mapping, s32 size, s32 mapMax)
Definition versioning.c:114
#define COPY_S16_ARRAY(new, old)
Definition versioning.c:128
#define PORT_ITEM_IDS(array, map)
Definition versioning.c:131
#define COPY_S8_ARRAY(new, old)
Definition versioning.c:127
void ver_deserialize_vanilla_save(SaveData *save)
Definition versioning.c:503
void fio_deserialize_state()
Load game data from gCurrentSaveFile Performs version checking and supports potential migration betwe...
Definition versioning.c:36
s16 VanillaItemIDs[]
Definition versioning.c:135
void ver_copy_s16_array(s16 *dest, s16 *src, s32 srcMax, s32 destMax)
Definition versioning.c:94
#define COPY_S32_ARRAY(new, old)
Definition versioning.c:129
void ver_copy_s8_array(s8 *dest, s8 *src, s32 srcMax, s32 destMax)
Definition versioning.c:84
void ver_copy_s32_array(s32 *dest, s32 *src, s32 srcMax, s32 destMax)
Definition versioning.c:104
void ver_deserialize_standard()
Load save file data from a supported save version Assumes no changes in the SaveData,...
Definition versioning.c:61
void fio_serialize_state()
Store current game data to gCurrentSaveFile.
Definition versioning.c:9
s8 majorVersion
Definition versioning.h:146
s32 areaFlags[8]
Definition versioning.h:162
s32 globalFlags[64]
Definition versioning.h:120
s8 debugEnemyContact
Definition versioning.h:164
char magicString[16]
Definition versioning.h:108
s32 globalFlags[64]
Definition versioning.h:160
char version[32]
Definition versioning.h:109
SaveFileSummary summary
Definition versioning.h:170
VanillaPlayerData player
Definition versioning.h:114
PlayerData player
Definition versioning.h:154
s8 globalBytes[512]
Definition versioning.h:121
VanillaSaveFileSummary summary
Definition versioning.h:130
b8 debugUnused1
Definition versioning.h:165
s8 globalBytes[512]
Definition versioning.h:161
SaveData gCurrentSaveFile
Definition fio.c:21
char modName[28]
Definition versioning.h:145
char magicString[16]
Definition versioning.h:144
s32 enemyDefeatFlags[60][12]
Definition versioning.h:159
s32 saveSlot
Definition versioning.h:152
s16 equippedBadges[64]
Definition versioning.h:61
s32 saveCount
Definition versioning.h:153
b8 debugUnused2
Definition versioning.h:166
VanillaPartnerData partners[12]
Definition versioning.h:56
Vec3s savePos
Definition versioning.h:169
s32 partnerUnlockedTime[12]
Definition versioning.h:92
s16 entryID
Definition versioning.h:157
s16 storedItems[32]
Definition versioning.h:60
s8 areaBytes[16]
Definition versioning.h:163
b8 musicEnabled
Definition versioning.h:167
s32 partnerUsedTime[12]
Definition versioning.h:93
PlayerData struct from unmodified Paper Mario.
Definition versioning.h:36
SaveData struct from unmodified Paper Mario.
Definition versioning.h:107