openMSX
MusicalMemoryMapper.hh
Go to the documentation of this file.
1 #ifndef MUSICALMEMORYMAPPER_HH
2 #define MUSICALMEMORYMAPPER_HH
3 
4 #include "MSXMemoryMapperBase.hh"
5 #include <memory>
6 
7 namespace openmsx {
8 
9 class SN76489;
10 
16 {
17 public:
18  MusicalMemoryMapper(const DeviceConfig& config);
19  ~MusicalMemoryMapper() override;
20 
21  void reset(EmuTime::param time) override;
22  byte readIO(word port, EmuTime::param time) override;
23  byte peekIO(word port, EmuTime::param time) const override;
24  void writeIO(word port, byte value, EmuTime::param time) override;
25  byte peekMem(word address, EmuTime::param time) const override;
26  byte readMem(word address, EmuTime::param time) override;
27  void writeMem(word address, byte value, EmuTime::param time) override;
28  const byte* getReadCacheLine(word start) const override;
29  byte* getWriteCacheLine(word start) const override;
30 
31  template<typename Archive>
32  void serialize(Archive& ar, unsigned version);
33 
34 private:
39  int readReg(word address) const;
40 
44  bool registerAccessAt(word address) const;
45 
49  bool writeProtected(word address) const {
50  unsigned page = address >> 14;
51  return (controlReg & (1 << page)) != 0;
52  }
53 
54  void updateControlReg(byte value);
55 
56  std::unique_ptr<SN76489> sn76489;
57  byte controlReg;
58 };
59 
60 } // namespace openmsx
61 
62 #endif
openmsx::MusicalMemoryMapper::writeMem
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: MusicalMemoryMapper.cc:161
openmsx::MusicalMemoryMapper
Memory mapper which also controls an SN76489AN sound chip.
Definition: MusicalMemoryMapper.hh:15
openmsx::MusicalMemoryMapper::getWriteCacheLine
byte * getWriteCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
Definition: MusicalMemoryMapper.cc:197
openmsx::MusicalMemoryMapper::writeIO
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: MusicalMemoryMapper.cc:58
openmsx::DeviceConfig
Definition: DeviceConfig.hh:19
MSXMemoryMapperBase.hh
openmsx::MusicalMemoryMapper::peekMem
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
Definition: MusicalMemoryMapper.cc:149
openmsx::MusicalMemoryMapper::~MusicalMemoryMapper
~MusicalMemoryMapper() override
openmsx::MusicalMemoryMapper::peekIO
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition: MusicalMemoryMapper.cc:49
openmsx::SN76489
SN76489
Definition: SN76489.cc:323
openmsx::MusicalMemoryMapper::reset
void reset(EmuTime::param time) override
This method is called on reset.
Definition: MusicalMemoryMapper.cc:23
openmsx::MusicalMemoryMapper::MusicalMemoryMapper
MusicalMemoryMapper(const DeviceConfig &config)
Definition: MusicalMemoryMapper.cc:14
openmsx::MusicalMemoryMapper::serialize
void serialize(Archive &ar, unsigned version)
Definition: MusicalMemoryMapper.cc:212
openmsx::word
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
openmsx::MusicalMemoryMapper::getReadCacheLine
const byte * getReadCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
Definition: MusicalMemoryMapper.cc:187
openmsx::MSXMemoryMapperBase
Definition: MSXMemoryMapperBase.hh:11
openmsx::MusicalMemoryMapper::readIO
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
Definition: MusicalMemoryMapper.cc:40
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::MusicalMemoryMapper::readMem
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
Definition: MusicalMemoryMapper.cc:155