1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-10-02 04:55:56 +00:00

Add local data pointers.

This commit is contained in:
Thomas Harte 2021-12-04 17:58:41 -05:00
parent bfc70a1b60
commit fdf2b9cd7b
2 changed files with 17 additions and 5 deletions

View File

@ -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_input_rate(output_rate);
speaker_.set_high_frequency_cutoff(7000.0f);
} }
// MARK: - Exposed setters. // MARK: - Exposed setters.
@ -76,9 +77,12 @@ bool Audio::advance_dma(int channel) {
return false; return false;
} }
set_data(channel, ram_[pointer_[size_t(channel) & ram_mask_]]); set_data(channel, ram_[channels_[channel].data_address & ram_mask_]);
if(channels_[channel].state != Channel::State::WaitingForDummyDMA) { ++channels_[channel].data_address;
++pointer_[size_t(channel)];
if(channels_[channel].should_reload_address) {
channels_[channel].data_address = pointer_[size_t(channel)];
channels_[channel].should_reload_address = false;
} }
return true; return true;
@ -342,9 +346,10 @@ template <> bool Audio::Channel::transit<
Audio::Channel::State::PlayingHigh>() { Audio::Channel::State::PlayingHigh>() {
begin_state<State::PlayingHigh>(); begin_state<State::PlayingHigh>();
data_latch = data; // i.e. pbufld1 data_latch = data; // i.e. pbufld1
wants_data = true; 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). // TODO: volcntrld (see above).
// Request an interrupt. // Request an interrupt.
@ -447,6 +452,7 @@ template <> bool Audio::Channel::transit<
if(!length_counter) { if(!length_counter) {
length_counter = length; length_counter = length;
will_request_interrupt = true; will_request_interrupt = true;
should_reload_address = true; // ???
} }
} }

View File

@ -70,6 +70,12 @@ class Audio: public DMADevice<4> {
bool wants_data = false; bool wants_data = false;
uint16_t data_latch = 0x0000; 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. // Number of words remaining in DMA data.
uint16_t length = 0; uint16_t length = 0;
uint16_t length_counter = 0; uint16_t length_counter = 0;