diff --git a/Core/MemoryManager.cpp b/Core/MemoryManager.cpp index 35445f6..4e6a255 100644 --- a/Core/MemoryManager.cpp +++ b/Core/MemoryManager.cpp @@ -15,6 +15,7 @@ void MemoryManager::Initialize(shared_ptr console) { _masterClock = 0; + _openBus = 0; _console = console; _regs = console->GetInternalRegisters().get(); _ppu = console->GetPpu(); @@ -160,10 +161,10 @@ uint8_t MemoryManager::Read(uint32_t addr, MemoryOperationType type) uint8_t value; if(_handlers[addr >> 12]) { value = _handlers[addr >> 12]->Read(addr); + _openBus = value; } else { //open bus - value = (addr >> 12); - + value = _openBus; MessageManager::DisplayMessage("Debug", "Read - missing handler: $" + HexUtilities::ToHex(addr)); } _console->ProcessCpuRead(addr, value, type); @@ -176,9 +177,10 @@ uint8_t MemoryManager::ReadDma(uint32_t addr) uint8_t value; if(_handlers[addr >> 12]) { value = _handlers[addr >> 12]->Read(addr); + _openBus = value; } else { //open bus - value = (addr >> 12); + value = _openBus; MessageManager::DisplayMessage("Debug", "Read - missing handler: $" + HexUtilities::ToHex(addr)); } _console->ProcessCpuRead(addr, value, MemoryOperationType::DmaRead); @@ -226,6 +228,11 @@ void MemoryManager::WriteDma(uint32_t addr, uint8_t value) } } +uint8_t MemoryManager::GetOpenBus() +{ + return _openBus; +} + uint64_t MemoryManager::GetMasterClock() { return _masterClock; diff --git a/Core/MemoryManager.h b/Core/MemoryManager.h index 26cadee..835bbf4 100644 --- a/Core/MemoryManager.h +++ b/Core/MemoryManager.h @@ -30,6 +30,7 @@ private: vector> _workRamHandlers; uint8_t *_workRam; + uint8_t _openBus; uint64_t _masterClock; uint8_t _masterClockTable[2][0x10000]; @@ -56,6 +57,7 @@ public: void Write(uint32_t addr, uint8_t value, MemoryOperationType type); void WriteDma(uint32_t addr, uint8_t value); + uint8_t GetOpenBus(); uint64_t GetMasterClock(); uint8_t* DebugGetWorkRam(); diff --git a/Core/Ppu.cpp b/Core/Ppu.cpp index 0cf297b..4a28693 100644 --- a/Core/Ppu.cpp +++ b/Core/Ppu.cpp @@ -1255,7 +1255,7 @@ uint8_t Ppu::Read(uint16_t addr) break; } - return addr >> 8; + return _console->GetMemoryManager()->GetOpenBus(); } void Ppu::Write(uint32_t addr, uint8_t value)