NDS text pointers

Discussion in 'NDS - ROM Hacking and Translations' started by joesteve1914, Feb 14, 2014.

  1. joesteve1914
    OP

    joesteve1914 GBAtemp Fan

    Member
    335
    134
    Jul 31, 2012
    United States
    (The game is Tingle's Love Balloon Trip)

    Most of the text of this game is in lang.bin (there may be some in the various .olz files as well). The resLib files contain graphics (3d and 2d) and each has a .viw file (lists the files) and a .inf file (lists the sizes of the files). The .olz files do things like loading music, graphics and other game mechanics that don't need to be modified for translation.

    So I'm thinking that the pointers for the text are most likely in lang.bin. I'm looking for a way to make room for more text. The lines end with FF FF, which seems to indicate its end. However, simply moving this a byte forward causes the text to glitch and sometimes the game won't even boot. Does anyone know how I could find the pointers and modify them to repoint the text somewhere else (There's a lot of free space in lang.bin)?
     
  2. Kelebek

    Kelebek GBAtemp Regular

    Member
    165
    62
    May 25, 2012
    Firstly, how did you even get the text to work? It's not SJIS, but there seems to be some ASCII with the first character being wrong. it seems to be a like a font map instead. Did you figure out how to get at the real text?

    Either way, so far this is what I found:

    There's 6 tables inside the file, a header of length 0x10, short table count, long entry count in the first table, and 0xA blank bytes.

    Then each table has a 0x10 byte entry after that. Each entry is: long table number, long table start position (absolute), long text entry start (absolute), long table length. A blank 0x10 bytes after the tables.

    So our first table starts at 0x80, its text begins at 0x01fe00, and the table is 0x1091c0 long.

    Each string entry in the tables are 8 bytes, short unknown, short unknown, short unknown (character code?), short length.

    The variables are really strange, but I added 0x10 bytes to the first string, changed the length from 0a to 1a, as well as fixed all the other tables positions, and I'm not getting any text corruption. I tried again without editing the length of the string and made the string 2 bytes longer, and *all* the text disappeared, just to make sure editing the length worked.

    So yeah, it seems all you need to edit is that length variable, there doesn't seem to be any sort of pointer though which seems weird. The first 2 shorts seem like it, but I can't figure out how it works though. The first 5 entries just go up in 1s, then all of a sudden it jumps to 35 on the 6th entry. When the first variable goes up 1, the second variable resets. Maybe different scenes or something? Even the empty tables go up in weird amounts. Ah well, maybe you can figure it out. Hopefully just editing the length should let you do what you want though.
     
  3. joesteve1914
    OP

    joesteve1914 GBAtemp Fan

    Member
    335
    134
    Jul 31, 2012
    United States
    Yes, its custom encoded.

    Here's the table-

    Warning: Spoilers inside!



    Anyways, thanks I'll take a look at it.
     
  4. Kelebek

    Kelebek GBAtemp Regular

    Member
    165
    62
    May 25, 2012
    Ah, nice.
     
  5. joesteve1914
    OP

    joesteve1914 GBAtemp Fan

    Member
    335
    134
    Jul 31, 2012
    United States
    Sorry for asking again, but how do you know which length goes to what string?
     
  6. Kelebek

    Kelebek GBAtemp Regular

    Member
    165
    62
    May 25, 2012
    It's in order. The first entry at 0x80 will be the first string at 0x01fe00, the second entry at 0x88 will be the second string (so it'll be at 0x0a + 0x01fe00) and so on.
     
  7. joesteve1914
    OP

    joesteve1914 GBAtemp Fan

    Member
    335
    134
    Jul 31, 2012
    United States
    So, say I wanted to edit the text at 55D16, I would have to count all the way to that?
     
  8. Kelebek

    Kelebek GBAtemp Regular

    Member
    165
    62
    May 25, 2012
    As far as I can see, yeah... Since there doesn't seem to be any actual pointers to text location. You should make some tools to dump the text out to edit, and recompile the file for you.
     
  9. joesteve1914
    OP

    joesteve1914 GBAtemp Fan

    Member
    335
    134
    Jul 31, 2012
    United States
    So how could I figure out where the other pointer tables are?
     
  10. Kelebek

    Kelebek GBAtemp Regular

    Member
    165
    62
    May 25, 2012
    What do you mean, what other pointers?
     
  11. joesteve1914
    OP

    joesteve1914 GBAtemp Fan

    Member
    335
    134
    Jul 31, 2012
    United States
    Actually nvm I read your post wrong.
     
  12. Kelebek

    Kelebek GBAtemp Regular

    Member
    165
    62
    May 25, 2012
    Yeah, they're all defined in the first 0x80 bytes as I said. Table 0 is at 0x10, table 1 is 0x20, table 2 is 0x30 etc down to 0x60. The start position of the table is just 4 bytes after that, so first table location is at 0x14, second at 0x24, third 0x34 etc.

    Here I made a little graphic for you, but it's sorta hard to see, I quickly ran out of colours and it's over the top of other text. Hope you can see it though. The actual table is the whole line (0x10 bytes), not just the little bit I covered, I'm just pointing out where the numbers are from, and where the start positions are. After the 4 bytes of the start positions, the next 4 is where the text starts for that table, and the final 4 after that are the length of the table.

    You'll need to edit all of those if you change text. You'll need to change the length of the first table, and also change the start positions of the tables below it as well.

    Warning: Spoilers inside!
     
  13. joesteve1914
    OP

    joesteve1914 GBAtemp Fan

    Member
    335
    134
    Jul 31, 2012
    United States
    Thanks! That helps a lot!