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
This commit is contained in:
XTra.KrazzY 2008-08-28 07:58:04 +00:00
parent 8a33d6787b
commit 051c2e0784
10 changed files with 60 additions and 61 deletions

View File

@ -55,6 +55,8 @@
#include "Host.h" #include "Host.h"
#include "LogManager.h" #include "LogManager.h"
#include "State.h"
#ifndef _WIN32 #ifndef _WIN32
#define WINAPI #define WINAPI
#endif #endif
@ -411,11 +413,11 @@ EState GetState()
} }
void SaveState() { void SaveState() {
PluginVideo::Video_SaveState(); State_Save("state.dlp");
} }
void LoadState() { void LoadState() {
PluginVideo::Video_LoadState(); State_Load("state.dlp");
} }
const SCoreStartupParameter& GetStartupParameter() const SCoreStartupParameter& GetStartupParameter()

View File

@ -35,8 +35,7 @@ typedef void (__cdecl* TVideo_EnterLoop)();
typedef void (__cdecl* TVideo_AddMessage)(const char* pstr, unsigned int milliseconds); typedef void (__cdecl* TVideo_AddMessage)(const char* pstr, unsigned int milliseconds);
typedef void (__cdecl* TVideo_SaveState)(); typedef void (__cdecl* TVideo_DoState)(ChunkFile &f);
typedef void (__cdecl* TVideo_LoadState)();
//! Function Pointer //! Function Pointer
TGetDllInfo g_GetDllInfo = 0; TGetDllInfo g_GetDllInfo = 0;
@ -50,8 +49,7 @@ TVideo_UpdateXFB g_Video_UpdateXFB = 0;
TVideo_Screenshot g_Video_Screenshot = 0; TVideo_Screenshot g_Video_Screenshot = 0;
TVideo_EnterLoop g_Video_EnterLoop = 0; TVideo_EnterLoop g_Video_EnterLoop = 0;
TVideo_AddMessage g_Video_AddMessage = 0; TVideo_AddMessage g_Video_AddMessage = 0;
TVideo_SaveState g_Video_SaveState = 0; TVideo_DoState g_Video_DoState = 0;
TVideo_LoadState g_Video_LoadState = 0;
//! Library Instance //! Library Instance
DynamicLibrary plugin; DynamicLibrary plugin;
@ -72,11 +70,10 @@ void UnloadPlugin()
g_Video_Shutdown = 0; g_Video_Shutdown = 0;
g_Video_SendFifoData = 0; g_Video_SendFifoData = 0;
g_Video_UpdateXFB = 0; g_Video_UpdateXFB = 0;
g_Video_AddMessage = 0; g_Video_AddMessage = 0;
g_Video_SaveState = 0; g_Video_DoState = 0;
g_Video_LoadState = 0;
plugin.Unload(); plugin.Unload();
} }
bool LoadPlugin(const char *_Filename) bool LoadPlugin(const char *_Filename)
@ -94,8 +91,7 @@ bool LoadPlugin(const char *_Filename)
g_Video_Screenshot = reinterpret_cast<TVideo_Screenshot> (plugin.Get("Video_Screenshot")); g_Video_Screenshot = reinterpret_cast<TVideo_Screenshot> (plugin.Get("Video_Screenshot"));
g_Video_EnterLoop = reinterpret_cast<TVideo_EnterLoop> (plugin.Get("Video_EnterLoop")); g_Video_EnterLoop = reinterpret_cast<TVideo_EnterLoop> (plugin.Get("Video_EnterLoop"));
g_Video_AddMessage = reinterpret_cast<TVideo_AddMessage> (plugin.Get("Video_AddMessage")); g_Video_AddMessage = reinterpret_cast<TVideo_AddMessage> (plugin.Get("Video_AddMessage"));
g_Video_SaveState = reinterpret_cast<TVideo_SaveState> (plugin.Get("Video_SaveState")); g_Video_DoState = reinterpret_cast<TVideo_DoState> (plugin.Get("Video_DoState"));
g_Video_LoadState = reinterpret_cast<TVideo_LoadState> (plugin.Get("Video_LoadState"));
if ((g_GetDllInfo != 0) && if ((g_GetDllInfo != 0) &&
(g_DllAbout != 0) && (g_DllAbout != 0) &&
@ -108,8 +104,7 @@ bool LoadPlugin(const char *_Filename)
(g_Video_EnterLoop != 0) && (g_Video_EnterLoop != 0) &&
(g_Video_Screenshot != 0) && (g_Video_Screenshot != 0) &&
(g_Video_AddMessage != 0) && (g_Video_AddMessage != 0) &&
(g_Video_SaveState != 0) && (g_Video_DoState != 0) )
(g_Video_LoadState != 0) )
{ {
return true; return true;
} }
@ -181,12 +176,8 @@ void Video_AddMessage(const char* pstr, unsigned int milliseconds)
g_Video_AddMessage(pstr,milliseconds); g_Video_AddMessage(pstr,milliseconds);
} }
void Video_SaveState() { void Video_DoState(ChunkFile &f) {
g_Video_SaveState(); g_Video_DoState(f);
}
void Video_LoadState() {
g_Video_LoadState();
} }
} // end of namespace PluginVideo } // end of namespace PluginVideo

