How do I set up mmc5 prg-rom and chr-rom size?

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
User avatar
Dreamwriter
Posts: 35
Joined: Tue Jun 02, 2015 9:17 pm
Location: Florida
Contact:

How do I set up mmc5 prg-rom and chr-rom size?

Post by Dreamwriter »

I'm just getting started on my first NES game, and I've setup my ines header for mmc5 (I have big plans!). All it does right now is play a small song (thanks Famitone) and display a few BG characters (not using any mmc5 features yet). But if I try to setup the details of prg-rom size and chr-rom size in the ines header, emulators (like puNES) won't run my game. If I leave both values at just 1, it works fine, if I try other values like 32 and 16, I get errors loading my game. Am I doing something wrong in how I set things up, do I need to change something about my memory setup? I looked at the ines header for Uncharted Waters (my target cart-size setup), and that's basically the same as my game, so the header doesn't seem to be the issue.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: How do I set up mmc5 prg-rom and chr-rom size?

Post by tepples »

You need to be producing as much data in the assembler as you are declaring in a header, or the ROM will not load correctly.
  • 32 in the PRG size field means 32*16384 = 524288 bytes.
  • 16 in the CHR size field means 16*8192 = 131072 bytes.
And you need to put init code in the correct bank. If I remember correctly, MMC5 boots up with the last PRG ROM bank in $E000-$FFFF, so you need to have your vectors and init code there.

MMC5 is a very powerful, very expensive chip. What MMC5 features do you plan to use?
User avatar
Dreamwriter
Posts: 35
Joined: Tue Jun 02, 2015 9:17 pm
Location: Florida
Contact:

Re: How do I set up mmc5 prg-rom and chr-rom size?

Post by Dreamwriter »

Thanks, I'll look into that.

I'm used to developing for Gameboy Color, and we used to use scanline DMAs all the time to do crazy scanline effects - reloading palettes, parallax scrolling, reusing sprite OAMs, changing char sets every other scanline for funky effects, things like that. So that's one thing I plan on using MMC5 for, it's apparently really easy the way MMC5 does it. Also the palette-per-tile extended attributes mode makes it a lot closer to a GBC as well. And one thing I really want to do if it is possible is to use the extra sound channels - I'm making a game for a not-quite-pure NES (that has MMC5 support built-in), so I think it might be able to play the extra sound channels without any hardware modifications needed.
User avatar
Dreamwriter
Posts: 35
Joined: Tue Jun 02, 2015 9:17 pm
Location: Florida
Contact:

Re: How do I set up mmc5 prg-rom and chr-rom size?

Post by Dreamwriter »

I researched nes.cfg so I could set up the PRG-ROM bank memory and put the code and vector segments in the final bank in $E000, and that worked nicely - I now have a working 512k MMC5 rom using a couple hundred bytes :) Something I don't really get, though:

Mmc5 starts off by default in PRG mode 3, which is 8k banks. But that seems to mean if I wanted to change the PRG mode at startup (say to 32k banks), I'd have to waste the 8k from that mode 3 startup bank - I'd have to boot into that bank so I could tell it to use the other mode, which wouldn't support 8k banks. Am I correct in this, or not seeing how it all really works?
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: How do I set up mmc5 prg-rom and chr-rom size?

Post by tepples »

Every 32K bank consists of four 8K banks. If you switch to 32K mode and load the last bank, the last 8K of the ROM will still be sitting there in $E000.
Post Reply