diff options
| author | Hannes Schulze <haschu0103@outlook.de> | 2025-01-16 23:58:33 +0100 |
|---|---|---|
| committer | Hannes Schulze <haschu0103@outlook.de> | 2025-01-16 23:58:33 +0100 |
| commit | 9d80b5b8a61bd8c2336f5032de8b84fea15d685f (patch) | |
| tree | 2b18cd37f1adaeb91215de6b4848e71f990b5a11 /src/nes/mapper.hh | |
| parent | 5734a139d3f218972b5ebaff0e51167770352bcf (diff) | |
implement cpu
Diffstat (limited to 'src/nes/mapper.hh')
| -rw-r--r-- | src/nes/mapper.hh | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/nes/mapper.hh b/src/nes/mapper.hh new file mode 100644 index 0000000..0aec2ac --- /dev/null +++ b/src/nes/mapper.hh @@ -0,0 +1,44 @@ +#pragma once + +#include "nes/util/address.hh" + +namespace nes +{ + class cartridge; + + class mapper + { + using read_func = std::uint8_t(mapper::*)(address); + using write_func = void(mapper::*)(address, std::uint8_t); + + cartridge& cartridge_; + read_func read_; + write_func write_; + + public: + static auto select(cartridge&) -> mapper; + + mapper(mapper const&) = delete; + mapper(mapper&&) = delete; + auto operator=(mapper const&) -> mapper& = delete; + auto operator=(mapper&&) -> mapper& = delete; + + auto read(address const addr) -> std::uint8_t + { + return (this->*read_)(addr); + } + + auto write(address const addr, std::uint8_t const value) -> void + { + (this->*write_)(addr, value); + } + + private: + explicit mapper(cartridge& cartridge, read_func read, write_func write); + + // Implementations + + auto nrom_read(address) -> std::uint8_t; + auto nrom_write(address, std::uint8_t) -> void; + }; +} // namespace nes
\ No newline at end of file |
