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(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"); } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexShader.h b/Source/Plugins/Plugin_VideoDX9/Src/VertexShader.h index 80a5f6b036..ff11939ebb 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexShader.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexShader.h @@ -3,7 +3,28 @@ #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_KCOLORS 4