openMSX
MSXFacMidiInterface.hh
Go to the documentation of this file.
1 #ifndef MSXFACMIDIINTERFACE_HH
2 #define MSXFACMIDIINTERFACE_HH
3 
4 #include "MSXDevice.hh"
5 #include "MidiInConnector.hh"
6 #include "MidiOutConnector.hh"
7 #include "I8251.hh"
8 
9 namespace openmsx {
10 
11 class MSXFacMidiInterface final : public MSXDevice, public MidiInConnector
12 {
13 public:
14  explicit MSXFacMidiInterface(const DeviceConfig& config);
15 
16  void reset(EmuTime::param time) override;
17  byte readIO(word port, EmuTime::param time) override;
18  byte peekIO(word port, EmuTime::param time) const override;
19  void writeIO(word port, byte value, EmuTime::param time) override;
20 
21  // MidiInConnector
22  bool ready() override;
23  bool acceptsData() override;
24  void setDataBits(DataBits bits) override;
25  void setStopBits(StopBits bits) override;
26  void setParityBit(bool enable, ParityBit parity) override;
27  void recvByte(byte value, EmuTime::param time) override;
28 
29  template<typename Archive>
30  void serialize(Archive& ar, unsigned version);
31 
32 private:
33  struct I8251Interf final : I8251Interface {
34  void setRxRDY(bool status, EmuTime::param time) override;
35  void setDTR(bool status, EmuTime::param time) override;
36  void setRTS(bool status, EmuTime::param time) override;
37  bool getDSR(EmuTime::param time) override;
38  bool getCTS(EmuTime::param time) override;
39  void setDataBits(DataBits bits) override;
40  void setStopBits(StopBits bits) override;
41  void setParityBit(bool enable, ParityBit parity) override;
42  void recvByte(byte value, EmuTime::param time) override;
43  void signal(EmuTime::param time) override;
44  } interf;
45 
46  // must come last
47  MidiOutConnector outConnector;
48  I8251 i8251;
49 };
50 
51 } // namespace openmsx
52 
53 #endif
openmsx::MSXDevice
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition: MSXDevice.hh:31
I8251.hh
openmsx::MidiInConnector
Definition: MidiInConnector.hh:12
openmsx::MSXFacMidiInterface
Definition: MSXFacMidiInterface.hh:11
openmsx::MSXFacMidiInterface::ready
bool ready() override
Definition: MSXFacMidiInterface.cc:101
openmsx::DeviceConfig
Definition: DeviceConfig.hh:19
openmsx::MSXFacMidiInterface::acceptsData
bool acceptsData() override
Definition: MSXFacMidiInterface.cc:106
openmsx::I8251Interface
Definition: I8251.hh:15
openmsx::MSXFacMidiInterface::reset
void reset(EmuTime::param time) override
This method is called on reset.
Definition: MSXFacMidiInterface.cc:20
openmsx::MSXFacMidiInterface::readIO
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
Definition: MSXFacMidiInterface.cc:25
openmsx::MSXFacMidiInterface::MSXFacMidiInterface
MSXFacMidiInterface(const DeviceConfig &config)
Definition: MSXFacMidiInterface.cc:8
openmsx::MSXFacMidiInterface::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: MSXFacMidiInterface.cc:37
openmsx::MidiOutConnector
Definition: MidiOutConnector.hh:11
MidiInConnector.hh
openmsx::MSXFacMidiInterface::recvByte
void recvByte(byte value, EmuTime::param time) override
Definition: MSXFacMidiInterface.cc:126
MSXDevice.hh
openmsx::SerialDataInterface::StopBits
StopBits
Definition: SerialDataInterface.hh:15
openmsx::SerialDataInterface::DataBits
DataBits
Definition: SerialDataInterface.hh:12
openmsx::MSXFacMidiInterface::setParityBit
void setParityBit(bool enable, ParityBit parity) override
Definition: MSXFacMidiInterface.cc:121
openmsx::word
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
openmsx::MSXFacMidiInterface::peekIO
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition: MSXFacMidiInterface.cc:32
MidiOutConnector.hh
openmsx::MSXFacMidiInterface::serialize
void serialize(Archive &ar, unsigned version)
Definition: MSXFacMidiInterface.cc:133
openmsx::I8251
Definition: I8251.hh:30
openmsx::SerialDataInterface::ParityBit
ParityBit
Definition: SerialDataInterface.hh:19
openmsx::MSXFacMidiInterface::setStopBits
void setStopBits(StopBits bits) override
Definition: MSXFacMidiInterface.cc:116
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::MSXFacMidiInterface::setDataBits
void setDataBits(DataBits bits) override
Definition: MSXFacMidiInterface.cc:111