Help with NES rom expansion and music insertion

Started by joesteve1914, September 29, 2012, 10:22:00 PM

Previous topic - Next topic

joesteve1914

I was just playing Zelda II and I thought, "what if ZREO's music tracks could play in the game?" Well, I've thought about it and decided to attempt it. But, I've never expanded a NES rom or inserted music before. My only experience is with hex and tile editors. Could anyone offer advice on this?

Bregalad

The expandability of NES ROMs all depends on theri mapper and the current amount of ROM they use.
Zelda II uses MMC1 with 128k PRG-ROM and 128k CHR-ROM, I think the PRG-ROM should be expandable to 256kb without breaking the game.
I haven't analyzed the bankswitching sheme used by Zelda II but very likely it uses 16kb PRG banks. You'd have to keep banks 0-6 intact, copy bank 7 to bank 15 (the hardwired bank at $c000-$ffff) and insert 8 new banks for banks 7 to bank 14. Of course you should also keep the CHR-ROM intact.

If Zelda II uses 32kb banks instead then what I said is just wrong and it should be more complicated to expand the ROM. However the majority of NES games used 16k banks.

Dr. Floppy

Zelda II uses SKROM, which is arguably the most hacker-friendly MMC1 submapper. It's got battery-backed SRAM, supports CHR-ROM and is expandable to 256kB (PRG). As Bregalad said, the original game only uses 128k of PRG-ROM, so expansion is definitely possible. Here's how you do it:


0) Make sure your Zelda II ROM ends at $4000F. If it doesn't, add empty bytes at the very end of the ROM until it does, then change the sixth byte in the iNES header ($000005) from #0E to #10.

1) Make a backup of the original ROM.

2) Open your guinea pig ROM in your favorite hex editor and add exactly 131,072 bytes to the end of the file. (If your editor allows, you can insert these new bytes between $2000F and $20010, then skip ahead to step 4.)

3) Copy/transfer the data from $[20010-4000F] to $[40010-6000F].

4) Copy/transfer the data from $[1C010-2000F] to $[3C010-4000F]. (Yes, this overwrites old data.)

5) Blank-out the data from $[1C010-3C00F]. (Yes, this blanks out old data.)

6) Copy the six bytes from $[4000A-F] to the following seven locations: $2000A-F, $2400A-F, $2800A-F, $2C00A-F, $3000A-F, $3400A-F, $3800A-F.

7) Update the fifth byte in the iNES header ($000004) from #08 to #10.

:crazy: :cookie: :crazy: :cookie: :crazy:

KingMike

Quote from: Dr. Floppy on October 10, 2012, 01:34:03 AM
0) Make sure your Zelda II ROM ends at $4000F. If it doesn't, add empty bytes at the very end of the ROM until it does, then change the sixth byte in the iNES header ($000005) from #0E to #10.

If it doesn't end at $4000F, then you've got a bad dump.
I'd rather go find a good dump (256KB).
Although looking at it in a tile editor, it seems to be empty space.
"My watch says 30 chickens" Google, 2018

Dr. Floppy

Quote from: KingMike on October 10, 2012, 09:51:41 AM
If it doesn't end at $4000F, then you've got a bad dump.

Yeah, I noticed that upon double-checking my procedural within my trusty Zelda II ROM. Turns out, I've been playing with such a bad egg for the better part of a decade!

joesteve1914

#5
Ok, thanks for the help!

Could anyone help me with inserting the music now that its expanded.

October 22, 2012, 07:02:51 PM - (Auto Merged - Double Posts are not allowed before 7 days.)

I just checked, and the music files are too big, so never mind, but thanks anyways!

Karatorian

Well, you seem to have given up, but I'll drop in a bit of advice anyway. One thing to remember is that you can probably free up space by removing the old music (and possibly the music engine too). To understand NES music hacking, you need to understand how NES music works. There's a portion of the game code called the "music engine" that interprets the music data and manipulates the sound hardware. There is no standard for NES music, it's all generally custom code and music from one game isn't generally compatible with another game. (Some developers have reused their in-house music engine in many games though).

So the first thing you need to do is identify the music engine and data in the source game and in the destination game. I'm not familiar with ZERO, but I'm assuming it's another NES game. (If not, the difficulty of the hack increases exponentially). There is a shortcut that can be used to find the source material. If an NFS rip of the music you want has been made, you can use it instead. (An NFS is basically the music engine and data without the rest of the game.) Once you've found this stuff, then you have to replace the calls to the original music engine with calls to the new one and the data with your new data. At first, you'll probably just want to add the new engine and some music data to the newly expanded space in the ROM. Even if it doesn't all fit, getting everything working before you start removing the old music engine and data (if you do), should be easier.

How big are the music files you're trying to insert? 128k is on the larger side for NES games and the expansion gives that much free space. I find it hard to imagine that the sounds you're thinking of adding are bigger than that. Unless (as I'm starting to suspect), the files you've got are in the wrong format. Waves or MP3? In that case, they won't do you any good. While rendered versions of VGM are handy for home listening, they're useless for hacking on older consoles like the NES. You've got to use the original source material to make this idea work.
Current ProjectsFinal Fantasy EngineSMB Special for NESStudio Karatorian
@loop: lda (src),y — sta (dst),y — iny — bne @loop — inc src+1 — inc dst+1 — dex — bne @loop

joesteve1914

ZREO is a group that makes reorchestrated versions of game music.

Karatorian

#8
Oh. I looked them up and it seems they're PCM (in MP3) format. Unfortunately, the NES can't really play PCM. (It does have some limited 8-Bit PCM playback capabilities, but nothing spectacular and probably not suitable for your purposes.) That said, the GBA can do PCM, so perhaps you could hack it into the GBA rerelease (part of the Classic NES Series).
Current ProjectsFinal Fantasy EngineSMB Special for NESStudio Karatorian
@loop: lda (src),y — sta (dst),y — iny — bne @loop — inc src+1 — inc dst+1 — dex — bne @loop

joesteve1914

Ok, so could anyone help me insert it into the gba rerelease?