mirror of
https://github.com/libretro/Play-.git
synced 2024-12-04 23:36:30 +00:00
Added state saving support on EE Timers.
git-svn-id: http://svn.purei.org/purei/trunk@1072 b36208d7-6611-0410-8bec-b1987f11c4a2
This commit is contained in:
parent
1fe939381b
commit
cc911af940
@ -586,6 +586,7 @@ void CPS2VM::SaveVMState(const char* sPath, unsigned int& result)
|
||||
m_intc.SaveState(archive);
|
||||
m_sif.SaveState(archive);
|
||||
m_vif.SaveState(archive);
|
||||
m_timer.SaveState(archive);
|
||||
m_iopOs->GetPadman()->SaveState(archive);
|
||||
//TODO: Save CDVDFSV state
|
||||
|
||||
@ -634,6 +635,7 @@ void CPS2VM::LoadVMState(const char* sPath, unsigned int& result)
|
||||
m_intc.LoadState(archive);
|
||||
m_sif.LoadState(archive);
|
||||
m_vif.LoadState(archive);
|
||||
m_timer.LoadState(archive);
|
||||
m_iopOs->GetPadman()->LoadState(archive);
|
||||
}
|
||||
catch(...)
|
||||
|
@ -1,9 +1,12 @@
|
||||
#include <stdio.h>
|
||||
#include "Timer.h"
|
||||
#include "Log.h"
|
||||
#include "RegisterStateFile.h"
|
||||
|
||||
#define LOG_NAME ("timer")
|
||||
|
||||
#define STATE_REGS_XML ("timer/regs.xml")
|
||||
|
||||
CTimer::CTimer(CINTC& intc)
|
||||
: m_intc(intc)
|
||||
{
|
||||
@ -237,3 +240,34 @@ void CTimer::DisassembleSet(uint32 nAddress, uint32 nValue)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CTimer::LoadState(Framework::CZipArchiveReader& archive)
|
||||
{
|
||||
CRegisterStateFile registerFile(*archive.BeginReadFile(STATE_REGS_XML));
|
||||
for(unsigned int i = 0; i < 4; i++)
|
||||
{
|
||||
auto& timer = m_timer[i];
|
||||
std::string timerPrefix = "TIMER" + std::to_string(i) + "_";
|
||||
timer.nCOUNT = registerFile.GetRegister32((timerPrefix + "COUNT").c_str());
|
||||
timer.nMODE = registerFile.GetRegister32((timerPrefix + "MODE").c_str());
|
||||
timer.nCOMP = registerFile.GetRegister32((timerPrefix + "COMP").c_str());
|
||||
timer.nHOLD = registerFile.GetRegister32((timerPrefix + "HOLD").c_str());
|
||||
timer.clockRemain = registerFile.GetRegister32((timerPrefix + "REM").c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void CTimer::SaveState(Framework::CZipArchiveWriter& archive)
|
||||
{
|
||||
CRegisterStateFile* registerFile = new CRegisterStateFile(STATE_REGS_XML);
|
||||
for(unsigned int i = 0; i < 4; i++)
|
||||
{
|
||||
const auto& timer = m_timer[i];
|
||||
std::string timerPrefix = "TIMER" + std::to_string(i) + "_";
|
||||
registerFile->SetRegister32((timerPrefix + "COUNT").c_str(), timer.nCOUNT);
|
||||
registerFile->SetRegister32((timerPrefix + "MODE").c_str(), timer.nMODE);
|
||||
registerFile->SetRegister32((timerPrefix + "COMP").c_str(), timer.nCOMP);
|
||||
registerFile->SetRegister32((timerPrefix + "HOLD").c_str(), timer.nHOLD);
|
||||
registerFile->SetRegister32((timerPrefix + "REM").c_str(), timer.clockRemain);
|
||||
}
|
||||
archive.InsertFile(registerFile);
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include "Types.h"
|
||||
#include "INTC.h"
|
||||
#include "zip/ZipArchiveWriter.h"
|
||||
#include "zip/ZipArchiveReader.h"
|
||||
|
||||
class CTimer
|
||||
{
|
||||
@ -25,6 +27,8 @@ public:
|
||||
uint32 GetRegister(uint32);
|
||||
void SetRegister(uint32, uint32);
|
||||
|
||||
void LoadState(Framework::CZipArchiveReader&);
|
||||
void SaveState(Framework::CZipArchiveWriter&);
|
||||
|
||||
private:
|
||||
void DisassembleGet(uint32);
|
||||
|
Loading…
Reference in New Issue
Block a user