NSF bankswitching question

Discuss NSF files, FamiTracker, MML tools, or anything else related to NES music.

Moderator: Moderators

Post Reply
Grapeshot
Posts: 85
Joined: Thu Apr 14, 2011 9:27 pm
Contact:

NSF bankswitching question

Post by Grapeshot »

If a NSF does not use bank switching, should I still allow access to the bank switching registers? The reason why I ask is because Strobe-Ziberia.nsf has all zeroes in the header from 0x70-0x7F but is obviously much larger than 32k. It expects to be loaded with the identity mappings and then tries to bank switch as the tune goes on. It doesn't work in Nestopia but does in Nintendulator, so should I cater to this NSF like Nintendulator does?
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: NSF bankswitching question

Post by rainwarrior »

An NSF that puts all zeroes in the bankswitch area but still writes to the bankswitch registers is malformed, and should be fixed. (Really easy fix, just put 00 01 02 03 04 05 06 07 in its bank setup data).

All zeroes is supposed to denote no use of the bankswitch registers, i.e. it should indicate that this NSF is safe to play on an implementation that cannot bankswitch.

It's up to you as an implementer whether you want to just always enable bankswitch registers, or only if the bank setup is nonzero. Anything that breaks because of either decision is a malformed NSF. In NSFPlay I take the stricter approach of disabling bankswitching (though I plan to add an option in the future to take the other approach in case somebody needs it).
Grapeshot
Posts: 85
Joined: Thu Apr 14, 2011 9:27 pm
Contact:

Re: NSF bankswitching question

Post by Grapeshot »

I did go ahead and hex-edit my personal copies of those broken superNSF tracks but I know no one else will bother.

There sure are an unfortunate amount of malformed NSFs out there, everything from Shift-JIS in the title field to not respecting the write delays required by the real expansion sound chip to bankswitching the same RAM in two places and expecting writes not to be mirrored. I guess that's what happens when the authors are only testing on a few players or using automated tools.
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: NSF bankswitching question

Post by rainwarrior »

SHIFT-JIS is pretty common in Japanese NSFs. I think that's just the result of underspecification; the spec never said anything about character encoding. I might consider it valid. At least it doesn't affect playback.

Currently NSFPlay uses SHIFT-JIS encoding if it's run in a Japanese region, and just ascii if it's run anywhere else. In the future I'd like to make it an option, though (changing the Windows region for testing is a bit of an ordeal), or maybe attempt to detect SHIFT-JIS in the text and automatically switch.
User avatar
B00daW
Posts: 586
Joined: Thu Jan 03, 2008 1:48 pm

Re: NSF bankswitching question

Post by B00daW »

Most of those were already fixed and resubmitted. SuperNSF didn't have a problem with bankswitching since the production headers already accounted for them; at least with the pack I received from madbrain/mukunda.

Strobe had his own hacked version of FamiTracker for a while where he made an output plugin that generated an FTM that played nicely with large samples. Before releasing the NSF Strobe just forgot about the bankswitching information in the header. No problems anymore since FamiTracker does bankswitching by itself now.
Post Reply