Core: if Rom is larger than ISViewerHandler, then use rom handler

This commit is contained in:
zilmar 2022-11-08 10:54:01 +10:30
parent 529812fdca
commit 48da86bea1
3 changed files with 14 additions and 3 deletions

View File

@ -3,9 +3,12 @@
#include "ISViewerHandler.h" #include "ISViewerHandler.h"
#include <Common/File.h> #include <Common/File.h>
#include <Common/path.h> #include <Common/path.h>
#include <Project64-core\N64System\N64Rom.h>
#include <Project64-core\N64System\N64System.h> #include <Project64-core\N64System\N64System.h>
ISViewerHandler::ISViewerHandler(CN64System & System) : ISViewerHandler::ISViewerHandler(CN64System & System, RomMemoryHandler & RomHandler, CN64Rom & Rom) :
m_RomMemoryHandler(RomHandler),
m_Rom(Rom),
m_hLogFile(nullptr), m_hLogFile(nullptr),
m_BufferPos(0) m_BufferPos(0)
{ {
@ -15,6 +18,10 @@ ISViewerHandler::ISViewerHandler(CN64System & System) :
bool ISViewerHandler::Read32(uint32_t Address, uint32_t & Value) 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()) if (!m_Data.empty())
{ {
Value = Swap32by8(*((uint32_t *)&m_Data[Address & 0xFFFC])); Value = Swap32by8(*((uint32_t *)&m_Data[Address & 0xFFFC]));

View File

@ -6,12 +6,14 @@
#include <vector> #include <vector>
class CN64System; class CN64System;
class RomMemoryHandler;
class CN64Rom;
class ISViewerHandler : class ISViewerHandler :
public MemoryHandler public MemoryHandler
{ {
public: public:
ISViewerHandler(CN64System & System); ISViewerHandler(CN64System & System, RomMemoryHandler & RomHandler, CN64Rom & Rom);
bool Read32(uint32_t Address, uint32_t & Value); bool Read32(uint32_t Address, uint32_t & Value);
bool Write32(uint32_t Address, uint32_t Value, uint32_t Mask); bool Write32(uint32_t Address, uint32_t Value, uint32_t Mask);
@ -29,6 +31,8 @@ private:
void SystemReset(void); void SystemReset(void);
RomMemoryHandler & m_RomMemoryHandler;
CN64Rom & m_Rom;
std::unique_ptr<CFile> m_hLogFile; std::unique_ptr<CFile> m_hLogFile;
std::vector<uint8_t> m_Data; std::vector<uint8_t> m_Data;
char m_Buffer[0x1000]; char m_Buffer[0x1000];

View File

@ -25,7 +25,7 @@ CMipsMemoryVM::CMipsMemoryVM(CN64System & System, bool SavesReadOnly) :
m_CartridgeDomain2Address2Handler(System, System.m_Reg, *this, SavesReadOnly), m_CartridgeDomain2Address2Handler(System, System.m_Reg, *this, SavesReadOnly),
m_RDRAMRegistersHandler(System.m_Reg), m_RDRAMRegistersHandler(System.m_Reg),
m_DPCommandRegistersHandler(System, System.GetPlugins(), 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_MIPSInterfaceHandler(System.m_Reg),
m_PeripheralInterfaceHandler(System, *this, System.m_Reg, m_CartridgeDomain2Address2Handler), m_PeripheralInterfaceHandler(System, *this, System.m_Reg, m_CartridgeDomain2Address2Handler),
m_PifRamHandler(System, SavesReadOnly), m_PifRamHandler(System, SavesReadOnly),