Skip to content

Commit

Permalink
Refill the SB audio channel when DMA reaches terminal count (#233)
Browse files Browse the repository at this point in the history
When the incoming DMA channel signals it's reached terminal count,
the state of SB is DMA is that there is a balance of now transfered
samples waiting to be consumed, but that haven't been read yet
by the SB.

This commit asks the audio channel to get caught up to the
current time: that is, the same state when the DMA transfer
completed. This fill up step will read a balance of remaining
DMA samples, and queue them for playback.

In 'Worms', logging shows the pending tail of DMA data is anywhere
from 4 to 30 bytes. Filling up the channel to the current time
draws in enough DMA samples to (roughly) complete the transfer
on the SB side.
  • Loading branch information
kcgen committed Jun 8, 2023
1 parent 3f71a75 commit e813626
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/hardware/sblaster.cpp
Expand Up @@ -588,8 +588,12 @@ static void DSP_FlushData()
static double last_dma_callback = 0.0;

static void DSP_DMA_CallBack(DmaChannel * chan, DMAEvent event) {
if (chan!=sb.dma.chan || event==DMA_REACHED_TC) return;
else if (event==DMA_MASKED) {
assert(chan && chan == sb.dma.chan);

if (event == DMA_REACHED_TC) {
assert(sb.mode == MODE_DMA);
sb.chan->FillUp();
} else if (event == DMA_MASKED) {
if (sb.mode==MODE_DMA) {
//Catch up to current time, but don't generate an IRQ!
//Fixes problems with later sci games.
Expand Down

0 comments on commit e813626

Please sign in to comment.