mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 17:19:44 -06:00
Basic VBA-style save state system implemented - kb shortcuts only working on Windows. Keyboard shortcut system added. More cleanup in GFX plugins.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@390 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -73,9 +73,11 @@ void Callback_VideoLog(const TCHAR* _szMessage, BOOL _bDoBreak);
|
||||
void Callback_VideoCopiedToXFB();
|
||||
void Callback_DSPLog(const TCHAR* _szMessage);
|
||||
void Callback_DSPInterrupt();
|
||||
void Callback_DVDLog(const TCHAR* _szMessage);
|
||||
void Callback_DVDSetStatusbar(TCHAR* _szMessage);
|
||||
void Callback_PADLog(const TCHAR* _szMessage);
|
||||
|
||||
// For keyboard shortcuts.
|
||||
void Callback_KeyPress(int key, BOOL shift, BOOL control);
|
||||
|
||||
TPeekMessages Callback_PeekMessages = NULL;
|
||||
TUpdateFPSDisplay g_pUpdateFPSDisplay = NULL;
|
||||
|
||||
@ -270,6 +272,7 @@ THREAD_RETURN EmuThread(void *pArg)
|
||||
VideoInitialize.pCPFifo = (SCPFifoStruct*)&CommandProcessor::fifo;
|
||||
VideoInitialize.pUpdateInterrupts = &(CommandProcessor::UpdateInterruptsFromVideoPlugin);
|
||||
VideoInitialize.pMemoryBase = Memory::base;
|
||||
VideoInitialize.pKeyPress = Callback_KeyPress;
|
||||
PluginVideo::Video_Initialize(&VideoInitialize);
|
||||
|
||||
// Under linux, this is an X11 Display, not an HWND!
|
||||
@ -414,11 +417,11 @@ EState GetState()
|
||||
}
|
||||
|
||||
void SaveState() {
|
||||
State_Save("state.dlp");
|
||||
State_Save(0);
|
||||
}
|
||||
|
||||
void LoadState() {
|
||||
State_Load("state.dlp");
|
||||
State_Load(0);
|
||||
}
|
||||
|
||||
const SCoreStartupParameter& GetStartupParameter()
|
||||
@ -517,25 +520,6 @@ void Callback_DSPInterrupt()
|
||||
DSP::GenerateDSPInterruptFromPlugin(DSP::INT_DSP);
|
||||
}
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
// Callback_DVDLog
|
||||
//
|
||||
void Callback_DVDLog(TCHAR* _szMessage)
|
||||
{
|
||||
LOG(DVDINTERFACE, _szMessage);
|
||||
}
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
// Callback_DVDSetStatusbar
|
||||
//
|
||||
void Callback_DVDSetStatusbar(TCHAR* _szMessage)
|
||||
{
|
||||
//Todo: PostMessage to main window to set the string
|
||||
// strDVDMessage = _szMessage;
|
||||
// if (g_CoreStartupParameter.m_StatusUpdate != NULL)
|
||||
// g_CoreStartupParameter.m_StatusUpdate();
|
||||
}
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
// Callback_PADLog
|
||||
//
|
||||
@ -544,4 +528,20 @@ void Callback_PADLog(const TCHAR* _szMessage)
|
||||
LOG(SERIALINTERFACE, _szMessage);
|
||||
}
|
||||
|
||||
|
||||
// Called from ANY thread!
|
||||
void Callback_KeyPress(int key, BOOL shift, BOOL control)
|
||||
{
|
||||
// 0x70 == VK_F1
|
||||
if (key >= 0x70 && key < 0x79) {
|
||||
// F-key
|
||||
int slot_number = key - 0x70 + 1;
|
||||
if (shift) {
|
||||
State_Save(slot_number);
|
||||
} else {
|
||||
State_Load(slot_number);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // end of namespace Core
|
||||
|
@ -195,7 +195,8 @@ CSIDevice_GCController::SendCommand(u32 _Cmd)
|
||||
{
|
||||
unsigned int uType = command.Parameter1; // 0 = stop, 1 = rumble, 2 = stop hard
|
||||
unsigned int uStrength = command.Parameter2;
|
||||
PluginPAD::PAD_Rumble(ISIDevice::m_iDeviceNumber, uType, uStrength);
|
||||
if (PluginPAD::PAD_Rumble)
|
||||
PluginPAD::PAD_Rumble(ISIDevice::m_iDeviceNumber, uType, uStrength);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -37,8 +37,18 @@ static int ev_Load;
|
||||
|
||||
static std::string cur_filename;
|
||||
|
||||
enum {
|
||||
version = 1
|
||||
};
|
||||
|
||||
void DoState(PointerWrap &p)
|
||||
{
|
||||
u32 cookie = 0xBAADBABE + version;
|
||||
p.Do(cookie);
|
||||
if (cookie != 0xBAADBABE + version) {
|
||||
PanicAlert("Can't load states from other versions.");
|
||||
return;
|
||||
}
|
||||
// Begin with video plugin, so that it gets a chance to clear it's caches and writeback modified things to RAM
|
||||
PluginVideo::Video_DoState(p.GetPPtr(), p.GetMode());
|
||||
PluginDSP::DSP_DoState(p.GetPPtr(), p.GetMode());
|
||||
@ -50,7 +60,6 @@ void DoState(PointerWrap &p)
|
||||
void SaveStateCallback(u64 userdata, int cyclesLate)
|
||||
{
|
||||
Jit64::ClearCache();
|
||||
|
||||
u8 *ptr = 0;
|
||||
PointerWrap p(&ptr, PointerWrap::MODE_MEASURE);
|
||||
DoState(p);
|
||||
@ -65,14 +74,17 @@ void SaveStateCallback(u64 userdata, int cyclesLate)
|
||||
|
||||
delete [] buffer;
|
||||
|
||||
Core::DisplayMessage("Saved State", 2000);
|
||||
Core::DisplayMessage(StringFromFormat("Saved State to %s", cur_filename.c_str()).c_str(), 2000);
|
||||
}
|
||||
|
||||
void LoadStateCallback(u64 userdata, int cyclesLate)
|
||||
{
|
||||
Jit64::ClearCache();
|
||||
|
||||
FILE *f = fopen(cur_filename.c_str(), "rb");
|
||||
if (!f) {
|
||||
Core::DisplayMessage("State not found", 2000);
|
||||
return;
|
||||
}
|
||||
Jit64::ClearCache();
|
||||
fseek(f, 0, SEEK_END);
|
||||
int sz = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
@ -87,7 +99,7 @@ void LoadStateCallback(u64 userdata, int cyclesLate)
|
||||
DoState(p);
|
||||
delete [] buffer;
|
||||
|
||||
Core::DisplayMessage("Loaded State", 2000);
|
||||
Core::DisplayMessage(StringFromFormat("Loaded state from %s", cur_filename.c_str()).c_str(), 2000);
|
||||
}
|
||||
|
||||
void State_Init()
|
||||
@ -101,18 +113,18 @@ void State_Shutdown()
|
||||
// nothing to do, here for consistency.
|
||||
}
|
||||
|
||||
std::string GetStateFilename(int state_number) {
|
||||
std::string MakeStateFilename(int state_number) {
|
||||
return StringFromFormat("StateSaves/%s.s%02i", Core::GetStartupParameter().GetUniqueID().c_str(), state_number);
|
||||
}
|
||||
|
||||
void State_Save(const char *filename)
|
||||
void State_Save(int slot)
|
||||
{
|
||||
cur_filename = GetStateFilename(0);
|
||||
cur_filename = MakeStateFilename(slot);
|
||||
CoreTiming::ScheduleEvent_Threadsafe(0, ev_Save);
|
||||
}
|
||||
|
||||
void State_Load(const char *filename)
|
||||
void State_Load(int slot)
|
||||
{
|
||||
cur_filename = GetStateFilename(0);
|
||||
cur_filename = MakeStateFilename(slot);
|
||||
CoreTiming::ScheduleEvent_Threadsafe(0, ev_Load);
|
||||
}
|
||||
|
@ -22,7 +22,8 @@ void State_Init();
|
||||
void State_Shutdown();
|
||||
|
||||
// These don't happen instantly - they get scheduled as events.
|
||||
void State_Save(const char *filename);
|
||||
void State_Load(const char *filename);
|
||||
// Slots from 0-99.
|
||||
void State_Save(int slot);
|
||||
void State_Load(int slot);
|
||||
|
||||
#endif
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "Common.h"
|
||||
#include "Config.h"
|
||||
#include "Core.h"
|
||||
#include "State.h"
|
||||
#include "PluginOptions.h"
|
||||
#include "PluginManager.h"
|
||||
#include "MemcardManager.h"
|
||||
@ -95,8 +96,26 @@ EVT_MENU(IDM_MEMCARD, CFrame::OnMemcard)
|
||||
EVT_MENU(IDM_TOGGLE_FULLSCREEN, CFrame::OnToggleFullscreen)
|
||||
EVT_MENU(IDM_TOGGLE_DUALCORE, CFrame::OnToggleDualCore)
|
||||
EVT_MENU(IDM_TOGGLE_TOOLBAR, CFrame::OnToggleToolbar)
|
||||
EVT_MENU(IDM_LOADSTATE, CFrame::OnLoadState)
|
||||
EVT_MENU(IDM_SAVESTATE, CFrame::OnSaveState)
|
||||
EVT_MENU(IDM_LOADSLOT1, CFrame::OnLoadState)
|
||||
EVT_MENU(IDM_LOADSLOT2, CFrame::OnLoadState)
|
||||
EVT_MENU(IDM_LOADSLOT3, CFrame::OnLoadState)
|
||||
EVT_MENU(IDM_LOADSLOT4, CFrame::OnLoadState)
|
||||
EVT_MENU(IDM_LOADSLOT5, CFrame::OnLoadState)
|
||||
EVT_MENU(IDM_LOADSLOT6, CFrame::OnLoadState)
|
||||
EVT_MENU(IDM_LOADSLOT7, CFrame::OnLoadState)
|
||||
EVT_MENU(IDM_LOADSLOT8, CFrame::OnLoadState)
|
||||
EVT_MENU(IDM_LOADSLOT9, CFrame::OnLoadState)
|
||||
EVT_MENU(IDM_LOADSLOT10, CFrame::OnLoadState)
|
||||
EVT_MENU(IDM_SAVESLOT1, CFrame::OnSaveState)
|
||||
EVT_MENU(IDM_SAVESLOT2, CFrame::OnSaveState)
|
||||
EVT_MENU(IDM_SAVESLOT3, CFrame::OnSaveState)
|
||||
EVT_MENU(IDM_SAVESLOT4, CFrame::OnSaveState)
|
||||
EVT_MENU(IDM_SAVESLOT5, CFrame::OnSaveState)
|
||||
EVT_MENU(IDM_SAVESLOT6, CFrame::OnSaveState)
|
||||
EVT_MENU(IDM_SAVESLOT7, CFrame::OnSaveState)
|
||||
EVT_MENU(IDM_SAVESLOT8, CFrame::OnSaveState)
|
||||
EVT_MENU(IDM_SAVESLOT9, CFrame::OnSaveState)
|
||||
EVT_MENU(IDM_SAVESLOT10, CFrame::OnSaveState)
|
||||
EVT_HOST_COMMAND(wxID_ANY, CFrame::OnHostMessage)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
@ -167,32 +186,32 @@ void CFrame::CreateMenu()
|
||||
|
||||
// file menu
|
||||
wxMenu* fileMenu = new wxMenu;
|
||||
fileMenu->Append(wxID_OPEN, _T("&Open..."));
|
||||
fileMenu->Append(wxID_OPEN, _T("&Open...\tCtrl+O"));
|
||||
fileMenu->Append(wxID_REFRESH, _T("&Refresh"));
|
||||
fileMenu->Append(IDM_BROWSE, _T("&Browse for ISOs..."));
|
||||
|
||||
fileMenu->AppendSeparator();
|
||||
fileMenu->Append(wxID_EXIT, _T("E&xit"), _T(""));
|
||||
fileMenu->Append(wxID_EXIT, _T("E&xit"), _T("Alt+F4"));
|
||||
m_pMenuBar->Append(fileMenu, _T("&File"));
|
||||
|
||||
// emulation menu
|
||||
wxMenu* emulationMenu = new wxMenu;
|
||||
m_pMenuItemPlay = new wxMenuItem(fileMenu, IDM_PLAY, _T("&Play"));
|
||||
emulationMenu->Append(m_pMenuItemPlay);
|
||||
m_pMenuItemStop = new wxMenuItem(fileMenu, IDM_STOP, _T("&Stop"));
|
||||
emulationMenu->Append(m_pMenuItemStop);
|
||||
m_pMenuItemPlay = emulationMenu->Append(IDM_PLAY, _T("&Play"));
|
||||
m_pMenuItemStop = emulationMenu->Append(IDM_STOP, _T("&Stop"));
|
||||
emulationMenu->AppendSeparator();
|
||||
|
||||
m_pMenuItemLoad = new wxMenuItem(fileMenu, IDM_LOADSTATE, _T("&Load State"));
|
||||
emulationMenu->Append(m_pMenuItemLoad);
|
||||
m_pMenuItemSave = new wxMenuItem(fileMenu, IDM_SAVESTATE, _T("Sa&ve State"));
|
||||
emulationMenu->Append(m_pMenuItemSave);
|
||||
wxMenu *saveMenu = new wxMenu;
|
||||
wxMenu *loadMenu = new wxMenu;
|
||||
m_pMenuItemLoad = emulationMenu->AppendSubMenu(saveMenu, _T("&Load State"));
|
||||
m_pMenuItemSave = emulationMenu->AppendSubMenu(loadMenu, _T("Sa&ve State"));
|
||||
for (int i = 1; i < 10; i++) {
|
||||
saveMenu->Append(IDM_LOADSLOT1 + i - 1, wxString::Format(_T("Slot %i F%i"), i, i));
|
||||
loadMenu->Append(IDM_SAVESLOT1 + i - 1, wxString::Format(_T("Slot %i Shift+F%i"), i, i));
|
||||
}
|
||||
m_pMenuBar->Append(emulationMenu, _T("&Emulation"));
|
||||
|
||||
// options menu
|
||||
wxMenu* pOptionsMenu = new wxMenu;
|
||||
m_pPluginOptions = new wxMenuItem(pOptionsMenu, IDM_PLUGIN_OPTIONS, _T("&Select plugins"));
|
||||
pOptionsMenu->Append(m_pPluginOptions);
|
||||
m_pPluginOptions = pOptionsMenu->Append(IDM_PLUGIN_OPTIONS, _T("&Select plugins"));
|
||||
pOptionsMenu->AppendSeparator();
|
||||
pOptionsMenu->Append(IDM_CONFIG_GFX_PLUGIN, _T("&GFX settings"));
|
||||
pOptionsMenu->Append(IDM_CONFIG_DSP_PLUGIN, _T("&DSP settings"));
|
||||
@ -501,14 +520,18 @@ void CFrame::OnToggleDualCore(wxCommandEvent& WXUNUSED (event))
|
||||
SConfig::GetInstance().SaveSettings();
|
||||
}
|
||||
|
||||
void CFrame::OnLoadState(wxCommandEvent& WXUNUSED (event))
|
||||
void CFrame::OnLoadState(wxCommandEvent& event)
|
||||
{
|
||||
Core::LoadState();
|
||||
int id = event.GetId();
|
||||
int slot = id - IDM_LOADSLOT1 + 1;
|
||||
State_Load(slot);
|
||||
}
|
||||
|
||||
void CFrame::OnSaveState(wxCommandEvent& WXUNUSED (event))
|
||||
void CFrame::OnSaveState(wxCommandEvent& event)
|
||||
{
|
||||
Core::SaveState();
|
||||
int id = event.GetId();
|
||||
int slot = id - IDM_SAVESLOT1 + 1;
|
||||
State_Save(slot);
|
||||
}
|
||||
|
||||
void CFrame::OnToggleToolbar(wxCommandEvent& event)
|
||||
|
@ -22,6 +22,26 @@ enum
|
||||
{
|
||||
IDM_LOADSTATE = 200,
|
||||
IDM_SAVESTATE,
|
||||
IDM_SAVESLOT1,
|
||||
IDM_SAVESLOT2,
|
||||
IDM_SAVESLOT3,
|
||||
IDM_SAVESLOT4,
|
||||
IDM_SAVESLOT5,
|
||||
IDM_SAVESLOT6,
|
||||
IDM_SAVESLOT7,
|
||||
IDM_SAVESLOT8,
|
||||
IDM_SAVESLOT9,
|
||||
IDM_SAVESLOT10,
|
||||
IDM_LOADSLOT1,
|
||||
IDM_LOADSLOT2,
|
||||
IDM_LOADSLOT3,
|
||||
IDM_LOADSLOT4,
|
||||
IDM_LOADSLOT5,
|
||||
IDM_LOADSLOT6,
|
||||
IDM_LOADSLOT7,
|
||||
IDM_LOADSLOT8,
|
||||
IDM_LOADSLOT9,
|
||||
IDM_LOADSLOT10,
|
||||
IDM_PLAY,
|
||||
IDM_STOP,
|
||||
IDM_BROWSE,
|
||||
|
@ -9,6 +9,7 @@ files = [
|
||||
"XFBConvert.cpp",
|
||||
"Fifo.cpp",
|
||||
"VideoState.cpp",
|
||||
"Profiler.cpp",
|
||||
]
|
||||
|
||||
env_common = env.Copy()
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8,00"
|
||||
Version="8.00"
|
||||
Name="VideoCommon"
|
||||
ProjectGUID="{E5D1F0C0-AA07-4841-A4EB-4CF4DAA6B0FA}"
|
||||
RootNamespace="VideoCommon"
|
||||
@ -437,6 +437,14 @@
|
||||
RelativePath=".\Src\OpcodeDecoding.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Profiler.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Profiler.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\SConscript"
|
||||
>
|
||||
|
Reference in New Issue
Block a user