Improved the EE/IOP counter optimization. It was causing branch tests to occur more frequently than needed.

git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@289 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
Jake.Stine 2008-11-04 00:31:32 +00:00 committed by Gregory Hainaut
parent 211829bb18
commit 0bbb879f2b
4 changed files with 20 additions and 1 deletions

View File

@ -56,12 +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.
// 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();
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();
if (c < nextCounter) nextCounter = c;
}

View File

@ -63,14 +63,21 @@ __forceinline static void _rcntSet( int i, int bitwise )
assert( i < 3 );
#endif
// psxNextCounter 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!
if(psxCounters[i].rate == PSXHBLANK) return;
c = (u64)((overflowCap - psxCounters[i].count) * psxCounters[i].rate) - (psxRegs.cycle - psxCounters[i].sCycleT);
c += cpuRegs.cycle - psxNextsCounter; // adjust for time passed since last rcntUpdate();
if (c < psxNextCounter) psxNextCounter = (u32)c;
//if((psxCounters[i].mode & 0x10) == 0 || psxCounters[i].target > 0xffff) continue;
c = (u64)((psxCounters[i].target - psxCounters[i].count) * psxCounters[i].rate) - (psxRegs.cycle - psxCounters[i].sCycleT);
c += cpuRegs.cycle - psxNextsCounter; // adjust for time passed since last rcntUpdate();
if (c < psxNextCounter) psxNextCounter = (u32)c;
}

View File

@ -582,6 +582,11 @@ static int recInit() {
}
static void recReset() {
#ifdef PCSX2_DEVBUILD
SysPrintf("IOP Recompiler data reset\n");
#endif
memset(recRAM, 0, sizeof(BASEBLOCK)/4*0x200000);
memset(recROM, 0, sizeof(BASEBLOCK)/4*0x400000);
memset(recROM1,0, sizeof(BASEBLOCK)/4*0x040000);

View File

@ -1589,7 +1589,7 @@ int recInit( void )
}
////////////////////////////////////////////////////
void recReset( void ) {
static void recReset( void ) {
#ifdef PCSX2_DEVBUILD
SysPrintf("EE Recompiler data reset\n");
#endif