gui:recording: force ascii for filepath of recording, remove legacy conversions

This commit is contained in:
Tyler Wilding 2018-07-15 22:10:40 -04:00 committed by lightningterror
parent cb7425c59f
commit 8b6ccde441
5 changed files with 2 additions and 214 deletions

View File

@ -52,7 +52,7 @@ bool InputRecordingFile::Open(const wxString fn, bool fNewOpen, VmStateBuffer *s
UndoCount = 0;
header.init();
}
if ( fopen_s(&fp, fn.c_str(), mode.c_str()) != 0)
if ( fopen_s(&fp, fn.ToAscii(), mode.c_str()) != 0)
{
recordingConLog(wxString::Format("[REC]: Movie file opening failed. Error - %s\n", strerror(errno)));
return false;
@ -308,157 +308,3 @@ void InputRecordingHeader::init()
memset(author, 0, ArraySize(author));
memset(cdrom, 0, ArraySize(cdrom));
}
void InputRecordingFile::ConvertV2ToV3(wxString filename)
{
// TODO, with the latest version of save states requiring a savestate integrated into the file
// or it restarts as it assumes it is from power-on
// I don't see how save states would be compatible
}
//===========================================================
// ver 1.0~1.2 -> ver 2.0~
// If the file does not have a version header, then we can assume it is prior to version....3?
// takes far too long to iterate through with the new format because of the large space reserved for
// the save state(s)
//
// Note - Save states are not even compatible from these two versions of PCSX2
//===========================================================
void InputRecordingFile::ConvertV1_XToV2(wxString filename)
{
recordingConLog(wxString::Format(L"[REC]: Conversion started - [%s]\n", WX_STR(filename)));
FILE * fp;
FILE * fp2;
fopen_s(&fp, filename, "rb");
if (fp == NULL) {
recordingConLog(wxString::Format(L"[REC]: Conversion failed - Error - %s\n", WX_STR(wxString(strerror(errno)))));
return;
}
wxString outfile = wxString::Format(L"%s_converted.p2m2", filename);
fopen_s(&fp2, outfile, "wb");
if (fp2 == NULL) {
// TODO: keybindings for Recording inputs - not related to this code, just made a note here lol
recordingConLog(wxString::Format(L"[REC]: Conversion failed - Error - %s\n", WX_STR(wxString(strerror(errno)))));
fclose(fp);
return;
}
//---------
// head
//---------
InputRecordingHeader header;
header.version = 2;
u32 maxframe =0;
u32 undo = 0;
fread(&maxframe, 4, 1, fp);
fread(&undo, 4, 1, fp);
MaxFrame = maxframe;
UndoCount = undo;
fwrite(&header, sizeof(InputRecordingHeader), 1, fp2);
fwrite(&MaxFrame, 4, 1, fp2);
fwrite(&UndoCount, 4, 1, fp2);
//---------
// frame
//---------
// this routine runs forever, looks broken
for (unsigned long i = 0; i < maxframe; i++) {
for (u8 port = 0; port < 2; port++) {
for (u8 buf = 3; buf < 3+6 ; buf++) {
long seekpoint1 = i;
seekpoint1 <<= (1 + 5);
seekpoint1 += port;
seekpoint1 <<= 5;
seekpoint1 += buf;
seekpoint1 += 8;
long seekpoint2 = _getBlockSeekPoint(i) + BLOCK_HEADER_SIZE + 6 * port + (buf - 3);
u8 tmp = 0;
fseek(fp, seekpoint1, SEEK_SET);
fread(&tmp, 1, 1, fp);
fseek(fp2, seekpoint2, SEEK_SET);
fwrite(&tmp, 1, 1, fp2);
}
}
}
fclose(fp);
fclose(fp2);
recordingConLog(wxString::Format(L"[REC]: Conversion successful\n"));
recordingConLog(wxString::Format(L"[REC]: Converted File - [%s]\n", WX_STR(outfile)));
}
void InputRecordingFile::ConvertV1ToV2(wxString filename)
{
// TODO: Save states are not compatible across these releases
// so unable to test
}
//===========================================================
// convert p2m -> p2m2
// The p2m file is a file generated with the following URL.
// https://code.google.com/archive/p/pcsx2-rr/
// Legacy Conversion this will
//===========================================================
void InputRecordingFile::ConvertLegacy(wxString filename)
{
recordingConLog(wxString::Format(L"[REC]: Conversion started - [%s]\n", WX_STR(filename)));
FILE * fp;
FILE * fp2;
fopen_s(&fp, filename, "rb");
if (fp == NULL) {
recordingConLog(wxString::Format(L"[REC]: Conversion failed - Error - %s\n", WX_STR(wxString(strerror(errno)))));
return;
}
wxString outfile = wxString::Format(L"%s.p2m2", filename);
fopen_s(&fp2, outfile, "wb");
if (fp2 == NULL) {
recordingConLog(wxString::Format(L"[REC]: Conversion failed - Error - %s\n", WX_STR(wxString(strerror(errno)))));
fclose(fp);
return;
}
//--------------------------------------
// fread(&g_Movie.FrameMax, 4, 1, g_Movie.File);
// fread(&g_Movie.Rerecs, 4, 1, g_Movie.File);
// fread(g_PadData[0]+2, 6, 1, g_Movie.File);
//--------------------------------------
//------
//head
//------
InputRecordingHeader header;
header.version = 2;
u32 maxframe = 0;
u32 undo = 0;
fread(&maxframe, 4, 1, fp);
fread(&undo, 4, 1, fp);
MaxFrame = maxframe;
UndoCount = undo;
fwrite(&header, sizeof(InputRecordingHeader), 1, fp2);
fwrite(&MaxFrame, 4, 1, fp2);
fwrite(&UndoCount, 4, 1, fp2);
//------
// frame
//------
for (unsigned long frame = 0; frame < maxframe; frame++)
{
u8 p1key[6];
fread(p1key, 6, 1, fp);
long seek = _getBlockSeekPoint(frame) + BLOCK_HEADER_SIZE;
fseek(fp2, seek, SEEK_SET);
fwrite(p1key, 6, 1, fp2);
// 2p
u8 p2key[6] = { 255,255,127,127,127,127 };
fwrite(p2key, 6, 1, fp2);
}
fclose(fp);
fclose(fp2);
recordingConLog(wxString::Format(L"[REC]: Conversion successful\n"));
recordingConLog(wxString::Format(L"[REC]: Converted File - [%s]\n", WX_STR(outfile)));
}

