2015-05-24 06:55:12 +02:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-18 01:08:10 +02:00
|
|
|
// Licensed under GPLv2+
|
2013-04-17 22:43:11 -04:00
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Emulator state saving support.
|
|
|
|
|
2014-02-10 13:54:46 -05:00
|
|
|
#pragma once
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2009-07-12 21:58:32 +00:00
|
|
|
#include <string>
|
2011-12-28 02:33:41 -06:00
|
|
|
#include <vector>
|
2009-07-12 21:58:32 +00:00
|
|
|
|
2014-10-21 02:01:38 -04:00
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
|
2011-03-17 10:17:45 +00:00
|
|
|
namespace State
|
2009-06-28 21:11:51 +00:00
|
|
|
{
|
|
|
|
|
2012-11-08 08:40:49 +01:00
|
|
|
// number of states
|
2013-08-02 20:42:30 -04:00
|
|
|
static const u32 NUM_STATES = 10;
|
2012-11-08 08:40:49 +01:00
|
|
|
|
|
|
|
struct StateHeader
|
|
|
|
{
|
|
|
|
u8 gameID[6];
|
|
|
|
u32 size;
|
|
|
|
double time;
|
|
|
|
};
|
|
|
|
|
2011-03-17 10:17:45 +00:00
|
|
|
void Init();
|
2011-10-15 22:19:42 +11:00
|
|
|
|
2011-03-17 10:17:45 +00:00
|
|
|
void Shutdown();
|
|
|
|
|
|
|
|
void EnableCompression(bool compression);
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2014-02-23 23:03:39 +01:00
|
|
|
bool ReadHeader(const std::string& filename, StateHeader& header);
|
2012-11-08 08:40:49 +01:00
|
|
|
|
2008-12-08 04:46:09 +00:00
|
|
|
// These don't happen instantly - they get scheduled as events.
|
2014-11-13 21:28:27 -05:00
|
|
|
// ...But only if we're not in the main CPU thread.
|
|
|
|
// If we're in the main CPU thread then they run immediately instead
|
2010-04-17 21:02:03 +00:00
|
|
|
// because some things (like Lua) need them to run immediately.
|
2008-12-08 04:46:09 +00:00
|
|
|
// Slots from 0-99.
|
2012-11-08 08:40:49 +01:00
|
|
|
void Save(int slot, bool wait = false);
|
2011-03-17 10:17:45 +00:00
|
|
|
void Load(int slot);
|
|
|
|
void Verify(int slot);
|
2009-06-28 01:11:35 +00:00
|
|
|
|
2012-11-08 08:40:49 +01:00
|
|
|
void SaveAs(const std::string &filename, bool wait = false);
|
2011-03-17 10:17:45 +00:00
|
|
|
void LoadAs(const std::string &filename);
|
|
|
|
void VerifyAt(const std::string &filename);
|
2009-09-15 18:54:10 +00:00
|
|
|
|
2011-12-28 02:33:41 -06:00
|
|
|
void SaveToBuffer(std::vector<u8>& buffer);
|
|
|
|
void LoadFromBuffer(std::vector<u8>& buffer);
|
|
|
|
void VerifyBuffer(std::vector<u8>& buffer);
|
2009-06-28 01:11:35 +00:00
|
|
|
|
2012-11-08 08:40:49 +01:00
|
|
|
void LoadLastSaved(int i = 1);
|
|
|
|
void SaveFirstSaved();
|
2011-03-17 10:17:45 +00:00
|
|
|
void UndoSaveState();
|
|
|
|
void UndoLoadState();
|
2009-11-07 20:01:39 +00:00
|
|
|
|
2011-12-28 02:33:41 -06:00
|
|
|
// wait until previously scheduled savestate event (if any) is done
|
|
|
|
void Flush();
|
2009-06-28 01:11:35 +00:00
|
|
|
|
2011-12-18 01:15:59 -08:00
|
|
|
// for calling back into UI code without introducing a dependency on it in core
|
|
|
|
typedef void(*CallbackFunc)(void);
|
|
|
|
void SetOnAfterLoadCallback(CallbackFunc callback);
|
|
|
|
|
2011-03-17 10:17:45 +00:00
|
|
|
}
|