diff --git a/Analyser/Static/Acorn/Target.hpp b/Analyser/Static/Acorn/Target.hpp index e247f7bfc..c2f9f22b4 100644 --- a/Analyser/Static/Acorn/Target.hpp +++ b/Analyser/Static/Acorn/Target.hpp @@ -16,9 +16,9 @@ namespace Static { namespace Acorn { struct Target: public ::Analyser::Static::Target { - bool has_adfs; - bool has_dfs; - bool should_shift_restart; + bool has_adfs = false; + bool has_dfs = false; + bool should_shift_restart = false; }; } diff --git a/Analyser/Static/AmstradCPC/Target.hpp b/Analyser/Static/AmstradCPC/Target.hpp index 056c45402..795106435 100644 --- a/Analyser/Static/AmstradCPC/Target.hpp +++ b/Analyser/Static/AmstradCPC/Target.hpp @@ -22,7 +22,7 @@ struct Target: public ::Analyser::Static::Target { CPC6128 }; - Model model; + Model model = Model::CPC464; }; } diff --git a/Analyser/Static/Atari/Target.hpp b/Analyser/Static/Atari/Target.hpp index dc6cd7955..9f0119ada 100644 --- a/Analyser/Static/Atari/Target.hpp +++ b/Analyser/Static/Atari/Target.hpp @@ -32,8 +32,8 @@ struct Target: public ::Analyser::Static::Target { }; // TODO: shouldn't these be properties of the cartridge? - PagingModel paging_model; - bool uses_superchip; + PagingModel paging_model = PagingModel::None; + bool uses_superchip = false; }; } diff --git a/Analyser/Static/Commodore/Target.hpp b/Analyser/Static/Commodore/Target.hpp index 381e35207..b40d0a1f0 100644 --- a/Analyser/Static/Commodore/Target.hpp +++ b/Analyser/Static/Commodore/Target.hpp @@ -22,8 +22,8 @@ struct Target: public ::Analyser::Static::Target { ThirtyTwoKB }; - MemoryModel memory_model; - bool has_c1540; + MemoryModel memory_model = MemoryModel::Unexpanded; + bool has_c1540 = false; }; } diff --git a/Analyser/Static/Oric/Target.hpp b/Analyser/Static/Oric/Target.hpp index b3a507de2..f920d7e5a 100644 --- a/Analyser/Static/Oric/Target.hpp +++ b/Analyser/Static/Oric/Target.hpp @@ -14,8 +14,8 @@ namespace Static { namespace Oric { struct Target: public ::Analyser::Static::Target { - bool use_atmos_rom; - bool has_microdisc; + bool use_atmos_rom = false; + bool has_microdisc = false; }; } diff --git a/Analyser/Static/ZX8081/Target.hpp b/Analyser/Static/ZX8081/Target.hpp index 180282576..7fef01e08 100644 --- a/Analyser/Static/ZX8081/Target.hpp +++ b/Analyser/Static/ZX8081/Target.hpp @@ -22,8 +22,8 @@ struct Target: public ::Analyser::Static::Target { SixtyFourKB }; - MemoryModel memory_model; - bool isZX81; + MemoryModel memory_model = MemoryModel::Unexpanded; + bool isZX81 = false; }; } diff --git a/Components/6560/6560.hpp b/Components/6560/6560.hpp index 8cb672d8b..345f67e5f 100644 --- a/Components/6560/6560.hpp +++ b/Components/6560/6560.hpp @@ -68,6 +68,10 @@ template class MOS6560 { set_output_mode(OutputMode::NTSC); } + ~MOS6560() { + audio_queue_.flush(); + } + void set_clock_rate(double clock_rate) { speaker_.set_input_rate(static_cast(clock_rate / 4.0)); } diff --git a/Concurrency/AsyncTaskQueue.cpp b/Concurrency/AsyncTaskQueue.cpp index 8775c4309..070301007 100644 --- a/Concurrency/AsyncTaskQueue.cpp +++ b/Concurrency/AsyncTaskQueue.cpp @@ -45,6 +45,7 @@ AsyncTaskQueue::AsyncTaskQueue() AsyncTaskQueue::~AsyncTaskQueue() { #ifdef __APPLE__ + flush(); dispatch_release(serial_dispatch_queue_); serial_dispatch_queue_ = nullptr; #else @@ -82,6 +83,7 @@ void AsyncTaskQueue::flush() { DeferringAsyncTaskQueue::~DeferringAsyncTaskQueue() { perform(); + flush(); } void DeferringAsyncTaskQueue::defer(std::function function) { diff --git a/Machines/AmstradCPC/AmstradCPC.cpp b/Machines/AmstradCPC/AmstradCPC.cpp index cd4ca2bff..8a55b8675 100644 --- a/Machines/AmstradCPC/AmstradCPC.cpp +++ b/Machines/AmstradCPC/AmstradCPC.cpp @@ -126,6 +126,10 @@ class AYDeferrer { speaker_.set_input_rate(1000000); } + ~AYDeferrer() { + audio_queue_.flush(); + } + /// Adds @c half_cycles half cycles to the amount of time that has passed. inline void run_for(HalfCycles half_cycles) { cycles_since_update_ += half_cycles; diff --git a/Machines/Atari2600/Bus.hpp b/Machines/Atari2600/Bus.hpp index 79d9dfbd4..7d6fabdaf 100644 --- a/Machines/Atari2600/Bus.hpp +++ b/Machines/Atari2600/Bus.hpp @@ -26,6 +26,10 @@ class Bus { tia_sound_(audio_queue_), speaker_(tia_sound_) {} + virtual ~Bus() { + audio_queue_.flush(); + } + virtual void run_for(const Cycles cycles) = 0; virtual void apply_confidence(Analyser::Dynamic::ConfidenceCounter &confidence_counter) = 0; virtual void set_reset_line(bool state) = 0; diff --git a/Machines/ColecoVision/ColecoVision.cpp b/Machines/ColecoVision/ColecoVision.cpp index f238637a3..7acd6ca22 100644 --- a/Machines/ColecoVision/ColecoVision.cpp +++ b/Machines/ColecoVision/ColecoVision.cpp @@ -125,6 +125,10 @@ class ConcreteMachine: joysticks_.emplace_back(new Joystick); } + ~ConcreteMachine() { + audio_queue_.flush(); + } + std::vector> &get_joysticks() override { return joysticks_; } diff --git a/Machines/Electron/Electron.cpp b/Machines/Electron/Electron.cpp index f54dfe637..edfaaf200 100644 --- a/Machines/Electron/Electron.cpp +++ b/Machines/Electron/Electron.cpp @@ -61,6 +61,10 @@ class ConcreteMachine: speaker_.set_input_rate(2000000 / SoundGenerator::clock_rate_divider); } + ~ConcreteMachine() { + audio_queue_.flush(); + } + void set_rom(ROMSlot slot, const std::vector &data, bool is_writeable) override final { uint8_t *target = nullptr; switch(slot) { diff --git a/Machines/MSX/MSX.cpp b/Machines/MSX/MSX.cpp index cec831d93..aaaa32cc4 100644 --- a/Machines/MSX/MSX.cpp +++ b/Machines/MSX/MSX.cpp @@ -144,6 +144,10 @@ class ConcreteMachine: tape_player_.set_sleep_observer(this); } + ~ConcreteMachine() { + audio_queue_.flush(); + } + void setup_output(float aspect_ratio) override { vdp_.reset(new TI::TMS9918(TI::TMS9918::TMS9918A)); } diff --git a/Machines/Oric/Oric.cpp b/Machines/Oric/Oric.cpp index 30da85595..64e8e1246 100644 --- a/Machines/Oric/Oric.cpp +++ b/Machines/Oric/Oric.cpp @@ -215,6 +215,10 @@ class ConcreteMachine: Memory::Fuzz(ram_, sizeof(ram_)); } + ~ConcreteMachine() { + audio_queue_.flush(); + } + // Obtains the system ROMs. bool set_rom_fetcher(const std::function>>(const std::string &machine, const std::vector &names)> &roms_with_names) override { auto roms = roms_with_names( diff --git a/Machines/ZX8081/ZX8081.cpp b/Machines/ZX8081/ZX8081.cpp index af566af18..ec30e8ebc 100644 --- a/Machines/ZX8081/ZX8081.cpp +++ b/Machines/ZX8081/ZX8081.cpp @@ -76,6 +76,10 @@ template class ConcreteMachine: clear_all_keys(); } + ~ConcreteMachine() { + audio_queue_.flush(); + } + forceinline HalfCycles perform_machine_cycle(const CPU::Z80::PartialMachineCycle &cycle) { const HalfCycles previous_counter = horizontal_counter_; horizontal_counter_ += cycle.length; diff --git a/Processors/Z80/Implementation/Z80Storage.hpp b/Processors/Z80/Implementation/Z80Storage.hpp index 0ef7244dd..24387224f 100644 --- a/Processors/Z80/Implementation/Z80Storage.hpp +++ b/Processors/Z80/Implementation/Z80Storage.hpp @@ -134,9 +134,9 @@ class ProcessorStorage { uint8_t carry_result_; // the carry flag is set if bit 0 of carry_result_ is set uint8_t halt_mask_ = 0xff; - int flag_adjustment_history_ = 0; // a shifting record of whether each opcode set any flags; it turns out - // that knowledge of what the last opcode did is necessary to get bits 5 & 3 - // correct for SCF and CCF. + unsigned int flag_adjustment_history_ = 0; // a shifting record of whether each opcode set any flags; it turns out + // that knowledge of what the last opcode did is necessary to get bits 5 & 3 + // correct for SCF and CCF. HalfCycles number_of_cycles_; diff --git a/Storage/Disk/Encodings/MFM/SegmentParser.cpp b/Storage/Disk/Encodings/MFM/SegmentParser.cpp index 5943fbb0b..8fd0c3810 100644 --- a/Storage/Disk/Encodings/MFM/SegmentParser.cpp +++ b/Storage/Disk/Encodings/MFM/SegmentParser.cpp @@ -56,7 +56,7 @@ std::map Storage::Encodings::MFM:: case 2: new_sector->address.sector = shifter.get_byte(); ++position; break; case 3: new_sector->size = shifter.get_byte(); - size = static_cast(128 << new_sector->size); + size = static_cast(128 << (new_sector->size&7)); ++position; is_reading = false; shifter.set_should_obey_syncs(true);