Skip to content

Commit

Permalink
Core: remove try/catch around Interpreter cpu
Browse files Browse the repository at this point in the history
  • Loading branch information
project64 committed Nov 30, 2023
1 parent df56964 commit de1288b
Showing 1 changed file with 80 additions and 87 deletions.
167 changes: 80 additions & 87 deletions Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp
Expand Up @@ -88,117 +88,110 @@ void R4300iOp::ExecuteCPU()
int32_t & NextTimer = *g_NextTimer;
bool CheckTimer = false;

__except_try()
while (!Done)
{
while (!Done)
if (!m_MMU.MemoryValue32(m_PROGRAM_COUNTER, m_Opcode.Value))
{
if (!m_MMU.MemoryValue32(m_PROGRAM_COUNTER, m_Opcode.Value))
{
m_Reg.TriggerAddressException((int32_t)m_PROGRAM_COUNTER, EXC_RMISS);
m_PROGRAM_COUNTER = JumpToLocation;
PipelineStage = PIPELINE_STAGE_NORMAL;
continue;
}
m_Reg.TriggerAddressException((int32_t)m_PROGRAM_COUNTER, EXC_RMISS);
m_PROGRAM_COUNTER = JumpToLocation;
PipelineStage = PIPELINE_STAGE_NORMAL;
continue;
}

if (HaveDebugger())
if (HaveDebugger())
{
if (HaveExecutionBP() && g_Debugger->ExecutionBP(m_PROGRAM_COUNTER))
{
if (HaveExecutionBP() && g_Debugger->ExecutionBP(m_PROGRAM_COUNTER))
{
g_Settings->SaveBool(Debugger_SteppingOps, true);
}

g_Debugger->CPUStepStarted(); // May set stepping ops/skip op

if (isStepping())
{
g_Debugger->WaitForStep();
}
g_Settings->SaveBool(Debugger_SteppingOps, true);
}

if (SkipOp())
{
// Skip command if instructed by the debugger
g_Settings->SaveBool(Debugger_SkipOp, false);
m_PROGRAM_COUNTER += 4;
continue;
}
g_Debugger->CPUStepStarted(); // May set stepping ops/skip op

g_Debugger->CPUStep();
if (isStepping())
{
g_Debugger->WaitForStep();
}

/* if (PROGRAM_COUNTER > 0x80000300 && PROGRAM_COUNTER < 0x80380000)
if (SkipOp())
{
WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s",m_PROGRAM_COUNTER,R4300iInstruction(m_PROGRAM_COUNTER, Opcode.Value).NameAndParam().c_str());
// WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s t9: %08X v1: %08X",m_PROGRAM_COUNTER,R4300iInstruction(m_PROGRAM_COUNTER, Opcode.Value).NameAndParam().c_str(),m_GPR[0x19].UW[0],m_GPR[0x03].UW[0]);
// WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %d %d",m_PROGRAM_COUNTER,*g_NextTimer,g_SystemTimer->CurrentType());
} */
// Skip command if instructed by the debugger
g_Settings->SaveBool(Debugger_SkipOp, false);
m_PROGRAM_COUNTER += 4;
continue;
}

(this->*Jump_Opcode[m_Opcode.op])();
m_GPR[0].DW = 0; // MIPS $zero hard-wired to 0
NextTimer -= CountPerOp;
g_Debugger->CPUStep();
}

if (CDebugSettings::HaveDebugger())
{
g_Debugger->CPUStepEnded();
}
/* if (PROGRAM_COUNTER > 0x80000300 && PROGRAM_COUNTER < 0x80380000)
{
WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s",m_PROGRAM_COUNTER,R4300iInstruction(m_PROGRAM_COUNTER, Opcode.Value).NameAndParam().c_str());
// WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s t9: %08X v1: %08X",m_PROGRAM_COUNTER,R4300iInstruction(m_PROGRAM_COUNTER, Opcode.Value).NameAndParam().c_str(),m_GPR[0x19].UW[0],m_GPR[0x03].UW[0]);
// WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %d %d",m_PROGRAM_COUNTER,*g_NextTimer,g_SystemTimer->CurrentType());
} */

