PDA

View Full Version : Fancy Knowledge #3 - Using Two Different Musics In One Event


Mastermind_X
October 16th, 2008, 09:44 AM
Fancy Knowledge #3 - Using Two Different Musics In One Event

Heyho. Some people asked how zel was able to use more than 1 music in his battles. I created that feature a year ago and called it "jukebox". I think it's time now to explain how it works... (I think zel won't have a problem if i tell it...)

You can find it here:
http://sfc.pokemon-inside.net/lesson.php?id=13&lang=en


greetz
MX

P.S. If you find offsets for other versions than Fire Red US and you want to share them with others post them in this thread or send me a PM.

liuyanghejerry
October 17th, 2008, 02:45 AM
Your page is kind of in disorder about the binary...
Anyway,thanks~

Νιτραμ
October 17th, 2008, 07:43 AM
Hey, the tutorial is really nice, it will find sure good use in many hacks.

I don't like being noobish and ask questions in wrong places, but isn't it October already, M_X? :P

cooley
October 17th, 2008, 12:46 PM
Very useful, indeed. I would make a tool, but I don't know if I can...or rather feel like it.
I'll be using this, and good luck! Especially with that Day&Night System ;)

Mastermind_X
October 17th, 2008, 02:42 PM
Your page is kind of in disorder about the binary...
Anyway,thanks~

Uhm. What exactly do you mean? Oo

Edit: @ Martin™
It is. Well. Do you want to have a D/N system that crashes for unknown reasons when you switch pokemon in battle? ^^° I try to fix that problem... -.-

liuyanghejerry
October 18th, 2008, 02:20 AM
Well,sorry for my bad English...I mean this:


http://www.pokecommunity.com/picture.php?albumid=365&pictureid=12066

Lady Berlitz
October 18th, 2008, 10:36 AM
This tutorial seems quite useful. I liked how you said that it's "fancy knowledge", Mastermind.
I will definitely be using this in the future for my hack.

Thanks for writing/translating this, Mastermind.

Νιτραμ
October 18th, 2008, 11:19 PM
@M_X: Ah, so that is the reason. Sorry then ^^" I hope you will be able to fix it.

Anyway, I am going to try out this tutorial, it will sure be great for me - already planned different wild Pokémon music on different parts of region. I would like to ask: Where the heck you know all this from? You're amazing, did you know?

@liuyanghejerry: Which browser are you using? If Internet Explorer 6- or one of browsers using its rendering engine (Maxthon for example), it should not be a surprise. If you're using a more standards-compilant browser such as IE8 or Firefox and the rest, then I have no idea.

Megiddo-san
October 19th, 2008, 04:56 PM
I have double checked my hex and have tried both hex and decimal for music values, but it isn't working for me. This is the script that changes it. #org @begin
setvar 0x1014 0x298
setvar 0x1016 0x299
message @this
boxset 6
release
end
#org @this
= Music test.

ZodiacDaGreat
October 19th, 2008, 08:37 PM
@Megiddo - It doesn't work like that, you have to use it before a wildbattle or trainerbattle. How?

1. Well, find the song that the wildbattle/trainerbattle plays.
2. Setvar 0x1014 the song it plays. (Original Song)
3. Setvar 0x1016 to the song you want it to play.

Ao, in simple terms its changing the played music, through setvars, by setting the original song to 0x1014 and set a new song to 0x1016. If the vars don't work, it can be changed:
0xcfff64:
[14 10 00 00] // nr of 1st variable containing music number to replace
[15 10 00 00] // nr of 2nd variable containing music number to replace
[16 10 00 00] // nr of 1st variable containing the value to replace with
[17 10 00 00] // nr of 2nd variable containing the value to replace with
[FF FF 00 00] // value the vars have to be set to in order to disable the track loader
[55 E4 06 08] // std_func_getvaradress + 1; don't change it!
[0F D1 1D 08] // return adress + 1
[9C 32 4A 08] // channel table (usually you don't have to change it)
[CC 32 4A 08] // pointer to the music-pointer-table
Change 1410, 1510, 1610, 1710 to something that works, thats the veryr reason why MX, block quoted this part.

