mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Fix some rewinding issues, better accessors.
This commit is contained in:
parent
f716d781b6
commit
79254c7a52
2 changed files with 23 additions and 3 deletions
|
@ -75,7 +75,7 @@ namespace SaveState
|
|||
CChunkFileReader::Error Save()
|
||||
{
|
||||
int n = next_++ % size_;
|
||||
if (n == first_)
|
||||
if ((next_ % size_) == first_)
|
||||
++first_;
|
||||
|
||||
SaveStart state;
|
||||
|
@ -89,7 +89,7 @@ namespace SaveState
|
|||
CChunkFileReader::Error Restore()
|
||||
{
|
||||
// No valid states left.
|
||||
if (next_ == first_)
|
||||
if (Empty())
|
||||
return CChunkFileReader::ERROR_BAD_FILE;
|
||||
|
||||
int n = (next_-- + size_) % size_;
|
||||
|
@ -100,6 +100,17 @@ namespace SaveState
|
|||
return CChunkFileReader::LoadPtr(&states_[n][0], state);
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
first_ = 0;
|
||||
next_ = 0;
|
||||
}
|
||||
|
||||
bool Empty()
|
||||
{
|
||||
return next_ == first_;
|
||||
}
|
||||
|
||||
typedef std::vector<u8> StateBuffer;
|
||||
int first_;
|
||||
int next_;
|
||||
|
@ -179,6 +190,11 @@ namespace SaveState
|
|||
Enqueue(Operation(SAVESTATE_REWIND, std::string(""), callback, cbUserData));
|
||||
}
|
||||
|
||||
bool CanRewind()
|
||||
{
|
||||
return !rewindStates.Empty();
|
||||
}
|
||||
|
||||
|
||||
// Slot utilities
|
||||
|
||||
|
@ -317,7 +333,7 @@ namespace SaveState
|
|||
|
||||
void Process()
|
||||
{
|
||||
if (rewindStateFreq != 0)
|
||||
if (rewindStateFreq != 0 && gpuStats.numFlips != 0)
|
||||
CheckRewindState();
|
||||
|
||||
if (!needsProcess)
|
||||
|
@ -429,5 +445,6 @@ namespace SaveState
|
|||
pspFileSystem.MkDir("ms0:/PSP/PPSSPP_STATE");
|
||||
|
||||
std::lock_guard<std::recursive_mutex> guard(mutex);
|
||||
rewindStates.Clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,9 @@ namespace SaveState
|
|||
// Warning: callback will be called on a different thread.
|
||||
void Rewind(Callback callback = 0, void *cbUserData = 0);
|
||||
|
||||
// Returns true if there are rewind snapshots available.
|
||||
bool CanRewind();
|
||||
|
||||
// Check if there's any save stating needing to be done. Normally called once per frame.
|
||||
void Process();
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue