summaryrefslogtreecommitdiff
path: root/src/nes/mapper.hh
diff options
context:
space:
mode:
authorHannes Schulze <haschu0103@outlook.de>2025-01-18 19:35:42 +0100
committerHannes Schulze <haschu0103@outlook.de>2025-01-18 19:35:42 +0100
commit67672d06776e38b06f31f6599678767c60eed58a (patch)
tree4846c762815b887036b10a7aadd849dd8fdd4420 /src/nes/mapper.hh
parentfe7243fdd14f6ef57033f9e70141aba970dba7ea (diff)
implement ppu io registers
Diffstat (limited to 'src/nes/mapper.hh')
-rw-r--r--src/nes/mapper.hh42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/nes/mapper.hh b/src/nes/mapper.hh
index 0aec2ac..f2873a6 100644
--- a/src/nes/mapper.hh
+++ b/src/nes/mapper.hh
@@ -8,12 +8,16 @@ namespace nes
class mapper
{
- using read_func = std::uint8_t(mapper::*)(address);
- using write_func = void(mapper::*)(address, std::uint8_t);
+ using read_cpu_func = std::uint8_t(mapper::*)(address);
+ using write_cpu_func = void(mapper::*)(address, std::uint8_t);
+ using read_ppu_func = std::uint8_t(mapper::*)(address, std::uint8_t const* vram);
+ using write_ppu_func = void(mapper::*)(address, std::uint8_t* vram, std::uint8_t);
cartridge& cartridge_;
- read_func read_;
- write_func write_;
+ read_cpu_func read_cpu_;
+ write_cpu_func write_cpu_;
+ read_ppu_func read_ppu_;
+ write_ppu_func write_ppu_;
public:
static auto select(cartridge&) -> mapper;
@@ -23,22 +27,38 @@ namespace nes
auto operator=(mapper const&) -> mapper& = delete;
auto operator=(mapper&&) -> mapper& = delete;
- auto read(address const addr) -> std::uint8_t
+ auto read_cpu(address const addr) -> std::uint8_t
{
- return (this->*read_)(addr);
+ return (this->*read_cpu_)(addr);
}
- auto write(address const addr, std::uint8_t const value) -> void
+ auto write_cpu(address const addr, std::uint8_t const value) -> void
{
- (this->*write_)(addr, value);
+ (this->*write_cpu_)(addr, value);
+ }
+
+ auto read_ppu(address const addr, std::uint8_t const* vram) -> std::uint8_t
+ {
+ return (this->*read_ppu_)(addr, vram);
+ }
+
+ auto write_ppu(address const addr, std::uint8_t* vram, std::uint8_t const value) -> void
+ {
+ (this->*write_ppu_)(addr, vram, value);
}
private:
- explicit mapper(cartridge& cartridge, read_func read, write_func write);
+ explicit mapper(
+ cartridge& cartridge,
+ read_cpu_func read_cpu, write_cpu_func write_cpu,
+ read_ppu_func read_ppu, write_ppu_func write_ppu);
// Implementations
- auto nrom_read(address) -> std::uint8_t;
- auto nrom_write(address, std::uint8_t) -> void;
+ auto nrom_read_cpu(address) -> std::uint8_t;
+ auto nrom_write_cpu(address, std::uint8_t) -> void;
+ auto nrom_read_ppu(address, std::uint8_t const* vram) -> std::uint8_t;
+ auto nrom_write_ppu(address, std::uint8_t* vram, std::uint8_t) -> void;
+ auto nrom_mirrored_vram_address(address) const -> unsigned;
};
} // namespace nes \ No newline at end of file