36 , numBlocks(config.getChildDataAsInt(
"size", 0) / 8)
37 , ram(config,
getName() +
" RAM",
"Mega-RAM", numBlocks * 0x2000)
38 , rom(config.findChild(
"rom")
39 ? std::make_unique<
Rom>(
getName() +
" ROM",
"Mega-RAM DiskROM", config)
41 , romBlockDebug(*this, bank, 0x0000, 0x10000, 13, 0, 3)
42 , maskBlocks(std::bit_ceil(numBlocks) - 1)
62 romMode = rom !=
nullptr;
73 if (address >= 0x4000 && address <= 0xBFFF) {
74 return &(*rom)[address - 0x4000];
78 unsigned block = bank[(address & 0x7FFF) / 0x2000];
79 return (block < numBlocks)
80 ? &ram[(block * 0x2000) + (address & 0x1FFF)]
89 assert(!romMode && !writeMode);
90 setBank((address & 0x7FFF) / 0x2000, value);
98 unsigned block = bank[(address & 0x7FFF) / 0x2000];
99 return (block < numBlocks)
100 ?
const_cast<byte*
>(&ram[(block * 0x2000) + (address & 0x1FFF)])
116 if (rom) romMode =
true;
137 if (rom) romMode =
true;
143 void MSXMegaRam::setBank(
byte page,
byte block)
145 bank[page] = block & maskBlocks;
146 word adr = page * 0x2000;
151 template<
typename Archive>
154 ar.template serializeBase<MSXDevice>(*
this);
155 ar.serialize(
"ram", ram,
157 "writeMode", writeMode,
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
static byte unmappedRead[0x10000]
void invalidateDeviceRWCache()
Calls MSXCPUInterface::invalidateXXCache() for the specific (part of) the slot that this device is lo...
static byte unmappedWrite[0x10000]
void reset(EmuTime::param time) override
This method is called on reset.
void powerUp(EmuTime::param time) override
This method is called when MSX is powered up.
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
void writeMem(word address, byte value, EmuTime::param time) override
Write a given byte to a given location at a certain time to this device.
byte * getWriteCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
void serialize(Archive &ar, unsigned version)
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
MSXMegaRam(const DeviceConfig &config)
void writeIO(word port, byte value, EmuTime::param time) override
Write a byte to a given IO port at a certain time to this device.
const byte * getReadCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
std::string getName(KeyCode keyCode)
Translate key code to key name.
This file implemented 3 utility functions:
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
uint16_t word
16 bit unsigned integer
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
constexpr auto xrange(T e)