Repointing music in the .sdat file?

Discussion in 'NDS - ROM Hacking and Translations' started by Masterlink, Apr 9, 2016.

  1. Masterlink
    OP

    Masterlink Member

    Newcomer
    12
    4
    Aug 26, 2015
    Hey guys, I've been doing some DS music hacking for fun and so far it hasn't been that hard, however, oftentimes I find that my .sseq files are bigger than the tracks I want to replace in the ROM, so I went to Google to see if someone has managed to repoint the music (so I can insert it in the huge empty areas of the ROM I'm working with instead of the original music slot), and apparently someone did, and he said that there is a table at the start of the .sdat file that points to each sequence on the ROM, which I assume is part of the FAT section, but that's as far as I got; I don't really know what to do there. I'm quite new to hacking DS games, and unfortunately my music knowledge isn't going to help me here, so that's why I made this thread. I was going to contact the person in question, but apparently he disappeared from the internet, so...

    tl;dr: How do I repoint the music so I can insert songs that are bigger than the originals?

    I hope someone can give me a hand here.

    Edit: It's also worth noting that I've been reading some documentation about the .sdat files, but I don't think I fully understand everything, especially because in some they use a C/C++ code that I doubt I can use if I'm editing everything directly with a hex editor.
     
    Last edited by Masterlink, Apr 9, 2016
  2. Kurausukun

    Kurausukun GBAtemp Regular

    Member
    211
    40
    Apr 6, 2014
    United States
    It's probably gonna be hard if you don't have at least some basic knowledge of bits, bytes, and hex editing. The SDAT format is documented pretty well here: http://www.feshrine.net/hacking/doc/nds-sdat.php

    If there's something specific you don't understand about how the documentation is presented, I can try to explain it, but keep in mind I'm also struggling with getting some stuff to work.

    Also, could you tell me what you're using to replace the SSEQ files? Just out of curiosity.
     
  3. Masterlink
    OP

    Masterlink Member

    Newcomer
    12
    4
    Aug 26, 2015
    I do have knowledge on that, don't worry. I'm not using anything to insert the .sseq files because I've heard the programs are quite buggy, so I just open the ROM in a hex editor, go to the where the original music data is stored and then I just paste my .sseq in there, if it was smaller than the original (which is the case most of the time), then I fill the leftover bytes with 00 to not break anything. So far it works just fine, but I'd like to have more liberties with custom music.

    Now, yeah, I've read that document, but as I said, it doesn't help me because it explains stuff with a C or C++ code according to Google, and I unfortunately don't know anything about real programming (yet). I guess it's meant to be used with programs? Even so, I don't know how to code programs, and the game I'm hacking is so niche nobody has bothered to make even a save editor.
     
  4. Kurausukun

    Kurausukun GBAtemp Regular

    Member
    211
    40
    Apr 6, 2014
    United States
    You don't really need to know C to know what it's talking about. I suppose you could put that code into a C document, but it wouldn't really do anything, it's just a definition. It's just telling you what metadata is stored where in the block headers. For example, in its documentation for the initial header, it has the following line:

    s8 type[4]; // 'SDAT'

    s8 (the "s" I'm guessing stands for short) means "8-bits" (1 byte) and the [4] means it's an array of 4 of these; so we have 4 8-bit values in a row for a total of 32 bits to represent the type as a string that reads "SDAT." The initial header doesn't actually contain any real data, it just gives the offsets and sizes of the rest of the blocks. Since you've been using smaller files and adding in zeroes to compensate, none of the sizes or offsets have changed, but if you make a bigger file, you'll need to edit the information both in the initial header and the SSEQ block header. I believe the SYMB and INFO blocks are also relevant for pointing to the right offsets, but I haven't actually looked at that myself yet. Does that help you understand it a little better?
     
  5. Masterlink
    OP

    Masterlink Member

    Newcomer
    12
    4
    Aug 26, 2015
    Ah, yes, thank you. I'm reading through the document again and I think I'm finally beginning to understand. However, there is something that I don't quite get: If I want to add new music - and make the old slots point to them instead of the originals because what I want to add doesn't fit in there - do I just add it at the end of the .sdat file, making it bigger? Or would that break the ROM? Because apparently I can't put music in the empty areas of the ROM like I wanted because the music offsets in the FAT area have to point inside the .sdat file instead of the ROM as a whole. I apologize if it's a stupid question, but well, one has to start from somewhere, right?

    But still, thanks a lot; I now know more or less what I have to edit, it's just that little thing that I need cleared up so I can start working again.

    Edit: Never mind! Did the experiment and it was successful. Thanks for the help, Kurausukun!
     
    Last edited by Masterlink, Apr 10, 2016