recording: Added some more useful logs and cleaned up some TODOs

This commit is contained in:
Tyler Wilding 2018-11-22 22:17:42 -05:00 committed by lightningterror
parent eb7030cf12
commit c12c6ed149
4 changed files with 55 additions and 31 deletions

View File

@ -178,9 +178,11 @@ void InputRecording::Play(wxString FileName, bool fromSaveState)
recordingConLog(L"[REC]: Information on CD in Movie file is Different.\n"); recordingConLog(L"[REC]: Information on CD in Movie file is Different.\n");
} }
} }
// TODO - probably output more informatiion on it
state = REPLAY; state = 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"Recording File Version: %d\n", InputRecordingData.getHeader().version));
recordingConLog(wxString::Format(L"Associated Game Name / ISO Filename: %s\n", InputRecordingData.getHeader().gameName));
recordingConLog(wxString::Format(L"Author: %s\n", InputRecordingData.getHeader().author));
recordingConLog(wxString::Format(L"MaxFrame: %d\n", InputRecordingData.getMaxFrame())); recordingConLog(wxString::Format(L"MaxFrame: %d\n", InputRecordingData.getMaxFrame()));
recordingConLog(wxString::Format(L"UndoCount: %d\n", InputRecordingData.getUndoCount())); recordingConLog(wxString::Format(L"UndoCount: %d\n", InputRecordingData.getUndoCount()));
} }

View File

