openMSX
CassettePort.hh
Go to the documentation of this file.
1#ifndef CASSETTEPORT_HH
2#define CASSETTEPORT_HH
3
4#include "Connector.hh"
6#include "serialize_meta.hh"
7#include "components.hh"
8
9namespace openmsx {
10
11class HardwareConfig;
12class MSXMotherBoard;
13class CassetteDevice;
14class CassettePlayer;
15#if COMPONENT_LASERDISC
16class LaserdiscPlayer;
17#endif
18
20{
21public:
22 virtual ~CassettePortInterface() = default;
23
28 virtual void setMotor(bool status, EmuTime::param time) = 0;
29
37 virtual void cassetteOut(bool output, EmuTime::param time) = 0;
38
43 [[nodiscard]] virtual bool lastOut() const = 0;
44
53 virtual bool cassetteIn(EmuTime::param time) = 0;
54
55#if COMPONENT_LASERDISC
60 virtual void setLaserdiscPlayer(LaserdiscPlayer *laserdisc) = 0;
61#endif
62
67};
68
69class CassettePort final : public CassettePortInterface, public Connector
70{
71public:
72 explicit CassettePort(const HardwareConfig& hwConf);
73 ~CassettePort() override;
74 void setMotor(bool status, EmuTime::param time) override;
75 void cassetteOut(bool output, EmuTime::param time) override;
76 bool cassetteIn(EmuTime::param time) override;
77#if COMPONENT_LASERDISC
78 void setLaserdiscPlayer(LaserdiscPlayer* laserdisc) override;
79#endif
80 [[nodiscard]] bool lastOut() const override;
81 CassettePlayer* getCassettePlayer() override { return cassettePlayer; }
82
83 // Connector
84 [[nodiscard]] std::string_view getDescription() const override;
85 [[nodiscard]] std::string_view getClass() const override;
86
87 template<typename Archive>
88 void serialize(Archive& ar, unsigned version);
89
90private:
91 [[nodiscard]] CassetteDevice& getPluggedCasDev() const;
92
93 MSXMotherBoard& motherBoard;
94
95#if COMPONENT_LASERDISC
96 LaserdiscPlayer* laserdiscPlayer = nullptr;
97#endif
98 CassettePlayer* cassettePlayer;
99
100 bool lastOutput = false;
101 bool motorControl = false;
102};
104
106{
107public:
108 explicit DummyCassettePort(MSXMotherBoard& motherBoard);
109 void setMotor(bool status, EmuTime::param time) override;
110 void cassetteOut(bool output, EmuTime::param time) override;
111 bool cassetteIn(EmuTime::param time) override;
112#if COMPONENT_LASERDISC
113 void setLaserdiscPlayer(LaserdiscPlayer *laserdisc) override;
114#endif
115 [[nodiscard]] bool lastOut() const override;
116 CassettePlayer* getCassettePlayer() override { return nullptr; }
117private:
118 CassettePlayerCommand cassettePlayerCommand;
119};
120
121} // namespace openmsx
122
123#endif
virtual ~CassettePortInterface()=default
virtual void cassetteOut(bool output, EmuTime::param time)=0
Writes one bit to the cassette port.
virtual void setMotor(bool status, EmuTime::param time)=0
Sets the cassette motor relay false = off true = on.
virtual CassettePlayer * getCassettePlayer()=0
Get the cassette player (if available)
virtual bool cassetteIn(EmuTime::param time)=0
Reads one bit from the cassette port.
virtual bool lastOut() const =0
last bit written to CasOut.
CassettePlayer * getCassettePlayer() override
Get the cassette player (if available)
bool cassetteIn(EmuTime::param time) override
Reads one bit from the cassette port.
void cassetteOut(bool output, EmuTime::param time) override
Writes one bit to the cassette port.
bool lastOut() const override
last bit written to CasOut.
void serialize(Archive &ar, unsigned version)
std::string_view getClass() const override
A Connector belong to a certain class.
void setMotor(bool status, EmuTime::param time) override
Sets the cassette motor relay false = off true = on.
std::string_view getDescription() const override
Get a description for this connector.
Represents something you can plug devices into.
Definition Connector.hh:21
bool lastOut() const override
last bit written to CasOut.
CassettePlayer * getCassettePlayer() override
Get the cassette player (if available)
bool cassetteIn(EmuTime::param time) override
Reads one bit from the cassette port.
void cassetteOut(bool output, EmuTime::param time) override
Writes one bit to the cassette port.
void setMotor(bool status, EmuTime::param time) override
Sets the cassette motor relay false = off true = on.
This file implemented 3 utility functions:
Definition Autofire.cc:11
#define SERIALIZE_CLASS_VERSION(CLASS, VERSION)