Processing steps V1 and V2 in apudsp.txt

Discussion of hardware and software development for Super NES and Super Famicom.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
Post Reply
User avatar
jwdonal
Posts: 719
Joined: Sat Jun 27, 2009 11:05 pm
Location: New Mexico, USA
Contact:

Processing steps V1 and V2 in apudsp.txt

Post by jwdonal » Sun Jan 26, 2014 8:00 pm

In apudsp.txt it states the following:

Code: Select all

 V1. Load the current value of the VxSRCN register, 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: Select all

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>...

}
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.

User avatar
blargg
Posts: 3715
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Re: Processing steps V1 and V2 in apudsp.txt

Post by blargg » Sun Jan 26, 2014 8:41 pm

Anomie's doc is likely incorrect then. He probably just failed to clarify this in the comment about using the previously loaded value. At some point I'll be posting all my DSP tests, some of which test this aspect.

EDIT: I just tried switching the order of those two lines (putting m.t_srcn = VREG(v->regs,srcn); first) and the DSP fails many of the tests.

User avatar
jwdonal
Posts: 719
Joined: Sat Jun 27, 2009 11:05 pm
Location: New Mexico, USA
Contact:

Re: Processing steps V1 and V2 in apudsp.txt

Post by jwdonal » Sun Feb 02, 2014 2:49 am

Forgot to reply and say thanks. This was very helpful. I've updated my personal copy of apudsp.txt to reflect this...along with the bazillion other notes I've added. :-P

User avatar
jwdonal
Posts: 719
Joined: Sat Jun 27, 2009 11:05 pm
Location: New Mexico, USA
Contact:

Re: Processing steps V1 and V2 in apudsp.txt

Post by jwdonal » Wed Feb 04, 2015 12:55 am

This is a big bump (almost exactly a year to the day actually), but I think it's worth it for anyone else who might need help understanding Anomie's apudsp.txt.

There is a response by Blargg in the thread below that directly relates to this question and explains things really well.

viewtopic.php?f=12&t=12331&p=140559

Post Reply