mirror of https://github.com/PCSX2/pcsx2.git
pcsx2-tas: Corrections to recording file's header data (#3480)
* The emulator version was hard-coded to PCSX2-1.5.X which is no longer accurate, it is no longer hard-coded and will use the correct version number the same way it is calculated to display in the window title. * When creating a recording, the game name is preferred over the ISO name. This is determined via the GameDB. When playing back the recording, a simple check occurs to see if the game running is the same one that was used to make the recording. On the playback side, it always only checked with the ISO filename.
This commit is contained in:
parent
b3d90537ba
commit
9d6d7f7f63
|
@ -87,8 +87,7 @@ void InputRecording::ControllerInterrupt(u8 &data, u8 &port, u16 & bufCount, u8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fInterruptFrame
|
if (!fInterruptFrame || state == INPUT_RECORDING_MODE_NONE
|
||||||
|| state == INPUT_RECORDING_MODE_NONE
|
|
||||||
// We do not want to record or save the first two
|
// We do not want to record or save the first two
|
||||||
// bytes in the data returned from LilyPad
|
// bytes in the data returned from LilyPad
|
||||||
|| bufCount < 3)
|
|| bufCount < 3)
|
||||||
|
@ -141,29 +140,17 @@ void InputRecording::Create(wxString FileName, bool fromSaveState, wxString auth
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Set emulator version
|
||||||
|
InputRecordingData.GetHeader().SetEmulatorVersion();
|
||||||
|
|
||||||
// Set author name
|
// Set author name
|
||||||
if (!authorName.IsEmpty())
|
if (!authorName.IsEmpty())
|
||||||
{
|
{
|
||||||
InputRecordingData.GetHeader().SetAuthor(authorName);
|
InputRecordingData.GetHeader().SetAuthor(authorName);
|
||||||
}
|
}
|
||||||
// Set Game Name
|
// Set Game Name
|
||||||
// Code loosely taken from AppCoreThread.cpp to resolve the Game Name
|
InputRecordingData.GetHeader().SetGameName(resolveGameName());
|
||||||
// Fallback is ISO name
|
// Write header contents
|
||||||
wxString gameName;
|
|
||||||
const wxString gameKey(SysGetDiscID());
|
|
||||||
if (!gameKey.IsEmpty())
|
|
||||||
{
|
|
||||||
if (IGameDatabase* GameDB = AppHost_GetGameDatabase())
|
|
||||||
{
|
|
||||||
Game_Data game;
|
|
||||||
if (GameDB->findGame(game, gameKey))
|
|
||||||
{
|
|
||||||
gameName = game.getString("Name");
|
|
||||||
gameName += L" (" + game.getString("Region") + L")";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
InputRecordingData.GetHeader().SetGameName(!gameName.IsEmpty() ? gameName : Path::GetFilename(g_Conf->CurrentIso));
|
|
||||||
InputRecordingData.WriteHeader();
|
InputRecordingData.WriteHeader();
|
||||||
state = INPUT_RECORDING_MODE_RECORD;
|
state = INPUT_RECORDING_MODE_RECORD;
|
||||||
recordingConLog(wxString::Format(L"[REC]: Started new recording - [%s]\n", FileName));
|
recordingConLog(wxString::Format(L"[REC]: Started new recording - [%s]\n", FileName));
|
||||||
|
@ -191,20 +178,41 @@ void InputRecording::Play(wxString FileName, bool fromSaveState)
|
||||||
// Check author name
|
// Check author name
|
||||||
if (!g_Conf->CurrentIso.IsEmpty())
|
if (!g_Conf->CurrentIso.IsEmpty())
|
||||||
{
|
{
|
||||||
if (Path::GetFilename(g_Conf->CurrentIso) != InputRecordingData.GetHeader().gameName)
|
if (resolveGameName() != InputRecordingData.GetHeader().gameName)
|
||||||
{
|
{
|
||||||
recordingConLog(L"[REC]: Information on CD in Movie file is Different.\n");
|
recordingConLog(L"[REC]: Recording was possibly recorded on a different game.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
state = INPUT_RECORDING_MODE_REPLAY;
|
state = INPUT_RECORDING_MODE_REPLAY;
|
||||||
recordingConLog(wxString::Format(L"[REC]: Replaying movie - [%s]\n", FileName));
|
recordingConLog(wxString::Format(L"[REC]: Replaying movie - [%s]\n", FileName));
|
||||||
|
recordingConLog(wxString::Format(L"[REC]: PCSX2 Version Used: %s\n", InputRecordingData.GetHeader().emu));
|
||||||
recordingConLog(wxString::Format(L"[REC]: Recording File Version: %d\n", InputRecordingData.GetHeader().version));
|
recordingConLog(wxString::Format(L"[REC]: Recording File Version: %d\n", InputRecordingData.GetHeader().version));
|
||||||
recordingConLog(wxString::Format(L"[REC]: Associated Game Name / ISO Filename: %s\n", InputRecordingData.GetHeader().gameName));
|
recordingConLog(wxString::Format(L"[REC]: Associated Game Name or ISO Filename: %s\n", InputRecordingData.GetHeader().gameName));
|
||||||
recordingConLog(wxString::Format(L"[REC]: Author: %s\n", InputRecordingData.GetHeader().author));
|
recordingConLog(wxString::Format(L"[REC]: Author: %s\n", InputRecordingData.GetHeader().author));
|
||||||
recordingConLog(wxString::Format(L"[REC]: MaxFrame: %d\n", InputRecordingData.GetMaxFrame()));
|
recordingConLog(wxString::Format(L"[REC]: MaxFrame: %d\n", InputRecordingData.GetMaxFrame()));
|
||||||
recordingConLog(wxString::Format(L"[REC]: UndoCount: %d\n", InputRecordingData.GetUndoCount()));
|
recordingConLog(wxString::Format(L"[REC]: UndoCount: %d\n", InputRecordingData.GetUndoCount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxString InputRecording::resolveGameName()
|
||||||
|
{
|
||||||
|
// Code loosely taken from AppCoreThread::_ApplySettings to resolve the Game Name
|
||||||
|
wxString gameName;
|
||||||
|
const wxString gameKey(SysGetDiscID());
|
||||||
|
if (!gameKey.IsEmpty())
|
||||||
|
{
|
||||||
|
if (IGameDatabase* GameDB = AppHost_GetGameDatabase())
|
||||||
|
{
|
||||||
|
Game_Data game;
|
||||||
|
if (GameDB->findGame(game, gameKey))
|
||||||
|
{
|
||||||
|
gameName = game.getString("Name");
|
||||||
|
gameName += L" (" + game.getString("Region") + L")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return !gameName.IsEmpty() ? gameName : Path::GetFilename(g_Conf->CurrentIso);
|
||||||
|
}
|
||||||
|
|
||||||
// Keybind Handler - Toggle between recording input and not
|
// Keybind Handler - Toggle between recording input and not
|
||||||
void InputRecording::RecordModeToggle()
|
void InputRecording::RecordModeToggle()
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,6 +48,9 @@ private:
|
||||||
InputRecordingFile InputRecordingData;
|
InputRecordingFile InputRecordingData;
|
||||||
INPUT_RECORDING_MODE state = INPUT_RECORDING_MODE_NONE;
|
INPUT_RECORDING_MODE state = INPUT_RECORDING_MODE_NONE;
|
||||||
bool fInterruptFrame = false;
|
bool fInterruptFrame = false;
|
||||||
|
// Resolve the name and region of the game currently loaded using the GameDB
|
||||||
|
// If the game cannot be found in the DB, the fallback is the ISO filename
|
||||||
|
wxString resolveGameName();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern InputRecording g_InputRecording;
|
extern InputRecording g_InputRecording;
|
||||||
|
|
|
@ -28,9 +28,7 @@ long InputRecordingFile::GetBlockSeekPoint(const long & frame)
|
||||||
{
|
{
|
||||||
if (savestate.fromSavestate)
|
if (savestate.fromSavestate)
|
||||||
{
|
{
|
||||||
return RecordingHeaderSize
|
return RecordingHeaderSize + RecordingSavestateHeaderSize + frame * RecordingBlockSize;
|
||||||
+ RecordingSavestateHeaderSize
|
|
||||||
+ frame * RecordingBlockSize;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -95,7 +93,8 @@ bool InputRecordingFile::Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write savestate flag to file
|
// Write savestate flag to file
|
||||||
bool InputRecordingFile::WriteSaveState() {
|
bool InputRecordingFile::WriteSaveState()
|
||||||
|
{
|
||||||
if (recordingFile == NULL)
|
if (recordingFile == NULL)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -120,8 +119,7 @@ bool InputRecordingFile::WriteKeyBuf(const uint & frame, const uint port, const
|
||||||
|
|
||||||
long seek = GetBlockSeekPoint(frame) + RecordingBlockHeaderSize + 18 * port + bufIndex;
|
long seek = GetBlockSeekPoint(frame) + RecordingBlockHeaderSize + 18 * port + bufIndex;
|
||||||
|
|
||||||
if (fseek(recordingFile, seek, SEEK_SET) != 0
|
if (fseek(recordingFile, seek, SEEK_SET) != 0 || fwrite(&buf, 1, 1, recordingFile) != 1)
|
||||||
|| fwrite(&buf, 1, 1, recordingFile) != 1)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -161,8 +159,7 @@ void InputRecordingFile::GetPadData(PadData & result, unsigned long frame)
|
||||||
}
|
}
|
||||||
|
|
||||||
long seek = GetBlockSeekPoint(frame) + RecordingBlockHeaderSize;
|
long seek = GetBlockSeekPoint(frame) + RecordingBlockHeaderSize;
|
||||||
if (fseek(recordingFile, seek, SEEK_SET) != 0
|
if (fseek(recordingFile, seek, SEEK_SET) != 0 || fread(result.buf, 1, RecordingBlockDataSize, recordingFile) == 0)
|
||||||
|| fread(result.buf, 1, RecordingBlockDataSize, recordingFile) == 0)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -278,10 +275,7 @@ bool InputRecordingFile::ReadHeaderAndCheck()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
rewind(recordingFile);
|
rewind(recordingFile);
|
||||||
if (fread(&header, sizeof(InputRecordingHeader), 1, recordingFile) != 1
|
if (fread(&header, sizeof(InputRecordingHeader), 1, recordingFile) != 1 || fread(&MaxFrame, 4, 1, recordingFile) != 1 || fread(&UndoCount, 4, 1, recordingFile) != 1 || fread(&savestate.fromSavestate, sizeof(bool), 1, recordingFile) != 1)
|
||||||
|| fread(&MaxFrame, 4, 1, recordingFile) != 1
|
|
||||||
|| fread(&UndoCount, 4, 1, recordingFile) != 1
|
|
||||||
|| fread(&savestate.fromSavestate, sizeof(bool), 1, recordingFile) != 1)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -359,6 +353,14 @@ void InputRecordingFile::AddUndoCount()
|
||||||
fwrite(&UndoCount, 4, 1, recordingFile);
|
fwrite(&UndoCount, 4, 1, recordingFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InputRecordingHeader::SetEmulatorVersion()
|
||||||
|
{
|
||||||
|
wxString emuVersion = wxString::Format("%s-%d.%d.%d", pxGetAppName().c_str(), PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo);
|
||||||
|
int max = ArraySize(emu) - 1;
|
||||||
|
strncpy(emu, emuVersion.c_str(), max);
|
||||||
|
emu[max] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void InputRecordingHeader::SetAuthor(wxString _author)
|
void InputRecordingHeader::SetAuthor(wxString _author)
|
||||||
{
|
{
|
||||||
int max = ArraySize(author) - 1;
|
int max = ArraySize(author) - 1;
|
||||||
|
@ -381,7 +383,8 @@ void InputRecordingHeader::Init()
|
||||||
|
|
||||||
InputRecordingHeader& InputRecordingFile::GetHeader()
|
InputRecordingHeader& InputRecordingFile::GetHeader()
|
||||||
{
|
{
|
||||||
return header; }
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned long& InputRecordingFile::GetMaxFrame()
|
unsigned long& InputRecordingFile::GetMaxFrame()
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,11 +23,12 @@
|
||||||
struct InputRecordingHeader
|
struct InputRecordingHeader
|
||||||
{
|
{
|
||||||
u8 version = 1;
|
u8 version = 1;
|
||||||
char emu[50] = "PCSX2-1.5.X";
|
char emu[50] = "";
|
||||||
char author[255] = "";
|
char author[255] = "";
|
||||||
char gameName[255] = "";
|
char gameName[255] = "";
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
void SetEmulatorVersion();
|
||||||
void SetAuthor(wxString author);
|
void SetAuthor(wxString author);
|
||||||
void SetGameName(wxString cdrom);
|
void SetGameName(wxString cdrom);
|
||||||
void Init();
|
void Init();
|
||||||
|
|
Loading…
Reference in New Issue