sb16: fix interrupt acknowledgement
PATCH 1/1 sb16: fix interrupt acknowledgement
SoundBlaster 16 emulation is very broken and consumes a lot of CPU, but a small fix was suggested offlist and it is enough to fix some games. I got Epic Pinball to work with the "SoundBlaster Clone" option.
The processing of the interrupt register is wrong due to two missing "not"s. This causes the interrupt flag to remain set even after the Acknowledge ports have been read (0x0e and 0x0f).
The line was introduced by commit 85571bc (audio merge (malc), 2004-11-07), but the code might have been broken before because I did not look closely at the huge patches from 10 years ago.
--- hw/audio/sb16.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/audio/sb16.c +2 -2
@@ -999,7 +999,7 @@ static IO_READ_PROTO (dsp_read) retval = (!s->out_data_len || s->highspeed) ?0 :0x80 ;if (s->mixer_regs[0x82 ] &1 ) { ack =1 ; - s->mixer_regs[0x82 ] &=1 ; + s->mixer_regs[0x82 ] &= ~1 ;qemu_irq_lower (s->pic); }break ;
@@ -1008,7 +1008,7 @@ static IO_READ_PROTO (dsp_read) retval =0xff ;if (s->mixer_regs[0x82 ] &2 ) { ack =1 ; - s->mixer_regs[0x82 ] &=2 ; + s->mixer_regs[0x82 ] &= ~2 ;qemu_irq_lower (s->pic); }break ;
Signature · 1 line
2.1.0
hw/audio/sb16.c static IO_READ_PROTO (dsp_read) · line 1002
Quoted 8 lines · Paolo Bonzini
hw/audio/sb16.c +1
-1@@ -999,7 +999,7 @@ static IO_READ_PROTO (dsp_read) retval = (!s->out_data_len || s->highspeed) ?0 :0x80 ;if (s->mixer_regs[0x82 ] &1 ) { ack =1 ; - s->mixer_regs[0x82 ] &=1 ; + s->mixer_regs[0x82 ] &= ~1 ;
Shouldn't it be ~1u instead?
/mjt
Quoted 9 lines · Michael Tokarev
Quoted 8 lines
hw/audio/sb16.c static IO_READ_PROTO (dsp_read) · line 1002
Quoted 8 lines
hw/audio/sb16.c +1
-1@@ -999,7 +999,7 @@ static IO_READ_PROTO (dsp_read) retval = (!s->out_data_len || s->highspeed) ?0 :0x80 ;if (s->mixer_regs[0x82 ] &1 ) { ack =1 ; - s->mixer_regs[0x82 ] &=1 ; + s->mixer_regs[0x82 ] &= ~1 ;Shouldn't it be ~1u instead?
It's the same since mixer_regs is an array of uint8_t.
I'm not a fan of unsigned suffixes, especially after ~ where most of the time they're wrong. For example if x is uint64_t:
x &= ~1 is right x &= ~1ull is right x &= ~1u also clears bits 32...64 x &= ~1ul also clears bits 32...64 on 32-bit machines
Paolo
Quoted 11 lines · Paolo Bonzini
SoundBlaster 16 emulation is very broken and consumes a lot of CPU, but a small fix was suggested offlist and it is enough to fix some games. I got Epic Pinball to work with the "SoundBlaster Clone" option.
The processing of the interrupt register is wrong due to two missing "not"s. This causes the interrupt flag to remain set even after the Acknowledge ports have been read (
0x0eand0x0f).The line was introduced by commit 85571bc (audio merge (malc), 2004-11-07), but the code might have been broken before because I did not look closely at the huge patches from 10 years ago.
Looks sane, picked up.
thanks,
Gerd