Remove built-in rewind code - RetroArch takes care of that

This commit is contained in:
twinaphex 2022-04-03 22:14:52 +02:00
parent 1ac829ab5c
commit 8c77855c6b
10 changed files with 3 additions and 79 deletions

View File

@ -22,7 +22,6 @@
#include "SoundMixer.h" #include "SoundMixer.h"
#include "NsfMapper.h" #include "NsfMapper.h"
#include "MovieManager.h" #include "MovieManager.h"
#include "RewindManager.h"
#include "SaveStateManager.h" #include "SaveStateManager.h"
#include "HdPackBuilder.h" #include "HdPackBuilder.h"
#include "HdAudioDevice.h" #include "HdAudioDevice.h"
@ -106,8 +105,6 @@ void Console::Release(bool forShutdown)
_master->_notificationManager->SendNotification(ConsoleNotificationType::VsDualSystemStopped); _master->_notificationManager->SendNotification(ConsoleNotificationType::VsDualSystemStopped);
} }
_rewindManager.reset();
_hdPackBuilder.reset(); _hdPackBuilder.reset();
_hdData.reset(); _hdData.reset();
_hdAudioDevice.reset(); _hdAudioDevice.reset();
@ -363,14 +360,6 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile, bool forP
ResetComponents(false); ResetComponents(false);
//Reset components before creating rewindmanager, otherwise the first save state it takes will be invalid
if(!forPowerCycle) {
_rewindManager.reset(new RewindManager(shared_from_this()));
_notificationManager->RegisterNotificationListener(_rewindManager);
} else {
_rewindManager->Initialize();
}
//Poll controller input after creating rewind manager, to make sure it catches the first frame's input //Poll controller input after creating rewind manager, to make sure it catches the first frame's input
_controlManager->UpdateInputState(); _controlManager->UpdateInputState();
@ -479,11 +468,6 @@ CheatManager* Console::GetCheatManager()
return _cheatManager.get(); return _cheatManager.get();
} }
shared_ptr<RewindManager> Console::GetRewindManager()
{
return _rewindManager;
}
HistoryViewer* Console::GetHistoryViewer() HistoryViewer* Console::GetHistoryViewer()
{ {
return _historyViewer.get(); return _historyViewer.get();
@ -659,7 +643,6 @@ void Console::Run()
if(_historyViewer) { if(_historyViewer) {
_historyViewer->ProcessEndOfFrame(); _historyViewer->ProcessEndOfFrame();
} }
_rewindManager->ProcessEndOfFrame();
_settings->DisableOverclocking(_disableOcNextFrame || IsNsf()); _settings->DisableOverclocking(_disableOcNextFrame || IsNsf());
_disableOcNextFrame = false; _disableOcNextFrame = false;
@ -1185,20 +1168,6 @@ bool Console::IsNsf()
return std::dynamic_pointer_cast<NsfMapper>(_mapper) != nullptr; return std::dynamic_pointer_cast<NsfMapper>(_mapper) != nullptr;
} }
void Console::CopyRewindData(shared_ptr<Console> sourceConsole)
{
sourceConsole->Pause();
Pause();
//Disable battery saving for this instance
_batteryManager->SetSaveEnabled(false);
_historyViewer.reset(new HistoryViewer(shared_from_this()));
sourceConsole->_rewindManager->CopyHistory(_historyViewer);
Resume();
sourceConsole->Resume();
}
uint8_t* Console::GetRamBuffer(uint16_t address) uint8_t* Console::GetRamBuffer(uint16_t address)
{ {
//Only used by libretro port for achievements - should not be used by anything else. //Only used by libretro port for achievements - should not be used by anything else.

View File

@ -6,7 +6,6 @@
#include "VirtualFile.h" #include "VirtualFile.h"
class BaseMapper; class BaseMapper;
class RewindManager;
class HistoryViewer; class HistoryViewer;
class APU; class APU;
class CPU; class CPU;
@ -48,7 +47,6 @@ private:
SimpleLock _stopLock; SimpleLock _stopLock;
atomic<uint32_t> _pauseCounter; atomic<uint32_t> _pauseCounter;
shared_ptr<RewindManager> _rewindManager;
shared_ptr<HistoryViewer> _historyViewer; shared_ptr<HistoryViewer> _historyViewer;
shared_ptr<CPU> _cpu; shared_ptr<CPU> _cpu;
@ -129,7 +127,6 @@ public:
ControlManager* GetControlManager(); ControlManager* GetControlManager();
MemoryManager* GetMemoryManager(); MemoryManager* GetMemoryManager();
CheatManager* GetCheatManager(); CheatManager* GetCheatManager();
shared_ptr<RewindManager> GetRewindManager();
HistoryViewer* GetHistoryViewer(); HistoryViewer* GetHistoryViewer();
bool LoadMatchingRom(string romName, HashInfo hashInfo); bool LoadMatchingRom(string romName, HashInfo hashInfo);
@ -209,8 +206,6 @@ public:
void StartRecordingHdPack(string saveFolder, ScaleFilterType filterType, uint32_t scale, uint32_t flags, uint32_t chrRamBankSize); void StartRecordingHdPack(string saveFolder, ScaleFilterType filterType, uint32_t scale, uint32_t flags, uint32_t chrRamBankSize);
void StopRecordingHdPack(); void StopRecordingHdPack();
void CopyRewindData(shared_ptr<Console> sourceConsole);
uint8_t* GetRamBuffer(uint16_t address); uint8_t* GetRamBuffer(uint16_t address);
void DebugAddTrace(const char *log); void DebugAddTrace(const char *log);

View File

@ -19,7 +19,6 @@
#include "DisassemblyInfo.h" #include "DisassemblyInfo.h"
#include "PPU.h" #include "PPU.h"
#include "MemoryManager.h" #include "MemoryManager.h"
#include "RewindManager.h"
#include "DebugBreakHelper.h" #include "DebugBreakHelper.h"
#include "ScriptHost.h" #include "ScriptHost.h"
#include "StandardController.h" #include "StandardController.h"
@ -95,7 +94,6 @@ Debugger::Debugger(shared_ptr<Console> console, shared_ptr<CPU> cpu, shared_ptr<
_runToCycle = -1; _runToCycle = -1;
_prevInstructionCycle = -1; _prevInstructionCycle = -1;
_curInstructionCycle = -1; _curInstructionCycle = -1;
_needRewind = false;
//Only enable break on uninitialized reads when debugger is opened at power on/reset //Only enable break on uninitialized reads when debugger is opened at power on/reset
_enableBreakOnUninitRead = _cpu->GetPC() == 0; _enableBreakOnUninitRead = _cpu->GetPC() == 0;
@ -705,32 +703,6 @@ bool Debugger::ProcessRamOperation(MemoryOperationType type, uint16_t &addr, uin
value = _memoryManager->DebugRead(addr, true); value = _memoryManager->DebugRead(addr, true);
_cpu->SetDebugPC(addr); _cpu->SetDebugPC(addr);
_nextReadAddr = -1; _nextReadAddr = -1;
} else if(_needRewind) {
//Step back - Need to load a state, and then alter the current opcode based on the new program counter
if(!_rewindCache.empty()) {
//Restore the state, and the cycle number of the instruction that preceeded that state
//Otherwise, the target cycle number when building the next cache will be incorrect
_console->LoadState(_rewindCache.back());
_curInstructionCycle = _rewindPrevInstructionCycleCache.back();
_rewindCache.pop_back();
_rewindPrevInstructionCycleCache.pop_back();
//This state is for the instruction we want to stop on, break here.
_runToCycle = -1;
Step(1);
} else {
_console->GetRewindManager()->StartRewinding(true);
//Adjust the cycle counter by 1 because the state was taken before the instruction started
//whereas the CPU already read the first byte of the instruction by the time we get here
State cpuState;
_cpu->GetState(cpuState);
cpuState.CycleCount++;
_cpu->SetState(cpuState);
}
UpdateProgramCounter(addr, value);
_needRewind = false;
} }
ProcessScriptSaveState(addr, value); ProcessScriptSaveState(addr, value);
@ -798,8 +770,6 @@ bool Debugger::ProcessRamOperation(MemoryOperationType type, uint16_t &addr, uin
if(_runToCycle != -1) { if(_runToCycle != -1) {
if((int64_t)_cpu->GetCycleCount() >= _runToCycle) { if((int64_t)_cpu->GetCycleCount() >= _runToCycle) {
//Step back operation is done, revert RewindManager's state & break debugger
_console->GetRewindManager()->StopRewinding(true);
_runToCycle = -1; _runToCycle = -1;
Step(1); Step(1);
} else if(_runToCycle - (int64_t)_cpu->GetCycleCount() < 500) { } else if(_runToCycle - (int64_t)_cpu->GetCycleCount() < 500) {
@ -916,7 +886,7 @@ bool Debugger::ProcessRamOperation(MemoryOperationType type, uint16_t &addr, uin
if(_runToCycle == -1 && (type == MemoryOperationType::ExecOpCode || type == MemoryOperationType::ExecOperand)) { if(_runToCycle == -1 && (type == MemoryOperationType::ExecOpCode || type == MemoryOperationType::ExecOperand)) {
_memoryAccessCounter->ProcessMemoryExec(addressInfo, _cpu->GetCycleCount()); _memoryAccessCounter->ProcessMemoryExec(addressInfo, _cpu->GetCycleCount());
} }
if(!_needRewind && type == MemoryOperationType::ExecOpCode) { if(type == MemoryOperationType::ExecOpCode) {
UpdateCallstack(_lastInstruction, addr); UpdateCallstack(_lastInstruction, addr);
} }
} }
@ -1120,7 +1090,6 @@ void Debugger::StepBack()
{ {
if(_runToCycle == -1 && _prevInstructionCycle < _curInstructionCycle) { if(_runToCycle == -1 && _prevInstructionCycle < _curInstructionCycle) {
_runToCycle = _prevInstructionCycle; _runToCycle = _prevInstructionCycle;
_needRewind = true;
Run(); Run();
} }
} }

View File

@ -1,7 +1,6 @@
#include "stdafx.h" #include "stdafx.h"
#include "EmulationSettings.h" #include "EmulationSettings.h"
#include "Console.h" #include "Console.h"
#include "RewindManager.h"
//Version 0.9.9 //Version 0.9.9
uint16_t EmulationSettings::_versionMajor = 0; uint16_t EmulationSettings::_versionMajor = 0;

View File

@ -3,7 +3,6 @@
#include "PPU.h" #include "PPU.h"
#include "HdNesPack.h" #include "HdNesPack.h"
#include "VideoDecoder.h" #include "VideoDecoder.h"
#include "RewindManager.h"
#include "HdPackBuilder.h" #include "HdPackBuilder.h"
#include "HdPpu.h" #include "HdPpu.h"
@ -127,4 +126,4 @@ public:
PPU::SendFrame(); PPU::SendFrame();
} }
} }
}; };

