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  static const unsigned ROTATIONS_PER_SECOND = 5; // 300rpm
16 
17  virtual ~DiskDrive() = default;
18 
21  virtual bool isDiskInserted() const = 0;
22 
25  virtual bool isWriteProtected() const = 0;
26 
29  virtual bool isDoubleSided() const = 0;
30 
33  virtual bool isTrack00() const = 0;
34 
39  virtual void setSide(bool side) = 0;
40 
41  /* Returns the previously selected side.
42  */
43  virtual bool getSide() const = 0;
44 
50  virtual void step(bool direction, EmuTime::param time) = 0;
51 
57  virtual void setMotor(bool status, EmuTime::param time) = 0;
58 
61  virtual bool getMotor() const = 0;
62 
66  virtual bool indexPulse(EmuTime::param time) = 0;
67 
74  virtual EmuTime getTimeTillIndexPulse(EmuTime::param time, int count = 1) = 0;
75 
76  virtual unsigned getTrackLength() = 0;
77  virtual void writeTrackByte(int idx, byte val, bool addIdam = false) = 0;
78  virtual byte readTrackByte(int idx) = 0;
79  virtual EmuTime getNextSector(EmuTime::param time, RawTrack::Sector& sector) = 0;
80  virtual void flushTrack() = 0;
81 
84  virtual bool diskChanged() = 0;
85  virtual bool peekDiskChanged() const = 0;
86 
89  virtual bool isDummyDrive() const = 0;
90 
92  virtual void applyWd2793ReadTrackQuirk() = 0;
93  virtual void invalidateWd2793ReadTrackQuirk() = 0;
94 };
95 
96 
100 class DummyDrive final : public DiskDrive
101 {
102 public:
103  bool isDiskInserted() const override;
104  bool isWriteProtected() const override;
105  bool isDoubleSided() const override;
106  bool isTrack00() const override;
107  void setSide(bool side) override;
108  bool getSide() const override;
109  void step(bool direction, EmuTime::param time) override;
110  void setMotor(bool status, EmuTime::param time) override;
111  bool getMotor() const override;
112  bool indexPulse(EmuTime::param time) override;
113  EmuTime getTimeTillIndexPulse(EmuTime::param time, int count) override;
114  unsigned getTrackLength() override;
115  void writeTrackByte(int idx, byte val, bool addIdam) override;
116  byte readTrackByte(int idx) override;
117  EmuTime getNextSector(EmuTime::param time, RawTrack::Sector& sector) override;
118  void flushTrack() override;
119  bool diskChanged() override;
120  bool peekDiskChanged() const override;
121  bool isDummyDrive() const override;
122  void applyWd2793ReadTrackQuirk() override;
123  void invalidateWd2793ReadTrackQuirk() override;
124 };
125 
126 } // namespace openmsx
127 
128 #endif
virtual void writeTrackByte(int idx, byte val, bool addIdam=false)=0
static const unsigned ROTATIONS_PER_SECOND
Definition: DiskDrive.hh:15
virtual void flushTrack()=0
virtual bool isDoubleSided() const =0
Is disk double sided?
virtual EmuTime getNextSector(EmuTime::param time, RawTrack::Sector &sector)=0
virtual byte readTrackByte(int idx)=0
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
virtual void setSide(bool side)=0
Side select.
virtual unsigned getTrackLength()=0
virtual void invalidateWd2793ReadTrackQuirk()=0
virtual ~DiskDrive()=default
virtual bool isDiskInserted() const =0
Is drive ready?
virtual bool getMotor() const =0
Returns the previously set motor status.
virtual bool isTrack00() const =0
Head above track 0.
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
This class implements a not connected disk drive.
Definition: DiskDrive.hh:100
virtual bool getSide() const =0
auto count(InputRange &&range, const T &value)
Definition: ranges.hh:209
virtual void setMotor(bool status, EmuTime::param time)=0
Set motor on/off.
virtual bool isDummyDrive() const =0
Is there a dummy (unconncted) drive?
virtual bool diskChanged()=0
Is disk changed?
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 bool peekDiskChanged() const =0
virtual bool isWriteProtected() const =0
Is disk write protected?
This (abstract) class defines the DiskDrive interface.
Definition: DiskDrive.hh:12
virtual void step(bool direction, EmuTime::param time)=0
Step head.
virtual void applyWd2793ReadTrackQuirk()=0
See RawTrack::applyWd2793ReadTrackQuirk()
virtual bool indexPulse(EmuTime::param time)=0
Gets the state of the index pulse.