openMSX
PanasonicRam.cc
Go to the documentation of this file.
1 #include "PanasonicRam.hh"
2 #include "MSXMotherBoard.hh"
3 #include "PanasonicMemory.hh"
4 #include "serialize.hh"
5 
6 namespace openmsx {
7 
9  : MSXMemoryMapper(config)
10  , panasonicMemory(getMotherBoard().getPanasonicMemory())
11 {
12  panasonicMemory.registerRam(checkedRam.getUncheckedRam());
13 }
14 
15 void PanasonicRam::writeMem(word address, byte value, EmuTime::param /*time*/)
16 {
17  unsigned addr = calcAddress(address);
18  if (panasonicMemory.isWritable(addr)) {
19  checkedRam.write(addr, value);
20  }
21 }
22 
24 {
25  unsigned addr = calcAddress(start);
26  if (panasonicMemory.isWritable(addr)) {
27  return checkedRam.getWriteCacheLine(addr);
28  } else {
29  return unmappedWrite;
30  }
31 }
32 
33 template<typename Archive>
34 void PanasonicRam::serialize(Archive& ar, unsigned /*version*/)
35 {
36  ar.template serializeBase<MSXMemoryMapper>(*this);
37 }
39 REGISTER_MSXDEVICE(PanasonicRam, "PanasonicRam");
40 
41 } // namespace openmsx
byte * getWriteCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing...
Definition: PanasonicRam.cc:23
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.
Definition: PanasonicRam.cc:15
PanasonicRam(const DeviceConfig &config)
Definition: PanasonicRam.cc:8
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
void registerRam(Ram &ram)
Pass reference of the actual Ram block for use in DRAM mode and RAM access via the ROM mapper...
void serialize(Archive &ar, unsigned version)
Definition: PanasonicRam.cc:34
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
Ram & getUncheckedRam()
Give access to the unchecked Ram.
Definition: CheckedRam.hh:50
void write(unsigned addr, byte value)
Definition: CheckedRam.cc:59
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
bool isWritable(unsigned address) const
static byte unmappedWrite[0x10000]
Definition: MSXDevice.hh:275
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:981
unsigned calcAddress(word address) const
Converts a Z80 address to a RAM address.
byte * getWriteCacheLine(unsigned addr) const
Definition: CheckedRam.cc:53