Mappers and .NES file layout

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
frantik
Posts: 370
Joined: Tue Mar 03, 2009 3:56 pm

Mappers and .NES file layout

Post by frantik »

I'm working on a project using mappers, but I'm not sure exactly how I should set up the ROM file.. I know each mapper is different but are the .NES files always arranged the same way?

like for mapper #180 which has a fixed first bank (starting at $8000) and swappable 2nd bank (@ $c000), do I put the fixed bank first, then all of the banks which will be swapped, and then the CHR?

or for UNROM do I put all of the swappable banks first, then the fixed bank, then the chr? and MMC3 seems super complex
User avatar
beneficii
Posts: 127
Joined: Tue Jul 12, 2005 4:37 pm

Post by beneficii »

In the MMC3 the two fixed banks go at the end. As for the other mappers, you should find that in the documentation. There was a really good website for mappers whose name and address I don't really remember, but it would go into such details as the design of those mappers.
frantik
Posts: 370
Joined: Tue Mar 03, 2009 3:56 pm

Post by frantik »

thanks.. i'll keep looking for the layout.. i've looked on the wiki here and in disch's mapper docs but neither has the layout of the actual .NES file

edit: looks like the firebug mappers.doc has layout info on quite a few mappers :)
ccovell
Posts: 1041
Joined: Sun Mar 19, 2006 9:44 pm
Location: Japan
Contact:

Post by ccovell »

Try not to confuse the ROM layout of the iNES mapper and the layout of PRG/CHR ROM space in the NES' actual memory space.

iNES ROMs always have a 16-byte header, which tells you what follows: A (512-byte?) trainer, if ever (rarely) present, then 1 or more 16K ROM banks, followed by 0 or more CHR-ROM banks. If the CHR-ROM is set to 0, then the game uses CHR-RAM.
frantik
Posts: 370
Joined: Tue Mar 03, 2009 3:56 pm

Post by frantik »

ccovell wrote:Try not to confuse the ROM layout of the iNES mapper and the layout of PRG/CHR ROM space in the NES' actual memory space.
yeah, i'm wondering the layout of the actual .NES files.

I know the NES ROM space is from $8000 to $FFFF and is usuallyk broken up into 2 banks at $C000

I just was wondering if there is a standard way or a document which tells the layout of the .NES file

i was thinking something like

- 10NES header
- 16k PRG-ROM bank1, can be swapped into $8000
- 16k PRG-ROM bank2, can be swapped into $8000
- 16k PRG-ROM bank3, can be swapped into $C000
- 16k PRG-ROM bank4, can be swapped into $C000
- 8k CHR-ROM
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

In the NES file, there is no such thing as a bank that "can be swapped into $XXXX". UNROM games, for example, have 128KB of RG-ROM, broken up into 8 16KB banks, but the "fixed bank" is defined by the mapper. The mapper makes the last 16KB bank visible at $C000-$FFFF at all times, but you can make this same bank visible at $8000-$BFFF as well. I don't know why you'd want that, but it's possible.
frantik
Posts: 370
Joined: Tue Mar 03, 2009 3:56 pm

Post by frantik »

i just meant which banks in the NES file correspond to which banks that the mapper uses

here's the layout for UxROM (mapper 2) which i just used

- 10NES header
- 16k PRG-ROM banks 1-15 (Must be 1, 3, 7 or 15 banks) can be swapped into $8000.
- 16k PRG-ROM last bank , fixed at $C000
- 8k CHR-ROM

i was just wondering if there was a document which has this information. i found one which has it for most mappers and got what I wanted to do done, though it still would be nice to keep my options open :)
User avatar
Hamtaro126
Posts: 783
Joined: Thu Jan 19, 2006 5:08 pm

Post by Hamtaro126 »

frantik wrote:i was just wondering if there was a document which has this information. i found one which has it for most mappers and got what I wanted to do done, though it still would be nice to keep my options open :)
Hey, It's Frantik!

If you want a list of mappers and it's list of capabilities, Try to go to RHDN and Download ''Disch's NES Mapper Docs'' in the documents section. I have kept it as a reference myself, too.

I will be gone for three days, Enjoy and Have Fun!
User avatar
Disch
Posts: 1848
Joined: Wed Nov 10, 2004 6:47 pm

Post by Disch »

iNES layout is simple:

- $10 byte header
- optional $200 byte trainer (typically absent)
- X*$4000 PRG-ROM banks
- X*$2000 CHR-ROM banks

The number of PRG and CHR banks is indicated in the header, as well as whether or not the trainer exists.

Like tokumaru said ... there's no such thing as a bank which can/can't be swapped into X. The mapper simply uses the selected (swapped in) page number to fill in the high bits of the address when it reads from the ROM chip. Therefore:

If dealing with 16K PRG banks:

bank 0 = offset 0x00010-0x0400F
bank 1 = offset 0x04010-0x0800F
bank 2 = offset 0x08010-0x0C00F
... etc

Or if dealing with 8K PRG banks:

bank 0 = 0x00010 - 0x0200F
bank 1 = 0x02010 - 0x0400F
bank 2 = 0x04010 - 0x0600F
... etc

(note: offsets assume no trainer)

CHR works the same way.

Any bank can be swapped to anywhere, the mapper doesn't care (with a few rare exceptions which are always noted in documentation)
frantik
Posts: 370
Joined: Tue Mar 03, 2009 3:56 pm

Post by frantik »

ok, i think i understand more. for most mappers, any bank can be swapped into the swappable bank area

that still leaves the 'fixed banks' though.. are those in the same place for each mapper? this is not in most mapper documentations i've found, even your crazy comprehensive list Disch (or at least not for mmc3).

but it's ok cause i got unrom working :) (and i'm handling the bus conflicts dont worry :D)
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

Banks fixed to $C000-$FFFF are usually the highest numbered bank, so they appear last in the PRG chip. Banks fixed to $8000-$BFFF are usually the lowest numbered bank, so they appear first in the PRG chip. There are a few exceptions, like that mapper used for pirate SMB2j that puts 8 KiB PRG banks 4, 5, 6, and 7 into $8000, $A000, $6000, and $E000 instead of the expected $8000, $A000, $C000, and $E000.
Last edited by tepples on Fri Mar 06, 2009 1:21 pm, edited 1 time in total.
User avatar
MottZilla
Posts: 2835
Joined: Wed Dec 06, 2006 8:18 pm

Post by MottZilla »

Disch's docs say -1 and -2 for fixed banks.
frantik
Posts: 370
Joined: Tue Mar 03, 2009 3:56 pm

Post by frantik »

MottZilla wrote:Disch's docs say -1 and -2 for fixed banks.
oh, i guess i didn't realize thats what the {-1} and {-2} meant. cool

thanks everyone for your help :)
User avatar
Disch
Posts: 1848
Joined: Wed Nov 10, 2004 6:47 pm

Post by Disch »

I figured it was easier to put explanations for all the shorthand in one doc rather than making every doc overly wordy (they're already pretty wordy). But the problem with that approach seems to be that nobody reads the main readme ;_;.
__READ THIS FIRST__.txt wrote:Numbers surrounded by {curly braces} mean the page is fixed. Here, $E000-FFFF is fixed to page -1. Negative pages indicate the last pages are used. IE: "-1" means to use the last page of PRG, "-2" would be the second last, etc.
frantik
Posts: 370
Joined: Tue Mar 03, 2009 3:56 pm

Post by frantik »

don't feel bad Disch.. i have read that file, but it was hella long ago. lol :P
Post Reply