Merge pull request #90 from gizmo98/patch-2
[libretro-ppsspp.git] / Core / SaveState.h
blob9b288c0a518ac0f0a7e77b03e27621a7851d62b3
1 // Copyright (c) 2012- PPSSPP Project.
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, version 2.0 or later versions.
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License 2.0 for more details.
12 // A copy of the GPL 2.0 should have been included with the program.
13 // If not, see http://www.gnu.org/licenses/
15 // Official git repository and contact information can be found at
16 // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
18 #include <string>
19 #include <vector>
21 #include "base/functional.h"
22 #include "Common/ChunkFile.h"
24 namespace SaveState
26 struct SaveStart
28 void DoState(PointerWrap &p);
30 typedef std::function<void(bool status, void *cbUserData)> Callback;
32 // TODO: Better place for this?
33 const int REVISION = 4;
34 const int SAVESTATESLOTS = 5;
36 void Init();
38 // Cycle through the 5 savestate slots
39 void NextSlot();
40 void SaveSlot(int slot, Callback callback, void *cbUserData = 0);
41 void LoadSlot(int slot, Callback callback, void *cbUserData = 0);
42 // Checks whether there's an existing save in the specified slot.
43 bool HasSaveInSlot(int slot);
44 bool HasScreenshotInSlot(int slot);
46 int GetCurrentSlot();
48 // Returns -1 if there's no newest slot.
49 int GetNewestSlot();
51 std::string GetSlotDateAsString(int slot);
52 std::string GenerateSaveSlotFilename(int slot, const char *extension);
54 // Load the specified file into the current state (async.)
55 // Warning: callback will be called on a different thread.
56 void Load(const std::string &filename, Callback callback = Callback(), void *cbUserData = 0);
58 // Save the current state to the specified file (async.)
59 // Warning: callback will be called on a different thread.
60 void Save(const std::string &filename, Callback callback = Callback(), void *cbUserData = 0);
62 CChunkFileReader::Error SaveToRam(std::vector<u8> &state);
63 CChunkFileReader::Error LoadFromRam(std::vector<u8> &state);
65 // For testing / automated tests. Runs a save state verification pass (async.)
66 // Warning: callback will be called on a different thread.
67 void Verify(Callback callback = Callback(), void *cbUserData = 0);
69 // To go back to a previous snapshot (only if enabled.)
70 // Warning: callback will be called on a different thread.
71 void Rewind(Callback callback = Callback(), void *cbUserData = 0);
73 // Returns true if there are rewind snapshots available.
74 bool CanRewind();
76 // Returns true if a savestate has been used during this session.
77 bool HasLoadedState();
79 // Check if there's any save stating needing to be done. Normally called once per frame.
80 void Process();