In apudsp.txt it states the following:
And in Blargg's snes_spc SPC_DSP.cpp we have:
I don't understand why Blargg's code calculates the value of t_dir_addr with the pre-updated value of t_srcn. The apudsp.txt doc says "using previously loaded DIR and VxSRCN". I'm not sure about DIR, but the previously loaded value of VxSRCN was the value loaded in voice processing step V1. But that is not the value used in the code.
Code:
V1. Load the current value of the VxSRCN register, if necessary.
V2. Load the sample pointer (using previously loaded DIR and VxSRCN) if
necessary.
V2. Load the sample pointer (using previously loaded DIR and VxSRCN) if
necessary.
And in Blargg's snes_spc SPC_DSP.cpp we have:
Code:
inline VOICE_CLOCK( V1 )
{
m.t_dir_addr = m.t_dir * 0x100 + m.t_srcn * 4;
m.t_srcn = VREG(v->regs,srcn);
}
inline VOICE_CLOCK( V2 )
{
// Read sample pointer (ignored if not needed)
uint8_t const* entry = &m.ram [m.t_dir_addr];
...<snip>...
}
{
m.t_dir_addr = m.t_dir * 0x100 + m.t_srcn * 4;
m.t_srcn = VREG(v->regs,srcn);
}
inline VOICE_CLOCK( V2 )
{
// Read sample pointer (ignored if not needed)
uint8_t const* entry = &m.ram [m.t_dir_addr];
...<snip>...
}
I don't understand why Blargg's code calculates the value of t_dir_addr with the pre-updated value of t_srcn. The apudsp.txt doc says "using previously loaded DIR and VxSRCN". I'm not sure about DIR, but the previously loaded value of VxSRCN was the value loaded in voice processing step V1. But that is not the value used in the code.