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)
virtual EmuTime getTimeTillIndexPulse(EmuTime::param time, int count)
Return the time till the start of the next index pulse When there is no disk in the drive or when the...
virtual bool isTrack00() const
Head above track 0.
virtual bool isDoubleSided() const =0
Is disk double sided?
virtual void readTrack(RawTrack &track)
virtual bool headLoaded(EmuTime::param time)=0
Is head loaded?
virtual void writeTrack(const RawTrack &track)
virtual void setSide(bool side)=0
Side select.
virtual bool diskChanged()
Is disk changed?
virtual void setSide(bool side)
Side select.
This class connects to a FDC as a normal DiskDrive and deligates all requests to one of four other Di...
virtual bool isWriteProtected() const
Is disk write protected?
virtual EmuTime getNextSector(EmuTime::param time, RawTrack &track, RawTrack::Sector &sector)=0
void serialize(Archive &ar, unsigned version)
virtual bool isDiskInserted() const =0
Is drive ready?
virtual void writeTrack(const RawTrack &track)=0
virtual void readTrack(RawTrack &track)=0
virtual bool isTrack00() const =0
Head above track 0.
virtual void setHeadLoaded(bool status, EmuTime::param time)=0
Set head loaded status.
virtual bool isDiskInserted() const
Is drive ready?
virtual EmuTime getNextSector(EmuTime::param time, RawTrack &track, RawTrack::Sector &sector)
This class implements a not connected disk drive.
Definition: DiskDrive.hh:99
virtual void setMotor(bool status, EmuTime::param time)=0
Set motor on/off.
virtual bool isDoubleSided() const
Is disk double sided?
virtual bool isDummyDrive() const =0
Is there a dummy (unconncted) drive?
virtual bool peekDiskChanged() const
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:802
virtual bool diskChanged()=0
Is disk changed?
virtual bool headLoaded(EmuTime::param time)
Is head loaded?
virtual void setHeadLoaded(bool status, EmuTime::param time)
Set head loaded status.
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
DriveMultiplexer(DiskDrive *drive[4])
void selectDrive(DriveNum num, EmuTime::param time)
virtual void step(bool direction, EmuTime::param time)
Step head.
virtual void step(bool direction, EmuTime::param time)=0
Step head.
virtual bool isDummyDrive() const
Is there a dummy (unconncted) drive?
std::unique_ptr< T > make_unique()
Definition: memory.hh:27
virtual bool indexPulse(EmuTime::param time)
Gets the state of the index pulse.
virtual void setMotor(bool status, EmuTime::param time)
Set motor on/off.
virtual bool indexPulse(EmuTime::param time)=0
Gets the state of the index pulse.