Anyway, Good News is you may see a tool soon :)

Megiddo-san
October 20th, 2008, 05:27 AM
I think I need new ones. I tried putting them before a trainerbattle in a script. Thanks. I'm going to try others.

Edit: I just made that work by using different variables. It needn't be in the same script.

Drayano
January 7th, 2010, 03:21 PM
I've tried to do this a couple times now and each time I try the game just stops; you try to load the game, the blue background of the intro opens, and it just stops there.

I've double checked the hex to make sure I've input it correctly and I've put it in the same locations as described on the tutorial, so I've also used the same pointer in the second part where I'm attaching it to the musicloader.

I tried toying around with the var numbers in the hex (the 14 10 00 00, 15 10 00 00 etc) but changing them didn't fix anything. As far as I can tell the Fire Red ROM started doing this intro freeze after I put in the hex that is in the first part of the tutorial.

Either way, I've tried this three odd times now and got the same result every time... would anyone happen to have any idea why the game keeps doing this whenever I put in the hex?

edit: Okay I took a look at AdvanceMap at the broken ROM and it seems that all of the tiles are broken :x

aar2697
August 7th, 2012, 05:53 PM
Drayano, it doesn't work with my ROM either for some reason. I'm having the same problem as you. Luckily I made a backup.

thanethane98
August 14th, 2012, 08:45 AM
Drayano, it doesn't work with my ROM either for some reason. I'm having the same problem as you. Luckily I made a backup.

I had the same problem at first, but I found out what I did wrong. You have to remember to flip your offset when putting it into the music loader. Such as, I had 0x810211 as my offset. So I originally put that in as 81 02 11 00, while I needed to put it in as 11 02 81 08. I'm not an expert with this, but I'm pretty sure that 08 always needs to go on the end of the offset, somebody can correct me if I'm wrong though.

Good luck!

Golden Empoleon
August 15th, 2012, 05:34 PM
When I go to this part Im kinda lost lol

01 49 08 47 00 00 [XX XX XX XX] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

And my pointer is F1 FE CF 08 also but everytime i do this from 0x1DD0F6 to 0x1DD10E
my rom will end up crashing.

thanethane98
August 15th, 2012, 09:05 PM
When I go to this part Im kinda lost lol

01 49 08 47 00 00 [XX XX XX XX] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

And my pointer is F1 FE CF 08 also but everytime i do this from 0x1DD0F6 to 0x1DD10E
my rom will end up crashing.

How exactly does it crash? When I originally did this, my hex editor actually expanded the rom when I typed in stuff like this, which leads to the ROM being unusable.

I've actually managed to get this working, but to do it I had to take a look at another hack that had successfully done this. Take a look at Azure Horizons if you're stuck, the makers of it have it inserted and working correctly so it's a great example.

Golden Empoleon
August 15th, 2012, 10:23 PM
Thanks thanethane98 for the input. :)
It didn't crash this time and you was right that
was a great example.

Now all I need help is the setvar.
Btw. I am using pokescript.

thanethane98
August 16th, 2012, 11:02 AM
Thanks thanethane98 for the input. :)
It didn't crash this time and you was right that
was a great example.

Now all I need help is the setvar.
Btw. I am using pokescript.
I believe with the modified version used in Azure Horizons it's 7030 and 7033. That worked for me in XSE, and it should work for you no matter what program you're using for scripting. :)

Team Fail
August 16th, 2012, 11:19 AM
I've actually been looking for something like this for the last little bit, actually. I'll have to give this a try and give it a shot at implementing it in a hack.

Although, with a repointed sound table, this will be fun.

