Voice processing steps V5-V7 in apudsp.txt

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Voice processing steps V5-V7 in apudsp.txt
by on (#124822)
apudsp.txt wrote:
V5. Load and apply VxVOLR.
The new ENDX value is prepared, and can be overwritten. Reads will not
see it yet.
V6. The new VxOUTX value is prepared, and can be overwritten. Reads will not
see it yet.
V7. The new ENDX value may now be read.
The new VxENVX value is prepared, and can be overwritten. Reads will not
see it yet.

What is meant by "and can be overwritten"? Overwritten by who? Another process in the DSP? The SMP via the register interface?

Steps 5-7 seem to be the only place where these values are updated according to apudsp.txt. So what else could cause them to be overwritten before they are stored in their final locations (i.e. in the DSP user registers) in steps 7-9?
Re: Voice processing steps V5-V7 in apudsp.txt
by on (#124823)
Code:
VOICE_CLOCK( V7 )
{
    // Won't be seen until V9...
    envx_buf = envelope >> 4;
}

void smp_write_envx( int data )
{
    // ...but writes before then will effectively nullify the write in V9
    envx     = data;
    envx_buf = data;
}

int smp_read_envx()
{
   return envx;
}

VOICE_CLOCK( V9 )
{
    envx = envx_buf;
}
Re: Voice processing steps V5-V7 in apudsp.txt
by on (#124828)
Aha! So the SMP writing to the DSP register _also_ updates the internal buffer version of that register. That's the key piece of info I was missing.

As usual, thanks a bunch blargg. :)
Re: Voice processing steps V5-V7 in apudsp.txt
by on (#124843)
jwdonal wrote:
Aha! So the SMP writing to the DSP register _also_ updates the internal buffer version of that register. That's the key piece of info I was missing.

No, the internal buffer value would be the 11bit "envelope" value.
The value that can be read is 7bit "envx".

And 7bit "envx_buf" is meant to be some "temporary" storage needed to reproduce some weird timing effect. It's quite strange, I am not sure if the hardware is really working like that, might be so, but it's hard to believe.
Re: Voice processing steps V5-V7 in apudsp.txt
by on (#124847)
I doubt the hardware does what the code above does, just that the code above reproduces the SMP-visible behavior and passes tests that exercise this oddity. The basic idea is that if you write just before the DSP is going to update the register, the DSP doesn't do the write.