From 5fb6e6780ca6adbbffd3bb164278b9d698600c01 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 8 Jan 2025 22:30:17 -0500 Subject: [PATCH 1/4] Eliminate unused variable (at least temporarily). --- Analyser/Static/Commodore/StaticAnalyser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Analyser/Static/Commodore/StaticAnalyser.cpp b/Analyser/Static/Commodore/StaticAnalyser.cpp index 094a9d4f56..82aa918b41 100644 --- a/Analyser/Static/Commodore/StaticAnalyser.cpp +++ b/Analyser/Static/Commodore/StaticAnalyser.cpp @@ -87,7 +87,7 @@ std::optional analyse(const File &file) { } uint16_t line_address = file.starting_address; - int previous_line_number = -1; +// int previous_line_number = -1; const auto byte = [&](uint16_t address) { return file.data[address - file.starting_address]; @@ -153,7 +153,7 @@ std::optional analyse(const File &file) { break; } - previous_line_number = line_number; +// previous_line_number = line_number; line_address = next_line_address; } From 06779873207856a3675abfdd388cfbe234a64897 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 8 Jan 2025 22:30:32 -0500 Subject: [PATCH 2/4] Ensure all paths return a value. --- Storage/Tape/Formats/CommodoreTAP.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Storage/Tape/Formats/CommodoreTAP.cpp b/Storage/Tape/Formats/CommodoreTAP.cpp index c78f61dc83..4bf30467fa 100644 --- a/Storage/Tape/Formats/CommodoreTAP.cpp +++ b/Storage/Tape/Formats/CommodoreTAP.cpp @@ -43,6 +43,7 @@ CommodoreTAP::Serialiser::Serialiser(const std::string &file_name) : current_pulse_.length.clock_rate = static_cast( [&] { switch(platform_) { + default: case Platform::Vic20: // It empirically seems like Vic-20 waves are counted with C64 timings? case Platform::C64: return video_ == VideoStandard::PAL ? 985'248 : 1'022'727; case Platform::C16: return video_ == VideoStandard::PAL ? 886'722 : 894'886; From c679e2c06793ed183dc3a71533eabe2e934eeeef Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 9 Jan 2025 16:14:16 -0500 Subject: [PATCH 3/4] `line_number` is now unused. --- Analyser/Static/Commodore/StaticAnalyser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Analyser/Static/Commodore/StaticAnalyser.cpp b/Analyser/Static/Commodore/StaticAnalyser.cpp index 82aa918b41..f8ba8fb247 100644 --- a/Analyser/Static/Commodore/StaticAnalyser.cpp +++ b/Analyser/Static/Commodore/StaticAnalyser.cpp @@ -115,7 +115,7 @@ std::optional analyse(const File &file) { } const auto next_line_address = word(line_address); - const auto line_number = word(line_address + 2); +// const auto line_number = word(line_address + 2); uint16_t code = line_address + 4; const auto next = [&]() -> uint8_t { From 56f10a9a529e66a67b9e923819e6b91b61de9193 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 9 Jan 2025 16:27:19 -0500 Subject: [PATCH 4/4] Adjust ownership to avoid passing reference to uninitialised object. --- .../Commodore/1540/Implementation/C1540.cpp | 20 ++++++++++--------- .../1540/Implementation/C1540Base.hpp | 12 +++++------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Machines/Commodore/1540/Implementation/C1540.cpp b/Machines/Commodore/1540/Implementation/C1540.cpp index ab35fa18c9..47eed737e0 100644 --- a/Machines/Commodore/1540/Implementation/C1540.cpp +++ b/Machines/Commodore/1540/Implementation/C1540.cpp @@ -33,11 +33,10 @@ ROM::Request Machine::rom_request(Personality personality) { MachineBase::MachineBase(Personality personality, const ROM::Map &roms) : Storage::Disk::Controller(1000000), m6502_(*this), - serial_port_VIA_port_handler_(serial_port_VIA_), drive_VIA_(drive_VIA_port_handler_), serial_port_VIA_(serial_port_VIA_port_handler_) { // Attach the serial port to its VIA and vice versa. - serial_port_.set_serial_port_via(serial_port_VIA_port_handler_); + serial_port_.connect(serial_port_VIA_port_handler_, serial_port_VIA_); serial_port_VIA_port_handler_.set_serial_port(serial_port_); // Set this instance as the delegate to receive interrupt requests from both VIAs. @@ -163,8 +162,6 @@ void MachineBase::drive_via_did_set_data_density(void *, const int density) { // MARK: - SerialPortVIA -SerialPortVIA::SerialPortVIA(MOS::MOS6522::MOS6522 &via) : via_(via) {} - uint8_t SerialPortVIA::get_port_input(MOS::MOS6522::Port port) { if(port) return port_b_; return 0xff; @@ -180,7 +177,11 @@ void SerialPortVIA::set_port_output(MOS::MOS6522::Port port, uint8_t value, uint } } -void SerialPortVIA::set_serial_line_state(::Commodore::Serial::Line line, bool value) { +void SerialPortVIA::set_serial_line_state( + ::Commodore::Serial::Line line, + bool value, + MOS::MOS6522::MOS6522 &via +) { switch(line) { default: break; case ::Commodore::Serial::Line::Data: port_b_ = (port_b_ & ~0x01) | (value ? 0x00 : 0x01); break; @@ -188,7 +189,7 @@ void SerialPortVIA::set_serial_line_state(::Commodore::Serial::Line line, bool v case ::Commodore::Serial::Line::Attention: attention_level_input_ = !value; port_b_ = (port_b_ & ~0x80) | (value ? 0x00 : 0x80); - via_.set_control_line_input(MOS::MOS6522::Port::A, MOS::MOS6522::Line::One, !value); + via.set_control_line_input(MOS::MOS6522::Port::A, MOS::MOS6522::Line::One, !value); update_data_line(); break; } @@ -274,9 +275,10 @@ void DriveVIA::set_activity_observer(Activity::Observer *observer) { // MARK: - SerialPort void SerialPort::set_input(Serial::Line line, Serial::LineLevel level) { - serial_port_VIA_->set_serial_line_state(line, bool(level)); + serial_port_via_->set_serial_line_state(line, bool(level), *via_); } -void SerialPort::set_serial_port_via(SerialPortVIA &serialPortVIA) { - serial_port_VIA_ = &serialPortVIA; +void SerialPort::connect(SerialPortVIA &serial_port_via, MOS::MOS6522::MOS6522 &via) { + serial_port_via_ = &serial_port_via; + via_ = &via; } diff --git a/Machines/Commodore/1540/Implementation/C1540Base.hpp b/Machines/Commodore/1540/Implementation/C1540Base.hpp index 91f5da8179..690f1061cf 100644 --- a/Machines/Commodore/1540/Implementation/C1540Base.hpp +++ b/Machines/Commodore/1540/Implementation/C1540Base.hpp @@ -39,17 +39,14 @@ namespace Commodore::C1540 { */ class SerialPortVIA: public MOS::MOS6522::IRQDelegatePortHandler { public: - SerialPortVIA(MOS::MOS6522::MOS6522 &via); - uint8_t get_port_input(MOS::MOS6522::Port); void set_port_output(MOS::MOS6522::Port, uint8_t value, uint8_t mask); - void set_serial_line_state(::Commodore::Serial::Line, bool); + void set_serial_line_state(::Commodore::Serial::Line, bool, MOS::MOS6522::MOS6522 &); void set_serial_port(Commodore::Serial::Port &); private: - MOS::MOS6522::MOS6522 &via_; uint8_t port_b_ = 0x0; Commodore::Serial::Port *serial_port_ = nullptr; bool attention_acknowledge_level_ = false; @@ -111,11 +108,12 @@ class DriveVIA: public MOS::MOS6522::IRQDelegatePortHandler { */ class SerialPort : public ::Commodore::Serial::Port { public: - void set_input(Commodore::Serial::Line, Commodore::Serial::LineLevel); - void set_serial_port_via(SerialPortVIA &); + void set_input(Commodore::Serial::Line, Commodore::Serial::LineLevel) override; + void connect(SerialPortVIA &, MOS::MOS6522::MOS6522&); private: - SerialPortVIA *serial_port_VIA_ = nullptr; + SerialPortVIA *serial_port_via_ = nullptr; + MOS::MOS6522::MOS6522 *via_ = nullptr; }; class MachineBase: