diff --git a/Components/DiskII/DiskII.cpp b/Components/DiskII/DiskII.cpp index b80c68417..e915b61a7 100644 --- a/Components/DiskII/DiskII.cpp +++ b/Components/DiskII/DiskII.cpp @@ -120,6 +120,15 @@ void DiskII::run_for(const Cycles cycles) { if(!drive_is_sleeping_[1]) drives_[1].run_for(Cycles(1)); } + // Per comp.sys.apple2.programmer there is a delay between the controller + // motor switch being flipped and the drive motor actually switching off. + // This models that, accepting overrun as a risk. + if(motor_off_time_ >= 0) { + motor_off_time_ -= cycles.as_int(); + if(motor_off_time_ < 0) { + set_control(Control::Motor, false); + } + } decide_clocking_preference(); } @@ -238,9 +247,12 @@ int DiskII::read_address(int address) { case 0x8: shift_register_ = 0; - set_control(Control::Motor, false); + motor_off_time_ = clock_rate_; + break; + case 0x9: + set_control(Control::Motor, true); + motor_off_time_ = -1; break; - case 0x9: set_control(Control::Motor, true); break; case 0xa: select_drive(0); break; case 0xb: select_drive(1); break; diff --git a/Components/DiskII/DiskII.hpp b/Components/DiskII/DiskII.hpp index e95682101..dfd5b364a 100644 --- a/Components/DiskII/DiskII.hpp +++ b/Components/DiskII/DiskII.hpp @@ -109,6 +109,7 @@ class DiskII: int stepper_mask_ = 0; int stepper_position_ = 0; + int motor_off_time_ = -1; bool is_write_protected(); std::array state_machine_;