From 09b2823ef624469e258db1e5309f3cc63c9ea1a9 Mon Sep 17 00:00:00 2001 From: MadMaurice Date: Wed, 30 Aug 2023 22:16:57 +0200 Subject: [PATCH] memory - Add way to map register into address space --- Makeconf | 1 + memory/register.cpp | 13 +++++++++++++ memory/register.h | 17 +++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 memory/register.cpp create mode 100644 memory/register.h diff --git a/Makeconf b/Makeconf index 73b4f2c..695f9ca 100644 --- a/Makeconf +++ b/Makeconf @@ -2,6 +2,7 @@ modules := memory/mem_device \ memory/bus \ memory/ram \ memory/bootrom_overlay \ + memory/register \ cpu/cpu \ cpu/decoder diff --git a/memory/register.cpp b/memory/register.cpp new file mode 100644 index 0000000..2dcc64d --- /dev/null +++ b/memory/register.cpp @@ -0,0 +1,13 @@ +#include + +void BoundRegister::write8(u16 addr, u8 data) +{ + if(addr) return; + reg = data; +} + +u8 BoundRegister::read8(u16 addr) +{ + if(addr) return 0xFF; + return reg; +} diff --git a/memory/register.h b/memory/register.h new file mode 100644 index 0000000..92aef64 --- /dev/null +++ b/memory/register.h @@ -0,0 +1,17 @@ +#pragma once + +#include +#include + +class BoundRegister : public Mem_device { +private: + u8& reg; +public: + inline + BoundRegister(u8& reg) + : reg(reg) + {} + + virtual void write8(u16 addr, u8 data); + virtual u8 read8(u16 addr); +};