openMSX
CassettePort.hh
Go to the documentation of this file.
1 #ifndef CASSETTEPORT_HH
2 #define CASSETTEPORT_HH
3 
4 #include "Connector.hh"
5 #include "serialize_meta.hh"
6 #include "components.hh"
7 
8 namespace openmsx {
9 
10 class HardwareConfig;
11 class MSXMotherBoard;
12 class CassetteDevice;
13 class CassettePlayer;
14 #if COMPONENT_LASERDISC
15 class LaserdiscPlayer;
16 #endif
17 
19 {
20 public:
21  virtual ~CassettePortInterface() = default;
22 
27  virtual void setMotor(bool status, EmuTime::param time) = 0;
28 
36  virtual void cassetteOut(bool output, EmuTime::param time) = 0;
37 
42  virtual bool lastOut() const = 0;
43 
52  virtual bool cassetteIn(EmuTime::param time) = 0;
53 
54 #if COMPONENT_LASERDISC
55 
59  virtual void setLaserdiscPlayer(LaserdiscPlayer *laserdisc) = 0;
60 #endif
61 };
62 
63 class CassettePort final : public CassettePortInterface, public Connector
64 {
65 public:
66  explicit CassettePort(const HardwareConfig& hwConf);
67  ~CassettePort() override;
68  void setMotor(bool status, EmuTime::param time) override;
69  void cassetteOut(bool output, EmuTime::param time) override;
70  bool cassetteIn(EmuTime::param time) override;
71 #if COMPONENT_LASERDISC
72  void setLaserdiscPlayer(LaserdiscPlayer* laserdisc) override;
73 #endif
74  bool lastOut() const override;
75 
76  // Connector
77  std::string_view getDescription() const override;
78  std::string_view getClass() const override;
79  void unplug(EmuTime::param time) override;
80 
81  template<typename Archive>
82  void serialize(Archive& ar, unsigned version);
83 
84 private:
85  CassetteDevice& getPluggedCasDev() const;
86 
87  MSXMotherBoard& motherBoard;
88 
89 #if COMPONENT_LASERDISC
90  LaserdiscPlayer* laserdiscPlayer;
91 #endif
92  CassettePlayer* cassettePlayer;
93 
94  bool lastOutput;
95  bool motorControl;
96 };
98 
100 {
101 public:
102  void setMotor(bool status, EmuTime::param time) override;
103  void cassetteOut(bool output, EmuTime::param time) override;
104  bool cassetteIn(EmuTime::param time) override;
105 #if COMPONENT_LASERDISC
106  void setLaserdiscPlayer(LaserdiscPlayer *laserdisc) override;
107 #endif
108  bool lastOut() const override;
109 };
110 
111 } // namespace openmsx
112 
113 #endif
openmsx::HardwareConfig
HardwareConfig
Definition: HardwareConfig.cc:459
openmsx::CassettePort::serialize
void serialize(Archive &ar, unsigned version)
Definition: CassettePort.cc:134
openmsx::CassettePortInterface::cassetteOut
virtual void cassetteOut(bool output, EmuTime::param time)=0
Writes one bit to the cassette port.
openmsx::DummyCassettePort
Definition: CassettePort.hh:99
openmsx::CassettePortInterface::setLaserdiscPlayer
virtual void setLaserdiscPlayer(LaserdiscPlayer *laserdisc)=0
Set the Laserdisc Player; when the motor control is off, sound is read from the laserdisc.
openmsx::CassettePort::cassetteIn
bool cassetteIn(EmuTime::param time) override
Reads one bit from the cassette port.
Definition: CassettePort.cc:88
serialize_meta.hh
openmsx::CassettePortInterface::lastOut
virtual bool lastOut() const =0
last bit written to CasOut.
openmsx::CassettePlayer
CassettePlayer
Definition: CassettePlayer.cc:952
openmsx::LaserdiscPlayer
Definition: LaserdiscPlayer.hh:25
openmsx::CassettePortInterface::cassetteIn
virtual bool cassetteIn(EmuTime::param time)=0
Reads one bit from the cassette port.
openmsx::CassettePort
Definition: CassettePort.hh:63
openmsx::SERIALIZE_CLASS_VERSION
SERIALIZE_CLASS_VERSION(CassettePlayer, 2)
openmsx::CassettePort::setMotor
void setMotor(bool status, EmuTime::param time) override
Sets the cassette motor relay false = off true = on.
Definition: CassettePort.cc:69
openmsx::DummyCassettePort::setLaserdiscPlayer
void setLaserdiscPlayer(LaserdiscPlayer *laserdisc) override
Set the Laserdisc Player; when the motor control is off, sound is read from the laserdisc.
Definition: CassettePort.cc:39
openmsx::CassettePort::cassetteOut
void cassetteOut(bool output, EmuTime::param time) override
Writes one bit to the cassette port.
Definition: CassettePort.cc:76
openmsx::MSXMotherBoard
Definition: MSXMotherBoard.hh:59
openmsx::CassettePort::setLaserdiscPlayer
void setLaserdiscPlayer(LaserdiscPlayer *laserdisc) override
Set the Laserdisc Player; when the motor control is off, sound is read from the laserdisc.
Definition: CassettePort.cc:107
openmsx::LaserdiscPlayer
LaserdiscPlayer
Definition: LaserdiscPlayer.cc:1133
openmsx::CassettePortInterface
Definition: CassettePort.hh:18
openmsx::CassetteDevice
Definition: CassetteDevice.hh:9
openmsx::CassettePortInterface::~CassettePortInterface
virtual ~CassettePortInterface()=default
openmsx::DummyCassettePort::setMotor
void setMotor(bool status, EmuTime::param time) override
Sets the cassette motor relay false = off true = on.
Definition: CassettePort.cc:22
openmsx::CassettePort::getClass
std::string_view getClass() const override
A Connector belong to a certain class.
Definition: CassettePort.cc:123
openmsx::DummyCassettePort::cassetteIn
bool cassetteIn(EmuTime::param time) override
Reads one bit from the cassette port.
Definition: CassettePort.cc:30
components.hh
Connector.hh
openmsx::CassettePort::getDescription
std::string_view getDescription() const override
Get a description for this connector.
Definition: CassettePort.cc:118
openmsx::CassettePort::~CassettePort
~CassettePort() override
Definition: CassettePort.cc:63
openmsx::CassettePort::lastOut
bool lastOut() const override
last bit written to CasOut.
Definition: CassettePort.cc:83
openmsx::Connector
Represents something you can plug devices into.
Definition: Connector.hh:20
openmsx::HardwareConfig
Definition: HardwareConfig.hh:21
openmsx::CassettePlayer
Definition: CassettePlayer.hh:25
openmsx::DummyCassettePort::cassetteOut
void cassetteOut(bool output, EmuTime::param time) override
Writes one bit to the cassette port.
Definition: CassettePort.cc:26
openmsx::CassettePortInterface::setMotor
virtual void setMotor(bool status, EmuTime::param time)=0
Sets the cassette motor relay false = off true = on.
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::CassettePort::unplug
void unplug(EmuTime::param time) override
This unplugs the currently inserted Pluggable from this Connector.
Definition: CassettePort.cc:113
openmsx::DummyCassettePort::lastOut
bool lastOut() const override
last bit written to CasOut.
Definition: CassettePort.cc:34
openmsx::CassettePort::CassettePort
CassettePort(const HardwareConfig &hwConf)
Definition: CassettePort.cc:48