From a7fcdbaafa7b7eaa3b2ab07790b8775eb014ef00 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Wed, 4 Mar 2009 13:00:32 +0000 Subject: [PATCH] Savestate version upgrade and stability fix -- added some vars that the SPRdma might like to preserve between states, and removed some old hacky VM-related stuff while I was at it. Fixed up the Saveslot detection somewhat (File:Load > menu now greys out unavailable saveslots). Applied ICC fixup patch from Issue 84. :) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@677 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/CDVD.cpp | 12 +----------- pcsx2/Counters.cpp | 4 ++-- pcsx2/Exceptions.h | 2 ++ pcsx2/Gif.cpp | 2 +- pcsx2/IPU/IPU.cpp | 2 +- pcsx2/Misc.cpp | 3 ++- pcsx2/SPR.cpp | 17 ++++++++++++++--- pcsx2/SaveState.h | 6 +++--- pcsx2/Sif.cpp | 2 +- pcsx2/Sio.cpp | 4 ++-- pcsx2/SourceLog.cpp | 2 +- pcsx2/VUmicroMem.cpp | 4 ++-- pcsx2/VifDma.cpp | 10 +++++----- pcsx2/windows/WinMain.cpp | 2 -- pcsx2/x86/ix86/ix86_cpudetect.cpp | 2 ++ 15 files changed, 39 insertions(+), 35 deletions(-) diff --git a/pcsx2/CDVD.cpp b/pcsx2/CDVD.cpp index d4b1e30ba1..1747d8aa18 100644 --- a/pcsx2/CDVD.cpp +++ b/pcsx2/CDVD.cpp @@ -766,17 +766,7 @@ struct Freeze_v10Compat void SaveState::cdvdFreeze() { - if( GetVersion() <= 0x10 ) - { - // the old cdvd struct didn't save the last few items. - FreezeLegacy( cdvd, sizeof(Freeze_v10Compat) ); - cdvd.SeekToSector = cdvd.Sector; - cdvd.Action = cdvdAction_None; - cdvd.ReadTime = cdvdBlockReadTime( MODE_DVDROM ); - cdvd.Spinning = true; - } - else - Freeze( cdvd ); + Freeze( cdvd ); if( IsLoading() ) { diff --git a/pcsx2/Counters.cpp b/pcsx2/Counters.cpp index 3482d1bdbf..97c4016a11 100644 --- a/pcsx2/Counters.cpp +++ b/pcsx2/Counters.cpp @@ -770,8 +770,8 @@ void SaveState::rcntFreeze() Freeze(nextCounter); Freeze(nextsCounter); - // New in version 11 -- save the PAL/NTSC info! - if( GetVersion() > 0x10 ) + // New in version 1 -- save the PAL/NTSC info! + if( GetVersion() >= 0x1 ) { Freeze( Config.PsxType ); } diff --git a/pcsx2/Exceptions.h b/pcsx2/Exceptions.h index b3766f3e27..2c7c89dee7 100644 --- a/pcsx2/Exceptions.h +++ b/pcsx2/Exceptions.h @@ -122,6 +122,7 @@ namespace Exception public: explicit OutOfMemory( const std::string& msg="Out of memory!" ) : RuntimeError( msg ) {} + virtual ~OutOfMemory() throw() {} }; // This exception thrown any time an operation is attempted when an object @@ -161,6 +162,7 @@ namespace Exception public: explicit HardwareDeficiency( const std::string& msg="Your machine's hardware is incapable of running Pcsx2. Sorry dood." ) : RuntimeError( msg ) {} + virtual ~HardwareDeficiency() throw() {} }; // This exception is thrown by the PS2 emulation (R5900, etc) when bad things happen diff --git a/pcsx2/Gif.cpp b/pcsx2/Gif.cpp index 415981beb7..a7c3011cc1 100644 --- a/pcsx2/Gif.cpp +++ b/pcsx2/Gif.cpp @@ -584,7 +584,7 @@ void gifMFIFOInterrupt() void SaveState::gifFreeze() { - if( GetVersion() >= 0x14 ) + if( GetVersion() >= 0x04 ) { Freeze( gifstate ); Freeze( gifqwc ); diff --git a/pcsx2/IPU/IPU.cpp b/pcsx2/IPU/IPU.cpp index e67ce388ff..99a1a9ef94 100644 --- a/pcsx2/IPU/IPU.cpp +++ b/pcsx2/IPU/IPU.cpp @@ -169,7 +169,7 @@ void ipuShutdown() void SaveState::ipuFreeze() { IPUProcessInterrupt(); - if( GetVersion() < 0x14 ) + if( GetVersion() < 0x04 ) { // old versions saved the IPU regs, but they're already saved as part of HW! FreezeMem(ipuRegs, sizeof(IPUregisters)); diff --git a/pcsx2/Misc.cpp b/pcsx2/Misc.cpp index 494e5c2e9b..75af273af3 100644 --- a/pcsx2/Misc.cpp +++ b/pcsx2/Misc.cpp @@ -28,7 +28,7 @@ #include "Common.h" #include "PsxCommon.h" -#include "SaveState.h" +#include "HostGui.h" #include "CDVDisodrv.h" #include "VUmicro.h" @@ -583,6 +583,7 @@ void ProcessFKeys(int fkey, int shift) try { gzSavingState( SaveState::GetFilename( StatesC ) ).FreezeAll(); + HostGui::ResetMenuSlots(); } catch( Exception::BaseException& ex ) { diff --git a/pcsx2/SPR.cpp b/pcsx2/SPR.cpp index 2a1b943b01..28d7225d89 100644 --- a/pcsx2/SPR.cpp +++ b/pcsx2/SPR.cpp @@ -26,9 +26,10 @@ #define spr0 ((DMACh*)&PS2MEM_HW[0xD000]) #define spr1 ((DMACh*)&PS2MEM_HW[0xD400]) -int spr0finished = 0; -int spr1finished = 0; -u32 mfifotransferred = 0; +static int spr0finished = 0; +static int spr1finished = 0; +static u32 mfifotransferred = 0; + void sprInit() { } @@ -451,3 +452,13 @@ void SPRTOinterrupt() hwDmacIrq(9); } +void SaveState::sprFreeze() +{ + // Gotta save the weird ref-style DMA timing vars! + if( GetVersion() >= 0x05 ) + { + Freeze(spr0finished); + Freeze(spr1finished); + Freeze(mfifotransferred); + } +} \ No newline at end of file diff --git a/pcsx2/SaveState.h b/pcsx2/SaveState.h index 9b9fadbadf..ac26d1f086 100644 --- a/pcsx2/SaveState.h +++ b/pcsx2/SaveState.h @@ -27,7 +27,7 @@ // Savestate Versioning! // If you make changes to the savestate version, please increment the value below. -static const u32 g_SaveVersion = 0x8b400004; +static const u32 g_SaveVersion = 0x8b400005; // this function is meant to be sued in the place of GSfreeze, and provides a safe layer // between the GS saving function and the MTGS's needs. :) @@ -52,8 +52,7 @@ public: // The version refers to the low 16 bits only (high 16 bits classifies Pcsx2 build types) u32 GetVersion() const { - // HACK! Matches the vTLB build versions with VM - return (m_version & 0xffff) + 0x10; + return (m_version & 0xffff); } // Loads or saves the entire emulation state. @@ -110,6 +109,7 @@ protected: void sifFreeze(); void ipuFreeze(); void gifFreeze(); + void sprFreeze(); void sioFreeze(); void cdrFreeze(); diff --git a/pcsx2/Sif.cpp b/pcsx2/Sif.cpp index d61319a473..5996e030a9 100644 --- a/pcsx2/Sif.cpp +++ b/pcsx2/Sif.cpp @@ -591,7 +591,7 @@ void SaveState::sifFreeze() { Freeze(sif0); Freeze(sif1); - if( GetVersion() >= 0x0012 ) + if( GetVersion() >= 0x0002 ) { Freeze(eesifbusy); Freeze(iopsifbusy); diff --git a/pcsx2/Sio.cpp b/pcsx2/Sio.cpp index 9fdc751f87..ed50adf161 100644 --- a/pcsx2/Sio.cpp +++ b/pcsx2/Sio.cpp @@ -568,8 +568,8 @@ void SaveState::sioFreeze() Freeze( sio ); - // versions prior to 13 didn't have CRCs. - if( GetVersion() >= 0x13 ) + // versions prior to 3 didn't have CRCs. + if( GetVersion() >= 0x03 ) { if( IsSaving() ) { diff --git a/pcsx2/SourceLog.cpp b/pcsx2/SourceLog.cpp index a569e2bde9..08351bb72d 100644 --- a/pcsx2/SourceLog.cpp +++ b/pcsx2/SourceLog.cpp @@ -98,7 +98,7 @@ static __forceinline void _vSourceLog( u16 protocol, u8 source, u32 cpuPc, u32 c #ifdef PCSX2_DEVBUILD #ifdef _WIN32 // Send log data to the (remote?) debugger. - if (connected && logProtocol>=0 && logProtocol<0x10) + if (connected && logProtocol<0x10) { sendTTYP(logProtocol, logSource, tmp); } diff --git a/pcsx2/VUmicroMem.cpp b/pcsx2/VUmicroMem.cpp index 42c233ae2d..1c31f324aa 100644 --- a/pcsx2/VUmicroMem.cpp +++ b/pcsx2/VUmicroMem.cpp @@ -169,7 +169,7 @@ void SaveState::vuMicroFreeze() FreezeMem(VU0.Micro, 4*1024); Freeze(VU0.VF); - if( GetVersion() >= 0x0012 ) + if( GetVersion() >= 0x02 ) Freeze(VU0.VI); else { @@ -185,7 +185,7 @@ void SaveState::vuMicroFreeze() FreezeMem(VU1.Micro, 16*1024); Freeze(VU1.VF); - if( GetVersion() >= 0x0012 ) + if( GetVersion() >= 0x02 ) Freeze(VU1.VI); else { diff --git a/pcsx2/VifDma.cpp b/pcsx2/VifDma.cpp index 9d79f9a810..7211134ad8 100644 --- a/pcsx2/VifDma.cpp +++ b/pcsx2/VifDma.cpp @@ -55,8 +55,8 @@ extern vifStruct *_vif; vifStruct vif0, vif1; -PCSX2_ALIGNED16(u32 g_vif1Masks[64]); -PCSX2_ALIGNED16(u32 g_vif0Masks[64]); +static PCSX2_ALIGNED16(u32 g_vif1Masks[64]); +static PCSX2_ALIGNED16(u32 g_vif0Masks[64]); u32 g_vif1HasMask3[4] = {0}, g_vif0HasMask3[4] = {0}; // Generic constants @@ -1338,11 +1338,11 @@ void vif0Reset() { void SaveState::vif0Freeze() { // Dunno if this one is needed, but whatever, it's small. :) - if( GetVersion() >= 0x14 ) + if( GetVersion() >= 0x04 ) Freeze( g_vifCycles ); Freeze( vif0 ); - if( GetVersion() >= 0x14 ) + if( GetVersion() >= 0x04 ) { Freeze( g_vif0HasMask3 ); Freeze( g_vif0Masks ); @@ -2263,7 +2263,7 @@ void SaveState::vif1Freeze() { Freeze(vif1); - if( GetVersion() >= 0x14 ) + if( GetVersion() >= 0x04 ) { Freeze( g_vif1HasMask3 ); Freeze( g_vif1Masks ); diff --git a/pcsx2/windows/WinMain.cpp b/pcsx2/windows/WinMain.cpp index 5a839c58cd..d5e01a0c9b 100644 --- a/pcsx2/windows/WinMain.cpp +++ b/pcsx2/windows/WinMain.cpp @@ -1027,8 +1027,6 @@ void CreateMainWindow() RECT rect; int w, h; - //g_ReturnToGui = true; - #ifdef _MSC_VER sprintf(COMPILER, "(VC%d)", (_MSC_VER+100)/200);//hacky:) works for VC6 & VC.NET #elif __BORLANDC__ diff --git a/pcsx2/x86/ix86/ix86_cpudetect.cpp b/pcsx2/x86/ix86/ix86_cpudetect.cpp index c99372261f..6c0d91838e 100644 --- a/pcsx2/x86/ix86/ix86_cpudetect.cpp +++ b/pcsx2/x86/ix86/ix86_cpudetect.cpp @@ -32,8 +32,10 @@ { void __cpuid(int* CPUInfo, int InfoType); unsigned __int64 __rdtsc(); +#ifndef __INTEL_COMPILER # pragma intrinsic(__cpuid) # pragma intrinsic(__rdtsc) +#endif } #endif