openMSX
MSXMidi.hh
Go to the documentation of this file.
1#ifndef MSXMIDI_HH
2#define MSXMIDI_HH
3
4#include "MSXDevice.hh"
5#include "IRQHelper.hh"
6#include "MidiInConnector.hh"
7#include "MidiOutConnector.hh"
8#include "I8251.hh"
9#include "I8254.hh"
10
11namespace openmsx {
12
13class MSXMidi final : public MSXDevice, public MidiInConnector
14{
15public:
16 explicit MSXMidi(const DeviceConfig& config);
17 ~MSXMidi() override;
18
19 void reset(EmuTime::param time) override;
20 [[nodiscard]] byte readIO(word port, EmuTime::param time) override;
21 [[nodiscard]] byte peekIO(word port, EmuTime::param time) const override;
22 void writeIO(word port, byte value, EmuTime::param time) override;
23
24 // MidiInConnector
25 [[nodiscard]] bool ready() override;
26 [[nodiscard]] bool acceptsData() override;
27 void setDataBits(DataBits bits) override;
28 void setStopBits(StopBits bits) override;
29 void setParityBit(bool enable, Parity parity) override;
30 void recvByte(byte value, EmuTime::param time) override;
31
32 template<typename Archive>
33 void serialize(Archive& ar, unsigned version);
34
35private:
36 void setTimerIRQ(bool status, EmuTime::param time);
37 void enableTimerIRQ(bool enabled, EmuTime::param time);
38 void updateEdgeEvents(EmuTime::param time);
39 void setRxRDYIRQ(bool status);
40 void enableRxRDYIRQ(bool enabled);
41
42 void registerIOports(byte value);
43
44private:
45 struct Counter0 final : ClockPinListener {
46 void signal(ClockPin& pin, EmuTime::param time) override;
47 void signalPosEdge(ClockPin& pin, EmuTime::param time) override;
48 } cntr0; // counter 0 clock pin
49
50 struct Counter2 final : ClockPinListener {
51 void signal(ClockPin& pin, EmuTime::param time) override;
52 void signalPosEdge(ClockPin& pin, EmuTime::param time) override;
53 } cntr2; // counter 2 clock pin
54
55 struct Interface final : I8251Interface {
56 void setRxRDY(bool status, EmuTime::param time) override;
57 void setDTR(bool status, EmuTime::param time) override;
58 void setRTS(bool status, EmuTime::param time) override;
59 [[nodiscard]] bool getDSR(EmuTime::param time) override;
60 [[nodiscard]] bool getCTS(EmuTime::param time) override;
61 void setDataBits(DataBits bits) override;
62 void setStopBits(StopBits bits) override;
63 void setParityBit(bool enable, Parity parity) override;
64 void recvByte(byte value, EmuTime::param time) override;
65 void signal(EmuTime::param time) override;
66 } interface;
67
68 IRQHelper timerIRQ;
69 IRQHelper rxrdyIRQ;
70 bool timerIRQlatch = false;
71 bool timerIRQenabled = false;
72 bool rxrdyIRQlatch = false;
73 bool rxrdyIRQenabled = false;
74
75 const bool isExternalMSXMIDI;
76 bool isEnabled; /* EN bit */
77 bool isLimitedTo8251 = true; /* inverse of E8 bit */
78
79 // must come last
80 MidiOutConnector outConnector;
81 I8251 i8251;
82 I8254 i8254;
83};
85
86} // namespace openmsx
87
88#endif
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition MSXDevice.hh:36
bool acceptsData() override
Definition MSXMidi.cc:358
void recvByte(byte value, EmuTime::param time) override
Definition MSXMidi.cc:378
void serialize(Archive &ar, unsigned version)
Definition MSXMidi.cc:385
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
Definition MSXMidi.cc:77
void setDataBits(DataBits bits) override
Definition MSXMidi.cc:363
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition MSXMidi.cc:101
bool ready() override
Definition MSXMidi.cc:353
void setStopBits(StopBits bits) override
Definition MSXMidi.cc:368
void setParityBit(bool enable, Parity parity) override
Definition MSXMidi.cc:373
void reset(EmuTime::param time) override
This method is called on reset.
Definition MSXMidi.cc:62
~MSXMidi() override
Definition MSXMidi.cc:54
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 MSXMidi.cc:125
This file implemented 3 utility functions:
Definition Autofire.cc:11
uint16_t word
16 bit unsigned integer
Definition openmsx.hh:29
#define SERIALIZE_CLASS_VERSION(CLASS, VERSION)