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
6namespace openmsx {
7
9 : MSXMemoryMapperBase(config)
10 , panasonicMemory(getMotherBoard().getPanasonicMemory())
11{
12 panasonicMemory.registerRam(checkedRam.getUncheckedRam());
13}
14
15void 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.data();
30 }
31}
32
33void PanasonicRam::writeIO(word port, byte value, EmuTime::param time)
34{
35 MSXMemoryMapperBase::writeIOImpl(port, value, time);
36 byte page = port & 3;
37 unsigned addr = segmentOffset(page);
38 if (byte* data = checkedRam.getRWCacheLines(addr, 0x4000)) {
39 const byte* rData = data;
40 byte* wData = panasonicMemory.isWritable(addr) ? data : unmappedWrite.data();
41 fillDeviceRWCache(page * 0x4000, 0x4000, rData, wData);
42 } else {
43 invalidateDeviceRWCache(page * 0x4000, 0x4000);
44 }
45}
46
47template<typename Archive>
48void PanasonicRam::serialize(Archive& ar, unsigned /*version*/)
49{
50 ar.template serializeBase<MSXMemoryMapperBase>(*this);
51}
54
55} // namespace openmsx
byte * getRWCacheLines(size_t addr, size_t size) const
Definition: CheckedRam.cc:51
Ram & getUncheckedRam()
Give access to the unchecked Ram.
Definition: CheckedRam.hh:51
byte * getWriteCacheLine(size_t addr) const
Definition: CheckedRam.cc:45
void write(size_t addr, byte value)
Definition: CheckedRam.cc:64
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:505
static std::array< byte, 0x10000 > unmappedWrite
Definition: MSXDevice.hh:303
void invalidateDeviceRWCache()
Calls MSXCPUInterface::invalidateXXCache() for the specific (part of) the slot that this device is lo...
Definition: MSXDevice.hh:210
unsigned calcAddress(word address) const
Converts a Z80 address to a RAM address.
void writeIOImpl(word port, byte value, EmuTime::param time)
unsigned segmentOffset(byte page) const
void registerRam(Ram &ram)
Pass reference of the actual Ram block for use in DRAM mode and RAM access via the ROM mapper.
bool isWritable(unsigned address) const
void serialize(Archive &ar, unsigned version)
Definition: PanasonicRam.cc:48
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
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.
Definition: PanasonicRam.cc:33
PanasonicRam(const DeviceConfig &config)
Definition: PanasonicRam.cc:8
This file implemented 3 utility functions:
Definition: Autofire.cc:9
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:1021