picogus
picogus copied to clipboard
SB: Fix Tyrian and Dig-It! by implementing DSP_DAC_PAUSE_DURATION
This change fixes Sound Blaster mode support for Tyrian and "Dig-It!"
I disassembled Tyran's sound setup program - as part of autodetection for SB, after the DMA port is specified, they:
- Set up interrupt handlers for IRQs 2, 5, and 7.
- Start communicating with SB (initially on 210h)
- Send the DSP a DSP_DAC_PAUSE_DURATION (80h) command. It is expected that while this timeout is pending, no audio will be output by the DAC and once the timeout happens, the SB interrupt will be signaled. NB: It is not a DMA pause, but a DAC pause.
- Loop checking DSP_WRITE_STATUS to check that the DSP has executed the command.
- Check a global set by their interrupt handlers.
- If it's zero, increment SB port by 10h, goto 2 if < 280h and try again.
The interrupt signaling wasn't implemented, so it looped through this and failed to get the interrupt resulting in "error 253".
I was able to fix Tyrian/Tyrian2k by implementing this. I then tested Dig-It! - both FM and SB sound work with this change applied. I haven't disassembled Dig-It! but noticed it was also using this DSP command during early debugging.