[hatari-devel] Suggested patch to fix problem handling STOP when DSP is active

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


As you probably know, I'm currently investigating differences in behaviour of 
some programs between EmuTOS and Atari TOS.  The programs in question use the 
DSP to process audio, and the audio output is worse on EmuTOS than Atari TOS.

Because of the actual symptoms, it occurred to me that perhaps the biggest 
difference in basic processing between TOS4 and EmuTOS is the latter's use of 
the STOP instruction to lighten processor load on emulators.  I built a copy of 
EmuTOS that doesn't use the STOP instruction (it's just a simple config option 
to disable it), but alas my poor underpowered Linux box could not cope with the 
additional load.

So I thought about the Hatari side of things and wondered how the DSP was run 
in parallel with the 680x0.  If I understand things correctly, it's the job of 
DSP_Run() to make sure that it gets the right number of cycles, on a regular 
basis.  However, when the 680x0 is stopped, Hatari runs through a while() loop 
in do_specialties(), waiting for a matching interrupt, and during this period, 
DSP_Run() is NOT called.

I added some debugging code and discovered that the STOP typically lasts around 
60000 680x0 cycles (@ 16MHz), long enough for up to 60000 DSP instructions.  
The way the code is written, the DSP will eventually get those cycles, but they 
will be delayed, and the DSP processing will not be overlapped with the STOP 
state (unlike under TOS4, when it *will* be overlapped with the busy-waiting).
Apart from affecting the DSP, this also affects the 680x0, since the host will 
not run 680x0 code until the DSP has 'caught up'.

So I made the attached small patch to Hatari 2.2.1, to call DSP_Run() on a 
regular basis within the 'STOP is active' loop.  With this patch, the sound 
quality from EmuTOS is now better than that from Atari TOS (identical 
configurations), although it's still not perfect - that underpowered Linux box 
again.

Please consider this patch (or something equivalent) for incorporation in 
Hatari.

Thanks,
Roger Burrows
Cross-posted to emutos-devel since it's relevant there too.
The following section of this message contains a file attachment
prepared for transmission using the Internet MIME message format.
If you are using Pegasus Mail, or any other MIME-compliant system,
you should be able to save it or view it from within your mailer.
If you cannot, please ask your system administrator for assistance.

   ---- File information -----------
     File:  hat_dsp.patch
     Date:  28 Oct 2020, 21:59
     Size:  519 bytes.
     Type:  Unknown

Attachment: hat_dsp.patch
Description: Binary data



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/