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
7namespace openmsx {
8
9[[nodiscard]] static unsigned calcBaseAddr(const DeviceConfig& config)
10{
11 int base = config.getChild("mem").getAttributeValueAsInt("base", 0);
12 int first = config.getChild("rom").getChildDataAsInt("firstblock", 0);
13 return first * 0x2000 - base;
14}
15
16RomDRAM::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 (void)panasonicMemory.getRomBlock(baseAddr);
23}
24
25byte RomDRAM::readMem(word address, EmuTime::param /*time*/)
26{
27 return *RomDRAM::getReadCacheLine(address);
28}
29
30const byte* RomDRAM::getReadCacheLine(word address) const
31{
32 unsigned addr = address + baseAddr;
33 return &panasonicMemory.getRomBlock(addr >> 13)[addr & 0x1FFF];
34}
35
37
38} // namespace openmsx
#define REGISTER_MSXDEVICE(CLASS, NAME)
Definition MSXDevice.hh:356
std::span< const byte, 0x2000 > getRomBlock(unsigned block) const
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
RomDRAM(const DeviceConfig &config, Rom &&rom)
Definition RomDRAM.cc:16
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
This file implemented 3 utility functions:
Definition Autofire.cc:11
uint16_t word
16 bit unsigned integer
Definition openmsx.hh:29
STL namespace.