mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-30 19:30:17 +00:00
0e0c789b02
Without having access to the SCSI-1 standard, a lot of this is guesswork.
44 lines
870 B
C++
44 lines
870 B
C++
//
|
|
// SCSI.cpp
|
|
// Clock Signal
|
|
//
|
|
// Created by Thomas Harte on 12/08/2019.
|
|
// Copyright © 2019 Thomas Harte. All rights reserved.
|
|
//
|
|
|
|
#include "SCSI.hpp"
|
|
|
|
using namespace SCSI;
|
|
|
|
size_t Bus::add_device() {
|
|
const auto slot = device_states_.size();
|
|
device_states_.push_back(DefaultBusState);
|
|
return slot;
|
|
}
|
|
|
|
void Bus::set_device_output(size_t device, BusState output) {
|
|
if(device_states_[device] == output) return;
|
|
device_states_[device] = output;
|
|
|
|
const auto previous_state = state_;
|
|
state_ = DefaultBusState;
|
|
for(auto state: device_states_) {
|
|
state_ |= state;
|
|
}
|
|
if(state_ == previous_state) return;
|
|
|
|
printf("SCSI bus: %08x\n", state_);
|
|
|
|
for(auto &observer: observers_) {
|
|
observer->scsi_bus_did_change(this, state_);
|
|
}
|
|
}
|
|
|
|
BusState Bus::get_state() {
|
|
return state_;
|
|
}
|
|
|
|
void Bus::add_observer(Observer *observer) {
|
|
observers_.push_back(observer);
|
|
}
|