diff --git a/Source/Project64-core/N64System/MemoryHandler/PeripheralInterfaceHandler.cpp b/Source/Project64-core/N64System/MemoryHandler/PeripheralInterfaceHandler.cpp index 77444e982..ad05c9fbb 100644 --- a/Source/Project64-core/N64System/MemoryHandler/PeripheralInterfaceHandler.cpp +++ b/Source/Project64-core/N64System/MemoryHandler/PeripheralInterfaceHandler.cpp @@ -35,9 +35,11 @@ PeripheralInterfaceHandler::PeripheralInterfaceHandler(CN64System & System, CMip m_Domain2Address2Handler(Domain2Address2Handler), m_MMU(MMU), m_Reg(Reg), - m_PC(Reg.m_PROGRAM_COUNTER) + m_PC(Reg.m_PROGRAM_COUNTER), + m_DMAUsed(false) { System.RegisterCallBack(CN64SystemCB_Reset, this, (CN64System::CallBackFunction)stSystemReset); + System.RegisterCallBack(CN64SystemCB_LoadedGameState, this, (CN64System::CallBackFunction)stLoadedGameState); } bool PeripheralInterfaceHandler::Read32(uint32_t Address, uint32_t & Value) @@ -166,10 +168,16 @@ bool PeripheralInterfaceHandler::Write32(uint32_t Address, uint32_t Value, uint3 return true; } +void PeripheralInterfaceHandler::LoadedGameState(void) +{ + m_DMAUsed = true; +} + void PeripheralInterfaceHandler::SystemReset(void) { PI_RD_LEN_REG = 0x0000007F; PI_WR_LEN_REG = 0x0000007F; + m_DMAUsed = false; } void PeripheralInterfaceHandler::OnFirstDMA() @@ -282,9 +290,9 @@ void PeripheralInterfaceHandler::PI_DMA_READ() } PI_CART_ADDR_REG += 0x10000000; - if (!g_System->DmaUsed()) + if (!m_DMAUsed) { - g_System->SetDmaUsed(true); + m_DMAUsed = true; OnFirstDMA(); } if (g_Recompiler && g_System->bSMM_PIDMA()) @@ -335,9 +343,9 @@ void PeripheralInterfaceHandler::PI_DMA_WRITE() g_Debugger->PIDMAWriteStarted(); } - if (!g_System->DmaUsed()) + if (!m_DMAUsed) { - g_System->SetDmaUsed(true); + m_DMAUsed = true; OnFirstDMA(); } diff --git a/Source/Project64-core/N64System/MemoryHandler/PeripheralInterfaceHandler.h b/Source/Project64-core/N64System/MemoryHandler/PeripheralInterfaceHandler.h index 8c81ef43d..0469bdcad 100644 --- a/Source/Project64-core/N64System/MemoryHandler/PeripheralInterfaceHandler.h +++ b/Source/Project64-core/N64System/MemoryHandler/PeripheralInterfaceHandler.h @@ -69,9 +69,11 @@ private: PeripheralInterfaceHandler & operator=(const PeripheralInterfaceHandler &); static void stSystemReset(PeripheralInterfaceHandler * _this) { _this->SystemReset(); } + static void stLoadedGameState(PeripheralInterfaceHandler * _this) { _this->LoadedGameState(); } void PI_DMA_READ(); void PI_DMA_WRITE(); + void LoadedGameState(void); void SystemReset(void); void OnFirstDMA(); void ReadBlock(uint32_t Address, uint8_t * Block, uint32_t BlockLen); @@ -80,4 +82,6 @@ private: CMipsMemoryVM & m_MMU; CRegisters & m_Reg; uint32_t & m_PC; + + bool m_DMAUsed; }; diff --git a/Source/Project64-core/N64System/N64System.cpp b/Source/Project64-core/N64System/N64System.cpp index 3ae3d898d..538a7c497 100644 --- a/Source/Project64-core/N64System/N64System.cpp +++ b/Source/Project64-core/N64System/N64System.cpp @@ -39,7 +39,6 @@ CN64System::CN64System(CPlugins * Plugins, uint32_t randomizer_seed, bool SavesR m_SystemTimer(*this), m_bCleanFrameBox(true), m_RspBroke(true), - m_DMAUsed(false), m_TestTimer(false), m_PipelineStage(PIPELINE_STAGE_NORMAL), m_JumpToLocation(0), @@ -912,7 +911,6 @@ void CN64System::Reset(bool bInitReg, bool ClearMenory) m_AlistCount = 0; m_DlistCount = 0; m_UnknownCount = 0; - m_DMAUsed = false; m_RspBroke = true; m_SyncCount = 0; diff --git a/Source/Project64-core/N64System/N64System.h b/Source/Project64-core/N64System/N64System.h index 786d5f6c3..a29a5c53f 100644 --- a/Source/Project64-core/N64System/N64System.h +++ b/Source/Project64-core/N64System/N64System.h @@ -97,8 +97,6 @@ public: void SyncSystem(); void SyncSystemPC(); - bool DmaUsed() const { return m_DMAUsed; } - void SetDmaUsed(bool DMAUsed) { m_DMAUsed = DMAUsed; } CPlugins * GetPlugins() { return m_Plugins; } PIPELINE_STAGE PipelineStage() const { return m_PipelineStage; } uint32_t JumpToLocation() const { return m_JumpToLocation; } @@ -174,7 +172,6 @@ private: CSystemTimer m_SystemTimer; bool m_bCleanFrameBox; bool m_RspBroke; - bool m_DMAUsed; uint32_t m_Buttons[4]; bool m_TestTimer; PIPELINE_STAGE m_PipelineStage;