openMSX
DriveMultiplexer.hh
Go to the documentation of this file.
1 #ifndef DRIVEMULTIPLEXER_HH
2 #define DRIVEMULTIPLEXER_HH
3 
4 #include "DiskDrive.hh"
5 
6 namespace openmsx {
7 
12 class DriveMultiplexer final : public DiskDrive
13 {
14 public:
15  enum DriveNum {
16  DRIVE_A = 0,
17  DRIVE_B = 1,
18  DRIVE_C = 2,
19  DRIVE_D = 3,
21  };
22 
23  // Multiplexer interface
24  explicit DriveMultiplexer(DiskDrive* drv[4]);
25 
26  void selectDrive(DriveNum num, EmuTime::param time);
27  DriveNum getSelectedDrive() const { return selected; }
28 
29  // DiskDrive interface
30  bool isDiskInserted() const override;
31  bool isWriteProtected() const override;
32  bool isDoubleSided() const override;
33  bool isTrack00() const override;
34  void setSide(bool side) override;
35  bool getSide() const override;
36  void step(bool direction, EmuTime::param time) override;
37  void setMotor(bool status, EmuTime::param time) override;
38  bool getMotor() const override;
39  bool indexPulse(EmuTime::param time) override;
40  EmuTime getTimeTillIndexPulse(EmuTime::param time, int count) override;
41  unsigned getTrackLength() override;
42  void writeTrackByte(int idx, byte val, bool addIdam) override;
43  byte readTrackByte(int idx) override;
44  EmuTime getNextSector(EmuTime::param time, RawTrack::Sector& sector) override;
45  void flushTrack() override;
46  bool diskChanged() override;
47  bool peekDiskChanged() const override;
48  bool isDummyDrive() const override;
49  void applyWd2793ReadTrackQuirk() override;
50  void invalidateWd2793ReadTrackQuirk() override;
51 
52  bool isDiskInserted(DriveNum num) const;
53  bool diskChanged(DriveNum num);
54  bool peekDiskChanged(DriveNum num) const;
55 
56  template<typename Archive>
57  void serialize(Archive& ar, unsigned version);
58 
59 private:
60  DummyDrive dummyDrive;
61  DiskDrive* drive[5];
62  DriveNum selected;
63  bool motor;
64  bool side;
65 };
66 
67 } // namespace openmsx
68 
69 #endif
openmsx::DriveMultiplexer::DRIVE_C
@ DRIVE_C
Definition: DriveMultiplexer.hh:18
openmsx::DriveMultiplexer::applyWd2793ReadTrackQuirk
void applyWd2793ReadTrackQuirk() override
See RawTrack::applyWd2793ReadTrackQuirk()
Definition: DriveMultiplexer.cc:140
openmsx::DriveMultiplexer::peekDiskChanged
bool peekDiskChanged() const override
Definition: DriveMultiplexer.cc:125
openmsx::DiskDrive
This (abstract) class defines the DiskDrive interface.
Definition: DiskDrive.hh:12
DiskDrive.hh
openmsx::DriveMultiplexer::invalidateWd2793ReadTrackQuirk
void invalidateWd2793ReadTrackQuirk() override
Definition: DriveMultiplexer.cc:145
openmsx::DriveMultiplexer::getMotor
bool getMotor() const override
Returns the previously set motor status.
Definition: DriveMultiplexer.cc:75
openmsx::DriveMultiplexer::getNextSector
EmuTime getNextSector(EmuTime::param time, RawTrack::Sector &sector) override
Definition: DriveMultiplexer.cc:105
openmsx::DriveMultiplexer::writeTrackByte
void writeTrackByte(int idx, byte val, bool addIdam) override
Definition: DriveMultiplexer.cc:95
LZ4::count
ALWAYS_INLINE unsigned count(const uint8_t *pIn, const uint8_t *pMatch, const uint8_t *pInLimit)
Definition: lz4.cc:207
openmsx::DriveMultiplexer::isDoubleSided
bool isDoubleSided() const override
Is disk double sided?
Definition: DriveMultiplexer.cc:43
openmsx::DriveMultiplexer::readTrackByte
byte readTrackByte(int idx) override
Definition: DriveMultiplexer.cc:100
openmsx::DriveMultiplexer::setMotor
void setMotor(bool status, EmuTime::param time) override
Set motor on/off.
Definition: DriveMultiplexer.cc:69
openmsx::DriveMultiplexer::isDummyDrive
bool isDummyDrive() const override
Is there a dummy (unconncted) drive?
Definition: DriveMultiplexer.cc:135
openmsx::DriveMultiplexer::NO_DRIVE
@ NO_DRIVE
Definition: DriveMultiplexer.hh:20
openmsx::DriveMultiplexer::setSide
void setSide(bool side) override
Side select.
Definition: DriveMultiplexer.cc:48
openmsx::DriveMultiplexer::isTrack00
bool isTrack00() const override
Head above track 0.
Definition: DriveMultiplexer.cc:64
openmsx::DriveMultiplexer::serialize
void serialize(Archive &ar, unsigned version)
Definition: DriveMultiplexer.cc:161
openmsx::DriveMultiplexer::DRIVE_B
@ DRIVE_B
Definition: DriveMultiplexer.hh:17
openmsx::DriveMultiplexer::DriveMultiplexer
DriveMultiplexer(DiskDrive *drv[4])
Definition: DriveMultiplexer.cc:6
openmsx::DriveMultiplexer::DRIVE_D
@ DRIVE_D
Definition: DriveMultiplexer.hh:19
openmsx::DriveMultiplexer::isDiskInserted
bool isDiskInserted() const override
Is drive ready?
Definition: DriveMultiplexer.cc:28
openmsx::DriveMultiplexer::DRIVE_A
@ DRIVE_A
Definition: DriveMultiplexer.hh:16
openmsx::DriveMultiplexer::indexPulse
bool indexPulse(EmuTime::param time) override
Gets the state of the index pulse.
Definition: DriveMultiplexer.cc:80
openmsx::DriveMultiplexer::getTrackLength
unsigned getTrackLength() override
Definition: DriveMultiplexer.cc:90
openmsx::DriveMultiplexer::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: DriveMultiplexer.cc:85
openmsx::RawTrack::Sector
Definition: RawTrack.hh:73
openmsx::DriveMultiplexer::flushTrack
void flushTrack() override
Definition: DriveMultiplexer.cc:110
openmsx::DriveMultiplexer::getSide
bool getSide() const override
Definition: DriveMultiplexer.cc:54
openmsx::DriveMultiplexer::getSelectedDrive
DriveNum getSelectedDrive() const
Definition: DriveMultiplexer.hh:27
openmsx::DriveMultiplexer::selectDrive
void selectDrive(DriveNum num, EmuTime::param time)
Definition: DriveMultiplexer.cc:18
openmsx::DummyDrive
This class implements a not connected disk drive.
Definition: DiskDrive.hh:105
openmsx::DriveMultiplexer::DriveNum
DriveNum
Definition: DriveMultiplexer.hh:15
openmsx::DriveMultiplexer
This class connects to a FDC as a normal DiskDrive and deligates all requests to one of four other Di...
Definition: DriveMultiplexer.hh:12
openmsx::DriveMultiplexer::diskChanged
bool diskChanged() override
Is disk changed?
Definition: DriveMultiplexer.cc:115
openmsx::DriveMultiplexer::isWriteProtected
bool isWriteProtected() const override
Is disk write protected?
Definition: DriveMultiplexer.cc:38
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::DriveMultiplexer::step
void step(bool direction, EmuTime::param time) override
Step head.
Definition: DriveMultiplexer.cc:59