summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorXTra.KrazzY <XTra.KrazzY@gmail.com>2008-08-28 21:30:13 +0000
committerXTra.KrazzY <XTra.KrazzY@gmail.com>2008-08-28 21:30:13 +0000
commit2e760d69fed99553e436d754c1fb315b3f33ecac (patch)
treec852f9c0f2a5129857548d1db59eebaefa509ccd /Source/Core
parent1716ef46bbfe9826014bb32293561b4c1174a181 (diff)
Added save/load state support in the UI
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@375 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Common/Src/ChunkFile.cpp29
-rw-r--r--Source/Core/Core/Src/Core.cpp4
-rw-r--r--Source/Core/DolphinWX/src/Frame.cpp28
-rw-r--r--Source/Core/DolphinWX/src/Frame.h5
-rw-r--r--Source/Core/VideoCommon/Src/VideoState.cpp6
5 files changed, 55 insertions, 17 deletions
diff --git a/Source/Core/Common/Src/ChunkFile.cpp b/Source/Core/Common/Src/ChunkFile.cpp
index 52e854d696..59827eb321 100644
--- a/Source/Core/Common/Src/ChunkFile.cpp
+++ b/Source/Core/Common/Src/ChunkFile.cpp
@@ -39,6 +39,8 @@ ChunkFile::ChunkFile(const char *filename, ChunkFileMode _mode)
fsize = ftell(f);
eof = fsize;
+ fseek(f, 0, SEEK_SET);
+
stack_ptr = 0;
}
@@ -69,18 +71,19 @@ bool ChunkFile::Do(void *ptr, int size)
if (sz != size)
return false;
fread(ptr, size, 1, f);
- fseek(f, ((size + 3) & ~3) - size, SEEK_CUR);
+ //fseek(f, ((size + 3) & ~3) - size, SEEK_CUR);
break;
case MODE_WRITE:
WriteInt(size);
fwrite(ptr, size, 1, f);
- fseek(f, ((size + 3) & ~3) - size, SEEK_CUR);
+ //fseek(f, ((size + 3) & ~3) - size, SEEK_CUR);
break;
case MODE_VERIFY:
sz = ReadInt();
if (sz != size)
return false;
- fseek(f, (size + 3) & ~3, SEEK_CUR);
+ //fseek(f, (size + 3) & ~3, SEEK_CUR);
+ fseek(f, size, SEEK_CUR);
break;
}
return true;
@@ -102,18 +105,18 @@ bool ChunkFile::DoArray(void *ptr, int size, int arrSize) {
if (sz != arrSize)
return false;
- fread(ptr, arrSize * size, 1, f);
- fseek(f, (((arrSize * size) + 3) & ~3) - (arrSize * size),
- SEEK_CUR);
+ fread(ptr, size, arrSize, f);
+ //fseek(f, (((arrSize * size) + 3) & ~3) - (arrSize * size),
+ // SEEK_CUR);
break;
case MODE_WRITE:
WriteInt(size);
WriteInt(arrSize);
- fwrite(ptr, arrSize * size, 1, f);
- fseek(f, (((arrSize * size) + 3) & ~3) - (arrSize * size),
- SEEK_CUR);
+ fwrite(ptr, size, arrSize, f);
+ //fseek(f, (((arrSize * size) + 3) & ~3) - (arrSize * size),
+ // SEEK_CUR);
break;
case MODE_VERIFY:
@@ -124,8 +127,10 @@ bool ChunkFile::DoArray(void *ptr, int size, int arrSize) {
if (sz != arrSize)
return false;
- for(int i = 0; i < arrSize; i++)
- fseek(f, (size + 3) & ~3, SEEK_CUR);
+ //for(int i = 0; i < arrSize; i++)
+ //fseek(f, (size + 3) & ~3, SEEK_CUR);
+
+ fseek(f, arrSize * size, SEEK_CUR);
break;
}
return true;
@@ -134,6 +139,7 @@ bool ChunkFile::DoArray(void *ptr, int size, int arrSize) {
//let's get into the business
bool ChunkFile::Descend(const char *cid)
{
+ return true;
unsigned int id = *reinterpret_cast<const unsigned int*>(cid);
if (mode == MODE_READ)
{
@@ -193,6 +199,7 @@ bool ChunkFile::Descend(const char *cid)
//let's ascend out
void ChunkFile::Ascend()
{
+ return;
if (mode == MODE_READ)
{
//ascend, and restore information
diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp
index 516ad809c3..f2ec671444 100644
--- a/Source/Core/Core/Src/Core.cpp
+++ b/Source/Core/Core/Src/Core.cpp
@@ -413,11 +413,15 @@ EState GetState()
}
void SaveState() {
+ CCPU::EnableStepping(true);
State_Save("state.dlp");
+ CCPU::EnableStepping(false);
}
void LoadState() {
+ CCPU::EnableStepping(true);
State_Load("state.dlp");
+ CCPU::EnableStepping(false);
}
const SCoreStartupParameter& GetStartupParameter()
diff --git a/Source/Core/DolphinWX/src/Frame.cpp b/Source/Core/DolphinWX/src/Frame.cpp
index c77f61009f..4f07c6d510 100644
--- a/Source/Core/DolphinWX/src/Frame.cpp
+++ b/Source/Core/DolphinWX/src/Frame.cpp
@@ -95,6 +95,8 @@ 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_HOST_COMMAND(wxID_ANY, CFrame::OnHostMessage)
END_EVENT_TABLE()
@@ -174,11 +176,13 @@ void CFrame::CreateMenu()
m_pMenuItemStop = new wxMenuItem(fileMenu, IDM_STOP, _T("&Stop"));
fileMenu->Append(m_pMenuItemStop);
- /*fileMenu->AppendSeparator();
- wxMenuItem* LoadState = fileMenu->Append(IDM_LOADSTATE, _T("&Load State..."));
- LoadState->Enable(false);
- wxMenuItem* SaveState = fileMenu->Append(IDM_SAVESTATE, _T("&Save State..."));
- SaveState->Enable(false);*/
+ fileMenu->AppendSeparator();
+ m_pMenuItemLoad = new wxMenuItem(fileMenu, IDM_LOADSTATE, _T("&Load State... (AKA Russian Roulette)"));
+ fileMenu->Append(m_pMenuItemLoad);
+ m_pMenuItemLoad->Enable(false);
+ m_pMenuItemSave = new wxMenuItem(fileMenu, IDM_SAVESTATE, _T("Sa&ve State... (Use at your own risk)"));
+ fileMenu->Append(m_pMenuItemSave);
+ m_pMenuItemSave->Enable(false);
fileMenu->AppendSeparator();
fileMenu->Append(wxID_EXIT, _T("E&xit"), _T(""));
@@ -496,6 +500,16 @@ void CFrame::OnToggleDualCore(wxCommandEvent& WXUNUSED (event))
SConfig::GetInstance().SaveSettings();
}
+void CFrame::OnLoadState(wxCommandEvent& WXUNUSED (event))
+{
+ Core::LoadState();
+}
+
+void CFrame::OnSaveState(wxCommandEvent& WXUNUSED (event))
+{
+ Core::SaveState();
+}
+
void CFrame::OnToggleToolbar(wxCommandEvent& event)
{
wxToolBarBase* toolBar = GetToolBar();
@@ -539,6 +553,8 @@ void CFrame::UpdateGUI()
m_pMenuItemPlay->Enable(false);
m_pMenuItemStop->Enable(false);
+ m_pMenuItemLoad->Enable(false);
+ m_pMenuItemSave->Enable(false);
}
else
{
@@ -550,6 +566,8 @@ void CFrame::UpdateGUI()
m_pMenuItemPlay->Enable(true);
m_pMenuItemStop->Enable(true);
+ m_pMenuItemLoad->Enable(true);
+ m_pMenuItemSave->Enable(true);
if (Core::GetState() == Core::CORE_RUN)
{
diff --git a/Source/Core/DolphinWX/src/Frame.h b/Source/Core/DolphinWX/src/Frame.h
index d31d389815..6b6b5d777d 100644
--- a/Source/Core/DolphinWX/src/Frame.h
+++ b/Source/Core/DolphinWX/src/Frame.h
@@ -69,6 +69,8 @@ class CFrame
void OnToggleToolbar(wxCommandEvent& event);
void OnKeyDown(wxKeyEvent& event);
void OnHostMessage(wxCommandEvent& event);
+ void OnLoadState(wxCommandEvent& event);
+ void OnSaveState(wxCommandEvent& event);
wxStatusBar* m_pStatusBar;
@@ -78,6 +80,9 @@ class CFrame
wxMenuItem* m_pMenuItemStop;
wxMenuItem* m_pPluginOptions;
+ wxMenuItem* m_pMenuItemLoad;
+ wxMenuItem* m_pMenuItemSave;
+
wxBusyInfo* m_pBootProcessDialog;
void UpdateGUI();
diff --git a/Source/Core/VideoCommon/Src/VideoState.cpp b/Source/Core/VideoCommon/Src/VideoState.cpp
index 0952f0d0eb..d0366e4bb4 100644
--- a/Source/Core/VideoCommon/Src/VideoState.cpp
+++ b/Source/Core/VideoCommon/Src/VideoState.cpp
@@ -33,11 +33,14 @@ static void DoState(ChunkFile &f) {
f.Do(MatrixIndexB);
// XF Memory
f.Do(xfregs);
+ PanicAlert("video: XFMem");
f.Do(xfmem);
+ PanicAlert("video: Texture decoder");
// Texture decoder
f.Do(texMem);
// FIFO
+ PanicAlert("video: FIFO");
Fifo_DoState(f);
//TODO: Check for more pointers in the data structures and make them
@@ -45,9 +48,10 @@ static void DoState(ChunkFile &f) {
}
void VideoCommon_DoState(ChunkFile &f) {
- //PanicAlert("Saving state from Video Common Library");
+ PanicAlert("Saving state from Video Common Library");
//TODO: Save the video state
f.Descend("VID ");
DoState(f);
f.Ascend();
+ PanicAlert("END save video");
}