Jump to content

Recommended Posts

Posted (edited)

Because nobody ever really understood how trainer music was determined until now, and it seems like a useful feature to have.

Alright so for this you're gonna want to extract your rom and decompress a couple of the files. I normally use ndstool and blz.exe to do this:

ndstool -x originalromname.nds -9 arm9.bin -7 arm7.bin -y9 y9.bin -y7 y7.bin -d data -y overlay -t banner.bin -h header.bin
copy arm9.bin arm9decomp.bin
blz -d arm9decomp.bin
copy overlay\overlay_0036.bin overlay_0036decomp.bin
blz -d overlay_0036decomp.bin

Now we need to make a few changes to our decompressed overlay 36. They change slightly based on version.

Black 2:

  Reveal hidden contents

White 2:

  Reveal hidden contents

Now, this change will affect how big the file is when compressed, so we need to edit a table in y9.bin to take that into account open it up, go to offset 0x49C, and change it from 58 E9 03 -> 5C E9 03 for Black 2 or 30 E9 03 -> 34 E9 03 for White 2.

Finally, we insert the music table itself. Originally the game contains a table for each of the 236 trainer classes in the form AA GG EE EE, where AA is unknown, GG is gender, and EE EE is the encounter (not the battle) music. The gender field isn't really used for much of anything, so we're just gonna overwrite it with a field for battle music. Note that we only have one byte to work with, so we're restricted to music in the range 0400 to 04FF, but that includes pretty much everything anyway. Now, open your decompressed arm9, and go to 0x8E394 for Black 2 or 0x8E3C0 for White 2. Here, you want to replace

  Reveal hidden contents

with

  Reveal hidden contents

This will assign each trainer class the same music they had in the vanilla game. Obviously this is not very useful, so go ahead and edit that second column to assign whatever music you like to each trainer class. You can use BWTE or something to remind yourself what order the 236 classes come in.

Once you've done that, it's time to rebuild the rom. Which brings us to the bad news. Even though we didn't change the size of the decompressed arm9, our changes still affect what size it is after compression, which for some reason causes major issues when rebuilding the rom. One way to solve this is to just insert the decompressed arm9, instead of compressing it first. This basically solves the issue, but at a cost: the game will now supposedly only be compatible with emulators, not an actual DS.

copy overlay_0036decomp.bin overlay\overlay_0036.bin
blz -en overlay\overlay_0036.bin
ndstool -c newromname.nds -9 arm9decomp.bin -7 arm7.bin -y9 y9.bin -y7 y7.bin -d data -y overlay -t banner.bin -h header.bin

Obviously this is not ideal, so if anyone knows how to insert a compressed arm9.bin with a different size from the original WITHOUT making the game impossible to boot, please let me know. But either way, hope someone finds all this useful.

Edited by MrCheeze
  • Like 2
  • 1 month later...
  • 1 year later...
Posted

This pretty much replaces the existing code for determining battle music with something else entirely, so not an easy thing to just port to gen 4 unfortunately.

But just for your information, this was made with the help of Bond697's partial disassembly here, as well as some of my own reverse engineering work.

  • V-Wheeeeeel!!! 1
Posted
  On 12/5/2017 at 11:47 PM, MrCheeze said:

This pretty much replaces the existing code for determining battle music with something else entirely, so not an easy thing to just port to gen 4 unfortunately.

But just for your information, this was made with the help of Bond697's partial disassembly here, as well as some of my own reverse engineering work.

Expand  

That's cool, thanks a lot :D

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...