Rewind: Ensure original speed is restored when rewind stops
This commit is contained in:
parent
1ff6747e63
commit
cd79022f60
8 changed files with 34 additions and 25 deletions
|
@ -108,7 +108,7 @@ void AutomaticRomTest::ProcessNotification(ConsoleNotificationType type, void* p
|
|||
|
||||
int32_t AutomaticRomTest::Run(string filename)
|
||||
{
|
||||
EmulationSettings::SetEmulationSpeed(0);
|
||||
EmulationSettings::SetFlags(EmulationFlags::ForceMaxSpeed);
|
||||
EmulationSettings::SetMasterVolume(0);
|
||||
Console::Pause();
|
||||
if(Console::LoadROM(filename)) {
|
||||
|
@ -123,7 +123,7 @@ int32_t AutomaticRomTest::Run(string filename)
|
|||
_errorCode |= 0x10;
|
||||
}
|
||||
|
||||
EmulationSettings::SetEmulationSpeed(100);
|
||||
EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
EmulationSettings::SetMasterVolume(1.0);
|
||||
|
||||
Console::GetInstance()->Stop();
|
||||
|
|
|
@ -113,4 +113,19 @@ void EmulationSettings::SetRewindBufferSize(uint32_t seconds)
|
|||
Console::Resume();
|
||||
}
|
||||
_rewindBufferSize = seconds;
|
||||
}
|
||||
|
||||
uint32_t EmulationSettings::GetEmulationSpeed(bool ignoreTurbo)
|
||||
{
|
||||
if(ignoreTurbo) {
|
||||
return _emulationSpeed;
|
||||
} else if(CheckFlag(EmulationFlags::ForceMaxSpeed)) {
|
||||
return 0;
|
||||
} else if(CheckFlag(EmulationFlags::Turbo)) {
|
||||
return _turboSpeed;
|
||||
} else if(RewindManager::IsRewinding()) {
|
||||
return _rewindSpeed;
|
||||
} else {
|
||||
return _emulationSpeed;
|
||||
}
|
||||
}
|
|
@ -57,6 +57,8 @@ enum EmulationFlags : uint64_t
|
|||
|
||||
DisplayMovieIcons = 0x10000000000,
|
||||
HidePauseOverlay = 0x20000000000,
|
||||
|
||||
ForceMaxSpeed = 0x40000000000,
|
||||
|
||||
ConsoleMode = 0x8000000000000000,
|
||||
};
|
||||
|
@ -672,10 +674,7 @@ public:
|
|||
return _rewindBufferSize;
|
||||
}
|
||||
|
||||
static uint32_t GetEmulationSpeed(bool ignoreTurbo = false)
|
||||
{
|
||||
return (CheckFlag(EmulationFlags::Turbo) && !ignoreTurbo) ? _turboSpeed : _emulationSpeed;
|
||||
}
|
||||
static uint32_t GetEmulationSpeed(bool ignoreTurbo = false);
|
||||
|
||||
static void UpdateEffectiveOverclockRate()
|
||||
{
|
||||
|
|
14
Core/FDS.cpp
14
Core/FDS.cpp
|
@ -135,13 +135,11 @@ void FDS::ProcessCpuClock()
|
|||
}
|
||||
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::FdsFastForwardOnLoad)) {
|
||||
bool enableFastforward = (_scanningDisk || _gameStarted < 2);
|
||||
uint32_t emulationSpeed = EmulationSettings::GetEmulationSpeed(true);
|
||||
if(emulationSpeed > 0 || !_fastForwarding) {
|
||||
_previousSpeed = emulationSpeed;
|
||||
if(_scanningDisk || _gameStarted < 2) {
|
||||
EmulationSettings::SetFlags(EmulationFlags::ForceMaxSpeed);
|
||||
} else {
|
||||
EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
}
|
||||
EmulationSettings::SetEmulationSpeed(enableFastforward ? 0 : _previousSpeed);
|
||||
_fastForwarding = enableFastforward;
|
||||
}
|
||||
|
||||
ClockIrq();
|
||||
|
@ -412,9 +410,7 @@ FDS::FDS()
|
|||
FDS::~FDS()
|
||||
{
|
||||
//Restore emulation speed to normal when closing
|
||||
if(_previousSpeed >= 0) {
|
||||
EmulationSettings::SetEmulationSpeed(_previousSpeed);
|
||||
}
|
||||
EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
|
||||
if(_isDirty) {
|
||||
FdsLoader loader;
|
||||
|
|
|
@ -71,8 +71,6 @@ private:
|
|||
string _romFilepath;
|
||||
|
||||
uint8_t _gameStarted = 0;
|
||||
int32_t _previousSpeed = -1;
|
||||
bool _fastForwarding = false;
|
||||
|
||||
protected:
|
||||
virtual uint16_t GetPRGPageSize() override { return 0x2000; }
|
||||
|
|
|
@ -166,8 +166,9 @@ uint8_t GameClientConnection::GetControllerState(uint8_t port)
|
|||
|
||||
if(_inputData[port].size() > _minimumQueueSize) {
|
||||
//Too much data, catch up
|
||||
EmulationSettings::SetEmulationSpeed(0);
|
||||
EmulationSettings::SetFlags(EmulationFlags::ForceMaxSpeed);
|
||||
} else {
|
||||
EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
EmulationSettings::SetEmulationSpeed(100);
|
||||
}
|
||||
return state;
|
||||
|
|
|
@ -210,7 +210,7 @@ int32_t RecordedRomTest::Run(string filename)
|
|||
return false;
|
||||
}
|
||||
|
||||
EmulationSettings::SetEmulationSpeed(0);
|
||||
EmulationSettings::SetFlags(EmulationFlags::ForceMaxSpeed);
|
||||
EmulationSettings::SetMasterVolume(0);
|
||||
|
||||
Console::Pause();
|
||||
|
@ -247,7 +247,7 @@ int32_t RecordedRomTest::Run(string filename)
|
|||
Console::GetInstance()->Stop();
|
||||
|
||||
|
||||
EmulationSettings::SetEmulationSpeed(100);
|
||||
EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
EmulationSettings::SetMasterVolume(1.0);
|
||||
|
||||
return _badFrameCount;
|
||||
|
|
|
@ -60,7 +60,7 @@ void RewindManager::ProcessNotification(ConsoleNotificationType type, void * par
|
|||
}
|
||||
_historyBackup.clear();
|
||||
_rewindState = RewindState::Stopped;
|
||||
EmulationSettings::SetEmulationSpeed(100);
|
||||
EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
}
|
||||
} else {
|
||||
_currentHistory.FrameCount++;
|
||||
|
@ -116,7 +116,7 @@ void RewindManager::Start()
|
|||
|
||||
PopHistory();
|
||||
SoundMixer::StopAudio(true);
|
||||
EmulationSettings::SetEmulationSpeed(0);
|
||||
EmulationSettings::SetFlags(EmulationFlags::ForceMaxSpeed);
|
||||
|
||||
Console::Resume();
|
||||
}
|
||||
|
@ -154,11 +154,11 @@ void RewindManager::Stop()
|
|||
if(_framesToFastForward > 0) {
|
||||
_rewindState = RewindState::Stopping;
|
||||
_currentHistory.FrameCount = 0;
|
||||
EmulationSettings::SetEmulationSpeed(0);
|
||||
EmulationSettings::SetFlags(EmulationFlags::ForceMaxSpeed);
|
||||
} else {
|
||||
_rewindState = RewindState::Stopped;
|
||||
_historyBackup.clear();
|
||||
EmulationSettings::SetEmulationSpeed(100);
|
||||
EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
}
|
||||
|
||||
_videoHistoryBuilder.clear();
|
||||
|
@ -195,7 +195,7 @@ void RewindManager::ProcessFrame(void * frameBuffer, uint32_t width, uint32_t he
|
|||
|
||||
if(_rewindState == RewindState::Started || _videoHistory.size() >= RewindManager::BufferSize) {
|
||||
_rewindState = RewindState::Started;
|
||||
EmulationSettings::SetEmulationSpeed(EmulationSettings::GetRewindSpeed());
|
||||
EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed);
|
||||
if(!_videoHistory.empty()) {
|
||||
VideoRenderer::GetInstance()->UpdateFrame(_videoHistory.back().data(), width, height);
|
||||
_videoHistory.pop_back();
|
||||
|
|
Loading…
Add table
Reference in a new issue