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 DriveNum {
23 NO_DRIVE = 4
24 };
25
26 // Multiplexer interface
27 explicit DriveMultiplexer(std::span<std::unique_ptr<DiskDrive>, 4> drv);
28
29 void selectDrive(DriveNum num, EmuTime::param time);
30 [[nodiscard]] DriveNum getSelectedDrive() const { return selected; }
31
32 // DiskDrive interface
33 [[nodiscard]] bool isDiskInserted() const override;
34 [[nodiscard]] bool isWriteProtected() const override;
35 [[nodiscard]] bool isDoubleSided() override;
36 [[nodiscard]] bool isTrack00() const override;
37 void setSide(bool side) override;
38 [[nodiscard]] bool getSide() const override;
39 void step(bool direction, EmuTime::param time) override;
40 void setMotor(bool status, EmuTime::param time) override;
41 [[nodiscard]] bool getMotor() const override;
42 [[nodiscard]] bool indexPulse(EmuTime::param time) override;
43 [[nodiscard]] EmuTime getTimeTillIndexPulse(EmuTime::param time, int count) override;
44 [[nodiscard]] unsigned getTrackLength() override;
45 void writeTrackByte(int idx, uint8_t val, bool addIdam) override;
46 [[nodiscard]] uint8_t readTrackByte(int idx) override;
47 EmuTime getNextSector(EmuTime::param time, RawTrack::Sector& sector) override;
48 void flushTrack() override;
49 bool diskChanged() override;
50 [[nodiscard]] bool peekDiskChanged() const override;
51 [[nodiscard]] bool isDummyDrive() const override;
52 void applyWd2793ReadTrackQuirk() override;
53 void invalidateWd2793ReadTrackQuirk() override;
54
55 [[nodiscard]] bool isDiskInserted(DriveNum num) const;
56 bool diskChanged(DriveNum num);
57 [[nodiscard]] bool peekDiskChanged(DriveNum num) const;
58
59 template<typename Archive>
60 void serialize(Archive& ar, unsigned version);
61
62private:
63 DummyDrive dummyDrive;
64 std::array<DiskDrive*, 5> drive;
65 DriveNum selected = NO_DRIVE;
66 bool motor = false;
67 bool side = false;
68};
69
70} // namespace openmsx
71
72#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(DriveNum num, EmuTime::param time)
bool isDiskInserted() const override
Is drive ready?
DriveNum getSelectedDrive() const
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:9