Page 1 of 1

Old broken N163 NSFs

Posted: Tue Jul 28, 2015 4:46 pm
by rainwarrior
There was a mistake in ppMCK prior to 2007 with the N163, and NSFs from before then have a problem playing back in NSFPlay (and also NezPlug++, and real hardware AFAIK). The problem stems from poor knowledge of the sample length register, which uses 6 bits for length and not just 3. These used to play in earlier versions of emulators which had incorrectly implemented N163.

Here's a quick fix, if you run into these:

1. You'll need a hex editor. Search the NSF for a string of the following form:

Code: Select all

09 80 9D ?? 06 8D 00 48

There should only be one string that fits this form, and it's probably at an offset in the range $0D00-$1300 somewhere. If there's more than one, something else may be going on. (The symbol ?? could be anything, so search for just "09 80 9D" or "06 8D 00 48" and look for the other half next to it.)

2. Replace the 80 in that string with E0:

Code: Select all

09 E0 9D ?? 06 8D 00 48

3. Save it, and you should be good.

For the curious, that string means:

Code: Select all

09 80    = ORA $80
9D ?? 06 = STA $06??, X  ;  (RAM variable)
8D 00 48 = STA $4800     ;  (N163 register)

Changing $80 to $E0 sets all three of the top bits, which unless they are all set will contribute to the length of the sample (making it too long). Old ppMCK versions assumed a maximum sample length of 32, and thought that the high bit was simply an enable bit (it is not, it subtracts 128 from the maximum sample length of 256, the other two bits we are setting subtract 64 and 32).

Re: Old broken N163 NSFs

Posted: Tue Jul 28, 2015 4:49 pm
by rainwarrior
A long time ago when this was first coming to light and I posted this method for fixing old N163 NSFs, jrlepage went through a collection of Robokabuto's old NSFs and fixed them. The collection is attached.

Re: Old broken N163 NSFs

Posted: Tue Jul 28, 2015 4:52 pm
by rainwarrior
Here is a tune by Rophon called Summer Vacation, fixed by the method described above.