From 428fcdb978493abc5780ffc12cfec4d13c638f11 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 6 Jul 2016 07:46:21 -0400 Subject: [PATCH] Centralised and improved serial logging. --- Machines/Commodore/1540/Commodore1540.hpp | 8 ++++---- Machines/Commodore/SerialBus.cpp | 13 +++++++++++++ Machines/Commodore/SerialBus.hpp | 2 ++ Machines/Commodore/Vic-20/Vic20.hpp | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Machines/Commodore/1540/Commodore1540.hpp b/Machines/Commodore/1540/Commodore1540.hpp index 69ee5a44e..2eae8b37d 100644 --- a/Machines/Commodore/1540/Commodore1540.hpp +++ b/Machines/Commodore/1540/Commodore1540.hpp @@ -38,14 +38,14 @@ class SerialPortVIA: public MOS::MOS6522, public MOS::MOS6522IRQD serialPort->set_output(::Commodore::Serial::Line::Clock, !(value&0x08)); serialPort->set_output(::Commodore::Serial::Line::Data, !(value&0x02)); } - printf("1540 serial port VIA port B: %02x\n", value); +// printf("1540 serial port VIA port B: %02x\n", value); } - else - printf("1540 serial port VIA port A: %02x\n", value); +// else +// printf("1540 serial port VIA port A: %02x\n", value); } void set_serial_line_state(::Commodore::Serial::Line line, bool value) { - printf("1540 Serial port line %d: %s\n", line, value ? "on" : "off"); +// printf("1540 Serial port line %d: %s\n", line, value ? "on" : "off"); switch(line) { default: break; case ::Commodore::Serial::Line::Data: _portB = (_portB & ~0x01) | (value ? 0 : 0x01); break; diff --git a/Machines/Commodore/SerialBus.cpp b/Machines/Commodore/SerialBus.cpp index be76aaef5..3692fbfda 100644 --- a/Machines/Commodore/SerialBus.cpp +++ b/Machines/Commodore/SerialBus.cpp @@ -10,6 +10,18 @@ using namespace Commodore::Serial; +const char *::Commodore::Serial::StringForLine(Line line) +{ + switch(line) + { + case ServiceRequest: return "Service request"; + case Attention: return "Attention"; + case Clock: return "Clock"; + case Data: return "Data"; + case Reset: return "Reset"; + } +} + void Bus::add_port(std::shared_ptr port) { _ports.push_back(port); @@ -39,6 +51,7 @@ void Bus::set_line_output_did_change(Line line) // post an update only if one occurred if(new_line_value != _line_values[line]) { + printf("[Bus] %s is %s\n", StringForLine(line), new_line_value ? "true" : "false"); _line_values[line] = new_line_value; for(std::weak_ptr port : _ports) diff --git a/Machines/Commodore/SerialBus.hpp b/Machines/Commodore/SerialBus.hpp index 9f1034c7a..44aa908a3 100644 --- a/Machines/Commodore/SerialBus.hpp +++ b/Machines/Commodore/SerialBus.hpp @@ -22,6 +22,8 @@ namespace Serial { Reset }; + const char *StringForLine(Line line); + class Port; class Bus { diff --git a/Machines/Commodore/Vic-20/Vic20.hpp b/Machines/Commodore/Vic-20/Vic20.hpp index ca2b55d53..6d940a34d 100644 --- a/Machines/Commodore/Vic-20/Vic20.hpp +++ b/Machines/Commodore/Vic-20/Vic20.hpp @@ -76,7 +76,7 @@ class UserPortVIA: public MOS::MOS6522, public MOS::MOS6522IRQDeleg } void set_serial_line_state(::Commodore::Serial::Line line, bool value) { - printf("VIC Serial port line %d: %s\n", line, value ? "on" : "off"); +// printf("VIC Serial port line %d: %s\n", line, value ? "on" : "off"); switch(line) { default: break; case ::Commodore::Serial::Line::Data: _portA = (_portA & ~0x02) | (value ? 0 : 0x02); break;