View File

@ -52,12 +52,6 @@ public:
bool InsertPadData(unsigned long frame, const PadData& key);
bool UpdatePadData(unsigned long frame, const PadData& key);
// convert
void ConvertV2ToV3(wxString filename);
void ConvertV1_XToV2(wxString filename);
void ConvertV1ToV2(wxString filename);
void ConvertLegacy(wxString filename);
private:
FILE * fp=NULL;
wxString filename = "";

View File

@ -258,10 +258,6 @@ void MainEmuFrame::ConnectMenus()
Bind(wxEVT_MENU, &MainEmuFrame::Menu_Recording_Editor_Click, this, MenuId_Recording_Editor);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_Recording_VirtualPad_Open_Click, this, MenuId_Recording_VirtualPad_Port0);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_Recording_VirtualPad_Open_Click, this, MenuId_Recording_VirtualPad_Port1);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_Recording_ConvertV2ToV3_Click, this, MenuId_Recording_ConvertV2ToV3);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_Recording_ConvertV1_XToV2_Click, this, MenuId_Recording_ConvertV1_XToV2);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_Recording_ConvertV1ToV2_Click, this, MenuId_Recording_ConvertV1ToV2);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_Recording_ConvertLegacy_Click, this, MenuId_Recording_ConvertLegacy);
#endif
//Bind(wxEVT_MENU, &MainEmuFrame::Menu_Debug_MemoryDump_Click, this, MenuId_Debug_MemoryDump);
@ -349,7 +345,6 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title)
, m_submenuScreenshot ( *new wxMenu() )
#ifndef DISABLE_RECORDING
, m_menuRecording(*new wxMenu())
, m_submenuMovieConvert(*new wxMenu())
#endif
, m_LoadStatesSubmenu( *MakeStatesSubMenu( MenuId_State_Load01, MenuId_State_LoadBackup ) )
, m_SaveStatesSubmenu( *MakeStatesSubMenu( MenuId_State_Save01 ) )
@ -584,12 +579,6 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title)
m_menuRecording.Append(MenuId_Recording_Editor, _("Open Movie Editor"));
m_menuRecording.Append(MenuId_Recording_VirtualPad_Port0, _("Virtual Pad (Port 1)"));
m_menuRecording.Append(MenuId_Recording_VirtualPad_Port1, _("Virtual Pad (Port 2)"));
m_menuRecording.AppendSeparator();
m_menuRecording.Append(MenuId_Recording_Conversions, _("Movie File Conversions"), &m_submenuMovieConvert);
m_submenuMovieConvert.Append(MenuId_Recording_ConvertV2ToV3, _("Convert (v2.0 -> v3.0)"))->Enable(false); // TODO
m_submenuMovieConvert.Append(MenuId_Recording_ConvertV1_XToV2, _("Convert (v1.X -> v2.0)"));
m_submenuMovieConvert.Append(MenuId_Recording_ConvertV1ToV2, _("Convert (v1.0 -> v2.0)"))->Enable(false); // TODO
m_submenuMovieConvert.Append(MenuId_Recording_ConvertLegacy, _("Convert Legacy Movie (p2m -> p2m2)"));
#endif
m_MenuItem_Console.Check( g_Conf->ProgLogBox.Visible );

