From 06fd91f002a9854390c7d788bbec346a236c8c0b Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 16 Apr 2024 22:12:10 -0400 Subject: [PATCH] Fix period, table lookup. --- Machines/Acorn/Archimedes/Sound.hpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Machines/Acorn/Archimedes/Sound.hpp b/Machines/Acorn/Archimedes/Sound.hpp index 417ed278f..77a28845c 100644 --- a/Machines/Acorn/Archimedes/Sound.hpp +++ b/Machines/Acorn/Archimedes/Sound.hpp @@ -28,9 +28,16 @@ static constexpr std::array generate_levels() { // Bit 7 provides a sign. for(size_t c = 0; c < 256; c++) { - const bool is_negative = c & 128; - const auto point = static_cast(c & 0xf); - const auto chord = static_cast((c >> 4) & 7); + // This is the VIDC1 rule. +// const bool is_negative = c & 128; +// const auto point = static_cast(c & 0xf); +// const auto chord = static_cast((c >> 4) & 7); + + // VIDC2 rule, which seems to be effective. I've yet to spot the rule by which + // VIDC1/2 is detected. + const bool is_negative = c & 1; + const auto point = static_cast((c >> 1) & 0xf); + const auto chord = static_cast((c >> 5) & 7); const int start = (1 << chord) - 1; const int end = (chord == 7) ? 247 : ((start << 1) + 1); @@ -106,7 +113,7 @@ struct Sound: private SoundLevels { // Apply user-programmed clock divider. --divider_; if(!divider_) { - divider_ = reload_; + divider_ = reload_ + 2; // Grab a single byte from the FIFO. const uint8_t raw = ram_[static_cast(current_.start) + static_cast(byte_)];