diff --git a/Machines/Amiga/Chipset.cpp b/Machines/Amiga/Chipset.cpp index 91e405969..6d5e0e1b7 100644 --- a/Machines/Amiga/Chipset.cpp +++ b/Machines/Amiga/Chipset.cpp @@ -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. diff --git a/Storage/Disk/Controller/DiskController.cpp b/Storage/Disk/Controller/DiskController.cpp index 9ad93661e..b2c8e5969 100644 --- a/Storage/Disk/Controller/DiskController.cpp +++ b/Storage/Disk/Controller/DiskController.cpp @@ -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); diff --git a/Storage/Disk/Controller/DiskController.hpp b/Storage/Disk/Controller/DiskController.hpp index 67f9d0ea2..57d574854 100644 --- a/Storage/Disk/Controller/DiskController.hpp +++ b/Storage/Disk/Controller/DiskController.hpp @@ -60,8 +60,8 @@ class Controller: Adds a new drive to the drive list, returning its index. */ template size_t emplace_drive(Args&&... args) { - drives_.emplace_back(std::forward(args)...); - drives_.back().set_clocking_hint_observer(this); + drives_.emplace_back(new Drive(std::forward(args)...)); + drives_.back()->set_clocking_hint_observer(this); return drives_.size() - 1; } @@ -70,8 +70,7 @@ class Controller: */ template size_t emplace_drives(size_t count, Args&&... args) { while(count--) { - drives_.emplace_back(std::forward(args)...); - drives_.back().set_clocking_hint_observer(this); + emplace_drive(std::forward(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 &func) { size_t index = 0; for(auto &drive: drives_) { - func(drive, index); + func(*drive, index); ++index; } } @@ -149,7 +148,7 @@ class Controller: friend DigitalPhaseLockedLoop; Drive empty_drive_; - std::vector drives_; + std::vector> drives_; Drive *drive_; int drive_selection_mask_ = 0xff; diff --git a/Storage/Disk/Drive.hpp b/Storage/Disk/Drive.hpp index f7671e236..c0b81a4a5 100644 --- a/Storage/Disk/Drive.hpp +++ b/Storage/Disk/Drive.hpp @@ -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. */