It is currently Thu Nov 23, 2017 5:54 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Sat Aug 11, 2012 2:06 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6448
Location: UK (temporarily)
If you use unix, you might use the file(1) command. You might, like me, want to be able to look at an rom image cursorally without having to manually decode the first 16 bytes of the .NES file. If so, you might like this. For NES2 roms, it produces output that looks like TetrisMMC3.nes: iNES2 ROM, Mapper 0x004, submapper 0, 0x002x16k PRG, 0x002x8k CHR, no PRGRAM, no CHRRAM, [NTSC], [Horz]

Copy or append it to /etc/magic or ~/.magic, depending on your version of file(1).

edit: Now that we have an attachment mechanism here, added to the forum instead; also changes in the syntax used by file(1) require a trivial change to the "default" directives.


Attachments:
iNESmagic.txt [7.57 KiB]
Downloaded 16 times


Last edited by lidnariq on Tue Sep 26, 2017 8:14 pm, edited 2 times in total.
Top
 Profile  
 
PostPosted: Sun Aug 12, 2012 3:10 pm 
Offline
User avatar

Joined: Mon Feb 07, 2011 12:46 pm
Posts: 932
Can suppport also for NES 2.0, UNIF, DotFami, NSF, NSFe, and NSF2, be added?

_________________
.


Top
 Profile  
 
PostPosted: Sun Aug 12, 2012 6:36 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3951
I think the first post said that it already did NES 2.0 roms.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
PostPosted: Sun Aug 12, 2012 8:14 pm 
Offline
User avatar

Joined: Mon Feb 07, 2011 12:46 pm
Posts: 932
Dwedit wrote:
I think the first post said that it already did NES 2.0 roms.
Yes, you are correct, I just forgot about that at first but now I can see that you are correct. That still doesn't have to do with the other formats though.

_________________
.


Top
 Profile  
 
PostPosted: Sun Aug 12, 2012 9:19 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6448
Location: UK (temporarily)
Debian (and therefore Ubuntu) are already distributed supporting NSF parsing; I wasn't able / didn't try very hard to find a description for UNIF or the expansions to NSF.

I'll wait 'til you finish .FAMI before I look at supporting it.


Top
 Profile  
 
PostPosted: Sun Aug 12, 2012 10:36 pm 
Offline
User avatar

Joined: Mon Feb 07, 2011 12:46 pm
Posts: 932
lidnariq wrote:
Debian (and therefore Ubuntu) are already distributed supporting NSF parsing; I wasn't able / didn't try very hard to find a description for UNIF or the expansions to NSF.
OK.

Quote:
I'll wait 'til you finish .FAMI before I look at supporting it.
OK.

_________________
.


Top
 Profile  
 
PostPosted: Mon Aug 13, 2012 7:16 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6448
Location: UK (temporarily)
It turns out UNIF is even more obnoxious to implement using magic(5)'s syntax, but I've updated the archive (http://eamp.org/li/iNESmagic.zip) with two different implementations. Both have problems.

Because UNIF distributes its metadata all over the image, and file(1) only ever reads the first 100kB from disk, chances are semirandom as to whether you'll actually get any useful information out of any given UNIF image.

I initially tried going and using indirect math, but math made it impossible to calculate the location of a third tag in the file; additionally I'd have to encode tests for every permutation the tags can arrive in.

The first implementation (UNIF1.txt) uses magic(5)'s indirect command, which has the downside that it horribly pollutes the search space, and other files can be parsed as chunks of a UNIF file or vice versa.
It looks like: NES Color Bars Demo V2 by Quietust (PD) [U].unf: UNIFv7, [Vert], mapper:"NES-NROM-128", named:"Color Bars demo, version 2", [NTSC], 16384 B PRG, 8192 B CHR
The second implementation (UNIF2.txt) uses magic(5)'s search command, which doesn't follow the chunks and so can be tricked into parsing non-chunks as real data.
When all goes well it looks like NES Color Bars Demo V2 by Quietust (PD) [U].unf: UNIFv7, 16384 B PRG, 8192 B CHR, mapper:"NES-NROM-128", named:"Color Bars demo, version 2", [NTSC], [Vert]


Top
 Profile  
 
PostPosted: Mon Aug 20, 2012 6:38 am 
Offline
Formerly ~J-@D!~
User avatar

Joined: Sun Mar 12, 2006 12:36 am
Posts: 445
Location: Rive nord de Montréal
I noticed on my Linux machine there's even file(1) support for iNES1 files, (shows mirroring PRG size and CHR size).
Your contribution is useful though because now it shows the MAPPER ;)

Thanks!


Top
 Profile  
 
PostPosted: Tue Sep 26, 2017 8:24 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6448
Location: UK (temporarily)
I noticed that new versions of file(1) support naming headers, and invoking them at a specified offset into the file.

Which suddenly makes parsing chunked formats like UNIF headers really easy and robust! So here's my UNIF parser that uses these new-ish "name" and "use" commands. (It's almost identical to the previous version that used "indirect", but "indirect" just says "start over from scratch", and could match against things outside of our desired parse tree, as well as letting other things incorrectly match against internal headers)


Attachments:
UNIFmagic.txt [2.12 KiB]
Downloaded 13 times
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group