memory - Add way to map register into address space

This commit is contained in:
madmaurice 2023-08-30 22:16:57 +02:00
parent 3f1a23b7e5
commit 09b2823ef6
3 changed files with 31 additions and 0 deletions

View file

@ -2,6 +2,7 @@ modules := memory/mem_device \
memory/bus \
memory/ram \
memory/bootrom_overlay \
memory/register \
cpu/cpu \
cpu/decoder

13
memory/register.cpp Normal file
View file

@ -0,0 +1,13 @@
#include <memory/register.h>
void BoundRegister::write8(u16 addr, u8 data)
{
if(addr) return;
reg = data;
}
u8 BoundRegister::read8(u16 addr)
{
if(addr) return 0xFF;
return reg;
}

17
memory/register.h Normal file
View file

@ -0,0 +1,17 @@
#pragma once
#include <misc/types.h>
#include <memory/mem_device.h>
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);
};