memory - Add way to map register into address space
This commit is contained in:
parent
3f1a23b7e5
commit
09b2823ef6
3 changed files with 31 additions and 0 deletions
1
Makeconf
1
Makeconf
|
@ -2,6 +2,7 @@ modules := memory/mem_device \
|
||||||
memory/bus \
|
memory/bus \
|
||||||
memory/ram \
|
memory/ram \
|
||||||
memory/bootrom_overlay \
|
memory/bootrom_overlay \
|
||||||
|
memory/register \
|
||||||
cpu/cpu \
|
cpu/cpu \
|
||||||
cpu/decoder
|
cpu/decoder
|
||||||
|
|
||||||
|
|
13
memory/register.cpp
Normal file
13
memory/register.cpp
Normal 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
17
memory/register.h
Normal 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);
|
||||||
|
};
|
Loading…
Reference in a new issue