diff --git a/Components/DiskII/MacintoshDoubleDensityDrive.cpp b/Components/DiskII/MacintoshDoubleDensityDrive.cpp index 7db79c2bc..523217195 100644 --- a/Components/DiskII/MacintoshDoubleDensityDrive.cpp +++ b/Components/DiskII/MacintoshDoubleDensityDrive.cpp @@ -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; +} diff --git a/Components/DiskII/MacintoshDoubleDensityDrive.hpp b/Components/DiskII/MacintoshDoubleDensityDrive.hpp index 00665dcae..da409b6de 100644 --- a/Components/DiskII/MacintoshDoubleDensityDrive.hpp +++ b/Components/DiskII/MacintoshDoubleDensityDrive.hpp @@ -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; }; } diff --git a/Storage/Disk/Drive.cpp b/Storage/Disk/Drive.cpp index 82e332291..caf875305 100644 --- a/Storage/Disk/Drive.cpp +++ b/Storage/Disk/Drive.cpp @@ -53,6 +53,7 @@ void Drive::set_disk(const std::shared_ptr &disk) { has_disk_ = !!disk_; invalidate_track(); + did_set_disk(); update_clocking_observer(); } diff --git a/Storage/Disk/Drive.hpp b/Storage/Disk/Drive.hpp index 2c0eb0f57..1b1402ddf 100644 --- a/Storage/Disk/Drive.hpp +++ b/Storage/Disk/Drive.hpp @@ -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).