ROM Hack Telling the Game to play a STRM instead of SSEQ

Munchulax

Member
OP
Newcomer
Joined
Jul 12, 2012
Messages
11
Trophies
1
XP
428
Country
United States
I have some custom music that I made that I have successfully inserted into the game's sound_data.sdat as a STRM file, but the game obviously will continue playing the SSEQ unless I repoint or recode some parts of the games code. I know how to repoint music, but I don't think that would work here because the game would try to play the STRM as a SSEQ and that would fail (correct me if I'm wrong). Is there any known way to change the way the game loads the music? I'm hacking the third Phoenix Wright (T&T) game if that helps in any way. Thanks!
 

Prof. 9

Well-Known Member
Member
Joined
Jun 17, 2008
Messages
324
Trophies
1
Location
The Netherlands
Website
twitter.com
XP
853
Country
Netherlands
You need slightly advanced ASM hacking to do this in most cases. Find the routine that starts SSEQ playback and the one that starts STRM playback, log or search for calls to the SSEQ routine somehow and replace them with calls to the STRM routine.
 

Munchulax

Member
OP
Newcomer
Joined
Jul 12, 2012
Messages
11
Trophies
1
XP
428
Country
United States
Maybe just convert the STRM to SSEQ?

Also why would you want to change music in Phoenix Wright? The music in those games is awesome

If you must know, if trying to bring the music used in the GBA version of the third game into T&T because the music is much more epic in my opinion. I'm kinda doing what CAPCOM did with some of the songs in Apollo Justice (Klavier's theme for example).
 

Munchulax

Member
OP
Newcomer
Joined
Jul 12, 2012
Messages
11
Trophies
1
XP
428
Country
United States
You need slightly advanced ASM hacking to do this in most cases. Find the routine that starts SSEQ playback and the one that starts STRM playback, log or search for calls to the SSEQ routine somehow and replace them with calls to the STRM routine.

But, if I did this then the rest of the music from the first and second games (SSEQ's) that are in this game wouldn't be able to play anymore, right?

And I'm not really good with ASM at all yet :(
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,321
Country
United Kingdom
What Prof. 9 said though there might be an alternative depending upon how much you want to do- http://gbatemp.net/threads/playing-streamed-audio-in-nsmb.331736/ (general idea was the wave file was sampled and piece by piece converted to a bank and then a SSEQ that played sample 1,2,3..... was made).

As for doing it properly the DS SDAT stuff looks somewhat like an include with relatively simple commands rather than a complex developer coded C function so you might not require ASM skills quite as advanced (get it to play another SSEQ first and move from there if you are going to try) as you are probably imagining right now
If you do head down this path I would be quite interested in seeing what you encounter- most SSEQ work happens around repointing and replacement of files as a whole.
 

Dirbaio

Well-Known Member
Member
Joined
Sep 26, 2010
Messages
158
Trophies
0
Age
111
Location
Spain
Website
dirbaio.net
XP
108
Country
What Prof. 9 said though there might be an alternative depending upon how much you want to do- http://gbatemp.net/threads/playing-streamed-audio-in-nsmb.331736/ (general idea was the wave file was sampled and piece by piece converted to a bank and then a SSEQ that played sample 1,2,3..... was made).
Well, the thing is that isn't really "streamed" music. All these samples will be loaded when the sequence is loaded so they all have to fit in RAM at the same time. And the limit in size is NOT the RAM size, many games (NSMB for example) load sounds to a separate sound heap which is SMALL. So this is useful for playing very short music tracks only.

I actually wanted to do the same thing with NSMB before, because streamed music is much cooler than SSEQ, you can basically convert anything into a PCM stream :)
The main problem is: Nintendo's compiler seems to remove library functions that aren't used. NSMB doesn't use STRM at all, so there's NO STRM function code at all in the ROM. This will be the case with most other NDS games that don't use STRM. I got tired of the SDAT crap, and I coded my own streaming :)

https://github.com/Dirbaio/NSMBCR/blob/master/source/soundThread.cpp
https://github.com/Dirbaio/NSMBCR/blob/master/source/wavplayer.cpp

