input-rec: Set frame count to zero on "reset"

This commit is contained in:
sonicfind 2022-09-23 13:44:11 -05:00 committed by refractionpcsx2
parent 5cd243f2c1
commit 592395d15c
3 changed files with 20 additions and 5 deletions

View File

@ -517,7 +517,7 @@ bool InputRecording::create(const std::string& fileName, const bool fromSaveStat
{ {
FileSystem::CopyFilePath(savestatePath.c_str(), fmt::format("{}.bak", savestatePath).c_str(), true); FileSystem::CopyFilePath(savestatePath.c_str(), fmt::format("{}.bak", savestatePath).c_str(), true);
} }
m_initial_savestate_load_complete = false; m_initial_load_complete = false;
m_type = Type::FROM_SAVESTATE; m_type = Type::FROM_SAVESTATE;
m_is_active = true; m_is_active = true;
// TODO - error handling // TODO - error handling
@ -527,6 +527,7 @@ bool InputRecording::create(const std::string& fileName, const bool fromSaveStat
{ {
m_starting_frame = 0; m_starting_frame = 0;
m_type = Type::POWER_ON; m_type = Type::POWER_ON;
m_initial_load_complete = false;
m_is_active = true; m_is_active = true;
// TODO - should this be an explicit [full] boot instead of a reset? // TODO - should this be an explicit [full] boot instead of a reset?
VMManager::Reset(); VMManager::Reset();
@ -561,7 +562,7 @@ bool InputRecording::play(const std::string& filename)
return false; return false;
} }
m_type = Type::FROM_SAVESTATE; m_type = Type::FROM_SAVESTATE;
m_initial_savestate_load_complete = false; m_initial_load_complete = false;
m_is_active = true; m_is_active = true;
const auto loaded = VMManager::LoadState(savestatePath.c_str()); const auto loaded = VMManager::LoadState(savestatePath.c_str());
if (!loaded) if (!loaded)
@ -576,6 +577,7 @@ bool InputRecording::play(const std::string& filename)
{ {
m_starting_frame = 0; m_starting_frame = 0;
m_type = Type::POWER_ON; m_type = Type::POWER_ON;
m_initial_load_complete = false;
m_is_active = true; m_is_active = true;
// TODO - should this be an explicit [full] boot instead of a reset? // TODO - should this be an explicit [full] boot instead of a reset?
VMManager::Reset(); VMManager::Reset();
@ -695,6 +697,13 @@ void InputRecording::handleExceededFrameCounter()
} }
} }
void InputRecording::handleReset()
{
if (m_initial_load_complete)
adjustFrameCounterOnReRecord(0);
m_initial_load_complete = true;
}
void InputRecording::handleLoadingSavestate() void InputRecording::handleLoadingSavestate()
{ {
// We need to keep track of the starting internal frame of the recording // We need to keep track of the starting internal frame of the recording
@ -704,10 +713,10 @@ void InputRecording::handleLoadingSavestate()
// Why? // Why?
// - When you re-record you load another save-state which has it's own frame counter // - When you re-record you load another save-state which has it's own frame counter
// stored within, we use this to adjust the frame we are replaying/recording to // stored within, we use this to adjust the frame we are replaying/recording to
if (isTypeSavestate() && !m_initial_savestate_load_complete) if (isTypeSavestate() && !m_initial_load_complete)
{ {
setStartingFrame(g_FrameCount); setStartingFrame(g_FrameCount);
m_initial_savestate_load_complete = true; m_initial_load_complete = true;
} }
else else
{ {

View File

@ -178,6 +178,7 @@ public:
void ControllerInterrupt(u8 port, size_t fifoSize, u8 dataIn, u8 dataOut); void ControllerInterrupt(u8 port, size_t fifoSize, u8 dataIn, u8 dataOut);
void handleExceededFrameCounter(); void handleExceededFrameCounter();
void handleReset();
void handleLoadingSavestate(); void handleLoadingSavestate();
bool isTypeSavestate() const; bool isTypeSavestate() const;
void adjustFrameCounterOnReRecord(u32 newFrameCounter); void adjustFrameCounterOnReRecord(u32 newFrameCounter);
@ -196,7 +197,7 @@ private:
Type m_type; Type m_type;
bool m_initial_savestate_load_complete = false; bool m_initial_load_complete = false;
bool m_is_active = false; bool m_is_active = false;
bool m_pad_data_available = false; bool m_pad_data_available = false;
bool m_watching_for_rerecords = false; bool m_watching_for_rerecords = false;

View File

@ -1125,6 +1125,11 @@ void VMManager::Reset()
// gameid change, so apply settings // gameid change, so apply settings
if (game_was_started) if (game_was_started)
UpdateRunningGame(true, false); UpdateRunningGame(true, false);
if (g_InputRecording.isActive())
{
g_InputRecording.handleReset();
}
} }
std::string VMManager::GetSaveStateFileName(const char* game_serial, u32 game_crc, s32 slot) std::string VMManager::GetSaveStateFileName(const char* game_serial, u32 game_crc, s32 slot)