Telling the Game to play a STRM instead of SSEQ

Discussion in 'NDS - ROM Hacking and Translations' started by Munchulax, Jan 7, 2013.

Jan 7, 2013
  1. Munchulax
    OP

    Newcomer Munchulax Newbie

    Joined:
    Jul 12, 2012
    Messages:
    7
    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!
     
  2. Prof. 9

    Member Prof. 9 GBAtemp Fan

    Joined:
    Jun 17, 2008
    Messages:
    316
    Location:
    The Netherlands
    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.
     
  3. Janthran

    Member Janthran Solarian

    Joined:
    Sep 17, 2011
    Messages:
    3,777
    Location:
    The Pacific Northwet
    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
     
  4. Munchulax
    OP

    Newcomer Munchulax Newbie

    Joined:
    Jul 12, 2012
    Messages:
    7
    Country:
    United States
    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).
     
  5. Munchulax
    OP

    Newcomer Munchulax Newbie

    Joined:
    Jul 12, 2012
    Messages:
    7
    Country:
    United States
    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 :(
     
  6. FAST6191

    Reporter FAST6191 Techromancer

    pip
    Joined:
    Nov 21, 2005
    Messages:
    21,712
    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.
     
  7. Dirbaio

    Member Dirbaio GBAtemp Regular

    Joined:
    Sep 26, 2010
    Messages:
    158
    Location:
    Spain
    Country:
    Spain
    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.
     
  8. Munchulax
    OP

    Newcomer Munchulax Newbie

    Joined:
    Jul 12, 2012
    Messages:
    7
    Country:
    United States
    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)
     
  9. Dirbaio

    Member Dirbaio GBAtemp Regular

    Joined:
    Sep 26, 2010
    Messages:
    158
    Location:
    Spain
    Country:
    Spain
    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!
     

Share This Page