From 8f062975c3f2c3e667708562e06e7206f044f8ff Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 19 Oct 2023 19:28:38 +1030 Subject: [PATCH] Core: improve DisplayControlRegHandler::Write32 --- .../DisplayControlRegHandler.cpp | 44 ++++++++++++++----- .../MemoryHandler/DisplayControlRegHandler.h | 2 + 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/Source/Project64-core/N64System/MemoryHandler/DisplayControlRegHandler.cpp b/Source/Project64-core/N64System/MemoryHandler/DisplayControlRegHandler.cpp index 9d3251737..c03e868cc 100644 --- a/Source/Project64-core/N64System/MemoryHandler/DisplayControlRegHandler.cpp +++ b/Source/Project64-core/N64System/MemoryHandler/DisplayControlRegHandler.cpp @@ -98,37 +98,47 @@ bool DisplayControlRegHandler::Write32(uint32_t Address, uint32_t Value, uint32_ DPC_CURRENT_REG = DPC_START_REG; DPC_STATUS_REG &= ~DPC_STATUS_START_VALID; } - if (m_Plugins->Gfx()->ProcessRDPList) - { - m_Plugins->Gfx()->ProcessRDPList(); - } + ProcessRDPList(); break; //case 0x04100008: g_Reg->DPC_CURRENT_REG = Value; break; case 0x0410000C: - if ((MaskedValue & DPC_CLR_XBUS_DMEM_DMA) != 0) + if ((MaskedValue & DPC_CLR_XBUS_DMEM_DMA) != 0 && (Value & DPC_SET_XBUS_DMEM_DMA) == 0) { DPC_STATUS_REG &= ~DPC_STATUS_XBUS_DMEM_DMA; } - if ((MaskedValue & DPC_SET_XBUS_DMEM_DMA) != 0) + if ((MaskedValue & DPC_SET_XBUS_DMEM_DMA) != 0 && (Value & DPC_CLR_XBUS_DMEM_DMA) == 0) { DPC_STATUS_REG |= DPC_STATUS_XBUS_DMEM_DMA; } - if ((MaskedValue & DPC_CLR_FREEZE) != 0) + if ((MaskedValue & DPC_CLR_FREEZE) != 0 && (Value & DPC_SET_FREEZE) == 0) { DPC_STATUS_REG &= ~DPC_STATUS_FREEZE; + ProcessRDPList(); } - if ((MaskedValue & DPC_SET_FREEZE) != 0) + if ((MaskedValue & DPC_SET_FREEZE) != 0 && (Value & DPC_CLR_FREEZE) == 0) { DPC_STATUS_REG |= DPC_STATUS_FREEZE; } - if ((MaskedValue & DPC_CLR_FLUSH) != 0) + if ((MaskedValue & DPC_CLR_FLUSH) != 0 && (Value & DPC_SET_FLUSH) == 0) { DPC_STATUS_REG &= ~DPC_STATUS_FLUSH; } - if ((MaskedValue & DPC_SET_FLUSH) != 0) + if ((MaskedValue & DPC_SET_FLUSH) != 0 && (Value & DPC_CLR_FLUSH) == 0) { DPC_STATUS_REG |= DPC_STATUS_FLUSH; } + if ((MaskedValue & DPC_CLR_TMEM_CTR) != 0) + { + DPC_STATUS_REG &= ~DPC_STATUS_TMEM_BUSY; + } + if ((MaskedValue & DPC_CLR_PIPE_CTR) != 0) + { + DPC_STATUS_REG &= ~DPC_STATUS_PIPE_BUSY; + } + if ((MaskedValue & DPC_CLR_CMD_CTR) != 0) + { + DPC_STATUS_REG &= ~DPC_STATUS_CMD_BUSY; + } if ((MaskedValue & DPC_CLR_FREEZE) != 0) { if ((SP_STATUS_REG & SP_STATUS_HALT) == 0) @@ -148,3 +158,17 @@ bool DisplayControlRegHandler::Write32(uint32_t Address, uint32_t Value, uint32_ } return true; } + +void DisplayControlRegHandler::ProcessRDPList(void) +{ + if ((DPC_STATUS_REG & DPC_STATUS_FREEZE) != 0) + { + return; + } + DPC_STATUS_REG |= DPC_STATUS_PIPE_BUSY | DPC_STATUS_START_GCLK; + if (DPC_END_REG > DPC_CURRENT_REG && m_Plugins->Gfx()->ProcessRDPList != nullptr) + { + m_Plugins->Gfx()->ProcessRDPList(); + } + DPC_STATUS_REG |= DPC_STATUS_CBUF_READY; +} diff --git a/Source/Project64-core/N64System/MemoryHandler/DisplayControlRegHandler.h b/Source/Project64-core/N64System/MemoryHandler/DisplayControlRegHandler.h index 3327adbaa..919a301f5 100644 --- a/Source/Project64-core/N64System/MemoryHandler/DisplayControlRegHandler.h +++ b/Source/Project64-core/N64System/MemoryHandler/DisplayControlRegHandler.h @@ -74,6 +74,8 @@ private: DisplayControlRegHandler(const DisplayControlRegHandler &); DisplayControlRegHandler & operator=(const DisplayControlRegHandler &); + void ProcessRDPList(void); + CN64System & m_System; CPlugins * m_Plugins; uint32_t & m_PC;