thanethane98
August 16th, 2012, 11:50 AM
I've actually been looking for something like this for the last little bit, actually. I'll have to give this a try and give it a shot at implementing it in a hack.

Although, with a repointed sound table, this will be fun.

Good luck. :)

The only problem I've had with this at the moment is that it seems to have errors when you attempt to use it with a normal trainer (one that battles you when you're in their sight). Has anyone else had this issue?

Golden Empoleon
August 16th, 2012, 11:57 AM
#org $script
setvar 0x7030 0x297
setvar 0x7033 0xblah
trainerbattle 0x00 0x0001 $see $win
$see 1 = Battle me!
$win 1 = I lost.
message $after
$after 1 = You're tough.
boxset 6
release
end

This my script for pokescript
And it still not working for me.
Is it the same for xse :)

Jambo51
August 16th, 2012, 12:26 PM
#org $script
setvar 0x7030 0x297
setvar 0x7033 0xblah
trainerbattle 0x00 0x0001 $see $win
$see 1 = Battle me!
$win 1 = I lost.
message $after
$after 1 = You're tough.
boxset 6
release
end

This my script for pokescript
Is it the same for xse :)

This script won't work. Trainerbattles ONLY work if the first command in the script is the trainerbattle itself. The only exception to this is type 0x1 of trainerbattles.

That's why this method is limited. It can execute changes like regional music, or class based music if you're extremely careful and clever, but it's incapable of more complex changes.

Golden Empoleon
August 16th, 2012, 01:45 PM
This script won't work. Trainerbattles ONLY work if the first command in the script is the trainerbattle itself. The only exception to this is type 0x1 of trainerbattles.

That's why this method is limited. It can execute changes like regional music, or class based music if you're extremely careful and clever, but it's incapable of more complex changes.

Thanks Jambo51 for this input :D
Also, your last video on youtube was so
amazing i am really a fan but anyways so where
do i put the setvars or i should redue this script. :)

#org $script
trainerbattle 0x1 0x1 $see $win
$see 1 = Blah
$win 1 = Blah Blah.
message $after
$after 1 = Blah Blah Blah.
boxset 6
setvar 0x7030 0x297
setvar 0x7033 0xblah
release
end

Redid the script

Jambo51
August 16th, 2012, 03:47 PM
No, it's not possible to use this method to change the music for each trainer. This is because that setvar won't be used until after the battle is finished. It works for rival style trainers, since they execute parts of scripts before battling, but it won't work with normal trainers for the aforementioned reason. You can set the vars in a level script if all trainers in the area need a different music (a Team Rocket takeover of a place, for example), but you can't set each trainer in an area individually.

Golden Empoleon
August 16th, 2012, 06:30 PM
Okay I see what you are saying and its makes perfect
sense.

So the level script

#org $script
setvar 0x7030 0x297
setvar 0x7033 0xblah
release
end

and i put this in advance map
the area i chose (like you said a bad guys area)
script it to one of the green boxes idk lol
This is confusing in a good way :)

Golden Empoleon
August 17th, 2012, 11:25 AM
I believe with the modified version used in Azure Horizons it's 7030 and 7033. That worked for me in XSE, and it should work for you no matter what program you're using for scripting. :)

How do you make a level script :)

thanethane98
August 17th, 2012, 12:18 PM
How do you make a level script :)
I actually just learned how to do this today, lol. Here's the tutorial I used: link (http://www.pokecommunity.com/showpost.php?p=4414826&postcount=86)

By the way, I may try to develop a tool to insert this in at some point, once I've learned a bit more programming.

Golden Empoleon
August 17th, 2012, 12:55 PM
Thanks thanethane98 :)
And also Jambo51 :)
The credit goes to both of you.

It finally work!!!!
I will keep this link in mind.

thanethane98
August 24th, 2012, 07:41 PM
I'm currently looking for the offsets for this in emerald. I'll update this post when I find them.

sonic1
August 25th, 2012, 02:21 AM
Don't bother.

