Thread: Research/Survey: Game Boy Player for FireRed
View Single Post
  #1    
Old July 18th, 2011, 12:49 PM
Jambo51's Avatar
Jambo51
Glory To Arstotzka
 
Join Date: Jun 2009
Gender: Male
Nature: Quiet
This is a very popular feature in HGSS, with good reason.
My question is this:

Would it be worthwhile to attempt to make something similar for FireRed?
Many people (myself included) have a very strong affinity for the original 8 bit music, and creating such a hack would open up hundreds of alternative uses for the routines used to play music.

As a proof of concept, I present these 2 youtube videos showing that the FR rom is capable of playing "pure" 8 bit music. (What I mean by this, is that each track heard in these tracks is actual Synth, and not a sample of synth played through the direct tracks.)

The videos:
http://www.youtube.com/watch?v=2AGYcEHERng
http://www.youtube.com/watch?v=fORic4oUTe8

For those wondering how this works, the New Sappy helps immensely.
Firstly, open the VoiceGroup editor within the new sappy, and navigate to voice 80 and 81 (0x50 and 0x51), and change it to match the following configurations.

BIG THANKS TO MR. PKMN, who showed me this function of the new sappy, and pointed me in the right direction to make it emulate the square instruments!

This works with any voicegroup, I just happened to choose that particular one.




Then comes the most complicated part for the simple music. Now we go to 82 (the "wave synth") and edit the wave to match the square wave of the actual Square instrument. This is surprisingly easy to do!



This is your basic setup. Remember to repoint the wave to free space, otherwise it'll overwrite the ARM code at the start of the rom, rendering it useless. Then select "Edit Wave..." Modify it so that it looks EXACTLY like this:



This makes the wave sound IDENTICAL to the Square instrument. Thus we overcome the lack of 3 synth channels.
This only affects the "wave synth" of the voicegroup you actually edit, so it's perfectly feasible to create a separate voicegroup specifically for the synth music!

The next thing we must do, is write some sort of check into the music table selecting routines, to change which table to read based on a variable/flag.

This is my code for this part of the rom. I had to be slightly imaginative to make this code work, and it will require a host of edits. First of all, the code:

Code:
.text
.align 2
.thumb
.thumb_func
.global gameboyplayerbackgroundroutine
main:
 add r3, r2, #0x4
 ldr r2, ramtable
 push {r0,r2-r7}
 ldr r0, flag
 bl decrypt
 add r1, r0, #0x0
 pop {r0,r2-r7}
 cmp r1, #0x0
 bne gbp
 ldr r1, normaltable
 b exit
gbp: ldr r1, gbptable
exit: lsr r0, r0, #0xD
 add r0, r0, r1
 mov pc, r3
decrypt: ldr r1, decry
 bx r1
.align
ramtable: .word 0x084A329C
normaltable: .word 0x084A32CC
gbptable: .word 0x08FFFFFF
flag:  .word 0x000008F0
decry:  .word 0x0806E6D1
Now, there are 5 locations where this code needs to be linked in. Thankfully, it's actually relatively simple to do so!
Navigate to 0x1DD0F8, 0x1DD124, 0x1DD170, 0x1DD1C4 and 0x1DD1F8 and change the code at ALL of the locations to:
Code:
 7A 46 XX 49 08 47
It's XX because the number should always be left unchanged, as it's loading from a pre-determined spot. Finally, replace all previously existing pointers to 0x4A32CC with a pointer to the THUMB routine, remembering to add 1 for thumb of course, and leaving the new pointer in the custom routine.

Obviously, you should make a new music/SFX table specifically for the GBP music. And make sure the music is in the same slots as the "normal" music. Ie, have the Wild Battle Music in slot 0x12A on both tables etc.

If you don't have a piece of GBP music for a tune in your game, you can always go the HGSS route and just put a pointer to the "normal" version instead!

If you correctly pulled this off, the game will show no ill effects of the insertion, and will continue to load music as it should. Feel free to change the flag used should you wish to.

At this stage, the music can actually be switched, but only by setting/clearing the flag in a script. For this to mimic HGSS's version, we would need to come up with a way to change the music on the fly. In other words, we would need an item which would return the player to the OW from the bag, then run a script which would change the flag/variable, followed by a fadedefault or a writebytetooffset 0x1 0x03000FC2, which would make the normal/gbp music play.

This routine has a distinct advantage. It gets applied RIGHT from the boot screen of the game. So if the player has the flag set for the GBP, it will play the GBP music right from the boot screen onwards!
__________________
Hey guys, please check out my recreations of the gen 1 and 2 music on my custom engine at my SoundCloud! - Here!

Last edited by Jambo51; July 20th, 2011 at 01:01 PM.
Reply With Quote