(this->*Jump_Opcode[m_Opcode.op])();
m_GPR[0].DW = 0; // MIPS $zero hard-wired to 0
NextTimer -= CountPerOp;

if (CDebugSettings::HaveDebugger())
{
g_Debugger->CPUStepEnded();
}

m_PROGRAM_COUNTER += 4;
switch (PipelineStage)
m_PROGRAM_COUNTER += 4;
switch (PipelineStage)
{
case PIPELINE_STAGE_NORMAL:
break;
case PIPELINE_STAGE_DELAY_SLOT:
PipelineStage = PIPELINE_STAGE_JUMP;
break;
case PIPELINE_STAGE_PERMLOOP_DO_DELAY:
PipelineStage = PIPELINE_STAGE_PERMLOOP_DELAY_DONE;
break;
case PIPELINE_STAGE_JUMP:
CheckTimer = (JumpToLocation < m_PROGRAM_COUNTER - 4 || TestTimer);
m_PROGRAM_COUNTER = JumpToLocation;
PipelineStage = PIPELINE_STAGE_NORMAL;
if ((m_PROGRAM_COUNTER & 0x3) != 0)
{
case PIPELINE_STAGE_NORMAL:
break;
case PIPELINE_STAGE_DELAY_SLOT:
PipelineStage = PIPELINE_STAGE_JUMP;
break;
case PIPELINE_STAGE_PERMLOOP_DO_DELAY:
PipelineStage = PIPELINE_STAGE_PERMLOOP_DELAY_DONE;
break;
case PIPELINE_STAGE_JUMP:
CheckTimer = (JumpToLocation < m_PROGRAM_COUNTER - 4 || TestTimer);
m_Reg.DoAddressError((int32_t)JumpToLocation, true);
m_PROGRAM_COUNTER = JumpToLocation;
PipelineStage = PIPELINE_STAGE_NORMAL;
if ((m_PROGRAM_COUNTER & 0x3) != 0)
{
m_Reg.DoAddressError((int32_t)JumpToLocation, true);
m_PROGRAM_COUNTER = JumpToLocation;
PipelineStage = PIPELINE_STAGE_NORMAL;
}
else if (CheckTimer)
}
else if (CheckTimer)
{
TestTimer = false;
if (NextTimer < 0)
{
TestTimer = false;
if (NextTimer < 0)
{
g_SystemTimer->TimerDone();
}
if (DoSomething)
{
SystemEvents.ExecuteEvents();
}
g_SystemTimer->TimerDone();
}
break;
case PIPELINE_STAGE_JUMP_DELAY_SLOT:
PipelineStage = PIPELINE_STAGE_JUMP;
m_PROGRAM_COUNTER = JumpToLocation;
JumpToLocation = JumpDelayLocation;
break;
case PIPELINE_STAGE_PERMLOOP_DELAY_DONE:
m_PROGRAM_COUNTER = JumpToLocation;
PipelineStage = PIPELINE_STAGE_NORMAL;
InPermLoop();
g_SystemTimer->TimerDone();
if (DoSomething)
{
SystemEvents.ExecuteEvents();
}
break;
default:
g_Notify->BreakPoint(__FILE__, __LINE__);
}
break;
case PIPELINE_STAGE_JUMP_DELAY_SLOT:
PipelineStage = PIPELINE_STAGE_JUMP;
m_PROGRAM_COUNTER = JumpToLocation;
JumpToLocation = JumpDelayLocation;
break;
case PIPELINE_STAGE_PERMLOOP_DELAY_DONE:
m_PROGRAM_COUNTER = JumpToLocation;
PipelineStage = PIPELINE_STAGE_NORMAL;
InPermLoop();
g_SystemTimer->TimerDone();
if (DoSomething)
{
SystemEvents.ExecuteEvents();
}
break;
default:
g_Notify->BreakPoint(__FILE__, __LINE__);
}
}
__except_catch()
{
g_Notify->FatalError(GS(MSG_UNKNOWN_MEM_ACTION));
}
WriteTrace(TraceN64System, TraceDebug, "Done");
}

Expand Down

0 comments on commit de1288b

Please sign in to comment.