From 8819711bc8056d2cf7f14f0a24dcb4e3a378466b Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 5 Jul 2016 22:22:09 -0400 Subject: [PATCH] Threw in the second VIA as a currently clearly incorrect thing. --- Components/6522/6522.hpp | 2 +- Machines/Commodore/1540/Commodore1540.cpp | 10 ++++++++++ Machines/Commodore/1540/Commodore1540.hpp | 6 ++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Components/6522/6522.hpp b/Components/6522/6522.hpp index 4353c6a6b..e35f6c039 100644 --- a/Components/6522/6522.hpp +++ b/Components/6522/6522.hpp @@ -1,4 +1,4 @@ -// + // // 6522.hpp // Clock Signal // diff --git a/Machines/Commodore/1540/Commodore1540.cpp b/Machines/Commodore/1540/Commodore1540.cpp index 44379a9d3..9ad308ff6 100644 --- a/Machines/Commodore/1540/Commodore1540.cpp +++ b/Machines/Commodore/1540/Commodore1540.cpp @@ -18,6 +18,8 @@ Machine::Machine() _serialPort->set_serial_port_via(_serialPortVIA); _serialPortVIA->set_serial_port(_serialPort); + _serialPortVIA->set_delegate(this); + _driveVIA.set_delegate(this); } void Machine::set_serial_bus(std::shared_ptr<::Commodore::Serial::Bus> serial_bus) @@ -47,8 +49,16 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin else _serialPortVIA->set_register(address, *value); } + else if(address >= 0x1c00 && address <= 0x1c0f) + { + if(isReadOperation(operation)) + *value = _driveVIA.get_register(address); + else + _driveVIA.set_register(address, *value); + } _serialPortVIA->run_for_half_cycles(2); + _driveVIA.run_for_half_cycles(2); return 1; } diff --git a/Machines/Commodore/1540/Commodore1540.hpp b/Machines/Commodore/1540/Commodore1540.hpp index 7ef1d1734..69ee5a44e 100644 --- a/Machines/Commodore/1540/Commodore1540.hpp +++ b/Machines/Commodore/1540/Commodore1540.hpp @@ -66,6 +66,11 @@ class SerialPortVIA: public MOS::MOS6522, public MOS::MOS6522IRQD std::weak_ptr<::Commodore::Serial::Port> _serialPort; }; +class DriveVIA: public MOS::MOS6522, public MOS::MOS6522IRQDelegate { + public: + using MOS6522IRQDelegate::set_interrupt_status; +}; + class SerialPort : public ::Commodore::Serial::Port { public: void set_input(::Commodore::Serial::Line line, bool value) { @@ -101,6 +106,7 @@ class Machine: std::shared_ptr _serialPortVIA; std::shared_ptr _serialPort; + DriveVIA _driveVIA; }; }