From b4a3b235716246c066bcea712f94c65cd5511540 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 15 Feb 2024 13:32:49 -0500 Subject: [PATCH] Eliminate use of printf. --- Components/6526/6526.hpp | 3 +++ .../6526/Implementation/6526Implementation.hpp | 17 +++++------------ Outputs/Log.hpp | 4 ++-- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Components/6526/6526.hpp b/Components/6526/6526.hpp index 508994e46..c70e5ba18 100644 --- a/Components/6526/6526.hpp +++ b/Components/6526/6526.hpp @@ -12,6 +12,7 @@ #include "Implementation/6526Storage.hpp" #include "../Serial/Line.hpp" +#include "../../Outputs/Log.hpp" namespace MOS::MOS6526 { @@ -82,6 +83,8 @@ template class MOS6526: void advance_counters(int); bool serial_line_did_produce_bit(Serial::Line *line, int bit) final; + + Log::Logger log; }; } diff --git a/Components/6526/Implementation/6526Implementation.hpp b/Components/6526/Implementation/6526Implementation.hpp index 28889cb7f..543e21195 100644 --- a/Components/6526/Implementation/6526Implementation.hpp +++ b/Components/6526/Implementation/6526Implementation.hpp @@ -8,9 +8,6 @@ #pragma once -#include -#include - namespace MOS::MOS6526 { enum Interrupts: uint8_t { @@ -132,13 +129,11 @@ void MOS6526::write(int address, uint8_t value) { // Shift control. case 12: - printf("TODO: write to shift register\n"); + log.error().append("TODO: write to shift register"); break; - default: - printf("Unhandled 6526 write: %02x to %d\n", value, address); - assert(false); - break; + // Logically unreachable. + default: break; } } @@ -179,10 +174,8 @@ uint8_t MOS6526::read(int address) { // Shift register. case 12: return shift_data_; - default: - printf("Unhandled 6526 read from %d\n", address); - assert(false); - break; + // Logically unreachable. + default: break; } return 0xff; } diff --git a/Outputs/Log.hpp b/Outputs/Log.hpp index c5652226b..4ce024e83 100644 --- a/Outputs/Log.hpp +++ b/Outputs/Log.hpp @@ -36,6 +36,7 @@ enum class Source { MasterSystem, MultiMachine, MFP68901, + MOS6526, MSX, NCR5380, OpenGL, @@ -91,6 +92,7 @@ constexpr const char *prefix(Source source) { case Source::M50740: return "M50740"; case Source::Macintosh: return "Macintosh"; case Source::MasterSystem: return "SMS"; + case Source::MOS6526: return "MOS6526"; case Source::MFP68901: return "MFP68901"; case Source::MultiMachine: return "Multi-machine"; case Source::MSX: return "MSX"; @@ -112,8 +114,6 @@ class Logger { public: static constexpr bool enabled = is_enabled(source); - Logger() {} - struct LogLine { public: LogLine(FILE *stream) : stream_(stream) {