Detecting an NES rom based on file contents.

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Detecting an NES rom based on file contents.

Post by lidnariq »

The task simonwjackson is describing is exactly the function of the unix-realm file command and libmagic database.

I wrote a file(1) magic(5) for iNES, NES2.0, and UNIF in this thread.
Bisqwit
Posts: 249
Joined: Fri Oct 14, 2011 1:09 am

Re: Detecting an NES rom based on file contents.

Post by Bisqwit »

blargg wrote:Find a file with lots of occurrences of the pairs $15 $40 and $07 $20 :)

Code: Select all

bisqwit@chii:~/src/nescom/clever$ egrep '2007|4015' cv.lst      
-       $803E  8D 07 20:    sta $2007
        $C0F9  8D 15 40:    sta $4015
        $CBDB  8D 07 20:    sta $2007
-       $CBE9  8D 07 20:    sta $2007
+       $FDA2  8D 07 20:    sta $2007
        $FE98  8D 15 40:    sta $4015
        $FEAF  8D 15 40:    sta $4015
bisqwit@chii:~/src/nescom/clever$ egrep '2007|4015' cv2u.lst
        $967D  AD 15 40:    lda APU_HW__4015_EnableChannelsMask
        $A3CF  8D 15 40:    sta APU_HW__4015_EnableChannelsMask
        $A3E4  8D 15 40:    sta APU_HW__4015_EnableChannelsMask
        $C09F  8D 15 40:    sta APU_HW__4015_EnableChannelsMask
        $C6F7  8D 07 20:    sta $2007
-       $C714  8D 07 20:    sta $2007
-       $CBBD  8D 07 20:    sta $2007
-       $CBD9  8D 07 20:    sta $2007
        $CBF2  AD 07 20:    lda $2007
        $CBF5  AD 07 20:    lda $2007
        $CC15  8D 07 20:    sta $2007
That's not a significant number compared to their ROM sizes (Castlevania & Castlevania II).
VRAM games might have some more, and games that do a lot of custom timing.
Bigfoot for example has 360 matches, 347 of them being for $2007.
simonwjackson
Posts: 7
Joined: Tue Nov 12, 2013 7:05 am

Re: Detecting an NES rom based on file contents.

Post by simonwjackson »

lidnariq wrote:The task simonwjackson is describing is exactly the function of the unix-realm file command and libmagic database.

I wrote a file(1) magic(5) for iNES, NES2.0, and UNIF in this thread.
This should get me most of the way there for nes, thanks lidnariq!
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Detecting an NES rom based on file contents.

Post by tepples »

tepples wrote: Tue Nov 12, 2013 8:35 am The problem is similar to distinguishing a program written in Python 2 from a program written in Python 3. The "open" action under Windows looks only at the file name suffix
Today I read "Taxes redux: You can’t open the file until the user tells you to open it" by Raymond Chen and learned exactly why Windows relies so much on the file extension: the storage hierarchy may end at a remote server that accesses a library of tapes in a nearline jukebox. File Explorer needs a concept of "file type" even for something that has been archived to a tape drive or otherwise on a remote server. Reading magic numbers from each file in a folder to determine their type would force the file system to recall each file from the server if the files happen to be archived.
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Detecting an NES rom based on file contents.

Post by Pokun »

Makes sense, I guess file extensions are more important than I have thought.
Post Reply