openMSX
DriveMultiplexer.hh
Go to the documentation of this file.
1#ifndef DRIVEMULTIPLEXER_HH
2#define DRIVEMULTIPLEXER_HH
3
4#include "DiskDrive.hh"
5#include <array>
6#include <memory>
7#include <span>
8
9namespace openmsx {
10
15class DriveMultiplexer final : public DiskDrive
16{
17public:
18 enum class Drive {
19 A, B, C, D, NONE,
20 NUM
21 };
22
23 // Multiplexer interface
24 explicit DriveMultiplexer(std::span<std::unique_ptr<DiskDrive>, 4> drv);
25
26 void selectDrive(Drive num, EmuTime::param time);
27 [[nodiscard]] Drive getSelectedDrive() const { return selected; }
28
29 // DiskDrive interface
30 [[nodiscard]] bool isDiskInserted() const override;
31 [[nodiscard]] bool isWriteProtected() const override;
32 [[nodiscard]] bool isDoubleSided() override;
33 [[nodiscard]] bool isTrack00() const override;
34 void setSide(bool side) override;
35 [[nodiscard]] bool getSide() const override;
36 void step(bool direction, EmuTime::param time) override;
37 void setMotor(bool status, EmuTime::param time) override;
38 [[nodiscard]] bool getMotor() const override;
39 [[nodiscard]] bool indexPulse(EmuTime::param time) override;
40 [[nodiscard]] EmuTime getTimeTillIndexPulse(EmuTime::param time, int count) override;
41 [[nodiscard]] unsigned getTrackLength() override;
42 void writeTrackByte(int idx, uint8_t val, bool addIdam) override;
43 [[nodiscard]] uint8_t readTrackByte(int idx) override;
44 EmuTime getNextSector(EmuTime::param time, RawTrack::Sector& sector) override;
45 void flushTrack() override;
46 bool diskChanged() override;
47 [[nodiscard]] bool peekDiskChanged() const override;
48 [[nodiscard]] bool isDummyDrive() const override;
49 void applyWd2793ReadTrackQuirk() override;
50 void invalidateWd2793ReadTrackQuirk() override;
51
52 [[nodiscard]] bool isDiskInserted(Drive num) const;
53 bool diskChanged(Drive num);
54 [[nodiscard]] bool peekDiskChanged(Drive num) const;
55
56 template<typename Archive>
57 void serialize(Archive& ar, unsigned version);
58
59private:
60 DummyDrive dummyDrive;
62 Drive selected = Drive::NONE;
63 bool motor = false;
64 bool side = false;
65};
66
67} // namespace openmsx
68
69#endif
This (abstract) class defines the DiskDrive interface.
Definition DiskDrive.hh:13
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
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 setSide(bool side) override
Side select.
bool isDoubleSided() override
Is disk double sided?
unsigned getTrackLength() override
This class implements a not connected disk drive.
Definition DiskDrive.hh:106
This file implemented 3 utility functions:
Definition Autofire.cc:11