pokeemerald/src/reload_save.c

31 lines
933 B
C
Raw Normal View History

2017-09-16 04:12:45 +02:00
#include "global.h"
#include "main.h"
#include "gpu_regs.h"
#include "m4a.h"
#include "load_save.h"
#include "save.h"
#include "new_game.h"
2017-10-12 09:06:19 +02:00
#include "overworld.h"
#include "malloc.h"
2017-09-16 04:12:45 +02:00
// Reloads the game, continuing from the point of the last save
// Used to gracefully exit after a link connection error
void ReloadSave(void)
2017-09-16 04:12:45 +02:00
{
u16 imeBackup = REG_IME;
2017-09-16 04:12:45 +02:00
REG_IME = 0;
RegisterRamReset(RESET_EWRAM);
2018-02-08 00:00:25 +01:00
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_FORCED_BLANK);
2017-09-16 04:12:45 +02:00
REG_IME = imeBackup;
gMain.inBattle = FALSE;
SetSaveBlocksPointers(GetSaveBlocksPointersBaseOffset());
ResetMenuAndMonGlobals();
2018-02-15 23:54:34 +01:00
Save_ResetSaveCounters();
2021-10-29 04:54:41 +02:00
LoadGameSave(SAVE_NORMAL);
2020-01-12 21:27:37 +01:00
if (gSaveFileStatus == SAVE_STATUS_EMPTY || gSaveFileStatus == SAVE_STATUS_CORRUPT)
2017-09-16 04:12:45 +02:00
Sav2_ClearSetDefault();
SetPokemonCryStereo(gSaveBlock2Ptr->optionsSound);
InitHeap(gHeap, HEAP_SIZE);
2018-02-14 00:58:22 +01:00
SetMainCallback2(CB2_ContinueSavedGame);
2017-09-16 04:12:45 +02:00
}