mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-22 11:29:20 +00:00
Switch to slightly more straightforward presumption of no data wanted.
This commit is contained in:
parent
9554869886
commit
d6f1ea50a6
@ -29,7 +29,7 @@ Audio::Audio(Chipset &chipset, uint16_t *ram, size_t word_size, float output_rat
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Audio::advance_dma(int channel) {
|
bool Audio::advance_dma(int channel) {
|
||||||
if(channels_[channel].has_data) {
|
if(!channels_[channel].wants_data) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ void Audio::set_volume(int channel, uint16_t volume) {
|
|||||||
|
|
||||||
void Audio::set_data(int channel, uint16_t data) {
|
void Audio::set_data(int channel, uint16_t data) {
|
||||||
assert(channel >= 0 && channel < 4);
|
assert(channel >= 0 && channel < 4);
|
||||||
channels_[channel].has_data = true;
|
channels_[channel].wants_data = false;
|
||||||
channels_[channel].data = data;
|
channels_[channel].data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,7 +325,7 @@ template <> bool Audio::Channel::transit<
|
|||||||
state = State::PlayingHigh;
|
state = State::PlayingHigh;
|
||||||
|
|
||||||
data_latch = data; // i.e. pbufld1
|
data_latch = data; // i.e. pbufld1
|
||||||
has_data = false;
|
wants_data = true;
|
||||||
period_counter = period; // i.e. percntrld
|
period_counter = period; // i.e. percntrld
|
||||||
// TODO: volcntrld (see above).
|
// TODO: volcntrld (see above).
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ template <> bool Audio::Channel::transit<
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <> bool Audio::Channel::output<Audio::Channel::State::Disabled>() {
|
template <> bool Audio::Channel::output<Audio::Channel::State::Disabled>() {
|
||||||
if(has_data && !dma_enabled && !interrupt_pending) {
|
if(!wants_data && !dma_enabled && !interrupt_pending) {
|
||||||
return transit<State::Disabled, State::PlayingHigh>();
|
return transit<State::Disabled, State::PlayingHigh>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,7 +355,7 @@ template <> bool Audio::Channel::transit<
|
|||||||
Audio::Channel::State::WaitingForDMA>() {
|
Audio::Channel::State::WaitingForDMA>() {
|
||||||
state = State::WaitingForDMA;
|
state = State::WaitingForDMA;
|
||||||
|
|
||||||
has_data = false;
|
wants_data = true;
|
||||||
if(length == 1) {
|
if(length == 1) {
|
||||||
length_counter = length;
|
length_counter = length;
|
||||||
return true;
|
return true;
|
||||||
@ -369,7 +369,7 @@ template <> bool Audio::Channel::output<Audio::Channel::State::WaitingForDummyDM
|
|||||||
return transit<State::WaitingForDummyDMA, State::Disabled>();
|
return transit<State::WaitingForDummyDMA, State::Disabled>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dma_enabled && has_data) {
|
if(dma_enabled && !wants_data) {
|
||||||
return transit<State::WaitingForDummyDMA, State::WaitingForDMA>();
|
return transit<State::WaitingForDummyDMA, State::WaitingForDMA>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,7 +386,7 @@ template <> bool Audio::Channel::transit<
|
|||||||
state = State::PlayingHigh;
|
state = State::PlayingHigh;
|
||||||
|
|
||||||
data_latch = data;
|
data_latch = data;
|
||||||
has_data = false;
|
wants_data = true;
|
||||||
period_counter = period; // i.e. percntrld
|
period_counter = period; // i.e. percntrld
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -397,7 +397,7 @@ template <> bool Audio::Channel::output<Audio::Channel::State::WaitingForDMA>()
|
|||||||
return transit<State::WaitingForDummyDMA, State::Disabled>();
|
return transit<State::WaitingForDummyDMA, State::Disabled>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dma_enabled && has_data) {
|
if(dma_enabled && !wants_data) {
|
||||||
return transit<State::WaitingForDummyDMA, State::PlayingHigh>();
|
return transit<State::WaitingForDummyDMA, State::PlayingHigh>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,7 +424,7 @@ template <> bool Audio::Channel::transit<
|
|||||||
// if lenfin and AUDxON and AUDxDAT, then lencntrld
|
// if lenfin and AUDxON and AUDxDAT, then lencntrld
|
||||||
// if (not lenfin) and AUDxON and AUDxDAT, then lencount
|
// if (not lenfin) and AUDxON and AUDxDAT, then lencount
|
||||||
// if lenfin and AUDxON and AUDxDAT, then intreq2
|
// if lenfin and AUDxON and AUDxDAT, then intreq2
|
||||||
if(dma_enabled && has_data) {
|
if(dma_enabled && !wants_data) {
|
||||||
--length_counter;
|
--length_counter;
|
||||||
if(!length_counter) {
|
if(!length_counter) {
|
||||||
length_counter = length;
|
length_counter = length;
|
||||||
@ -465,7 +465,7 @@ template <> bool Audio::Channel::transit<
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
data_latch = data; // i.e. pbufld2
|
data_latch = data; // i.e. pbufld2
|
||||||
has_data = false; // AUDxDR
|
wants_data = true; // AUDxDR
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dma_enabled && will_request_interrupt) {
|
if(dma_enabled && will_request_interrupt) {
|
||||||
|
@ -67,7 +67,7 @@ class Audio: public DMADevice<4> {
|
|||||||
// The data latch plus a count of unused samples
|
// The data latch plus a count of unused samples
|
||||||
// in the latch, which will always be 0, 1 or 2.
|
// in the latch, which will always be 0, 1 or 2.
|
||||||
uint16_t data = 0x0000;
|
uint16_t data = 0x0000;
|
||||||
bool has_data = false;
|
bool wants_data = false;
|
||||||
uint16_t data_latch = 0x0000;
|
uint16_t data_latch = 0x0000;
|
||||||
|
|
||||||
// Number of words remaining in DMA data.
|
// Number of words remaining in DMA data.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user