Horrible, nasty workaround to the Linux cpu sseMXCSR bug.

git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@354 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
arcum42 2008-11-21 05:25:33 +00:00 committed by Gregory Hainaut
parent e47f14f4d5
commit acb1ab1c29
7 changed files with 68 additions and 26 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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