mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
Eliminated memory leaks of the save state code and put it in a namespace. It is prettier than before, but it could be better (less global usage). Other minor stuff.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7366 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@@ -57,6 +57,7 @@
|
||||
#include "DSPEmulator.h"
|
||||
#include "ConfigManager.h"
|
||||
#include "VideoBackendBase.h"
|
||||
#include "OnScreenDisplay.h"
|
||||
|
||||
#include "VolumeHandler.h"
|
||||
#include "FileMonitor.h"
|
||||
@@ -200,6 +201,8 @@ bool Init()
|
||||
return false;
|
||||
}
|
||||
|
||||
OSD::AddMessage(("Dolphin " + g_video_backend->GetName() + " Video Backend.").c_str(), 5000);
|
||||
|
||||
HW::Init();
|
||||
if (!DSP::GetDSPEmulator()->Initialize(g_pWindowHandle,
|
||||
_CoreParameter.bWii, _CoreParameter.bDSPThread))
|
||||
@@ -321,7 +324,7 @@ void CpuThread()
|
||||
EMM::InstallExceptionHandler(); // Let's run under memory watch
|
||||
|
||||
if (!g_stateFileName.empty())
|
||||
State_LoadAs(g_stateFileName);
|
||||
State::LoadAs(g_stateFileName);
|
||||
|
||||
// Enter CPU run loop. When we leave it - we are done.
|
||||
CCPU::Run();
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace HW
|
||||
{
|
||||
CoreTiming::Init();
|
||||
|
||||
State_Init();
|
||||
State::Init();
|
||||
|
||||
// Init the whole Hardware
|
||||
AudioInterface::Init();
|
||||
@@ -82,7 +82,7 @@ namespace HW
|
||||
WII_IPC_HLE_Interface::Shutdown();
|
||||
}
|
||||
|
||||
State_Shutdown();
|
||||
State::Shutdown();
|
||||
CoreTiming::Shutdown();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <regex>
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbt.h>
|
||||
@@ -406,6 +407,9 @@ int UnPair()
|
||||
// negative number on failure
|
||||
int PairUp(bool unpair)
|
||||
{
|
||||
// match strings like "Nintendo RVL-WBC-01", "Nintendo RVL-CNT-01"
|
||||
const std::wregex wiimote_device_name(L"Nintendo RVL-\\w{3}-\\d{2}");
|
||||
|
||||
int nPaired = 0;
|
||||
|
||||
BLUETOOTH_DEVICE_SEARCH_PARAMS srch;
|
||||
@@ -451,9 +455,7 @@ int PairUp(bool unpair)
|
||||
DEBUG_LOG(WIIMOTE, "authed %i connected %i remembered %i ",
|
||||
btdi.fAuthenticated, btdi.fConnected, btdi.fRemembered);
|
||||
|
||||
// TODO: Probably could just check for "Nintendo RVL"
|
||||
if (0 == wcscmp(btdi.szName, L"Nintendo RVL-WBC-01") ||
|
||||
0 == wcscmp(btdi.szName, L"Nintendo RVL-CNT-01"))
|
||||
if (std::regex_match(btdi.szName, wiimote_device_name))
|
||||
{
|
||||
if (unpair)
|
||||
{
|
||||
|
||||
@@ -205,7 +205,7 @@ bool BeginRecordingInput(int controllers)
|
||||
const std::string stateFilename = g_recordFile + ".sav";
|
||||
if(File::Exists(stateFilename))
|
||||
File::Delete(stateFilename);
|
||||
State_SaveAs(stateFilename.c_str());
|
||||
State::SaveAs(stateFilename.c_str());
|
||||
g_bRecordingFromSaveState = true;
|
||||
}
|
||||
|
||||
|
||||
+210
-327
File diff suppressed because it is too large
Load Diff
@@ -22,44 +22,37 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
typedef struct
|
||||
namespace State
|
||||
{
|
||||
u8 *buffer;
|
||||
size_t size;
|
||||
} saveStruct;
|
||||
|
||||
void State_Init();
|
||||
void State_Shutdown();
|
||||
void Init();
|
||||
void Shutdown();
|
||||
|
||||
void EnableCompression(bool compression);
|
||||
|
||||
// These don't happen instantly - they get scheduled as events.
|
||||
// ...But only if we're not in the main cpu thread.
|
||||
// If we're in the main cpu thread then they run immediately instead
|
||||
// because some things (like Lua) need them to run immediately.
|
||||
// Slots from 0-99.
|
||||
void State_Save(int slot);
|
||||
void State_Load(int slot);
|
||||
void State_Verify(int slot);
|
||||
void Save(int slot);
|
||||
void Load(int slot);
|
||||
void Verify(int slot);
|
||||
|
||||
void State_SaveAs(const std::string &filename);
|
||||
void State_LoadAs(const std::string &filename);
|
||||
void State_VerifyAt(const std::string &filename);
|
||||
void SaveAs(const std::string &filename);
|
||||
void LoadAs(const std::string &filename);
|
||||
void VerifyAt(const std::string &filename);
|
||||
|
||||
void State_LoadFromBuffer(u8 **buffer);
|
||||
void State_SaveToBuffer(u8 **buffer);
|
||||
void State_VerifyBuffer(u8 **buffer);
|
||||
void SaveToBuffer(u8 **buffer);
|
||||
void LoadFromBuffer(u8 **buffer);
|
||||
void VerifyBuffer(u8 **buffer);
|
||||
|
||||
void State_LoadLastSaved();
|
||||
void State_UndoSaveState();
|
||||
void State_UndoLoadState();
|
||||
void LoadLastSaved();
|
||||
void UndoSaveState();
|
||||
void UndoLoadState();
|
||||
|
||||
size_t State_GetSize();
|
||||
void State_Flush(); // wait until previously scheduled savestate event (if any) is done
|
||||
void Flush(); // wait until previously scheduled savestate event (if any) is done
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u8 gameID[6];
|
||||
size_t sz;
|
||||
} state_header;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -885,20 +885,20 @@ void CFrame::OnKeyDown(wxKeyEvent& event)
|
||||
{
|
||||
int slot_number = event.GetKeyCode() - WXK_F1 + 1;
|
||||
if (event.GetModifiers() == wxMOD_NONE)
|
||||
State_Load(slot_number);
|
||||
State::Load(slot_number);
|
||||
else if (event.GetModifiers() == wxMOD_SHIFT)
|
||||
State_Save(slot_number);
|
||||
State::Save(slot_number);
|
||||
else
|
||||
event.Skip();
|
||||
}*/
|
||||
else if (event.GetKeyCode() == WXK_F11 && event.GetModifiers() == wxMOD_NONE)
|
||||
State_LoadLastSaved();
|
||||
State::LoadLastSaved();
|
||||
else if (event.GetKeyCode() == WXK_F12)
|
||||
{
|
||||
if (event.GetModifiers() == wxMOD_NONE)
|
||||
State_UndoSaveState();
|
||||
State::UndoSaveState();
|
||||
else if (event.GetModifiers() == wxMOD_SHIFT)
|
||||
State_UndoLoadState();
|
||||
State::UndoLoadState();
|
||||
else
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
@@ -1401,8 +1401,8 @@ void CFrame::OnLoadStateFromFile(wxCommandEvent& WXUNUSED (event))
|
||||
wxFD_OPEN | wxFD_PREVIEW | wxFD_FILE_MUST_EXIST,
|
||||
this);
|
||||
|
||||
if(!path.IsEmpty())
|
||||
State_LoadAs((const char*)path.mb_str());
|
||||
if (!path.IsEmpty())
|
||||
State::LoadAs((const char*)path.mb_str());
|
||||
}
|
||||
|
||||
void CFrame::OnSaveStateToFile(wxCommandEvent& WXUNUSED (event))
|
||||
@@ -1415,23 +1415,23 @@ void CFrame::OnSaveStateToFile(wxCommandEvent& WXUNUSED (event))
|
||||
wxFD_SAVE,
|
||||
this);
|
||||
|
||||
if(! path.IsEmpty())
|
||||
State_SaveAs((const char*)path.mb_str());
|
||||
if (!path.IsEmpty())
|
||||
State::SaveAs((const char*)path.mb_str());
|
||||
}
|
||||
|
||||
void CFrame::OnLoadLastState(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
State_LoadLastSaved();
|
||||
State::LoadLastSaved();
|
||||
}
|
||||
|
||||
void CFrame::OnUndoLoadState(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
State_UndoLoadState();
|
||||
State::UndoLoadState();
|
||||
}
|
||||
|
||||
void CFrame::OnUndoSaveState(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
State_UndoSaveState();
|
||||
State::UndoSaveState();
|
||||
}
|
||||
|
||||
|
||||
@@ -1439,14 +1439,14 @@ void CFrame::OnLoadState(wxCommandEvent& event)
|
||||
{
|
||||
int id = event.GetId();
|
||||
int slot = id - IDM_LOADSLOT1 + 1;
|
||||
State_Load(slot);
|
||||
State::Load(slot);
|
||||
}
|
||||
|
||||
void CFrame::OnSaveState(wxCommandEvent& event)
|
||||
{
|
||||
int id = event.GetId();
|
||||
int slot = id - IDM_SAVESLOT1 + 1;
|
||||
State_Save(slot);
|
||||
State::Save(slot);
|
||||
}
|
||||
|
||||
void CFrame::OnFrameSkip(wxCommandEvent& event)
|
||||
|
||||
@@ -214,20 +214,20 @@ void X11_MainLoop()
|
||||
{
|
||||
int slot_number = key - XK_F1 + 1;
|
||||
if (event.xkey.state & ShiftMask)
|
||||
State_Save(slot_number);
|
||||
State::Save(slot_number);
|
||||
else
|
||||
State_Load(slot_number);
|
||||
State::Load(slot_number);
|
||||
}
|
||||
else if (key == XK_F9)
|
||||
Core::SaveScreenShot();
|
||||
else if (key == XK_F11)
|
||||
State_LoadLastSaved();
|
||||
State::LoadLastSaved();
|
||||
else if (key == XK_F12)
|
||||
{
|
||||
if (event.xkey.state & ShiftMask)
|
||||
State_UndoLoadState();
|
||||
State::UndoLoadState();
|
||||
else
|
||||
State_UndoSaveState();
|
||||
State::UndoSaveState();
|
||||
}
|
||||
break;
|
||||
case FocusIn:
|
||||
|
||||
@@ -270,7 +270,6 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
|
||||
// - EFB
|
||||
// EFB scale
|
||||
wxBoxSizer* const efb_scale_szr = new wxBoxSizer(wxHORIZONTAL);
|
||||
// TODO: give this a label (?)
|
||||
const wxString efbscale_choices[] = { _("Fractional"), _("Integral [recommended]"),
|
||||
wxT("1x"), wxT("2x"), wxT("3x"), wxT("0.75x"), wxT("0.5x"), wxT("0.375x") };
|
||||
|
||||
|
||||
@@ -171,7 +171,6 @@ bool VideoBackend::Initialize(void *&window_handle)
|
||||
return false;
|
||||
}
|
||||
|
||||
OSD::AddMessage("Dolphin Direct3D11 Video Backend.", 5000);
|
||||
s_BackendInitialized = true;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -156,7 +156,6 @@ bool VideoBackend::Initialize(void *&window_handle)
|
||||
return false;
|
||||
}
|
||||
|
||||
OSD::AddMessage("Dolphin Direct3D9 Video Backend.", 5000);
|
||||
s_BackendInitialized = true;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -173,7 +173,6 @@ bool VideoBackend::Initialize(void *&window_handle)
|
||||
if (!OpenGL_Create(window_handle))
|
||||
return false;
|
||||
|
||||
OSD::AddMessage("Dolphin OpenGL Video Backend.", 5000);
|
||||
s_BackendInitialized = true;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -178,17 +178,12 @@ void VideoSoftware::Video_EnterLoop()
|
||||
Common::YieldCPU();
|
||||
}
|
||||
|
||||
if (!emuRunningState)
|
||||
while (!emuRunningState && fifoStateRun)
|
||||
{
|
||||
while (!emuRunningState && fifoStateRun)
|
||||
{
|
||||
g_video_backend->PeekMessages();
|
||||
Common::SleepCurrentThread(1);
|
||||
}
|
||||
g_video_backend->PeekMessages();
|
||||
Common::SleepCurrentThread(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void VideoSoftware::Video_ExitLoop()
|
||||
|
||||
Reference in New Issue
Block a user