diff --git a/pcsx2/Linux/GtkGui.cpp b/pcsx2/Linux/GtkGui.cpp index 2fb38f4a62..87d4640c83 100644 --- a/pcsx2/Linux/GtkGui.cpp +++ b/pcsx2/Linux/GtkGui.cpp @@ -83,6 +83,13 @@ void RunGui() { StartGui(); } +void FixCPUState(void) +{ + Config.sseMXCSR = LinuxsseMXCSR; + Config.sseVUMXCSR = LinuxsseVUMXCSR; + SetCPUState(Config.sseMXCSR, Config.sseVUMXCSR); +} + void OnDestroy(GtkObject *object, gpointer user_data) { if (!destroy) OnFile_Exit(NULL, user_data); } @@ -132,7 +139,8 @@ void RunExecute(int run) } signal(SIGINT, SignalExit); signal(SIGPIPE, SignalExit); - + + FixCPUState(); if (needReset == TRUE) { if( RunExe == 0 ) @@ -156,6 +164,8 @@ void RunExecute(int run) void OnFile_RunCD(GtkMenuItem *menuitem, gpointer user_data) { needReset = TRUE; efile = 0; + + FixCPUState(); RunExecute(1); } @@ -167,6 +177,8 @@ void OnRunElf_Ok(GtkButton* button, gpointer user_data) { gtk_widget_destroy(FileSel); needReset = TRUE; efile = 1; + + FixCPUState(); RunExecute(1); } @@ -767,6 +779,9 @@ void on_Speed_Hack_OK(GtkButton *button, gpointer user_data) } void setAdvancedOptions() { + LinuxsseMXCSR = Config.sseMXCSR; + LinuxsseVUMXCSR = Config.sseVUMXCSR; + switch((Config.sseMXCSR & 0x6000) >> 13) { case 0: @@ -818,34 +833,40 @@ void on_Advanced(GtkMenuItem *menuitem, gpointer user_data) void on_Advanced_Defaults(GtkButton *button, gpointer user_data) { - Config.sseMXCSR = DEFAULT_sseMXCSR; - Config.sseVUMXCSR = DEFAULT_sseVUMXCSR; + LinuxsseMXCSR = DEFAULT_sseMXCSR; + LinuxsseVUMXCSR = DEFAULT_sseVUMXCSR; setAdvancedOptions(); } void on_Advanced_OK(GtkButton *button, gpointer user_data) { - Config.sseMXCSR &= 0x1fbf; - Config.sseVUMXCSR &= 0x1fbf; + LinuxsseMXCSR &= 0x1fbf; + LinuxsseVUMXCSR &= 0x1fbf; - - Config.sseMXCSR |= is_checked(AdvDlg, "radio_EE_Round_Near") ? FLAG_ROUND_NEAR : 0; - Config.sseMXCSR |= is_checked(AdvDlg, "radio_EE_Round_Negative") ? FLAG_ROUND_NEGATIVE : 0; - Config.sseMXCSR |= is_checked(AdvDlg, "radio_EE_Round_Positive") ? FLAG_ROUND_POSITIVE : 0; - Config.sseMXCSR |= is_checked(AdvDlg, "radio_EE_Round_Zero") ? FLAG_ROUND_ZERO : 0; + LinuxsseMXCSR |= is_checked(AdvDlg, "radio_EE_Round_Near") ? FLAG_ROUND_NEAR : 0; + LinuxsseMXCSR |= is_checked(AdvDlg, "radio_EE_Round_Negative") ? FLAG_ROUND_NEGATIVE : 0; + LinuxsseMXCSR |= is_checked(AdvDlg, "radio_EE_Round_Positive") ? FLAG_ROUND_POSITIVE : 0; + LinuxsseMXCSR |= is_checked(AdvDlg, "radio_EE_Round_Zero") ? FLAG_ROUND_ZERO : 0; - Config.sseVUMXCSR |= is_checked(AdvDlg, "radio_VU_Round_Near") ? FLAG_ROUND_NEAR : 0; - Config.sseVUMXCSR |= is_checked(AdvDlg, "radio_VU_Round_Negative") ? FLAG_ROUND_NEGATIVE : 0; - Config.sseVUMXCSR |= is_checked(AdvDlg, "radio_VU_Round_Positive") ? FLAG_ROUND_POSITIVE : 0; - Config.sseVUMXCSR |= is_checked(AdvDlg, "radio_VU_Round_Zero") ? FLAG_ROUND_ZERO : 0; + LinuxsseMXCSR = Config.sseMXCSR; + LinuxsseVUMXCSR = Config.sseVUMXCSR; - Config.sseMXCSR |= is_checked(AdvDlg, "check_EE_Flush_Zero") ? FLAG_FLUSH_ZERO : 0; - Config.sseVUMXCSR |= is_checked(AdvDlg, "check_VU_Flush_Zero") ? FLAG_FLUSH_ZERO : 0; + LinuxsseVUMXCSR |= is_checked(AdvDlg, "radio_VU_Round_Near") ? FLAG_ROUND_NEAR : 0; + LinuxsseVUMXCSR |= is_checked(AdvDlg, "radio_VU_Round_Negative") ? FLAG_ROUND_NEGATIVE : 0; + LinuxsseVUMXCSR |= is_checked(AdvDlg, "radio_VU_Round_Positive") ? FLAG_ROUND_POSITIVE : 0; + LinuxsseVUMXCSR |= is_checked(AdvDlg, "radio_VU_Round_Zero") ? FLAG_ROUND_ZERO : 0; - Config.sseMXCSR |= is_checked(AdvDlg, "check_EE_Denormal_Zero") ? FLAG_DENORMAL_ZERO : 0; - Config.sseVUMXCSR |= is_checked(AdvDlg, "check_VU_Denormal_Zero") ? FLAG_DENORMAL_ZERO : 0; + LinuxsseMXCSR |= is_checked(AdvDlg, "check_EE_Flush_Zero") ? FLAG_FLUSH_ZERO : 0; + LinuxsseVUMXCSR |= is_checked(AdvDlg, "check_VU_Flush_Zero") ? FLAG_FLUSH_ZERO : 0; + LinuxsseMXCSR |= is_checked(AdvDlg, "check_EE_Denormal_Zero") ? FLAG_DENORMAL_ZERO : 0; + LinuxsseVUMXCSR |= is_checked(AdvDlg, "check_VU_Denormal_Zero") ? FLAG_DENORMAL_ZERO : 0; + + Config.sseMXCSR = LinuxsseMXCSR; + Config.sseVUMXCSR = LinuxsseVUMXCSR; + + //SysPrintf("Advanced: Config.sseMXCSR = %x; Config.sseVUMXCSR = %x \n", Config.sseMXCSR, Config.sseVUMXCSR); SetCPUState(Config.sseMXCSR, Config.sseVUMXCSR); SaveConfig(); diff --git a/pcsx2/Linux/Linux.h b/pcsx2/Linux/Linux.h index e1336fda0c..6a6e842a42 100644 --- a/pcsx2/Linux/Linux.h +++ b/pcsx2/Linux/Linux.h @@ -63,6 +63,11 @@ extern bool RunExe; extern int efile; extern int g_SaveGSStream; extern int g_ZeroGSOptions; + +// Nasty, currently neccessary hack +extern u32 LinuxsseMXCSR; +extern u32 LinuxsseVUMXCSR; +extern void FixCPUState(void); /* LnxMain */ extern void InitLanguages(); diff --git a/pcsx2/Linux/LnxMain.c b/pcsx2/Linux/LnxMain.c index e16779f22b..5776760c14 100644 --- a/pcsx2/Linux/LnxMain.c +++ b/pcsx2/Linux/LnxMain.c @@ -195,7 +195,7 @@ int main(int argc, char *argv[]) { SysReset(); - SetCPUState(Config.sseMXCSR, Config.sseVUMXCSR); + FixCPUState(); cpuExecuteBios(); if (file) strcpy(elfname, file); if (!efile) efile=GetPS2ElfName(elfname); diff --git a/pcsx2/Linux/Pref.cpp b/pcsx2/Linux/Pref.cpp index 54591af14c..b3bc556a95 100644 --- a/pcsx2/Linux/Pref.cpp +++ b/pcsx2/Linux/Pref.cpp @@ -29,6 +29,9 @@ extern "C" { FILE *pref_file; char *data; + u32 LinuxsseMXCSR = DEFAULT_sseMXCSR; + u32 LinuxsseVUMXCSR = DEFAULT_sseVUMXCSR; + static void SetValue( const char *name, char *var) { fprintf (pref_file,"%s = %s\n", name, var); @@ -102,12 +105,12 @@ int LoadConfig() { GetValuel("Fixes", Config.GameFixes); - Config.sseMXCSR = DEFAULT_sseMXCSR; - Config.sseVUMXCSR = DEFAULT_sseVUMXCSR; - - GetValuel("sseMXCSR", Config.sseMXCSR); - GetValuel("sseVUMXCSR", Config.sseVUMXCSR); - + GetValuel("sseMXCSR", LinuxsseMXCSR); + GetValuel("sseVUMXCSR", LinuxsseVUMXCSR); + + Config.sseMXCSR = LinuxsseMXCSR; + Config.sseVUMXCSR = LinuxsseVUMXCSR; + GetValuel("Patch", Config.Patch); GetValuel("CustomFps", Config.CustomFps); diff --git a/pcsx2/Patch.c b/pcsx2/Patch.c index c2945b3ad2..f6e19802f4 100644 --- a/pcsx2/Patch.c +++ b/pcsx2/Patch.c @@ -651,7 +651,13 @@ void patchFunc_zerogs(char* cmd, char* param) void SetRoundMode(u32 ee, u32 vu) { // don't set a state for interpreter only + SysMessage("SetRoundMode: Config.sseMXCSR = %x; Config.sseVUMXCSR = %x \n", Config.sseMXCSR, Config.sseVUMXCSR); + #ifndef PCSX2_NORECBUILD SetCPUState( (Config.sseMXCSR & 0x9fff) | ee, (Config.sseVUMXCSR & 0x9fff) | vu); +#endif + #ifdef __LINUX__ + LinuxsseMXCSR = Config.sseMXCSR; + LinuxsseVUMXCSR = Config.sseVUMXCSR; #endif } diff --git a/pcsx2/Patch.h b/pcsx2/Patch.h index c6bffe8fae..6b11d7170a 100644 --- a/pcsx2/Patch.h +++ b/pcsx2/Patch.h @@ -97,6 +97,11 @@ extern PatchTextTable cpuCore[]; extern IniPatch patch[ MAX_PATCH ]; extern int patchnumber; +#ifdef __LINUX__ +// Nasty, currently neccessary hack +extern u32 LinuxsseMXCSR; +extern u32 LinuxsseVUMXCSR; +#endif void applypatch( int place ); void inifile_read( char * name ); diff --git a/pcsx2/x86/ix86-32/iR5900-32.c b/pcsx2/x86/ix86-32/iR5900-32.c index 9b839637b2..5faaa241ac 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.c +++ b/pcsx2/x86/ix86-32/iR5900-32.c @@ -1445,6 +1445,7 @@ u32 g_sseVUMXCSR = DEFAULT_sseVUMXCSR; void SetCPUState(u32 sseMXCSR, u32 sseVUMXCSR) { + //SysMessage("SetCPUState: Config.sseMXCSR = %x; Config.sseVUMXCSR = %x \n", Config.sseMXCSR, Config.sseVUMXCSR); // SSE STATE // // WARNING: do not touch unless you know what you are doing @@ -1581,7 +1582,7 @@ int recInit( void ) g_MACFlagTransform[i] = macarr[i>>4]|(macarr[i&15]<<4); } - + //SysMessage("recInit: Config.sseMXCSR = %x; Config.sseVUMXCSR = %x \n", Config.sseMXCSR, Config.sseVUMXCSR); SetCPUState(Config.sseMXCSR, Config.sseVUMXCSR); return 0; @@ -1667,6 +1668,7 @@ static void execute( void ) g_EEFreezeRegs = 1; // skip the POPs + #ifdef _DEBUG fnptr = (u8*)pblock->pFnptr;