2024-04-08 01:22:35 +00:00
|
|
|
//
|
|
|
|
// FloppyDisc.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 07/04/2024.
|
|
|
|
// Copyright © 2024 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../../../Components/1770/1770.hpp"
|
|
|
|
|
|
|
|
namespace Archimedes {
|
|
|
|
|
|
|
|
template <typename InterruptObserverT>
|
|
|
|
class FloppyDisc: public WD::WD1770, public WD::WD1770::Delegate {
|
|
|
|
public:
|
|
|
|
FloppyDisc(InterruptObserverT &observer) : WD::WD1770(P1772), observer_(observer) {
|
2024-04-08 02:29:00 +00:00
|
|
|
emplace_drives(4, 8000000, 300, 2);
|
2024-04-08 01:22:35 +00:00
|
|
|
set_delegate(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void wd1770_did_change_output(WD::WD1770 *) override {
|
|
|
|
observer_.update_interrupts();
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_control(uint8_t value) {
|
|
|
|
// TODO:
|
|
|
|
// b0, b1, b2, b3 = drive selects;
|
|
|
|
// b4 = side select;
|
|
|
|
// b5 = motor on/off
|
|
|
|
// b6 = floppy in use (i.e. LED?);
|
|
|
|
// b7 = disc eject/change reset.
|
2024-04-08 02:29:00 +00:00
|
|
|
set_drive((value & 0xf) ^ 0xf);
|
2024-04-08 01:22:35 +00:00
|
|
|
get_drive().set_head(1 ^ ((value >> 4) & 1));
|
2024-04-08 02:29:00 +00:00
|
|
|
get_drive().set_motor_on(!(value & 0x20));
|
2024-04-08 01:22:35 +00:00
|
|
|
}
|
|
|
|
void reset() {}
|
|
|
|
|
2024-04-09 01:15:40 +00:00
|
|
|
void set_disk(std::shared_ptr<Storage::Disk::Disk> disk, size_t drive) {
|
|
|
|
get_drive(drive).set_disk(disk);
|
|
|
|
}
|
|
|
|
|
2024-04-08 01:22:35 +00:00
|
|
|
private:
|
|
|
|
InterruptObserverT &observer_;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|