Here they are:
0x086B49C0 -> Offset of channel table
0x086B49F0 -> Offset of Music Table.

And the offsets you must start overwriting is 0x2E0130 (the music_loader routine)
~Sonic1

tajaros
March 8th, 2013, 02:38 AM
Since the revival rule doesn't work around here, I'm gonna post a fancy idea I thought about earlier this morning.

Some midi from later generations have more than 10 tracks which cannot be inserted in a gen 3 rom. But I think my idea can make a Firered or another rom like ruby and emerald play midi from new generations with tracks higher than 10. First split it into two parts, midi will have 10 tracks and the other 6. This is the case if the midi you want to play in your hack has 16 tracks. So I guess you have to loop the two at the same time and play them both at the same time and tada! A music with more than 10 tracks.

Though I haven't tested this out yet but when I do I'll be sure to inform you guys if it's working or not.

Omega Zero
March 8th, 2013, 08:42 PM
Since the revival rule doesn't work around here, I'm gonna post a fancy idea I thought about earlier this morning.

Some midi from later generations have more than 10 tracks which cannot be inserted in a gen 3 rom. But I think my idea can make a Firered or another rom like ruby and emerald play midi from new generations with tracks higher than 10. First split it into two parts, midi will have 10 tracks and the other 6. This is the case if the midi you want to play in your hack has 16 tracks. So I guess you have to loop the two at the same time and play them both at the same time and tada! A music with more than 10 tracks.

Though I haven't tested this out yet but when I do I'll be sure to inform you guys if it's working or not.

First of all this - http://www.pokecommunity.com/showpost.php?p=7559059&postcount=316
That alone gives you the ability to use up to 12 direct tracks in Pokemon firered, why would you need any more?
Yeah 16 would be nice but you can nearly always find dumbed down version of songs and most midis
have nearly duplicate tracks.

Second, how would you go about playing two songs at the same time?

tajaros
March 8th, 2013, 09:11 PM
First of all this - http://www.pokecommunity.com/showpost.php?p=7559059&postcount=316
That alone gives you the ability to use up to 12 direct tracks in Pokemon firered, why would you need any more?
Yeah 16 would be nice but you can nearly always find dumbed down version of songs and most midis
have nearly duplicate tracks.

Second, how would you go about playing two songs at the same time?

Hmm... It seems I misunderstood what this thread really for I have not really read the OP fully.

Haha, I thought this was for having two songs play at the same time haha... xD

Sorry for that disregard my previous post.

Chaos Rush
March 19th, 2013, 07:11 PM
First of all this - http://www.pokecommunity.com/showpost.php?p=7559059&postcount=316
That alone gives you the ability to use up to 12 direct tracks in Pokemon firered, why would you need any more?

Nonono you don't understand. What you linked to extends the Direct Sound limit from 5 to 12. In the GBA games, only 5 Direct Sound instruments can be playing at once. This allows 12. This does NOT allow a Sappy song to have 12 instruments, the limit is still 10. All it does it make it so that up to 12 Direct Sound instruments can be playing at once, which is possible even with 10 tracks, since you can have a single track play more than one note at the same time. In other words, in the GBA games unmodified, you can only have 5 Direct Sound instruments playing at once, and 5 "Game Boy" instruments playing at once, but you must limit it to 10 Sappy tracks total. With this extension, you can now have up to 12 Direct Sound instruments playing at once, and 5 "Game Boy" instruments playing at once, but you're still limited to 10 Sappy tracks.

What tajaros was talking about is if its possible to extend the maximum amount of Sappy tracks to 16. The thing you linked to just makes it so that you can have 12 Direct Sound notes playing at once, but the track limit is still 10.

