From 7a2cdef9124864fe5ca3a09ceb89883f26d3c5d1 Mon Sep 17 00:00:00 2001 From: "XTra.KrazzY" Date: Tue, 26 Aug 2008 23:40:18 +0000 Subject: [PATCH] Preliminary video save state support. More work is necessary, this is just some infrastructure for inter-project communication. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@332 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/Core.cpp | 8 +++++ Source/Core/Core/Src/Core.h | 4 +++ Source/Core/Core/Src/Plugins/Plugin_Video.cpp | 20 +++++++++++- Source/Core/Core/Src/Plugins/Plugin_Video.h | 3 ++ Source/Core/VideoCommon/Src/SConscript | 1 + Source/Core/VideoCommon/Src/VideoState.cpp | 31 +++++++++++++++++++ Source/Core/VideoCommon/Src/VideoState.h | 26 ++++++++++++++++ Source/PluginSpecs/pluginspecs_video.h | 16 ++++++++++ Source/Plugins/Plugin_VideoDX9/Src/main.cpp | 15 +++++++++ Source/Plugins/Plugin_VideoOGL/Src/main.cpp | 15 +++++++++ 10 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 Source/Core/VideoCommon/Src/VideoState.cpp create mode 100644 Source/Core/VideoCommon/Src/VideoState.h diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 61a5a244e5..8b1729efbe 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -410,6 +410,14 @@ EState GetState() return CORE_UNINITIALIZED; } +void SaveState() { + PluginVideo::Video_SaveState(); +} + +void LoadState() { + PluginVideo::Video_LoadState(); +} + const SCoreStartupParameter& GetStartupParameter() { return g_CoreStartupParameter; diff --git a/Source/Core/Core/Src/Core.h b/Source/Core/Core/Src/Core.h index a8ea7ac88d..d4ab0da840 100644 --- a/Source/Core/Core/Src/Core.h +++ b/Source/Core/Core/Src/Core.h @@ -42,6 +42,10 @@ namespace Core // Get state EState GetState(); + // Save/Load state + void SaveState(); + void LoadState(); + // get core parameters extern SCoreStartupParameter g_CoreStartupParameter; //uck const SCoreStartupParameter& GetStartupParameter(); diff --git a/Source/Core/Core/Src/Plugins/Plugin_Video.cpp b/Source/Core/Core/Src/Plugins/Plugin_Video.cpp index 01d4f3fae9..9744e289b3 100644 --- a/Source/Core/Core/Src/Plugins/Plugin_Video.cpp +++ b/Source/Core/Core/Src/Plugins/Plugin_Video.cpp @@ -35,6 +35,8 @@ 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)(); //! Function Pointer TGetDllInfo g_GetDllInfo = 0; @@ -48,6 +50,8 @@ 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; //! Library Instance DynamicLibrary plugin; @@ -69,6 +73,8 @@ void UnloadPlugin() g_Video_SendFifoData = 0; g_Video_UpdateXFB = 0; g_Video_AddMessage = 0; + g_Video_SaveState = 0; + g_Video_LoadState = 0; plugin.Unload(); } @@ -88,6 +94,8 @@ 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")); if ((g_GetDllInfo != 0) && (g_DllAbout != 0) && @@ -99,7 +107,9 @@ bool LoadPlugin(const char *_Filename) (g_Video_UpdateXFB != 0) && (g_Video_EnterLoop != 0) && (g_Video_Screenshot != 0) && - (g_Video_AddMessage != 0)) + (g_Video_AddMessage != 0) && + (g_Video_SaveState != 0) && + (g_Video_LoadState != 0)) { return true; } @@ -171,4 +181,12 @@ 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_SaveState(); +} + } // 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 3c8f9f5c64..9ca087736b 100644 --- a/Source/Core/Core/Src/Plugins/Plugin_Video.h +++ b/Source/Core/Core/Src/Plugins/Plugin_Video.h @@ -42,6 +42,9 @@ 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(); + } // end of namespace PluginVideo #endif diff --git a/Source/Core/VideoCommon/Src/SConscript b/Source/Core/VideoCommon/Src/SConscript index 2596e7db13..cab758ea50 100644 --- a/Source/Core/VideoCommon/Src/SConscript +++ b/Source/Core/VideoCommon/Src/SConscript @@ -8,6 +8,7 @@ files = [ "XFMemory.cpp", "XFBConvert.cpp", "Fifo.cpp", + "VideoState.cpp", ] env_common = env.Copy() diff --git a/Source/Core/VideoCommon/Src/VideoState.cpp b/Source/Core/VideoCommon/Src/VideoState.cpp new file mode 100644 index 0000000000..ab41047b44 --- /dev/null +++ b/Source/Core/VideoCommon/Src/VideoState.cpp @@ -0,0 +1,31 @@ +// Copyright (C) 2003-2008 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#include "VideoState.h" +#include "TextureDecoder.h" + +void VideoCommon_SaveState() { +#ifdef WIN32 + MessageBoxA(NULL, "SAVING STATE", "From Common Video Library", NULL); +#endif +} + +void VideoCommon_LoadState() { +#ifdef WIN32 + MessageBoxA(NULL, "LOADING STATE", "From Common Video Library", NULL); +#endif +} \ No newline at end of file diff --git a/Source/Core/VideoCommon/Src/VideoState.h b/Source/Core/VideoCommon/Src/VideoState.h new file mode 100644 index 0000000000..cccf542849 --- /dev/null +++ b/Source/Core/VideoCommon/Src/VideoState.h @@ -0,0 +1,26 @@ +// Copyright (C) 2003-2008 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#ifndef __VIDEOSTATE_H +#define __VIDEOSTATE_H + +#include "Common.h" + +void VideoCommon_SaveState(); +void VideoCommon_LoadState(); + +#endif \ No newline at end of file diff --git a/Source/PluginSpecs/pluginspecs_video.h b/Source/PluginSpecs/pluginspecs_video.h index 3ee9d02396..cb139f6a59 100644 --- a/Source/PluginSpecs/pluginspecs_video.h +++ b/Source/PluginSpecs/pluginspecs_video.h @@ -177,6 +177,22 @@ 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 +// input: The chunkfile to write to? FIXME +// output: none +// +EXPORT void CALL Video_SaveState(); + +// __________________________________________________________________________________________________ +// Function: Video_LoadState +// Purpose: Loads the current video data state +// input: The chunkfile to read from? FIXME +// output: none +// +EXPORT void CALL Video_LoadState(); + #undef CALL #if defined(__cplusplus) diff --git a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp index d27512425e..8d7271572b 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp @@ -20,6 +20,7 @@ #include "D3DUtil.h" #include "W32Util/Misc.h" #include "EmuWindow.h" +#include "VideoState.h" #include "Utils.h" @@ -165,6 +166,20 @@ void Video_Initialize(SVideoInitialize* _pVideoInitialize) } +void Video_SaveState() { + VideoCommon_SaveState(); +#ifdef WIN32 + MessageBoxA(NULL, "SAVING STATE", "From DirectX", NULL); +#endif +} + +void Video_LoadState() { + VideoCommon_LoadState(); +#ifdef WIN32 + MessageBoxA(NULL, "LOADING STATE", "From DirectX", NULL); +#endif +} + void Video_EnterLoop() { Fifo_EnterLoop(g_VideoInitialize); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index 92edc64eb5..ebd51a7fb8 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -37,6 +37,8 @@ #include "PixelShaderManager.h" #include "VertexShaderManager.h" +#include "VideoState.h" + SVideoInitialize g_VideoInitialize; #define VERSION_STRING "0.1" @@ -177,6 +179,19 @@ void Video_Initialize(SVideoInitialize* _pVideoInitialize) } +void Video_SaveState() { + VideoCommon_SaveState(); +#ifdef WIN32 + MessageBoxA(NULL, "SAVING STATE", "From OpenGL", NULL); +#endif +} + +void Video_LoadState() { + VideoCommon_LoadState(); +#ifdef WIN32 + MessageBoxA(NULL, "LOADING STATE", "From OpenGL", NULL); +#endif +} void Video_Prepare(void) {