openMSX
MSXMemoryMapper.cc
Go to the documentation of this file.
1 #include "MSXMemoryMapper.hh"
2 #include "serialize.hh"
3 
4 namespace openmsx {
5 
7  : MSXMemoryMapperBase(config)
8 {
9 }
10 
11 void MSXMemoryMapper::writeIO(word port, byte value, EmuTime::param time)
12 {
13  MSXMemoryMapperBase::writeIOImpl(port, value, time);
14  byte page = port & 3;
15  if (byte* data = checkedRam.getRWCacheLines(segmentOffset(page), 0x4000)) {
16  fillDeviceRWCache(page * 0x4000, 0x4000, data);
17  } else {
18  invalidateDeviceRWCache(page * 0x4000, 0x4000);
19  }
20 }
21 
22 template<typename Archive>
23 void MSXMemoryMapper::serialize(Archive& ar, unsigned version)
24 {
25  // use serializeInlinedBase instead of serializeBase for bw-compat savestates
26  ar.template serializeInlinedBase<MSXMemoryMapperBase>(*this, version);
27 }
28 
30 REGISTER_MSXDEVICE(MSXMemoryMapper, "MemoryMapper");
31 
32 } // namespace openmsx
unsigned segmentOffset(byte page) const
void invalidateDeviceRWCache()
Calls MSXCPUInterface::invalidateXXCache() for the specific (part of) the slot that this device is lo...
Definition: MSXDevice.hh:208
byte * getRWCacheLines(unsigned addr, unsigned size) const
Definition: CheckedRam.cc:59
MSXMemoryMapper(const DeviceConfig &config)
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
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.
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void fillDeviceRWCache(unsigned start, unsigned size, byte *rwData)
Calls MSXCPUInterface::fillXXCache() for the specific (part of) the slot that this device is located ...
Definition: MSXDevice.cc:509
void writeIOImpl(word port, byte value, EmuTime::param time)
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:981
void serialize(Archive &ar, unsigned version)