openMSX
DriveMultiplexer.cc
Go to the documentation of this file.
1#include "DriveMultiplexer.hh"
2#include "serialize.hh"
3
4namespace openmsx {
5
6DriveMultiplexer::DriveMultiplexer(std::span<std::unique_ptr<DiskDrive>, 4> drv)
7{
8 drive[Drive::A] = drv[0].get();
9 drive[Drive::B] = drv[1].get();
10 drive[Drive::C] = drv[2].get();
11 drive[Drive::D] = drv[3].get();
12 drive[Drive::NONE] = &dummyDrive;
13}
14
15void DriveMultiplexer::selectDrive(Drive num, EmuTime::param time)
16{
17 if (selected != num) {
18 drive[selected]->setMotor(false, time);
19 selected = num;
20 drive[selected]->setSide(side);
21 drive[selected]->setMotor(motor, time);
22 }
23}
24
26{
27 return drive[selected]->isDiskInserted();
28}
29
31{
32 return drive[num]->isDiskInserted();
33}
34
36{
37 return drive[selected]->isWriteProtected();
38}
39
41{
42 return drive[selected]->isDoubleSided();
43}
44
46{
47 side = side_;
48 drive[selected]->setSide(side);
49}
50
52{
53 return side;
54}
55
56void DriveMultiplexer::step(bool direction, EmuTime::param time)
57{
58 drive[selected]->step(direction, time);
59}
60
62{
63 return drive[selected]->isTrack00();
64}
65
66void DriveMultiplexer::setMotor(bool status, EmuTime::param time)
67{
68 motor = status;
69 drive[selected]->setMotor(status, time);
70}
71
73{
74 return motor;
75}
76
77bool DriveMultiplexer::indexPulse(EmuTime::param time)
78{
79 return drive[selected]->indexPulse(time);
80}
81
82EmuTime DriveMultiplexer::getTimeTillIndexPulse(EmuTime::param time, int count)
83{
84 return drive[selected]->getTimeTillIndexPulse(time, count);
85}
86
88{
89 return drive[selected]->getTrackLength();
90}
91
92void DriveMultiplexer::writeTrackByte(int idx, uint8_t val, bool addIdam)
93{
94 drive[selected]->writeTrackByte(idx, val, addIdam);
95}
96
98{
99 return drive[selected]->readTrackByte(idx);
100}
101
102EmuTime DriveMultiplexer::getNextSector(EmuTime::param time, RawTrack::Sector& sector)
103{
104 return drive[selected]->getNextSector(time, sector);
105}
106
108{
109 drive[selected]->flushTrack();
110}
111
113{
114 return drive[selected]->diskChanged();
115}
116
118{
119 return drive[num]->diskChanged();
120}
121
123{
124 return drive[selected]->peekDiskChanged();
125}
126
128{
129 return drive[num]->peekDiskChanged();
130}
131
133{
134 return drive[selected]->isDummyDrive();
135}
136
138{
139 drive[selected]->applyWd2793ReadTrackQuirk();
140}
141
143{
144 drive[selected]->invalidateWd2793ReadTrackQuirk();
145}
146
147
148static constexpr std::initializer_list<enum_string<DriveMultiplexer::Drive>> driveNumInfo = {
154};
156
157template<typename Archive>
158void DriveMultiplexer::serialize(Archive& ar, unsigned /*version*/)
159{
160 ar.serialize("selected", selected,
161 "motor", motor,
162 "side", side);
163}
165
166} // namespace openmsx
This class connects to a FDC as a normal DiskDrive and delegates all requests to one of four other Di...
EmuTime getNextSector(EmuTime::param time, RawTrack::Sector &sector) override
void setMotor(bool status, EmuTime::param time) override
Set motor on/off.
void invalidateWd2793ReadTrackQuirk() override
bool isTrack00() const override
Head above track 0.
bool isWriteProtected() const override
Is disk write protected?
bool peekDiskChanged() const override
uint8_t readTrackByte(int idx) override
void selectDrive(Drive num, EmuTime::param time)
bool isDiskInserted() const override
Is drive ready?
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...
bool getMotor() const override
Returns the previously set motor status.
void writeTrackByte(int idx, uint8_t val, bool addIdam) override
DriveMultiplexer(std::span< std::unique_ptr< DiskDrive >, 4 > drv)
bool getSide() const override
bool diskChanged() override
Is disk changed?
void serialize(Archive &ar, unsigned version)
bool isDummyDrive() const override
Is there a dummy (unconnected) drive?
void applyWd2793ReadTrackQuirk() override
See RawTrack::applyWd2793ReadTrackQuirk()
bool indexPulse(EmuTime::param time) override
Gets the state of the index pulse.
void step(bool direction, EmuTime::param time) override
Step head.
void setSide(bool side) override
Side select.
bool isDoubleSided() override
Is disk double sided?
unsigned getTrackLength() override
This file implemented 3 utility functions:
Definition Autofire.cc:11
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
#define SERIALIZE_ENUM(TYPE, INFO)