(It's compiled as a NSMB-Editor ASM hack, read more here: http://nsmbhd.net/thread/1281-how-asm-hacks-are-setup-tutorial/)

I had to run the streaming on a separate thread, otherwise it would lag the game. Also streaming is very CPU-intensive, so depending on your game it might not be possible at all, either the game will lag (if you set the streaming thread's priority higher than the game's) or the stream will stutter and lag (if you set it lower). Luckily NSMB isn't a very CPU-intensive game, and it works fine.
 

Munchulax

Member
OP
Newcomer
Joined
Jul 12, 2012
Messages
11
Trophies
1
XP
428
Country
United States
I actually wanted to do the same thing with NSMB before, because streamed music is much cooler than SSEQ, you can basically convert anything into a PCM stream
The main problem is: Nintendo's compiler seems to remove library functions that aren't used. NSMB doesn't use STRM at all, so there's NO STRM function code at all in the ROM. This will be the case with most other NDS games that don't use STRM.

I had no idea that if a game doesn't have STRM that the code isn't even there. I guess I just assumed that since Apollo Justice used STRM playback for some of the music, that Trials and Tribulations would at least have the code in there I guess.


So, how would I insert this ASM hack into Trials and Tribulations? Would I use the method on the site above? I would think that I can't, because the ROM is totally different in every way, but I guess I could be wrong too. Sorry if I'm asking too many questions, I'm still pretty new to NDS hacking, I'm more experienced with GBC hacking (I don't really know ASM though)
 

Dirbaio

Well-Known Member
Member
Joined
Sep 26, 2010
Messages
158
Trophies
0
Age
111
Location
Spain
Website
dirbaio.net
XP
108
Country
About the code not being there, well, it depends on the game. I know for sure that Nintendo's compiler leaves out unused library functions. The compiler automatically removes unused functions to save RAM.
And I'm pretty sure that there's no STRM code in NSMB, I've identified every single sound function from NitroSDK, and no trace of STRM stuff.

To compile that thing, yes, you can use NSMBe :P
You'll need to find:
- the correct arenaoffs address. Put it in arenaoffs.txt
- the correct adresses of all the library functions that the code uses. Put them in symbols.x
- Change the hook adresses in soundThread.cpp. The first one can be anything that gets run when the game starts. The other ones are hooks from the game's functions to start/stop music.
Also this doesn't play .STRM files. It plays two 8bit mono PCM files, one for each channel. You have to give the file ID of the left file, the rigth file is that file ID + 1.

Maybe you'll have to tweak other stuff, I don't know if it will be hard to get it working or not.
Good luck!
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • Bunjolio @ Bunjolio:
    our school network and chrome policies block stuff too
  • Bunjolio @ Bunjolio:
    alot of yt to mp3 sites are blocked by light speed for "Security"
  • SylverReZ @ SylverReZ:
    It was easy to bypass some of the restrictions, as one of the admins left a registry key in the administrative shares drive, which allowed me to get around the blocking of some sites.
  • Bunjolio @ Bunjolio:
    tf does tta mean
  • Bunjolio @ Bunjolio:
    yeah this is chrome os
  • Bunjolio @ Bunjolio:
    cant do shit
  • SylverReZ @ SylverReZ:
    @Bunjolio, Wdym 'TTA'?
  • Bunjolio @ Bunjolio:
    that* as in why yt to mp3 sites are blocked for security
  • SylverReZ @ SylverReZ:
    @Bunjolio, Remember when YouTubetoMP3 was a thing back in the 2010s?
  • SylverReZ @ SylverReZ:
    Until YT updated some stuffs and broke the website.
  • Bunjolio @ Bunjolio:
    I was 2 in 2010
  • SylverReZ @ SylverReZ:
    Oh lol
  • Bunjolio @ Bunjolio:
    lol
  • SylverReZ @ SylverReZ:
    This was in the Minecraft-era.
  • AncientBoi @ AncientBoi:
    lol Bun rockin out at 2 :rofl2:
  • BakerMan @ BakerMan:
    same tbh
  • AncientBoi @ AncientBoi:
    ♫ Mama hully gully, Papa hully gully, Baby hully gully too:rofl2:
  • AncientBoi @ AncientBoi:
    Oh god, I really am old. lol
  • Sicklyboy @ Sicklyboy:
    @SylverReZ, sup Sylv!
    +1
  • AncientBoi @ AncientBoi:
    Anyway, I gotta go to the store. L8er guys. Oops, I better put some clothes on :shy::tpi::rofl2:
  • SylverReZ @ SylverReZ:
    @Sicklyboy, Hey there Sickly.
  • SylverReZ @ SylverReZ:
    @AncientBoi, Make sure the cops don't see that.
    hazbeans @ hazbeans: hi