From 48da86bea1dd516a118ff3eefbc0060b9c8abfa9 Mon Sep 17 00:00:00 2001 From: zilmar Date: Tue, 8 Nov 2022 10:54:01 +1030 Subject: [PATCH] Core: if Rom is larger than ISViewerHandler, then use rom handler --- .../N64System/MemoryHandler/ISViewerHandler.cpp | 9 ++++++++- .../N64System/MemoryHandler/ISViewerHandler.h | 6 +++++- .../Project64-core/N64System/Mips/MemoryVirtualMem.cpp | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Source/Project64-core/N64System/MemoryHandler/ISViewerHandler.cpp b/Source/Project64-core/N64System/MemoryHandler/ISViewerHandler.cpp index d87150005..d47e6997c 100644 --- a/Source/Project64-core/N64System/MemoryHandler/ISViewerHandler.cpp +++ b/Source/Project64-core/N64System/MemoryHandler/ISViewerHandler.cpp @@ -3,9 +3,12 @@ #include "ISViewerHandler.h" #include #include +#include #include -ISViewerHandler::ISViewerHandler(CN64System & System) : +ISViewerHandler::ISViewerHandler(CN64System & System, RomMemoryHandler & RomHandler, CN64Rom & Rom) : + m_RomMemoryHandler(RomHandler), + m_Rom(Rom), m_hLogFile(nullptr), m_BufferPos(0) { @@ -15,6 +18,10 @@ ISViewerHandler::ISViewerHandler(CN64System & System) : bool ISViewerHandler::Read32(uint32_t Address, uint32_t & Value) { + if ((Address & 0xFFFFFFF) < m_Rom.GetRomSize()) + { + return m_RomMemoryHandler.Read32(Address, Value); + } if (!m_Data.empty()) { Value = Swap32by8(*((uint32_t *)&m_Data[Address & 0xFFFC])); diff --git a/Source/Project64-core/N64System/MemoryHandler/ISViewerHandler.h b/Source/Project64-core/N64System/MemoryHandler/ISViewerHandler.h index 6336abcef..0209aab5d 100644 --- a/Source/Project64-core/N64System/MemoryHandler/ISViewerHandler.h +++ b/Source/Project64-core/N64System/MemoryHandler/ISViewerHandler.h @@ -6,12 +6,14 @@ #include class CN64System; +class RomMemoryHandler; +class CN64Rom; class ISViewerHandler : public MemoryHandler { public: - ISViewerHandler(CN64System & System); + ISViewerHandler(CN64System & System, RomMemoryHandler & RomHandler, CN64Rom & Rom); bool Read32(uint32_t Address, uint32_t & Value); bool Write32(uint32_t Address, uint32_t Value, uint32_t Mask); @@ -29,6 +31,8 @@ private: void SystemReset(void); + RomMemoryHandler & m_RomMemoryHandler; + CN64Rom & m_Rom; std::unique_ptr m_hLogFile; std::vector m_Data; char m_Buffer[0x1000]; diff --git a/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp b/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp index 71ff9a94e..f75c75fe2 100755 --- a/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp +++ b/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp @@ -25,7 +25,7 @@ CMipsMemoryVM::CMipsMemoryVM(CN64System & System, bool SavesReadOnly) : m_CartridgeDomain2Address2Handler(System, System.m_Reg, *this, SavesReadOnly), m_RDRAMRegistersHandler(System.m_Reg), m_DPCommandRegistersHandler(System, System.GetPlugins(), System.m_Reg), - m_ISViewerHandler(System), + m_ISViewerHandler(System, m_RomMemoryHandler, *g_Rom), m_MIPSInterfaceHandler(System.m_Reg), m_PeripheralInterfaceHandler(System, *this, System.m_Reg, m_CartridgeDomain2Address2Handler), m_PifRamHandler(System, SavesReadOnly),