openMSX
MSXDeviceSwitch.hh
Go to the documentation of this file.
1 #ifndef MSXDEVICESWITCH_HH
2 #define MSXDEVICESWITCH_HH
3 
4 #include "MSXDevice.hh"
5 
6 namespace openmsx {
7 
53 class MSXSwitchedDevice;
54 
55 class MSXDeviceSwitch final : public MSXDevice
56 {
57 public:
58  explicit MSXDeviceSwitch(const DeviceConfig& config);
60 
61  // (un)register methods for devices
62  void registerDevice(byte id, MSXSwitchedDevice* device);
63  void unregisterDevice(byte id);
64  bool hasRegisteredDevices() const { return count != 0; }
65 
66  void reset(EmuTime::param time) override;
67  byte readIO(word port, EmuTime::param time) override;
68  byte peekIO(word port, EmuTime::param time) const override;
69  void writeIO(word port, byte value, EmuTime::param time) override;
70 
71  template<typename Archive>
72  void serialize(Archive& ar, unsigned version);
73 
74 private:
75  MSXSwitchedDevice* devices[256];
76  unsigned count;
77  byte selected;
78 };
79 
80 } // namespace openmsx
81 
82 #endif
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
void registerDevice(byte id, MSXSwitchedDevice *device)
void unregisterDevice(byte id)
void reset(EmuTime::param time) override
This method is called on reset.
bool hasRegisteredDevices() const
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.
MSXDeviceSwitch(const DeviceConfig &config)
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX...
Definition: MSXDevice.hh:31
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
void serialize(Archive &ar, unsigned version)
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.