From bcd4a2216a8b06d4767cb193c3d7f22b98ea1711 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 21 Nov 2023 22:36:11 -0500 Subject: [PATCH] Improve clocking. --- Machines/PCCompatible/PCCompatible.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Machines/PCCompatible/PCCompatible.cpp b/Machines/PCCompatible/PCCompatible.cpp index f419a7705..b5b271eca 100644 --- a/Machines/PCCompatible/PCCompatible.cpp +++ b/Machines/PCCompatible/PCCompatible.cpp @@ -54,7 +54,14 @@ struct PCSpeaker { } void set_level() { - toggle.set_output(pit_mask_ ? pit_input_ : level_); + // TODO: eliminate complete guess of mixing function here. + const bool new_output = (pit_mask_ & pit_input_) ^ level_; + + if(new_output != output_) { + update(); + toggle.set_output(new_output); + output_ = new_output; + } } Concurrency::AsyncTaskQueue queue; @@ -65,6 +72,7 @@ struct PCSpeaker { bool pit_input_ = false; bool pit_mask_ = false; bool level_ = false; + bool output_ = false; }; class PITObserver {