mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Adds SCSI bus clocking to the Macintosh, and fixes its internal counting.
This commit is contained in:
parent
2f8e31bc8b
commit
318cdb41ea
@ -504,6 +504,7 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
|
||||
private:
|
||||
void set_component_prefers_clocking(ClockingHint::Source *component, ClockingHint::Preference clocking) override {
|
||||
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 {
|
||||
@ -595,8 +596,9 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
|
||||
}
|
||||
|
||||
// Update the SCSI if currently active.
|
||||
if(model == Analyser::Static::Macintosh::Target::Model::MacPlus && scsi_is_clocked_) {
|
||||
scsi_.run_for(Cycles(duration.as_int()));
|
||||
if(model == Analyser::Static::Macintosh::Target::Model::MacPlus) {
|
||||
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_;
|
||||
SCSI::Target::Target<SCSI::DirectAccessDevice> hard_drive_;
|
||||
bool scsi_is_clocked_ = false;
|
||||
bool scsi_bus_is_clocked_ = false;
|
||||
|
||||
HalfCycles via_clock_;
|
||||
HalfCycles real_time_clock_;
|
||||
|
@ -73,16 +73,16 @@ void Bus::add_observer(Observer *observer) {
|
||||
}
|
||||
|
||||
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) {
|
||||
if(dispatch_index_ < sizeof(dispatch_times_)) {
|
||||
if(dispatch_index_ < dispatch_times_.size()) {
|
||||
time_in_state_ += time;
|
||||
|
||||
const auto old_index = dispatch_index_;
|
||||
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_;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#ifndef SCSI_hpp
|
||||
#define SCSI_hpp
|
||||
|
||||
#include <array>
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
|
||||
@ -138,7 +139,7 @@ class Bus: public ClockingHint::Source {
|
||||
HalfCycles time_in_state_;
|
||||
double cycles_to_time_ = 1.0;
|
||||
size_t dispatch_index_ = 0;
|
||||
int dispatch_times_[8];
|
||||
std::array<int, 8> dispatch_times_;
|
||||
|
||||
std::vector<BusState> device_states_;
|
||||
BusState state_ = DefaultBusState;
|
||||
|
Loading…
Reference in New Issue
Block a user