| e8555c89 Andy McCall |
1 |
#ifndef DRIVEMULTIPLEXER_HH |
| 2 |
#define DRIVEMULTIPLEXER_HH |
| 3 |
|
| 4 |
#include "DiskDrive.hh" |
| 5 |
|
| 6 |
#include "stl.hh" |
| 7 |
|
| 8 |
#include <cstdint> |
| 9 |
#include <memory> |
| 10 |
#include <span> |
| 11 |
|
| 12 |
namespace openmsx { |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
class DriveMultiplexer final : public DiskDrive |
| 19 |
{ |
| 20 |
public: |
| 21 |
enum class Drive : uint8_t { |
| 22 |
A, B, C, D, NONE, |
| 23 |
NUM |
| 24 |
}; |
| 25 |
|
| 26 |
|
| 27 |
explicit DriveMultiplexer(std::span<std::unique_ptr<DiskDrive>, 4> drv); |
| 28 |
|
| 29 |
void selectDrive(Drive num, EmuTime time); |
| 30 |
[[nodiscard]] Drive getSelectedDrive() const { return selected; } |
| 31 |
|
| 32 |
|
| 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 time) override; |
| 40 |
void setMotor(bool status, EmuTime time) override; |
| 41 |
[[nodiscard]] bool getMotor() const override; |
| 42 |
[[nodiscard]] bool indexPulse(EmuTime time) override; |
| 43 |
[[nodiscard]] EmuTime getTimeTillIndexPulse(EmuTime 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 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(Drive num) const; |
| 56 |
bool diskChanged(Drive num); |
| 57 |
[[nodiscard]] bool peekDiskChanged(Drive num) const; |
| 58 |
|
| 59 |
template<typename Archive> |
| 60 |
void serialize(Archive& ar, unsigned version); |
| 61 |
|
| 62 |
private: |
| 63 |
DummyDrive dummyDrive; |
| 64 |
array_with_enum_index<Drive, DiskDrive*> drive; |
| 65 |
Drive selected = Drive::NONE; |
| 66 |
bool motor = false; |
| 67 |
bool side = false; |
| 68 |
}; |
| 69 |
|
| 70 |
} |
| 71 |
|
| 72 |
#endif |