Decompressing and recompressing files in Tales of Rebirth PsP

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
Haken
Posts: 1
Joined: Fri Jul 16, 2021 2:21 am

Decompressing and recompressing files in Tales of Rebirth PsP

Post by Haken »

This game uses LZSS compression(i think) for some files, i have managed to make a simple decompressor in c#, but i'm struggling with compresssing it back. Tried to see if i could do it with quickbms but the decompressed result was different from the decompressed by the game, maybe probably because the window must be initialized with a pattern of data. Is it possible do decompress/compress these files with quickbms?

compressed.bin

default window.bin

uncompressed(game).BIN

uncompressed(quickbms).bin
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Decompressing and recompressing files in Tales of Rebirth PsP

Post by aluigi »

It's just the normal lzss with the window initialized using a NUL byte rather than the usual space (0x20).

Decompress script:

Code: Select all

comtype lzss0
get ZIP byte    # 1
get ZSIZE long
get SIZE long
savepos OFFSET
get NAME basename
clog NAME OFFSET ZSIZE SIZE


Compress script:

Code: Select all

comtype lzss0_compress
get SIZE asize
log MEMORY_FILE 0 0
put 1 byte MEMORY_FILE
put 0 long MEMORY_FILE
put SIZE long MEMORY_FILE
savepos OFFSET MEMORY_FILE
append
clog MEMORY_FILE 0 SIZE SIZE
append
get ZSIZE asize MEMORY_FILE
math ZSIZE - OFFSET
goto 1 MEMORY_FILE
put ZSIZE long MEMORY_FILE
get SIZE asize MEMORY_FILE
get NAME basename
log NAME 0 SIZE MEMORY_FILE