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  virtual bool isDiskInserted() const = 0;
27 
30  virtual bool isWriteProtected() const = 0;
31 
34  virtual bool isDoubleSided() const = 0;
35 
38  virtual bool isTrack00() const = 0;
39 
44  virtual void setSide(bool side) = 0;
45 
46  /* Returns the previously selected side.
47  */
48  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  virtual bool getMotor() const = 0;
67 
71  virtual bool indexPulse(EmuTime::param time) = 0;
72 
79  virtual EmuTime getTimeTillIndexPulse(EmuTime::param time, int count = 1) = 0;
80 
81  virtual unsigned getTrackLength() = 0;
82  virtual void writeTrackByte(int idx, byte val, bool addIdam = false) = 0;
83  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  virtual bool peekDiskChanged() const = 0; // read without reset
91 
94  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  bool isDiskInserted() const override;
109  bool isWriteProtected() const override;
110  bool isDoubleSided() const override;
111  bool isTrack00() const override;
112  void setSide(bool side) override;
113  bool getSide() const override;
114  void step(bool direction, EmuTime::param time) override;
115  void setMotor(bool status, EmuTime::param time) override;
116  bool getMotor() const override;
117  bool indexPulse(EmuTime::param time) override;
118  EmuTime getTimeTillIndexPulse(EmuTime::param time, int count) override;
119  unsigned getTrackLength() override;
120  void writeTrackByte(int idx, byte val, bool addIdam) override;
121  byte readTrackByte(int idx) override;
122  EmuTime getNextSector(EmuTime::param time, RawTrack::Sector& sector) override;
123  void flushTrack() override;
124  bool diskChanged() override;
125  bool peekDiskChanged() const override;
126  bool isDummyDrive() const override;
127  void applyWd2793ReadTrackQuirk() override;
128  void invalidateWd2793ReadTrackQuirk() override;
129 };
130 
131 } // namespace openmsx
132 
133 #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:13
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:20
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:74
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:106
openmsx::DummyDrive::getSide
bool getSide() const override
Definition: DiskDrive.cc:33
openmsx::DiskDrive::TrackMode::NORMAL
@ NORMAL
openmsx
This file implemented 3 utility functions:
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
openmsx::DiskDrive::TrackMode::YAMAHA_FD_03
@ YAMAHA_FD_03
openmsx::DiskDrive::TrackMode
TrackMode
Definition: DiskDrive.hh:15