Core: Have UpdateSyncCPU use its Sync cpu instead of passing a cpu to it

This commit is contained in:
zilmar 2023-12-14 11:18:07 +10:30
parent 236d618c20
commit c67f3f0e97
4 changed files with 134 additions and 135 deletions

View File

@ -1092,8 +1092,12 @@ void CN64System::CpuStopped()
WriteTrace(TraceN64System, TraceDebug, "Done");
}
void CN64System::UpdateSyncCPU(CN64System * const SecondCPU, uint32_t const Cycles)
void CN64System::UpdateSyncCPU(uint32_t const Cycles)
{
if (m_SyncCPU == nullptr)
{
return;
}
int CyclesToExecute = Cycles - m_CyclesToSkip;
// Update the number of cycles to skip
@ -1109,37 +1113,41 @@ void CN64System::UpdateSyncCPU(CN64System * const SecondCPU, uint32_t const Cycl
return;
}
SecondCPU->SetActiveSystem(true);
m_OpCodes.ExecuteOps(Cycles);
m_SyncCPU->SetActiveSystem(true);
m_SyncCPU->m_OpCodes.ExecuteOps(Cycles);
SetActiveSystem(true);
}
void CN64System::SyncCPUPC(CN64System * const SecondCPU)
void CN64System::SyncSystemPC(void)
{
if (m_SyncCPU == nullptr)
{
return;
}
bool ErrorFound = false;
g_SystemTimer->UpdateTimers();
if (m_Reg.m_PROGRAM_COUNTER != SecondCPU->m_Reg.m_PROGRAM_COUNTER)
if (m_Reg.m_PROGRAM_COUNTER != m_SyncCPU->m_Reg.m_PROGRAM_COUNTER)
{
ErrorFound = true;
}
if (m_TLB != SecondCPU->m_TLB)
if (m_TLB != m_SyncCPU->m_TLB)
{
ErrorFound = true;
}
if (m_SystemTimer != SecondCPU->m_SystemTimer)
if (m_SystemTimer != m_SyncCPU->m_SystemTimer)
{
ErrorFound = true;
}
if (m_NextTimer != SecondCPU->m_NextTimer)
if (m_NextTimer != m_SyncCPU->m_NextTimer)
{
ErrorFound = true;
}
if (ErrorFound)
{
DumpSyncErrors(SecondCPU);
DumpSyncErrors();
}
for (int i = (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])) - 1; i > 0; i--)
@ -1149,8 +1157,12 @@ void CN64System::SyncCPUPC(CN64System * const SecondCPU)
m_LastSuccessSyncPC[0] = m_Reg.m_PROGRAM_COUNTER;
}
void CN64System::SyncCPU(CN64System * const SecondCPU)
void CN64System::SyncSystem()
{
if (m_SyncCPU == nullptr)
{
return;
}
bool ErrorFound = false;
m_SyncCount += 1;
@ -1162,7 +1174,7 @@ void CN64System::SyncCPU(CN64System * const SecondCPU)
ErrorFound = true;
}
#endif
if (m_Reg.m_PROGRAM_COUNTER != SecondCPU->m_Reg.m_PROGRAM_COUNTER)
if (m_Reg.m_PROGRAM_COUNTER != m_SyncCPU->m_Reg.m_PROGRAM_COUNTER)
{
ErrorFound = true;
}
@ -1170,15 +1182,15 @@ void CN64System::SyncCPU(CN64System * const SecondCPU)
{
for (int count = 0; count < 32; count++)
{
if (m_Reg.m_GPR[count].W[0] != SecondCPU->m_Reg.m_GPR[count].W[0])
if (m_Reg.m_GPR[count].W[0] != m_SyncCPU->m_Reg.m_GPR[count].W[0])
{
ErrorFound = true;
}
if (m_Reg.m_FPR[count].DW != SecondCPU->m_Reg.m_FPR[count].DW)
if (m_Reg.m_FPR[count].DW != m_SyncCPU->m_Reg.m_FPR[count].DW)
{
ErrorFound = true;
}
if (m_Reg.m_CP0[count] != SecondCPU->m_Reg.m_CP0[count])
if (m_Reg.m_CP0[count] != m_SyncCPU->m_Reg.m_CP0[count])
{
ErrorFound = true;
}
@ -1188,64 +1200,64 @@ void CN64System::SyncCPU(CN64System * const SecondCPU)
{
for (int count = 0; count < 32; count++)
{
if (m_Reg.m_GPR[count].DW != SecondCPU->m_Reg.m_GPR[count].DW)
if (m_Reg.m_GPR[count].DW != m_SyncCPU->m_Reg.m_GPR[count].DW)
{
ErrorFound = true;
}
if (m_Reg.m_FPR[count].DW != SecondCPU->m_Reg.m_FPR[count].DW)
if (m_Reg.m_FPR[count].DW != m_SyncCPU->m_Reg.m_FPR[count].DW)
{
ErrorFound = true;
}
if (m_Reg.m_CP0[count] != SecondCPU->m_Reg.m_CP0[count])
if (m_Reg.m_CP0[count] != m_SyncCPU->m_Reg.m_CP0[count])
{
ErrorFound = true;
}
}
}
if (m_Random.get_state() != SecondCPU->m_Random.get_state())
if (m_Random.get_state() != m_SyncCPU->m_Random.get_state())
{
ErrorFound = true;
}
if (m_TLB != SecondCPU->m_TLB)
if (m_TLB != m_SyncCPU->m_TLB)
{
ErrorFound = true;
}
if (m_Reg.m_FPCR[0] != SecondCPU->m_Reg.m_FPCR[0])
if (m_Reg.m_FPCR[0] != m_SyncCPU->m_Reg.m_FPCR[0])
{
ErrorFound = true;
}
if (m_Reg.m_FPCR[31] != SecondCPU->m_Reg.m_FPCR[31])
if (m_Reg.m_FPCR[31] != m_SyncCPU->m_Reg.m_FPCR[31])
{
ErrorFound = true;
}
if (m_Reg.m_HI.DW != SecondCPU->m_Reg.m_HI.DW)
if (m_Reg.m_HI.DW != m_SyncCPU->m_Reg.m_HI.DW)
{
ErrorFound = true;
}
if (m_Reg.m_LO.DW != SecondCPU->m_Reg.m_LO.DW)
if (m_Reg.m_LO.DW != m_SyncCPU->m_Reg.m_LO.DW)
{
ErrorFound = true;
}
/*if (m_SyncCount > 4788000)
{
if (memcmp(m_MMU_VM.Rdram(),SecondCPU->m_MMU_VM.Rdram(),RdramSize()) != 0)
if (memcmp(m_MMU_VM.Rdram(),m_SyncCPU->m_MMU_VM.Rdram(),RdramSize()) != 0)
{
ErrorFound = true;
}
}
if (memcmp(m_MMU_VM.Imem(),SecondCPU->m_MMU_VM.Imem(),0x1000) != 0)
if (memcmp(m_MMU_VM.Imem(),m_SyncCPU->m_MMU_VM.Imem(),0x1000) != 0)
{
ErrorFound = true;
}
if (memcmp(m_MMU_VM.Dmem(),SecondCPU->m_MMU_VM.Dmem(),0x1000) != 0)
if (memcmp(m_MMU_VM.Dmem(),m_SyncCPU->m_MMU_VM.Dmem(),0x1000) != 0)
{
ErrorFound = true;
}*/
/*for (int z = 0; z < 0x100; z++)
{
if (m_MMU_VM.Rdram()[0x00206970 + z] != SecondCPU->m_MMU_VM.Rdram()[0x00206970 + z])
if (m_MMU_VM.Rdram()[0x00206970 + z] != m_SyncCPU->m_MMU_VM.Rdram()[0x00206970 + z])
{
ErrorFound = true;
break;
@ -1275,22 +1287,22 @@ void CN64System::SyncCPU(CN64System * const SecondCPU)
}
}
if (m_SystemTimer != SecondCPU->m_SystemTimer)
if (m_SystemTimer != m_SyncCPU->m_SystemTimer)
{
ErrorFound = true;
}
if (m_NextTimer != SecondCPU->m_NextTimer)
if (m_NextTimer != m_SyncCPU->m_NextTimer)
{
ErrorFound = true;
}
if (m_PipelineStage != SecondCPU->m_PipelineStage)
if (m_PipelineStage != m_SyncCPU->m_PipelineStage)
{
ErrorFound = true;
}
for (int i = 0, n = sizeof(m_Reg.m_Mips_Interface) / sizeof(m_Reg.m_Mips_Interface[0]); i < n; i++)
{
if (m_Reg.m_Mips_Interface[i] != SecondCPU->m_Reg.m_Mips_Interface[i])
if (m_Reg.m_Mips_Interface[i] != m_SyncCPU->m_Reg.m_Mips_Interface[i])
{
ErrorFound = true;
}
@ -1298,7 +1310,7 @@ void CN64System::SyncCPU(CN64System * const SecondCPU)
for (int i = 0, n = sizeof(m_Reg.m_SigProcessor_Interface) / sizeof(m_Reg.m_SigProcessor_Interface[0]); i < n; i++)
{
if (m_Reg.m_SigProcessor_Interface[i] != SecondCPU->m_Reg.m_SigProcessor_Interface[i])
if (m_Reg.m_SigProcessor_Interface[i] != m_SyncCPU->m_Reg.m_SigProcessor_Interface[i])
{
ErrorFound = true;
}
@ -1306,7 +1318,7 @@ void CN64System::SyncCPU(CN64System * const SecondCPU)
for (int i = 0, n = sizeof(m_Reg.m_Display_ControlReg) / sizeof(m_Reg.m_Display_ControlReg[0]); i < n; i++)
{
if (m_Reg.m_Display_ControlReg[i] != SecondCPU->m_Reg.m_Display_ControlReg[i])
if (m_Reg.m_Display_ControlReg[i] != m_SyncCPU->m_Reg.m_Display_ControlReg[i])
{
ErrorFound = true;
}
@ -1314,7 +1326,7 @@ void CN64System::SyncCPU(CN64System * const SecondCPU)
if (ErrorFound)
{
DumpSyncErrors(SecondCPU);
DumpSyncErrors();
}
for (int i = (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])) - 1; i > 0; i--)
@ -1324,17 +1336,7 @@ void CN64System::SyncCPU(CN64System * const SecondCPU)
m_LastSuccessSyncPC[0] = m_Reg.m_PROGRAM_COUNTER;
}
void CN64System::SyncSystem()
{
SyncCPU(g_SyncSystem);
}
void CN64System::SyncSystemPC()
{
SyncCPUPC(g_SyncSystem);
}
void CN64System::DumpSyncErrors(CN64System * SecondCPU)
void CN64System::DumpSyncErrors()
{
int count;
@ -1351,19 +1353,19 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU)
Error.Log("m_CurrentSP,%X,%X\r\n", m_CurrentSP, GPR[29].UW[0]);
}
#endif
if (m_Reg.m_PROGRAM_COUNTER != SecondCPU->m_Reg.m_PROGRAM_COUNTER)
if (m_Reg.m_PROGRAM_COUNTER != m_SyncCPU->m_Reg.m_PROGRAM_COUNTER)
{
Error.LogF("PROGRAM_COUNTER 0x%X, 0x%X\r\n", m_Reg.m_PROGRAM_COUNTER, SecondCPU->m_Reg.m_PROGRAM_COUNTER);
Error.LogF("PROGRAM_COUNTER 0x%X, 0x%X\r\n", m_Reg.m_PROGRAM_COUNTER, m_SyncCPU->m_Reg.m_PROGRAM_COUNTER);
}
if (b32BitCore())
{
for (count = 0; count < 32; count++)
{
if (m_Reg.m_GPR[count].UW[0] != SecondCPU->m_Reg.m_GPR[count].UW[0])
if (m_Reg.m_GPR[count].UW[0] != m_SyncCPU->m_Reg.m_GPR[count].UW[0])
{
Error.LogF("GPR[%s] 0x%08X%08X, 0x%08X%08X\r\n", CRegName::GPR[count],
m_Reg.m_GPR[count].W[1], m_Reg.m_GPR[count].W[0],
SecondCPU->m_Reg.m_GPR[count].W[1], SecondCPU->m_Reg.m_GPR[count].W[0]);
m_SyncCPU->m_Reg.m_GPR[count].W[1], m_SyncCPU->m_Reg.m_GPR[count].W[0]);
}
}
}
@ -1371,80 +1373,80 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU)
{
for (count = 0; count < 32; count++)
{
if (m_Reg.m_GPR[count].DW != SecondCPU->m_Reg.m_GPR[count].DW)
if (m_Reg.m_GPR[count].DW != m_SyncCPU->m_Reg.m_GPR[count].DW)
{
Error.LogF("GPR[%s] 0x%08X%08X, 0x%08X%08X\r\n", CRegName::GPR[count],
m_Reg.m_GPR[count].W[1], m_Reg.m_GPR[count].W[0],
SecondCPU->m_Reg.m_GPR[count].W[1], SecondCPU->m_Reg.m_GPR[count].W[0]);
m_SyncCPU->m_Reg.m_GPR[count].W[1], m_SyncCPU->m_Reg.m_GPR[count].W[0]);
}
}
}
for (count = 0; count < 32; count++)
{
if (m_Reg.m_FPR[count].DW != SecondCPU->m_Reg.m_FPR[count].DW)
if (m_Reg.m_FPR[count].DW != m_SyncCPU->m_Reg.m_FPR[count].DW)
{
Error.LogF("FPR[%s] 0x%08X%08X, 0x%08X%08X\r\n", CRegName::FPR[count],
m_Reg.m_FPR[count].W[1], m_Reg.m_FPR[count].W[0],
SecondCPU->m_Reg.m_FPR[count].W[1], SecondCPU->m_Reg.m_FPR[count].W[0]);
m_SyncCPU->m_Reg.m_FPR[count].W[1], m_SyncCPU->m_Reg.m_FPR[count].W[0]);
}
}
for (count = 0; count < 32; count++)
{
if (m_Reg.m_FPCR[count] != SecondCPU->m_Reg.m_FPCR[count])
if (m_Reg.m_FPCR[count] != m_SyncCPU->m_Reg.m_FPCR[count])
{
Error.LogF("FPCR[%s] 0x%08X, 0x%08X\r\n", CRegName::FPR_Ctrl[count],
m_Reg.m_FPCR[count], SecondCPU->m_Reg.m_FPCR[count]);
m_Reg.m_FPCR[count], m_SyncCPU->m_Reg.m_FPCR[count]);
}
}
for (count = 0; count < 32; count++)
{
if (m_Reg.m_CP0[count] != SecondCPU->m_Reg.m_CP0[count])
if (m_Reg.m_CP0[count] != m_SyncCPU->m_Reg.m_CP0[count])
{
Error.LogF("CP0[%s] 0x%08X%08X, 0x%08X%08X\r\n", CRegName::Cop0[count],
(uint32_t)(m_Reg.m_CP0[count] >> 32), (uint32_t)m_Reg.m_CP0[count], (uint32_t)(SecondCPU->m_Reg.m_CP0[count] >> 32), (uint32_t)(SecondCPU->m_Reg.m_CP0[count]));
(uint32_t)(m_Reg.m_CP0[count] >> 32), (uint32_t)m_Reg.m_CP0[count], (uint32_t)(m_SyncCPU->m_Reg.m_CP0[count] >> 32), (uint32_t)(m_SyncCPU->m_Reg.m_CP0[count]));
}
}
if (m_Reg.m_HI.DW != SecondCPU->m_Reg.m_HI.DW)
if (m_Reg.m_HI.DW != m_SyncCPU->m_Reg.m_HI.DW)
{
Error.LogF("HI Reg 0x%08X%08X, 0x%08X%08X\r\n", m_Reg.m_HI.UW[1], m_Reg.m_HI.UW[0], SecondCPU->m_Reg.m_HI.UW[1], SecondCPU->m_Reg.m_HI.UW[0]);
Error.LogF("HI Reg 0x%08X%08X, 0x%08X%08X\r\n", m_Reg.m_HI.UW[1], m_Reg.m_HI.UW[0], m_SyncCPU->m_Reg.m_HI.UW[1], m_SyncCPU->m_Reg.m_HI.UW[0]);
}
if (m_Reg.m_LO.DW != SecondCPU->m_Reg.m_LO.DW)
if (m_Reg.m_LO.DW != m_SyncCPU->m_Reg.m_LO.DW)
{
Error.LogF("LO Reg 0x%08X%08X, 0x%08X%08X\r\n", m_Reg.m_LO.UW[1], m_Reg.m_LO.UW[0], SecondCPU->m_Reg.m_LO.UW[1], SecondCPU->m_Reg.m_LO.UW[0]);
Error.LogF("LO Reg 0x%08X%08X, 0x%08X%08X\r\n", m_Reg.m_LO.UW[1], m_Reg.m_LO.UW[0], m_SyncCPU->m_Reg.m_LO.UW[1], m_SyncCPU->m_Reg.m_LO.UW[0]);
}
for (int i = 0, n = sizeof(m_Reg.m_Mips_Interface) / sizeof(m_Reg.m_Mips_Interface[0]); i < n; i++)
{
if (m_Reg.m_Mips_Interface[i] != SecondCPU->m_Reg.m_Mips_Interface[i])
if (m_Reg.m_Mips_Interface[i] != m_SyncCPU->m_Reg.m_Mips_Interface[i])
{
Error.LogF("Mips_Interface[%d] 0x%08X, 0x%08X\r\n", i, m_Reg.m_Mips_Interface[i], SecondCPU->m_Reg.m_Mips_Interface[i]);
Error.LogF("Mips_Interface[%d] 0x%08X, 0x%08X\r\n", i, m_Reg.m_Mips_Interface[i], m_SyncCPU->m_Reg.m_Mips_Interface[i]);
}
}
for (int i = 0, n = sizeof(m_Reg.m_SigProcessor_Interface) / sizeof(m_Reg.m_SigProcessor_Interface[0]); i < n; i++)
{
if (m_Reg.m_SigProcessor_Interface[i] != SecondCPU->m_Reg.m_SigProcessor_Interface[i])
if (m_Reg.m_SigProcessor_Interface[i] != m_SyncCPU->m_Reg.m_SigProcessor_Interface[i])
{
Error.LogF("SigProcessor_Interface[%d] 0x%08X, 0x%08X\r\n", i, m_Reg.m_SigProcessor_Interface[i], SecondCPU->m_Reg.m_SigProcessor_Interface[i]);
Error.LogF("SigProcessor_Interface[%d] 0x%08X, 0x%08X\r\n", i, m_Reg.m_SigProcessor_Interface[i], m_SyncCPU->m_Reg.m_SigProcessor_Interface[i]);
}
}
for (int i = 0, n = sizeof(m_Reg.m_Display_ControlReg) / sizeof(m_Reg.m_Display_ControlReg[0]); i < n; i++)
{
if (m_Reg.m_Display_ControlReg[i] != SecondCPU->m_Reg.m_Display_ControlReg[i])
if (m_Reg.m_Display_ControlReg[i] != m_SyncCPU->m_Reg.m_Display_ControlReg[i])
{
Error.LogF("Display_ControlReg[%d] 0x%08X, 0x%08X\r\n", i, m_Reg.m_Display_ControlReg[i], SecondCPU->m_Reg.m_Display_ControlReg[i]);
Error.LogF("Display_ControlReg[%d] 0x%08X, 0x%08X\r\n", i, m_Reg.m_Display_ControlReg[i], m_SyncCPU->m_Reg.m_Display_ControlReg[i]);
}
}
if (m_NextTimer != SecondCPU->m_NextTimer)
if (m_NextTimer != m_SyncCPU->m_NextTimer)
{
Error.LogF("Current Time: %X %X\r\n", (uint32_t)m_NextTimer, (uint32_t)SecondCPU->m_NextTimer);
Error.LogF("Current Time: %X %X\r\n", (uint32_t)m_NextTimer, (uint32_t)m_SyncCPU->m_NextTimer);
}
if (m_PipelineStage != SecondCPU->m_PipelineStage)
if (m_PipelineStage != m_SyncCPU->m_PipelineStage)
{
Error.LogF("Pipeline Stage: %X %X\r\n", (uint32_t)m_PipelineStage, (uint32_t)SecondCPU->m_PipelineStage);
Error.LogF("Pipeline Stage: %X %X\r\n", (uint32_t)m_PipelineStage, (uint32_t)m_SyncCPU->m_PipelineStage);
}
m_TLB.RecordDifference(Error, SecondCPU->m_TLB);
m_SystemTimer.RecordDifference(Error, SecondCPU->m_SystemTimer);
m_TLB.RecordDifference(Error, m_SyncCPU->m_TLB);
m_SystemTimer.RecordDifference(Error, m_SyncCPU->m_SystemTimer);
if (bFastSP() && m_Recomp)
{
uint32_t StackPointer = (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF);
@ -1468,7 +1470,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU)
}
}
uint32_t *Rdram = (uint32_t *)m_MMU_VM.Rdram(), *Rdram2 = (uint32_t *)SecondCPU->m_MMU_VM.Rdram();
uint32_t *Rdram = (uint32_t *)m_MMU_VM.Rdram(), *Rdram2 = (uint32_t *)m_SyncCPU->m_MMU_VM.Rdram();
for (int z = 0, n = (RdramSize() >> 2); z < n; z++)
{
if (Rdram[z] != Rdram2[z])
@ -1477,7 +1479,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU)
}
}
uint32_t *Imem = (uint32_t *)m_MMU_VM.Imem(), *Imem2 = (uint32_t *)SecondCPU->m_MMU_VM.Imem();
uint32_t *Imem = (uint32_t *)m_MMU_VM.Imem(), *Imem2 = (uint32_t *)m_SyncCPU->m_MMU_VM.Imem();
for (int z = 0; z < (0x1000 >> 2); z++)
{
if (Imem[z] != Imem2[z])
@ -1485,7 +1487,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU)
Error.LogF("IMEM[%X]: %X %X\r\n", z << 2, Imem[z], Imem2[z]);
}
}
uint32_t *Dmem = (uint32_t *)m_MMU_VM.Dmem(), *Dmem2 = (uint32_t *)SecondCPU->m_MMU_VM.Dmem();
uint32_t *Dmem = (uint32_t *)m_MMU_VM.Dmem(), *Dmem2 = (uint32_t *)m_SyncCPU->m_MMU_VM.Dmem();
for (int z = 0; z < (0x1000 >> 2); z++)
{
if (Dmem[z] != Dmem2[z])
@ -1509,49 +1511,49 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU)
{
Error.LogF("GPR[%s], 0x%08X%08X, 0x%08X%08X\r\n", CRegName::GPR[count],
m_Reg.m_GPR[count].W[1], m_Reg.m_GPR[count].W[0],
SecondCPU->m_Reg.m_GPR[count].W[1], SecondCPU->m_Reg.m_GPR[count].W[0]);
m_SyncCPU->m_Reg.m_GPR[count].W[1], m_SyncCPU->m_Reg.m_GPR[count].W[0]);
}
Error.Log("\r\n");
for (count = 0; count < 32; count++)
{
Error.LogF("FPR[%s],%*s0x%08X%08X, 0x%08X%08X\r\n", CRegName::FPR[count],
count < 10 ? 9 : 8, " ", m_Reg.m_FPR[count].W[1], m_Reg.m_FPR[count].W[0],
SecondCPU->m_Reg.m_FPR[count].W[1], SecondCPU->m_Reg.m_FPR[count].W[0]);
m_SyncCPU->m_Reg.m_FPR[count].W[1], m_SyncCPU->m_Reg.m_FPR[count].W[0]);
}
Error.Log("\r\n");
for (count = 0; count < 32; count++)
{
Error.LogF("FPR_S[%s],%*s%f, %f\r\n", CRegName::FPR[count],
count < 10 ? 7 : 6, " ", *(m_Reg.m_FPR_S[count]), *(SecondCPU->m_Reg.m_FPR_S[count]));
count < 10 ? 7 : 6, " ", *(m_Reg.m_FPR_S[count]), *(m_SyncCPU->m_Reg.m_FPR_S[count]));
}
Error.Log("\r\n");
for (count = 0; count < 32; count++)
{
Error.LogF("FPR_D[%s],%*s%f, %f\r\n", CRegName::FPR[count],
count < 10 ? 7 : 6, " ", *(m_Reg.m_FPR_D[count]), *(SecondCPU->m_Reg.m_FPR_D[count]));
count < 10 ? 7 : 6, " ", *(m_Reg.m_FPR_D[count]), *(m_SyncCPU->m_Reg.m_FPR_D[count]));
}
Error.Log("\r\n");
for (count = 0; count < 32; count++)
{
Error.LogF("CP0[%s] %*s0x%08X%08X, 0x%08X%08X\r\n", CRegName::Cop0[count], 12 - strlen(CRegName::Cop0[count]), "",
(uint32_t)(m_Reg.m_CP0[count] >> 32), (uint32_t)m_Reg.m_CP0[count], (uint32_t)(SecondCPU->m_Reg.m_CP0[count] >> 32), (uint32_t)(SecondCPU->m_Reg.m_CP0[count]));
(uint32_t)(m_Reg.m_CP0[count] >> 32), (uint32_t)m_Reg.m_CP0[count], (uint32_t)(m_SyncCPU->m_Reg.m_CP0[count] >> 32), (uint32_t)(m_SyncCPU->m_Reg.m_CP0[count]));
}
Error.Log("\r\n");
for (count = 0; count < 32; count++)
{
Error.LogF("FPR_Ctrl[%s],%*s0x%08X, 0x%08X\r\n", CRegName::FPR_Ctrl[count],
12 - strlen(CRegName::FPR_Ctrl[count]), "",
m_Reg.m_FPCR[count], SecondCPU->m_Reg.m_FPCR[count]);
m_Reg.m_FPCR[count], m_SyncCPU->m_Reg.m_FPCR[count]);
}
Error.Log("\r\n");
Error.LogF("HI 0x%08X%08X, 0x%08X%08X\r\n", m_Reg.m_HI.UW[1], m_Reg.m_HI.UW[0],
SecondCPU->m_Reg.m_HI.UW[1], SecondCPU->m_Reg.m_HI.UW[0]);
m_SyncCPU->m_Reg.m_HI.UW[1], m_SyncCPU->m_Reg.m_HI.UW[0]);
Error.LogF("LO 0x%08X%08X, 0x%08X%08X\r\n", m_Reg.m_LO.UW[1], m_Reg.m_LO.UW[0],
SecondCPU->m_Reg.m_LO.UW[1], SecondCPU->m_Reg.m_LO.UW[0]);
m_SyncCPU->m_Reg.m_LO.UW[1], m_SyncCPU->m_Reg.m_LO.UW[0]);
Error.LogF("CP0[%s],%*s0x%08X, 0x%08X\r\n", CRegName::Cop0[count],
12 - strlen(CRegName::Cop0[count]), "",
m_Reg.m_CP0[count], SecondCPU->m_Reg.m_CP0[count]);
m_Reg.m_CP0[count], m_SyncCPU->m_Reg.m_CP0[count]);
bool bHasTlb = false;
for (count = 0; count < 32; count++)
@ -1568,7 +1570,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU)
}
Error.LogF("TLB[%2d], %08X, %08X, %08X, %08X\r\n", count,
m_TLB.TlbEntry(count).EntryHi.Value, m_TLB.TlbEntry(count).PageMask.Value,
SecondCPU->m_TLB.TlbEntry(count).EntryHi.Value, SecondCPU->m_TLB.TlbEntry(count).PageMask.Value);
m_SyncCPU->m_TLB.TlbEntry(count).EntryHi.Value, m_SyncCPU->m_TLB.TlbEntry(count).PageMask.Value);
}
Error.Log("\r\n");
Error.Log("Code at PC:\r\n");
@ -2242,7 +2244,7 @@ bool CN64System::LoadState(const char * FileName)
m_SyncCPU->SetActiveSystem(true);
m_SyncCPU->LoadState(FileName);
SetActiveSystem(true);
SyncCPU(m_SyncCPU);
SyncSystem();
}
}
NotifyCallback(CN64SystemCB_LoadedGameState);

View File

@ -104,9 +104,7 @@ public:
uint32_t m_CurrentSP;
#endif
// For sync CPU
void UpdateSyncCPU(CN64System * const SecondCPU, uint32_t const Cycles);
void SyncCPU(CN64System * const SecondCPU);
void SyncCPUPC(CN64System * const SecondCPU);
void UpdateSyncCPU(uint32_t const Cycles);
void SyncSystem();
void SyncSystemPC();
@ -158,7 +156,7 @@ private:
void ExecuteCPU();
void RefreshScreen();
void DumpSyncErrors(CN64System * SecondCPU);
void DumpSyncErrors();
void StartEmulation2(bool NewThread);
bool SetActiveSystem(bool bActive = true);
void NotifyCallback(CN64SystemCB Type);

View File

@ -43,9 +43,9 @@ void CRecompiler::Run()
__except_try()
{
if (g_System->LookUpMode() == FuncFind_VirtualLookup)
if (m_System.LookUpMode() == FuncFind_VirtualLookup)
{
if (g_System->bSMM_ValidFunc())
if (m_System.bSMM_ValidFunc())
{
RecompilerMain_VirtualTable_validate();
}
@ -54,13 +54,13 @@ void CRecompiler::Run()
RecompilerMain_VirtualTable();
}
}
else if (g_System->LookUpMode() == FuncFind_ChangeMemory)
else if (m_System.LookUpMode() == FuncFind_ChangeMemory)
{
RecompilerMain_ChangeMemory();
}
else
{
if (g_System->bSMM_ValidFunc())
if (m_System.bSMM_ValidFunc())
{
RecompilerMain_Lookup_validate();
}
@ -88,8 +88,8 @@ void CRecompiler::RecompilerMain_VirtualTable()
if (!m_MMU.ValidVaddr(PC))
{
m_Reg.TriggerAddressException(PC, EXC_RMISS);
PC = g_System->m_JumpToLocation;
g_System->m_PipelineStage = PIPELINE_STAGE_NORMAL;
PC = m_System.m_JumpToLocation;
m_System.m_PipelineStage = PIPELINE_STAGE_NORMAL;
if (!m_MMU.ValidVaddr(PC))
{
g_Notify->DisplayError(stdstr_f("Failed to translate PC to a PAddr: %X\n\nEmulation stopped", PC).c_str());
@ -124,7 +124,7 @@ void CRecompiler::RecompilerMain_VirtualTable()
g_Notify->FatalError(MSG_MEM_ALLOC_ERROR);
}
memset(table, 0, sizeof(PCCompiledFunc) * (0x1000 >> 2));
if (g_System->bSMM_Protect())
if (m_System.bSMM_Protect())
{
WriteTrace(TraceRecompiler, TraceError, "Create Table (%X): Index = %d", table, PC >> 0xC);
m_MMU.ProtectMemory(PC & ~0xFFF, PC | 0xFFF);
@ -155,11 +155,11 @@ void CRecompiler::RecompilerMain_Lookup()
g_Notify->DisplayError(stdstr_f("Failed to translate PC to a PAddr: %X\n\nEmulation stopped", PROGRAM_COUNTER).c_str());
m_EndEmulation = true;
}
PROGRAM_COUNTER = g_System->m_JumpToLocation;
g_System->m_PipelineStage = PIPELINE_STAGE_NORMAL;
PROGRAM_COUNTER = m_System.m_JumpToLocation;
m_System.m_PipelineStage = PIPELINE_STAGE_NORMAL;
continue;
}
if (PhysicalAddr < g_System->RdramSize())
if (PhysicalAddr < m_System.RdramSize())
{
CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2];
@ -170,7 +170,7 @@ void CRecompiler::RecompilerMain_Lookup()
{
break;
}
if (g_System->bSMM_Protect())
if (m_System.bSMM_Protect())
{
m_MMU.ProtectMemory(PROGRAM_COUNTER & ~0xFFF, PROGRAM_COUNTER | 0xFFF);
}
@ -182,16 +182,16 @@ void CRecompiler::RecompilerMain_Lookup()
{
uint32_t opsExecuted = 0;
while (m_MMU.VAddrToPAddr(PROGRAM_COUNTER, PhysicalAddr) && PhysicalAddr >= g_System->RdramSize())
while (m_MMU.VAddrToPAddr(PROGRAM_COUNTER, PhysicalAddr) && PhysicalAddr >= m_System.RdramSize())
{
g_System->m_OpCodes.ExecuteOps(g_System->CountPerOp());
opsExecuted += g_System->CountPerOp();
m_System.m_OpCodes.ExecuteOps(m_System.CountPerOp());
opsExecuted += m_System.CountPerOp();
}
if (g_SyncSystem)
{
g_System->UpdateSyncCPU(g_SyncSystem, opsExecuted);
g_System->SyncCPU(g_SyncSystem);
m_System.UpdateSyncCPU(opsExecuted);
m_System.SyncSystem();
}
}
}
@ -214,11 +214,11 @@ void CRecompiler::RecompilerMain_Lookup_validate()
g_Notify->DisplayError(stdstr_f("Failed to translate PC to a PAddr: %X\n\nEmulation stopped", PC).c_str());
Done = true;
}
PROGRAM_COUNTER = g_System->m_JumpToLocation;
g_System->m_PipelineStage = PIPELINE_STAGE_NORMAL;
PROGRAM_COUNTER = m_System.m_JumpToLocation;
m_System.m_PipelineStage = PIPELINE_STAGE_NORMAL;
continue;
}
if (PhysicalAddr < g_System->RdramSize())
if (PhysicalAddr < m_System.RdramSize())
{
CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2];
@ -229,7 +229,7 @@ void CRecompiler::RecompilerMain_Lookup_validate()
{
break;
}
if (g_System->bSMM_Protect())
if (m_System.bSMM_Protect())
{
m_MMU.ProtectMemory(PC & ~0xFFF, PC | 0xFFF);
}
@ -260,12 +260,12 @@ void CRecompiler::RecompilerMain_Lookup_validate()
if (bRecordExecutionTimes())
{
uint64_t PreNonCPUTime = g_System->m_CPU_Usage.NonCPUTime();
uint64_t PreNonCPUTime = m_System.m_CPU_Usage.NonCPUTime();
HighResTimeStamp StartTime, EndTime;
StartTime.SetToNow();
(info->Function())();
EndTime.SetToNow();
uint64_t PostNonCPUTime = g_System->m_CPU_Usage.NonCPUTime();
uint64_t PostNonCPUTime = m_System.m_CPU_Usage.NonCPUTime();
uint64_t TimeTaken = EndTime.GetMicroSeconds() - StartTime.GetMicroSeconds();
if (PostNonCPUTime >= PreNonCPUTime)
{
@ -295,16 +295,16 @@ void CRecompiler::RecompilerMain_Lookup_validate()
{
uint32_t opsExecuted = 0;
while (m_MMU.VAddrToPAddr(PC, PhysicalAddr) && PhysicalAddr >= g_System->RdramSize())
while (m_MMU.VAddrToPAddr(PC, PhysicalAddr) && PhysicalAddr >= m_System.RdramSize())
{
g_System->m_OpCodes.ExecuteOps(g_System->CountPerOp());
opsExecuted += g_System->CountPerOp();
m_System.m_OpCodes.ExecuteOps(m_System.CountPerOp());
opsExecuted += m_System.CountPerOp();
}
if (g_SyncSystem)
{
g_System->UpdateSyncCPU(g_SyncSystem, opsExecuted);
g_System->SyncCPU(g_SyncSystem);
m_System.UpdateSyncCPU(opsExecuted);
m_System.SyncSystem();
}
}
}
@ -441,7 +441,7 @@ CCompiledFunc * CRecompiler::CompileCode()
void CRecompiler::ClearRecompCode_Phys(uint32_t Address, int length, REMOVE_REASON Reason)
{
if (g_System->LookUpMode() == FuncFind_VirtualLookup)
if (m_System.LookUpMode() == FuncFind_VirtualLookup)
{
ClearRecompCode_Virt(Address + 0x80000000, length, Reason);
ClearRecompCode_Virt(Address + 0xA0000000, length, Reason);
@ -453,19 +453,19 @@ void CRecompiler::ClearRecompCode_Phys(uint32_t Address, int length, REMOVE_REAS
ClearRecompCode_Virt(VAddr, length, Reason);
}
}
else if (g_System->LookUpMode() == FuncFind_PhysicalLookup)
else if (m_System.LookUpMode() == FuncFind_PhysicalLookup)
{
if (Address < g_System->RdramSize())
if (Address < m_System.RdramSize())
{
int ClearLen = ((length + 3) & ~3);
if (Address + ClearLen > g_System->RdramSize())
if (Address + ClearLen > m_System.RdramSize())
{
g_Notify->BreakPoint(__FILE__, __LINE__);
ClearLen = g_System->RdramSize() - Address;
ClearLen = m_System.RdramSize() - Address;
}
WriteTrace(TraceRecompiler, TraceInfo, "Resetting jump table, Addr: %X len: %d", Address, ClearLen);
memset((uint8_t *)JumpTable() + Address, 0, ClearLen);
if (g_System->bSMM_Protect())
if (m_System.bSMM_Protect())
{
m_MMU.UnProtectMemory(Address + 0x80000000, Address + 0x80000004);
}
@ -482,7 +482,7 @@ void CRecompiler::ClearRecompCode_Virt(uint32_t Address, int length, REMOVE_REAS
uint32_t AddressIndex, WriteStart;
int DataInBlock, DataToWrite, DataLeft;
switch (g_System->LookUpMode())
switch (m_System.LookUpMode())
{
case FuncFind_VirtualLookup:
AddressIndex = Address >> 0xC;

View File

@ -59,8 +59,8 @@ void CX86RecompilerOps::x86CompilerBreakPoint()
g_System->m_OpCodes.ExecuteOps(g_System->CountPerOp());
if (g_SyncSystem)
{
g_System->UpdateSyncCPU(g_SyncSystem, g_System->CountPerOp());
g_System->SyncCPU(g_SyncSystem);
g_System->UpdateSyncCPU(g_System->CountPerOp());
g_System->SyncSystem();
}
} while (CDebugSettings::isStepping());
@ -70,8 +70,8 @@ void CX86RecompilerOps::x86CompilerBreakPoint()
g_System->m_OpCodes.ExecuteOps(g_System->CountPerOp());
if (g_SyncSystem)
{
g_System->UpdateSyncCPU(g_SyncSystem, g_System->CountPerOp());
g_System->SyncCPU(g_SyncSystem);
g_System->UpdateSyncCPU(g_System->CountPerOp());
g_System->SyncSystem();
}
}
}
@ -81,8 +81,8 @@ void CX86RecompilerOps::x86BreakPointDelaySlot()
g_System->m_OpCodes.ExecuteOps(g_System->CountPerOp());
if (g_SyncSystem)
{
g_System->UpdateSyncCPU(g_SyncSystem, g_System->CountPerOp());
g_System->SyncCPU(g_SyncSystem);
g_System->UpdateSyncCPU(g_System->CountPerOp());
g_System->SyncSystem();
}
if (g_Debugger->ExecutionBP(g_Reg->m_PROGRAM_COUNTER))
{
@ -93,8 +93,8 @@ void CX86RecompilerOps::x86BreakPointDelaySlot()
g_System->m_OpCodes.ExecuteOps(g_System->CountPerOp());
if (g_SyncSystem)
{
g_System->UpdateSyncCPU(g_SyncSystem, g_System->CountPerOp());
g_System->SyncCPU(g_SyncSystem);
g_System->UpdateSyncCPU(g_System->CountPerOp());
g_System->SyncSystem();
}
}
}
@ -9448,8 +9448,7 @@ void CX86RecompilerOps::UpdateSyncCPU(CRegInfo & RegSet, uint32_t Cycles)
m_CodeBlock.Log(" // Updating sync CPU");
RegSet.BeforeCallDirect();
m_Assembler.PushImm32(stdstr_f("%d", Cycles).c_str(), Cycles);
m_Assembler.PushImm32("g_SyncSystem", (uint32_t)g_SyncSystem);
m_Assembler.CallThis((uint32_t)g_System, AddressOf(&CN64System::UpdateSyncCPU), "CN64System::UpdateSyncCPU", 12);
m_Assembler.CallThis((uint32_t)g_System, AddressOf(&CN64System::UpdateSyncCPU), "CN64System::UpdateSyncCPU", 8);
RegSet.AfterCallDirect();
}