2015-05-24 07:55:12 +03:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-18 02:08:10 +03:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 05:43:11 +03:00
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 06:46:09 +02:00
|
|
|
|
|
|
|
// Emulator state saving support.
|
|
|
|
|
2014-02-10 20:54:46 +02:00
|
|
|
#pragma once
|
2008-12-08 06:46:09 +02:00
|
|
|
|
2017-04-03 12:39:48 +03:00
|
|
|
#include <functional>
|
2009-07-13 00:58:32 +03:00
|
|
|
#include <string>
|
2011-12-28 10:33:41 +02:00
|
|
|
#include <vector>
|
2009-07-13 00:58:32 +03:00
|
|
|
|
2014-10-21 09:01:38 +03:00
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
|
2011-03-17 12:17:45 +02:00
|
|
|
namespace State
|
2009-06-29 00:11:51 +03:00
|
|
|
{
|
2012-11-08 09:40:49 +02:00
|
|
|
// number of states
|
2013-08-03 03:42:30 +03:00
|
|
|
static const u32 NUM_STATES = 10;
|
2012-11-08 09:40:49 +02:00
|
|
|
|
|
|
|
struct StateHeader
|
|
|
|
{
|
2016-06-24 11:43:46 +03:00
|
|
|
char gameID[6];
|
|
|
|
u32 size;
|
|
|
|
double time;
|
2012-11-08 09:40:49 +02:00
|
|
|
};
|
|
|
|
|
2011-03-17 12:17:45 +02:00
|
|
|
void Init();
|
2011-10-15 14:19:42 +03:00
|
|
|
|
2011-03-17 12:17:45 +02:00
|
|
|
void Shutdown();
|
|
|
|
|
|
|
|
void EnableCompression(bool compression);
|
2008-12-08 06:46:09 +02:00
|
|
|
|
2014-02-24 00:03:39 +02:00
|
|
|
bool ReadHeader(const std::string& filename, StateHeader& header);
|
2012-11-08 09:40:49 +02:00
|
|
|
|
2015-07-12 02:49:12 +03:00
|
|
|
// Returns a string containing information of the savestate in the given slot
|
|
|
|
// which can be presented to the user for identification purposes
|
2015-12-19 15:36:09 +02:00
|
|
|
std::string GetInfoStringOfSlot(int slot, bool translate = true);
|
2015-07-12 02:49:12 +03:00
|
|
|
|
2008-12-08 06:46:09 +02:00
|
|
|
// These don't happen instantly - they get scheduled as events.
|
2014-11-14 04:28:27 +02: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-18 00:02:03 +03:00
|
|
|
// because some things (like Lua) need them to run immediately.
|
2008-12-08 06:46:09 +02:00
|
|
|
// Slots from 0-99.
|
2012-11-08 09:40:49 +02:00
|
|
|
void Save(int slot, bool wait = false);
|
2011-03-17 12:17:45 +02:00
|
|
|
void Load(int slot);
|
2009-06-28 04:11:35 +03:00
|
|
|
|
2016-06-24 11:43:46 +03:00
|
|
|
void SaveAs(const std::string& filename, bool wait = false);
|
|
|
|
void LoadAs(const std::string& filename);
|
2009-09-15 21:54:10 +03:00
|
|
|
|
2011-12-28 10:33:41 +02:00
|
|
|
void SaveToBuffer(std::vector<u8>& buffer);
|
|
|
|
void LoadFromBuffer(std::vector<u8>& buffer);
|
2009-06-28 04:11:35 +03:00
|
|
|
|
2012-11-08 09:40:49 +02:00
|
|
|
void LoadLastSaved(int i = 1);
|
|
|
|
void SaveFirstSaved();
|
2011-03-17 12:17:45 +02:00
|
|
|
void UndoSaveState();
|
|
|
|
void UndoLoadState();
|
2009-11-07 22:01:39 +02:00
|
|
|
|
2011-12-28 10:33:41 +02:00
|
|
|
// wait until previously scheduled savestate event (if any) is done
|
|
|
|
void Flush();
|
2009-06-28 04:11:35 +03:00
|
|
|
|
2011-12-18 11:15:59 +02:00
|
|
|
// for calling back into UI code without introducing a dependency on it in core
|
2017-04-03 12:39:48 +03:00
|
|
|
using AfterLoadCallbackFunc = std::function<void()>;
|
|
|
|
void SetOnAfterLoadCallback(AfterLoadCallbackFunc callback);
|
2011-03-17 12:17:45 +02:00
|
|
|
}
|