| 1 |
#include "RomDRAM.hh" |
| 2 |
|
| 3 |
#include "PanasonicMemory.hh" |
| 4 |
|
| 5 |
#include "MSXMotherBoard.hh" |
| 6 |
#include "XMLElement.hh" |
| 7 |
#include "serialize.hh" |
| 8 |
|
| 9 |
namespace openmsx { |
| 10 |
|
| 11 |
[[nodiscard]] static unsigned calcBaseAddr(const DeviceConfig& config) |
| 12 |
{ |
| 13 |
int base = config.getChild("mem").getAttributeValueAsInt("base", 0); |
| 14 |
int first = config.getChild("rom").getChildDataAsInt("firstblock", 0); |
| 15 |
return first * 0x2000 - base; |
| 16 |
} |
| 17 |
|
| 18 |
RomDRAM::RomDRAM(const DeviceConfig& config, Rom&& rom_) |
| 19 |
: MSXRom(config, std::move(rom_)) |
| 20 |
, panasonicMemory(getMotherBoard().getPanasonicMemory()) |
| 21 |
, baseAddr(calcBaseAddr(config)) |
| 22 |
{ |
| 23 |
|
| 24 |
(void)panasonicMemory.getRomBlock(baseAddr); |
| 25 |
} |
| 26 |
|
| 27 |
byte RomDRAM::readMem(uint16_t address, EmuTime ) |
| 28 |
{ |
| 29 |
return *RomDRAM::getReadCacheLine(address); |
| 30 |
} |
| 31 |
|
| 32 |
const byte* RomDRAM::getReadCacheLine(uint16_t address) const |
| 33 |
{ |
| 34 |
unsigned addr = address + baseAddr; |
| 35 |
return &panasonicMemory.getRomBlock(addr >> 13)[addr & 0x1FFF]; |
| 36 |
} |
| 37 |
|
| 38 |
REGISTER_MSXDEVICE(RomDRAM, "RomDRAM"); |
| 39 |
|
| 40 |
} |