From fb9fd26af7a24a9cc3e4a075d7b6677bccabb6f0 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 11 Sep 2017 22:08:10 -0400 Subject: [PATCH] Updates the 1540 for the slightly-more modern world of decoupled drives and disks (!). --- Machines/Commodore/1540/Implementation/C1540.cpp | 14 ++++++++------ .../Commodore/1540/Implementation/C1540Base.hpp | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Machines/Commodore/1540/Implementation/C1540.cpp b/Machines/Commodore/1540/Implementation/C1540.cpp index 7bad7bcf9..1944e8f7c 100644 --- a/Machines/Commodore/1540/Implementation/C1540.cpp +++ b/Machines/Commodore/1540/Implementation/C1540.cpp @@ -22,7 +22,8 @@ MachineBase::MachineBase() : serial_port_(new SerialPort), serial_port_VIA_port_handler_(new SerialPortVIA(serial_port_VIA_)), drive_VIA_(drive_VIA_port_handler_), - serial_port_VIA_(*serial_port_VIA_port_handler_) { + serial_port_VIA_(*serial_port_VIA_port_handler_), + drive_(new Storage::Disk::Drive(1000000, 300)) { // attach the serial port to its VIA and vice versa serial_port_->set_serial_port_via(serial_port_VIA_port_handler_); serial_port_VIA_port_handler_->set_serial_port(serial_port_); @@ -34,6 +35,9 @@ MachineBase::MachineBase() : // set a bit rate set_expected_bit_length(Storage::Encodings::CommodoreGCR::length_of_a_bit_in_time_zone(3)); + + // attach the only drive there is + set_drive(drive_); } void Machine::set_serial_bus(std::shared_ptr<::Commodore::Serial::Bus> serial_bus) { @@ -82,16 +86,14 @@ void Machine::set_rom(const std::vector &rom) { } void Machine::set_disk(std::shared_ptr disk) { - std::shared_ptr drive(new Storage::Disk::Drive(1000000, 300)); - drive->set_disk(disk); - set_drive(drive); + drive_->set_disk(disk); } void Machine::run_for(const Cycles cycles) { m6502_.run_for(cycles); bool drive_motor = drive_VIA_port_handler_.get_motor_enabled(); - get_drive().set_motor_on(drive_motor); + drive_->set_motor_on(drive_motor); if(drive_motor) Storage::Disk::Controller::run_for(cycles); } @@ -130,7 +132,7 @@ void MachineBase::process_index_hole() {} #pragma mak - Drive VIA delegate void MachineBase::drive_via_did_step_head(void *driveVIA, int direction) { - get_drive().step(direction); + drive_->step(direction); } void MachineBase::drive_via_did_set_data_density(void *driveVIA, int density) { diff --git a/Machines/Commodore/1540/Implementation/C1540Base.hpp b/Machines/Commodore/1540/Implementation/C1540Base.hpp index f96d4b464..a179a3f58 100644 --- a/Machines/Commodore/1540/Implementation/C1540Base.hpp +++ b/Machines/Commodore/1540/Implementation/C1540Base.hpp @@ -135,6 +135,7 @@ class MachineBase: protected: CPU::MOS6502::Processor m6502_; + std::shared_ptr drive_; uint8_t ram_[0x800]; uint8_t rom_[0x4000];