51 lines
1 KiB
C++
51 lines
1 KiB
C++
|
#include "memory/bootrom_overlay.h"
|
||
|
|
||
|
BootRom::BootRom(Mem_device* lowmem, Mem_device* highmem, Mem_device* backend)
|
||
|
: lowmem(lowmem), highmem(highmem), backend(backend), enabled(true)
|
||
|
{}
|
||
|
|
||
|
void BootRom::enable()
|
||
|
{
|
||
|
enabled = true;
|
||
|
}
|
||
|
void BootRom::disable()
|
||
|
{
|
||
|
enabled = false;
|
||
|
}
|
||
|
|
||
|
void BootRom::write8(u16 addr, u8 data)
|
||
|
{
|
||
|
if(enabled && (lowrange.contains(addr) || highrange.contains(addr)))
|
||
|
return;
|
||
|
|
||
|
backend->write8(addr, data);
|
||
|
}
|
||
|
|
||
|
u8 BootRom::read8(u16 addr)
|
||
|
{
|
||
|
if(enabled && lowrange.contains(addr))
|
||
|
return lowmem->read8(addr);
|
||
|
else if(enabled && highrange.contains(addr))
|
||
|
return highmem->read8(addr);
|
||
|
else
|
||
|
return backend->read8(addr);
|
||
|
}
|
||
|
|
||
|
void BootRom::write16(u16 addr, u16 data)
|
||
|
{
|
||
|
if(enabled && (lowrange.contains(addr) || highrange.contains(addr)))
|
||
|
return;
|
||
|
|
||
|
backend->write16(addr, data);
|
||
|
}
|
||
|
|
||
|
u16 BootRom::read16(u16 addr)
|
||
|
{
|
||
|
if(enabled && lowrange.contains(addr))
|
||
|
return lowmem->read16(addr);
|
||
|
else if(enabled && highrange.contains(addr))
|
||
|
return highmem->read16(addr);
|
||
|
else
|
||
|
return backend->read16(addr);
|
||
|
}
|