1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-29 00:29:34 +00:00

Adds has-new-disk flag, allowing mounting of software from the desktop.

This commit is contained in:
Thomas Harte 2019-07-12 13:17:24 -04:00
parent 59b5dfddec
commit 2c39229b13
4 changed files with 25 additions and 12 deletions

View File

@ -71,29 +71,30 @@ void DoubleDensityDrive::set_control_lines(int lines) {
// Catch low-to-high LSTRB transitions.
if((old_state ^ control_state_) & control_state_ & Line::LSTRB) {
switch(control_state_ & (Line::CA1 | Line::CA0 | Line::SEL)) {
switch(control_state_ & (Line::CA2 | Line::CA1 | Line::CA0 | Line::SEL)) {
default:
break;
case 0: // Set step direction — CA2 set => step outward.
case Line::CA2:
step_direction_ = (control_state_ & Line::CA2) ? -1 : 1;
break;
case Line::CA1: // Set drive motor — CA2 set => motor off.
case Line::CA1|Line::CA2:
set_motor_on(!(control_state_ & Line::CA2));
break;
case Line::CA0: // Initiate a step, if CA2 is clear.
if(!(control_state_ & Line::CA2))
step(Storage::Disk::HeadPosition(step_direction_));
case Line::CA0: // Initiate a step.
step(Storage::Disk::HeadPosition(step_direction_));
break;
case Line::SEL: // Reset has-been-ejected flag (if CA2 is set?)
case Line::SEL|Line::CA2: // Reset new disk flag.
has_new_disk_ = false;
break;
case Line::CA1 | Line::CA0: // Eject the disk if CA2 is set.
if(control_state_ & Line::CA2)
set_disk(nullptr); // TODO: should probably trigger the disk has been ejected bit?
case Line::CA2 | Line::CA1 | Line::CA0: // Eject the disk.
set_disk(nullptr);
break;
}
}
@ -131,7 +132,7 @@ bool DoubleDensityDrive::read() {
case CA1|CA0: // Disk has been ejected.
// (0 = user has ejected disk)
return false;
return !has_new_disk_;
case CA1|CA0|SEL: // Tachometer.
// (arbitrary)
@ -163,3 +164,7 @@ bool DoubleDensityDrive::read() {
return true;
}
}
void DoubleDensityDrive::did_set_disk() {
has_new_disk_ = true;
}

View File

@ -25,10 +25,12 @@ class DoubleDensityDrive: public IWMDrive {
private:
// To receive the proper notifications from Storage::Disk::Drive.
void did_step(Storage::Disk::HeadPosition to_position) override;
void did_set_disk() override;
bool is_800k_;
int control_state_;
int step_direction_;
const bool is_800k_;
bool has_new_disk_ = false;
int control_state_ = 0;
int step_direction_ = 1;
};
}

View File

@ -53,6 +53,7 @@ void Drive::set_disk(const std::shared_ptr<Disk> &disk) {
has_disk_ = !!disk_;
invalidate_track();
did_set_disk();
update_clocking_observer();
}

View File

@ -165,6 +165,11 @@ class Drive: public ClockingHint::Source, public TimedEventLoop {
*/
virtual void did_step(HeadPosition to_position) {}
/*!
Announces new media installation.
*/
virtual void did_set_disk() {}
/*!
@returns the current rotation of the disk, a float in the half-open range
0.0 (the index hole) to 1.0 (back to the index hole, a whole rotation later).