From b4a3b235716246c066bcea712f94c65cd5511540 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 15 Feb 2024 13:32:49 -0500 Subject: [PATCH 1/3] 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) { From 093a029b8c75afa4da86aff6e4c6a080c35fa4ab Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 15 Feb 2024 13:41:35 -0500 Subject: [PATCH 2/3] Further reduce printf footprint. --- Components/6526/6526.hpp | 1 - Components/6526/Implementation/6526Storage.hpp | 4 +++- Components/DiskII/IWM.cpp | 4 ---- Components/DiskII/MacintoshDoubleDensityDrive.cpp | 1 - Machines/Atari/ST/DMAController.cpp | 2 +- Machines/Oric/BD500.cpp | 5 +---- 6 files changed, 5 insertions(+), 12 deletions(-) diff --git a/Components/6526/6526.hpp b/Components/6526/6526.hpp index c70e5ba18..751d91616 100644 --- a/Components/6526/6526.hpp +++ b/Components/6526/6526.hpp @@ -12,7 +12,6 @@ #include "Implementation/6526Storage.hpp" #include "../Serial/Line.hpp" -#include "../../Outputs/Log.hpp" namespace MOS::MOS6526 { diff --git a/Components/6526/Implementation/6526Storage.hpp b/Components/6526/Implementation/6526Storage.hpp index 0c3695eab..35db218aa 100644 --- a/Components/6526/Implementation/6526Storage.hpp +++ b/Components/6526/Implementation/6526Storage.hpp @@ -11,6 +11,7 @@ #include #include "../../../ClockReceiver/ClockReceiver.hpp" +#include "../../../Outputs/Log.hpp" namespace MOS::MOS6526 { @@ -220,7 +221,8 @@ struct MOS6526Storage { control = v; if(v&2) { - printf("UNIMPLEMENTED: PB strobe\n"); + Log::Logger log; + log.error().append("UNIMPLEMENTED: PB strobe"); } } diff --git a/Components/DiskII/IWM.cpp b/Components/DiskII/IWM.cpp index 57cb5a798..8a047eb03 100644 --- a/Components/DiskII/IWM.cpp +++ b/Components/DiskII/IWM.cpp @@ -55,10 +55,6 @@ uint8_t IWM::read(int address) { logger.info().append("Invalid read\n"); return 0xff; - // "Read all 1s". -// printf("Reading all 1s\n"); -// return 0xff; - case 0: case ENABLE: { /* Read data register. Zeroing afterwards is a guess. */ const auto result = data_register_; diff --git a/Components/DiskII/MacintoshDoubleDensityDrive.cpp b/Components/DiskII/MacintoshDoubleDensityDrive.cpp index 164d3ebe0..d90784b76 100644 --- a/Components/DiskII/MacintoshDoubleDensityDrive.cpp +++ b/Components/DiskII/MacintoshDoubleDensityDrive.cpp @@ -30,7 +30,6 @@ DoubleDensityDrive::DoubleDensityDrive(int input_clock_rate, bool is_800k) : // MARK: - Speed Selection void DoubleDensityDrive::did_step(Storage::Disk::HeadPosition to_position) { -// printf("At track %d\n", to_position.as_int()); // The 800kb drive automatically selects rotation speed as a function of // head position; the 400kb drive doesn't do so. if(is_800k_) { diff --git a/Machines/Atari/ST/DMAController.cpp b/Machines/Atari/ST/DMAController.cpp index 7c416aa25..f7c551fb8 100644 --- a/Machines/Atari/ST/DMAController.cpp +++ b/Machines/Atari/ST/DMAController.cpp @@ -16,7 +16,7 @@ using namespace Atari::ST; namespace { -Log::Logger logger; +[[maybe_unused]] Log::Logger logger; enum Control: uint16_t { Direction = 0x100, diff --git a/Machines/Oric/BD500.cpp b/Machines/Oric/BD500.cpp index 7daf3ab57..eb8ffd115 100644 --- a/Machines/Oric/BD500.cpp +++ b/Machines/Oric/BD500.cpp @@ -28,7 +28,6 @@ void BD500::write(int address, uint8_t value) { access(address); if(address >= 0x0320 && address <= 0x0323) { -// if(address == 0x320) printf("Command %02x\n", value); WD::WD1770::write(address, value); } @@ -69,9 +68,7 @@ void BD500::access(int address) { case 0x314: enable_overlay_ram_ = true; break; case 0x317: disable_basic_rom_ = false; break; - default: -// printf("Switch %04x???\n", address); - break; + default: break; } select_paged_item(); From d9ec11c62e8a802dbe796c992b5bbb51b999a4d6 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 15 Feb 2024 13:55:46 -0500 Subject: [PATCH 3/3] Use logger instead of printf. --- Machines/Apple/AppleII/SCSICard.cpp | 6 +++--- Machines/Apple/AppleII/SCSICard.hpp | 3 +++ Outputs/Log.hpp | 8 +++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Machines/Apple/AppleII/SCSICard.cpp b/Machines/Apple/AppleII/SCSICard.cpp index d84c575fe..674a4c7b6 100644 --- a/Machines/Apple/AppleII/SCSICard.cpp +++ b/Machines/Apple/AppleII/SCSICard.cpp @@ -125,13 +125,13 @@ void SCSICard::perform_bus_operation(Select select, bool is_read, uint16_t addre case 0xb: if(!is_read) { - printf("TODO: NCR reset\n"); + logger_.error().append("TODO: NCR reset"); } break; case 0xd: if(!is_read) { - printf("TODO: Enable PDMA\n"); + logger_.error().append("TODO: Enable PDMA"); } break; @@ -143,7 +143,7 @@ void SCSICard::perform_bus_operation(Select select, bool is_read, uint16_t addre break; default: - printf("Unhandled: %04x %c %02x\n", address, is_read ? 'r' : 'w', *value); + logger_.error().append("Unhandled: %04x %c %02x\n", address, is_read ? 'r' : 'w', *value); break; } break; diff --git a/Machines/Apple/AppleII/SCSICard.hpp b/Machines/Apple/AppleII/SCSICard.hpp index 40ce1a1b7..18f7182e4 100644 --- a/Machines/Apple/AppleII/SCSICard.hpp +++ b/Machines/Apple/AppleII/SCSICard.hpp @@ -17,6 +17,8 @@ #include "../../../Storage/MassStorage/SCSI/DirectAccessDevice.hpp" #include "../../../Storage/MassStorage/MassStorageDevice.hpp" +#include "../../../Outputs/Log.hpp" + #include #include @@ -47,6 +49,7 @@ class SCSICard: public Card { SCSI::Bus scsi_bus_; NCR::NCR5380::NCR5380 ncr5380_; SCSI::Target::Target storage_; + Log::Logger logger_; }; } diff --git a/Outputs/Log.hpp b/Outputs/Log.hpp index 4ce024e83..7ccef5756 100644 --- a/Outputs/Log.hpp +++ b/Outputs/Log.hpp @@ -23,6 +23,7 @@ enum class Source { AmigaCopper, AmigaChipset, AmigaBlitter, + AppleIISCSICard, AtariST, AtariSTDMAController, CommodoreStaticAnalyser, @@ -65,10 +66,13 @@ constexpr bool is_enabled(Source source) { case Source::AmigaChipset: case Source::AmigaCopper: case Source::AmigaDisk: + case Source::DirectAccessDevice: case Source::IWM: case Source::MFP68901: case Source::NCR5380: - case Source::SCC: return false; + case Source::SCC: + case Source::SCSI: + return false; } } @@ -82,9 +86,11 @@ constexpr const char *prefix(Source source) { case Source::AmigaChipset: return "Chipset"; case Source::AmigaCopper: return "Copper"; case Source::AmigaDisk: return "Disk"; + case Source::AppleIISCSICard: return "SCSI card"; case Source::AtariST: return "AtariST"; case Source::AtariSTDMAController: return "DMA"; case Source::CommodoreStaticAnalyser: return "Commodore Static Analyser"; + case Source::DirectAccessDevice: return "Direct Access Device"; case Source::Enterprise: return "Enterprise"; case Source::i8272: return "i8272"; case Source::IntelligentKeyboard: return "IKYB";