From c228e982ccb4a8ddcd00dd1838af455cd2166fd5 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Thu, 11 Dec 2008 04:08:26 +0000 Subject: [PATCH] A couple minor GUI bug fixes: - DaZ mode is now disabled for SSE1 CPUs, preventing a crash when trying to OK the setting or run the Emulator with default settings. - Emulator no longer tries to run games when a BIOS hasn't been configured (usually led to a crash). git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@410 a6443dda-0b58-4228-96e9-037be469359c --- pcsx2/Memory.c | 5 +++-- pcsx2/Memory.h | 2 +- pcsx2/Misc.h | 2 +- pcsx2/R5900.c | 6 ++++-- pcsx2/R5900.h | 2 +- pcsx2/System.h | 2 +- pcsx2/windows/WinMain.c | 38 ++++++++++++++++++++++++++++------- pcsx2/x86/ix86-32/iR5900-32.c | 9 +++++++++ 8 files changed, 51 insertions(+), 15 deletions(-) diff --git a/pcsx2/Memory.c b/pcsx2/Memory.c index efd0c10438..dd323f4b95 100644 --- a/pcsx2/Memory.c +++ b/pcsx2/Memory.c @@ -2980,7 +2980,7 @@ void loadBiosRom(char *ext, u8 *dest) { SysPrintf("**************\n\n\n"); } -void memReset() { +int memReset() { struct stat buf; char Bios[g_MaxPath]; FILE *fp; @@ -2998,7 +2998,7 @@ void memReset() { if (stat(Bios, &buf) == -1) { SysMessage(_("Unable to load bios: '%s', PCSX2 can't run without that"), Bios); - return; + return 0; } #ifdef PCSX2_VIRTUAL_MEM @@ -3048,6 +3048,7 @@ void memReset() { #endif #endif + return 1; } void memSetKernelMode() { diff --git a/pcsx2/Memory.h b/pcsx2/Memory.h index 79d4017f42..65488dcd9f 100644 --- a/pcsx2/Memory.h +++ b/pcsx2/Memory.h @@ -163,7 +163,7 @@ extern uptr *memLUTWU; #define PSMu64(mem) (*(u64*)PSM(mem)) int memInit(); -void memReset(); +int memReset(); // returns FALSE on error void memSetKernelMode(); void memSetSupervisorMode(); void memSetUserMode(); diff --git a/pcsx2/Misc.h b/pcsx2/Misc.h index f9e189111a..211fe40517 100644 --- a/pcsx2/Misc.h +++ b/pcsx2/Misc.h @@ -42,7 +42,7 @@ // --->> Path Utilities [PathUtil.c] -#define g_MaxPath 512 +#define g_MaxPath 255 // 255 is safer with antiquitated Win32 ASCII APIs. extern int g_Error_PathTooLong; int isPathRooted( const char* path ); diff --git a/pcsx2/R5900.c b/pcsx2/R5900.c index 55f7968ca1..a56bc6b99d 100644 --- a/pcsx2/R5900.c +++ b/pcsx2/R5900.c @@ -111,11 +111,11 @@ int cpuInit() return ret; } -void cpuReset() +int cpuReset() { Cpu->Reset(); - memReset(); + if( !memReset() ) return 0; memset(&cpuRegs, 0, sizeof(cpuRegs)); memset(&fpuRegs, 0, sizeof(fpuRegs)); @@ -139,6 +139,8 @@ void cpuReset() vif1Reset(); rcntInit(); psxReset(); + + return 1; } void cpuShutdown() diff --git a/pcsx2/R5900.h b/pcsx2/R5900.h index b6665a53c4..0e94af72e3 100644 --- a/pcsx2/R5900.h +++ b/pcsx2/R5900.h @@ -225,7 +225,7 @@ extern PCSX2_ALIGNED16_DECL(tlbs tlb[48]); #endif int cpuInit(); -void cpuReset(); +int cpuReset(); void cpuShutdown(); void cpuException(u32 code, u32 bd); void cpuTlbMissR(u32 addr, u32 bd); diff --git a/pcsx2/System.h b/pcsx2/System.h index 98f6982a9d..758c4336cd 100644 --- a/pcsx2/System.h +++ b/pcsx2/System.h @@ -20,7 +20,7 @@ #define __SYSTEM_H__ int SysInit(); // Init mem and plugins -void SysReset(); // Resets mem +int SysReset(); // Resets mem void SysPrintf(const char *fmt, ...); // Printf used by bios syscalls void SysMessage(const char *fmt, ...); // Message used to print msg to users void SysUpdate(); // Called on VBlank (to update i.e. pads) diff --git a/pcsx2/windows/WinMain.c b/pcsx2/windows/WinMain.c index acc29e16c8..6d0aecf9d4 100644 --- a/pcsx2/windows/WinMain.c +++ b/pcsx2/windows/WinMain.c @@ -118,7 +118,7 @@ void RunExecute(int run) { nDisableSC = 1; if (needReset == 1) { - SysReset(); + if( !SysReset() ) return; } if( UseGui ) @@ -1034,9 +1034,24 @@ BOOL APIENTRY AdvancedOptionsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM if (Config.sseMXCSR & 0x8000) CheckDlgButton(hDlg, IDC_EE_CHECK1, TRUE); if (Config.sseVUMXCSR & 0x8000) CheckDlgButton(hDlg, IDC_VU_CHECK1, TRUE); - if (Config.sseMXCSR & 0x0040) CheckDlgButton(hDlg, IDC_EE_CHECK2, TRUE); - if (Config.sseVUMXCSR & 0x0040) CheckDlgButton(hDlg, IDC_VU_CHECK2, TRUE); - + if( !cpucaps.hasStreamingSIMD2Extensions ) + { + // SSE1 cpus do not support Denormals Are Zero flag. + + Config.sseMXCSR &= ~0x0040; + Config.sseVUMXCSR &= ~0x0040; + + EnableWindow( GetDlgItem( hDlg, IDC_EE_CHECK2 ), FALSE ); + EnableWindow( GetDlgItem( hDlg, IDC_VU_CHECK2 ), FALSE ); + CheckDlgButton( hDlg, IDC_EE_CHECK2, FALSE ); + CheckDlgButton( hDlg, IDC_VU_CHECK2, FALSE ); + } + else + { + if (Config.sseMXCSR & 0x0040) CheckDlgButton(hDlg, IDC_EE_CHECK2, TRUE); + if (Config.sseVUMXCSR & 0x0040) CheckDlgButton(hDlg, IDC_VU_CHECK2, TRUE); + } + return TRUE; case WM_COMMAND: @@ -1079,6 +1094,14 @@ BOOL APIENTRY AdvancedOptionsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM Config.sseMXCSR = DEFAULT_sseMXCSR; Config.sseVUMXCSR = DEFAULT_sseVUMXCSR; + if( !cpucaps.hasStreamingSIMD2Extensions ) + { + // SSE1 cpus do not support Denormals Are Zero flag. + + Config.sseMXCSR &= ~0x0040; + Config.sseVUMXCSR &= ~0x0040; + } + CheckRadioButton(hDlg, IDC_EE_ROUNDMODE0, IDC_EE_ROUNDMODE3, IDC_EE_ROUNDMODE0 + ( (Config.sseMXCSR & 0x6000) >> 13)); CheckRadioButton(hDlg, IDC_VU_ROUNDMODE0, IDC_VU_ROUNDMODE3, IDC_VU_ROUNDMODE0 + ( (Config.sseVUMXCSR & 0x6000) >> 13)); @@ -1774,11 +1797,12 @@ int SysInit() { return 0; } -void SysReset() { - if (sinit == 0) return; +int SysReset() { + if (sinit == 0) return 1; StatusSet(_("Resetting...")); - cpuReset(); + if( !cpuReset() ) return 0; StatusSet(_("Ready")); + return 1; } diff --git a/pcsx2/x86/ix86-32/iR5900-32.c b/pcsx2/x86/ix86-32/iR5900-32.c index b4ec630fb5..cdfa76c18f 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.c +++ b/pcsx2/x86/ix86-32/iR5900-32.c @@ -1452,6 +1452,15 @@ void SetCPUState(u32 sseMXCSR, u32 sseVUMXCSR) sseMXCSR &= 0xffff; // clear the upper 16 bits since they shouldn't be set sseVUMXCSR &= 0xffff; + if( !cpucaps.hasStreamingSIMD2Extensions ) + { + // SSE1 cpus do not support Denormals Are Zero flag (throws an exception + // if we don't mask them off) + + sseMXCSR &= ~0x0040; + sseVUMXCSR &= ~0x0040; + } + g_sseMXCSR = sseMXCSR; g_sseVUMXCSR = sseVUMXCSR; // do NOT set Denormals-Are-Zero flag (charlie and chocfac messes up)