mirror of
https://github.com/zoriya/ComSquare.git
synced 2025-12-20 14:15:11 +00:00
Finishing the LoRom mapping
This commit is contained in:
@@ -57,7 +57,7 @@ namespace ComSquare::Memory
|
|||||||
void MemoryBus::mapComponents(SNES &console)
|
void MemoryBus::mapComponents(SNES &console)
|
||||||
{
|
{
|
||||||
// The WRam and PU registers are always mapped at the same address no matter the mapping mode.
|
// The WRam and PU registers are always mapped at the same address no matter the mapping mode.
|
||||||
console.wram->setMemoryRegion(0x7E0000, 0x7FFFFF);
|
console.wram->setMemoryRegion(0x7E, 0x7F, 0x0000, 0xFFFF);
|
||||||
this->_memoryAccessors.push_back(console.wram);
|
this->_memoryAccessors.push_back(console.wram);
|
||||||
|
|
||||||
console.ppu->setMemoryRegion(0x2100, 0x2140);
|
console.ppu->setMemoryRegion(0x2100, 0x2140);
|
||||||
@@ -88,6 +88,10 @@ namespace ComSquare::Memory
|
|||||||
this->_memoryAccessors.emplace_back(new Memory::RectangleShadow(console.cartridge, 0x00, 0x7D, 0x8000, 0xFFFF));
|
this->_memoryAccessors.emplace_back(new Memory::RectangleShadow(console.cartridge, 0x00, 0x7D, 0x8000, 0xFFFF));
|
||||||
// Mirror on the lower half of the Q2.
|
// Mirror on the lower half of the Q2.
|
||||||
this->_memoryAccessors.emplace_back((new Memory::RectangleShadow(console.cartridge, 0x40, 0x6F, 0x0000, 0x7FFF))->setBankOffset(0x40));
|
this->_memoryAccessors.emplace_back((new Memory::RectangleShadow(console.cartridge, 0x40, 0x6F, 0x0000, 0x7FFF))->setBankOffset(0x40));
|
||||||
|
|
||||||
|
console.sram->setMemoryRegion(0x70, 0x7D, 0x0000, 0x7FFF);
|
||||||
|
this->_memoryAccessors.push_back(console.sram);
|
||||||
|
this->_memoryAccessors.emplace_back(new Memory::RectangleShadow(console.sram, 0xFE, 0xFF, 0x0000, 0x7FFF));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,12 +16,13 @@ namespace ComSquare::Memory
|
|||||||
|
|
||||||
uint8_t RectangleShadow::read_internal(uint24_t addr)
|
uint8_t RectangleShadow::read_internal(uint24_t addr)
|
||||||
{
|
{
|
||||||
// TODO implement read/write bank offset.
|
addr += this->_bankOffset << 16u;
|
||||||
return this->_initial->read_internal(addr);
|
return this->_initial->read_internal(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RectangleShadow::write_internal(uint24_t addr, uint8_t data)
|
void RectangleShadow::write_internal(uint24_t addr, uint8_t data)
|
||||||
{
|
{
|
||||||
|
addr += this->_bankOffset << 16u;
|
||||||
this->_initial->write_internal(addr, data);
|
this->_initial->write_internal(addr, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,14 +18,14 @@ namespace ComSquare::Ram
|
|||||||
delete[] this->_data;
|
delete[] this->_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Ram::read(uint24_t addr)
|
uint8_t Ram::read_internal(uint24_t addr)
|
||||||
{
|
{
|
||||||
if (addr >= this->_size)
|
if (addr >= this->_size)
|
||||||
throw InvalidAddress("Ram read", addr);
|
throw InvalidAddress("Ram read", addr);
|
||||||
return this->_data[addr];
|
return this->_data[addr];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ram::write(uint24_t addr, uint8_t data)
|
void Ram::write_internal(uint24_t addr, uint8_t data)
|
||||||
{
|
{
|
||||||
if (addr >= this->_size)
|
if (addr >= this->_size)
|
||||||
throw InvalidAddress("Ram write", addr);
|
throw InvalidAddress("Ram write", addr);
|
||||||
|
|||||||
@@ -5,11 +5,11 @@
|
|||||||
#ifndef COMSQUARE_RAM_HPP
|
#ifndef COMSQUARE_RAM_HPP
|
||||||
#define COMSQUARE_RAM_HPP
|
#define COMSQUARE_RAM_HPP
|
||||||
|
|
||||||
#include "../Memory/IMemory.hpp"
|
#include "../Memory/IRectangleMemory.hpp"
|
||||||
|
|
||||||
namespace ComSquare::Ram
|
namespace ComSquare::Ram
|
||||||
{
|
{
|
||||||
class Ram : public Memory::IMemory {
|
class Ram : public Memory::IRectangleMemory {
|
||||||
private:
|
private:
|
||||||
//! @brief The ram. (Can be used for WRam, SRam, VRam etc)
|
//! @brief The ram. (Can be used for WRam, SRam, VRam etc)
|
||||||
uint8_t *_data;
|
uint8_t *_data;
|
||||||
@@ -24,12 +24,12 @@ namespace ComSquare::Ram
|
|||||||
//! @param addr The address to read from. The address 0x0 should refer to the first byte of this ram.
|
//! @param addr The address to read from. The address 0x0 should refer to the first byte of this ram.
|
||||||
//! @throw InvalidAddress will be thrown if the address is more than the size of the ram.
|
//! @throw InvalidAddress will be thrown if the address is more than the size of the ram.
|
||||||
//! @return Return the data at the address.
|
//! @return Return the data at the address.
|
||||||
uint8_t read(uint24_t addr) override;
|
uint8_t read_internal(uint24_t addr) override;
|
||||||
//! @brief Write data to the ram.
|
//! @brief Write data to the ram.
|
||||||
//! @param addr The address to write to. The address 0x0 should refer to the first byte of this ram.
|
//! @param addr The address to write to. The address 0x0 should refer to the first byte of this ram.
|
||||||
//! @param data The data to write.
|
//! @param data The data to write.
|
||||||
//! @throw InvalidAddress will be thrown if the address is more than the size of the ram.
|
//! @throw InvalidAddress will be thrown if the address is more than the size of the ram.
|
||||||
void write(uint24_t addr, uint8_t data) override;
|
void write_internal(uint24_t addr, uint8_t data) override;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user