+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  NES ROM expansion...
Pages: [1]
Author Topic: NES ROM expansion...  (Read 538 times)
Griever
Guest
« on: December 31, 2006, 08:54:38 am »

OK, here is the deal: let's say I decided to expand NES ROM, but I don't want to DOUBLE prg rom,
I just want to add only one prg bank. For example: Contra Force has 8x16 PRG Banks, and I have succesfully
expanded it to 16x16, BUT when I expanded original rom up to 9x16... BAM! It didn't work! In fact, FCEU
couldn't even load rom in memory properly, though this 'bad' hack succesfully ran on Nestopia.
So is it possible to add only one prg rom?
RedComet
Guest
« Reply #1 on: December 31, 2006, 09:05:48 am »

Depends on the mapper. It could be that there is a similar mapper to that supports the extra PRG banks and you just got lucky. Also, what do you mean by 8x16 PRG Banks?
Lenophis
Guest
« Reply #2 on: December 31, 2006, 01:55:43 pm »

Quote from: RedComet on December 31, 2006, 09:05:48 am
Also, what do you mean by 8x16 PRG Banks?
The PRG rom banks are 16kb in size, and there are 8 of them.
Disch
Guest
« Reply #3 on: December 31, 2006, 02:15:27 pm »

Due to the way the concept of bankswapping works, most mappers require a power-of-two size to function properly (not just for PRG, but for CHR as well).  NEStopia likely just does a sort of "smart" correction to get games with funky sizes working -- which I would really NOT advise you rely on, since doing this is bad practice all around.

Mappers which don't require an even power-of-two size (I can really only think of one:  225 or something -- which ever one Action 52 uses, can't look it up right now) get away with this by having multiple chips of variable sizes (but each chip having a power-of-two size.  For instance, Action 52 can have 1.5 MB of PRG because it has either two PRG chips (one with 1 MB PRG and one with 512k), or 3 PRG chips (each with 512k) -- I forget which.

For further reading on the subject, you might find this thread interesting:
http://nesdev.parodius.com/bbs/viewtopic.php?t=2769

The reason power-of-two is more or less required is because bankswapping doesn't really "swap in" a bank like the misleading name suggests.  What's really going on is the desired bank number is stored in a register internal to the mapper, which it uses to index a larger area of memory.  The easiest way to visualize this is with 32k PRG swapping (mapper 7, for example).  When a game writes to a mapper reg at $8000-FFFF it sets the internal register.  The low bits of that registers simply replace the high bits of the address on the 6502 during reads.

For example, if the game swaps to bank 2, it would write $02 to the reg.  Then if it read from, say, $9314, the mapper would replace the high bits of that address with the low bits of the mapper reg:

Code:
mapper reg    address
$02 = %0010   $9314 = %10010011 00010100
         ||            |||||||| ||||||||
          \\\\           x||||||| ||||||||
           \\\\           ||||||| ||||||||
            \\\\         /////// ////////
             \\\\       /////// ////////
              \\\\     /////// ////////
               |\\   /////// ////////
               | | /////// ////////
              %1 00010011 00010100 = $11314
                               final PRG address (add $10 for .nes rom offset)

The logic gets a bit more complex when you get into smaller swapping ranges (ie, 8k swapping at $8000 and $A000 a la MMC3) where the mapper has multiple registers (one for each swappable region) and determines which register to use based on the high bits of the read address.

For mappers with "hardwired" banks, the mapper-fed bits are usually all pulled high (as if the swap reg always contained $FF).  This results in the last PRG bank being "hardwired" to wherever.  This also is why emulators might bork the job if the the PRG size isn't a power-of-two.  If the emu simply switches to page $FF for the hardwired bank, this may or may not be the last PRG page depending on the size of the PRG.  For example, if the game has a total of $7F PRG pages (one shy of a nice even power-of-two $80), the emu might hardwire page $01 instead of the last page $7E (since $FF mod $7F is $01).

As for how it behaves on the "real thing" -- it's sort of moot, since I doubt you'll be able to find any ROM/RAM chip that isn't an even power-of-two size.  Or if you can, they're at least a lot harder to find and probably much more expensive.  Not to mention you'll probably have a hell of a time trying to get one to work how you want with any NES MMC.




So in short:

You need to have power-of-two PRG/CHR sizes (barring very special circumstances).  So if you want to expand, you MUST double the PRG.
Griever
Guest
« Reply #4 on: January 01, 2007, 09:31:47 am »

aha, thank you very much - that was a great answer! But what about patch size. I'm pretty sure that it will be too large even if I could add only one bank (which is impossible =))
So is there any solution for that problem? Maybe some special patchers for expanded ROMs?
KaioShin
Guest
« Reply #5 on: January 01, 2007, 09:42:18 am »

The unused space will compress to practically nothing, so the file size won't really change if you add one or 1000 rom banks.
Disch
Guest
« Reply #6 on: January 01, 2007, 12:48:36 pm »

The .ips of an expanded ROM will be bigger just by its nature (it'll have to contain pretty much all of the game's CHR and a lot of the game's original PRG because it has to move it back in the file -- makes me wonder why people even bother with .ips at all anymore).  But NES ROMs (even expanded ones) are tiny.  Even on dialup, the download time of a zipped hack will be minimal.  I wouldn't concern myself with it.
Pages: [1]  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC