From f3e18da4165ad3c9f6207c87d8c6079be3fa5715 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 15 Oct 2024 21:49:42 -0400 Subject: [PATCH 1/5] Use custom type for deleter. --- OSBindings/SDL/main.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/OSBindings/SDL/main.cpp b/OSBindings/SDL/main.cpp index 60620adb33..309eb725ae 100644 --- a/OSBindings/SDL/main.cpp +++ b/OSBindings/SDL/main.cpp @@ -444,7 +444,12 @@ std::string final_path_component(const std::string &path) { Executes @c command and returns its STDOUT. */ std::string system_get(const char *command) { - std::unique_ptr pipe(popen(command, "r"), pclose); + struct pcloser { + void operator()(FILE *file) { + pclose(dir); + } + }; + std::unique_ptr pipe(popen(command, "r")); if(!pipe) return ""; std::string result; From b701ce9721676008d649c41f52331ec25b9f1e94 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 15 Oct 2024 21:51:23 -0400 Subject: [PATCH 2/5] Shuffle construction order. --- Machines/Apple/Macintosh/Macintosh.cpp | 4 ++-- Machines/MSX/MSX.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Machines/Apple/Macintosh/Macintosh.cpp b/Machines/Apple/Macintosh/Macintosh.cpp index 35424a2f31..cf1f65981b 100644 --- a/Machines/Apple/Macintosh/Macintosh.cpp +++ b/Machines/Apple/Macintosh/Macintosh.cpp @@ -91,8 +91,8 @@ template class ConcreteMachin mc68000_(*this), iwm_(CLOCK_RATE), video_(audio_, drive_speed_accumulator_), - via_(via_port_handler_), via_port_handler_(*this, clock_, keyboard_, audio_, iwm_, mouse_), + via_(via_port_handler_), scsi_bus_(CLOCK_RATE * 2), scsi_(scsi_bus_, CLOCK_RATE * 2), hard_drive_(scsi_bus_, 6 /* SCSI ID */), @@ -760,8 +760,8 @@ template class ConcreteMachin Apple::Clock::SerialClock clock_; Keyboard keyboard_; - MOS::MOS6522::MOS6522 via_; VIAPortHandler via_port_handler_; + MOS::MOS6522::MOS6522 via_; Zilog::SCC::z8530 scc_; SCSI::Bus scsi_bus_; diff --git a/Machines/MSX/MSX.cpp b/Machines/MSX/MSX.cpp index acf3fffa97..66dae2aa45 100644 --- a/Machines/MSX/MSX.cpp +++ b/Machines/MSX/MSX.cpp @@ -198,10 +198,10 @@ class ConcreteMachine: public: ConcreteMachine(const Target &target, const ROMMachine::ROMFetcher &rom_fetcher): z80_(*this), - i8255_(i8255_port_handler_), tape_player_(3579545 * 2), i8255_port_handler_(*this, speaker_.audio_toggle, tape_player_), ay_port_handler_(tape_player_), + i8255_(i8255_port_handler_), memory_slots_{{*this}, {*this}, {*this}, {*this}}, clock_(ClockRate) { set_clock_rate(ClockRate); @@ -913,7 +913,6 @@ class ConcreteMachine: CPU::Z80::Processor z80_; JustInTimeActor> vdp_; - Intel::i8255::i8255 i8255_; Storage::Tape::BinaryTapePlayer tape_player_; bool tape_player_is_sleeping_ = false; @@ -932,6 +931,8 @@ class ConcreteMachine: Speaker speaker_; AYPortHandler ay_port_handler_; + Intel::i8255::i8255 i8255_; + /// The current primary and secondary slot selections; the former retains whatever was written /// last to the 8255 PPI via port A8 and the latter — if enabled — captures 0xffff on a per-slot basis. uint8_t primary_slots_ = 0; From d35165bd8ea4e91d623dffd80474e7ccf326443d Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 15 Oct 2024 21:54:04 -0400 Subject: [PATCH 3/5] Correct parameter usage. --- OSBindings/SDL/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OSBindings/SDL/main.cpp b/OSBindings/SDL/main.cpp index 309eb725ae..2231268c8d 100644 --- a/OSBindings/SDL/main.cpp +++ b/OSBindings/SDL/main.cpp @@ -446,7 +446,7 @@ std::string final_path_component(const std::string &path) { std::string system_get(const char *command) { struct pcloser { void operator()(FILE *file) { - pclose(dir); + pclose(file); } }; std::unique_ptr pipe(popen(command, "r")); From a1634ab4964b64f5f9029e317d39b8632e0498be Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 15 Oct 2024 22:10:16 -0400 Subject: [PATCH 4/5] Reduce uninitialised usages. --- Machines/Commodore/Vic-20/Vic20.cpp | 4 ++-- Machines/Oric/Oric.cpp | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Machines/Commodore/Vic-20/Vic20.cpp b/Machines/Commodore/Vic-20/Vic20.cpp index 89c1bb1dcc..181eb8cc9b 100644 --- a/Machines/Commodore/Vic-20/Vic20.cpp +++ b/Machines/Commodore/Vic-20/Vic20.cpp @@ -233,8 +233,8 @@ class Vic6560BusHandler { } // It is assumed that these pointers have been filled in by the machine. - uint8_t *video_memory_map[16]; // Segments video memory into 1kb portions. - uint8_t *colour_memory; // Colour memory must be contiguous. + uint8_t *video_memory_map[16]{}; // Segments video memory into 1kb portions. + uint8_t *colour_memory{}; // Colour memory must be contiguous. }; /*! diff --git a/Machines/Oric/Oric.cpp b/Machines/Oric/Oric.cpp index 63f574d629..59f0dcdbb6 100644 --- a/Machines/Oric/Oric.cpp +++ b/Machines/Oric/Oric.cpp @@ -36,6 +36,7 @@ #include "../../ClockReceiver/JustInTime.hpp" +#include #include #include #include @@ -715,7 +716,7 @@ template rom_, disk_rom_; - uint8_t ram_[65536]; + std::array ram_{}; // ROM bookkeeping uint16_t tape_get_byte_address_ = 0, tape_speed_address_ = 0; From 08d094c7868dd935820e750facc4f04e8cd0a938 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 15 Oct 2024 22:14:29 -0400 Subject: [PATCH 5/5] Use appropriate std::array semantics. --- Machines/Oric/Oric.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Machines/Oric/Oric.cpp b/Machines/Oric/Oric.cpp index 59f0dcdbb6..f10a4e8848 100644 --- a/Machines/Oric/Oric.cpp +++ b/Machines/Oric/Oric.cpp @@ -285,7 +285,7 @@ template