mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Add Verify() method to quickly test states work.
This commit is contained in:
parent
d6d3688c8c
commit
abeaaa9105
9 changed files with 116 additions and 1 deletions
|
@ -765,6 +765,8 @@ add_library(${CoreLibName} ${CoreLinkType}
|
|||
Core/PSPLoaders.h
|
||||
Core/PSPMixer.cpp
|
||||
Core/PSPMixer.h
|
||||
Core/SaveState.cpp
|
||||
Core/SaveState.h
|
||||
Core/System.cpp
|
||||
Core/System.h
|
||||
Core/Util/BlockAllocator.cpp
|
||||
|
|
|
@ -428,6 +428,30 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static bool Verify(T& _class)
|
||||
{
|
||||
u8 *ptr = 0;
|
||||
|
||||
// Step 1: Measure the space required.
|
||||
PointerWrap p(&ptr, PointerWrap::MODE_MEASURE);
|
||||
_class.DoState(p);
|
||||
size_t const sz = (size_t)ptr;
|
||||
std::vector<u8> buffer(sz);
|
||||
|
||||
// Step 2: Dump the state.
|
||||
ptr = &buffer[0];
|
||||
p.SetMode(PointerWrap::MODE_WRITE);
|
||||
_class.DoState(p);
|
||||
|
||||
// Step 3: Verify the state.
|
||||
ptr = &buffer[0];
|
||||
p.SetMode(PointerWrap::MODE_VERIFY);
|
||||
_class.DoState(p);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
struct SChunkHeader
|
||||
{
|
||||
|
|
|
@ -253,6 +253,7 @@
|
|||
<ClCompile Include="MIPS\x86\RegCache.cpp" />
|
||||
<ClCompile Include="PSPLoaders.cpp" />
|
||||
<ClCompile Include="PSPMixer.cpp" />
|
||||
<ClCompile Include="SaveState.cpp" />
|
||||
<ClCompile Include="System.cpp" />
|
||||
<ClCompile Include="Util\BlockAllocator.cpp" />
|
||||
<ClCompile Include="Util\PPGeDraw.cpp" />
|
||||
|
@ -371,6 +372,7 @@
|
|||
<ClInclude Include="MIPS\x86\RegCache.h" />
|
||||
<ClInclude Include="PSPLoaders.h" />
|
||||
<ClInclude Include="PSPMixer.h" />
|
||||
<ClInclude Include="SaveState.h" />
|
||||
<ClInclude Include="System.h" />
|
||||
<ClInclude Include="Util\BlockAllocator.h" />
|
||||
<ClInclude Include="Util\Pool.h" />
|
||||
|
|
|
@ -348,6 +348,9 @@
|
|||
<ClCompile Include="HLE\sceUsb.cpp">
|
||||
<Filter>HLE\Libraries</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SaveState.cpp">
|
||||
<Filter>Core</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ELF\ElfReader.h">
|
||||
|
@ -641,6 +644,9 @@
|
|||
<ClInclude Include="HLE\sceUsb.h">
|
||||
<Filter>HLE\Libraries</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SaveState.h">
|
||||
<Filter>Core</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="CMakeLists.txt" />
|
||||
|
|
|
@ -141,7 +141,6 @@ void __KernelDoState(PointerWrap &p)
|
|||
kernelObjects.DoState(p);
|
||||
p.DoMarker("KernelObjects");
|
||||
// TODO
|
||||
// kernelObjects
|
||||
// modules
|
||||
// core timing
|
||||
// memstick
|
||||
|
|
46
Core/SaveState.cpp
Normal file
46
Core/SaveState.cpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
// Copyright (c) 2012- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include "SaveState.h"
|
||||
#include "MemMap.h"
|
||||
#include "HLE/sceKernel.h"
|
||||
|
||||
// TODO: Need a way to schedule via CoreTiming and actually run then.
|
||||
|
||||
bool SaveState::Load(std::string &filename)
|
||||
{
|
||||
SaveState state;
|
||||
return CChunkFileReader::Load(filename, REVISION, state);
|
||||
}
|
||||
|
||||
bool SaveState::Save(std::string &filename)
|
||||
{
|
||||
SaveState state;
|
||||
return CChunkFileReader::Save(filename, REVISION, state);
|
||||
}
|
||||
|
||||
bool SaveState::Verify()
|
||||
{
|
||||
SaveState state;
|
||||
return CChunkFileReader::Verify(state);
|
||||
}
|
||||
|
||||
void SaveState::DoState(PointerWrap &p)
|
||||
{
|
||||
Memory::DoState(p);
|
||||
__KernelDoState(p);
|
||||
}
|
33
Core/SaveState.h
Normal file
33
Core/SaveState.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) 2012- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include "../Common/ChunkFile.h"
|
||||
|
||||
struct SaveState
|
||||
{
|
||||
// TODO: Better place for this?
|
||||
static const int REVISION = 1;
|
||||
|
||||
// Load the specified file into the current state.
|
||||
static bool Load(std::string &filename);
|
||||
// Save the current state to the specified file.
|
||||
static bool Save(std::string &filename);
|
||||
// For testing / automated tests. Runs a save state verification pass.
|
||||
static bool Verify();
|
||||
|
||||
void DoState(PointerWrap &p);
|
||||
};
|
|
@ -121,6 +121,7 @@ SOURCES += ../Core/CPU.cpp \ # Core
|
|||
../Core/MemMapFunctions.cpp \
|
||||
../Core/PSPLoaders.cpp \
|
||||
../Core/PSPMixer.cpp \
|
||||
../Core/SaveState.cpp \
|
||||
../Core/System.cpp \
|
||||
../Core/Util/BlockAllocator.cpp \
|
||||
../Core/Util/PPGeDraw.cpp \
|
||||
|
@ -227,6 +228,7 @@ HEADERS += ../Core/CPU.h \
|
|||
../Core/MemMap.h \
|
||||
../Core/PSPLoaders.h \
|
||||
../Core/PSPMixer.h \
|
||||
../Core/SaveState.h \
|
||||
../Core/System.h \
|
||||
../Core/Util/BlockAllocator.h \
|
||||
../Core/Util/PPGeDraw.h \
|
||||
|
|
|
@ -95,6 +95,7 @@ LOCAL_SRC_FILES := \
|
|||
$(SRC)/Core/PSPLoaders.cpp \
|
||||
$(SRC)/Core/MemMap.cpp \
|
||||
$(SRC)/Core/MemMapFunctions.cpp \
|
||||
$(SRC)/Core/SaveState.cpp \
|
||||
$(SRC)/Core/System.cpp \
|
||||
$(SRC)/Core/PSPMixer.cpp \
|
||||
$(SRC)/Core/Debugger/Breakpoints.cpp \
|
||||
|
|
Loading…
Add table
Reference in a new issue