SPC File Format Text vs. Binary

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
SPC File Format Text vs. Binary
by on (#156085)
So I'm trying to understand this...there are at least 47 reserved/unused bytes in the current v.31 SPC file format. And we couldn't pick just *1* of those reserved bytes to specify whether or not the tag info is in text/binary format? Really??

So now you have to jump through all these hoops just to figure out which format it's in. Unless I'm missing something is no simple (one-liner/one-byte-check) way to determine with 100% certainty if the file is in binary/text format. For example, if I have the 3-byte value of 0x39,0x00,0x00 starting @ offset 0xA9, there is no simple way to know if that is supposed to mean 9 seconds (text) or 57 seconds (binary). :-/

Reference: http://www.romhacking.net/documents/221/
Re: SPC File Format Text vs. Binary
by on (#156086)
Wait...I think I might have it! What if you check if the byte @ offset 0xD2 is 0x00? If it is 0x00 then according to the format spec it _must_ be a binary format SPC. Because a text format SPC is required to have either 0x30, 0x31, or 0x32.

So as long as the SPC has a valid format header then that should work shouldn't it?

UPDATE: So yes, this method definitely works provided the SPC header information is valid. In running a script through the entire snesmusic.org archive I only found 6 SPCs which had invalid header format and they were all from the same game - Ms. Pac Man - Tracks 01,03-07. The problem with those tracks is that the value at offset 0xD2 should be 0x30 instead of 0x00. All other 34,000+ tracks in the archive have valid header information.