From fdf2b9cd7b44907181fddc1e0252adce8cd91cb9 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 4 Dec 2021 17:58:41 -0500 Subject: [PATCH] Add local data pointers. --- Machines/Amiga/Audio.cpp | 16 +++++++++++----- Machines/Amiga/Audio.hpp | 6 ++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Machines/Amiga/Audio.cpp b/Machines/Amiga/Audio.cpp index bad03caf1..3c2520911 100644 --- a/Machines/Amiga/Audio.cpp +++ b/Machines/Amiga/Audio.cpp @@ -27,6 +27,7 @@ Audio::Audio(Chipset &chipset, uint16_t *ram, size_t word_size, float output_rat } speaker_.set_input_rate(output_rate); + speaker_.set_high_frequency_cutoff(7000.0f); } // MARK: - Exposed setters. @@ -76,9 +77,12 @@ bool Audio::advance_dma(int channel) { return false; } - set_data(channel, ram_[pointer_[size_t(channel) & ram_mask_]]); - if(channels_[channel].state != Channel::State::WaitingForDummyDMA) { - ++pointer_[size_t(channel)]; + set_data(channel, ram_[channels_[channel].data_address & ram_mask_]); + ++channels_[channel].data_address; + + if(channels_[channel].should_reload_address) { + channels_[channel].data_address = pointer_[size_t(channel)]; + channels_[channel].should_reload_address = false; } return true; @@ -342,9 +346,10 @@ template <> bool Audio::Channel::transit< Audio::Channel::State::PlayingHigh>() { begin_state(); - data_latch = data; // i.e. pbufld1 + data_latch = data; // i.e. pbufld1 wants_data = true; - period_counter = period; // i.e. percntrld + period_counter = period; // i.e. percntrld + should_reload_address = true; // i.e. dmasen // TODO: volcntrld (see above). // Request an interrupt. @@ -447,6 +452,7 @@ template <> bool Audio::Channel::transit< if(!length_counter) { length_counter = length; will_request_interrupt = true; + should_reload_address = true; // ??? } } diff --git a/Machines/Amiga/Audio.hpp b/Machines/Amiga/Audio.hpp index 3683e057d..685ef48c0 100644 --- a/Machines/Amiga/Audio.hpp +++ b/Machines/Amiga/Audio.hpp @@ -70,6 +70,12 @@ class Audio: public DMADevice<4> { bool wants_data = false; uint16_t data_latch = 0x0000; + // The DMA address; unlike most of the Amiga Chipset, + // the user posts a value to feed a pointer, rather + // than having access to the pointer itself. + bool should_reload_address = false; + uint32_t data_address = 0x0000'0000; + // Number of words remaining in DMA data. uint16_t length = 0; uint16_t length_counter = 0;