diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index d82d190209..0c7738f1e0 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -622,15 +622,34 @@ EState GetState() return CORE_UNINITIALIZED; } -// Save or recreate the emulation state -void SaveState() { - State_Save(0); -} - -void LoadState() { - State_Load(0); +static inline std::string GenerateScreenshotName() +{ + int index = 1; + std::string tempname, name; + tempname = FULL_SCREENSHOTS_DIR + GetStartupParameter().GetUniqueID(); + + name = StringFromFormat("%s-%d.bmp", tempname.c_str(), index); + + while(File::Exists(name.c_str())) + name = StringFromFormat("%s-%d.bmp", tempname.c_str(), ++index); + + return name; } +void ScreenShot(const std::string& name) +{ + bool bPaused = (GetState() == CORE_PAUSE); + + SetState(CORE_PAUSE); + CPluginManager::GetInstance().GetVideo()->Video_Screenshot(name.c_str()); + if(!bPaused) + SetState(CORE_RUN); +} + +void ScreenShot() +{ + ScreenShot(GenerateScreenshotName()); +} // --- Callbacks for plugins / engine --- @@ -849,28 +868,38 @@ const char *Callback_ISOName() return ""; } - // Called from ANY thread! +// The hotkey function void Callback_KeyPress(int key, bool shift, bool control) { - // 0x70 == VK_F1 - if (key >= 0x70 && key < 0x79) { + // F1 - F8: Save states + if (key >= 0x70 && key < 0x78) { // F-key int slot_number = key - 0x70 + 1; - if (shift) { + if (shift) State_Save(slot_number); - } else { + else State_Load(slot_number); - } } + // 0x78 == VK_F9 + if (key == 0x78) + ScreenShot(); + // 0x7a == VK_F11 if (key == 0x7a) State_LoadLastSaved(); // 0x7a == VK_F12 - if (key == 0x7b) - State_LoadAs(FULL_STATESAVES_DIR "lastState.sav"); + if (key == 0x7b) + { + // TODO: Move to memory buffer, implement last state before loading + if(shift) + State_LoadAs(FULL_STATESAVES_DIR "lastState.sav"); + /*else + State_LoadAs(FULL_STATESAVES_DIR "tempState.sav"); + */ + } } // Callback_WiimoteLog diff --git a/Source/Core/Core/Src/Core.h b/Source/Core/Core/Src/Core.h index cd018b9529..1c66e8f4de 100644 --- a/Source/Core/Core/Src/Core.h +++ b/Source/Core/Core/Src/Core.h @@ -49,9 +49,8 @@ namespace Core void SetState(EState _State); EState GetState(); - // Save/Load state - void SaveState(); - void LoadState(); + void ScreenShot(const std::string& name); + void ScreenShot(); // Get core parameters kill use SConfig instead const SCoreStartupParameter& GetStartupParameter(); diff --git a/Source/Core/Core/Src/State.cpp b/Source/Core/Core/Src/State.cpp index 2c8f635b8c..123e8d653a 100644 --- a/Source/Core/Core/Src/State.cpp +++ b/Source/Core/Core/Src/State.cpp @@ -49,8 +49,8 @@ static unsigned char __LZO_MMODEL out [ OUT_LEN ]; static HEAP_ALLOC(wrkmem,LZO1X_1_MEM_COMPRESS); -static int ev_Save; -static int ev_Load; +static int ev_Save, ev_BufferSave; +static int ev_Load, ev_BufferLoad; static std::string cur_filename, lastFilename; diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index 438622b4d8..b2e02baa70 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -290,8 +290,8 @@ EVT_MENU(IDM_UNDOSTATE, CFrame::OnUndoState) EVT_MENU(IDM_LOADSTATEFILE, CFrame::OnLoadStateFromFile) EVT_MENU(IDM_SAVESTATEFILE, CFrame::OnSaveStateToFile) -EVT_MENU_RANGE(IDM_LOADSLOT1, IDM_LOADSLOT10, CFrame::OnLoadState) -EVT_MENU_RANGE(IDM_SAVESLOT1, IDM_SAVESLOT10, CFrame::OnSaveState) +EVT_MENU_RANGE(IDM_LOADSLOT1, IDM_LOADSLOT8, CFrame::OnLoadState) +EVT_MENU_RANGE(IDM_SAVESLOT1, IDM_SAVESLOT8, CFrame::OnSaveState) EVT_MENU_RANGE(IDM_DRIVE1, IDM_DRIVE24, CFrame::OnBootDrive) EVT_SIZE(CFrame::OnResize) diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index a56d83533d..ffe0d54d54 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -144,7 +144,7 @@ void CFrame::CreateMenu() loadMenu->Append(IDM_UNDOSTATE, _T("Last Overwritten State\tF12")); loadMenu->AppendSeparator(); - for (int i = 1; i < 10; i++) { + for (int i = 1; i <= 8; i++) { loadMenu->Append(IDM_LOADSLOT1 + i - 1, wxString::Format(_T("Slot %i\tF%i"), i, i)); saveMenu->Append(IDM_SAVESLOT1 + i - 1, wxString::Format(_T("Slot %i\tShift+F%i"), i, i)); } @@ -516,34 +516,12 @@ void CFrame::OnBrowse(wxCommandEvent& WXUNUSED (event)) m_GameListCtrl->BrowseForDirectory(); } - // Create screenshot -static inline void GenerateScreenshotName(std::string& name) -{ - int index = 1; - std::string tempname; - tempname = FULL_SCREENSHOTS_DIR; - tempname += Core::GetStartupParameter().GetUniqueID(); - - name = StringFromFormat("%s-%d.bmp", tempname.c_str(), index); - - while(File::Exists(name.c_str())) - name = StringFromFormat("%s-%d.bmp", tempname.c_str(), ++index); -} - void CFrame::OnScreenshot(wxCommandEvent& WXUNUSED (event)) { - std::string name; - GenerateScreenshotName(name); - bool bPaused = (Core::GetState() == Core::CORE_PAUSE); - - Core::SetState(Core::CORE_PAUSE); - CPluginManager::GetInstance().GetVideo()->Video_Screenshot(name.c_str()); - if(!bPaused) - Core::SetState(Core::CORE_RUN); + Core::ScreenShot(); } - // Stop the emulation void CFrame::DoStop() { @@ -583,7 +561,6 @@ void CFrame::OnStop(wxCommandEvent& WXUNUSED (event)) DoStop(); } - void CFrame::OnConfigMain(wxCommandEvent& WXUNUSED (event)) { CConfigMain ConfigMain(this); diff --git a/Source/Core/DolphinWX/Src/Globals.h b/Source/Core/DolphinWX/Src/Globals.h index 7dae1f508d..819b24337b 100644 --- a/Source/Core/DolphinWX/Src/Globals.h +++ b/Source/Core/DolphinWX/Src/Globals.h @@ -43,8 +43,6 @@ enum IDM_SAVESLOT6, IDM_SAVESLOT7, IDM_SAVESLOT8, - IDM_SAVESLOT9, - IDM_SAVESLOT10, IDM_LOADSLOT1, IDM_LOADSLOT2, IDM_LOADSLOT3, @@ -53,8 +51,6 @@ enum IDM_LOADSLOT6, IDM_LOADSLOT7, IDM_LOADSLOT8, - IDM_LOADSLOT9, - IDM_LOADSLOT10, IDM_PLAY, IDM_STOP, IDM_SCREENSHOT,