openMSX
YM2148.hh
Go to the documentation of this file.
1#ifndef YM2148_HH
2#define YM2148_HH
3
4#include "IRQHelper.hh"
5#include "MidiInConnector.hh"
6#include "MidiOutConnector.hh"
7#include "Schedulable.hh"
8#include "openmsx.hh"
9#include "outer.hh"
10
11namespace openmsx {
12
13class MSXMotherBoard;
14class Scheduler;
15
16class YM2148 final : public MidiInConnector
17{
18public:
19 YM2148(const std::string& name, MSXMotherBoard& motherBoard);
20 void reset();
21
22 void writeCommand(byte value);
23 void writeData(byte value, EmuTime::param time);
24 [[nodiscard]] byte readStatus(EmuTime::param time) const;
25 [[nodiscard]] byte readData(EmuTime::param time);
26 [[nodiscard]] byte peekStatus(EmuTime::param time) const;
27 [[nodiscard]] byte peekData(EmuTime::param time) const;
28
29 [[nodiscard]] bool pendingIRQ() const;
30
31 template<typename Archive>
32 void serialize(Archive& ar, unsigned version);
33
34private:
35 // MidiInConnector
36 [[nodiscard]] bool ready() override;
37 [[nodiscard]] bool acceptsData() override;
38 void setDataBits(DataBits bits) override;
39 void setStopBits(StopBits bits) override;
40 void setParityBit(bool enable, Parity parity) override;
41 void recvByte(byte value, EmuTime::param time) override;
42
43 // Schedulable
44 struct SyncRecv final : Schedulable {
45 friend class YM2148;
46 explicit SyncRecv(Scheduler& s) : Schedulable(s) {}
47 void executeUntil(EmuTime::param time) override {
48 auto& ym2148 = OUTER(YM2148, syncRecv);
49 ym2148.execRecv(time);
50 }
51 } syncRecv;
52 struct SyncTrans final : Schedulable {
53 friend class YM2148;
54 explicit SyncTrans(Scheduler& s) : Schedulable(s) {}
55 void executeUntil(EmuTime::param time) override {
56 auto& ym2148 = OUTER(YM2148, syncTrans);
57 ym2148.execTrans(time);
58 }
59 } syncTrans;
60 void execRecv (EmuTime::param time);
61 void execTrans(EmuTime::param time);
62
63 void send(byte value, EmuTime::param time);
64
65 IRQHelper rxIRQ;
66 IRQHelper txIRQ;
67 bool rxReady;
68 byte rxBuffer; //<! Byte received from MIDI in connector.
69 byte txBuffer1 = 0; //<! The byte currently being send.
70 byte txBuffer2 = 0; //<! The next to-be-send byte.
71 byte status;
72 byte commandReg;
73
74 MidiOutConnector outConnector;
75};
77
78} // namespace openmsx
79
80#endif
Every class that wants to get scheduled at some point must inherit from this class.
void reset()
Definition YM2148.cc:42
byte readData(EmuTime::param time)
Definition YM2148.cc:123
void writeCommand(byte value)
Definition YM2148.cc:135
void serialize(Archive &ar, unsigned version)
Definition YM2148.cc:227
byte peekData(EmuTime::param time) const
Definition YM2148.cc:129
byte readStatus(EmuTime::param time) const
Definition YM2148.cc:113
byte peekStatus(EmuTime::param time) const
Definition YM2148.cc:117
bool pendingIRQ() const
Definition YM2148.cc:221
void writeData(byte value, EmuTime::param time)
Definition YM2148.cc:178
This file implemented 3 utility functions:
Definition Autofire.cc:11
#define OUTER(type, member)
Definition outer.hh:42
#define SERIALIZE_CLASS_VERSION(CLASS, VERSION)