View File

@ -20,6 +20,8 @@
#include "pluginspecs_video.h" #include "pluginspecs_video.h"
#include "ChunkFile.h"
namespace PluginVideo namespace PluginVideo
{ {
bool IsLoaded(); bool IsLoaded();
@ -42,8 +44,7 @@ void Video_UpdateXFB(BYTE* _pXFB, DWORD _dwHeight, DWORD _dwWidth);
bool Video_Screenshot(TCHAR* _szFilename); bool Video_Screenshot(TCHAR* _szFilename);
void Video_AddMessage(const char* pstr, unsigned int milliseconds); void Video_AddMessage(const char* pstr, unsigned int milliseconds);
void Video_SaveState(); void Video_DoState(ChunkFile &f);
void Video_LoadState();
} // end of namespace PluginVideo } // end of namespace PluginVideo

View File

@ -17,6 +17,7 @@ void DoState(ChunkFile &f)
f.Descend("DOLP"); f.Descend("DOLP");
PowerPC::DoState(f); PowerPC::DoState(f);
HW::DoState(f); HW::DoState(f);
PluginVideo::Video_DoState(f);
f.Ascend(); f.Ascend();
} }
@ -43,13 +44,13 @@ void State_Shutdown()
// nothing to do, here for consistency. // nothing to do, here for consistency.
} }
void SaveState(const char *filename) void State_Save(const char *filename)
{ {
cur_filename = filename; cur_filename = filename;
CoreTiming::ScheduleEvent_Threadsafe(0, ev_Save); CoreTiming::ScheduleEvent_Threadsafe(0, ev_Save);
} }
void LoadState(const char *filename) void State_Load(const char *filename)
{ {
cur_filename = filename; cur_filename = filename;
CoreTiming::ScheduleEvent_Threadsafe(0, ev_Load); CoreTiming::ScheduleEvent_Threadsafe(0, ev_Load);

View File

@ -6,7 +6,7 @@
void State_Init(); void State_Init();
void State_Shutdown(); void State_Shutdown();
void State_Save(); void State_Save(const char *filename);
void State_Load(); void State_Load(const char *filename);
#endif #endif

View File

@ -18,12 +18,34 @@
#include "VideoState.h" #include "VideoState.h"
#include "TextureDecoder.h" #include "TextureDecoder.h"
void VideoCommon_SaveState() { void DoState(ChunkFile &f) {
//PanicAlert("Saving state from Video Common Library"); // BP Memory
//TODO: Save the video state 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() { void VideoCommon_DoState(ChunkFile &f) {
//PanicAlert("Loading state from Video Common Library"); //PanicAlert("Saving state from Video Common Library");
//TODO: Load the video state //TODO: Save the video state
f.Descend("VID ");
f.DoState(f);
f.Ascend();
} }

View File

@ -19,8 +19,8 @@
#define __VIDEOSTATE_H #define __VIDEOSTATE_H
#include "Common.h" #include "Common.h"
#include "ChunkFile.h"
void VideoCommon_SaveState(); void VideoCommon_DoState(ChunkFile &f);
void VideoCommon_LoadState();
#endif #endif

View File

@ -168,20 +168,12 @@ EXPORT void CALL Video_EnterLoop(void);
EXPORT void CALL Video_AddMessage(const char* pstr, unsigned int milliseconds); EXPORT void CALL Video_AddMessage(const char* pstr, unsigned int milliseconds);
// __________________________________________________________________________________________________ // __________________________________________________________________________________________________
// Function: Video_SaveState // Function: Video_DoState
// Purpose: Saves the current video data state // Purpose: Saves/Loads the current video data state(depends on parameter)
// input: The chunkfile to write to? FIXME // input: The chunkfile to write to? FIXME
// output: none // output: none
// //
EXPORT void CALL Video_SaveState(void); EXPORT void CALL Video_DoState(ChunkFile &f);
// __________________________________________________________________________________________________
// 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);
#include "ExportEpilog.h" #include "ExportEpilog.h"
#endif #endif

View File

@ -166,14 +166,9 @@ void Video_Initialize(SVideoInitialize* _pVideoInitialize)
} }
void Video_SaveState(void) { void Video_DoState(ChunkFile &f) {
VideoCommon_SaveState(); VideoCommon_DoState(f);
//PanicAlert("Saving state from DirectX9"); //PanicAlert("Saving/Loading state from DirectX9");
}
void Video_LoadState(void) {
VideoCommon_LoadState();
//PanicAlert("Loading state from DirectX9");
} }
void Video_EnterLoop() void Video_EnterLoop()

View File

@ -179,14 +179,9 @@ void Video_Initialize(SVideoInitialize* _pVideoInitialize)
} }
void Video_SaveState(void) { void Video_DoState(ChunkFile &f) {
VideoCommon_SaveState(); VideoCommon_DoState(f);
//PanicAlert("Saving state from OpenGL"); //PanicAlert("Saving/Loading state from OpenGL");
}
void Video_LoadState(void) {
VideoCommon_LoadState();
//PanicAlert("Loading state from OpenGL");
} }
void Video_Prepare(void) void Video_Prepare(void)