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  drive[selected]->setHeadLoaded(status, time);
78 }
79 
81 {
82  return drive[selected]->headLoaded(time);
83 }
84 
86 {
87  drive[selected]->writeTrack(track);
88 }
89 
91 {
92  drive[selected]->readTrack(track);
93 }
94 
96  RawTrack::Sector& sector)
97 {
98  return drive[selected]->getNextSector(time, track, sector);
99 }
100 
102 {
103  return drive[selected]->diskChanged();
104 }
105 
107 {
108  return drive[selected]->peekDiskChanged();
109 }
110 
112 {
113  return drive[selected]->isDummyDrive();
114 }
115 
116 
117 static enum_string<DriveMultiplexer::DriveNum> driveNumInfo[] = {
118  { "A", DriveMultiplexer::DRIVE_A },
119  { "B", DriveMultiplexer::DRIVE_B },
120  { "C", DriveMultiplexer::DRIVE_C },
121  { "D", DriveMultiplexer::DRIVE_D },
122  { "none", DriveMultiplexer::NO_DRIVE }
123 };
125 
126 template<typename Archive>
127 void DriveMultiplexer::serialize(Archive& ar, unsigned /*version*/)
128 {
129  ar.serialize("selected", selected);
130  ar.serialize("motor", motor);
131  ar.serialize("side", side);
132 }
134 
135 } // namespace openmsx
SERIALIZE_ENUM(CassettePlayer::State, stateInfo)
bool headLoaded(EmuTime::param time) override
Is head loaded?
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?
bool isDiskInserted() const override
Is drive ready?
virtual bool headLoaded(EmuTime::param time)=0
Is head loaded?
virtual void setSide(bool side)=0
Side select.
void writeTrack(const RawTrack &track) override
This class connects to a FDC as a normal DiskDrive and deligates all requests to one of four other Di...
virtual EmuTime getNextSector(EmuTime::param time, RawTrack &track, RawTrack::Sector &sector)=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 setHeadLoaded(bool status, EmuTime::param time) override
Set head loaded status.
void readTrack(RawTrack &track) override
void step(bool direction, EmuTime::param time) override
Step head.
virtual void writeTrack(const RawTrack &track)=0
virtual void readTrack(RawTrack &track)=0
virtual bool isTrack00() const =0
Head above track 0.
bool isTrack00() const override
Head above track 0.
virtual void setHeadLoaded(bool status, EmuTime::param time)=0
Set head loaded status.
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.
virtual bool isDummyDrive() const =0
Is there a dummy (unconncted) drive?
EmuTime getNextSector(EmuTime::param time, RawTrack &track, RawTrack::Sector &sector) override
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:802
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:13
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.
virtual bool indexPulse(EmuTime::param time)=0
Gets the state of the index pulse.