bochs-emu / Bochs

Bochs - Cross Platform x86 Emulator Project
https://bochs.sourceforge.io/
GNU Lesser General Public License v2.1
858 stars 100 forks source link

No sound playback in Impulse Tracker with Sound Blaster 16 #248

Open Vort opened 8 months ago

Vort commented 8 months ago

After loading test music file (elysium.mod) into Impulse Tracker and starting playback, nothing happens.

To reproduce this problem, load test configuration attached below and press Enter, Enter, F5.

https://github.com/bochs-emu/Bochs/assets/1242858/534249ae-9acd-438e-94a9-e801501b7536

This is how program should work (video should be played with sound turned on):

https://github.com/bochs-emu/Bochs/assets/1242858/093cf33e-eb43-4ea7-b5b5-dd0300cfc633

Impulse Tracker is open source software. Its code can be useful for debugging: https://github.com/herrnst/impulsetracker

Test files: impulse.zip. Version: b373890b05b696fe9c7eda2817c276c74b08dcee.

Vort commented 7 months ago

Impulse Tracker is able to produce sound with it /S4 (Sound Blaster Pro) driver. So problem with Sound Blaster 16 is related to differences between Pro and 16.

Vort commented 7 months ago

Here are the differences: /S4 (Sound Blaster Pro) driver makes DSP Reset only once, when program is started. /S5 (Sound Blaster 16) driver makes DSP Reset several times.

Important thing is that ITSB16 driver makes such reset during active DMA transfer:

00608654538 (4) DMA transfer done, triggering IRQ
00608654538 (4) auto-DMA reinitializing to length 2047
00608654741 (4) read from mixer register 82 returns 42
00608654827 (4) 16-bit DMA IRQ acknowledged
00608767178 (5) Received 8-bit DMA: 0x00, 2047 remaining 
00608806995 (4) DSP Reset port write value 1
00608807082 (3) Read access to 0x0226: unsupported port!
00608807163 (3) Read access to 0x0226: unsupported port!
00608807244 (3) Read access to 0x0226: unsupported port!
00608807325 (3) Read access to 0x0226: unsupported port!
00608807406 (4) DSP Reset port write value 0
00608807406 (4) DSP resetting...
00608807406 (4) DSP reset: DMA aborted
00608807406 (4) DMA transfer done, triggering IRQ
00608807610 (4) read from mixer register 82 returns 42
00608807696 (3) 16-bit DMA IRQ acknowledged but not active!

And looks like Bochs reacts to such situation incorrectly. 16-bit DMA IRQ acknowledged but not active! message is sign of a problem.

I think something is wrong in this place: https://github.com/bochs-emu/Bochs/blob/ad8c21437f2752a330e2a7eac50ed544b2045e42/bochs/iodev/sound/sb16.cc#L671-L680

bx_sb16_c::dsp_dmadone sets DSP.irqpending = 1; and then bx_sb16_c::dsp_reset just sets it back to 0.

If I remove DSP.irqpending = 0; line from dsp_reset, Impulse Tracker with Sound Blaster 16 starts to produce sound. But, most likely, something smarter should be done with it instead.