From 4c49963988c95089b98be8f8aab42a95e4bdfc26 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 16 May 2018 21:44:09 -0400 Subject: [PATCH] Switches to proper handling of the motor control and write protection. Per Understanding the Apple II the drive looks write protected while phase 1 is enabled. --- Components/DiskII/DiskII.cpp | 14 +++++++++----- Components/DiskII/DiskII.hpp | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Components/DiskII/DiskII.cpp b/Components/DiskII/DiskII.cpp index d0f2178af..abb24a99b 100644 --- a/Components/DiskII/DiskII.cpp +++ b/Components/DiskII/DiskII.cpp @@ -36,9 +36,8 @@ void DiskII::set_control(Control control, bool on) { case Control::P3: stepper_mask_ = (stepper_mask_ & 0x7) | (on ? 0x8 : 0x0); break; case Control::Motor: - // TODO: does the motor control trigger both motors at once? - drives_[0].set_motor_on(on); - drives_[1].set_motor_on(on); + motor_is_enabled_ = on; + drives_[active_drive_].set_motor_on(on); break; } @@ -71,9 +70,14 @@ void DiskII::set_mode(Mode mode) { void DiskII::select_drive(int drive) { // printf("Select drive %d\n", drive); - active_drive_ = drive & 1; + if((drive&1) == active_drive_) return; + drives_[active_drive_].set_event_delegate(this); drives_[active_drive_^1].set_event_delegate(nullptr); + + drives_[active_drive_].set_motor_on(false); + active_drive_ = drive & 1; + drives_[active_drive_].set_motor_on(motor_is_enabled_); } void DiskII::set_data_register(uint8_t value) { @@ -134,7 +138,7 @@ void DiskII::set_controller_can_sleep() { } bool DiskII::is_write_protected() { - return true; + return !!(stepper_mask_ & 2) | drives_[active_drive_].get_is_read_only(); } void DiskII::set_state_machine(const std::vector &state_machine) { diff --git a/Components/DiskII/DiskII.hpp b/Components/DiskII/DiskII.hpp index 28b4cd2cc..9c5932c84 100644 --- a/Components/DiskII/DiskII.hpp +++ b/Components/DiskII/DiskII.hpp @@ -76,6 +76,7 @@ class DiskII: bool drive_is_sleeping_[2]; bool controller_can_sleep_ = false; int active_drive_ = 0; + bool motor_is_enabled_ = false; void set_controller_can_sleep(); };