From ed06533e6045a042014a4d0a8abfaf0d3ed9fee4 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 18 May 2018 22:07:58 -0400 Subject: [PATCH] Implements write support out of the Disk II. --- Components/DiskII/DiskII.cpp | 25 ++++++++++++++++++++----- Storage/Disk/Track/PCMPatchedTrack.cpp | 3 ++- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Components/DiskII/DiskII.cpp b/Components/DiskII/DiskII.cpp index 6a4b90b60..b71c9238b 100644 --- a/Components/DiskII/DiskII.cpp +++ b/Components/DiskII/DiskII.cpp @@ -104,6 +104,13 @@ void DiskII::run_for(const Cycles cycles) { case 0xb: shift_register_ = data_input_; break; // load data register from data bus } + // Currently writing? + if(inputs_&input_mode) { + // state_ & 0x80 should be the current level sent to the disk; + // therefore transitions in that bit should become flux transitions + drives_[active_drive_].write_bit(!!((state_ ^ address) & 0x80)); + } + // TODO: surely there's a less heavyweight solution than this? if(!drive_is_sleeping_[0]) drives_[0].run_for(Cycles(1)); if(!drive_is_sleeping_[1]) drives_[1].run_for(Cycles(1)); @@ -135,9 +142,9 @@ void DiskII::set_state_machine(const std::vector &state_machine) { state b0, state b2, state b3, pulse, Q7, Q6, shift, state b1 - ... and has the top nibble reflected. Beneath Apple Pro-DOS uses a - different order and several of the online copies are reformatted - into that order. + ... and has the top nibble of each value stored in the ROM reflected. + Beneath Apple Pro-DOS uses a different order and several of the + online copies are reformatted into that order. So the code below remaps into Beneath Apple Pro-DOS order if the supplied state machine isn't already in that order. @@ -221,8 +228,16 @@ int DiskII::read_address(int address) { case 0xc: inputs_ &= ~input_command; break; case 0xd: inputs_ |= input_command; break; - case 0xe: inputs_ &= ~input_mode; break; - case 0xf: inputs_ |= input_mode; break; + case 0xe: + if(inputs_ & input_mode) + drives_[active_drive_].end_writing(); + inputs_ &= ~input_mode; + break; + case 0xf: + if(!(inputs_ & input_mode)) + drives_[active_drive_].begin_writing(Storage::Time(1, 2045454), false); + inputs_ |= input_mode; + break; } set_controller_can_sleep(); return (address & 1) ? 0xff : shift_register_; diff --git a/Storage/Disk/Track/PCMPatchedTrack.cpp b/Storage/Disk/Track/PCMPatchedTrack.cpp index 5f2450339..d845749b0 100644 --- a/Storage/Disk/Track/PCMPatchedTrack.cpp +++ b/Storage/Disk/Track/PCMPatchedTrack.cpp @@ -202,7 +202,8 @@ Storage::Time PCMPatchedTrack::seek_to(const Time &time_since_index_hole) { else current_time_ = underlying_track_->seek_to(time_since_index_hole); - assert(current_time_ <= time_since_index_hole); + // The assert below is disabled as it assumes too much about total precision. +// assert(current_time_ <= time_since_index_hole); return current_time_; }