@ -49,12 +49,16 @@ bool InputRecordingFile::Open(const wxString path, bool fNewOpen, bool fromSaveS
} }
filename = path; filename = path;
// TODO - from power on its fine
// problems seem to be be based in how we are saving the savestate // problems seem to be be based in how we are saving the savestate
if (fNewOpen) { if (fNewOpen) {
if (fromSaveState) { if (fromSaveState) {
savestate.fromSavestate = true; savestate.fromSavestate = true;
// TODO - Check if existing, if so rename // TODO - Return save-state data back into the movie file eventually.
FILE* ssFileCheck = wxFopen(path + "_SaveState.p2s", "r");
if (ssFileCheck != NULL) {
wxCopyFile(path + "_SaveState.p2s", path + "_SaveState.p2s.bak", false);
}
fclose(ssFileCheck);
StateCopy_SaveToFile(path + "_SaveState.p2s"); StateCopy_SaveToFile(path + "_SaveState.p2s");
} }
else { else {
@ -66,7 +70,8 @@ bool InputRecordingFile::Open(const wxString path, bool fNewOpen, bool fromSaveS
bool InputRecordingFile::Close() bool InputRecordingFile::Close()
{ {
if (recordingFile == NULL)return false; if (recordingFile == NULL)
return false;
writeHeader(); writeHeader();
writeSaveState(); writeSaveState();
fclose(recordingFile); fclose(recordingFile);
@ -77,11 +82,12 @@ bool InputRecordingFile::Close()
bool InputRecordingFile::writeSaveState() { bool InputRecordingFile::writeSaveState() {
if (recordingFile == NULL) if (recordingFile == NULL)
{
return false; return false;
}
fseek(recordingFile, SEEKPOINT_SAVESTATE, SEEK_SET); fseek(recordingFile, SEEKPOINT_SAVESTATE, SEEK_SET);
if (fwrite(&savestate.fromSavestate, sizeof(bool), 1, recordingFile) != 1) return false; if (fwrite(&savestate.fromSavestate, sizeof(bool), 1, recordingFile) != 1)
return false;
return true; return true;
} }
@ -90,15 +96,16 @@ bool InputRecordingFile::writeSaveState() {
//---------------------------------- //----------------------------------
bool InputRecordingFile::writeKeyBuf(const uint & frame, const uint port, const uint bufIndex, const u8 & buf) bool InputRecordingFile::writeKeyBuf(const uint & frame, const uint port, const uint bufIndex, const u8 & buf)
{ {
if (recordingFile == NULL)return false; if (recordingFile == NULL)
return false;
long seek = _getBlockSeekPoint(frame) + BLOCK_HEADER_SIZE + 18 * port + bufIndex; long seek = _getBlockSeekPoint(frame) + BLOCK_HEADER_SIZE + 18 * port + bufIndex;
if (fseek(recordingFile, seek, SEEK_SET) != 0){
if (fseek(recordingFile, seek, SEEK_SET) != 0)
return false; return false;
} if (fwrite(&buf, 1, 1, recordingFile) != 1)
if (fwrite(&buf, 1, 1, recordingFile) != 1) {
return false; return false;
}
fflush(recordingFile); fflush(recordingFile);
return true; return true;
} }
@ -108,15 +115,15 @@ bool InputRecordingFile::writeKeyBuf(const uint & frame, const uint port, const
//---------------------------------- //----------------------------------
bool InputRecordingFile::readKeyBuf(u8 & result,const uint & frame, const uint port, const uint bufIndex) bool InputRecordingFile::readKeyBuf(u8 & result,const uint & frame, const uint port, const uint bufIndex)
{ {
if (recordingFile == NULL)return false; if (recordingFile == NULL)
return false;
long seek = _getBlockSeekPoint(frame) + BLOCK_HEADER_SIZE + 18 * port + bufIndex; long seek = _getBlockSeekPoint(frame) + BLOCK_HEADER_SIZE + 18 * port + bufIndex;
if (fseek(recordingFile, seek, SEEK_SET) != 0) { if (fseek(recordingFile, seek, SEEK_SET) != 0)
return false; return false;
} if (fread(&result, 1, 1, recordingFile) != 1)
if (fread(&result, 1, 1, recordingFile) != 1) {
return false; return false;
}
return true; return true;
} }
@ -126,16 +133,22 @@ bool InputRecordingFile::readKeyBuf(u8 & result,const uint & frame, const uint p
void InputRecordingFile::getPadData(PadData & result, unsigned long frame) void InputRecordingFile::getPadData(PadData & result, unsigned long frame)
{ {
result.fExistKey = false; result.fExistKey = false;
if (recordingFile == NULL)return; if (recordingFile == NULL)
return;
long seek = _getBlockSeekPoint(frame) + BLOCK_HEADER_SIZE; long seek = _getBlockSeekPoint(frame) + BLOCK_HEADER_SIZE;
if (fseek(recordingFile, seek, SEEK_SET) != 0)return; if (fseek(recordingFile, seek, SEEK_SET) != 0)
if (fread(result.buf, 1, BLOCK_DATA_SIZE, recordingFile) == 0)return; return;
if (fread(result.buf, 1, BLOCK_DATA_SIZE, recordingFile) == 0)
return;
result.fExistKey = true; result.fExistKey = true;
} }
bool InputRecordingFile::DeletePadData(unsigned long frame) bool InputRecordingFile::DeletePadData(unsigned long frame)
{ {
if (recordingFile == NULL)return false; if (recordingFile == NULL)
return false;
for (unsigned long i = frame; i < MaxFrame - 1; i++) for (unsigned long i = frame; i < MaxFrame - 1; i++)
{ {
@ -157,8 +170,10 @@ bool InputRecordingFile::DeletePadData(unsigned long frame)
bool InputRecordingFile::InsertPadData(unsigned long frame, const PadData& key) bool InputRecordingFile::InsertPadData(unsigned long frame, const PadData& key)
{ {
if (recordingFile == NULL)return false; if (recordingFile == NULL)
if (!key.fExistKey)return false; return false;
if (!key.fExistKey)
return false;
for (unsigned long i = MaxFrame - 1; i >= frame; i--) for (unsigned long i = MaxFrame - 1; i >= frame; i--)
{ {
@ -185,12 +200,15 @@ bool InputRecordingFile::InsertPadData(unsigned long frame, const PadData& key)
bool InputRecordingFile::UpdatePadData(unsigned long frame, const PadData& key) bool InputRecordingFile::UpdatePadData(unsigned long frame, const PadData& key)
{ {
if (recordingFile == NULL) return false; if (recordingFile == NULL)
if (!key.fExistKey) return false; return false;
if (!key.fExistKey)
return false;
long seek = _getBlockSeekPoint(frame) + BLOCK_HEADER_SIZE; long seek = _getBlockSeekPoint(frame) + BLOCK_HEADER_SIZE;
fseek(recordingFile, seek, SEEK_SET); fseek(recordingFile, seek, SEEK_SET);
if (fwrite(key.buf, 1, BLOCK_DATA_SIZE, recordingFile) == 0) return false; if (fwrite(key.buf, 1, BLOCK_DATA_SIZE, recordingFile) == 0)
return false;
fflush(recordingFile); fflush(recordingFile);
return true; return true;
@ -251,7 +269,8 @@ void InputRecordingFile::updateFrameMax(unsigned long frame)
void InputRecordingFile::addUndoCount() void InputRecordingFile::addUndoCount()
{ {
UndoCount++; UndoCount++;
if (recordingFile == NULL)return; if (recordingFile == NULL)
return;
fseek(recordingFile, SEEKPOINT_UNDOCOUNT, SEEK_SET); fseek(recordingFile, SEEKPOINT_UNDOCOUNT, SEEK_SET);
fwrite(&UndoCount, 4, 1, recordingFile); fwrite(&UndoCount, 4, 1, recordingFile);
} }

View File

@ -9,8 +9,9 @@ wxBEGIN_EVENT_TABLE(VirtualPad, wxFrame)
EVT_CLOSE(VirtualPad::OnClose) EVT_CLOSE(VirtualPad::OnClose)
wxEND_EVENT_TABLE() wxEND_EVENT_TABLE()
// TODO - Problems: // TODO - Problems / Potential improvements:
// Controller inputs dont update UI, add a refresh method or something // - The UI doesn't update to manual controller inputs and actually overrides the controller when opened (easily noticable with analog stick)
// - This is less than ideal, but it's going to take a rather large / focused refactor, in it's current state the virtual pad does what it needs to do (precise inputs, frame by frame)
VirtualPad::VirtualPad(wxWindow* parent, wxWindowID id, const wxString& title, int controllerPort, const wxPoint& pos, const wxSize& size, long style) : VirtualPad::VirtualPad(wxWindow* parent, wxWindowID id, const wxString& title, int controllerPort, const wxPoint& pos, const wxSize& size, long style) :
wxFrame(parent, id, title, pos, size, wxDEFAULT_FRAME_STYLE) wxFrame(parent, id, title, pos, size, wxDEFAULT_FRAME_STYLE)
{ {
@ -56,7 +57,7 @@ VirtualPad::VirtualPad(wxWindow* parent, wxWindowID id, const wxString& title, i
// Initialize class members // Initialize class members
VirtualPad::controllerPort = controllerPort; VirtualPad::controllerPort = controllerPort;
// NOTE: Order MATTERS, these match the map-key array defined in PadData.h // NOTE: Order MATTERS, these match enum defined in PadData.h
wxToggleButton* tempButtons[16] = { wxToggleButton* tempButtons[16] = {
// Pressure sensitive buttons // Pressure sensitive buttons
upButton, rightButton, leftButton, downButton, upButton, rightButton, leftButton, downButton,
@ -67,6 +68,7 @@ VirtualPad::VirtualPad(wxWindow* parent, wxWindowID id, const wxString& title, i
selectButton, startButton}; selectButton, startButton};
std::copy(std::begin(tempButtons), std::end(tempButtons), std::begin(buttons)); std::copy(std::begin(tempButtons), std::end(tempButtons), std::begin(buttons));
// NOTE: Order MATTERS, these match enum defined in PadData.h
wxSpinCtrl* tempPressureButtons[16] = { wxSpinCtrl* tempPressureButtons[16] = {
// Pressure sensitive buttons // Pressure sensitive buttons
upButtonPressure, rightButtonPressure, leftButtonPressure, downButtonPressure, upButtonPressure, rightButtonPressure, leftButtonPressure, downButtonPressure,
@ -74,9 +76,11 @@ VirtualPad::VirtualPad(wxWindow* parent, wxWindowID id, const wxString& title, i
l1ButtonPressure, l2ButtonPressure, r1ButtonPressure, r2ButtonPressure}; l1ButtonPressure, l2ButtonPressure, r1ButtonPressure, r2ButtonPressure};
std::copy(std::begin(tempPressureButtons), std::end(tempPressureButtons), std::begin(buttonsPressure)); std::copy(std::begin(tempPressureButtons), std::end(tempPressureButtons), std::begin(buttonsPressure));
// NOTE: Order MATTERS, these match enum defined in PadData.h
wxSlider* tempAnalogSliders[4] = { leftAnalogXVal, leftAnalogYVal, rightAnalogXVal, rightAnalogYVal }; wxSlider* tempAnalogSliders[4] = { leftAnalogXVal, leftAnalogYVal, rightAnalogXVal, rightAnalogYVal };
std::copy(std::begin(tempAnalogSliders), std::end(tempAnalogSliders), std::begin(analogSliders)); std::copy(std::begin(tempAnalogSliders), std::end(tempAnalogSliders), std::begin(analogSliders));
// NOTE: Order MATTERS, these match enum defined in PadData.h
wxSpinCtrl* tempAnalogVals[4] = { leftAnalogXValPrecise, leftAnalogYValPrecise, rightAnalogXValPrecise, rightAnalogYValPrecise }; wxSpinCtrl* tempAnalogVals[4] = { leftAnalogXValPrecise, leftAnalogYValPrecise, rightAnalogXValPrecise, rightAnalogYValPrecise };
std::copy(std::begin(tempAnalogVals), std::end(tempAnalogVals), std::begin(analogVals)); std::copy(std::begin(tempAnalogVals), std::end(tempAnalogVals), std::begin(analogVals));

View File

@ -800,7 +800,6 @@ void MainEmuFrame::Menu_Recording_New_Click(wxCommandEvent &event)
// From Power-On // From Power-On
else if (NewRecordingFrame->getFrom() == 1) else if (NewRecordingFrame->getFrom() == 1)
{ {
// TODO extensively test this
g_InputRecording.Create(NewRecordingFrame->getFile(), false, NewRecordingFrame->getAuthor()); g_InputRecording.Create(NewRecordingFrame->getFile(), false, NewRecordingFrame->getAuthor());
} }
} }