openMSX
MSXMapperIO.hh
Go to the documentation of this file.
1 #ifndef MSXMAPPERIO_HH
2 #define MSXMAPPERIO_HH
3 
4 #include "MSXDevice.hh"
5 #include "MSXMotherBoard.hh"
6 #include "SimpleDebuggable.hh"
7 #include <vector>
8 
9 namespace openmsx {
10 
12 {
13  virtual byte readIO(word port, EmuTime::param time) = 0;
14  virtual byte peekIO(word port, EmuTime::param time) const = 0;
15  virtual void writeIO(word port, byte value, EmuTime::param time) = 0;
16  virtual byte getSelectedSegment(byte page) const = 0;
17 protected:
19 };
20 
21 
22 class MSXMapperIO final : public MSXDevice
23 {
24 public:
25  explicit MSXMapperIO(const DeviceConfig& config);
26 
27  byte readIO(word port, EmuTime::param time) override;
28  byte peekIO(word port, EmuTime::param time) const override;
29  void writeIO(word port, byte value, EmuTime::param time) override;
30 
33 
34  template<typename Archive>
35  void serialize(Archive& ar, unsigned version);
36 
37 private:
38  struct Debuggable final : SimpleDebuggable {
39  Debuggable(MSXMotherBoard& motherBoard, const std::string& name);
40  byte read(unsigned address) override;
41  void write(unsigned address, byte value, EmuTime::param time) override;
42  } debuggable;
43 
44  std::vector<MSXMemoryMapperInterface*> mappers;
45 
50  byte mask;
51 };
53 
54 
56 {
57 protected:
59  : motherBoard(motherBoard_)
60  {
61  auto& mapperIO = motherBoard.createMapperIO();
62  mapperIO.registerMapper(this);
63  }
64 
66  {
67  auto& mapperIO = motherBoard.getMapperIO();
68  mapperIO.unregisterMapper(this);
69  motherBoard.destroyMapperIO();
70  }
71 
72 private:
73  MSXMotherBoard& motherBoard;
74 };
75 
76 } // namespace openmsx
77 
78 #endif
openmsx::MSXDevice
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition: MSXDevice.hh:32
openmsx::MSXMotherBoard::createMapperIO
MSXMapperIO & createMapperIO()
All memory mappers in one MSX machine share the same four (logical) memory mapper registers.
Definition: MSXMotherBoard.cc:669
openmsx::MSXMapperIOClient::MSXMapperIOClient
MSXMapperIOClient(MSXMotherBoard &motherBoard_)
Definition: MSXMapperIO.hh:58
openmsx::MSXMemoryMapperInterface::getSelectedSegment
virtual byte getSelectedSegment(byte page) const =0
openmsx::DeviceConfig
Definition: DeviceConfig.hh:20
openmsx::MSXMemoryMapperInterface
Definition: MSXMapperIO.hh:12
openmsx::MSXMemoryMapperInterface::writeIO
virtual void writeIO(word port, byte value, EmuTime::param time)=0
openmsx::SimpleDebuggable
Definition: SimpleDebuggable.hh:12
openmsx::MSXMapperIO::unregisterMapper
void unregisterMapper(MSXMemoryMapperInterface *mapper)
Definition: MSXMapperIO.cc:45
openmsx::MSXMemoryMapperInterface::peekIO
virtual byte peekIO(word port, EmuTime::param time) const =0
openmsx::MSXMapperIO::MSXMapperIO
MSXMapperIO(const DeviceConfig &config)
Definition: MSXMapperIO.cc:32
openmsx::SERIALIZE_CLASS_VERSION
SERIALIZE_CLASS_VERSION(CassettePlayer, 2)
openmsx::MSXMapperIO::peekIO
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition: MSXMapperIO.cc:59
openmsx::MSXMotherBoard::getMapperIO
MSXMapperIO & getMapperIO() const
Definition: MSXMotherBoard.hh:184
openmsx::MSXMotherBoard
Definition: MSXMotherBoard.hh:61
MSXDevice.hh
openmsx::MSXMapperIOClient::~MSXMapperIOClient
~MSXMapperIOClient()
Definition: MSXMapperIO.hh:65
SimpleDebuggable.hh
openmsx::MSXMotherBoard::destroyMapperIO
void destroyMapperIO()
Definition: MSXMotherBoard.cc:688
openmsx::MSXMapperIO::readIO
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
Definition: MSXMapperIO.cc:50
openmsx::MSXMemoryMapperInterface::~MSXMemoryMapperInterface
~MSXMemoryMapperInterface()=default
openmsx::word
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
openmsx::MSXMapperIOClient
Definition: MSXMapperIO.hh:56
openmsx::MSXMapperIO
Definition: MSXMapperIO.hh:23
openmsx::MSXMapperIO::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: MSXMapperIO.cc:68
openmsx::MSXMapperIO::registerMapper
void registerMapper(MSXMemoryMapperInterface *mapper)
Definition: MSXMapperIO.cc:40
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
MSXMotherBoard.hh
openmsx::MSXMapperIO::serialize
void serialize(Archive &ar, unsigned version)
Definition: MSXMapperIO.cc:107
openmsx::MSXMemoryMapperInterface::readIO
virtual byte readIO(word port, EmuTime::param time)=0