openMSX
RomDRAM.cc
Go to the documentation of this file.
1 #include "RomDRAM.hh"
2 #include "PanasonicMemory.hh"
3 #include "MSXMotherBoard.hh"
4 #include "XMLElement.hh"
5 #include "serialize.hh"
6 
7 namespace openmsx {
8 
9 static unsigned calcBaseAddr(const DeviceConfig& config)
10 {
11  int base = config.getChild("mem").getAttributeAsInt("base");
12  int first = config.getChild("rom").getChildDataAsInt("firstblock");
13  return first * 0x2000 - base;
14 }
15 
16 RomDRAM::RomDRAM(const DeviceConfig& config, Rom&& rom_)
17  : MSXRom(config, std::move(rom_))
18  , panasonicMemory(getMotherBoard().getPanasonicMemory())
19  , baseAddr(calcBaseAddr(config))
20 {
21  // ignore result, only called to trigger 'missing rom' error early
22  panasonicMemory.getRomBlock(baseAddr);
23 }
24 
25 byte RomDRAM::readMem(word address, EmuTime::param /*time*/)
26 {
27  return *RomDRAM::getReadCacheLine(address);
28 }
29 
30 const byte* RomDRAM::getReadCacheLine(word address) const
31 {
32  unsigned addr = address + baseAddr;
33  return &panasonicMemory.getRomBlock(addr >> 13)[addr & 0x1FFF];
34 }
35 
36 REGISTER_MSXDEVICE(RomDRAM, "RomDRAM");
37 
38 } // namespace openmsx
serialize.hh
openmsx::DeviceConfig
Definition: DeviceConfig.hh:19
openmsx::PanasonicMemory::getRomBlock
const byte * getRomBlock(unsigned block)
Definition: PanasonicMemory.cc:43
XMLElement.hh
openmsx::REGISTER_MSXDEVICE
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
openmsx::MSXRom
Definition: MSXRom.hh:9
openmsx::RomDRAM::getReadCacheLine
const byte * getReadCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
Definition: RomDRAM.cc:30
openmsx::RomDRAM::readMem
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
Definition: RomDRAM.cc:25
openmsx::Rom
Definition: Rom.hh:20
openmsx::RomDRAM::RomDRAM
RomDRAM(const DeviceConfig &config, Rom &&rom)
Definition: RomDRAM.cc:16
openmsx::RomDRAM
Definition: RomDRAM.hh:10
openmsx::word
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
PanasonicMemory.hh
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
MSXMotherBoard.hh
RomDRAM.hh