View File

@ -118,7 +118,6 @@ protected:
#ifndef DISABLE_RECORDING
wxMenu& m_menuRecording;
wxMenu& m_submenuMovieConvert;
#endif
wxMenu& m_LoadStatesSubmenu;
@ -231,10 +230,6 @@ protected:
void Menu_Recording_Stop_Click(wxCommandEvent &event);
void Menu_Recording_Editor_Click(wxCommandEvent &event);
void Menu_Recording_VirtualPad_Open_Click(wxCommandEvent &event);
void Menu_Recording_ConvertV2ToV3_Click(wxCommandEvent &event);
void Menu_Recording_ConvertV1_XToV2_Click(wxCommandEvent &event);
void Menu_Recording_ConvertV1ToV2_Click(wxCommandEvent &event);
void Menu_Recording_ConvertLegacy_Click(wxCommandEvent &event);
#endif
void _DoBootCdvd();

View File

@ -514,7 +514,7 @@ void MainEmuFrame::Menu_EnableRecordingTools_Click(wxCommandEvent&)
}
g_Conf->EmuOptions.EnableRecordingTools = checked;
((ConsoleLogSource*)&SysConsole.recordingConsole)->Enabled = checked;
SysConsole.recordingConsole.Enabled = checked;
ConsoleLogFrame* proglog = wxGetApp().GetProgramLog();
proglog->UpdateLogList();
AppApplySettings();
@ -844,40 +844,4 @@ void MainEmuFrame::Menu_Recording_VirtualPad_Open_Click(wxCommandEvent &event)
if (vp)
vp->Show();
}
void MainEmuFrame::Menu_Recording_ConvertV2ToV3_Click(wxCommandEvent &event)
{
wxFileDialog openFileDialog(this, _("Select P2M2 record file."), L"", L"",
L"p2m file(*.p2m2)|*.p2m2", wxFD_OPEN);
if (openFileDialog.ShowModal() == wxID_CANCEL)return;// cancel
wxString path = openFileDialog.GetPath();
g_InputRecordingData.ConvertV2ToV3(path);
}
void MainEmuFrame::Menu_Recording_ConvertV1_XToV2_Click(wxCommandEvent &event)
{
wxFileDialog openFileDialog(this, _("Select P2M2 record file."), L"", L"",
L"p2m file(*.p2m2)|*.p2m2", wxFD_OPEN);
if (openFileDialog.ShowModal() == wxID_CANCEL)return;// cancel
wxString path = openFileDialog.GetPath();
g_InputRecordingData.ConvertV1_XToV2(path);
}
void MainEmuFrame::Menu_Recording_ConvertV1ToV2_Click(wxCommandEvent &event)
{
wxFileDialog openFileDialog(this, _("Select P2M2 record file."), L"", L"",
L"p2m file(*.p2m2)|*.p2m2", wxFD_OPEN);
if (openFileDialog.ShowModal() == wxID_CANCEL)return;// cancel
wxString path = openFileDialog.GetPath();
g_InputRecordingData.ConvertV1ToV2(path);
}
void MainEmuFrame::Menu_Recording_ConvertLegacy_Click(wxCommandEvent &event)
{
wxFileDialog openFileDialog(this, _("Select P2M record file."), L"", L"",
L"p2m file(*.p2m)|*.p2m", wxFD_OPEN);
if (openFileDialog.ShowModal() == wxID_CANCEL)return;// cancel
wxString path = openFileDialog.GetPath();
g_InputRecordingData.ConvertLegacy(path);
}
#endif