MrCheeze Posted November 24, 2015 Posted November 24, 2015 (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: offset 0x46BA0: change 6A F6 10 FB 07 1C 01 98 6A F6 FA FA 0E 2F 08 D2 18 49 7A 00 89 5A 03 B0 21 80 -> 1C 49 82 00 89 5C 21 70 6A F6 0C FB 07 1C 01 98 6A F6 F6 FA 0E 2F 04 D2 03 B0 (This rearranges things so that the music table is indexed by trainer class, instead of by battle intro.) offset 0x46C0C: change 20 80 -> 04 48 (Trainers without a battle intro are hardcoded to use the regular battle music. This replaces the code that does that with a NOP.) offset 0x46C14: change E4 28 1D 02 -> 95 23 09 02 (Repoint the location of the music table, the original one isn't large enough for us.) White 2: offset 0x46B98: change 6A F6 0A FB 07 1C 01 98 6A F6 F4 FA 0E 2F 08 D2 18 49 7A 00 89 5A 03 B0 21 80 -> 1C 49 82 00 89 5C 21 70 6A F6 06 FB 07 1C 01 98 6A F6 F0 FA 0E 2F 04 D2 03 B0 (This rearranges things so that the music table is indexed by trainer class, instead of by battle intro.) offset 0x46C04: change 20 80 -> 04 48 (Trainers without a battle intro are hardcoded to use the regular battle music. This replaces the code that does that with a NOP.) offset 0x46C0C: change 18 29 1D 02 -> C1 23 09 02 (Repoint the location of the music table, the original one isn't large enough for us.) 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 00 00 5A 04 01 01 5A 04 02 00 5A 04 03 01 5B 04 04 00 5A 04 05 01 5B 04 06 01 64 04 07 00 64 04 08 00 65 04 09 01 65 04 0A 00 5A 04 0B 00 5A 04 0C 00 5A 04 0D 01 5F 04 0E 01 5C 04 0F 00 5C 04 10 01 5C 04 11 00 5A 04 12 01 5F 04 13 01 5A 04 14 00 5A 04 15 01 5A 04 16 00 5A 04 17 01 5A 04 18 00 5D 04 19 01 5D 04 1A 00 65 04 1B 00 64 04 1C 01 64 04 1D 00 64 04 1E 00 63 04 1F 00 5E 04 20 00 63 04 21 00 66 04 22 01 65 04 23 00 61 04 24 01 61 04 25 00 5A 04 26 01 5A 04 27 00 5A 04 28 00 5A 04 29 00 5A 04 2A 01 5B 04 2B 00 65 04 2C 00 65 04 2D 00 64 04 2E 01 62 04 28 00 5A 04 2F 01 5F 04 30 01 5D 04 31 00 5D 04 32 00 61 04 33 00 62 04 34 00 64 04 35 00 5A 04 36 01 5A 04 37 00 5A 04 38 00 5E 04 39 00 65 04 3A 00 63 04 3B 01 63 04 3C 00 65 04 3D 01 65 04 3E 00 5E 04 3F 01 61 04 40 01 5F 04 41 00 65 04 42 00 65 04 43 00 63 04 44 01 63 04 45 00 5D 04 46 01 5D 04 47 00 61 04 48 00 64 04 49 00 64 04 4A 01 66 04 4B 00 66 04 4C 01 5A 04 4D 01 5A 04 4E 00 5A 04 4F 00 5A 04 50 01 5A 04 51 00 5A 04 52 00 65 04 53 00 60 04 54 01 5F 04 55 00 65 04 56 01 66 04 57 00 5A 04 58 00 5A 04 59 00 60 04 5A 01 60 04 47 00 61 04 04 00 5A 04 46 01 5A 04 4A 01 5A 04 4B 00 5A 04 45 00 5D 04 2A 01 5A 04 29 00 5A 04 5B 01 5A 04 28 00 5A 04 5C 00 5A 04 5D 00 5A 04 33 00 62 04 49 00 64 04 23 00 61 04 24 01 61 04 45 00 5D 04 46 01 5D 04 31 00 5D 04 30 01 5D 04 5E 01 5A 04 5F 00 5A 04 60 01 5A 04 61 00 5A 04 62 01 5A 04 63 00 5A 04 64 00 5A 04 65 00 5A 04 66 00 5A 04 67 01 5A 04 68 00 5A 04 69 01 5A 04 6A 01 5A 04 6B 00 5A 04 6C 00 5A 04 6D 00 5A 04 6E 00 5A 04 6F 01 5A 04 70 00 5A 04 71 00 5A 04 72 01 5A 04 73 00 5A 04 74 01 5A 04 75 01 5A 04 76 01 5A 04 77 00 5A 04 78 00 5A 04 79 01 5A 04 7A 00 5A 04 7B 01 5A 04 7C 00 5A 04 7D 01 5A 04 7E 00 5A 04 7F 00 5A 04 80 01 5E 04 11 00 5A 04 11 00 5A 04 12 01 5F 04 12 01 5F 04 18 00 5D 04 18 00 5D 04 19 01 5D 04 19 01 5D 04 57 00 5A 04 57 00 5A 04 31 00 5D 04 31 00 5D 04 30 01 5D 04 30 01 5D 04 45 00 5D 04 45 00 5D 04 46 01 5D 04 46 01 5D 04 5C 00 5A 04 5C 00 5A 04 81 00 5A 04 82 01 5A 04 83 01 5A 04 84 01 5A 04 85 00 5A 04 86 00 5A 04 87 01 5A 04 88 00 5A 04 89 00 5A 04 8A 00 5A 04 8B 00 5A 04 8C 00 5A 04 8D 01 DB 04 8E 00 5A 04 8F 01 5A 04 90 00 5A 04 91 01 5A 04 92 00 5A 04 93 01 5A 04 94 00 5A 04 95 00 67 04 96 01 67 04 97 00 5A 04 98 00 5A 04 99 00 5A 04 9A 00 5A 04 9B 01 5A 04 9C 00 5A 04 94 00 5A 04 49 00 5A 04 61 00 5A 04 9B 01 5A 04 9D 00 5A 04 9E 01 5A 04 9F 00 5A 04 A0 01 5A 04 A1 00 5A 04 A2 01 5A 04 A3 00 5A 04 A4 01 5A 04 A5 00 5A 04 A6 01 5A 04 A7 00 5A 04 A8 01 5A 04 A9 00 5A 04 AA 00 5A 04 AB 00 5A 04 AC 01 5A 04 AD 01 5A 04 AE 00 5A 04 AF 01 5A 04 B0 00 5A 04 B1 00 5A 04 B2 01 5A 04 B3 01 5A 04 B4 00 5A 04 B5 00 5A 04 B6 01 5A 04 B7 00 5A 04 B8 01 5A 04 B9 00 5A 04 32 00 61 04 3F 01 61 04 2E 01 62 04 2B 00 65 04 BA 00 5A 04 20 00 DC 04 BB 00 5A 04 94 00 5A 04 with 00 6A 5A 04 01 6A 5A 04 02 6A 5A 04 03 6A 5B 04 04 6A 5A 04 05 6A 5B 04 06 6A 64 04 07 6A 64 04 08 6A 65 04 09 6A 65 04 0A 6A 5A 04 0B 6A 5A 04 0C 6A 5A 04 0D 6A 5F 04 0E 6A 5C 04 0F 6A 5C 04 10 6A 5C 04 11 6A 5A 04 12 6A 5F 04 13 6A 5A 04 14 6A 5A 04 15 6A 5A 04 16 6A 5A 04 17 6A 5A 04 18 6A 5D 04 19 6A 5D 04 1A 6A 65 04 1B 6A 64 04 1C 6A 64 04 1D 6A 64 04 1E 6A 63 04 1F 6A 5E 04 20 6A 63 04 21 6A 66 04 22 6A 65 04 23 6A 61 04 24 6A 61 04 25 6A 5A 04 26 6D 5A 04 27 6A 5A 04 28 71 5A 04 29 6A 5A 04 2A 6A 5B 04 2B 6A 65 04 2C 6A 65 04 2D 6A 64 04 2E 6A 62 04 28 6A 5A 04 2F 6A 5F 04 30 6A 5D 04 31 6A 5D 04 32 6A 61 04 33 6A 62 04 34 6A 64 04 35 6A 5A 04 36 6A 5A 04 37 6A 5A 04 38 6A 5E 04 39 6A 65 04 3A 6A 63 04 3B 6A 63 04 3C 6A 65 04 3D 6A 65 04 3E 6A 5E 04 3F 6A 61 04 40 6A 5F 04 41 6A 65 04 42 6A 65 04 43 6A 63 04 44 6A 63 04 45 6A 5D 04 46 6A 5D 04 47 6A 61 04 48 6A 64 04 49 6A 64 04 4A 6A 66 04 4B 6A 66 04 4C 6A 5A 04 4D 6F 5A 04 4E 6F 5A 04 4F 6F 5A 04 50 6F 5A 04 51 6A 5A 04 52 6A 65 04 53 6A 60 04 54 6A 5F 04 55 6A 65 04 56 6A 66 04 57 6A 5A 04 58 6A 5A 04 59 6A 60 04 5A 6A 60 04 47 6A 61 04 04 6A 5A 04 46 6A 5A 04 4A 6A 5A 04 4B 6A 5A 04 45 6A 5D 04 2A 6A 5A 04 29 6A 5A 04 5B 79 5A 04 28 6A 5A 04 5C 6A 5A 04 5D 6A 5A 04 33 6A 62 04 49 6A 64 04 23 6A 61 04 24 6A 61 04 45 6A 5D 04 46 6A 5D 04 31 6A 5D 04 30 6A 5D 04 5E 6C 5A 04 5F 6C 5A 04 60 6C 5A 04 61 6C 5A 04 62 6C 5A 04 63 6C 5A 04 64 6C 5A 04 65 6C 5A 04 66 6A 5A 04 67 6A 5A 04 68 6A 5A 04 69 6A 5A 04 6A 6A 5A 04 6B 6A 5A 04 6C 6A 5A 04 6D 6A 5A 04 6E 6A 5A 04 6F 6A 5A 04 70 6A 5A 04 71 6A 5A 04 72 6A 5A 04 73 6A 5A 04 74 6A 5A 04 75 6A 5A 04 76 6A 5A 04 77 6A 5A 04 78 6A 5A 04 79 6A 5A 04 7A 6A 5A 04 7B 6A 5A 04 7C 6A 5A 04 7D 6A 5A 04 7E 6A 5A 04 7F EE 5A 04 80 6A 5E 04 11 6A 5A 04 11 6A 5A 04 12 6A 5F 04 12 6A 5F 04 18 6A 5D 04 18 6A 5D 04 19 6A 5D 04 19 6A 5D 04 57 6A 5A 04 57 6A 5A 04 31 6A 5D 04 31 6A 5D 04 30 6A 5D 04 30 6A 5D 04 45 6A 5D 04 45 6A 5D 04 46 6A 5D 04 46 6A 5D 04 5C 6A 5A 04 5C 6A 5A 04 81 6A 5A 04 82 6A 5A 04 83 6A 5A 04 84 6A 5A 04 85 6A 5A 04 86 6A 5A 04 87 6A 5A 04 88 6A 5A 04 89 6A 5A 04 8A 6A 5A 04 8B 6A 5A 04 8C 6A 5A 04 8D 6A DB 04 8E 6A 5A 04 8F 6A 5A 04 90 6A 5A 04 91 6A 5A 04 92 6A 5A 04 93 6A 5A 04 94 EA 5A 04 95 E9 67 04 96 E9 67 04 97 EB 5A 04 98 6A 5A 04 99 F3 5A 04 9A E9 5A 04 9B EC 5A 04 9C 6A 5A 04 94 6A 5A 04 49 6A 5A 04 61 6D 5A 04 9B 6A 5A 04 9D 6A 5A 04 9E 6A 5A 04 9F 6A 5A 04 A0 6A 5A 04 A1 6A 5A 04 A2 6A 5A 04 A3 6A 5A 04 A4 6A 5A 04 A5 6A 5A 04 A6 6A 5A 04 A7 6A 5A 04 A8 6A 5A 04 A9 6A 5A 04 AA 6A 5A 04 AB 6A 5A 04 AC 6A 5A 04 AD 6A 5A 04 AE 6A 5A 04 AF 6A 5A 04 B0 6A 5A 04 B1 6A 5A 04 B2 6A 5A 04 B3 6A 5A 04 B4 6A 5A 04 B5 6A 5A 04 B6 6A 5A 04 B7 6A 5A 04 B8 6A 5A 04 B9 ED 5A 04 32 6A 61 04 3F 6A 61 04 2E 6A 62 04 2B 6A 65 04 BA 6A 5A 04 20 6A DC 04 BB 6A 5A 04 94 EA 5A 04 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 November 24, 2015 by MrCheeze 2
Unknownl Posted January 6, 2016 Posted January 6, 2016 This is super amazing. Surprised it's not getting more attention.
JackHack96 Posted December 3, 2017 Posted December 3, 2017 How did you find out these information? It would be interesting to hack battle's music of 4 gen games 1
gta205 Posted December 5, 2017 Posted December 5, 2017 Yep... also i want this information of battle music!
MrCheeze Posted December 5, 2017 Author Posted December 5, 2017 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. 1
JackHack96 Posted December 6, 2017 Posted December 6, 2017 14 hours ago, 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. That's cool, thanks a lot
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now