2023-08-28 21:55:46 +02:00
|
|
|
#include "memory/bootrom_overlay.h"
|
|
|
|
|
|
|
|
BootRom::BootRom(Mem_device* lowmem, Mem_device* highmem, Mem_device* backend)
|
2023-08-30 00:08:05 +02:00
|
|
|
: lowmem(lowmem), highmem(highmem), backend(backend), enabled(true),
|
|
|
|
lowrange(0x0000, 0x00FF), highrange(0x0200, 0x08FF)
|
2023-08-28 21:55:46 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|