diff options
author | ProjectRevoTPP <projectrevotpp@hotmail.com> | 2016-12-12 02:08:36 -0500 |
---|---|---|
committer | YamaArashi <YamaArashi@users.noreply.github.com> | 2016-12-11 23:08:36 -0800 |
commit | 36214115534dd9329b5c02d78595967e671b6caf (patch) | |
tree | 953d530079418c9e69679ecc74bde7df367089b9 /src/load_save.c | |
parent | cd1db96498c4ac9ec940611a114a604800e12c2a (diff) |
decompile load_save.c (#125)
* start decompiling load_save.c
* almost finish decompiling load_save.c
* finish decompiling load_save.c
* i cannot hex math
* formatting
Diffstat (limited to 'src/load_save.c')
-rw-r--r-- | src/load_save.c | 165 |
1 files changed, 165 insertions, 0 deletions
diff --git a/src/load_save.c b/src/load_save.c new file mode 100644 index 000000000..6f12718f0 --- /dev/null +++ b/src/load_save.c @@ -0,0 +1,165 @@ +#include "global.h" +#include "main.h" +#include "rom4.h" +#include "pokemon.h" + +extern u8 gPlayerPartyCount; +extern u32 gUnknown_3004820; + +struct LoadedSaveData +{ + struct ItemSlot items[20]; + struct ItemSlot keyItems[20]; + struct ItemSlot pokeBalls[16]; + struct ItemSlot TMsHMs[64]; + struct ItemSlot berries[46]; + struct SaveBlock1_2B4C_Struct unknownSaveData[16]; +}; + +extern struct LoadedSaveData gLoadedSaveData[]; + +extern u16 IdentifyFlash(void); +extern void gpu_sync_bg_hide(); + +void CheckForFlashMemory(void) +{ + if(!IdentifyFlash()) + { + gUnknown_3004820 = 1; + InitFlashTimer(); + } + else + gUnknown_3004820 = 0; +} + +u8 GetSecretBase2Field_9(void) +{ + return gSaveBlock2.specialSaveWarp; +} + +void ClearSecretBase2Field_9(void) +{ + gSaveBlock2.specialSaveWarp = 0; +} + +void SetSecretBase2Field_9(void) +{ + gSaveBlock2.specialSaveWarp = 1; +} + +void SetSecretBase2Field_9_AndHideBG(void) // note: no other function sets specialSaveWarp to values other than 0 or 1, hence clear and set distinctions. +{ + gpu_sync_bg_hide(0); // the function doesn't use the parameter passed to it, but this is necessary to match. + gSaveBlock2.specialSaveWarp = 1; +} + +void ClearSecretBase2Field_9_2(void) // duplicate function +{ + gSaveBlock2.specialSaveWarp = 0; +} + +void SavePlayerParty(void) +{ + int i; + + gSaveBlock1.playerPartyCount = gPlayerPartyCount; + + for (i = 0; i < 6; i++) + gSaveBlock1.playerParty[i] = gPlayerParty[i]; +} + +void LoadPlayerParty(void) +{ + int i; + + gPlayerPartyCount = gSaveBlock1.playerPartyCount; + + for (i = 0; i < 6; i++) + gPlayerParty[i] = gSaveBlock1.playerParty[i]; +} + +void SaveMapObjects(void) +{ + int i; + + for(i = 0; i < 16; i++) + gSaveBlock1.mapObjects[i] = gMapObjects[i]; +} + +void LoadMapObjects(void) +{ + int i; + + for(i = 0; i < 16; i++) + gMapObjects[i] = gSaveBlock1.mapObjects[i]; +} + +void SaveSerializedGame(void) +{ + SavePlayerParty(); + SaveMapObjects(); +} + +void LoadSerializedGame(void) +{ + LoadPlayerParty(); + LoadMapObjects(); +} + +void LoadPlayerData(void) +{ + int i; + + // load player items. + for(i = 0; i < 20; i++) + gLoadedSaveData->items[i] = gSaveBlock1.bagPocket_Items[i]; + + // load player key items. + for(i = 0; i < 20; i++) + gLoadedSaveData->keyItems[i] = gSaveBlock1.bagPocket_KeyItems[i]; + + // load player pokeballs. + for(i = 0; i < 16; i++) + gLoadedSaveData->pokeBalls[i] = gSaveBlock1.bagPocket_PokeBalls[i]; + + // load player TMs and HMs. + for(i = 0; i < 64; i++) + gLoadedSaveData->TMsHMs[i] = gSaveBlock1.bagPocket_TMHM[i]; + + // load player berries. + for(i = 0; i < 46; i++) + gLoadedSaveData->berries[i] = gSaveBlock1.bagPocket_Berries[i]; + + // load misc data. + for(i = 0; i < 16; i++) + gLoadedSaveData->unknownSaveData[i] = gSaveBlock1.unkSave[i]; +} + +void SavePlayerData(void) +{ + int i; + + // save player items. + for(i = 0; i < 20; i++) + gSaveBlock1.bagPocket_Items[i] = gLoadedSaveData->items[i]; + + // save player key items. + for(i = 0; i < 20; i++) + gSaveBlock1.bagPocket_KeyItems[i] = gLoadedSaveData->keyItems[i]; + + // save player pokeballs. + for(i = 0; i < 16; i++) + gSaveBlock1.bagPocket_PokeBalls[i] = gLoadedSaveData->pokeBalls[i]; + + // save player TMs and HMs. + for(i = 0; i < 64; i++) + gSaveBlock1.bagPocket_TMHM[i] = gLoadedSaveData->TMsHMs[i]; + + // save player berries. + for(i = 0; i < 46; i++) + gSaveBlock1.bagPocket_Berries[i] = gLoadedSaveData->berries[i]; + + // save misc data. + for(i = 0; i < 16; i++) + gSaveBlock1.unkSave[i] = gLoadedSaveData->unknownSaveData[i]; +} |