From 8827597363ac5d7c8bb555ea14841b144cd2d003 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 8 Jul 2016 19:00:39 -0400 Subject: [PATCH] Messier and messier, but I've at least attempted to implement hardware attention acknowledge. --- Machines/Commodore/1540/Commodore1540.cpp | 13 +++++++++++- Machines/Commodore/1540/Commodore1540.hpp | 25 ++++++++++++++++++----- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/Machines/Commodore/1540/Commodore1540.cpp b/Machines/Commodore/1540/Commodore1540.cpp index 335113474..0d803fc6e 100644 --- a/Machines/Commodore/1540/Commodore1540.cpp +++ b/Machines/Commodore/1540/Commodore1540.cpp @@ -30,7 +30,14 @@ void Machine::set_serial_bus(std::shared_ptr<::Commodore::Serial::Bus> serial_bu unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value) { -// if(operation == CPU6502::BusOperation::ReadOpcode) printf("%04x\n", address); + static bool log = false; + + if(operation == CPU6502::BusOperation::ReadOpcode) + { + log = (address >= 0xE85B && address <= 0xE907) || (address >= 0xE9C9 && address <= 0xEA2D); + if(log) printf("\n%04x: ", address); + } + if(log) printf("[%c %04x] ", isReadOperation(operation) ? 'r' : 'w', address); if(address < 0x800) { @@ -46,6 +53,10 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin } else if(address >= 0x1800 && address <= 0x180f) { + if(address == 0x1805) + { + printf("Timer\n"); + } if(isReadOperation(operation)) *value = _serialPortVIA->get_register(address); else diff --git a/Machines/Commodore/1540/Commodore1540.hpp b/Machines/Commodore/1540/Commodore1540.hpp index f5df4c36e..153dc5b8c 100644 --- a/Machines/Commodore/1540/Commodore1540.hpp +++ b/Machines/Commodore/1540/Commodore1540.hpp @@ -20,7 +20,7 @@ class SerialPortVIA: public MOS::MOS6522, public MOS::MOS6522IRQD public: using MOS6522IRQDelegate::set_interrupt_status; - SerialPortVIA() : _portB(0x9f), _attention_acknowledge_level(false) {} + SerialPortVIA() : _portB(0x00), _attention_acknowledge_level(false), _attention_level_input(true), _data_level_output(false) {} uint8_t get_port_input(Port port) { if(port) { @@ -37,10 +37,10 @@ class SerialPortVIA: public MOS::MOS6522, public MOS::MOS6522IRQD printf("1540 output: %02x\n", value); // "ATNA (Attention Acknowledge) is an output from PB4 which is sensed on the serial data line after being exclusively "ored" by the attention line and inverted" _attention_acknowledge_level = !(value&0x10); - serialPort->set_output(::Commodore::Serial::Line::Clock, (::Commodore::Serial::LineLevel)!(value&0x08)); - serialPort->set_output(::Commodore::Serial::Line::Data, (::Commodore::Serial::LineLevel)!(value&0x02)); + _data_level_output = (value&0x02); -// serialPort->set_output(::Commodore::Serial::Line::Data, _attention_acknowledge_level ) + serialPort->set_output(::Commodore::Serial::Line::Clock, (::Commodore::Serial::LineLevel)!(value&0x08)); + update_data_line(); } // printf("1540 serial port VIA port B: %02x\n", value); } @@ -56,8 +56,10 @@ class SerialPortVIA: public MOS::MOS6522, public MOS::MOS6522IRQD case ::Commodore::Serial::Line::Clock: _portB = (_portB & ~0x04) | (value ? 0x00 : 0x04); break; case ::Commodore::Serial::Line::Attention: // "ATN (Attention) is an input on pin 3 of P2 and P3 that is sensed at PB7 and CA1 of UC3 after being inverted by UA1" + _attention_level_input = !value; _portB = (_portB & ~0x80) | (value ? 0x00 : 0x80); set_control_line_input(Port::A, Line::One, !value); + update_data_line(); break; } } @@ -69,7 +71,20 @@ class SerialPortVIA: public MOS::MOS6522, public MOS::MOS6522IRQD private: uint8_t _portB; std::weak_ptr<::Commodore::Serial::Port> _serialPort; - bool _attention_acknowledge_level; + bool _attention_acknowledge_level, _attention_level_input, _data_level_output; + + void update_data_line() + { + std::shared_ptr<::Commodore::Serial::Port> serialPort = _serialPort.lock(); + if(serialPort) { + serialPort->set_output(::Commodore::Serial::Line::Data, + (::Commodore::Serial::LineLevel)!(_data_level_output + || (_attention_level_input == _attention_acknowledge_level)) + ); + +// + } + } }; class DriveVIA: public MOS::MOS6522, public MOS::MOS6522IRQDelegate {