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);
59  ~MSXDeviceSwitch() override;
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
openmsx::MSXDevice
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition: MSXDevice.hh:32
openmsx::MSXDeviceSwitch::readIO
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
Definition: MSXDeviceSwitch.cc:61
openmsx::DeviceConfig
Definition: DeviceConfig.hh:20
openmsx::MSXDeviceSwitch::hasRegisteredDevices
bool hasRegisteredDevices() const
Definition: MSXDeviceSwitch.hh:64
openmsx::MSXDeviceSwitch::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: MSXDeviceSwitch.cc:79
openmsx::MSXSwitchedDevice
Definition: MSXSwitchedDevice.hh:12
openmsx::MSXDeviceSwitch::serialize
void serialize(Archive &ar, unsigned version)
Definition: MSXDeviceSwitch.cc:92
openmsx::MSXDeviceSwitch
Definition: MSXDeviceSwitch.hh:56
openmsx::MSXDeviceSwitch::unregisterDevice
void unregisterDevice(byte id)
Definition: MSXDeviceSwitch.cc:43
openmsx::MSXDeviceSwitch::MSXDeviceSwitch
MSXDeviceSwitch(const DeviceConfig &config)
Definition: MSXDeviceSwitch.cc:11
openmsx::MSXDeviceSwitch::reset
void reset(EmuTime::param time) override
This method is called on reset.
Definition: MSXDeviceSwitch.cc:56
MSXDevice.hh
openmsx::MSXDeviceSwitch::registerDevice
void registerDevice(byte id, MSXSwitchedDevice *device)
Definition: MSXDeviceSwitch.cc:26
openmsx::MSXDeviceSwitch::~MSXDeviceSwitch
~MSXDeviceSwitch() override
Definition: MSXDeviceSwitch.cc:19
openmsx::word
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::MSXDeviceSwitch::peekIO
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition: MSXDeviceSwitch.cc:70