The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > ROM Hacking > Tools, Tutorials & Resources
Sign Up Rules/FAQ Live Battle Blogs Mark Forums Read

Notices

Tools, Tutorials & Resources Various tools to help you develop your hacks can be found here.
New threads in this forum are to be approved by a moderator before they are displayed.


Advertise here

Reply
 
Thread Tools
  #1    
Old August 14th, 2010, 10:30 AM
TSK's Avatar
TSK
Feeling appreaciated =D
 
Join Date: Jun 2007
Gender:
Nature: Timid

Advertise here
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:

Code:
0x3000FC0
0x3000FC1
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:

Code:
0x3000FC4
Write a 1 to that offset and the game will load the new song.

This can be easily tested with the following script:

Code:
#dynamic 0x800000

#org @main
lock
writebytetooffset 0x09 0x3000FC0
writebytetooffset 0x01 0x3000FC1
writebytetooffset 0x1 0x3000FC4
release
end
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:
Demonstration

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:

Code:
.text
.align 2
.thumb
.thumb_func
.global lesson1

main:
	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

.VAR0:
	.word 0x020270B6 + (0x800D * 2)
.VAR1:
	.word 0x020370BA
.VAR2:
	.word 0x020370BC 
.VAR3:
	.word 0x020370BE 
.SVAR1:
	.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:

Code:
#dynamic 0x800000

#org @main
lock
setvar 0x8001 0x??
setvar 0x8002 0x??
setvar 0x8003 0x??
callasm 0x????????   'ASM routine's offset + 1
writebytetooffset 0x3000FC4
release
end
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.
__________________
SilverCurrent is on indefinite hiatus.
Reply With Quote
  #2    
Old September 28th, 2011, 09:32 AM
ManInTheMask's Avatar
ManInTheMask
Pro Hacker
 
Join Date: Aug 2011
Gender: Male
Does this work with trainer battles?
Reply With Quote
Reply
Quick Reply

Sponsored Links


Advertise here
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
Minimum Characters Per Post: 25



All times are UTC -8. The time now is 03:52 PM.


Style by Nymphadora, artwork by Sa-Dui.
Like our Facebook Page Follow us on Twitter © 2002 - 2014 The PokéCommunity™, pokecommunity.com.
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éCommunity.com.
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.