diff --git a/Source/Core/Core/Src/OnFrame.cpp b/Source/Core/Core/Src/OnFrame.cpp index 701a30ac7d..63ad3abd75 100644 --- a/Source/Core/Core/Src/OnFrame.cpp +++ b/Source/Core/Core/Src/OnFrame.cpp @@ -57,18 +57,17 @@ void FrameUpdate() { g_bFirstKey = !g_bFirstKey; // Dump/Read all controllers' states for this frame - if(g_bPolled) { - if(IsRecordingInput()) - fwrite(g_padStates, sizeof(ControllerState), g_numPads, g_recordfd); - else if(IsPlayingInput()) { - fread(g_padStates, sizeof(ControllerState), g_numPads, g_recordfd); + if(IsRecordingInput()) + fwrite(g_padStates, sizeof(ControllerState), g_numPads, g_recordfd); + else if(IsPlayingInput()) { + fread(g_padStates, sizeof(ControllerState), g_numPads, g_recordfd); - // End of recording - if(feof(g_recordfd)) - EndPlayInput(); - } + // End of recording + if(feof(g_recordfd)) + EndPlayInput(); } + g_bPolled = false; } @@ -212,8 +211,9 @@ void EndRecordingInput() DTMHeader header; memset(&header, 0, sizeof(DTMHeader)); - header.bWii = Core::g_CoreStartupParameter.bWii; + header.filetype[0] = 'D'; header.filetype[1] = 'T'; header.filetype[2] = 'M'; header.filetype[3] = 0x1A; strncpy((char *)header.gameID, Core::g_CoreStartupParameter.GetUniqueID().c_str(), 6); + header.bWii = Core::g_CoreStartupParameter.bWii; header.numControllers = g_numPads; header.bFromSaveState = false; // TODO: add the case where it's true @@ -284,6 +284,11 @@ bool PlayInput(const char *filename) fread(&header, sizeof(DTMHeader), 1, g_recordfd); + if(header.filetype[0] != 'D' || header.filetype[1] != 'T' || header.filetype[2] != 'M' || header.filetype[3] != 0x1A) { + PanicAlert("Invalid recording file"); + goto cleanup; + } + // Load savestate (and skip to frame data) if(header.bFromSaveState) { // TODO diff --git a/Source/Core/Core/Src/OnFrame.h b/Source/Core/Core/Src/OnFrame.h index 9b1773840a..d4e62b97ce 100644 --- a/Source/Core/Core/Src/OnFrame.h +++ b/Source/Core/Core/Src/OnFrame.h @@ -44,8 +44,10 @@ typedef struct { } ControllerState; // Total: 58 + 2 = 60 bits per frame typedef struct { - bool bWii; // Wii game - u8 gameID[6]; // The Game ID + u8 filetype[4]; // Unique Identifier (always "DTM"0x1A) + + u8 gameID[6]; // The Game ID + bool bWii; // Wii game u8 numControllers; // The number of connected controllers (1-4) diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index d119c0001f..1ad8369039 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -238,6 +238,7 @@ EVT_MENU(IDM_PLAY, CFrame::OnPlay) EVT_MENU(IDM_RECORD, CFrame::OnRecord) EVT_MENU(IDM_PLAYRECORD, CFrame::OnPlayRecording) EVT_MENU(IDM_STOP, CFrame::OnStop) +EVT_MENU(IDM_FRAMESTEP, CFrame::OnFrameStep) EVT_MENU(IDM_SCREENSHOT, CFrame::OnScreenshot) EVT_MENU(IDM_CONFIG_MAIN, CFrame::OnConfigMain) EVT_MENU(IDM_CONFIG_GFX_PLUGIN, CFrame::OnPluginGFX) diff --git a/Source/Core/DolphinWX/Src/Frame.h b/Source/Core/DolphinWX/Src/Frame.h index 856dcf1f24..2cb9f73bfb 100644 --- a/Source/Core/DolphinWX/Src/Frame.h +++ b/Source/Core/DolphinWX/Src/Frame.h @@ -173,6 +173,7 @@ class CFrame : public wxFrame void OnUndoSaveState(wxCommandEvent& event); void OnFrameSkip(wxCommandEvent& event); + void OnFrameStep(wxCommandEvent& event); void OnConfigMain(wxCommandEvent& event); // Options void OnPluginGFX(wxCommandEvent& event); diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index 4cb798ddf4..a63e202171 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -136,9 +136,10 @@ void CFrame::CreateMenu() emulationMenu->AppendSeparator(); emulationMenu->Append(IDM_CHANGEDISC, _T("Change &Disc")); - + emulationMenu->Append(IDM_FRAMESTEP, _T("&Frame Stepping"), wxEmptyString, wxITEM_CHECK); + wxMenu *skippingMenu = new wxMenu; - m_pSubMenuFrameSkipping = emulationMenu->AppendSubMenu(skippingMenu, _T("&Frame Skipping")); + m_pSubMenuFrameSkipping = emulationMenu->AppendSubMenu(skippingMenu, _T("Frame S&kipping")); for(int i = 0; i < 10; i++) skippingMenu->Append(IDM_FRAMESKIP0 + i, wxString::Format(_T("%i"), i), wxEmptyString, wxITEM_RADIO); @@ -486,6 +487,11 @@ void CFrame::DoOpen(bool Boot) } } +void CFrame::OnFrameStep(wxCommandEvent& event) +{ + Frame::SetFrameStepping(event.IsChecked()); +} + void CFrame::OnChangeDisc(wxCommandEvent& WXUNUSED (event)) { DoOpen(false); @@ -887,6 +893,7 @@ void CFrame::UpdateGUI() GetMenuBar()->FindItem(IDM_STOP)->Enable(running || paused); GetMenuBar()->FindItem(IDM_RECORD)->Enable(!initialized); GetMenuBar()->FindItem(IDM_PLAYRECORD)->Enable(!initialized); + GetMenuBar()->FindItem(IDM_FRAMESTEP)->Enable(running || paused); GetMenuBar()->FindItem(IDM_SCREENSHOT)->Enable(running || paused); m_pSubMenuLoad->Enable(initialized); m_pSubMenuSave->Enable(initialized); diff --git a/Source/Core/DolphinWX/Src/Globals.h b/Source/Core/DolphinWX/Src/Globals.h index a1fec1f9f5..1ba37bead8 100644 --- a/Source/Core/DolphinWX/Src/Globals.h +++ b/Source/Core/DolphinWX/Src/Globals.h @@ -65,6 +65,7 @@ enum IDM_RECORD, IDM_PLAYRECORD, IDM_STOP, + IDM_FRAMESTEP, IDM_SCREENSHOT, IDM_BROWSE, IDM_DRIVE1,