Core: Have only one function to do what R4300iOp::ExecuteOps and R4300iOp::ExecuteCPU was doing
This commit is contained in:
parent
c39582b9ed
commit
5750d3df80
|
@ -73,10 +73,8 @@ void R4300iOp::InPermLoop()
|
|||
}
|
||||
}
|
||||
|
||||
void R4300iOp::ExecuteCPU()
|
||||
void R4300iOp::ExecuteOps(uint32_t Cycles)
|
||||
{
|
||||
WriteTrace(TraceN64System, TraceDebug, "Start");
|
||||
|
||||
bool & Done = m_System.m_EndEmulation;
|
||||
PIPELINE_STAGE & PipelineStage = m_System.m_PipelineStage;
|
||||
uint64_t & JumpToLocation = m_System.m_JumpToLocation;
|
||||
|
@ -88,7 +86,7 @@ void R4300iOp::ExecuteCPU()
|
|||
int32_t & NextTimer = *g_NextTimer;
|
||||
bool CheckTimer = false;
|
||||
|
||||
while (!Done)
|
||||
while (!Done && Cycles > 0)
|
||||
{
|
||||
if ((uint64_t)((int32_t)m_PROGRAM_COUNTER) != m_PROGRAM_COUNTER)
|
||||
{
|
||||
|
@ -136,16 +134,13 @@ void R4300iOp::ExecuteCPU()
|
|||
g_Debugger->CPUStep();
|
||||
}
|
||||
|
||||
/* 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 (Cycles != (uint32_t)-1)
|
||||
{
|
||||
Cycles -= CountPerOp;
|
||||
}
|
||||
|
||||
if (CDebugSettings::HaveDebugger())
|
||||
{
|
||||
|
@ -205,115 +200,7 @@ void R4300iOp::ExecuteCPU()
|
|||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
WriteTrace(TraceN64System, TraceDebug, "Done");
|
||||
}
|
||||
|
||||
void R4300iOp::ExecuteOps(int32_t Cycles)
|
||||
{
|
||||
bool & Done = m_System.m_EndEmulation;
|
||||
PIPELINE_STAGE & PipelineStage = m_System.m_PipelineStage;
|
||||
uint64_t & JumpDelayLocation = m_System.m_JumpDelayLocation;
|
||||
uint64_t & JumpToLocation = m_System.m_JumpToLocation;
|
||||
bool & TestTimer = m_System.m_TestTimer;
|
||||
CSystemEvents & SystemEvents = m_System.m_SystemEvents;
|
||||
const bool & DoSomething = SystemEvents.DoSomething();
|
||||
uint32_t CountPerOp = m_System.CountPerOp();
|
||||
bool CheckTimer = false;
|
||||
|
||||
while (!Done)
|
||||
{
|
||||
if (Cycles <= 0)
|
||||
{
|
||||
g_SystemTimer->UpdateTimers();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_MMU.MemoryValue32((uint32_t)m_PROGRAM_COUNTER, m_Opcode.Value))
|
||||
{
|
||||
/*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());
|
||||
}*/
|
||||
/*if (PROGRAM_COUNTER > 0x80323000 && 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 */
|
||||
|
||||
Cycles -= CountPerOp;
|
||||
*g_NextTimer -= CountPerOp;
|
||||
|
||||
/*static uint32_t TestAddress = 0x80077B0C, TestValue = 0, CurrentValue = 0;
|
||||
if (m_MMU.MemoryValue32(TestAddress, TestValue))
|
||||
{
|
||||
if (TestValue != CurrentValue)
|
||||
{
|
||||
WriteTraceF(TraceError,"%X: %X changed (%s)",PROGRAM_COUNTER,TestAddress,R4300iInstruction(PROGRAM_COUNTER, m_Opcode.Value).NameAndParam().c_str());
|
||||
CurrentValue = TestValue;
|
||||
}
|
||||
}*/
|
||||
|
||||
switch (PipelineStage)
|
||||
{
|
||||
case PIPELINE_STAGE_NORMAL:
|
||||
m_PROGRAM_COUNTER += 4;
|
||||
break;
|
||||
case PIPELINE_STAGE_DELAY_SLOT:
|
||||
PipelineStage = PIPELINE_STAGE_JUMP;
|
||||
m_PROGRAM_COUNTER += 4;
|
||||
break;
|
||||
case PIPELINE_STAGE_PERMLOOP_DO_DELAY:
|
||||
PipelineStage = PIPELINE_STAGE_PERMLOOP_DELAY_DONE;
|
||||
m_PROGRAM_COUNTER += 4;
|
||||
break;
|
||||
case PIPELINE_STAGE_JUMP:
|
||||
CheckTimer = (JumpToLocation < m_PROGRAM_COUNTER || TestTimer);
|
||||
m_PROGRAM_COUNTER = JumpToLocation;
|
||||
PipelineStage = PIPELINE_STAGE_NORMAL;
|
||||
if (CheckTimer)
|
||||
{
|
||||
TestTimer = false;
|
||||
if (*g_NextTimer < 0)
|
||||
{
|
||||
g_SystemTimer->TimerDone();
|
||||
}
|
||||
if (DoSomething)
|
||||
{
|
||||
SystemEvents.ExecuteEvents();
|
||||
}
|
||||
}
|
||||
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__);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Reg.TriggerAddressException((int32_t)m_PROGRAM_COUNTER, EXC_RMISS);
|
||||
m_PROGRAM_COUNTER = JumpToLocation;
|
||||
PipelineStage = PIPELINE_STAGE_NORMAL;
|
||||
}
|
||||
}
|
||||
g_SystemTimer->UpdateTimers();
|
||||
}
|
||||
|
||||
void R4300iOp::SPECIAL()
|
||||
|
|
|
@ -17,7 +17,7 @@ public:
|
|||
~R4300iOp(void);
|
||||
|
||||
void ExecuteCPU();
|
||||
void ExecuteOps(int32_t Cycles);
|
||||
void ExecuteOps(uint32_t Cycles);
|
||||
void InPermLoop();
|
||||
|
||||
R4300iOpcode Opcode(void) const
|
||||
|
|
|
@ -1052,7 +1052,7 @@ void CN64System::ExecuteCPU()
|
|||
void CN64System::ExecuteInterpret()
|
||||
{
|
||||
SetActiveSystem();
|
||||
m_OpCodes.ExecuteCPU();
|
||||
m_OpCodes.ExecuteOps((uint32_t)-1);
|
||||
}
|
||||
|
||||
void CN64System::ExecuteRecompiler()
|
||||
|
|
|
@ -47,7 +47,6 @@ public:
|
|||
CN64System(CPlugins * Plugins, uint32_t randomizer_seed, bool SavesReadOnly, bool SyncSystem);
|
||||
virtual ~CN64System(void);
|
||||
|
||||
bool m_EndEmulation;
|
||||
SAVE_CHIP_TYPE m_SaveUsing;
|
||||
|
||||
// Methods
|
||||
|
@ -189,6 +188,7 @@ private:
|
|||
CProfiling m_CPU_Usage; // Used to track the CPU usage
|
||||
CRecompiler * m_Recomp;
|
||||
CSpeedLimiter m_Limiter;
|
||||
bool m_EndEmulation;
|
||||
bool m_InReset;
|
||||
int32_t m_NextTimer;
|
||||
CSystemTimer m_SystemTimer;
|
||||
|
|
Loading…
Reference in New Issue