1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-25 16:31:42 +00:00

Makes drives non-copyable.

To avoid error in the future.
This commit is contained in:
Thomas Harte 2021-10-14 12:37:55 -07:00
parent 9be23ecc34
commit b12c640807
4 changed files with 14 additions and 13 deletions

View File

@ -890,7 +890,6 @@ void Chipset::Bitplanes::set_control(uint16_t control) {
}
}
// MARK: - Sprites.
void Chipset::Sprite::set_pointer(int shift, uint16_t value) {
@ -1057,7 +1056,7 @@ void Chipset::CIABHandler::set_port_output(MOS::MOS6526::Port port, uint8_t valu
}
uint8_t Chipset::CIABHandler::get_port_input(MOS::MOS6526::Port) {
LOG("Unexpected input for CIA B");
LOG("Unexpected: input for CIA B");
return 0xff;
}
@ -1065,7 +1064,6 @@ uint8_t Chipset::CIABHandler::get_port_input(MOS::MOS6526::Port) {
void Chipset::set_component_prefers_clocking(ClockingHint::Source *, ClockingHint::Preference preference) {
disk_controller_is_sleeping_ = preference == ClockingHint::Preference::None;
LOG("Disk controller is " << (disk_controller_is_sleeping_ ? "sleeping" : "awake"));
}
// MARK: - Disk Controller.

View File

@ -28,7 +28,7 @@ ClockingHint::Preference Controller::preferred_clocking() const {
// Nominate RealTime clocking if any drive currently wants any clocking whatsoever.
// Otherwise, ::None will do.
for(auto &drive: drives_) {
const auto preferred_clocking = drive.preferred_clocking();
const auto preferred_clocking = drive->preferred_clocking();
if(preferred_clocking != ClockingHint::Preference::None) {
return ClockingHint::Preference::RealTime;
}
@ -41,7 +41,7 @@ ClockingHint::Preference Controller::preferred_clocking() const {
void Controller::run_for(const Cycles cycles) {
for(auto &drive: drives_) {
drive.run_for(cycles);
drive->run_for(cycles);
}
empty_drive_.run_for(cycles);
}
@ -110,7 +110,7 @@ void Controller::set_drive(int index_mask) {
index_mask >>= 1;
++index;
}
drive_ = &drives_[index];
drive_ = drives_[index].get();
}
get_drive().set_event_delegate(this);

View File

@ -60,8 +60,8 @@ class Controller:
Adds a new drive to the drive list, returning its index.
*/
template<typename... Args> size_t emplace_drive(Args&&... args) {
drives_.emplace_back(std::forward<Args>(args)...);
drives_.back().set_clocking_hint_observer(this);
drives_.emplace_back(new Drive(std::forward<Args>(args)...));
drives_.back()->set_clocking_hint_observer(this);
return drives_.size() - 1;
}
@ -70,8 +70,7 @@ class Controller:
*/
template<typename... Args> size_t emplace_drives(size_t count, Args&&... args) {
while(count--) {
drives_.emplace_back(std::forward<Args>(args)...);
drives_.back().set_clocking_hint_observer(this);
emplace_drive(std::forward<Args>(args)...);
}
return drives_.size() - 1;
}
@ -122,13 +121,13 @@ class Controller:
Drive &get_drive();
Drive &get_drive(size_t index) {
return drives_[index];
return *drives_[index];
}
void for_all_drives(const std::function<void(Drive &, size_t)> &func) {
size_t index = 0;
for(auto &drive: drives_) {
func(drive, index);
func(*drive, index);
++index;
}
}
@ -149,7 +148,7 @@ class Controller:
friend DigitalPhaseLockedLoop<Controller>;
Drive empty_drive_;
std::vector<Drive> drives_;
std::vector<std::unique_ptr<Drive>> drives_;
Drive *drive_;
int drive_selection_mask_ = 0xff;

View File

@ -37,6 +37,10 @@ class Drive: public ClockingHint::Source, public TimedEventLoop {
Drive(int input_clock_rate, int number_of_heads, ReadyType rdy_type = ReadyType::ShugartRDY);
virtual ~Drive();
// Disallow copying.
Drive(const Drive &) = delete;
void operator=(const Drive &) = delete;
/*!
Replaces whatever is in the drive with @c disk. Supply @c nullptr to eject any current disk and leave none inserted.
*/