Save States: Added PADfreeze calls to PCSX2, though they're currently only implemented by LilyPad. Also fixed a bug where a save state would failed to load when the last plugin's freeze function actually saved something. Minor changes to new plugin API as well.

Because of a convenient bug in load state function, older save states with no saved pad info should still work.  Don't blame me if they don't, though.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@791 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
mattmenke 2009-03-15 09:30:31 +00:00
parent 493ecaa206
commit 0efde91a92
5 changed files with 35 additions and 21 deletions

View File

@ -548,6 +548,7 @@ typedef void (CALLBACK* _PADgsDriverInfo)(GSdriverInfo *info);
typedef void (CALLBACK* _PADconfigure)(); typedef void (CALLBACK* _PADconfigure)();
typedef s32 (CALLBACK* _PADtest)(); typedef s32 (CALLBACK* _PADtest)();
typedef void (CALLBACK* _PADabout)(); typedef void (CALLBACK* _PADabout)();
typedef int (CALLBACK* _PADfreeze)(int mode, freezeData *data);
// SIO // SIO
typedef s32 (CALLBACK* _SIOinit)(u32 port, u32 slot, SIOchangeSlotCB f); typedef s32 (CALLBACK* _SIOinit)(u32 port, u32 slot, SIOchangeSlotCB f);
@ -732,6 +733,7 @@ extern _PADgsDriverInfo PAD1gsDriverInfo;
extern _PADconfigure PAD1configure; extern _PADconfigure PAD1configure;
extern _PADtest PAD1test; extern _PADtest PAD1test;
extern _PADabout PAD1about; extern _PADabout PAD1about;
extern _PADfreeze PAD1freeze;
// PAD2 // PAD2
extern _PADinit PAD2init; extern _PADinit PAD2init;
@ -748,6 +750,7 @@ extern _PADgsDriverInfo PAD2gsDriverInfo;
extern _PADconfigure PAD2configure; extern _PADconfigure PAD2configure;
extern _PADtest PAD2test; extern _PADtest PAD2test;
extern _PADabout PAD2about; extern _PADabout PAD2about;
extern _PADfreeze PAD2freeze;
// SIO[2] // SIO[2]
extern _SIOinit SIOinit[2][9]; extern _SIOinit SIOinit[2][9];

View File

@ -26,7 +26,7 @@ extern "C"
typedef u32 (CALLBACK* _PS2EgetLibType)(void); typedef u32 (CALLBACK* _PS2EgetLibType)(void);
typedef u32 (CALLBACK* _PS2EgetLibVersion2)(u32 type); typedef u32 (CALLBACK* _PS2EgetLibVersion2)(u32 type);
typedef char*(CALLBACK* _PS2EgetLibName)(void); typedef char*(CALLBACK* _PS2EgetLibName)(void);
typedef void (CALLBACK* _PS2EpassConfig)(PcsxConfig Config); typedef void (CALLBACK* _PS2EpassConfig)(PcsxConfig *Config);
// GS // GS
// NOTE: GSreadFIFOX/GSwriteCSR functions CANNOT use XMM/MMX regs // NOTE: GSreadFIFOX/GSwriteCSR functions CANNOT use XMM/MMX regs

View File

@ -35,8 +35,10 @@
// Called by SIO_TYPE_MTAP plugins to change the slot. // Called by SIO_TYPE_MTAP plugins to change the slot.
// Slot is then passed to memcard and pad plugins on SIOstartPoll. // Slot is then passed to memcard and pad plugins on SIOstartPoll.
// MTAP SIO plugins should ignore slot vvalues on startPoll, as should RMs (probably). // MTAP SIO plugins should ignore slot values on startPoll, as should RMs (probably).
typedef int (CALLBACK * SIOchangeSlotCB)(int slot);
// Port isn't strictly necessary, but doesn't hurt.
typedef int (CALLBACK * SIOchangeSlotCB)(int port, int slot);
// Basic functions. // Basic functions.
@ -67,7 +69,10 @@ EXPORT_C_(u32) SIOquery();
EXPORT_C_(void) SIOconfigure(); EXPORT_C_(void) SIOconfigure();
EXPORT_C_(keyEvent*) CALLBACK SIOkeyEvent(); EXPORT_C_(keyEvent*) CALLBACK SIOkeyEvent();
EXPORT_C_(s32) SIOfreeze(u8 mode, freezeData *data);
// Save one type at a time. If a plugin supports all 4 types,
// should expect 4 calls. Increases savestate compatibility.
EXPORT_C_(s32) SIOfreeze(u8 mode, freezeData *data, int type);
EXPORT_C_(void) SIOabout(); EXPORT_C_(void) SIOabout();
EXPORT_C_(s32) SIOtest(); EXPORT_C_(s32) SIOtest();
@ -78,6 +83,4 @@ SIO_TYPE_RM = 0x00000040,
SIO_TYPE_MC = 0x00000100 SIO_TYPE_MC = 0x00000100
} SioTypes; } SioTypes;
#endif
#endif // __SIOAPI_H__ #endif // __SIOAPI_H__

