NES playroutine identifier

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
NES playroutine identifier
by on (#172724)
I have started work on a configuration file for sidid, but instead of identifying C64 players, it identifies NSF players. I have also created a small modification of the original program, so it looks for NSFs instead of SIDs.

The signature file is not complete, but I'd like your thoughts on this.
Re: NES playroutine identifier
by on (#172725)
I was actually thinking of integrating something similar into my NSF player. Consider me interested.
Re: NES playroutine identifier
by on (#172740)
HertzDevil had a similar idea.


It's not traditional to use .exe with UNIX executables. You can usually detect the difference between UNIX and Windows by the absence or presence of the COMSPEC environment variable.
Code:
# Use .exe only on Windows, which defines COMSPEC
ifdef COMSPEC
DOTEXE:=.exe
else
DOTEXE:=
endif
EXENAME:=nsfid$(DOTEXE)

.PHONY: all
all: $(EXENAME)

$(EXENAME): nsfid.c
   gcc $^ -Wall -O3 -s -o $@


This makefile incorporates COMSPEC as well as three other changes:
  • You can strip debugging symbols from the output while linking by using -s in the command line that produces the executable.
  • Use two automatic variables so that the makefile doesn't repeat itself: $^ means "name of all dependencies", and $@ means "name of the target".
  • Target names that do not refer to an actual file, such as all, clean, and the like, need to be declared .PHONY so that Make doesn't get confused if there's an actual file by that name.

Some error checking is missing. -Wall in GCC 4.8.5 includes -Wunused-result, and you're ignoring return values of several standard library functions declared with attribute warn_unused_result:
  • getcwd at lines 100, 175, 321
  • chdir at lines 174, 177, 333, 335
  • fscanf at line 199
  • fread at line 199, 390

Once I compiled the program and ran it from a terminal, the output was as follows:
Code:
.../nsfid$ ./nsfid
Using configfile
No signatures defined!

It's traditional, if a required argument is missing, to recommend on stderr that the user run programname --help.

Usage is somewhat confusing, as it works only on directories, not individual files.
Code:
.../nsfid$ NSFIDCFG=./nsfid.cfg ./nsfid ~/Music/old_nt2_nsfs
emerald_hill.nsf                                         NerdTracker_II
meatspin.nsf                                             NerdTracker_II
fuga7777.nsf                                             NerdTracker_II
Opentris.nsf                                             NerdTracker_II
bomblodev2.nsf                                           NerdTracker_II
dy-covers.nsf                                            NerdTracker_II
Butterfly.nsf                                            NerdTracker_II

Detected players:
NerdTracker_II           7

Statistics:
Identified               7
Unidentified             0
Total files examined     7
.../nsfid$ NSFIDCFG=./nsfid.cfg ./nsfid ~/Music/old_nt2_nsfs/dy-covers.nsf
Using configfile ./nsfid.cfg

Statistics:
Identified               0
Unidentified             0
Total files examined     0


I ran it against the development folder for my own music engine, whose source code can be browsed:
Code:
.../nsfid$ NSFIDCFG=./nsfid.cfg ./nsfid ~/develop/pently
Using configfile ./nsfid.cfg

Statistics:
Identified               0
Unidentified             1
Total files examined     1


Any tips on making signatures that are distinctive yet resilient to minor changes in new versions of the engine, beyond those listed on the sidid GitHub project?
Re: NES playroutine identifier
by on (#176684)
Updated signatures.
Re: NES playroutine identifier
by on (#192846)
Been a while since I posted anything related to this. Here's a new signature file, with a whole lot more added :)

And sorry, but no update to the program. I am not proficient at all in C++ :/
Re: NES playroutine identifier
by on (#193056)
This update only contains the config file, and the link with the actual program in the first post is dead.
Re: NES playroutine identifier
by on (#193057)
Here's the program
Re: NES playroutine identifier
by on (#197468)
Another update. I also added information to the unknown id's in the nsfid.nfo file, so if you have any info on these then please feel free to tell me.
Re: NES playroutine identifier
by on (#197513)
I decided to look at how you're detecting Pently in the new cfg:
Code:
Damian_Yerrick
DE ?? ?? 10 ?? BD ?? ?? 9D ?? ?? B5 ?? 85 ?? B5 ?? 85 ?? 18 69 END
(Pently)
BD ?? ?? 1D ?? ?? D0 ?? A5 ?? D0 ?? E0 08 F0 ?? A9 30 9D 00 40 END


You've correctly determined that pentlysound.s is on the whole less volatile than pentlymusic.s. I matched both snippets to parts of the pently_update_one_ch subroutine there:

  1. The first snippet is the "playback rate divider" and "fetch the instruction" parts of sound effect envelope processing.
  2. The second snippet is the code immediately preceding it, which mutes a channel if its sound effect has finished and its instrument is silent.

Incidentally, after reviewing this subroutine, I see room to optimize "fetch the instruction". I may act on it later.
Re: NES playroutine identifier
by on (#198873)
Another update.

I'd like to ask out of curiosity, is anyone actually using this tool for anything? If so, then what for? Don't worry too much about the answer, I'll continue work on this regardless :p
Re: NES playroutine identifier
by on (#202959)
Hey, Karmic, do you think you can post this up at like GitHub or something? (People could push updates to the database.) It would be nice if this was also incorporated into NSFPlay and VirtuaNSF too. :)
Re: NES playroutine identifier
by on (#203001)
B00daW wrote:
Hey, Karmic, do you think you can post this up at like GitHub or something? (People could push updates to the database.)

Seems like a good idea, but I have a hard time thinking that anyone would actually bother. Aside from HertzDevil maybe, but I think he has his own solution already.
Re: NES playroutine identifier
by on (#203430)
Time to update this thing again.

Note that "?FCP3_Unknown_1" is a player used on quite a few Famicompo Pico 3 entries, but due to the compo's anonymous nature I can't provide a proper name for now.
Re: NES playroutine identifier
by on (#206795)
Another small update with only a few fixes for existing IDs. Still 356 unidentified NSFs in Knurek's archive.
Re: NES playroutine identifier
by on (#206855)
I am definitely going to be messing with this program. I have skimmed through all the files and I'm about to fire it up soon.
Re: NES playroutine identifier
by on (#206857)
Karmic wrote:
Another small update with only a few fixes for existing IDs. Still 356 unidentified NSFs in Knurek's archive.

You should try identifying all the files in MrNorbert1994's NSF archive. :)
Re: NES playroutine identifier
by on (#207100)
Is it possible to update the program so that it displays the signature in a readable form on the console?

I am working on a game that was detected as Namco_1. It's programmed by Pony Canyon.

Namco_1
F0 ?? C9 05 90 ?? 38 E9 05 ?? A9 01 END
A0 04 BD ?? ?? 90 03 9D 00 40 E8 88 D0 END
A0 04 90 06 BD ?? ?? 9D 00 40 E8 88 D0 END
A9 01 99 ?? ?? A0 00 98 91 ?? C8 C0 END
(Micronics)
85 ?? 98 29 07 A8 B9 ?? ?? A0 00 11 ?? 91 END

I converted two lines to show you what I mean, generally.

BEQ ?? CMP #$05 BCC ?? SEC SBC #$05 ?? LDA #$01 END

LDY #$04 LDA $????,x BCC 03 STA $4000,x INX DEY BNE END
Re: NES playroutine identifier
by on (#207101)
One thing I forgot to mention about the tool: the -m switch should be used to nake it possible to see the sub-IDs (in brackets).

@Gil: Unfortunately not. I still don't really know C.
Re: NES playroutine identifier
by on (#210979)
Another update.
Re: NES playroutine identifier
by on (#213814)
A few bug reports (is there a more formal issue tracker?):

  1. Thank you for including my makefile. But the part before gcc needs to be an actual tab character, not spaces. (phpBB corrupted this.)
  2. -c nsfid.cfg doesn't work; it has to be -cnsfid.cfg. It's traditional for programs to accept both.
  3. On non-Win32, the result of GetModuleFileName() is stored in argv[0], so you can mostly just strncpy that into place, then deal with the presence or absence of an executable extension.
  4. ishex() already exists in <ctype.h> under the name isxdigit().

Are you looking for someone else to take over as maintainer?
Re: NES playroutine identifier
by on (#221451)
New ID for Indies_Soft, now identifies Bishoujo SF Alien Battle
Re: NES playroutine identifier
by on (#230988)
Hey Karmic.
Needs to be updated because some Famicompo entities uses both FT and 0cc entities
Yeah. Still "Famitracker" here.
I need to be added
"0CC-FT 0.3.1X.X"
"j0CC-FT 0.X.X"
Re: NES playroutine identifier
by on (#230990)
TheJuanCarlos64 wrote:
Hey Karmic.
Needs to be updated because some Famicompo entities uses both FT and 0cc entities
Yeah. Still "Famitracker" here.
I need to be added
"0CC-FT 0.3.1X.X"
"j0CC-FT 0.X.X"

Try using the /m command line option, where I've added a sub-id for (0CC-FamiTracker). j0CC as far as I know has an identical NSF driver so it can't be identified.
Re: NES playroutine identifier
by on (#242417)
Renamed Nice_Code_1 to TXC as I've found it first used in "Qi Wang - Chinese Chess", and updated Hirokazu_Tanaka to identify Stroke & Match Golf.

Remember to use the -m switch, always.