Input-recording: Add new FirstFrame function

Jumps emulation to the initial state of an active input recording file whether boost or savestate. Makes it easier to reset savestate-based recordings.
* Overrides the Boot ISO/CDVD/Bios menu option.
This commit is contained in:
sonicfind 2021-02-22 23:04:46 -06:00 committed by refractionpcsx2
parent 7b9c8634f4
commit c664a48f26
6 changed files with 54 additions and 5 deletions

View File

@ -86,6 +86,9 @@ FrameAdvance = SPACE
TogglePause = Shift-P
InputRecordingModeToggle = Shift-R
# Note - This is disabled if no input recording is active
GoToFirstFrame = Shift-L
# Save State Management
# Note - These are disabled if 'System > Enable Recording Tools' is disabled
States_SaveSlot0 = Shift-KP_0

View File

@ -20,8 +20,6 @@
#ifndef DISABLE_RECORDING
#include <vector>
#include "AppGameDatabase.h"
#include "DebugTools/Debug.h"
@ -398,6 +396,26 @@ bool InputRecording::Play(wxString fileName)
return true;
}
bool InputRecording::GoToFirstFrame()
{
if (inputRecordingData.FromSaveState())
{
if (!wxFileExists(inputRecordingData.GetFilename() + "_SaveState.p2s"))
{
inputRec::consoleLog(fmt::format("[REC]: Could not locate savestate file at location - {}_SaveState.p2s\n",
inputRecordingData.GetFilename()));
return false;
}
StateCopy_LoadFromFile(inputRecordingData.GetFilename() + "_SaveState.p2s");
}
else
sApp.SysExecute(g_Conf->CdvdSource);
if (IsRecording())
SetToReplayMode();
return true;
}
wxString InputRecording::resolveGameName()
{
// Code loosely taken from AppCoreThread::_ApplySettings to resolve the Game Name

View File

@ -88,10 +88,12 @@ public:
bool Play(wxString filename);
// Stop the active input recording
void Stop();
// Displays the VirtualPad window for the chosen pad
// Displays the VirtualPad window for the chosen pad
void ShowVirtualPad(const int port);
// Logs the padData and redraws the virtualPad windows of active pads
void LogAndRedraw();
// Resets emulation to the beginning of a recording
bool GoToFirstFrame();
// Resets a recording if the base savestate could not be loaded at the start
void FailedSavestate();

View File

@ -109,11 +109,13 @@ void GSPanel::InitRecordingAccelerators()
m_Accels->Map(AAC(WXK_SPACE), "FrameAdvance");
m_Accels->Map(AAC(wxKeyCode('p')).Shift(), "TogglePause");
m_Accels->Map(AAC(wxKeyCode('r')).Shift(), "InputRecordingModeToggle");
m_Accels->Map(AAC(wxKeyCode('l')).Shift(), "GoToFirstFrame");
#if defined(__unix__)
// Shift+P (80) and Shift+p (112) have two completely different codes
// On Linux the former is sometimes fired so define bindings for both
m_Accels->Map(AAC(wxKeyCode('P')).Shift(), "TogglePause");
m_Accels->Map(AAC(wxKeyCode('R')).Shift(), "InputRecordingModeToggle");
m_Accels->Map(AAC(wxKeyCode('L')).Shift(), "GoToFirstFrame");
#endif
m_Accels->Map(AAC(WXK_NUMPAD0).Shift(), "States_SaveSlot0");

View File

@ -541,6 +541,17 @@ namespace Implementations
}
}
void GoToFirstFrame()
{
if (g_Conf->EmuOptions.EnableRecordingTools && g_InputRecording.IsActive())
{
if (!g_InputRecording.GoToFirstFrame())
{
sMainFrame.StopInputRecording();
}
}
}
void States_SaveSlot(int slot)
{
States_SetCurrentSlot(slot);
@ -838,6 +849,8 @@ static const GlobalCommandDescriptor CommandDeclarations[] =
{"FrameAdvance", Implementations::FrameAdvance, NULL, NULL, false},
{"TogglePause", Implementations::TogglePause, NULL, NULL, false},
{"InputRecordingModeToggle", Implementations::InputRecordingModeToggle, NULL, NULL, false},
{"GoToFirstFrame", Implementations::GoToFirstFrame, NULL, NULL, false},
{"States_SaveSlot0", Implementations::States_SaveSlot0, NULL, NULL, false},
{"States_SaveSlot1", Implementations::States_SaveSlot1, NULL, NULL, false},
{"States_SaveSlot2", Implementations::States_SaveSlot2, NULL, NULL, false},
@ -848,6 +861,7 @@ static const GlobalCommandDescriptor CommandDeclarations[] =
{"States_SaveSlot7", Implementations::States_SaveSlot7, NULL, NULL, false},
{"States_SaveSlot8", Implementations::States_SaveSlot8, NULL, NULL, false},
{"States_SaveSlot9", Implementations::States_SaveSlot9, NULL, NULL, false},
{"States_LoadSlot0", Implementations::States_LoadSlot0, NULL, NULL, false},
{"States_LoadSlot1", Implementations::States_LoadSlot1, NULL, NULL, false},
{"States_LoadSlot2", Implementations::States_LoadSlot2, NULL, NULL, false},

View File

@ -465,8 +465,18 @@ void MainEmuFrame::Menu_CdvdSource_Click(wxCommandEvent& event)
void MainEmuFrame::Menu_BootCdvd_Click(wxCommandEvent& event)
{
g_Conf->EmuOptions.UseBOOT2Injection = g_Conf->EnableFastBoot;
_DoBootCdvd();
#ifndef DISABLE_RECORDING
if (g_InputRecording.IsActive())
{
if (!g_InputRecording.GoToFirstFrame())
StopInputRecording();
}
else
#endif
{
g_Conf->EmuOptions.UseBOOT2Injection = g_Conf->EnableFastBoot;
_DoBootCdvd();
}
}
void MainEmuFrame::Menu_FastBoot_Click(wxCommandEvent& event)