openMSX
DriveMultiplexer.cc
Go to the documentation of this file.
1 #include "DriveMultiplexer.hh"
2 #include "serialize.hh"
3 #include "memory.hh"
4 
5 namespace openmsx {
6 
8  : dummyDrive(make_unique<DummyDrive>())
9 {
10  motor = false;
11  side = false;
12  selected = NO_DRIVE;
13  drive[DRIVE_A] = drv[0];
14  drive[DRIVE_B] = drv[1];
15  drive[DRIVE_C] = drv[2];
16  drive[DRIVE_D] = drv[3];
17  drive[NO_DRIVE] = dummyDrive.get();
18 }
19 
21 {
22 }
23 
25 {
26  if (selected != num) {
27  drive[selected]->setMotor(false, time);
28  selected = num;
29  drive[selected]->setSide(side);
30  drive[selected]->setMotor(motor, time);
31  }
32 }
33 
35 {
36  return drive[selected]->isDiskInserted();
37 }
38 
40 {
41  return drive[selected]->isWriteProtected();
42 }
43 
45 {
46  return drive[selected]->isDoubleSided();
47 }
48 
49 void DriveMultiplexer::setSide(bool side_)
50 {
51  side = side_;
52  drive[selected]->setSide(side);
53 }
54 
55 void DriveMultiplexer::step(bool direction, EmuTime::param time)
56 {
57  drive[selected]->step(direction, time);
58 }
59 
61 {
62  return drive[selected]->isTrack00();
63 }
64 
66 {
67  motor = status;
68  drive[selected]->setMotor(status, time);
69 }
70 
72 {
73  return drive[selected]->indexPulse(time);
74 }
75 
77 {
78  return drive[selected]->getTimeTillIndexPulse(time, count);
79 }
80 
82 {
83  drive[selected]->setHeadLoaded(status, time);
84 }
85 
87 {
88  return drive[selected]->headLoaded(time);
89 }
90 
92 {
93  drive[selected]->writeTrack(track);
94 }
95 
97 {
98  drive[selected]->readTrack(track);
99 }
100 
102  RawTrack::Sector& sector)
103 {
104  return drive[selected]->getNextSector(time, track, sector);
105 }
106 
108 {
109  return drive[selected]->diskChanged();
110 }
111 
113 {
114  return drive[selected]->peekDiskChanged();
115 }
116 
118 {
119  return drive[selected]->isDummyDrive();
120 }
121 
122 
123 static enum_string<DriveMultiplexer::DriveNum> driveNumInfo[] = {
124  { "A", DriveMultiplexer::DRIVE_A },
125  { "B", DriveMultiplexer::DRIVE_B },
126  { "C", DriveMultiplexer::DRIVE_C },
127  { "D", DriveMultiplexer::DRIVE_D },
128  { "none", DriveMultiplexer::NO_DRIVE }
129 };
131 
132 template<typename Archive>
133 void DriveMultiplexer::serialize(Archive& ar, unsigned /*version*/)
134 {
135  ar.serialize("selected", selected);
136  ar.serialize("motor", motor);
137  ar.serialize("side", side);
138 }
140 
141 } // 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:7
This class implements a not connected disk drive.
Definition: DiskDrive.hh:99
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.
std::unique_ptr< T > make_unique()
Definition: memory.hh:27
virtual bool indexPulse(EmuTime::param time)=0
Gets the state of the index pulse.