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); +};