The PokéCommunity Forums Fan Games ROM Hacking Tools, Tutorials & Resources
Tutorial Controlling the sound "manually" + a demonstration of it's uses

Tools, Tutorials & Resources Various tools to help you develop your hacks can be found here.

Thread Tools
Old August 14th, 2010 (10:30 AM).
TSK's Avatar
TSK TSK is offline
Roaming Kanto
    Join Date: Jun 2007
    Nature: Timid
    Posts: 168
    Like the title says this thread will describe a way to change the playing song wihtout using any of the built in scripting commands.

    To change the song what you have to do is write the correct values to the following offsets:

    The above locations hold the two bytes that identify the song that is being played but also holds the data for the next song to be played. You can write a sappy song ID to this location, but you have to keep in mind to flip the bytes, e.g.: 0109 => 09 01

    Just writing to those offset will not cause the music to change but writing to the following offset will:

    Write a 1 to that offset and the game will load the new song.

    This can be easily tested with the following script:

    #dynamic 0x800000
    #org @main
    writebytetooffset 0x09 0x3000FC0
    writebytetooffset 0x01 0x3000FC1
    writebytetooffset 0x1 0x3000FC4
    Now, you're probably wondering why you'd ever be interested in this if you have the scripting commands(playsong, sound,...) at your disposal.
    Well I have used it for the following:

    See, the normal sound commands only take song ID's as arguments so they can't be called flexible.

    This is what you need to make a script that reads values from certain vars and plays a song based on those.

    First of all a little piece of ASM code is needed:

    .align 2
    .global lesson1
    	push {r0-r2, lr}
    	ldr r0, .VAR3
    	ldrh r1, [r0]
    	ldr r0, .VAR2
    	ldrh r0, [r0]
    	mov r2, #16
    	mul r0, r2
    	add r1, r0
    	ldr r0, .VAR1
    	ldrh r0, [r0]
    	mov r2, #16
    	mul r0, r2
    	mul r0, r2
    	add r1, r0
    	ldr r0, .SVAR1	
    	strh r1, [r0]
    	ldr r0, .VAR0
    	strh r1, [r0]
    	pop {r0-r2, pc}
    .align 2
    	.word 0x020270B6 + (0x800D * 2)
    	.word 0x020370BA
    	.word 0x020370BC 
    	.word 0x020370BE 
    	.word 0x03000FC0
    The above code will load the content of vars 0x8001, 0x8002 and 0x8003 make a Song ID out of the content and store the ID in 0x800D and 0x3000FC0.

    The ID is formed as follows:

    ([0x8001]*0x10 * 0x10)+([0x8002] * 0x10)+([0x8003])

    So the most basic form of usage for the ASM code in a actual Script is as follows:

    #dynamic 0x800000
    #org @main
    setvar 0x8001 0x??
    setvar 0x8002 0x??
    setvar 0x8003 0x??
    callasm 0x????????   'ASM routine's offset + 1
    writebytetooffset 0x3000FC4
    If anyone wants I can put the my script seen in the Youtube Video in here as well, but it's not commented at the moment and I don't really feel like adding comments. Just ask in the thread.

    Also please note that this is the first thing I did involving ASM so it might not be the most efficient way of way of doing this.

    I hope this information will help someone and if there are any question feel free to ask.
    Reply With Quote

    Relevant Advertising!

    Old September 28th, 2011 (9:32 AM).
    ManInTheMask's Avatar
    ManInTheMask ManInTheMask is offline
    Pro Hacker
      Join Date: Aug 2011
      Gender: Male
      Posts: 31
      Does this work with trainer battles?
      Reply With Quote

      Quick Reply

      Join the conversation!

      Create an account to post a reply in this thread, participate in other discussions, and more!

      Create a PokéCommunity Account

      Sponsored Links
      Thread Tools

      Posting Rules
      You may not post new threads
      You may not post replies
      You may not post attachments
      You may not edit your posts

      BB code is On
      Smilies are On
      [IMG] code is On
      HTML code is Off

      Forum Jump

      All times are GMT -8. The time now is 2:18 AM.