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
8namespace openmsx {
9
10class HardwareConfig;
11class MSXMotherBoard;
12class CassetteDevice;
13class CassettePlayer;
14#if COMPONENT_LASERDISC
15class LaserdiscPlayer;
16#endif
17
19{
20public:
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 [[nodiscard]] virtual bool lastOut() const = 0;
43
52 virtual bool cassetteIn(EmuTime::param time) = 0;
53
54#if COMPONENT_LASERDISC
59 virtual void setLaserdiscPlayer(LaserdiscPlayer *laserdisc) = 0;
60#endif
61};
62
63class CassettePort final : public CassettePortInterface, public Connector
64{
65public:
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 [[nodiscard]] bool lastOut() const override;
75
76 // Connector
77 [[nodiscard]] std::string_view getDescription() const override;
78 [[nodiscard]] std::string_view getClass() const override;
79
80 template<typename Archive>
81 void serialize(Archive& ar, unsigned version);
82
83private:
84 [[nodiscard]] CassetteDevice& getPluggedCasDev() const;
85
86 MSXMotherBoard& motherBoard;
87
88#if COMPONENT_LASERDISC
89 LaserdiscPlayer* laserdiscPlayer = nullptr;
90#endif
91 CassettePlayer* cassettePlayer;
92
93 bool lastOutput = false;
94 bool motorControl = false;
95};
97
99{
100public:
101 void setMotor(bool status, EmuTime::param time) override;
102 void cassetteOut(bool output, EmuTime::param time) override;
103 bool cassetteIn(EmuTime::param time) override;
104#if COMPONENT_LASERDISC
105 void setLaserdiscPlayer(LaserdiscPlayer *laserdisc) override;
106#endif
107 [[nodiscard]] bool lastOut() const override;
108};
109
110} // namespace openmsx
111
112#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 bool cassetteIn(EmuTime::param time)=0
Reads one bit from the cassette port.
virtual bool lastOut() const =0
last bit written to CasOut.
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.
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)