Fixed a freeze up bug from r252. The IOP must run at least one branch test for every EE branch test, which was a problem with the extended-length IOP_WAIT_CYCLE.

git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@254 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
Jake.Stine 2008-10-31 16:33:12 +00:00 committed by Gregory Hainaut
parent 76f08e165e
commit 41d466120b
3 changed files with 18 additions and 21 deletions

View File

@ -71,7 +71,7 @@ void psxShutdown() {
void psxException(u32 code, u32 bd) {
// PSXCPU_LOG("psxException %x: %x, %x\n", code, psxHu32(0x1070), psxHu32(0x1074));
// SysPrintf("psxException %x: %x, %x\n", code, psxHu32(0x1070), psxHu32(0x1074));
//SysPrintf("!! psxException %x: %x, %x\n", code, psxHu32(0x1070), psxHu32(0x1074));
// Set the Cause
psxRegs.CP0.n.Cause &= ~0x7f;
psxRegs.CP0.n.Cause |= code;
@ -171,16 +171,6 @@ static void _psxTestInterrupts() {
void psxBranchTest()
{
// EEsCycle update was moved to outside the psxBranchTest. Since it gets run
// for every branch now, the following code block is obsolete.
/*EEsCycle -= (psxRegs.cycle - IOPoCycle) << 3;
IOPoCycle = psxRegs.cycle;
if( EEsCycle > 0 )
g_psxNextBranchCycle = psxRegs.cycle + min(IOP_WAIT_CYCLE, (EEsCycle>>3));
else
g_psxNextBranchCycle = psxRegs.cycle;*/
g_psxNextBranchCycle = psxRegs.cycle + IOP_WAIT_CYCLE;
if ((int)(psxRegs.cycle - psxNextsCounter) >= psxNextCounter)

View File

@ -438,6 +438,9 @@ void cpuBranchTest()
EEsCycle += cpuRegs.cycle - EEoCycle;
EEoCycle = cpuRegs.cycle;
// Force the IOP to run at least one branch test:
// If the IOP doesn't run it's branch test, bad things can happen.
g_psxNextBranchCycle = min( g_psxNextBranchCycle, EEsCycle >> 3 );
psxCpu->ExecuteBlock();
if (VU0.VI[REG_VPU_STAT].UL & 0x1) {

View File

@ -984,34 +984,38 @@ static void iPsxBranchTest(u32 newpc, u32 cpuBranch)
if( !USE_FAST_BRANCHES || cpuBranch ) {
MOV32MtoR(ECX, (uptr)&psxRegs.cycle);
ADD32ItoR(ECX, s_psxBlockCycles*PSXCYCLE_MULT); // greater mult factor causes nfsmw to crash
SUB32ItoM((uptr)&EEsCycle, s_psxBlockCycles*PSXCYCLE_MULT*8); // 8 EE clocks for every IOP clock.
MOV32RtoM((uptr)&psxRegs.cycle, ECX); // update cycles
}
else {
SUB32ItoM((uptr)&EEsCycle, s_psxBlockCycles*8); // 8 EE clocks for every IOP clock.
SUB32ItoM((uptr)&EEsCycle, s_psxBlockCycles*PSXCYCLE_MULT*8); // 8 EE clocks for every IOP clock.
ADD32ItoM((uptr)&psxRegs.cycle, s_psxBlockCycles*PSXCYCLE_MULT);
return;
}
SUB32MtoR(ECX, (uptr)&g_psxNextBranchCycle);
// check if should branch
j8Ptr[0] = JS8( 0 );
CALLFunc((uptr)psxBranchTest);
CMP32ItoM((uptr)&EEsCycle, 0);
// check if we've caught up with the EE
SUB32ItoM((uptr)&EEsCycle, s_psxBlockCycles*PSXCYCLE_MULT*8); // 8 EE clocks for every IOP clock.
j8Ptr[2] = JG8(0);
// Break the Block-execute Loop here.
if( REC_INC_STACK )
ADD64ItoR(ESP, REC_INC_STACK);
RET2();
// Continue onward with branching here:
x86SetJ8( j8Ptr[2] );
// check if should branch
SUB32MtoR(ECX, (uptr)&g_psxNextBranchCycle);
j8Ptr[0] = JS8( 0 );
CALLFunc((uptr)psxBranchTest);
if( newpc != 0xffffffff ) {
CMP32ItoM((uptr)&psxRegs.pc, newpc);
JNE32((uptr)psxDispatcherReg - ( (uptr)x86Ptr + 6 ));
}
// Skip branch jump target here:
x86SetJ8( j8Ptr[0] );
}