[Project64] Change order of MMV initialization
This commit is contained in:
parent
d408190f87
commit
26ab7f6b70
|
@ -131,19 +131,19 @@ void CMipsMemoryVM::FreeReservedMemory()
|
|||
}
|
||||
}
|
||||
|
||||
bool CMipsMemoryVM::Initialize()
|
||||
bool CMipsMemoryVM::Initialize(bool SyncSystem)
|
||||
{
|
||||
if (m_RDRAM != NULL)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m_Reserve1)
|
||||
if (!SyncSystem && m_RDRAM == NULL && m_Reserve1 != NULL)
|
||||
{
|
||||
m_RDRAM = m_Reserve1;
|
||||
m_Reserve1 = NULL;
|
||||
}
|
||||
if (m_RDRAM == NULL && m_Reserve2)
|
||||
if (SyncSystem && m_RDRAM == NULL && m_Reserve2 != NULL)
|
||||
{
|
||||
m_RDRAM = m_Reserve2;
|
||||
m_Reserve2 = NULL;
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
static void ReserveMemory();
|
||||
static void FreeReservedMemory();
|
||||
|
||||
bool Initialize();
|
||||
bool Initialize(bool SyncSystem);
|
||||
void Reset(bool EraseMemory);
|
||||
|
||||
uint8_t * Rdram();
|
||||
|
|
|
@ -45,7 +45,6 @@ CN64System::CN64System(CPlugins * Plugins, bool SavesReadOnly, bool SyncSystem)
|
|||
m_NextTimer(0),
|
||||
m_SystemTimer(m_Reg, m_NextTimer),
|
||||
m_bCleanFrameBox(true),
|
||||
m_bInitialized(false),
|
||||
m_RspBroke(true),
|
||||
m_DMAUsed(false),
|
||||
m_TestTimer(false),
|
||||
|
@ -60,6 +59,8 @@ CN64System::CN64System(CPlugins * Plugins, bool SavesReadOnly, bool SyncSystem)
|
|||
m_SyncCpu(SyncSystem)
|
||||
{
|
||||
WriteTrace(TraceN64System, TraceDebug, "Start");
|
||||
memset(m_LastSuccessSyncPC, 0, sizeof(m_LastSuccessSyncPC));
|
||||
|
||||
uint32_t gameHertz = g_Settings->LoadDword(Game_ScreenHertz);
|
||||
if (gameHertz == 0)
|
||||
{
|
||||
|
@ -71,6 +72,24 @@ CN64System::CN64System(CPlugins * Plugins, bool SavesReadOnly, bool SyncSystem)
|
|||
WriteTrace(TraceN64System, TraceDebug, "Setting up system");
|
||||
CInterpreterCPU::BuildCPU();
|
||||
|
||||
if (!m_MMU_VM.Initialize(SyncSystem))
|
||||
{
|
||||
WriteTrace(TraceN64System, TraceWarning, "MMU failed to Initialize");
|
||||
WriteTrace(TraceN64System, TraceDebug, "Done");
|
||||
return;
|
||||
}
|
||||
|
||||
WriteTrace(TraceN64System, TraceDebug, "Reseting Plugins");
|
||||
g_Notify->DisplayMessage(5, MSG_PLUGIN_INIT);
|
||||
m_Plugins->CreatePlugins();
|
||||
bool bRes = m_Plugins->Initiate(this);
|
||||
if (!bRes)
|
||||
{
|
||||
WriteTrace(TraceN64System, TraceError, "g_Plugins->Initiate Failed");
|
||||
WriteTrace(TraceN64System, TraceDebug, "Done (Res: false)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SyncSystem)
|
||||
{
|
||||
uint32_t CpuType = g_Settings->LoadDword(Game_CpuType);
|
||||
|
@ -93,6 +112,8 @@ CN64System::CN64System(CPlugins * Plugins, bool SavesReadOnly, bool SyncSystem)
|
|||
m_SyncCPU = new CN64System(m_SyncPlugins, true, true);
|
||||
}
|
||||
|
||||
Reset(true, true);
|
||||
|
||||
if (CpuType == CPU_Recompiler || CpuType == CPU_SyncCores)
|
||||
{
|
||||
m_Recomp = new CRecompiler(m_MMU_VM, m_Reg, m_EndEmulation);
|
||||
|
@ -693,7 +714,6 @@ void CN64System::Reset(bool bInitReg, bool ClearMenory)
|
|||
|
||||
bool CN64System::SetActiveSystem(bool bActive)
|
||||
{
|
||||
bool bInitPlugin = false;
|
||||
bool bReset = false;
|
||||
bool bRes = true;
|
||||
|
||||
|
@ -736,19 +756,6 @@ bool CN64System::SetActiveSystem(bool bActive)
|
|||
R4300iOp::m_TestTimer = m_TestTimer;
|
||||
R4300iOp::m_NextInstruction = m_NextInstruction;
|
||||
R4300iOp::m_JumpToLocation = m_JumpToLocation;
|
||||
|
||||
if (!m_bInitialized)
|
||||
{
|
||||
if (!m_MMU_VM.Initialize())
|
||||
{
|
||||
WriteTrace(TraceN64System, TraceWarning, "MMU failed to Initialize");
|
||||
WriteTrace(TraceN64System, TraceDebug, "Done (Res: false)");
|
||||
return false;
|
||||
}
|
||||
bReset = true;
|
||||
m_bInitialized = true;
|
||||
bInitPlugin = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -771,24 +778,6 @@ bool CN64System::SetActiveSystem(bool bActive)
|
|||
}
|
||||
}
|
||||
|
||||
if (bInitPlugin)
|
||||
{
|
||||
WriteTrace(TraceN64System, TraceDebug, "Reseting Plugins");
|
||||
g_Notify->DisplayMessage(5, MSG_PLUGIN_INIT);
|
||||
m_Plugins->CreatePlugins();
|
||||
bRes = m_Plugins->Initiate(this);
|
||||
if (!bRes)
|
||||
{
|
||||
WriteTrace(TraceN64System, TraceError, "g_Plugins->Initiate Failed");
|
||||
WriteTrace(TraceN64System, TraceDebug, "Done (Res: false)");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (bReset)
|
||||
{
|
||||
Reset(true, true);
|
||||
}
|
||||
return bRes;
|
||||
}
|
||||
|
||||
|
@ -1621,7 +1610,7 @@ bool CN64System::SaveState()
|
|||
hSaveFile.Write(m_Reg.m_Peripheral_Interface, sizeof(uint32_t) * 13);
|
||||
hSaveFile.Write(m_Reg.m_RDRAM_Interface, sizeof(uint32_t) * 8);
|
||||
hSaveFile.Write(m_Reg.m_SerialInterface, sizeof(uint32_t) * 4);
|
||||
hSaveFile.Write(&g_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32);
|
||||
hSaveFile.Write(&m_TLB.TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32);
|
||||
hSaveFile.Write(g_MMU->PifRam(), 0x40);
|
||||
hSaveFile.Write(g_MMU->Rdram(), RdramSize);
|
||||
hSaveFile.Write(g_MMU->Dmem(), 0x1000);
|
||||
|
@ -1720,9 +1709,9 @@ bool CN64System::LoadState(const char * FileName)
|
|||
|
||||
uint32_t Value, SaveRDRAMSize, NextVITimer = 0, old_status, old_width, old_dacrate;
|
||||
bool LoadedZipFile = false, AudioResetOnLoad;
|
||||
old_status = g_Reg->VI_STATUS_REG;
|
||||
old_width = g_Reg->VI_WIDTH_REG;
|
||||
old_dacrate = g_Reg->AI_DACRATE_REG;
|
||||
old_status = m_Reg.VI_STATUS_REG;
|
||||
old_width = m_Reg.VI_WIDTH_REG;
|
||||
old_dacrate = m_Reg.AI_DACRATE_REG;
|
||||
|
||||
CPath SaveFile(FileName);
|
||||
|
||||
|
@ -1778,8 +1767,8 @@ bool CN64System::LoadState(const char * FileName)
|
|||
}
|
||||
Reset(false, true);
|
||||
|
||||
g_MMU->UnProtectMemory(0x80000000, 0x80000000 + g_Settings->LoadDword(Game_RDRamSize) - 4);
|
||||
g_MMU->UnProtectMemory(0xA4000000, 0xA4001FFC);
|
||||
m_MMU_VM.UnProtectMemory(0x80000000, 0x80000000 + g_Settings->LoadDword(Game_RDRamSize) - 4);
|
||||
m_MMU_VM.UnProtectMemory(0xA4000000, 0xA4001FFC);
|
||||
g_Settings->SaveDword(Game_RDRamSize, SaveRDRAMSize);
|
||||
unzReadCurrentFile(file, &NextVITimer, sizeof(NextVITimer));
|
||||
unzReadCurrentFile(file, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER));
|
||||
|
@ -1798,7 +1787,7 @@ bool CN64System::LoadState(const char * FileName)
|
|||
unzReadCurrentFile(file, m_Reg.m_Peripheral_Interface, sizeof(uint32_t) * 13);
|
||||
unzReadCurrentFile(file, m_Reg.m_RDRAM_Interface, sizeof(uint32_t) * 8);
|
||||
unzReadCurrentFile(file, m_Reg.m_SerialInterface, sizeof(uint32_t) * 4);
|
||||
unzReadCurrentFile(file, (void *const)&g_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32);
|
||||
unzReadCurrentFile(file, (void *const)&m_TLB.TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32);
|
||||
unzReadCurrentFile(file, m_MMU_VM.PifRam(), 0x40);
|
||||
unzReadCurrentFile(file, m_MMU_VM.Rdram(), SaveRDRAMSize);
|
||||
unzReadCurrentFile(file, m_MMU_VM.Dmem(), 0x1000);
|
||||
|
@ -1865,7 +1854,7 @@ bool CN64System::LoadState(const char * FileName)
|
|||
hSaveFile.Read(m_Reg.m_Peripheral_Interface, sizeof(uint32_t) * 13);
|
||||
hSaveFile.Read(m_Reg.m_RDRAM_Interface, sizeof(uint32_t) * 8);
|
||||
hSaveFile.Read(m_Reg.m_SerialInterface, sizeof(uint32_t) * 4);
|
||||
hSaveFile.Read((void *const)&g_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32);
|
||||
hSaveFile.Read((void *const)&m_TLB.TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32);
|
||||
hSaveFile.Read(m_MMU_VM.PifRam(), 0x40);
|
||||
hSaveFile.Read(m_MMU_VM.Rdram(), SaveRDRAMSize);
|
||||
hSaveFile.Read(m_MMU_VM.Dmem(), 0x1000);
|
||||
|
@ -1888,24 +1877,24 @@ bool CN64System::LoadState(const char * FileName)
|
|||
{
|
||||
m_Reg.m_AudioIntrReg |= MI_INTR_AI;
|
||||
m_Reg.AI_STATUS_REG &= ~AI_STATUS_FIFO_FULL;
|
||||
g_Reg->MI_INTR_REG |= MI_INTR_AI;
|
||||
m_Reg.MI_INTR_REG |= MI_INTR_AI;
|
||||
}
|
||||
|
||||
if (bFixedAudio())
|
||||
{
|
||||
m_Audio.SetFrequency(m_Reg.AI_DACRATE_REG, g_System->SystemType());
|
||||
m_Audio.SetFrequency(m_Reg.AI_DACRATE_REG, SystemType());
|
||||
}
|
||||
|
||||
if (old_status != g_Reg->VI_STATUS_REG)
|
||||
if (old_status != m_Reg.VI_STATUS_REG)
|
||||
{
|
||||
g_Plugins->Gfx()->ViStatusChanged();
|
||||
}
|
||||
|
||||
if (old_width != g_Reg->VI_WIDTH_REG)
|
||||
if (old_width != m_Reg.VI_WIDTH_REG)
|
||||
{
|
||||
g_Plugins->Gfx()->ViWidthChanged();
|
||||
}
|
||||
g_Plugins->Audio()->DacrateChanged(g_System->SystemType());
|
||||
g_Plugins->Audio()->DacrateChanged(SystemType());
|
||||
|
||||
//Fix Random Register
|
||||
while ((int)m_Reg.RANDOM_REGISTER < (int)m_Reg.WIRED_REGISTER)
|
||||
|
|
|
@ -153,7 +153,6 @@ private:
|
|||
int32_t m_NextTimer;
|
||||
CSystemTimer m_SystemTimer;
|
||||
bool m_bCleanFrameBox;
|
||||
bool m_bInitialized;
|
||||
bool m_RspBroke;
|
||||
bool m_DMAUsed;
|
||||
uint32_t m_Buttons[4];
|
||||
|
|
Loading…
Reference in New Issue