From 54aa211f56eae62395fac591dca91b0c52076912 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 18 Dec 2021 17:48:45 -0500 Subject: [PATCH] Avoid infinite loops for completely undefined addresses. --- Machines/Amiga/Chipset.cpp | 12 ++++++------ Machines/Amiga/Chipset.hpp | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Machines/Amiga/Chipset.cpp b/Machines/Amiga/Chipset.cpp index b9d36ff10..89c8eb943 100644 --- a/Machines/Amiga/Chipset.cpp +++ b/Machines/Amiga/Chipset.cpp @@ -810,13 +810,13 @@ void Chipset::perform(const CPU::MC68000::Microcycle &cycle) { const uint32_t register_address = *cycle.address & 0x1fe; if(cycle.operation & Microcycle::Read) { - cycle.set_value16(read(register_address)); + cycle.set_value16(read(register_address)); } else { - write(register_address, cycle.value16()); + write(register_address, cycle.value16()); } } -void Chipset::write(uint32_t address, uint16_t value) { +template void Chipset::write(uint32_t address, uint16_t value) { #define ApplySetClear(target, mask) { \ if(value & 0x8000) { \ target |= (value & mask); \ @@ -828,7 +828,7 @@ void Chipset::write(uint32_t address, uint16_t value) { switch(address) { default: // If there was nothing to write, perform a throwaway read. - read(address); + if constexpr (allow_conversion) read(address); break; // Raster position. @@ -1083,12 +1083,12 @@ void Chipset::write(uint32_t address, uint16_t value) { #undef ApplySetClear } -uint16_t Chipset::read(uint32_t address) { +template uint16_t Chipset::read(uint32_t address) { switch(address) { default: // If there was nothing to read, perform a write. // TODO: Rather than 0xffff, should be whatever is left on the bus, vapour-lock style. - write(address, 0xffff); + if constexpr (allow_conversion) write(address, 0xffff); return 0xffff; // Raster position. diff --git a/Machines/Amiga/Chipset.hpp b/Machines/Amiga/Chipset.hpp index 488b6fd80..104b74d53 100644 --- a/Machines/Amiga/Chipset.hpp +++ b/Machines/Amiga/Chipset.hpp @@ -108,8 +108,8 @@ class Chipset: private ClockingHint::Observer { friend class DMADeviceBase; // MARK: - Register read/write functions. - uint16_t read(uint32_t address); - void write(uint32_t address, uint16_t value); + template uint16_t read(uint32_t address); + template void write(uint32_t address, uint16_t value); // MARK: - E Clock and keyboard dividers.