Being my background mainly related to MAME, I've always been under the impression that gluing together the different chip contents + an 'arbitrary' header was not the best solution. Especially, given the large number of ROMs floating around with the wrong header (while working on pirate mappers, I have found tons of chinese roms generically assigned to Mapper 4 or 0, which in fact required different features to work), and the generic lack of consensus on some mapper numbers for obscure chinese carts.
This is why, starting from today, MESS publicly supports loading zipfiles containing separate PRG and CHR files, in addition to iNES and UNIF!
The matching between the ROM files and the correspondent boards is obtained through a .xml database which gets read when carts are loaded and which is public for anyone to use (as long as new findings about obscure boards are made public so that anyone can use them): you can get a copy from this link (click on 'plain' and save the ~2.5MB xml file)
http://git.redump.net/cgit.cgi/mess/tree/hash/nes.xml
Before getting into the xml details, I would like to point out that only 3 things are required to add support for these files in any emu:
1. an xml parser, to read info from nes.xml about the board type, the memory sizes, the mirroring, the dispwitches, the peripherals, etc.
2. the capability to load separate files from inside a zipfile based on checksums or filenames (like MAME, Nebula and FBA do for arcade romsets)
3. a lookup table to pass from the board type [read in nes.xml] to the correct mapper emulation. NEStopia has a lookup table of this sort in src/core/boards/NstBoard.h, if a reference is needed
once the file is loaded in memory and the emulator has chosen the appropriate read/write handlers, emulation can go on as it would usually do after loading an iNES file to memory.
Now let's focus on the xml format. Let's examine a typical entry (in this case for Aerobic Studio)
Code: Select all
<software name="train3as" supported="partial">
<!-- Serial: FT-03 - Release Date: 1987-02-26 - Alternative Title: ファミリートレーナー③ エアãƒãƒ“スタジオ -->
<description>Family Trainer 3: Aerobics Studio (Jpn)</description>
<year>1987</year>
<publisher>Bandai</publisher>
<part name="cart" interface="nes_cart">
<feature name="pcb" value="BANDAI-PT-554" />
<feature name="mirroring" value="horizontal" />
<feature name="peripherals" value="ftrainer" />
<dataarea name="prg" size="32768">
<rom name="aerob pr" size="32768" crc="f8da2506" sha1="c14075b1b7c98b684870e8d85b7ff2b462e3cd10" offset="00000" />
</dataarea>
<dataarea name="chr" size="32768">
<rom name="aerob ch" size="32768" crc="ff1d2bfd" sha1="c41872d3c28230f3a907db9bf46568ca8a789e22" offset="00000" />
</dataarea>
<dataarea name="adpcm" size="262144">
<rom name="m50805" status="nodump" offset="00000" />
</dataarea>
</part>
</software>
Then, we have the basic info which could be shown in the emu UI:
- <description> for the complete name of the game
- <year> & <publisher> for the corresponding info
the commented out fields (serial, release date & alt titles) might be re-added later, I'm not sure (this xml format is used for many systems in MESS, so some compromise had to be accepted)
Finally, <part> includes everything an emulator needs to know to emulate this specific piece of software (the "name" and "interface" attributes are internally used by MESS to know this is NES and not another console).
Ideally, an emulator could start any file of the xml list by simply parsing the part node:
- from <features>, you would find out: which "pcb" the game uses (in this case a Bandai CNROM variant containing an additional sound chip), so that you can choose the required mapper; if the game has hardwired "mirroring", horizontal in this case; if the game supports particular peripherals; etc. for some particular pcb there might be specific features, e.g. the pin settings for protected CNROM games, or the pin connections for Konami VRC-2, VRC-4 and VRC-6 games, or the chip revision for MMC1 and MMC3 (to handle different MMC3 IRQ or Mapper 1 vs. Mapper 155 emulation)...
- from <dataarea>, you would find out which chips were present on the pcb: in the example we have the expected "chr" and "prg", plus a "adpcm" area for the content of the audio chip, if we ever manage to dump it. Other possible 'dataarea' are "vram" (if present on the board), "wram" and "bwram" for PRG RAM with or without battery, "mapper_ram" and "mapper_bram" for mappers which have internal RAM with or without battery like MMC5, MMC6 & Taito X1-005. At start, an emu should simply load prg & chr, and take note of the other dataarea to setup VRAM & WRAM like it would do by parsing the iNES header
- from <dipswitch>, you would read if the cart had switches on it (this is needed for a few pirate multicarts)
Here are other three examples for Excitebike, Shin Satomi Hakkenden and Taito Grand Prix, respectively
Code: Select all
<software name="excitbik">
<!-- Serial: NES-EB (EEC/NOE/ESP) - Release Date: 1986 -->
<description>Excitebike (Euro)</description>
<year>1986</year>
<publisher>Nintendo</publisher>
<part name="cart" interface="nes_cart">
<feature name="pcb" value="NES-NROM-128" />
<feature name="mirroring" value="vertical" />
<dataarea name="prg" size="32768">
<rom name="pal-eb-0 prg" size="16384" crc="0b5667e9" sha1="8c37839c645d54184df6273e481527d4cfa312d2" offset="00000" />
<rom size="16384" offset="4000" loadflag="reload" />
</dataarea>
<dataarea name="chr" size="8192">
<rom name="hvc-eb-0 chr" size="8192" crc="e5f72401" sha1="a8bf028e1a62677e48e88cf421bb2a8051eb800c" offset="00000" />
</dataarea>
</part>
</software>
<software name="shinsato">
<!-- Serial: TDF-91 - Release Date: 1989-12-08 - Alternative Title: æ–° é‡Œè¦‹å…«çŠ¬ä¼ å…‰ã ¨é—‡ã ®æˆ¦ã „ -->
<description>Shin Satomi Hakkenden: Hikari to Yami no Tatakai (Jpn)</description>
<year>1989</year>
<publisher>Toei Animation</publisher>
<part name="cart" interface="nes_cart">
<feature name="pcb" value="HVC-SNROM" />
<feature name="mmc1_type" value="MMC1B2" />
<dataarea name="prg" size="262144">
<rom name="tdf-91-0 prg" size="262144" crc="23e9c736" sha1="835a0f9a3ddd516cecbccf34fbe8f7632f297558" offset="00000" />
</dataarea>
<!-- 8k VRAM on cartridge -->
<dataarea name="vram" size="8192">
</dataarea>
<!-- 8k WRAM on cartridge, battery backed up -->
<dataarea name="bwram" size="8192">
</dataarea>
</part>
</software>
<software name="taitogp">
<!-- Serial: TFC-TG-5500 (15) - Release Date: 1987-12-18 - Alternative Title: タイトーグランプリ æ „å…‰ã ¸ã ®ãƒ©ã‚¤ã‚»ãƒ³ã‚¹ -->
<description>Taito Grand Prix: Eikou e no License (Jpn)</description>
<year>1987</year>
<publisher>Taito</publisher>
<part name="cart" interface="nes_cart">
<feature name="pcb" value="TAITO-X1-005" />
<feature name="x1-pin17" value="CHR A17" />
<feature name="x1-pin31" value="CIRAM A10" />
<dataarea name="prg" size="131072">
<rom name="pr0 x3-018" size="131072" crc="17627d4b" sha1="5a8680dce5f2f2ecb28ef592b7418b2371fe98f4" offset="00000" />
</dataarea>
<dataarea name="chr" size="131072">
<rom name="ch x3-019" size="131072" crc="505aa340" sha1="8890e530e9b1485bfeb7e73669104edce8fa625f" offset="00000" />
</dataarea>
<!-- 128b Internal RAM (battery backed up) in the X1-005 chip -->
<dataarea name="mapper_bram" size="128">
</dataarea>
</part>
</software>
A few more remarks:
Concerning accuracy of the info in the xml list, the first part of the list is very precise, being based on the latest version of Bootgod's database.
On the other hand, the second part is not so complete (yet): it contains files (around 2500) from various other collections (GoodNES, nointro and NonGoodNES), with pcb, mirroring and vram/wram settings taken from the headers. As such, there might be mistakes which I hope to fix little by little... Moreover, additional info are mostly missing (I will add them next, but I thought checksums had definitely priority over Manufacturers and Release Dates ) and some Alt sets might actually be bad dumps which got incorrectly labeled, and they will need further investigations to be sorted out.
However, I think the current list is not that bas as a starting point, given that 95% of the games shows something when loaded
Concerning included file, you might notice that the xml list does not contain hacks or translations: this is done in purpose, since in my opinion these should be made available as IPS patches (to be applied at loading time, after the separate prg & chr have been loaded into memory). On the other hand, dumps from pirate carts are included.
Finally, concerning the file availability (a not so trivial question, given that it's what basically killed the nice UNIF format), conversion from iNES & UNIF is pretty easy since it mainly consists of splitting PRG and CHR chunks from the existing files: MESS is already capable of dumping out the data when the user loads one of his files, if required, and rommanager programs like clrmame or romvault can use the xml list to create zip archives with the correct names from the split files. Also, there is a group of users actively splitting the files so that ready-to-use zipfiles might appear soon-ish through rom collector websites. I'm not sure this will be enough to gain some momentum,
but I hope I can find some more people not exactly happy with the iNES format and the arbitrary mapper numbers
Of course, I'd be interested in feedback and suggestions (as well as critics, of course) and I'm ready to answer to any question which might arise.
That's all folks. Thanks for reading. Cheers.