diff --git a/Components/5380/DirectAccessDevice.cpp b/Components/5380/DirectAccessDevice.cpp index 6d776836e..d09f64fec 100644 --- a/Components/5380/DirectAccessDevice.cpp +++ b/Components/5380/DirectAccessDevice.cpp @@ -25,26 +25,30 @@ void DirectAccessDevice::scsi_bus_did_change(Bus *, BusState new_state) { time." */ - switch(state_) { - case State::Inactive: + switch(phase_) { + case Phase::AwaitingSelection: if( (new_state & scsi_id_mask_) && ((new_state & (Line::SelectTarget | Line::Busy | Line::Input)) == Line::SelectTarget) ) { - state_ = State::Selected; - bus_state_ |= Line::Busy | Line::Request; + phase_ = Phase::Command; + bus_state_ |= Line::Busy | Line::Request | Line::Control; // Initiate the command phase: request a command byte. bus_.set_device_output(scsi_bus_device_id_, bus_state_); } break; - case State::Selected: + case Phase::Command: switch(new_state & (Line::Request | Line::Acknowledge)) { + // If request and acknowledge are both enabled, grab a byte and cancel the request. case Line::Request | Line::Acknowledge: bus_state_ &= ~Line::Request; printf("Got %02x maybe?\n", bus_state_ & 0xff); + + // TODO: is the command phase over? break; - case Line::Acknowledge: + // The reset of request has caused the initiator to reset acknowledge, so it is now + // safe to request the next byte. case 0: bus_state_ |= Line::Request; break; diff --git a/Components/5380/DirectAccessDevice.hpp b/Components/5380/DirectAccessDevice.hpp index e92d486ce..9ff616f56 100644 --- a/Components/5380/DirectAccessDevice.hpp +++ b/Components/5380/DirectAccessDevice.hpp @@ -32,10 +32,10 @@ class DirectAccessDevice: public Bus::Observer { const BusState scsi_id_mask_; const size_t scsi_bus_device_id_; - enum class State { - Inactive, - Selected - } state_ = State::Inactive; + enum class Phase { + AwaitingSelection, + Command + } phase_ = Phase::AwaitingSelection; BusState bus_state_ = DefaultBusState; };