The PokéCommunity Forums

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

TSK August 14th, 2010 10:30 AM

Controlling the sound "manually" + a demonstration of it's uses
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.

ManInTheMask September 28th, 2011 9:32 AM

Does this work with trainer battles?

All times are UTC -8. The time now is 12:09 PM.

Like our Facebook Page Follow us on Twitter © 2002 - 2015 The PokéCommunity™,
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2014 The PokéCommunity / Poké
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.

Use of PokéCommunity Assets