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
This commit is contained in:
arcum42 2008-12-25 07:06:31 +00:00 committed by Gregory Hainaut
parent 243dcfedc8
commit d98ed02035
10 changed files with 92 additions and 36 deletions

View File

@ -19,6 +19,7 @@
#ifndef _PCSX2_EXCEPTIONS_H_
#define _PCSX2_EXCEPTIONS_H_
#include <stdexcept>
#include <string>
namespace Exception

View File

@ -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();

View File

@ -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 };

View File

@ -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];

View File

@ -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;

View File

@ -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() {

View File

@ -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

View File

@ -20,6 +20,7 @@
#define _SAVESTATE_H_
#include <zlib.h>
#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; }

View File

@ -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

View File

@ -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.."