From cddd72876f46b9eca82358c29fee2a09a1e463a4 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 18 Nov 2020 17:20:48 -0500 Subject: [PATCH] Flips meaning of ejected bit, to please the IIgs. --- Components/DiskII/MacintoshDoubleDensityDrive.cpp | 11 +++++++---- Components/DiskII/MacintoshDoubleDensityDrive.hpp | 2 +- Storage/Disk/Drive.cpp | 3 ++- Storage/Disk/Drive.hpp | 4 +++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Components/DiskII/MacintoshDoubleDensityDrive.cpp b/Components/DiskII/MacintoshDoubleDensityDrive.cpp index 657d78163..164d3ebe0 100644 --- a/Components/DiskII/MacintoshDoubleDensityDrive.cpp +++ b/Components/DiskII/MacintoshDoubleDensityDrive.cpp @@ -142,8 +142,11 @@ bool DoubleDensityDrive::read() { return !get_is_track_zero(); case CA1|CA0: // Disk has been ejected. - // (0 = user has ejected disk) - return !has_new_disk_; + // (1 = user has ejected disk) + // + // TODO: does this really mean _user_ has ejected disk? If so then I should avoid + // changing the flag upon a programmatic eject. + return has_new_disk_; case CA1|CA0|SEL: // Tachometer. // (arbitrary) @@ -174,6 +177,6 @@ bool DoubleDensityDrive::read() { } } -void DoubleDensityDrive::did_set_disk() { - has_new_disk_ = true; +void DoubleDensityDrive::did_set_disk(bool did_replace) { + has_new_disk_ = did_replace; } diff --git a/Components/DiskII/MacintoshDoubleDensityDrive.hpp b/Components/DiskII/MacintoshDoubleDensityDrive.hpp index eb439603f..4427d1a90 100644 --- a/Components/DiskII/MacintoshDoubleDensityDrive.hpp +++ b/Components/DiskII/MacintoshDoubleDensityDrive.hpp @@ -39,7 +39,7 @@ class DoubleDensityDrive: public IWMDrive { // To receive the proper notifications from Storage::Disk::Drive. void did_step(Storage::Disk::HeadPosition to_position) final; - void did_set_disk() final; + void did_set_disk(bool) final; const bool is_800k_; bool has_new_disk_ = false; diff --git a/Storage/Disk/Drive.cpp b/Storage/Disk/Drive.cpp index 32962e3e4..ef057b387 100644 --- a/Storage/Disk/Drive.cpp +++ b/Storage/Disk/Drive.cpp @@ -58,12 +58,13 @@ void Drive::set_disk(const std::shared_ptr &disk) { if(ready_type_ == ReadyType::ShugartModifiedRDY || ready_type_ == ReadyType::IBMRDY) { is_ready_ = false; } + const bool had_disk = bool(disk_); if(disk_) disk_->flush_tracks(); disk_ = disk; has_disk_ = !!disk_; invalidate_track(); - did_set_disk(); + did_set_disk(had_disk); update_clocking_observer(); } diff --git a/Storage/Disk/Drive.hpp b/Storage/Disk/Drive.hpp index b512cc8fc..25b7a442c 100644 --- a/Storage/Disk/Drive.hpp +++ b/Storage/Disk/Drive.hpp @@ -187,8 +187,10 @@ class Drive: public ClockingHint::Source, public TimedEventLoop { /*! Announces new media installation. + + @c did_replace is @c true if a previous disk was replaced; @c false if the drive was previously empty. */ - virtual void did_set_disk() {} + virtual void did_set_disk(bool did_replace [[maybe_unused]]) {} /*! @returns the current rotation of the disk, a float in the half-open range