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

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


Le 29/10/2020 à 03:03, Roger Burrows a écrit :

[...]

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.


Hi

good point, I did something to update MFP while in stop state, but DSP should also be updated as it's similar to MFP running in parallel of the CPU.

But doing it on a 100 cycles basis is not really fully accurate, so I did the attached patch where DSP_Run is called on each loop during the STOP state (at the interval where MFP is updated too).

Please check if it improves sound in your case (maybe it will require more CPU than your patch on every 100 cycles)

Patch is for current dev version, but it's easy to apply it to Hatari 2.2

Nicolas
diff --git a/src/cpu/newcpu.c b/src/cpu/newcpu.c
index 0afddfe1..b32188d2 100644
--- a/src/cpu/newcpu.c
+++ b/src/cpu/newcpu.c
@@ -4998,6 +4998,11 @@ static int do_specialties (int cycles)
 		if ( MFP_UpdateNeeded == true )
 			MFP_UpdateIRQ_All ( 0 );
 
+		/* Keep on running DSP if necessary, even if CPU is stopped */
+		/* During STOP state, the CPU runs for 2 or 4 cycles on each loop depending on settings */
+		if (bDspEnabled)
+			DSP_Run ( 2 * ( currprefs.cpu_cycle_exact ? 2 : 4 ) );
+
 		/* Check if there's an interrupt to process (could be a delayed MFP interrupt) */
 		if (regs.spcflags & SPCFLAG_MFP) {
 			MFP_DelayIRQ ();			/* Handle IRQ propagation */


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