Solving bugs with the rectangle shadow

This commit is contained in:
AnonymusRaccoon
2020-02-11 10:57:35 +01:00
parent 04ea6f25d0
commit 02760c469d
7 changed files with 72 additions and 21 deletions
+3 -2
View File
@@ -2,6 +2,7 @@
// Created by anonymus-raccoon on 1/29/20.
//
#include <iostream>
#include "IRectangleMemory.hpp"
#include "../Exceptions/InvalidAddress.hpp"
@@ -14,9 +15,9 @@ namespace ComSquare::Memory
unsigned bankCount = bank - this->_startBank;
unsigned pageCount = this->_endPage - this->_startPage;
if (bank < this->_startBank || bank >= this->_endBank)
if (bank < this->_startBank || bank > this->_endBank)
throw InvalidAddress("Rectangle memory read Invalid Bank", addr);
if (page < this->_startPage || page >= this->_endPage)
if (page < this->_startPage || page > this->_endPage)
throw InvalidAddress("Rectangle memory read Invalid Page", addr);
page -= this->_startPage;
page += pageCount * bankCount;
+7 -7
View File
@@ -46,12 +46,12 @@ namespace ComSquare::Memory
handler->write(addr - handler->getStart(), data);
}
void MemoryBus::_mirrorComponents(SNES &console, int i)
void MemoryBus::_mirrorComponents(SNES &console, unsigned i)
{
this->_memoryAccessors.emplace_back(new Memory::MemoryShadow(console.wram, i, i + 0x1FFF));
this->_memoryAccessors.emplace_back(new Memory::MemoryShadow(console.ppu, i + 0x2100, i + 0x213F));
this->_memoryAccessors.emplace_back(new Memory::MemoryShadow(console.apu, i + 0x2140, i + 0x2143));
this->_memoryAccessors.emplace_back(new Memory::MemoryShadow(console.cpu, i + 0x4200, i + 0x421F));
this->_memoryAccessors.emplace_back(new Memory::RectangleShadow(console.wram, i, i, 0x0000, 0x1FFF));
this->_memoryAccessors.emplace_back(new Memory::MemoryShadow(console.ppu, (i << 16u) + 0x2100, (i << 16u) + 0x213F));
this->_memoryAccessors.emplace_back(new Memory::MemoryShadow(console.apu, (i << 16u) + 0x2140, (i << 16u) + 0x2143));
this->_memoryAccessors.emplace_back(new Memory::MemoryShadow(console.cpu, (i << 16u) + 0x4200, (i << 16u) + 0x421F));
}
void MemoryBus::mapComponents(SNES &console)
@@ -73,10 +73,10 @@ namespace ComSquare::Memory
// TODO implement Joys.
// Mirror to the quarter 1.
for (uint24_t i = 0; i < 0x400000; i += 0x010000)
for (uint8_t i = 0x00; i < 0x40; i += 0x01)
this->_mirrorComponents(console, i);
// Mirror to the quarter 3.
for (uint24_t i = 0x800000; i < 0xC00000; i += 0x10000)
for (uint8_t i = 0x80; i < 0xC0; i += 0x01)
this->_mirrorComponents(console, i);
if (console.cartridge->header.mappingMode & Cartridge::LoRom) {
+1 -1
View File
@@ -33,7 +33,7 @@ namespace ComSquare
//! @brief WRam, CPU, PPU & APU registers are mirrored to all banks of Q1 & Q3. This function is used for the mirroring.
//! @param console All the components.
//! @param i Base address for the mirrors.
inline void _mirrorComponents(SNES &console, int i);
inline void _mirrorComponents(SNES &console, unsigned i);
public:
//! @brief Read data at a global address.
+1
View File
@@ -5,6 +5,7 @@
#include "RectangleShadow.hpp"
#include <utility>
#include <iostream>
namespace ComSquare::Memory
{