Help with file compression

Discussion in 'NDS - ROM Hacking and Translations' started by BlueSword, May 10, 2009.

May 10, 2009

Help with file compression by BlueSword at 7:14 PM (1,502 Views / 0 Likes) 12 replies

  1. BlueSword
    OP

    Newcomer BlueSword Member

    Joined:
    May 10, 2009
    Messages:
    17
    Country:
    Mexico
    Hey guys,

    I decided to make a translation of it because it's not fair that the non-english speakers can't fully enjoy the game, also I want to learn more about hack translations, and I think this is the best place to do it

    I already know the basics, but i just found that the script files are compressed in one single file, "script.pac" and since i am an ignorant and all the documentation about file compresion I've found are just a pile of random docs impossible to understand for a beginner like me my question is

    Where do I start to figure out what kind of compression is and how to decompress/compress these files?

    Really, I need help with this, I hope anyone here can help me

    Thanks [​IMG]
     
  2. DarthNemesis

    Member DarthNemesis GBAtemp Maniac

    Joined:
    Feb 19, 2008
    Messages:
    1,208
    Country:
    United States
    First 4 bytes = # of files. Starting at 0x08, each file entry is 8 bytes (first 4 bytes = offset, last 4 bytes = length). Each entry is shifted right 4 bits (i.e. 46060000 02000000 means there is a 0x20 byte file at 0x6460), and accordingly, files are padded to the next 0x10. Each individual file is LZ77-compressed.
     
  3. BlueSword
    OP

    Newcomer BlueSword Member

    Joined:
    May 10, 2009
    Messages:
    17
    Country:
    Mexico
    Thanks for reply [​IMG]

    I don't know if I'm doing it right, but this is what i have done so far



    So there are 8A 0C 01 00 = 2,316,042,496 files in "script.pac", right?



    Now, the first file entry is this, right?

    [​IMG]


    Then, how do you know 46060000 02000000 means that there is a 0x20 byte file at 0x6460 and no in 0x6064?



    Now, I look for the byte at 0x6460, and I copy the string of 0x20 byte

    [​IMG]

    Then I create a new file and I paste the string, then I save the file with the name "0000000001", Im using Hex Workshop 6

    [​IMG]

    Finaly I decompress the file with BatchLZ77.exe and what get is this

    [​IMG]


    ... Im sure im doing it wrong, Can you please explain me

    how to extract and decompress the first file (or tell me where im wrong)?

    and where starts the second file entry? ( I suppose its defined in 48060000 4E000000, but im not sure)

    Thanks [​IMG]
     
  4. DarthNemesis

    Member DarthNemesis GBAtemp Maniac

    Joined:
    Feb 19, 2008
    Messages:
    1,208
    Country:
    United States
    Actually on second look it's only the first 2 bytes, so there are 0xC8A (3210) files.

    Code:
    Entry 1ÂÂEntry 2ÂÂÂÂOffsetÂÂ Length
    46060000 02000000ÂÂ 0x6460ÂÂ 0x0020
    48060000 4E000000ÂÂ 0x6480ÂÂ 0x04E0
    96060000 00000000ÂÂ 0x6960ÂÂ 0x0000
    (...a bunch more empty files...)
    96060000 1E000000ÂÂ 0x6960ÂÂ 0x01E0
    B4060000 0A000000ÂÂ 0x6B40ÂÂ 0x00A0
    BE060000 1B010000ÂÂ 0x6BE0ÂÂ 0x11B0
    D9070000 59000000ÂÂ 0x7D90ÂÂ 0x0590
    32080000 59000000ÂÂ 0x8320ÂÂ 0x0590
    8B080000 59000000ÂÂ 0x88B0ÂÂ 0x0590
    E4080000 63000000ÂÂ 0x8E40ÂÂ 0x0630
    47090000 55000000ÂÂ 0x9470ÂÂ 0x0550
    9C090000 83000000ÂÂ 0x99C0ÂÂ 0x0830
    1F0A0000 96000000ÂÂ 0xA1F0ÂÂ 0x0960
    etc.
    And that output looks right. Try it with a bigger file and you should see text.
     
  5. BlueSword
    OP

    Newcomer BlueSword Member

    Joined:
    May 10, 2009
    Messages:
    17
    Country:
    Mexico
    Well, I have already extracted these files

    Entry 1 Entry 2 Offset Length
    46060000 02000000 0x6460 0x0020
    48060000 4E000000 0x6480 0x04E0
    96060000 1E000000 0x6960 0x01E0
    B4060000 0A000000 0x6B40 0x00A0
    BE060000 1B010000 0x6BE0 0x11B0

    And named them File0001, File0002, ..., File0005 and I decompress them using BatchLZ77.exe, but I didn't found any text, I used Relative Search but still nothing

    I extracted a bigger file but it doesn't work either

    What Im doing wrong?
     
  6. DarthNemesis

    Member DarthNemesis GBAtemp Maniac

    Joined:
    Feb 19, 2008
    Messages:
    1,208
    Country:
    United States
    The text is encoded as 2-byte Shift-JIS, not 1-byte ASCII. Use CrystalTile2 instead of Hex Workshop and set TBL->Code Page to Japanese (Shift-JIS).
     
  7. BlueSword
    OP

    Newcomer BlueSword Member

    Joined:
    May 10, 2009
    Messages:
    17
    Country:
    Mexico
    Ok, i have done this

    1.- Open CrystalTile2
    2.- Select TBL>Code Page>Japanese (Shift-JIS)
    3.- File>Open>File0002.decompressed
    4.- I can only see some weird japanese symbols, so i try to do relative search with every word from the text of the beginning of the game
    5.- Tools>relative search...>In the "variab" textbox i write, for example "world"
    6.- I have to be honest, im stock here, I don't know what a heck is going on, there are so many options in this dialog box i dont know if i found something or not

    Darn, just when i feel i was making a progress im stuck again, can please tell me how to see the text?

    Thanks for your patient, you will be the first person in the credits of the translation, i hope you can help me
     
  8. DarthNemesis

    Member DarthNemesis GBAtemp Maniac

    Joined:
    Feb 19, 2008
    Messages:
    1,208
    Country:
    United States
    There are 3,210 different files. Why are you expecting that specific text to show up in the first one? I'd just start translating whatever text you find, but if you have to do it in order, you can try extracting all the files and using a file search utility like AstroGrep. You don't need to use relative search since you already know the encoding; just make sure to search using the 2-byte characters ('?????' rather than 'world').
     
  9. BlueSword
    OP

    Newcomer BlueSword Member

    Joined:
    May 10, 2009
    Messages:
    17
    Country:
    Mexico
    Oh, ok then im going to get the 3210 files first
     
  10. BlueSword
    OP

    Newcomer BlueSword Member

    Joined:
    May 10, 2009
    Messages:
    17
    Country:
    Mexico
    Good news, I found the first text of the game! [​IMG]

    The file is in 000BC230 with a length of 0BA0

    I decompress the extracted file (Text 0001) with BatchLZ77.exe and I get a second file (Text 0001.decompressed)

    I open this new file with CrystalTyle2, and select TBL>Code Page>Japanese (Shift-JIS) and bingo!

    [​IMG]

    At this point i don't make any changes to the file, I close the file and CrystalTyle2

    Now, I try BatchlZ77.exe to recompress the file "Text 0001.decompressed" to get a new third file (Text 0001.decompressed.compressed)

    At this point both files ("Text 0001" and "Text 0001.decompressed.compressed") should have exactly the same content and size, right? Since I just decompressed and recompressed the file "Text 0001" without making any changes, but no

    [​IMG]

    It took me around 3 hours to find the first text, and now i don't know what im doing wrong

    Here are the files

    Any help please? [​IMG]
     
  11. DarthNemesis

    Member DarthNemesis GBAtemp Maniac

    Joined:
    Feb 19, 2008
    Messages:
    1,208
    Country:
    United States
    No, different compression algorithms. It doesn't make any difference as far as the game cares, but you will want to write a program to recalculate the pointers when you edit a file.
     
  12. BlueSword
    OP

    Newcomer BlueSword Member

    Joined:
    May 10, 2009
    Messages:
    17
    Country:
    Mexico
    Oh, ok, but I don't get it at all [​IMG]

    Can you please recommend me some documentation about it to try to write that kind of program?

    Thanks in advance
     
  13. DarthNemesis

    Member DarthNemesis GBAtemp Maniac

    Joined:
    Feb 19, 2008
    Messages:
    1,208
    Country:
    United States

Share This Page