1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-23 03:32:32 +00:00

Adds SCSI bus clocking to the Macintosh, and fixes its internal counting.

This commit is contained in:
Thomas Harte 2019-09-02 16:03:33 -04:00
parent 2f8e31bc8b
commit 318cdb41ea
3 changed files with 10 additions and 6 deletions

View File

@ -504,6 +504,7 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
private: private:
void set_component_prefers_clocking(ClockingHint::Source *component, ClockingHint::Preference clocking) override { void set_component_prefers_clocking(ClockingHint::Source *component, ClockingHint::Preference clocking) override {
scsi_is_clocked_ = scsi_.preferred_clocking() != ClockingHint::Preference::None; scsi_is_clocked_ = scsi_.preferred_clocking() != ClockingHint::Preference::None;
scsi_bus_is_clocked_ = scsi_bus_.preferred_clocking() != ClockingHint::Preference::None;
} }
void drive_speed_accumulator_set_drive_speed(DriveSpeedAccumulator *, float speed) override { void drive_speed_accumulator_set_drive_speed(DriveSpeedAccumulator *, float speed) override {
@ -595,8 +596,9 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
} }
// Update the SCSI if currently active. // Update the SCSI if currently active.
if(model == Analyser::Static::Macintosh::Target::Model::MacPlus && scsi_is_clocked_) { if(model == Analyser::Static::Macintosh::Target::Model::MacPlus) {
scsi_.run_for(Cycles(duration.as_int())); if(scsi_is_clocked_) scsi_.run_for(Cycles(duration.as_int()));
if(scsi_bus_is_clocked_) scsi_bus_.run_for(duration);
} }
} }
@ -741,6 +743,7 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
NCR::NCR5380::NCR5380 scsi_; NCR::NCR5380::NCR5380 scsi_;
SCSI::Target::Target<SCSI::DirectAccessDevice> hard_drive_; SCSI::Target::Target<SCSI::DirectAccessDevice> hard_drive_;
bool scsi_is_clocked_ = false; bool scsi_is_clocked_ = false;
bool scsi_bus_is_clocked_ = false;
HalfCycles via_clock_; HalfCycles via_clock_;
HalfCycles real_time_clock_; HalfCycles real_time_clock_;

View File

@ -73,16 +73,16 @@ void Bus::add_observer(Observer *observer) {
} }
ClockingHint::Preference Bus::preferred_clocking() { ClockingHint::Preference Bus::preferred_clocking() {
return (dispatch_index_ < sizeof(dispatch_times_)) ? ClockingHint::Preference::RealTime : ClockingHint::Preference::None; return (dispatch_index_ < dispatch_times_.size()) ? ClockingHint::Preference::RealTime : ClockingHint::Preference::None;
} }
void Bus::run_for(HalfCycles time) { void Bus::run_for(HalfCycles time) {
if(dispatch_index_ < sizeof(dispatch_times_)) { if(dispatch_index_ < dispatch_times_.size()) {
time_in_state_ += time; time_in_state_ += time;
const auto old_index = dispatch_index_; const auto old_index = dispatch_index_;
const auto time_as_int = time_in_state_.as_int(); const auto time_as_int = time_in_state_.as_int();
while(time_as_int >= dispatch_times_[dispatch_index_] && dispatch_index_ < sizeof(dispatch_times_)) { while(time_as_int >= dispatch_times_[dispatch_index_] && dispatch_index_ < dispatch_times_.size()) {
++dispatch_index_; ++dispatch_index_;
} }

View File

@ -9,6 +9,7 @@
#ifndef SCSI_hpp #ifndef SCSI_hpp
#define SCSI_hpp #define SCSI_hpp
#include <array>
#include <limits> #include <limits>
#include <vector> #include <vector>
@ -138,7 +139,7 @@ class Bus: public ClockingHint::Source {
HalfCycles time_in_state_; HalfCycles time_in_state_;
double cycles_to_time_ = 1.0; double cycles_to_time_ = 1.0;
size_t dispatch_index_ = 0; size_t dispatch_index_ = 0;
int dispatch_times_[8]; std::array<int, 8> dispatch_times_;
std::vector<BusState> device_states_; std::vector<BusState> device_states_;
BusState state_ = DefaultBusState; BusState state_ = DefaultBusState;