Determining correct mapper number with bad iNES headers

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
jwdonal
Posts: 719
Joined: Sat Jun 27, 2009 11:05 pm
Location: New Mexico, USA
Contact:

Determining correct mapper number with bad iNES headers

Post by jwdonal »

How do emulators determine the correct mapper number when the iNES ROM file header is bad. For example, I've got a dump of Dick Tracy with the following values:

$Address: $06 = $21
$Address: $07 = $44

The above (according to the iNES file format) would result in a mapper number of $42. But really it should be $02 (UNROM).

My VeriNES emulator does not properly play the game because it doesn't recognize the mapper number. However, if I load the same ROM into Nestopia it plays the game fine. How does Nestopia know that it's really not mapper $42 ????????????

THANKS!

Jonathon :)
User avatar
Dwedit
Posts: 4470
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

The low nibble of byte 7 is a dead giveaway of a bad header.
Since it's 4, it's a bad header, throw away the high nibble.
You look at bits #2 and #3 of Byte #7 of the header.

....xx.. <- 00 = okay, 10 = Nes 2.0
Anything else: throw out byte #7 of the header because it's a "DiskDude!" rom.
"DiskDude!" roms have 01 for those two bits.

44 in hex is an uppercase D.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
blargg
Posts: 3717
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg »

I think the usual algorithm for iNES is if the last byte of the header is not zero, treat the last 8 bytes of the header as zero, i.e.

Code: Select all

if ( header [15] != 0 )
{
    for ( int i = 8; i <= 15; i++ )
        header [i] = 0;
}
User avatar
jwdonal
Posts: 719
Joined: Sat Jun 27, 2009 11:05 pm
Location: New Mexico, USA
Contact:

THANKS!

Post by jwdonal »

Nice!! Thanks guys!! :-D
BootGod
Posts: 359
Joined: Wed Jul 13, 2005 3:14 pm

Post by BootGod »

Nestopia (and some other emulators as well) check the CRC against an internal database, if a match is found, it uses its own info instead of the header. This is most likely what's happening in this case.
User avatar
jwdonal
Posts: 719
Joined: Sat Jun 27, 2009 11:05 pm
Location: New Mexico, USA
Contact:

cool

Post by jwdonal »

That's really cool. I'd certainly like to do that with my emu (eventually). Is there a database available of Game-to-CRC mappings somewhere that I could use in the future? Or does anyone know where Nestopia stores this lookup-table so I could just steal it (lol, giving credit where credit is due of course)? :)

Thanks!

Jonathon
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: cool

Post by tepples »

jwdonal wrote:That's really cool. I'd certainly like to do that with my emu (eventually). Is there a database available of Game-to-CRC mappings somewhere that I could use in the future?
You might want to talk to bootgod about that. His NesCartDB (sample entry) has a CRC for every game. It'd be a lot cheaper than buying all the games and dumping them in CopyNES.

...pyNES.

...pyNES.

...pyNES.

Oh wait, am I channeling Dr. Robotnik?
User avatar
jwdonal
Posts: 719
Joined: Sat Jun 27, 2009 11:05 pm
Location: New Mexico, USA
Contact:

awesome!

Post by jwdonal »

Haha, oh man, tepples tepples tepples. LOL

Anyway, that is an awesome site! Never been there before. That must have taken him a heck of a long time to create! I was able to download the zipped XML file from his homepage. I'm not sure if he has it in any other formats but I can easily parse the XML. I'll wait to see if he replies to this post before bugging him.

Thanks for the tip!

Jonathon :)
etabeta
Posts: 109
Joined: Wed Nov 29, 2006 10:11 am
Location: Trieste, Italy

Post by etabeta »

notice that the checksums in that xml file are calculated *without* the header. so you have to ignore the first 0x10 bytes of the file if you want to recognize those crc.
BootGod
Posts: 359
Joined: Wed Jul 13, 2005 3:14 pm

Post by BootGod »

XML is the only external format I have right now. It doesn't get as in depth as the website profiles do, but should have everything you need as far as emulation is concerned.
Post Reply