From d98ed02035cd2c2d3f231cefe5990b87d431b556 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Thu, 25 Dec 2008 07:06:31 +0000 Subject: [PATCH] Correct compiling in Linux again. Cpu & Savestate code still need to be reworked in Linux. git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@490 a6443dda-0b58-4228-96e9-037be469359c --- pcsx2/Exceptions.h | 1 + pcsx2/Linux/GtkGui.cpp | 40 ++++++++++++++++++++------------------ pcsx2/Linux/GtkGui.h | 7 +++++++ pcsx2/Linux/Linux.h | 4 +++- pcsx2/Linux/LnxConsole.cpp | 14 +++++++++++-- pcsx2/Linux/LnxMain.cpp | 35 ++++++++++++++++++++++++++++----- pcsx2/Makefile.am | 4 ++-- pcsx2/SaveState.h | 14 +++++++------ pcsx2/build.sh | 2 +- plugins/fetch.sh | 7 +++++++ 10 files changed, 92 insertions(+), 36 deletions(-) diff --git a/pcsx2/Exceptions.h b/pcsx2/Exceptions.h index 685cc3ab1f..632b5286a8 100644 --- a/pcsx2/Exceptions.h +++ b/pcsx2/Exceptions.h @@ -19,6 +19,7 @@ #ifndef _PCSX2_EXCEPTIONS_H_ #define _PCSX2_EXCEPTIONS_H_ +#include #include namespace Exception diff --git a/pcsx2/Linux/GtkGui.cpp b/pcsx2/Linux/GtkGui.cpp index 0c64790e66..095790fd90 100644 --- a/pcsx2/Linux/GtkGui.cpp +++ b/pcsx2/Linux/GtkGui.cpp @@ -137,8 +137,7 @@ void RunExecute(int run) // cross platform gui?) - Air if (needReset == TRUE) - if (!SysReset()) - return; + SysReset(); gtk_widget_destroy(MainWindow); gtk_main_quit(); @@ -283,7 +282,7 @@ void OnEmu_Reset(GtkMenuItem *menuitem, gpointer user_data) } } -void UpdateMenuSlots(GtkMenuItem *menuitem, gpointer user_data) { +/*void UpdateMenuSlots(GtkMenuItem *menuitem, gpointer user_data) { char str[g_MaxPath]; int i = 0; @@ -291,7 +290,7 @@ void UpdateMenuSlots(GtkMenuItem *menuitem, gpointer user_data) { sprintf(str, SSTATES_DIR "/%8.8X.%3.3d", ElfCRC, i); Slots[i] = CheckState(str); } -} +}*/ void States_Load(const char* file, int num = -1 ) { @@ -358,7 +357,7 @@ void States_Load(int num) { States_Load( Text, num ); } -void States_Save( const char* file, int num = -1 ); +void States_Save( const char* file, int num = -1 ) { try { @@ -500,9 +499,9 @@ void OnEmu_Arguments(GtkMenuItem *menuitem, gpointer user_data) { void OnCpu_Ok(GtkButton *button, gpointer user_data) { u32 newopts = 0; - Cpu->Shutdown(); - vu0Shutdown(); - vu1Shutdown(); + //Cpu->Shutdown(); + //vu0Shutdown(); + //vu1Shutdown(); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkCheckButton_EERec")))) newopts |= PCSX2_EEREC; @@ -528,19 +527,22 @@ void OnCpu_Ok(GtkButton *button, gpointer user_data) { if (newopts & PCSX2_EEREC ) newopts |= PCSX2_COP2REC; - Config.Options = newopts; - - UpdateVSyncRate(); + if (Config.Options != newopts) + { + SysRestorableReset(); + + if( (Config.Options&PCSX2_GSMULTITHREAD) ^ (newopts&PCSX2_GSMULTITHREAD) ) + { + // gotta shut down *all* the plugins. + ResetPlugins(); + } + Config.Options = newopts; + } + else + UpdateVSyncRate(); + SaveConfig(); - if ((Config.Options&PCSX2_GSMULTITHREAD) ^ (newopts&PCSX2_GSMULTITHREAD)) - { - cpuShutdown(); - ResetPlugins(); - } - - cpuReset(); // cpuReset will call cpuInit() automatically if needed. - gtk_widget_destroy(CpuDlg); if (MainWindow) gtk_widget_set_sensitive(MainWindow, TRUE); gtk_main_quit(); diff --git a/pcsx2/Linux/GtkGui.h b/pcsx2/Linux/GtkGui.h index c210bf5a89..200e953097 100644 --- a/pcsx2/Linux/GtkGui.h +++ b/pcsx2/Linux/GtkGui.h @@ -41,6 +41,13 @@ bool UseGui = TRUE; bool needReset = TRUE; bool RunExe = FALSE; +MemoryAlloc* g_RecoveryState = NULL; +bool g_GameInProgress = false; // Set TRUE if a game is actively running. + +static bool AccBreak = false; +static bool m_ReturnToGame = false; // set to exit the RunGui message pump + + int efile = 0; char elfname[g_MaxPath]; int Slots[5] = { -1, -1, -1, -1, -1 }; diff --git a/pcsx2/Linux/Linux.h b/pcsx2/Linux/Linux.h index 553f7ae100..a2c8c4f4b5 100644 --- a/pcsx2/Linux/Linux.h +++ b/pcsx2/Linux/Linux.h @@ -82,7 +82,9 @@ extern void SaveConfig(); /* GtkGui */ extern void init_widgets(); - +extern MemoryAlloc* g_RecoveryState; +extern bool g_GameInProgress; +extern void SysRestorableReset(); typedef struct { char lang[g_MaxPath]; diff --git a/pcsx2/Linux/LnxConsole.cpp b/pcsx2/Linux/LnxConsole.cpp index 3cf463844a..1885365c45 100644 --- a/pcsx2/Linux/LnxConsole.cpp +++ b/pcsx2/Linux/LnxConsole.cpp @@ -100,7 +100,7 @@ namespace Console { char msg[2048]; - vsnprintf(msg,2045,fmt,list); + vsnprintf(msg,2045,fmt,args); msg[2044] = '\0'; strcat( msg, "\n" ); SetColor( color ); @@ -110,7 +110,17 @@ namespace Console if( emuLog != NULL ) fflush( emuLog ); // manual flush to accompany manual newline } - + + // Writes a line of colored text to the console, with automatic newline appendage. + bool MsgLn( Colors color, const char* fmt, ... ) + { + va_list list; + va_start(list,fmt); + _MsgLn( Color_White, fmt, list ); + va_end(list); + return false; + } + bool Msg( Colors color, const char* fmt, ... ) { va_list list; diff --git a/pcsx2/Linux/LnxMain.cpp b/pcsx2/Linux/LnxMain.cpp index 0ebe889d8e..d79cd0e7f3 100644 --- a/pcsx2/Linux/LnxMain.cpp +++ b/pcsx2/Linux/LnxMain.cpp @@ -418,11 +418,36 @@ int SysInit() return 0; } -int SysReset() { - if (sinit == 0) return 1; - // Resetting - if( !cpuReset() ) return 0; - return 1; +void SysRestorableReset() +{ + // already reset? and saved? + if( !g_GameInProgress ) return; + if( g_RecoveryState != NULL ) return; + + try + { + g_RecoveryState = new MemoryAlloc(); + memSavingState( *g_RecoveryState ).FreezeAll(); + cpuShutdown(); + g_GameInProgress = false; + } + catch( std::runtime_error& ex ) + { + SysMessage( + "Pcsx2 gamestate recovery failed. Some options may have been reverted to protect your game's state.\n" + "Error: %s", ex.what() ); + safe_delete( g_RecoveryState ); + } +} + +void SysReset() +{ + if (!sinit) return; + + g_GameInProgress = false; + safe_free( g_RecoveryState ); + + ResetPlugins(); } void SysClose() { diff --git a/pcsx2/Makefile.am b/pcsx2/Makefile.am index 5b45351dc8..10337b32d6 100644 --- a/pcsx2/Makefile.am +++ b/pcsx2/Makefile.am @@ -17,7 +17,7 @@ COP0.c Hw.h Plugins.h PsxInterpreter.c SPR.h VUops.h COP0.h Interpreter.c PS2Edefs.h PsxMem.c System.h \ Counters.c InterTables.c PS2Etypes.h PsxMem.h Vif.c \ Counters.h InterTables.h PsxBios2.h PsxSio2.c VifDma.c \ -Decode_XA.c Mdec.c PsxBios.c PsxSio2.h VifDma.h Cache.c vtlb.cpp\ -xmlpatchloader.cpp ThreadTools.cpp SourceLog.cpp +Decode_XA.c PsxBios.c PsxSio2.h VifDma.h Cache.c vtlb.cpp\ +xmlpatchloader.cpp ThreadTools.cpp SourceLog.cpp SaveState.cpp SUBDIRS = x86 . DebugTools IPU RDebug tinyxml Linux \ No newline at end of file diff --git a/pcsx2/SaveState.h b/pcsx2/SaveState.h index 61f14c40b0..8126db6218 100644 --- a/pcsx2/SaveState.h +++ b/pcsx2/SaveState.h @@ -20,6 +20,7 @@ #define _SAVESTATE_H_ #include +#include "PS2Edefs.h" // Savestate Versioning! // If you make changes to the savestate version, please increment the value below. @@ -62,7 +63,7 @@ public: } // Loads or saves a plugin. Plugin name is for console logging purposes. - virtual void FreezePlugin( const char* name, s32 (CALLBACK *freezer)(int mode, freezeData *data) )=0; + virtual void FreezePlugin( const char* name,s32(CALLBACK* freezer)(int mode, freezeData *data) )=0; // Loads or saves a memory block. virtual void FreezeMem( void* data, int size )=0; @@ -118,8 +119,7 @@ class gzSavingState : public gzBaseStateInfo public: virtual ~gzSavingState() {} gzSavingState( const char* filename ) ; - - void FreezePlugin( const char* name, s32 (CALLBACK *freezer)(int mode, freezeData *data) ); + void FreezePlugin( const char* name, s32(CALLBACK *freezer)(int mode, freezeData *data) ); void FreezeMem( void* data, int size ); bool IsSaving() const { return true; } }; @@ -130,7 +130,7 @@ public: virtual ~gzLoadingState(); gzLoadingState( const char* filename ); - void FreezePlugin( const char* name, s32 (CALLBACK *freezer)(int mode, freezeData *data) ); + void FreezePlugin( const char* name, s32(CALLBACK *freezer)(int mode, freezeData *data) ); void FreezeMem( void* data, int size ); bool IsSaving() const { return false; } bool Finished() const { return !!gzeof( m_file ); } @@ -158,7 +158,8 @@ protected: public: virtual ~memSavingState() { } memSavingState( MemoryAlloc& save_to ); - void FreezePlugin( const char* name, s32 (CALLBACK *freezer)(int mode, freezeData *data) ); + + void FreezePlugin( const char* name, s32(CALLBACK *freezer)(int mode, freezeData *data) ); // Saving of state data to a memory buffer void FreezeMem( void* data, int size ); bool IsSaving() const { return true; } @@ -169,7 +170,8 @@ class memLoadingState : public memBaseStateInfo public: virtual ~memLoadingState(); memLoadingState(MemoryAlloc& load_from ); - void FreezePlugin( const char* name, s32 (CALLBACK *freezer)(int mode, freezeData *data) ); + + void FreezePlugin( const char* name, s32(CALLBACK *freezer)(int mode, freezeData *data) ); // Loading of state data from a memory buffer... void FreezeMem( void* data, int size ); bool IsSaving() const { return false; } diff --git a/pcsx2/build.sh b/pcsx2/build.sh index b3e9b78e34..191e3b01cf 100644 --- a/pcsx2/build.sh +++ b/pcsx2/build.sh @@ -18,7 +18,7 @@ # #Normal -export PCSX2OPTIONS="--enable-sse3 --enable-sse4 --prefix `pwd`" +#export PCSX2OPTIONS="--enable-sse3 --enable-sse4 --prefix `pwd`" echo --------------- echo Building Pcsx2 diff --git a/plugins/fetch.sh b/plugins/fetch.sh index 6ca4917c72..dc2ef145db 100755 --- a/plugins/fetch.sh +++ b/plugins/fetch.sh @@ -57,6 +57,13 @@ rm -rf ./pad/zeropad cp -r zeropad ./pad/ fi +if [ -d CDVDiso ] +then +echo "Importing local copy of CDVDiso.." +rm -rf ./cdvd/CDVDiso +cp -r CDVDiso ./cdvd/ +fi + if [ -d CDVDlinuz ] then echo "Importing local copy of CDVDlinuz.."