openMSX
DriveMultiplexer.cc
Go to the documentation of this file.
1 #include "DriveMultiplexer.hh"
2 #include "serialize.hh"
3 
4 namespace openmsx {
5 
7 {
8  motor = false;
9  side = false;
10  selected = NO_DRIVE;
11  drive[DRIVE_A] = drv[0];
12  drive[DRIVE_B] = drv[1];
13  drive[DRIVE_C] = drv[2];
14  drive[DRIVE_D] = drv[3];
15  drive[NO_DRIVE] = &dummyDrive;
16 }
17 
19 {
20  if (selected != num) {
21  drive[selected]->setMotor(false, time);
22  selected = num;
23  drive[selected]->setSide(side);
24  drive[selected]->setMotor(motor, time);
25  }
26 }
27 
29 {
30  return drive[selected]->isDiskInserted();
31 }
32 
34 {
35  return drive[selected]->isWriteProtected();
36 }
37 
39 {
40  return drive[selected]->isDoubleSided();
41 }
42 
43 void DriveMultiplexer::setSide(bool side_)
44 {
45  side = side_;
46  drive[selected]->setSide(side);
47 }
48 
49 void DriveMultiplexer::step(bool direction, EmuTime::param time)
50 {
51  drive[selected]->step(direction, time);
52 }
53 
55 {
56  return drive[selected]->isTrack00();
57 }
58 
60 {
61  motor = status;
62  drive[selected]->setMotor(status, time);
63 }
64 
66 {
67  return drive[selected]->indexPulse(time);
68 }
69 
71 {
72  return drive[selected]->getTimeTillIndexPulse(time, count);
73 }
74 
76 {
77  return drive[selected]->getTrackLength();
78 }
79 
80 void DriveMultiplexer::writeTrackByte(int idx, byte val, bool addIdam)
81 {
82  drive[selected]->writeTrackByte(idx, val, addIdam);
83 }
84 
86 {
87  return drive[selected]->readTrackByte(idx);
88 }
89 
91 {
92  return drive[selected]->getNextSector(time, sector);
93 }
94 
96 {
97  drive[selected]->flushTrack();
98 }
99 
101 {
102  return drive[selected]->diskChanged();
103 }
104 
106 {
107  return drive[selected]->peekDiskChanged();
108 }
109 
111 {
112  return drive[selected]->isDummyDrive();
113 }
114 
116 {
117  drive[selected]->applyWd2793ReadTrackQuirk();
118 }
119 
121 {
122  drive[selected]->invalidateWd2793ReadTrackQuirk();
123 }
124 
125 
126 static std::initializer_list<enum_string<DriveMultiplexer::DriveNum>> driveNumInfo = {
127  { "A", DriveMultiplexer::DRIVE_A },
128  { "B", DriveMultiplexer::DRIVE_B },
129  { "C", DriveMultiplexer::DRIVE_C },
130  { "D", DriveMultiplexer::DRIVE_D },
131  { "none", DriveMultiplexer::NO_DRIVE }
132 };
134 
135 template<typename Archive>
136 void DriveMultiplexer::serialize(Archive& ar, unsigned /*version*/)
137 {
138  ar.serialize("selected", selected);
139  ar.serialize("motor", motor);
140  ar.serialize("side", side);
141 }
143 
144 } // namespace openmsx
virtual void writeTrackByte(int idx, byte val, bool addIdam=false)=0
SERIALIZE_ENUM(CassettePlayer::State, stateInfo)
EmuTime getNextSector(EmuTime::param time, RawTrack::Sector &sector) override
byte readTrackByte(int idx) override
virtual void flushTrack()=0
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...
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
bool isDiskInserted() const override
Is drive ready?
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
virtual void setSide(bool side)=0
Side select.
virtual unsigned getTrackLength()=0
This class connects to a FDC as a normal DiskDrive and deligates all requests to one of four other Di...
virtual void invalidateWd2793ReadTrackQuirk()=0
void serialize(Archive &ar, unsigned version)
bool isDummyDrive() const override
Is there a dummy (unconncted) drive?
bool isWriteProtected() const override
Is disk write protected?
virtual bool isDiskInserted() const =0
Is drive ready?
void applyWd2793ReadTrackQuirk() override
See RawTrack::applyWd2793ReadTrackQuirk()
void invalidateWd2793ReadTrackQuirk() override
void step(bool direction, EmuTime::param time) override
Step head.
virtual bool isTrack00() const =0
Head above track 0.
bool isTrack00() const override
Head above track 0.
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void setMotor(bool status, EmuTime::param time) override
Set motor on/off.
bool indexPulse(EmuTime::param time) override
Gets the state of the index pulse.
virtual void setMotor(bool status, EmuTime::param time)=0
Set motor on/off.
unsigned getTrackLength() override
virtual bool isDummyDrive() const =0
Is there a dummy (unconncted) drive?
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:840
virtual bool diskChanged()=0
Is disk changed?
void setSide(bool side) override
Side select.
bool diskChanged() override
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
bool isDoubleSided() const override
Is disk double sided?
DriveMultiplexer(DiskDrive *drive[4])
void selectDrive(DriveNum num, EmuTime::param time)
bool peekDiskChanged() const override
virtual void step(bool direction, EmuTime::param time)=0
Step head.
void writeTrackByte(int idx, byte val, bool addIdam) override
virtual void applyWd2793ReadTrackQuirk()=0
See RawTrack::applyWd2793ReadTrackQuirk()
virtual bool indexPulse(EmuTime::param time)=0
Gets the state of the index pulse.