From 323af0ebb287afe84fb8424fa61acbd3314f999f Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Tue, 4 Nov 2008 14:28:39 +0000 Subject: [PATCH] Fixed stupid typo in r289's EE counter that probably broke lots of things. Made a couple code cleanups of the IOP (no functional changes). git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@291 a6443dda-0b58-4228-96e9-037be469359c --- pcsx2/Counters.c | 6 +++--- pcsx2/R3000A.c | 4 ---- pcsx2/x86/iR3000A.cpp | 36 ++++++++++++++++++++---------------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/pcsx2/Counters.c b/pcsx2/Counters.c index 8264db0b79..4053b3d254 100644 --- a/pcsx2/Counters.c +++ b/pcsx2/Counters.c @@ -56,19 +56,19 @@ static __forceinline void _rcntSet( int i ) u32 c; if (!(counters[i].mode & 0x80) || (counters[i].mode & 0x3) == 0x3) return; // Stopped - // psxNextCounter is relative to the cpuRegs.cycle when rcntUpdate() was last called. + // nextCounter is relative to the cpuRegs.cycle when rcntUpdate() was last called. // However, the current _rcntSet could be called at any cycle count, so we need to take // that into account. Adding the difference from that cycle count to the current one // will do the trick! c = ((0x10000 - counters[i].count) * counters[i].rate) - (cpuRegs.cycle - counters[i].sCycleT); - c += cpuRegs.cycle - psxNextsCounter; // adjust for time passed since last rcntUpdate(); + c += cpuRegs.cycle - nextsCounter; // adjust for time passed since last rcntUpdate(); if (c < nextCounter) nextCounter = c; //if(!(counters[i].mode & 0x100) || counters[i].target > 0xffff) continue; c = ((counters[i].target - counters[i].count) * counters[i].rate) - (cpuRegs.cycle - counters[i].sCycleT); - c += cpuRegs.cycle - psxNextsCounter; // adjust for time passed since last rcntUpdate(); + c += cpuRegs.cycle - nextsCounter; // adjust for time passed since last rcntUpdate(); if (c < nextCounter) nextCounter = c; } diff --git a/pcsx2/R3000A.c b/pcsx2/R3000A.c index 1ee8ff8eb8..dd895a9c8c 100644 --- a/pcsx2/R3000A.c +++ b/pcsx2/R3000A.c @@ -144,10 +144,6 @@ void psxException(u32 code, u32 bd) { } static void _psxTestInterrupts() { - // uncommenting until refraction can give a good reason as to why it shouldn't be here - // Good reason given, why have something in there we dont use anymore? - /*PSX_TESTINT(4, psxDma4Interrupt); - PSX_TESTINT(7, psxDma7Interrupt);*/ PSX_TESTINT(9, sif0Interrupt); // SIF0 PSX_TESTINT(10, sif1Interrupt); // SIF1 diff --git a/pcsx2/x86/iR3000A.cpp b/pcsx2/x86/iR3000A.cpp index 36d147e56d..559cada299 100644 --- a/pcsx2/x86/iR3000A.cpp +++ b/pcsx2/x86/iR3000A.cpp @@ -859,9 +859,9 @@ static void recClear(u32 Addr, u32 Size) } #ifdef __x86_64__ -#define EE_MIN_BLOCK_BYTES 16 +#define IOP_MIN_BLOCK_BYTES 16 #else -#define EE_MIN_BLOCK_BYTES 15 +#define IOP_MIN_BLOCK_BYTES 15 #endif void rpsxMemConstClear(u32 mem) @@ -905,7 +905,7 @@ void psxRecClearMem(BASEBLOCK* p) PUSH32I((uptr)x86Ptr); #endif JMP32((uptr)psxDispatcherClear - ( (uptr)x86Ptr + 5 )); - assert( x86Ptr == (s8*)p->pFnptr + EE_MIN_BLOCK_BYTES ); + assert( x86Ptr == (s8*)p->pFnptr + IOP_MIN_BLOCK_BYTES ); pstart = PSX_GETBLOCK(p->startpc); pexblock = PSX_GETBLOCKEX(pstart); @@ -982,28 +982,32 @@ void psxSetBranchImm( u32 imm ) } #define USE_FAST_BRANCHES CHECK_FASTBRANCHES -#define PSXCYCLE_MULT (CHECK_IOPSYNC_HACK ? (CHECK_EE_IOP_EXTRA ? 3.1875 : 2.125) : (17/16)) // Important! The following macro makes sure the rounding error of both the psxRegs.cycle // modifier and EEsCycle modifier are consistent (in case you wonder why it's got a u32 typecast) -#define PSXCYCLE_TO_EE (((u32)(s_psxBlockCycles*PSXCYCLE_MULT)) * 8 ) // IOP to EE conversion +static u32 psxScaleBlockCycles() +{ + return s_psxBlockCycles * + (CHECK_IOPSYNC_HACK ? (CHECK_EE_IOP_EXTRA ? 3.1875 : 2.125) : (17/16)); +} static void iPsxBranchTest(u32 newpc, u32 cpuBranch) { + u32 blockCycles = psxScaleBlockCycles(); if( !USE_FAST_BRANCHES || cpuBranch ) { MOV32MtoR(ECX, (uptr)&psxRegs.cycle); - ADD32ItoR(ECX, s_psxBlockCycles*PSXCYCLE_MULT); // greater mult factor causes nfsmw to crash + ADD32ItoR(ECX, blockCycles); // greater mult factor causes nfsmw to crash MOV32RtoM((uptr)&psxRegs.cycle, ECX); // update cycles } else { - SUB32ItoM((uptr)&EEsCycle, PSXCYCLE_TO_EE ); - ADD32ItoM((uptr)&psxRegs.cycle, s_psxBlockCycles*PSXCYCLE_MULT); + SUB32ItoM((uptr)&EEsCycle, blockCycles*8 ); + ADD32ItoM((uptr)&psxRegs.cycle, blockCycles); return; } // check if we've caught up with the EE - SUB32ItoM((uptr)&EEsCycle, PSXCYCLE_TO_EE ); + SUB32ItoM((uptr)&EEsCycle, blockCycles*8 ); j8Ptr[2] = JGE8(0); // Break the Block-execute Loop here. @@ -1056,8 +1060,8 @@ void rpsxSYSCALL() CMP32ItoM((uptr)&psxRegs.pc, psxpc-4); j8Ptr[0] = JE8(0); - ADD32ItoM((uptr)&psxRegs.cycle, s_psxBlockCycles); - SUB32ItoM((uptr)&EEsCycle, PSXCYCLE_TO_EE ); + ADD32ItoM((uptr)&psxRegs.cycle, psxScaleBlockCycles() ); + SUB32ItoM((uptr)&EEsCycle, psxScaleBlockCycles()*8 ); JMP32((uptr)psxDispatcherReg - ( (uptr)x86Ptr + 5 )); x86SetJ8(j8Ptr[0]); @@ -1075,8 +1079,8 @@ void rpsxBREAK() CMP32ItoM((uptr)&psxRegs.pc, psxpc-4); j8Ptr[0] = JE8(0); - ADD32ItoM((uptr)&psxRegs.cycle, s_psxBlockCycles); - SUB32ItoM((uptr)&EEsCycle, PSXCYCLE_TO_EE ); + ADD32ItoM((uptr)&psxRegs.cycle, psxScaleBlockCycles() ); + SUB32ItoM((uptr)&EEsCycle, psxScaleBlockCycles()*8 ); JMP32((uptr)psxDispatcherReg - ( (uptr)x86Ptr + 5 )); x86SetJ8(j8Ptr[0]); @@ -1498,8 +1502,8 @@ StartRecomp: if( psxbranch ) assert( !willbranch3 ); else { - ADD32ItoM((uptr)&psxRegs.cycle, s_psxBlockCycles*PSXCYCLE_MULT); - SUB32ItoM((uptr)&EEsCycle, PSXCYCLE_TO_EE ); + ADD32ItoM((uptr)&psxRegs.cycle, psxScaleBlockCycles() ); + SUB32ItoM((uptr)&EEsCycle, psxScaleBlockCycles()*8 ); } if( willbranch3 ) { @@ -1521,7 +1525,7 @@ StartRecomp: } } - assert( x86Ptr >= (s8*)s_pCurBlock->pFnptr + EE_MIN_BLOCK_BYTES ); + assert( x86Ptr >= (s8*)s_pCurBlock->pFnptr + IOP_MIN_BLOCK_BYTES ); assert( x86Ptr < recMem+RECMEM_SIZE ); recPtr = x86Ptr;