View File

@ -4,7 +4,6 @@
#include "Console.h" #include "Console.h"
#include "HdNesPack.h" #include "HdNesPack.h"
#include "VideoDecoder.h" #include "VideoDecoder.h"
#include "RewindManager.h"
#include "HdPackConditions.h" #include "HdPackConditions.h"
#include "NotificationManager.h" #include "NotificationManager.h"
#include "BaseMapper.h" #include "BaseMapper.h"

View File

@ -10,7 +10,6 @@
#include "ScriptingContext.h" #include "ScriptingContext.h"
#include "DebugHud.h" #include "DebugHud.h"
#include "VideoDecoder.h" #include "VideoDecoder.h"
#include "RewindManager.h"
#include "SaveStateManager.h" #include "SaveStateManager.h"
#include "Console.h" #include "Console.h"
#include "IKeyManager.h" #include "IKeyManager.h"
@ -591,7 +590,6 @@ int LuaApi::Rewind(lua_State *lua)
checkparams(); checkparams();
checksavestateconditions(); checksavestateconditions();
errorCond(seconds <= 0, "seconds must be >= 1"); errorCond(seconds <= 0, "seconds must be >= 1");
_console->GetRewindManager()->RewindSeconds(seconds);
return l.ReturnCount(); return l.ReturnCount();
} }

View File

@ -6,7 +6,6 @@
#include "VideoDecoder.h" #include "VideoDecoder.h"
#include "Debugger.h" #include "Debugger.h"
#include "BaseMapper.h" #include "BaseMapper.h"
#include "RewindManager.h"
#include "ControlManager.h" #include "ControlManager.h"
#include "MemoryManager.h" #include "MemoryManager.h"
#include "Console.h" #include "Console.h"

View File

@ -4,7 +4,6 @@
#include "SoundMixer.h" #include "SoundMixer.h"
#include "CPU.h" #include "CPU.h"
#include "VideoRenderer.h" #include "VideoRenderer.h"
#include "RewindManager.h"
#include "OggMixer.h" #include "OggMixer.h"
#include "Console.h" #include "Console.h"
#include "BaseMapper.h" #include "BaseMapper.h"

View File

@ -9,7 +9,6 @@
#include "HdVideoFilter.h" #include "HdVideoFilter.h"
#include "ScaleFilter.h" #include "ScaleFilter.h"
#include "VideoRenderer.h" #include "VideoRenderer.h"
#include "RewindManager.h"
#include "Console.h" #include "Console.h"
#include "PPU.h" #include "PPU.h"
#include "HdData.h" #include "HdData.h"
@ -124,8 +123,7 @@ void VideoDecoder::DecodeFrame(bool synchronous)
_frameChanged = false; _frameChanged = false;
//Rewind manager will take care of sending the correct frame to the video renderer _console->GetVideoRenderer()->UpdateFrame(outputBuffer, frameInfo.Width, frameInfo.Height);
_console->GetRewindManager()->SendFrame(outputBuffer, frameInfo.Width, frameInfo.Height, synchronous);
} }
uint32_t VideoDecoder::GetFrameCount() uint32_t VideoDecoder::GetFrameCount()