mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-28 01:49:33 -06:00

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@303 8ced0084-cf51-0410-be5f-012b33b47a6e
57 lines
1.1 KiB
C++
57 lines
1.1 KiB
C++
#include "Common.h"
|
|
|
|
#include "State.h"
|
|
#include "CoreTiming.h"
|
|
#include "HW/HW.h"
|
|
#include "PowerPC/PowerPC.h"
|
|
|
|
#include <string>
|
|
|
|
static int ev_Save;
|
|
static int ev_Load;
|
|
|
|
static std::string cur_filename;
|
|
|
|
void DoState(ChunkFile &f)
|
|
{
|
|
f.Descend("DOLP");
|
|
PowerPC::DoState(f);
|
|
HW::DoState(f);
|
|
f.Ascend();
|
|
}
|
|
|
|
void SaveStateCallback(u64 userdata, int cyclesLate)
|
|
{
|
|
ChunkFile f(cur_filename.c_str(), ChunkFile::MODE_WRITE);
|
|
DoState(f);
|
|
}
|
|
|
|
void LoadStateCallback(u64 userdata, int cyclesLate)
|
|
{
|
|
ChunkFile f(cur_filename.c_str(), ChunkFile::MODE_READ);
|
|
DoState(f);
|
|
}
|
|
|
|
void State_Init()
|
|
{
|
|
ev_Load = CoreTiming::RegisterEvent("LoadState", &LoadStateCallback);
|
|
ev_Save = CoreTiming::RegisterEvent("SaveState", &SaveStateCallback);
|
|
}
|
|
|
|
void State_Shutdown()
|
|
{
|
|
// nothing to do, here for consistency.
|
|
}
|
|
|
|
void SaveState(const char *filename)
|
|
{
|
|
cur_filename = filename;
|
|
CoreTiming::ScheduleEvent_Threadsafe(0, ev_Save);
|
|
}
|
|
|
|
void LoadState(const char *filename)
|
|
{
|
|
cur_filename = filename;
|
|
CoreTiming::ScheduleEvent_Threadsafe(0, ev_Load);
|
|
}
|