| [hatari-devel] DSP bug found (and maybe solved) | 
[ Thread Index | 
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
] 
- To: hatari-devel@xxxxxxxxxxxxxxxxxxx
- Subject: [hatari-devel] DSP bug found (and maybe solved)
- From: Laurent Sallafranque <laurent.sallafranque@xxxxxxx>
- Date: Sun, 14 Apr 2024 23:48:31 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=free.fr;	s=smtp-20201208; t=1713131312;	bh=e0XaVqD8DI8qFW/I4c8eaRBboav/ZEzg6M/TQKTCpjw=;	h=Date:To:From:Subject:From;	b=FSAklzfooev60BhImMevShuQ8PG4EUW1p5sxk9p6NJ97S8ggEzCi+Ahh5I5rE1Yiq	 xDrYdmy3mgwb3vjznJjCCvfVyB1IHS/EiK+tJNmPiEb3UnAi0/bjKSELBQ0Y1Hevt0	 PRR2tt+Dt4s1c6M2msQFXSdQnXl6eDcxIOHfa0ZcOU7t1pNanoUFnoO56/mcyEXaVl	 XxqZZyIALF2gfUsG0e5W8BFxqH93GmxKGxDx3Dt/B95grlk43pkuberTlIyRwhX+fZ	 Ftyz/t2AhQcwJDvJJLijmS3xUQxQkJUsZ8lhGsU8LKCImQt1W3v7xJ9glwGqCi7J4B	 Ke6SIQSdZjV0g==
Hi all,
I've spent the last 2 weeks tracing Audio Fun Machine to find the bug 
when the equalizer is ON (sound becomes noisy).
I've isolated the bug : it's about Rn + Nn + Mn updating.
An example :
            move    #>0,r0                     ; R0 = 0
            movec    #$01,m0                ; modulo 2
            move    #$02,n0                   ; incrementor = 2
            move    #>1,a
            move    #>1,b
            move    a,x:(r0)+                 ; r0 = 1
            nop
            nop
            move    b,x:(r0)+                 ; r0 = 0  (because of the 
modulo)
            nop
            nop
            move    (r0)+n0                   ; R0 = 0 (should be 2)
            nop
            nop
            move    a,x:(r0)+                 ; R0 = 1 (should be 3)
I suggest the following fix in the function :
static void dsp_update_rn_modulo(uint32_t numreg, int16_t modifier)
Line 1694 :
replace
    if (abs_modifier>modulo) {
by
    if (abs_modifier>modulo-1) {
In line 1673, modulo is added +1 for buffer boundaries computing.
But I think modulo should be -1 when tested with modifier.
At least, Audio Fun Machine sound becomes good with this patch, but DSP 
programs should be tested for non regression.
I've tested 2 or 3 of them, but not all of them.
@eero, could you test my patch and tell me if AFM works well for you ?
Regards
Laurent