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 constexpr 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
openmsx::DummyDrive::readTrackByte
byte readTrackByte(int idx) override
Definition: DiskDrive.cc:73
openmsx::DummyDrive::invalidateWd2793ReadTrackQuirk
void invalidateWd2793ReadTrackQuirk() override
Definition: DiskDrive.cc:108
openmsx::DummyDrive::isWriteProtected
bool isWriteProtected() const override
Is disk write protected?
Definition: DiskDrive.cc:13
openmsx::DiskDrive::step
virtual void step(bool direction, EmuTime::param time)=0
Step head.
openmsx::DiskDrive::isWriteProtected
virtual bool isWriteProtected() const =0
Is disk write protected?
openmsx::DummyDrive::step
void step(bool direction, EmuTime::param time) override
Step head.
Definition: DiskDrive.cc:38
openmsx::DiskDrive
This (abstract) class defines the DiskDrive interface.
Definition: DiskDrive.hh:12
openmsx::DummyDrive::diskChanged
bool diskChanged() override
Is disk changed?
Definition: DiskDrive.cc:88
openmsx::DiskDrive::isDiskInserted
virtual bool isDiskInserted() const =0
Is drive ready?
openmsx::DiskDrive::isTrack00
virtual bool isTrack00() const =0
Head above track 0.
openmsx::DummyDrive::setMotor
void setMotor(bool status, EmuTime::param time) override
Set motor on/off.
Definition: DiskDrive.cc:43
LZ4::count
ALWAYS_INLINE unsigned count(const uint8_t *pIn, const uint8_t *pMatch, const uint8_t *pInLimit)
Definition: lz4.cc:207
openmsx::DummyDrive::writeTrackByte
void writeTrackByte(int idx, byte val, bool addIdam) override
Definition: DiskDrive.cc:68
openmsx::DummyDrive::getMotor
bool getMotor() const override
Returns the previously set motor status.
Definition: DiskDrive.cc:48
openmsx::DiskDrive::readTrackByte
virtual byte readTrackByte(int idx)=0
openmsx::DummyDrive::getTimeTillIndexPulse
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
openmsx::DummyDrive::peekDiskChanged
bool peekDiskChanged() const override
Definition: DiskDrive.cc:93
openmsx::DiskDrive::isDummyDrive
virtual bool isDummyDrive() const =0
Is there a dummy (unconncted) drive?
openmsx::DiskDrive::getTrackLength
virtual unsigned getTrackLength()=0
openmsx::DiskDrive::ROTATIONS_PER_SECOND
static constexpr unsigned ROTATIONS_PER_SECOND
Definition: DiskDrive.hh:15
openmsx::DiskDrive::flushTrack
virtual void flushTrack()=0
openmsx::DiskDrive::writeTrackByte
virtual void writeTrackByte(int idx, byte val, bool addIdam=false)=0
openmsx::DiskDrive::isDoubleSided
virtual bool isDoubleSided() const =0
Is disk double sided?
openmsx::DiskDrive::invalidateWd2793ReadTrackQuirk
virtual void invalidateWd2793ReadTrackQuirk()=0
openmsx::DummyDrive::setSide
void setSide(bool side) override
Side select.
Definition: DiskDrive.cc:28
openmsx::DummyDrive::getTrackLength
unsigned getTrackLength() override
Definition: DiskDrive.cc:63
openmsx::DummyDrive::isDiskInserted
bool isDiskInserted() const override
Is drive ready?
Definition: DiskDrive.cc:8
openmsx::DummyDrive::isDummyDrive
bool isDummyDrive() const override
Is there a dummy (unconncted) drive?
Definition: DiskDrive.cc:98
openmsx::DiskDrive::setSide
virtual void setSide(bool side)=0
Side select.
openmsx::DiskDrive::getTimeTillIndexPulse
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...
openmsx::DummyDrive::indexPulse
bool indexPulse(EmuTime::param time) override
Gets the state of the index pulse.
Definition: DiskDrive.cc:53
RawTrack.hh
openmsx::DiskDrive::peekDiskChanged
virtual bool peekDiskChanged() const =0
openmsx::DiskDrive::getMotor
virtual bool getMotor() const =0
Returns the previously set motor status.
openmsx::RawTrack::Sector
Definition: RawTrack.hh:73
openmsx::DiskDrive::applyWd2793ReadTrackQuirk
virtual void applyWd2793ReadTrackQuirk()=0
See RawTrack::applyWd2793ReadTrackQuirk()
openmsx::DiskDrive::indexPulse
virtual bool indexPulse(EmuTime::param time)=0
Gets the state of the index pulse.
openmsx::DummyDrive::isDoubleSided
bool isDoubleSided() const override
Is disk double sided?
Definition: DiskDrive.cc:18
openmsx::DiskDrive::setMotor
virtual void setMotor(bool status, EmuTime::param time)=0
Set motor on/off.
EmuTime.hh
openmsx::DummyDrive::getNextSector
EmuTime getNextSector(EmuTime::param time, RawTrack::Sector &sector) override
Definition: DiskDrive.cc:78
openmsx::DummyDrive::applyWd2793ReadTrackQuirk
void applyWd2793ReadTrackQuirk() override
See RawTrack::applyWd2793ReadTrackQuirk()
Definition: DiskDrive.cc:103
openmsx::DummyDrive::flushTrack
void flushTrack() override
Definition: DiskDrive.cc:83
openmsx::DiskDrive::getNextSector
virtual EmuTime getNextSector(EmuTime::param time, RawTrack::Sector &sector)=0
openmsx::DummyDrive
This class implements a not connected disk drive.
Definition: DiskDrive.hh:100
openmsx::DummyDrive::getSide
bool getSide() const override
Definition: DiskDrive.cc:33
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::DiskDrive::~DiskDrive
virtual ~DiskDrive()=default
openmsx::DummyDrive::isTrack00
bool isTrack00() const override
Head above track 0.
Definition: DiskDrive.cc:23
openmsx::DiskDrive::diskChanged
virtual bool diskChanged()=0
Is disk changed?
openmsx::DiskDrive::getSide
virtual bool getSide() const =0