mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Added save/load state support in the UI
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@375 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
1716ef46bb
commit
2e760d69fe
@ -39,6 +39,8 @@ ChunkFile::ChunkFile(const char *filename, ChunkFileMode _mode)
|
|||||||
fsize = ftell(f);
|
fsize = ftell(f);
|
||||||
eof = fsize;
|
eof = fsize;
|
||||||
|
|
||||||
|
fseek(f, 0, SEEK_SET);
|
||||||
|
|
||||||
stack_ptr = 0;
|
stack_ptr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,18 +71,19 @@ bool ChunkFile::Do(void *ptr, int size)
|
|||||||
if (sz != size)
|
if (sz != size)
|
||||||
return false;
|
return false;
|
||||||
fread(ptr, size, 1, f);
|
fread(ptr, size, 1, f);
|
||||||
fseek(f, ((size + 3) & ~3) - size, SEEK_CUR);
|
//fseek(f, ((size + 3) & ~3) - size, SEEK_CUR);
|
||||||
break;
|
break;
|
||||||
case MODE_WRITE:
|
case MODE_WRITE:
|
||||||
WriteInt(size);
|
WriteInt(size);
|
||||||
fwrite(ptr, size, 1, f);
|
fwrite(ptr, size, 1, f);
|
||||||
fseek(f, ((size + 3) & ~3) - size, SEEK_CUR);
|
//fseek(f, ((size + 3) & ~3) - size, SEEK_CUR);
|
||||||
break;
|
break;
|
||||||
case MODE_VERIFY:
|
case MODE_VERIFY:
|
||||||
sz = ReadInt();
|
sz = ReadInt();
|
||||||
if (sz != size)
|
if (sz != size)
|
||||||
return false;
|
return false;
|
||||||
fseek(f, (size + 3) & ~3, SEEK_CUR);
|
//fseek(f, (size + 3) & ~3, SEEK_CUR);
|
||||||
|
fseek(f, size, SEEK_CUR);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -102,18 +105,18 @@ bool ChunkFile::DoArray(void *ptr, int size, int arrSize) {
|
|||||||
if (sz != arrSize)
|
if (sz != arrSize)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
fread(ptr, arrSize * size, 1, f);
|
fread(ptr, size, arrSize, f);
|
||||||
fseek(f, (((arrSize * size) + 3) & ~3) - (arrSize * size),
|
//fseek(f, (((arrSize * size) + 3) & ~3) - (arrSize * size),
|
||||||
SEEK_CUR);
|
// SEEK_CUR);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MODE_WRITE:
|
case MODE_WRITE:
|
||||||
WriteInt(size);
|
WriteInt(size);
|
||||||
WriteInt(arrSize);
|
WriteInt(arrSize);
|
||||||
|
|
||||||
fwrite(ptr, arrSize * size, 1, f);
|
fwrite(ptr, size, arrSize, f);
|
||||||
fseek(f, (((arrSize * size) + 3) & ~3) - (arrSize * size),
|
//fseek(f, (((arrSize * size) + 3) & ~3) - (arrSize * size),
|
||||||
SEEK_CUR);
|
// SEEK_CUR);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MODE_VERIFY:
|
case MODE_VERIFY:
|
||||||
@ -124,8 +127,10 @@ bool ChunkFile::DoArray(void *ptr, int size, int arrSize) {
|
|||||||
if (sz != arrSize)
|
if (sz != arrSize)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for(int i = 0; i < arrSize; i++)
|
//for(int i = 0; i < arrSize; i++)
|
||||||
fseek(f, (size + 3) & ~3, SEEK_CUR);
|
//fseek(f, (size + 3) & ~3, SEEK_CUR);
|
||||||
|
|
||||||
|
fseek(f, arrSize * size, SEEK_CUR);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -134,6 +139,7 @@ bool ChunkFile::DoArray(void *ptr, int size, int arrSize) {
|
|||||||
//let's get into the business
|
//let's get into the business
|
||||||
bool ChunkFile::Descend(const char *cid)
|
bool ChunkFile::Descend(const char *cid)
|
||||||
{
|
{
|
||||||
|
return true;
|
||||||
unsigned int id = *reinterpret_cast<const unsigned int*>(cid);
|
unsigned int id = *reinterpret_cast<const unsigned int*>(cid);
|
||||||
if (mode == MODE_READ)
|
if (mode == MODE_READ)
|
||||||
{
|
{
|
||||||
@ -193,6 +199,7 @@ bool ChunkFile::Descend(const char *cid)
|
|||||||
//let's ascend out
|
//let's ascend out
|
||||||
void ChunkFile::Ascend()
|
void ChunkFile::Ascend()
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
if (mode == MODE_READ)
|
if (mode == MODE_READ)
|
||||||
{
|
{
|
||||||
//ascend, and restore information
|
//ascend, and restore information
|
||||||
|
@ -413,11 +413,15 @@ EState GetState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SaveState() {
|
void SaveState() {
|
||||||
|
CCPU::EnableStepping(true);
|
||||||
State_Save("state.dlp");
|
State_Save("state.dlp");
|
||||||
|
CCPU::EnableStepping(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadState() {
|
void LoadState() {
|
||||||
|
CCPU::EnableStepping(true);
|
||||||
State_Load("state.dlp");
|
State_Load("state.dlp");
|
||||||
|
CCPU::EnableStepping(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const SCoreStartupParameter& GetStartupParameter()
|
const SCoreStartupParameter& GetStartupParameter()
|
||||||
|
@ -95,6 +95,8 @@ EVT_MENU(IDM_MEMCARD, CFrame::OnMemcard)
|
|||||||
EVT_MENU(IDM_TOGGLE_FULLSCREEN, CFrame::OnToggleFullscreen)
|
EVT_MENU(IDM_TOGGLE_FULLSCREEN, CFrame::OnToggleFullscreen)
|
||||||
EVT_MENU(IDM_TOGGLE_DUALCORE, CFrame::OnToggleDualCore)
|
EVT_MENU(IDM_TOGGLE_DUALCORE, CFrame::OnToggleDualCore)
|
||||||
EVT_MENU(IDM_TOGGLE_TOOLBAR, CFrame::OnToggleToolbar)
|
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)
|
EVT_HOST_COMMAND(wxID_ANY, CFrame::OnHostMessage)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
@ -174,11 +176,13 @@ void CFrame::CreateMenu()
|
|||||||
m_pMenuItemStop = new wxMenuItem(fileMenu, IDM_STOP, _T("&Stop"));
|
m_pMenuItemStop = new wxMenuItem(fileMenu, IDM_STOP, _T("&Stop"));
|
||||||
fileMenu->Append(m_pMenuItemStop);
|
fileMenu->Append(m_pMenuItemStop);
|
||||||
|
|
||||||
/*fileMenu->AppendSeparator();
|
fileMenu->AppendSeparator();
|
||||||
wxMenuItem* LoadState = fileMenu->Append(IDM_LOADSTATE, _T("&Load State..."));
|
m_pMenuItemLoad = new wxMenuItem(fileMenu, IDM_LOADSTATE, _T("&Load State... (AKA Russian Roulette)"));
|
||||||
LoadState->Enable(false);
|
fileMenu->Append(m_pMenuItemLoad);
|
||||||
wxMenuItem* SaveState = fileMenu->Append(IDM_SAVESTATE, _T("&Save State..."));
|
m_pMenuItemLoad->Enable(false);
|
||||||
SaveState->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->AppendSeparator();
|
||||||
fileMenu->Append(wxID_EXIT, _T("E&xit"), _T(""));
|
fileMenu->Append(wxID_EXIT, _T("E&xit"), _T(""));
|
||||||
@ -496,6 +500,16 @@ void CFrame::OnToggleDualCore(wxCommandEvent& WXUNUSED (event))
|
|||||||
SConfig::GetInstance().SaveSettings();
|
SConfig::GetInstance().SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CFrame::OnLoadState(wxCommandEvent& WXUNUSED (event))
|
||||||
|
{
|
||||||
|
Core::LoadState();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CFrame::OnSaveState(wxCommandEvent& WXUNUSED (event))
|
||||||
|
{
|
||||||
|
Core::SaveState();
|
||||||
|
}
|
||||||
|
|
||||||
void CFrame::OnToggleToolbar(wxCommandEvent& event)
|
void CFrame::OnToggleToolbar(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
wxToolBarBase* toolBar = GetToolBar();
|
wxToolBarBase* toolBar = GetToolBar();
|
||||||
@ -539,6 +553,8 @@ void CFrame::UpdateGUI()
|
|||||||
|
|
||||||
m_pMenuItemPlay->Enable(false);
|
m_pMenuItemPlay->Enable(false);
|
||||||
m_pMenuItemStop->Enable(false);
|
m_pMenuItemStop->Enable(false);
|
||||||
|
m_pMenuItemLoad->Enable(false);
|
||||||
|
m_pMenuItemSave->Enable(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -550,6 +566,8 @@ void CFrame::UpdateGUI()
|
|||||||
|
|
||||||
m_pMenuItemPlay->Enable(true);
|
m_pMenuItemPlay->Enable(true);
|
||||||
m_pMenuItemStop->Enable(true);
|
m_pMenuItemStop->Enable(true);
|
||||||
|
m_pMenuItemLoad->Enable(true);
|
||||||
|
m_pMenuItemSave->Enable(true);
|
||||||
|
|
||||||
if (Core::GetState() == Core::CORE_RUN)
|
if (Core::GetState() == Core::CORE_RUN)
|
||||||
{
|
{
|
||||||
|
@ -69,6 +69,8 @@ class CFrame
|
|||||||
void OnToggleToolbar(wxCommandEvent& event);
|
void OnToggleToolbar(wxCommandEvent& event);
|
||||||
void OnKeyDown(wxKeyEvent& event);
|
void OnKeyDown(wxKeyEvent& event);
|
||||||
void OnHostMessage(wxCommandEvent& event);
|
void OnHostMessage(wxCommandEvent& event);
|
||||||
|
void OnLoadState(wxCommandEvent& event);
|
||||||
|
void OnSaveState(wxCommandEvent& event);
|
||||||
|
|
||||||
|
|
||||||
wxStatusBar* m_pStatusBar;
|
wxStatusBar* m_pStatusBar;
|
||||||
@ -78,6 +80,9 @@ class CFrame
|
|||||||
wxMenuItem* m_pMenuItemStop;
|
wxMenuItem* m_pMenuItemStop;
|
||||||
wxMenuItem* m_pPluginOptions;
|
wxMenuItem* m_pPluginOptions;
|
||||||
|
|
||||||
|
wxMenuItem* m_pMenuItemLoad;
|
||||||
|
wxMenuItem* m_pMenuItemSave;
|
||||||
|
|
||||||
wxBusyInfo* m_pBootProcessDialog;
|
wxBusyInfo* m_pBootProcessDialog;
|
||||||
|
|
||||||
void UpdateGUI();
|
void UpdateGUI();
|
||||||
|
@ -33,11 +33,14 @@ static void DoState(ChunkFile &f) {
|
|||||||
f.Do(MatrixIndexB);
|
f.Do(MatrixIndexB);
|
||||||
// XF Memory
|
// XF Memory
|
||||||
f.Do(xfregs);
|
f.Do(xfregs);
|
||||||
|
PanicAlert("video: XFMem");
|
||||||
f.Do(xfmem);
|
f.Do(xfmem);
|
||||||
|
PanicAlert("video: Texture decoder");
|
||||||
// Texture decoder
|
// Texture decoder
|
||||||
f.Do(texMem);
|
f.Do(texMem);
|
||||||
|
|
||||||
// FIFO
|
// FIFO
|
||||||
|
PanicAlert("video: FIFO");
|
||||||
Fifo_DoState(f);
|
Fifo_DoState(f);
|
||||||
|
|
||||||
//TODO: Check for more pointers in the data structures and make them
|
//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) {
|
void VideoCommon_DoState(ChunkFile &f) {
|
||||||
//PanicAlert("Saving state from Video Common Library");
|
PanicAlert("Saving state from Video Common Library");
|
||||||
//TODO: Save the video state
|
//TODO: Save the video state
|
||||||
f.Descend("VID ");
|
f.Descend("VID ");
|
||||||
DoState(f);
|
DoState(f);
|
||||||
f.Ascend();
|
f.Ascend();
|
||||||
|
PanicAlert("END save video");
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,28 @@
|
|||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|
||||||
const char *GenerateVertexShader();
|
const char *GenerateVertexShader(u32 components);
|
||||||
|
|
||||||
|
// shader variables
|
||||||
|
#define I_POSNORMALMATRIX "cpnmtx"
|
||||||
|
#define I_PROJECTION "cproj"
|
||||||
|
#define I_MATERIALS "cmtrl"
|
||||||
|
#define I_LIGHTS "clights"
|
||||||
|
#define I_TEXMATRICES "ctexmtx"
|
||||||
|
#define I_TRANSFORMMATRICES "ctrmtx"
|
||||||
|
#define I_NORMALMATRICES "cnmtx"
|
||||||
|
#define I_POSTTRANSFORMMATRICES "cpostmtx"
|
||||||
|
#define I_FOGPARAMS "cfog"
|
||||||
|
|
||||||
|
#define C_POSNORMALMATRIX 0
|
||||||
|
#define C_PROJECTION (C_POSNORMALMATRIX+6)
|
||||||
|
#define C_MATERIALS (C_PROJECTION+4)
|
||||||
|
#define C_LIGHTS (C_MATERIALS+4)
|
||||||
|
#define C_TEXMATRICES (C_LIGHTS+40)
|
||||||
|
#define C_TRANSFORMMATRICES (C_TEXMATRICES+24)
|
||||||
|
#define C_NORMALMATRICES (C_TRANSFORMMATRICES+64)
|
||||||
|
#define C_POSTTRANSFORMMATRICES (C_NORMALMATRICES+32)
|
||||||
|
#define C_FOGPARAMS (C_POSTTRANSFORMMATRICES+64)
|
||||||
|
|
||||||
#define PS_CONST_COLORS 0
|
#define PS_CONST_COLORS 0
|
||||||
#define PS_CONST_KCOLORS 4
|
#define PS_CONST_KCOLORS 4
|
||||||
|
Loading…
Reference in New Issue
Block a user