LZSS compressed files in Wii games

Discussion in 'Wii - Hacking' started by Poryhack, Oct 18, 2009.

Oct 18, 2009
  1. Poryhack
    OP

    Member Poryhack GBAtemp Fan

    Joined:
    Oct 18, 2009
    Messages:
    330
    Country:
    United States
    I guess I'm not sure if this applies to Wii games in general, but I recently decided to hunt for some files in Pokemon Battle Revolution and noticed that most of the interesting files are LZSS compressed. After some searching I found a tool called gbalzss which has apparently been successful in decompressing certain wii files in addition to GBA files. I tried it out on several of the files I had extracted with no luck; it was pretty apparent by looking at the output files that they were not decompressed properly. I did make sure to chop off the "LZSS" that was tacked onto the beginning of each file before doing this.

    A couple observations:
    -In traditional GBA/NDS/Wii compressed files there is a 4-byte header, the first byte of which specifies a compression method and the last 3 which give an decompressed filesize. The header is apparent here, but it is preceded by the identifier LZSS and it has a couple twists.
    -The compression method byte is left blank, but that isn't a major issue because we already know it is LZSS.
    -I am 99% sure the decompressed filesize is in big endian. As far as I can tell everything else, wii archive files included, are little endian.

    Download a sample file here.

    Does anybody have any insights on why gbalzss will not decompress these files correctly? Is anybody willing to do some debugging to figure out how wii games do it?

    EDIT: To clarify, I have already tried standard LZSS decompression as well as Nintendo's LZ77 (both variants), RL, and Huffman with no success.
     
  2. s3phir0th115

    Member s3phir0th115 GBAtemp Advanced Fan

    Joined:
    Dec 31, 2008
    Messages:
    700
    Country:
    United States
    I believe Triiforce has some code in it to deal with various compression types on the wii in order to work as it does. Maybe you could look at the source code and figure it out.

    I will say though, having injected virtual console games and just messed with wii games, I can say with confidence that compression with Nintendo games is royal pain in the ass. I wish they'd use one fucking compression type and stay with it instead of having a million different ones.
     
  3. WiiPower

    Member WiiPower GBAtemp Guru

    Joined:
    Oct 17, 2008
    Messages:
    8,165
    Country:
    Germany
    TriiForce source might help, but before i would try if it is able to load the game. If it does, you need to search for .dols. If there's only 1 and the rest is compressed or whatever, TriiForce decompression code is what you are looking for.
     
  4. Poryhack
    OP

    Member Poryhack GBAtemp Fan

    Joined:
    Oct 18, 2009
    Messages:
    330
    Country:
    United States
    PBR is an actual disc game though, not a VC/WiiWare game.

    I see that there are two variants of compression; 0x10 is what all the tools I've seen so far have used so I assume there's nothing different about how your code unpacks it. 0x11 could be what I'm looking for...

    Another question out of curiosity, why is it that LZSS and LZ77 are used interchangeably? At first I presumed they must be different but at least in the context of Nintendo's implementations they seem to be the same.
     
  5. WiiPower

    Member WiiPower GBAtemp Guru

    Joined:
    Oct 17, 2008
    Messages:
    8,165
    Country:
    Germany
    TriiForce has code to decompress LZ77 0x10 and 0x11. But no compress code.
     
  6. Poryhack
    OP

    Member Poryhack GBAtemp Fan

    Joined:
    Oct 18, 2009
    Messages:
    330
    Country:
    United States
    That wouldn't be an issue for what I'm trying to do. It's extract-only.
     
  7. Poryhack
    OP

    Member Poryhack GBAtemp Fan

    Joined:
    Oct 18, 2009
    Messages:
    330
    Country:
    United States
    I've tried and neither of the LZ77 variants work. I might as well mention that I previously tried Huffman and Run-Length for the hell of it.

    Am I missing something or is this compression just something different? Would the fact that the file seems to be big-endian have any effect on decompression (keeping in mind here that I have converted the 3-byte decompressed filesize to little endian)?
     
  8. stev418

    Member stev418 GBAtemp Fan

    Joined:
    Sep 25, 2007
    Messages:
    492
    Country:
    Australia
  9. Poryhack
    OP

    Member Poryhack GBAtemp Fan

    Joined:
    Oct 18, 2009
    Messages:
    330
    Country:
    United States
    No I haven't made any changes. It puzzled me as well when I saw that LZ77 was the norm... (I'm still operating under the assumption that they mean the same thing, correct me if I'm wrong.) On the other hand, how often have people actually looked at files in ISOs? People hack Brawl and MKWii but the vast majority of research here went towards WADs.

    DSdecmp is precisely what I used to test the 0x11 variant, with no luck. I don't expect there is any difference among the tools you listed.
     
  10. Omega Knight

    Member Omega Knight GBAtemp Regular

    Joined:
    Jul 29, 2007
    Messages:
    137
    Country:
    United States
    Wii.py also has compress (and decompress?) code. And about hacking WOD's, uhh, the conduit was hacked a bit.
     
  11. stev418

    Member stev418 GBAtemp Fan

    Joined:
    Sep 25, 2007
    Messages:
    492
    Country:
    Australia
    hmm : \ lol

    maybe since in wads LZ77 = LZSS, maybe in ISO LZSS = LZ77 ill whip out pokemon and have another look.
     
  12. Poryhack
    OP

    Member Poryhack GBAtemp Fan

    Joined:
    Oct 18, 2009
    Messages:
    330
    Country:
    United States
    I had the same thoughts, but after trying umpteen LZ77 decompression tools with no luck it appears that either they are not identical or something else is wrong.
     
  13. Poryhack
    OP

    Member Poryhack GBAtemp Fan

    Joined:
    Oct 18, 2009
    Messages:
    330
    Country:
    United States
    At this point I think that the implementation of LZSS used here is just plain different than the standards, which means I'm not going to find any kind of tool/sourcecode to help out.
     
  14. hcs

    Newcomer hcs Newbie

    Joined:
    Aug 23, 2009
    Messages:
    8
    Country:
    United States
    I've been doing some simple compression hacking lately, if you put the file back up I can take a look at it. The Conduit did have a LZSS-ish compression, fwiw.
     
  15. Poryhack
    OP

    Member Poryhack GBAtemp Fan

    Joined:
    Oct 18, 2009
    Messages:
    330
    Country:
    United States
    Ah, thank you in advance. Sorry about that, it's back up.
     
  16. hcs

    Newcomer hcs Newbie

    Joined:
    Aug 23, 2009
    Messages:
    8
    Country:
    United States
    Took a look, haven't had any luck yet, if you put up some more files I might be able to pick up the pattern better. I notice at least that there seems often to be 0xF? in front of literal strings.

    Better yet, consider posting it on XeNTaX, where someone might recognize it right away.
     
  17. Poryhack
    OP

    Member Poryhack GBAtemp Fan

    Joined:
    Oct 18, 2009
    Messages:
    330
    Country:
    United States
    My apologies for going AWOL, and I appreciate the advice. I just signed up and I'll post this just as soon as I'm approved.

    EDIT: Also wanted to say thanks for the fsys program of yours. At first I did not realize you had made that. Came in very handy to actually get me to the point where I could see these "LZSS" files.
     
  18. raydan

    Newcomer raydan Newbie

    Joined:
    Jan 13, 2010
    Messages:
    1
    Country:
    United States
    i am try to get PBR model too
    and i found a LZSS decompress code

    http://pastebin.com/f67678659

    the file is pkx_001.fsys
    i use gcfsysd.exe extract to 2 file pkx_001.000. pkx_001.001

    i use the above LZSS decompress code, it output a file, what next?


    any one still can help?
     

Share This Page