openMSX
DiskDrive.hh
Go to the documentation of this file.
1 #ifndef DISKDRIVE_HH
2 #define DISKDRIVE_HH
3 
4 #include "EmuTime.hh"
5 #include "RawTrack.hh"
6 
7 namespace openmsx {
8 
12 class DiskDrive
13 {
14 public:
15  enum class TrackMode {
17  };
18 
19 public:
20  static constexpr unsigned ROTATIONS_PER_SECOND = 5; // 300rpm
21 
22  virtual ~DiskDrive() = default;
23 
26  [[nodiscard]] virtual bool isDiskInserted() const = 0;
27 
30  [[nodiscard]] virtual bool isWriteProtected() const = 0;
31 
34  [[nodiscard]] virtual bool isDoubleSided() = 0;
35 
38  [[nodiscard]] virtual bool isTrack00() const = 0;
39 
44  virtual void setSide(bool side) = 0;
45 
46  /* Returns the previously selected side.
47  */
48  [[nodiscard]] virtual bool getSide() const = 0;
49 
55  virtual void step(bool direction, EmuTime::param time) = 0;
56 
62  virtual void setMotor(bool status, EmuTime::param time) = 0;
63 
66  [[nodiscard]] virtual bool getMotor() const = 0;
67 
71  [[nodiscard]] virtual bool indexPulse(EmuTime::param time) = 0;
72 
79  [[nodiscard]] virtual EmuTime getTimeTillIndexPulse(EmuTime::param time, int count = 1) = 0;
80 
81  [[nodiscard]] virtual unsigned getTrackLength() = 0;
82  virtual void writeTrackByte(int idx, byte val, bool addIdam = false) = 0;
83  [[nodiscard]] virtual byte readTrackByte(int idx) = 0;
84  virtual EmuTime getNextSector(EmuTime::param time, RawTrack::Sector& sector) = 0;
85  virtual void flushTrack() = 0;
86 
89  virtual bool diskChanged() = 0; // read and reset
90  [[nodiscard]] virtual bool peekDiskChanged() const = 0; // read without reset
91 
94  [[nodiscard]] virtual bool isDummyDrive() const = 0;
95 
97  virtual void applyWd2793ReadTrackQuirk() = 0;
98  virtual void invalidateWd2793ReadTrackQuirk() = 0;
99 };
100 
101 
105 class DummyDrive final : public DiskDrive
106 {
107 public:
108  [[nodiscard]] bool isDiskInserted() const override;
109  [[nodiscard]] bool isWriteProtected() const override;
110  [[nodiscard]] bool isDoubleSided() override;
111  [[nodiscard]] bool isTrack00() const override;
112  void setSide(bool side) override;
113  [[nodiscard]] bool getSide() const override;
114  void step(bool direction, EmuTime::param time) override;
115  void setMotor(bool status, EmuTime::param time) override;
116  [[nodiscard]] bool getMotor() const override;
117  [[nodiscard]] bool indexPulse(EmuTime::param time) override;
118  [[nodiscard]] EmuTime getTimeTillIndexPulse(EmuTime::param time, int count) override;
119  [[nodiscard]] unsigned getTrackLength() override;
120  void writeTrackByte(int idx, byte val, bool addIdam) override;
121  [[nodiscard]] byte readTrackByte(int idx) override;
122  EmuTime getNextSector(EmuTime::param time, RawTrack::Sector& sector) override;
123  void flushTrack() override;
124  bool diskChanged() override;
125  [[nodiscard]] bool peekDiskChanged() const override;
126  [[nodiscard]] bool isDummyDrive() const override;
127  void applyWd2793ReadTrackQuirk() override;
128  void invalidateWd2793ReadTrackQuirk() override;
129 };
130 
131 } // namespace openmsx
132 
133 #endif
This (abstract) class defines the DiskDrive interface.
Definition: DiskDrive.hh:13
virtual bool getMotor() const =0
Returns the previously set motor status.
virtual bool isDummyDrive() const =0
Is there a dummy (unconnected) drive?
virtual void applyWd2793ReadTrackQuirk()=0
See RawTrack::applyWd2793ReadTrackQuirk()
virtual bool peekDiskChanged() const =0
virtual bool isDiskInserted() const =0
Is drive ready?
virtual bool isWriteProtected() const =0
Is disk write protected?
virtual EmuTime getNextSector(EmuTime::param time, RawTrack::Sector &sector)=0
virtual void setMotor(bool status, EmuTime::param time)=0
Set motor on/off.
virtual void step(bool direction, EmuTime::param time)=0
Step head.
virtual bool isTrack00() const =0
Head above track 0.
virtual byte readTrackByte(int idx)=0
virtual bool indexPulse(EmuTime::param time)=0
Gets the state of the index pulse.
virtual void writeTrackByte(int idx, byte val, bool addIdam=false)=0
virtual EmuTime getTimeTillIndexPulse(EmuTime::param time, int count=1)=0
Return the time till the start of the next index pulse When there is no disk in the drive or when the...
virtual ~DiskDrive()=default
virtual bool diskChanged()=0
Is disk changed?
virtual void setSide(bool side)=0
Side select.
virtual void flushTrack()=0
virtual bool isDoubleSided()=0
Is disk double sided?
virtual bool getSide() const =0
virtual unsigned getTrackLength()=0
static constexpr unsigned ROTATIONS_PER_SECOND
Definition: DiskDrive.hh:20
virtual void invalidateWd2793ReadTrackQuirk()=0
This class implements a not connected disk drive.
Definition: DiskDrive.hh:106
EmuTime getTimeTillIndexPulse(EmuTime::param time, int count) override
Return the time till the start of the next index pulse When there is no disk in the drive or when the...
Definition: DiskDrive.cc:58
bool peekDiskChanged() const override
Definition: DiskDrive.cc:93
bool indexPulse(EmuTime::param time) override
Gets the state of the index pulse.
Definition: DiskDrive.cc:53
unsigned getTrackLength() override
Definition: DiskDrive.cc:63
void step(bool direction, EmuTime::param time) override
Step head.
Definition: DiskDrive.cc:38
bool isDiskInserted() const override
Is drive ready?
Definition: DiskDrive.cc:8
byte readTrackByte(int idx) override
Definition: DiskDrive.cc:73
bool isWriteProtected() const override
Is disk write protected?
Definition: DiskDrive.cc:13
EmuTime getNextSector(EmuTime::param time, RawTrack::Sector &sector) override
Definition: DiskDrive.cc:78
void writeTrackByte(int idx, byte val, bool addIdam) override
Definition: DiskDrive.cc:68
void invalidateWd2793ReadTrackQuirk() override
Definition: DiskDrive.cc:108
bool getMotor() const override
Returns the previously set motor status.
Definition: DiskDrive.cc:48
bool isDummyDrive() const override
Is there a dummy (unconnected) drive?
Definition: DiskDrive.cc:98
void setSide(bool side) override
Side select.
Definition: DiskDrive.cc:28
void setMotor(bool status, EmuTime::param time) override
Set motor on/off.
Definition: DiskDrive.cc:43
void flushTrack() override
Definition: DiskDrive.cc:83
bool getSide() const override
Definition: DiskDrive.cc:33
bool isTrack00() const override
Head above track 0.
Definition: DiskDrive.cc:23
void applyWd2793ReadTrackQuirk() override
See RawTrack::applyWd2793ReadTrackQuirk()
Definition: DiskDrive.cc:103
bool isDoubleSided() override
Is disk double sided?
Definition: DiskDrive.cc:18
bool diskChanged() override
Is disk changed?
Definition: DiskDrive.cc:88
ALWAYS_INLINE unsigned count(const uint8_t *pIn, const uint8_t *pMatch, const uint8_t *pInLimit)
Definition: lz4.cc:207
This file implemented 3 utility functions:
Definition: Autofire.cc:9