From 051c2e078482dce968a2c990618c6e5b78c9c695 Mon Sep 17 00:00:00 2001 From: "XTra.KrazzY" Date: Thu, 28 Aug 2008 07:58:04 +0000 Subject: [PATCH] A lot of save state groundwork. Please notify if compilation breaks because I haven't compiled git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@368 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/Core.cpp | 6 ++-- Source/Core/Core/Src/Plugins/Plugin_Video.cpp | 27 +++++---------- Source/Core/Core/Src/Plugins/Plugin_Video.h | 5 +-- Source/Core/Core/Src/State.cpp | 5 +-- Source/Core/Core/Src/State.h | 4 +-- Source/Core/VideoCommon/Src/VideoState.cpp | 34 +++++++++++++++---- Source/Core/VideoCommon/Src/VideoState.h | 4 +-- Source/PluginSpecs/pluginspecs_video.h | 14 ++------ Source/Plugins/Plugin_VideoDX9/Src/main.cpp | 11 ++---- Source/Plugins/Plugin_VideoOGL/Src/main.cpp | 11 ++---- 10 files changed, 60 insertions(+), 61 deletions(-) diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 8b1729efbe..516ad809c3 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -55,6 +55,8 @@ #include "Host.h" #include "LogManager.h" +#include "State.h" + #ifndef _WIN32 #define WINAPI #endif @@ -411,11 +413,11 @@ EState GetState() } void SaveState() { - PluginVideo::Video_SaveState(); + State_Save("state.dlp"); } void LoadState() { - PluginVideo::Video_LoadState(); + State_Load("state.dlp"); } const SCoreStartupParameter& GetStartupParameter() diff --git a/Source/Core/Core/Src/Plugins/Plugin_Video.cpp b/Source/Core/Core/Src/Plugins/Plugin_Video.cpp index 7d9e6a60e1..42d12e875c 100644 --- a/Source/Core/Core/Src/Plugins/Plugin_Video.cpp +++ b/Source/Core/Core/Src/Plugins/Plugin_Video.cpp @@ -35,8 +35,7 @@ typedef void (__cdecl* TVideo_EnterLoop)(); typedef void (__cdecl* TVideo_AddMessage)(const char* pstr, unsigned int milliseconds); -typedef void (__cdecl* TVideo_SaveState)(); -typedef void (__cdecl* TVideo_LoadState)(); +typedef void (__cdecl* TVideo_DoState)(ChunkFile &f); //! Function Pointer TGetDllInfo g_GetDllInfo = 0; @@ -50,8 +49,7 @@ TVideo_UpdateXFB g_Video_UpdateXFB = 0; TVideo_Screenshot g_Video_Screenshot = 0; TVideo_EnterLoop g_Video_EnterLoop = 0; TVideo_AddMessage g_Video_AddMessage = 0; -TVideo_SaveState g_Video_SaveState = 0; -TVideo_LoadState g_Video_LoadState = 0; +TVideo_DoState g_Video_DoState = 0; //! Library Instance DynamicLibrary plugin; @@ -72,11 +70,10 @@ void UnloadPlugin() g_Video_Shutdown = 0; g_Video_SendFifoData = 0; g_Video_UpdateXFB = 0; - g_Video_AddMessage = 0; - g_Video_SaveState = 0; - g_Video_LoadState = 0; + g_Video_AddMessage = 0; + g_Video_DoState = 0; - plugin.Unload(); + plugin.Unload(); } bool LoadPlugin(const char *_Filename) @@ -94,8 +91,7 @@ bool LoadPlugin(const char *_Filename) g_Video_Screenshot = reinterpret_cast (plugin.Get("Video_Screenshot")); g_Video_EnterLoop = reinterpret_cast (plugin.Get("Video_EnterLoop")); g_Video_AddMessage = reinterpret_cast (plugin.Get("Video_AddMessage")); - g_Video_SaveState = reinterpret_cast (plugin.Get("Video_SaveState")); - g_Video_LoadState = reinterpret_cast (plugin.Get("Video_LoadState")); + g_Video_DoState = reinterpret_cast (plugin.Get("Video_DoState")); if ((g_GetDllInfo != 0) && (g_DllAbout != 0) && @@ -108,8 +104,7 @@ bool LoadPlugin(const char *_Filename) (g_Video_EnterLoop != 0) && (g_Video_Screenshot != 0) && (g_Video_AddMessage != 0) && - (g_Video_SaveState != 0) && - (g_Video_LoadState != 0) ) + (g_Video_DoState != 0) ) { return true; } @@ -181,12 +176,8 @@ void Video_AddMessage(const char* pstr, unsigned int milliseconds) g_Video_AddMessage(pstr,milliseconds); } -void Video_SaveState() { - g_Video_SaveState(); -} - -void Video_LoadState() { - g_Video_LoadState(); +void Video_DoState(ChunkFile &f) { + g_Video_DoState(f); } } // end of namespace PluginVideo diff --git a/Source/Core/Core/Src/Plugins/Plugin_Video.h b/Source/Core/Core/Src/Plugins/Plugin_Video.h index 9ca087736b..607fd476fd 100644 --- a/Source/Core/Core/Src/Plugins/Plugin_Video.h +++ b/Source/Core/Core/Src/Plugins/Plugin_Video.h @@ -20,6 +20,8 @@ #include "pluginspecs_video.h" +#include "ChunkFile.h" + namespace PluginVideo { bool IsLoaded(); @@ -42,8 +44,7 @@ void Video_UpdateXFB(BYTE* _pXFB, DWORD _dwHeight, DWORD _dwWidth); bool Video_Screenshot(TCHAR* _szFilename); void Video_AddMessage(const char* pstr, unsigned int milliseconds); -void Video_SaveState(); -void Video_LoadState(); +void Video_DoState(ChunkFile &f); } // end of namespace PluginVideo diff --git a/Source/Core/Core/Src/State.cpp b/Source/Core/Core/Src/State.cpp index 09fd6364e6..89ff3a4f18 100644 --- a/Source/Core/Core/Src/State.cpp +++ b/Source/Core/Core/Src/State.cpp @@ -17,6 +17,7 @@ void DoState(ChunkFile &f) f.Descend("DOLP"); PowerPC::DoState(f); HW::DoState(f); + PluginVideo::Video_DoState(f); f.Ascend(); } @@ -43,13 +44,13 @@ void State_Shutdown() // nothing to do, here for consistency. } -void SaveState(const char *filename) +void State_Save(const char *filename) { cur_filename = filename; CoreTiming::ScheduleEvent_Threadsafe(0, ev_Save); } -void LoadState(const char *filename) +void State_Load(const char *filename) { cur_filename = filename; CoreTiming::ScheduleEvent_Threadsafe(0, ev_Load); diff --git a/Source/Core/Core/Src/State.h b/Source/Core/Core/Src/State.h index 5fe743d5e1..2fd5fe091a 100644 --- a/Source/Core/Core/Src/State.h +++ b/Source/Core/Core/Src/State.h @@ -6,7 +6,7 @@ void State_Init(); void State_Shutdown(); -void State_Save(); -void State_Load(); +void State_Save(const char *filename); +void State_Load(const char *filename); #endif diff --git a/Source/Core/VideoCommon/Src/VideoState.cpp b/Source/Core/VideoCommon/Src/VideoState.cpp index ded7f6fb03..0f9b959c4c 100644 --- a/Source/Core/VideoCommon/Src/VideoState.cpp +++ b/Source/Core/VideoCommon/Src/VideoState.cpp @@ -18,12 +18,34 @@ #include "VideoState.h" #include "TextureDecoder.h" -void VideoCommon_SaveState() { - //PanicAlert("Saving state from Video Common Library"); - //TODO: Save the video state +void DoState(ChunkFile &f) { + // BP Memory + f.Do(bpmem); + // CP Memory + f.Do(arraybases); + f.Do(arraystrides); + f.Do(MatrixIndexA); + f.Do(MatrixIndexB); + // XF Memory + f.Do(xfregs); + f.Do(xfmem); + // Texture decoder + f.Do(texMem); + + // FIFO + f.Do(size); + f.DoArray(videoBuffer, sizeof(u8), size); + + f.Do(readptr); + + //TODO: Check for more pointers in the data structures and make them + // serializable } -void VideoCommon_LoadState() { - //PanicAlert("Loading state from Video Common Library"); - //TODO: Load the video state +void VideoCommon_DoState(ChunkFile &f) { + //PanicAlert("Saving state from Video Common Library"); + //TODO: Save the video state + f.Descend("VID "); + f.DoState(f); + f.Ascend(); } diff --git a/Source/Core/VideoCommon/Src/VideoState.h b/Source/Core/VideoCommon/Src/VideoState.h index f3e985e655..0dd1d334ac 100644 --- a/Source/Core/VideoCommon/Src/VideoState.h +++ b/Source/Core/VideoCommon/Src/VideoState.h @@ -19,8 +19,8 @@ #define __VIDEOSTATE_H #include "Common.h" +#include "ChunkFile.h" -void VideoCommon_SaveState(); -void VideoCommon_LoadState(); +void VideoCommon_DoState(ChunkFile &f); #endif diff --git a/Source/PluginSpecs/pluginspecs_video.h b/Source/PluginSpecs/pluginspecs_video.h index f45c9c9bfc..92bed5d527 100644 --- a/Source/PluginSpecs/pluginspecs_video.h +++ b/Source/PluginSpecs/pluginspecs_video.h @@ -168,20 +168,12 @@ EXPORT void CALL Video_EnterLoop(void); EXPORT void CALL Video_AddMessage(const char* pstr, unsigned int milliseconds); // __________________________________________________________________________________________________ -// Function: Video_SaveState -// Purpose: Saves the current video data state +// Function: Video_DoState +// Purpose: Saves/Loads the current video data state(depends on parameter) // input: The chunkfile to write to? FIXME // output: none // -EXPORT void CALL Video_SaveState(void); - -// __________________________________________________________________________________________________ -// Function: Video_LoadState -// Purpose: Loads the current video data state -// input: The chunkfile to read from? FIXME -// output: none -// -EXPORT void CALL Video_LoadState(void); +EXPORT void CALL Video_DoState(ChunkFile &f); #include "ExportEpilog.h" #endif diff --git a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp index 453902a3d9..d87ec87ac1 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp @@ -166,14 +166,9 @@ void Video_Initialize(SVideoInitialize* _pVideoInitialize) } -void Video_SaveState(void) { - VideoCommon_SaveState(); - //PanicAlert("Saving state from DirectX9"); -} - -void Video_LoadState(void) { - VideoCommon_LoadState(); - //PanicAlert("Loading state from DirectX9"); +void Video_DoState(ChunkFile &f) { + VideoCommon_DoState(f); + //PanicAlert("Saving/Loading state from DirectX9"); } void Video_EnterLoop() diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index 033c8e944a..cb7bf88818 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -179,14 +179,9 @@ void Video_Initialize(SVideoInitialize* _pVideoInitialize) } -void Video_SaveState(void) { - VideoCommon_SaveState(); - //PanicAlert("Saving state from OpenGL"); -} - -void Video_LoadState(void) { - VideoCommon_LoadState(); - //PanicAlert("Loading state from OpenGL"); +void Video_DoState(ChunkFile &f) { + VideoCommon_DoState(f); + //PanicAlert("Saving/Loading state from OpenGL"); } void Video_Prepare(void)