tajaros
March 20th, 2013, 05:16 AM
Nonono you don't understand. What you linked to extends the Direct Sound limit from 5 to 12. In the GBA games, only 5 Direct Sound instruments can be playing at once. This allows 12. This does NOT allow a Sappy song to have 12 instruments, the limit is still 10. All it does it make it so that up to 12 Direct Sound instruments can be playing at once, which is possible even with 10 tracks, since you can have a single track play more than one note at the same time. In other words, in the GBA games unmodified, you can only have 5 Direct Sound instruments playing at once, and 5 "Game Boy" instruments playing at once, but you must limit it to 10 Sappy tracks total. With this extension, you can now have up to 12 Direct Sound instruments playing at once, and 5 "Game Boy" instruments playing at once, but you're still limited to 10 Sappy tracks.

What tajaros was talking about is if its possible to extend the maximum amount of Sappy tracks to 16. The thing you linked to just makes it so that you can have 12 Direct Sound notes playing at once, but the track limit is still 10.

Actually that's not what I am talking about. I should have explained further for example we have a 20 tracked Midi and you want it to be played in your game let's say we split the Midi to 10 each and just have the two songs play at the same time so it will look like you have the Midi playing as one.

Though if it's possible to make two music play at the same time.

Chaos Rush
March 20th, 2013, 05:52 AM
Actually that's not what I am talking about. I should have explained further for example we have a 20 tracked Midi and you want it to be played in your game let's say we split the Midi to 10 each and just have the two songs play at the same time so it will look like you have the Midi playing as one.

Though if it's possible to make two music play at the same time.
I knew what you're talking about, but, Omega Zero thought the Direct Sound extension lets you have up to 12 tracks playing, which is false, the Direct Sound extension just lets you have 12 Direct Sound notes playing at any given time.

Shiny Quagsire
March 24th, 2013, 03:47 PM
Actually that's not what I am talking about. I should have explained further for example we have a 20 tracked Midi and you want it to be played in your game let's say we split the Midi to 10 each and just have the two songs play at the same time so it will look like you have the Midi playing as one.

Though if it's possible to make two music play at the same time.

I doubt that it's possible to play two songs at the same time, since even with sounds, it usually has to stop one track to play the sound depending on how many tracks the song is. Either that or there are a few tracks (probably 2-6) reserved specifically for sound effects.

tajaros
March 24th, 2013, 04:09 PM
I doubt that it's possible to play two songs at the same time, since even with sounds, it usually has to stop one track to play the sound depending on how many tracks the song is. Either that or there are a few tracks (probably 2-6) reserved specifically for sound effects.

That would be cool if we can do that! We can play BW music properly haha... xD

Jambo51
March 24th, 2013, 10:37 PM
Yes, sounds and fanfares have separate memory, so that the main music pauses and resumes. No, you cannot abuse this fact to extend the number of tracks available in a song since it is a physical limit of the M4AA engine inside the given game. You'd have to rewrite the engine and vastly optimise it to be able to do what you want. Or did you think we didn't try numbers higher than 0xC in the limiter? Lol

ETA: the Sfx don't generally stop the music from playing, whereas fanfares do. You could exploit this behaviour to have "indefinite" fanfares, which would, in effect, emulate BW's behaviour with regard to certain music.

2 issues with this being, the game doesn't support indefinite fanfares (requires a length in music ticks (I think) to operate), and the physical coding to have this happen would not be easy.

DealNotTheDevil
April 16th, 2014, 01:00 PM
Don't bother.

Here they are:
0x086B49C0 -> Offset of channel table
0x086B49F0 -> Offset of Music Table.

And the offsets you must start overwriting is 0x2E0130 (the music_loader routine)
~Sonic1

I've tried inserting using these offsets, but all I get is a buzzing sound.
(with black and white flashing screen)
Haven't been able to even load the rom :/

Any help will be seriously seriously appreciated, as I've been looking at this for a long, long time.


EDIT:

As a matter of fact,
I've tried to "get the method correct" first for Firered.

I've copied everything, even the original addresses the OP used.
End result:

It's loads the intro, and hangs before "Press Start" is displayed.