View File

@ -71,6 +71,7 @@ _PADgsDriverInfo PAD1gsDriverInfo;
_PADconfigure PAD1configure; _PADconfigure PAD1configure;
_PADtest PAD1test; _PADtest PAD1test;
_PADabout PAD1about; _PADabout PAD1about;
_PADfreeze PAD1freeze;
// PAD2 // PAD2
_PADinit PAD2init; _PADinit PAD2init;
@ -87,6 +88,7 @@ _PADgsDriverInfo PAD2gsDriverInfo;
_PADconfigure PAD2configure; _PADconfigure PAD2configure;
_PADtest PAD2test; _PADtest PAD2test;
_PADabout PAD2about; _PADabout PAD2about;
_PADfreeze PAD2freeze;
// SIO[2] // SIO[2]
_SIOinit SIOinit[2][9]; _SIOinit SIOinit[2][9];
@ -330,6 +332,7 @@ void *PAD1plugin;
void CALLBACK PAD1_configure() {} void CALLBACK PAD1_configure() {}
void CALLBACK PAD1_about() {} void CALLBACK PAD1_about() {}
s32 CALLBACK PAD1_test() { return 0; } s32 CALLBACK PAD1_test() { return 0; }
s32 CALLBACK PAD1_freeze(int mode, freezeData *data) { data->size = 0; return 0; }
int LoadPAD1plugin(const string& filename) { int LoadPAD1plugin(const string& filename) {
void *drv; void *drv;
@ -352,6 +355,7 @@ int LoadPAD1plugin(const string& filename) {
MapSymbolPAD_Fallback(PAD1,PAD,configure); MapSymbolPAD_Fallback(PAD1,PAD,configure);
MapSymbolPAD_Fallback(PAD1,PAD,about); MapSymbolPAD_Fallback(PAD1,PAD,about);
MapSymbolPAD_Fallback(PAD1,PAD,test); MapSymbolPAD_Fallback(PAD1,PAD,test);
MapSymbolPAD_Fallback(PAD1,PAD,freeze);
return 0; return 0;
} }
@ -361,6 +365,7 @@ void *PAD2plugin;
void CALLBACK PAD2_configure() {} void CALLBACK PAD2_configure() {}
void CALLBACK PAD2_about() {} void CALLBACK PAD2_about() {}
s32 CALLBACK PAD2_test() { return 0; } s32 CALLBACK PAD2_test() { return 0; }
s32 CALLBACK PAD2_freeze(int mode, freezeData *data) { data->size = 0; return 0; }
int LoadPAD2plugin(const string& filename) { int LoadPAD2plugin(const string& filename) {
void *drv; void *drv;
@ -383,6 +388,7 @@ int LoadPAD2plugin(const string& filename) {
MapSymbolPAD_Fallback(PAD2,PAD,configure); MapSymbolPAD_Fallback(PAD2,PAD,configure);
MapSymbolPAD_Fallback(PAD2,PAD,about); MapSymbolPAD_Fallback(PAD2,PAD,about);
MapSymbolPAD_Fallback(PAD2,PAD,test); MapSymbolPAD_Fallback(PAD2,PAD,test);
MapSymbolPAD_Fallback(PAD2,PAD,freeze);
return 0; return 0;
} }

View File

@ -139,6 +139,8 @@ void SaveState::FreezeAll()
FreezePlugin( "SPU2", SPU2freeze ); FreezePlugin( "SPU2", SPU2freeze );
FreezePlugin( "DEV9", DEV9freeze ); FreezePlugin( "DEV9", DEV9freeze );
FreezePlugin( "USB", USBfreeze ); FreezePlugin( "USB", USBfreeze );
FreezePlugin( "PAD1", PAD1freeze );
FreezePlugin( "PAD2", PAD2freeze );
if( IsLoading() ) if( IsLoading() )
PostLoadPrep(); PostLoadPrep();
@ -267,9 +269,9 @@ void gzLoadingState::FreezePlugin( const char* name, s32 (CALLBACK *freezer)(int
fP.data = (s8*)malloc(fP.size); fP.data = (s8*)malloc(fP.size);
if (fP.data == NULL) if (fP.data == NULL)
throw Exception::OutOfMemory(); throw Exception::OutOfMemory();
gzread(m_file, fP.data, fP.size); int read = gzread(m_file, fP.data, fP.size);
if( gzeof( m_file ) ) if( read != fP.size )
throw Exception::BadSavedState( m_filename ); throw Exception::BadSavedState( m_filename );
if(freezer(FREEZE_LOAD, &fP) == -1) if(freezer(FREEZE_LOAD, &fP) == -1)