mirror of https://github.com/PCSX2/pcsx2.git
*EXPERIMENTAL* Switched the code over to a new method of exception handling which should be more efficient and easier to debug and, most importantly, fixes a lot of the weird errors we've been getting since r488.
*NOTE: THIS IS REVISION WORKS ON VTLB ONLY -- VM BUILDS ARE CURRENTLY BROKEN* If you like VM, do not try to compile or use this revision. The VM build will crash anytime you try to load a savestate or exit/resume emulation. (Interpreters and some other stuff are also broken too, but will be fixed shortly) git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@578 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
parent
7488e930d4
commit
7b2a5f068f
|
@ -497,10 +497,10 @@ __forceinline void rcntUpdate_hScanline()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__forceinline void rcntUpdate_vSync()
|
__forceinline bool rcntUpdate_vSync()
|
||||||
{
|
{
|
||||||
s32 diff = (cpuRegs.cycle - counters[5].sCycle);
|
s32 diff = (cpuRegs.cycle - counters[5].sCycle);
|
||||||
if( diff < counters[5].CycleT ) return;
|
if( diff < counters[5].CycleT ) return false;
|
||||||
|
|
||||||
//iopBranchAction = 1;
|
//iopBranchAction = 1;
|
||||||
if (counters[5].modeval == MODE_VSYNC)
|
if (counters[5].modeval == MODE_VSYNC)
|
||||||
|
@ -511,7 +511,8 @@ __forceinline void rcntUpdate_vSync()
|
||||||
counters[5].CycleT = vSyncInfo.Render;
|
counters[5].CycleT = vSyncInfo.Render;
|
||||||
counters[5].modeval = MODE_VRENDER;
|
counters[5].modeval = MODE_VRENDER;
|
||||||
|
|
||||||
SysUpdate(); // check for and handle keyevents
|
return true;
|
||||||
|
// SysUpdate(); // check for and handle keyevents
|
||||||
}
|
}
|
||||||
else // VSYNC end / VRENDER begin
|
else // VSYNC end / VRENDER begin
|
||||||
{
|
{
|
||||||
|
@ -534,8 +535,8 @@ __forceinline void rcntUpdate_vSync()
|
||||||
vblankinc = 0;
|
vblankinc = 0;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __forceinline void __fastcall _cpuTestTarget( int i )
|
static __forceinline void __fastcall _cpuTestTarget( int i )
|
||||||
|
@ -576,15 +577,13 @@ static __forceinline void _cpuTestOverflow( int i )
|
||||||
// forceinline note: this method is called from two locations, but one
|
// forceinline note: this method is called from two locations, but one
|
||||||
// of them is the interpreter, which doesn't count. ;) So might as
|
// of them is the interpreter, which doesn't count. ;) So might as
|
||||||
// well forceinline it!
|
// well forceinline it!
|
||||||
__forceinline void rcntUpdate()
|
__forceinline bool rcntUpdate()
|
||||||
{
|
{
|
||||||
int i;
|
bool retval = rcntUpdate_vSync();
|
||||||
|
|
||||||
rcntUpdate_vSync();
|
|
||||||
|
|
||||||
// Update counters so that we can perform overflow and target tests.
|
// Update counters so that we can perform overflow and target tests.
|
||||||
|
|
||||||
for (i=0; i<=3; i++) {
|
for (int i=0; i<=3; i++) {
|
||||||
|
|
||||||
// We want to count gated counters (except the hblank which exclude below, and are
|
// We want to count gated counters (except the hblank which exclude below, and are
|
||||||
// counted by the hblank timer instead)
|
// counted by the hblank timer instead)
|
||||||
|
@ -609,8 +608,8 @@ __forceinline void rcntUpdate()
|
||||||
else counters[i].sCycleT = cpuRegs.cycle;
|
else counters[i].sCycleT = cpuRegs.cycle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cpuRcntSet();
|
cpuRcntSet();
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _rcntSetGate( int index )
|
static void _rcntSetGate( int index )
|
||||||
|
|
|
@ -131,8 +131,8 @@ extern s32 nextCounter; // delta until the next counter event (must be signed)
|
||||||
extern u32 nextsCounter;
|
extern u32 nextsCounter;
|
||||||
|
|
||||||
extern void rcntUpdate_hScanline();
|
extern void rcntUpdate_hScanline();
|
||||||
extern void rcntUpdate_vSync();
|
extern bool rcntUpdate_vSync();
|
||||||
extern void rcntUpdate();
|
extern bool rcntUpdate();
|
||||||
|
|
||||||
void rcntInit();
|
void rcntInit();
|
||||||
void rcntStartGate(unsigned int mode, u32 sCycle);
|
void rcntStartGate(unsigned int mode, u32 sCycle);
|
||||||
|
|
|
@ -779,7 +779,7 @@ int __Deci2Call(int call, u32 *addr) {
|
||||||
else pdeciaddr += (deci2addr[4]+0xc)%16;
|
else pdeciaddr += (deci2addr[4]+0xc)%16;
|
||||||
memcpy(deci2buffer, pdeciaddr, deci2addr[1]-0xc);
|
memcpy(deci2buffer, pdeciaddr, deci2addr[1]-0xc);
|
||||||
deci2buffer[deci2addr[1]-0xc>=255?255:deci2addr[1]-0xc]='\0';
|
deci2buffer[deci2addr[1]-0xc>=255?255:deci2addr[1]-0xc]='\0';
|
||||||
SysPrintf(deci2buffer);
|
Console::Write( Color_Cyan, deci2buffer );
|
||||||
}
|
}
|
||||||
deci2addr[3] = 0;
|
deci2addr[3] = 0;
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -157,9 +157,8 @@ static void ReserveExtraMem( void* base, uint size )
|
||||||
throw vm_alloc_failed_exception( base, size, pExtraMem);
|
throw vm_alloc_failed_exception( base, size, pExtraMem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void memAlloc() {
|
void memAlloc()
|
||||||
|
{
|
||||||
int i;
|
|
||||||
LPVOID pExtraMem = NULL;
|
LPVOID pExtraMem = NULL;
|
||||||
|
|
||||||
// release the previous reserved mem
|
// release the previous reserved mem
|
||||||
|
@ -411,7 +410,6 @@ OtherException:
|
||||||
if( ExceptionRecord->ExceptionInformation[0] ) {
|
if( ExceptionRecord->ExceptionInformation[0] ) {
|
||||||
//SKIP_WRITE();
|
//SKIP_WRITE();
|
||||||
// shouldn't be writing
|
// shouldn't be writing
|
||||||
SysPrintf("Exception: Write\n"); // Naruto Ultimate Ninja 3 crashes right after a write!
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SysPrintf("vmhack ");
|
SysPrintf("vmhack ");
|
||||||
|
@ -2607,8 +2605,6 @@ static u8* m_psAllMem = NULL;
|
||||||
void memAlloc()
|
void memAlloc()
|
||||||
{
|
{
|
||||||
#ifdef __LINUX__
|
#ifdef __LINUX__
|
||||||
InstallLinuxExceptionHandler();
|
|
||||||
|
|
||||||
// For Linux we need to use the system virtual memory mapper so that we
|
// For Linux we need to use the system virtual memory mapper so that we
|
||||||
// can coerce an allocation below the 2GB line.
|
// can coerce an allocation below the 2GB line.
|
||||||
|
|
||||||
|
@ -2710,14 +2706,8 @@ void loadBiosRom( const char *ext, u8 *dest, long maxSize )
|
||||||
void memReset()
|
void memReset()
|
||||||
{
|
{
|
||||||
#ifdef PCSX2_VIRTUAL_MEM
|
#ifdef PCSX2_VIRTUAL_MEM
|
||||||
|
|
||||||
DWORD OldProtect;
|
|
||||||
|
|
||||||
memset(PS2MEM_BASE, 0, Ps2MemSize::Base);
|
|
||||||
memset(PS2MEM_SCRATCH, 0, Ps2MemSize::Scratch);
|
|
||||||
vm_Reset();
|
|
||||||
|
|
||||||
# ifdef _WIN32
|
# ifdef _WIN32
|
||||||
|
DWORD OldProtect;
|
||||||
// make sure can write
|
// make sure can write
|
||||||
VirtualProtect(PS2MEM_ROM, Ps2MemSize::Rom, PAGE_READWRITE, &OldProtect);
|
VirtualProtect(PS2MEM_ROM, Ps2MemSize::Rom, PAGE_READWRITE, &OldProtect);
|
||||||
VirtualProtect(PS2MEM_ROM1, Ps2MemSize::Rom1, PAGE_READWRITE, &OldProtect);
|
VirtualProtect(PS2MEM_ROM1, Ps2MemSize::Rom1, PAGE_READWRITE, &OldProtect);
|
||||||
|
@ -2730,8 +2720,22 @@ void memReset()
|
||||||
mprotect(PS2EMEM_EROM, Ps2MemSize::ERom, PROT_READ|PROT_WRITE);
|
mprotect(PS2EMEM_EROM, Ps2MemSize::ERom, PROT_READ|PROT_WRITE);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
memset(PS2MEM_BASE, 0, Ps2MemSize::Base);
|
||||||
|
memset(PS2MEM_SCRATCH, 0, Ps2MemSize::Scratch);
|
||||||
|
vm_Reset();
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
// VTLB Protection Preparations.
|
||||||
|
|
||||||
|
# ifdef _WIN32
|
||||||
|
DWORD OldProtect;
|
||||||
|
// make sure can write
|
||||||
|
VirtualProtect(m_psAllMem, m_allMemSize, PAGE_READWRITE, &OldProtect);
|
||||||
|
# else
|
||||||
|
mprotect(m_psAllMem, m_allMemSize, PROT_READ|PROT_WRITE);
|
||||||
|
# endif
|
||||||
|
|
||||||
// Note!! Ideally the vtlb should only be initialized once, and then subsequent
|
// Note!! Ideally the vtlb should only be initialized once, and then subsequent
|
||||||
// resets of the system hardware would only clear vtlb mappings, but since the
|
// resets of the system hardware would only clear vtlb mappings, but since the
|
||||||
// rest of the emu is not really set up to support a "soft" reset of that sort
|
// rest of the emu is not really set up to support a "soft" reset of that sort
|
||||||
|
|
|
@ -448,7 +448,7 @@ u32 g_nextBranchCycle = 0;
|
||||||
|
|
||||||
// Shared portion of the branch test, called from both the Interpreter
|
// Shared portion of the branch test, called from both the Interpreter
|
||||||
// and the recompiler. (moved here to help alleviate redundant code)
|
// and the recompiler. (moved here to help alleviate redundant code)
|
||||||
static __forceinline void _cpuBranchTest_Shared()
|
__forceinline bool _cpuBranchTest_Shared()
|
||||||
{
|
{
|
||||||
EventTestIsActive = true;
|
EventTestIsActive = true;
|
||||||
g_nextBranchCycle = cpuRegs.cycle + eeWaitCycles;
|
g_nextBranchCycle = cpuRegs.cycle + eeWaitCycles;
|
||||||
|
@ -460,12 +460,12 @@ static __forceinline void _cpuBranchTest_Shared()
|
||||||
iopBranchAction = true;
|
iopBranchAction = true;
|
||||||
|
|
||||||
// ---- Counters -------------
|
// ---- Counters -------------
|
||||||
|
bool vsyncEvent = false;
|
||||||
rcntUpdate_hScanline();
|
rcntUpdate_hScanline();
|
||||||
|
|
||||||
if( cpuTestCycle( nextsCounter, nextCounter ) )
|
if( cpuTestCycle( nextsCounter, nextCounter ) )
|
||||||
{
|
{
|
||||||
rcntUpdate();
|
vsyncEvent = rcntUpdate();
|
||||||
_cpuTestPERF();
|
_cpuTestPERF();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -577,31 +577,8 @@ static __forceinline void _cpuBranchTest_Shared()
|
||||||
TESTINT(30, intcInterrupt);
|
TESTINT(30, intcInterrupt);
|
||||||
TESTINT(31, dmacInterrupt);
|
TESTINT(31, dmacInterrupt);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void cpuBranchTest()
|
return vsyncEvent;
|
||||||
{
|
|
||||||
// cpuBranchTest should be called from the recompiler only.
|
|
||||||
assert( Cpu == &recCpu );
|
|
||||||
|
|
||||||
#ifdef PCSX2_DEVBUILD
|
|
||||||
// dont' remove this check unless doing an official release
|
|
||||||
if( g_globalXMMSaved || g_globalMMXSaved)
|
|
||||||
DevCon::Error("Pcsx2 Foopah! Frozen regs have not been restored!!!");
|
|
||||||
assert( !g_globalXMMSaved && !g_globalMMXSaved);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Don't need to freeze any regs during a BranchTest.
|
|
||||||
// Everything has been flushed already.
|
|
||||||
g_EEFreezeRegs = false;
|
|
||||||
|
|
||||||
// Perform counters, ints, and IOP updates:
|
|
||||||
_cpuBranchTest_Shared();
|
|
||||||
|
|
||||||
#ifdef PCSX2_DEVBUILD
|
|
||||||
assert( !g_globalXMMSaved && !g_globalMMXSaved);
|
|
||||||
#endif
|
|
||||||
g_EEFreezeRegs = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cpuTestINTCInts()
|
void cpuTestINTCInts()
|
||||||
|
|
|
@ -224,8 +224,9 @@ void cpuException(u32 code, u32 bd);
|
||||||
void cpuTlbMissR(u32 addr, u32 bd);
|
void cpuTlbMissR(u32 addr, u32 bd);
|
||||||
void cpuTlbMissW(u32 addr, u32 bd);
|
void cpuTlbMissW(u32 addr, u32 bd);
|
||||||
void IntcpuBranchTest();
|
void IntcpuBranchTest();
|
||||||
void cpuBranchTest();
|
extern void cpuTestHwInts();
|
||||||
void cpuTestHwInts();
|
|
||||||
|
extern bool _cpuBranchTest_Shared(); // for internal use by the Dynarecs and Ints inside R5900:
|
||||||
|
|
||||||
extern void cpuTestINTCInts();
|
extern void cpuTestINTCInts();
|
||||||
extern void cpuTestDMACInts();
|
extern void cpuTestDMACInts();
|
||||||
|
|
|
@ -52,12 +52,21 @@ void SysMunmap(uptr base, u32 size);
|
||||||
// *DEPRECIATED* Use Console namespace methods instead.
|
// *DEPRECIATED* Use Console namespace methods instead.
|
||||||
void SysPrintf(const char *fmt, ...); // *DEPRECIATED*
|
void SysPrintf(const char *fmt, ...); // *DEPRECIATED*
|
||||||
|
|
||||||
|
|
||||||
static __forceinline void SysMunmap( void* base, u32 size )
|
static __forceinline void SysMunmap( void* base, u32 size )
|
||||||
{
|
{
|
||||||
SysMunmap( (uptr)base, size );
|
SysMunmap( (uptr)base, size );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
# define PCSX2_MEM_PROTECT_BEGIN() __try {
|
||||||
|
# define PCSX2_MEM_PROTECT_END() } __except(SysPageFaultExceptionFilter(GetExceptionInformation())) {}
|
||||||
|
#else
|
||||||
|
# define PCSX2_MEM_PROTECT_BEGIN() InstallLinuxExceptionHandler()
|
||||||
|
# define PCSX2_MEM_PROTECT_END() ReleaseLinuxExceptionHandler()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Console Namespace -- Replacements for SysPrintf.
|
// Console Namespace -- Replacements for SysPrintf.
|
||||||
// SysPrintf is depreciated -- We should phase these in over time.
|
// SysPrintf is depreciated -- We should phase these in over time.
|
||||||
namespace Console
|
namespace Console
|
||||||
|
|
|
@ -146,6 +146,8 @@ void vuMicroMemReset()
|
||||||
jASSUME( VU0.Mem != NULL );
|
jASSUME( VU0.Mem != NULL );
|
||||||
jASSUME( VU1.Mem != NULL );
|
jASSUME( VU1.Mem != NULL );
|
||||||
|
|
||||||
|
PCSX2_MEM_PROTECT_BEGIN();
|
||||||
|
|
||||||
// === VU0 Initialization ===
|
// === VU0 Initialization ===
|
||||||
memset(&VU0.ACC, 0, sizeof(VECTOR));
|
memset(&VU0.ACC, 0, sizeof(VECTOR));
|
||||||
memset(VU0.VF, 0, sizeof(VECTOR)*32);
|
memset(VU0.VF, 0, sizeof(VECTOR)*32);
|
||||||
|
@ -187,6 +189,8 @@ void vuMicroMemReset()
|
||||||
// VU1.VI = (REG_VI*)(VU0.Mem + 0x4200);
|
// VU1.VI = (REG_VI*)(VU0.Mem + 0x4200);
|
||||||
VU1.vuExec = vu1Exec;
|
VU1.vuExec = vu1Exec;
|
||||||
VU1.vifRegs = vif1Regs;
|
VU1.vifRegs = vif1Regs;
|
||||||
|
|
||||||
|
PCSX2_MEM_PROTECT_END();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveState::vuMicroFreeze()
|
void SaveState::vuMicroFreeze()
|
||||||
|
|
|
@ -87,8 +87,8 @@ BOOL CALLBACK CpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
SetDlgItemText(hW, IDC_FEATURESINPUT, features);
|
SetDlgItemText(hW, IDC_FEATURESINPUT, features);
|
||||||
|
|
||||||
CheckDlgButton(hW, IDC_CPU_EEREC, !!(Config.Options&PCSX2_EEREC));
|
CheckDlgButton(hW, IDC_CPU_EEREC, !!(Config.Options&PCSX2_EEREC));
|
||||||
CheckDlgButton(hW, IDC_CPU_VU0REC, !!(Config.Options&CHECK_VU0REC));
|
CheckDlgButton(hW, IDC_CPU_VU0REC, !!(Config.Options&PCSX2_VU0REC));
|
||||||
CheckDlgButton(hW, IDC_CPU_VU1REC, !!(Config.Options&CHECK_VU1REC));
|
CheckDlgButton(hW, IDC_CPU_VU1REC, !!(Config.Options&PCSX2_VU1REC));
|
||||||
|
|
||||||
EnableDlgItem( hW, IDC_CPU_EEREC, !g_Session.ForceDisableEErec );
|
EnableDlgItem( hW, IDC_CPU_EEREC, !g_Session.ForceDisableEErec );
|
||||||
EnableDlgItem( hW, IDC_CPU_VU0REC, !g_Session.ForceDisableVU0rec );
|
EnableDlgItem( hW, IDC_CPU_VU0REC, !g_Session.ForceDisableVU0rec );
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
AdditionalIncludeDirectories="$(SolutionDir)\common"
|
AdditionalIncludeDirectories="$(SolutionDir)\common"
|
||||||
PreprocessorDefinitions="NDEBUG,WIN32_PTHREADS"
|
PreprocessorDefinitions="NDEBUG,WIN32_PTHREADS"
|
||||||
|
ExceptionHandling="2"
|
||||||
SmallerTypeCheck="false"
|
SmallerTypeCheck="false"
|
||||||
BufferSecurityCheck="false"
|
BufferSecurityCheck="false"
|
||||||
UsePrecompiledHeader="2"
|
UsePrecompiledHeader="2"
|
||||||
|
@ -137,6 +138,7 @@
|
||||||
AdditionalIncludeDirectories="$(SolutionDir)\common"
|
AdditionalIncludeDirectories="$(SolutionDir)\common"
|
||||||
PreprocessorDefinitions="WIN32_PTHREADS"
|
PreprocessorDefinitions="WIN32_PTHREADS"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
|
ExceptionHandling="2"
|
||||||
SmallerTypeCheck="false"
|
SmallerTypeCheck="false"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
UsePrecompiledHeader="2"
|
UsePrecompiledHeader="2"
|
||||||
|
@ -220,6 +222,7 @@
|
||||||
AdditionalIncludeDirectories="$(SolutionDir)\common"
|
AdditionalIncludeDirectories="$(SolutionDir)\common"
|
||||||
PreprocessorDefinitions="WIN32_PTHREADS"
|
PreprocessorDefinitions="WIN32_PTHREADS"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
|
ExceptionHandling="2"
|
||||||
SmallerTypeCheck="false"
|
SmallerTypeCheck="false"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
UsePrecompiledHeader="2"
|
UsePrecompiledHeader="2"
|
||||||
|
@ -311,6 +314,7 @@
|
||||||
AdditionalIncludeDirectories="$(SolutionDir)\common"
|
AdditionalIncludeDirectories="$(SolutionDir)\common"
|
||||||
PreprocessorDefinitions="NDEBUG;WIN32_PTHREADS"
|
PreprocessorDefinitions="NDEBUG;WIN32_PTHREADS"
|
||||||
StringPooling="true"
|
StringPooling="true"
|
||||||
|
ExceptionHandling="2"
|
||||||
SmallerTypeCheck="false"
|
SmallerTypeCheck="false"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
StructMemberAlignment="5"
|
StructMemberAlignment="5"
|
||||||
|
@ -398,6 +402,7 @@
|
||||||
EnableFiberSafeOptimizations="true"
|
EnableFiberSafeOptimizations="true"
|
||||||
AdditionalIncludeDirectories="$(SolutionDir)\common"
|
AdditionalIncludeDirectories="$(SolutionDir)\common"
|
||||||
PreprocessorDefinitions="NDEBUG,WIN32_PTHREADS"
|
PreprocessorDefinitions="NDEBUG,WIN32_PTHREADS"
|
||||||
|
ExceptionHandling="2"
|
||||||
SmallerTypeCheck="false"
|
SmallerTypeCheck="false"
|
||||||
BufferSecurityCheck="false"
|
BufferSecurityCheck="false"
|
||||||
EnableEnhancedInstructionSet="0"
|
EnableEnhancedInstructionSet="0"
|
||||||
|
@ -482,6 +487,7 @@
|
||||||
EnableFiberSafeOptimizations="true"
|
EnableFiberSafeOptimizations="true"
|
||||||
AdditionalIncludeDirectories="$(SolutionDir)\common"
|
AdditionalIncludeDirectories="$(SolutionDir)\common"
|
||||||
PreprocessorDefinitions="NDEBUG,WIN32_PTHREADS"
|
PreprocessorDefinitions="NDEBUG,WIN32_PTHREADS"
|
||||||
|
ExceptionHandling="2"
|
||||||
SmallerTypeCheck="false"
|
SmallerTypeCheck="false"
|
||||||
BufferSecurityCheck="false"
|
BufferSecurityCheck="false"
|
||||||
EnableEnhancedInstructionSet="0"
|
EnableEnhancedInstructionSet="0"
|
||||||
|
@ -598,11 +604,7 @@
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="3"
|
BufferSecurityCheck="false"
|
||||||
FavorSizeOrSpeed="2"
|
|
||||||
OmitFramePointers="false"
|
|
||||||
EnableFiberSafeOptimizations="false"
|
|
||||||
ExceptionHandling="0"
|
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
/>
|
/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
|
@ -611,7 +613,6 @@
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
ExceptionHandling="0"
|
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
/>
|
/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
|
@ -620,7 +621,6 @@
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
ExceptionHandling="0"
|
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
/>
|
/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
|
@ -629,11 +629,7 @@
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="3"
|
BufferSecurityCheck="false"
|
||||||
FavorSizeOrSpeed="2"
|
|
||||||
OmitFramePointers="false"
|
|
||||||
EnableFiberSafeOptimizations="false"
|
|
||||||
ExceptionHandling="0"
|
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
/>
|
/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
|
@ -642,11 +638,7 @@
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="3"
|
BufferSecurityCheck="false"
|
||||||
FavorSizeOrSpeed="2"
|
|
||||||
OmitFramePointers="false"
|
|
||||||
EnableFiberSafeOptimizations="false"
|
|
||||||
ExceptionHandling="0"
|
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
/>
|
/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
|
@ -655,11 +647,7 @@
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="3"
|
BufferSecurityCheck="false"
|
||||||
FavorSizeOrSpeed="2"
|
|
||||||
OmitFramePointers="false"
|
|
||||||
EnableFiberSafeOptimizations="false"
|
|
||||||
ExceptionHandling="0"
|
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
/>
|
/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
|
@ -672,10 +660,7 @@
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="3"
|
BufferSecurityCheck="false"
|
||||||
FavorSizeOrSpeed="2"
|
|
||||||
OmitFramePointers="false"
|
|
||||||
EnableFiberSafeOptimizations="false"
|
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
/>
|
/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
|
@ -684,10 +669,7 @@
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="3"
|
BufferSecurityCheck="false"
|
||||||
FavorSizeOrSpeed="2"
|
|
||||||
OmitFramePointers="false"
|
|
||||||
EnableFiberSafeOptimizations="false"
|
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
/>
|
/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
|
@ -696,10 +678,7 @@
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="3"
|
BufferSecurityCheck="false"
|
||||||
FavorSizeOrSpeed="2"
|
|
||||||
OmitFramePointers="false"
|
|
||||||
EnableFiberSafeOptimizations="false"
|
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
/>
|
/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
|
@ -708,10 +687,7 @@
|
||||||
>
|
>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="3"
|
BufferSecurityCheck="false"
|
||||||
FavorSizeOrSpeed="2"
|
|
||||||
OmitFramePointers="false"
|
|
||||||
EnableFiberSafeOptimizations="false"
|
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
/>
|
/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
AdditionalIncludeDirectories=""$(InputDir)""
|
AdditionalIncludeDirectories=""$(InputDir)""
|
||||||
PreprocessorDefinitions="PTW32_STATIC_LIB;WIN32;_DEBUG;_LIB"
|
PreprocessorDefinitions="PTW32_STATIC_LIB;WIN32;_DEBUG;_LIB"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
ExceptionHandling="0"
|
ExceptionHandling="2"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="1"
|
RuntimeLibrary="1"
|
||||||
StructMemberAlignment="5"
|
StructMemberAlignment="5"
|
||||||
|
@ -118,7 +118,7 @@
|
||||||
PreprocessorDefinitions="PTW32_STATIC_LIB;PTW32_BUILD_INLINED;WIN32;NDEBUG;_LIB"
|
PreprocessorDefinitions="PTW32_STATIC_LIB;PTW32_BUILD_INLINED;WIN32;NDEBUG;_LIB"
|
||||||
StringPooling="true"
|
StringPooling="true"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
ExceptionHandling="0"
|
ExceptionHandling="2"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
StructMemberAlignment="5"
|
StructMemberAlignment="5"
|
||||||
BufferSecurityCheck="false"
|
BufferSecurityCheck="false"
|
||||||
|
|
|
@ -118,7 +118,6 @@ namespace Console
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Msgbox
|
namespace Msgbox
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
// and it's usually user error, but in this case I'm pretty sure I found one.
|
// and it's usually user error, but in this case I'm pretty sure I found one.
|
||||||
// So put your c++ exception code in WinSysExec.cpp. It's better that way. :D (air)
|
// So put your c++ exception code in WinSysExec.cpp. It's better that way. :D (air)
|
||||||
|
|
||||||
// Disabled warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
|
|
||||||
#pragma warning(disable:4530)
|
|
||||||
|
|
||||||
#include "PrecompiledHeader.h"
|
#include "PrecompiledHeader.h"
|
||||||
#include "win32.h"
|
#include "win32.h"
|
||||||
|
@ -201,6 +199,21 @@ void WinClose()
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*class SehException
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
uint m_code;
|
||||||
|
const _EXCEPTION_POINTERS& m_info;
|
||||||
|
|
||||||
|
public:
|
||||||
|
SehException(uint code, const _EXCEPTION_POINTERS& eptr ) : m_code(code), m_info(eptr) { }
|
||||||
|
};
|
||||||
|
|
||||||
|
void SehTranslatorFunction( uint code, _EXCEPTION_POINTERS* eptr )
|
||||||
|
{
|
||||||
|
throw SehException( code, *eptr );
|
||||||
|
}*/
|
||||||
|
|
||||||
BOOL SysLoggedSetLockPagesPrivilege ( HANDLE hProcess, BOOL bEnable);
|
BOOL SysLoggedSetLockPagesPrivilege ( HANDLE hProcess, BOOL bEnable);
|
||||||
|
|
||||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
||||||
|
@ -246,9 +259,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||||
|
|
||||||
_getcwd( g_WorkingFolder, g_MaxPath );
|
_getcwd( g_WorkingFolder, g_MaxPath );
|
||||||
|
|
||||||
__try
|
|
||||||
{
|
|
||||||
|
|
||||||
int argc;
|
int argc;
|
||||||
TCHAR *const *const argv = _CommandLineToArgv( lpCmdLine, &argc );
|
TCHAR *const *const argv = _CommandLineToArgv( lpCmdLine, &argc );
|
||||||
|
|
||||||
|
@ -389,10 +399,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||||
LoadPatch("default");
|
LoadPatch("default");
|
||||||
RunGui();
|
RunGui();
|
||||||
|
|
||||||
}
|
/*}
|
||||||
__except(SysPageFaultExceptionFilter(GetExceptionInformation()))
|
catch( SehException& ex )
|
||||||
{
|
{
|
||||||
}
|
SysPageFaultExceptionFilter( ex.m_info );
|
||||||
|
}*/
|
||||||
|
|
||||||
// Note : Because of how the GUI and recompiler function, this area of
|
// Note : Because of how the GUI and recompiler function, this area of
|
||||||
// the code is effectively unreachable. Program termination is handled
|
// the code is effectively unreachable. Program termination is handled
|
||||||
|
|
|
@ -16,11 +16,6 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// NOTE : This file was created to separate code that uses C++ exceptions from the
|
|
||||||
// WinMain procedure in WinMain.cpp. Apparently MSVC handles not so well the idea
|
|
||||||
// of both __try/__except and try/catch in the same module. (yup, I ran into a
|
|
||||||
// dreaded compiler bug).
|
|
||||||
|
|
||||||
#include "PrecompiledHeader.h"
|
#include "PrecompiledHeader.h"
|
||||||
#include "win32.h"
|
#include "win32.h"
|
||||||
|
|
||||||
|
@ -197,7 +192,11 @@ void ExecuteCpu()
|
||||||
g_GameInProgress = true;
|
g_GameInProgress = true;
|
||||||
if( !m_EmuStateActive )
|
if( !m_EmuStateActive )
|
||||||
{
|
{
|
||||||
Cpu->Execute();
|
while( true )
|
||||||
|
{
|
||||||
|
Cpu->Execute();
|
||||||
|
SysUpdate();
|
||||||
|
}
|
||||||
g_GameInProgress = false;
|
g_GameInProgress = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -214,9 +213,6 @@ void RunExecute( const char* elf_file, bool use_bios )
|
||||||
|
|
||||||
g_GameInProgress = false;
|
g_GameInProgress = false;
|
||||||
|
|
||||||
if (OpenPlugins(g_TestRun.ptitle) == -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
cpuReset();
|
cpuReset();
|
||||||
|
@ -227,18 +223,15 @@ void RunExecute( const char* elf_file, bool use_bios )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (OpenPlugins(g_TestRun.ptitle) == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
if( elf_file == NULL )
|
if( elf_file == NULL )
|
||||||
{
|
{
|
||||||
if(g_RecoveryState != NULL)
|
if(g_RecoveryState != NULL)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
/*string Text;
|
|
||||||
SaveState::GetFilename( Text, 9 );
|
|
||||||
gzLoadingState joe( Text ); // throws exception on version mismatch
|
|
||||||
R5900::cpuReset();
|
|
||||||
joe.FreezeAll();*/
|
|
||||||
|
|
||||||
memLoadingState( *g_RecoveryState ).FreezeAll();
|
memLoadingState( *g_RecoveryState ).FreezeAll();
|
||||||
}
|
}
|
||||||
catch( std::runtime_error& ex )
|
catch( std::runtime_error& ex )
|
||||||
|
|
|
@ -639,7 +639,9 @@ static void execute( void )
|
||||||
__asm call pfn;
|
__asm call pfn;
|
||||||
__asm pop ebp; // restore ebp for the reason above
|
__asm pop ebp; // restore ebp for the reason above
|
||||||
#else
|
#else
|
||||||
|
__asm__("push %%ebp\n");
|
||||||
((R5900FNPTR)pblock->pFnptr)();
|
((R5900FNPTR)pblock->pFnptr)();
|
||||||
|
__asm__("pop %%ebp\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -650,15 +652,41 @@ static void execute( void )
|
||||||
void recStep( void ) {
|
void recStep( void ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void recExecute( void ) {
|
static __forceinline bool recEventTest()
|
||||||
if( Config.Options & PCSX2_EEREC ) Config.Options |= PCSX2_COP2REC;
|
{
|
||||||
|
#ifdef PCSX2_DEVBUILD
|
||||||
|
// dont' remove this check unless doing an official release
|
||||||
|
if( g_globalXMMSaved || g_globalMMXSaved)
|
||||||
|
DevCon::Error("Pcsx2 Foopah! Frozen regs have not been restored!!!");
|
||||||
|
assert( !g_globalXMMSaved && !g_globalMMXSaved);
|
||||||
|
#endif
|
||||||
|
|
||||||
for (;;)
|
// Perform counters, ints, and IOP updates:
|
||||||
execute();
|
bool retval = ::R5900::_cpuBranchTest_Shared();
|
||||||
|
|
||||||
|
#ifdef PCSX2_DEVBUILD
|
||||||
|
assert( !g_globalXMMSaved && !g_globalMMXSaved);
|
||||||
|
#endif
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void recExecuteBlock( void ) {
|
static void recExecute( void )
|
||||||
execute();
|
{
|
||||||
|
PCSX2_MEM_PROTECT_BEGIN()
|
||||||
|
while( true )
|
||||||
|
{
|
||||||
|
if( recEventTest() ) break;
|
||||||
|
execute();
|
||||||
|
}
|
||||||
|
PCSX2_MEM_PROTECT_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
static void recExecuteBlock( void )
|
||||||
|
{
|
||||||
|
PCSX2_MEM_PROTECT_BEGIN()
|
||||||
|
recEventTest();
|
||||||
|
execute();
|
||||||
|
PCSX2_MEM_PROTECT_END()
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
|
@ -710,8 +738,8 @@ CheckPtr:
|
||||||
// }
|
// }
|
||||||
__asm {
|
__asm {
|
||||||
and eax, 0x0fffffff
|
and eax, 0x0fffffff
|
||||||
mov edx, eax
|
|
||||||
pop ecx // x86Ptr to mod
|
pop ecx // x86Ptr to mod
|
||||||
|
mov edx, eax
|
||||||
sub edx, ecx
|
sub edx, ecx
|
||||||
sub edx, 4
|
sub edx, 4
|
||||||
mov dword ptr [ecx], edx
|
mov dword ptr [ecx], edx
|
||||||
|
@ -735,8 +763,8 @@ __declspec(naked,noreturn) void DispatcherClear()
|
||||||
// already modded the code, jump to the new place
|
// already modded the code, jump to the new place
|
||||||
__asm {
|
__asm {
|
||||||
pop edx
|
pop edx
|
||||||
add esp, 4 // ignore stack
|
|
||||||
mov eax, s_pDispatchBlock
|
mov eax, s_pDispatchBlock
|
||||||
|
add esp, 4 // ignore stack
|
||||||
mov eax, dword ptr [eax]
|
mov eax, dword ptr [eax]
|
||||||
and eax, 0x0fffffff
|
and eax, 0x0fffffff
|
||||||
jmp eax
|
jmp eax
|
||||||
|
@ -987,14 +1015,12 @@ void SetBranchReg( u32 reg )
|
||||||
iFlushCall(FLUSH_EVERYTHING);
|
iFlushCall(FLUSH_EVERYTHING);
|
||||||
|
|
||||||
iBranchTest(0xffffffff, 1);
|
iBranchTest(0xffffffff, 1);
|
||||||
if( bExecBIOS ) CheckForBIOSEnd();
|
|
||||||
|
|
||||||
JMP32((u32)DispatcherReg - ( (u32)x86Ptr + 5 ));
|
JMP32((u32)DispatcherReg - ( (u32)x86Ptr + 5 ));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetBranchImm( u32 imm )
|
void SetBranchImm( u32 imm )
|
||||||
{
|
{
|
||||||
u32* ptr;
|
|
||||||
branch = 1;
|
branch = 1;
|
||||||
|
|
||||||
assert( imm );
|
assert( imm );
|
||||||
|
@ -1004,10 +1030,9 @@ void SetBranchImm( u32 imm )
|
||||||
iFlushCall(FLUSH_EVERYTHING);
|
iFlushCall(FLUSH_EVERYTHING);
|
||||||
|
|
||||||
iBranchTest(imm, imm <= pc);
|
iBranchTest(imm, imm <= pc);
|
||||||
if( bExecBIOS ) CheckForBIOSEnd();
|
|
||||||
|
|
||||||
MOV32ItoR(EDX, 0);
|
MOV32ItoR(EDX, 0);
|
||||||
ptr = (u32*)(x86Ptr-4);
|
u32* ptr = (u32*)(x86Ptr-4);
|
||||||
*ptr = (u32)JMP32((u32)Dispatcher - ( (u32)x86Ptr + 5 ));
|
*ptr = (u32)JMP32((u32)Dispatcher - ( (u32)x86Ptr + 5 ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1161,17 +1186,25 @@ static void iBranchTest(u32 newpc, u32 cpuBranch)
|
||||||
|
|
||||||
// check if should branch
|
// check if should branch
|
||||||
j8Ptr[0] = JS8( 0 );
|
j8Ptr[0] = JS8( 0 );
|
||||||
|
RET();
|
||||||
|
|
||||||
|
/*if( newpc != 0xffffffff )
|
||||||
|
JNS32( (uptr)eventTestReg - ( (uptr)x86Ptr + 6 ) );
|
||||||
|
else
|
||||||
|
JNS32( (uptr)eventTest - ( (uptr)x86Ptr + 6 ) );*/
|
||||||
|
|
||||||
|
|
||||||
// has to be in the middle of Save/LoadBranchState
|
// has to be in the middle of Save/LoadBranchState
|
||||||
CALLFunc( (uptr)cpuBranchTest );
|
/*CALLFunc( (uptr)cpuBranchTest );
|
||||||
|
|
||||||
if( newpc != 0xffffffff )
|
if( newpc != 0xffffffff )
|
||||||
{
|
{
|
||||||
CMP32ItoM((uptr)&cpuRegs.pc, newpc);
|
CMP32ItoM((uptr)&cpuRegs.pc, newpc);
|
||||||
JNE32((uptr)DispatcherReg - ( (uptr)x86Ptr + 6 ));
|
JNE32((uptr)DispatcherReg - ( (uptr)x86Ptr + 6 ));
|
||||||
}
|
}*/
|
||||||
|
|
||||||
x86SetJ8( j8Ptr[0] );
|
x86SetJ8( j8Ptr[0] );
|
||||||
|
if( bExecBIOS ) CheckForBIOSEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace OpcodeImpl
|
namespace OpcodeImpl
|
||||||
|
@ -2111,7 +2144,6 @@ StartRecomp:
|
||||||
iFlushCall(FLUSH_EVERYTHING);
|
iFlushCall(FLUSH_EVERYTHING);
|
||||||
|
|
||||||
iBranchTest(0xffffffff, 1);
|
iBranchTest(0xffffffff, 1);
|
||||||
if( bExecBIOS ) CheckForBIOSEnd();
|
|
||||||
|
|
||||||
JMP32((uptr)DispatcherReg - ( (uptr)x86Ptr + 5 ));
|
JMP32((uptr)DispatcherReg - ( (uptr)x86Ptr + 5 ));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue