LZSS? Compression

Doubts, help and support about QuickBMS and other game research tools
FarOut
Posts: 1
Joined: Thu Aug 16, 2018 2:59 am

LZSS? Compression

Post by FarOut »

I have decompressed this TIM file of a PS1 game by using the game's ASM code, but I need to re-compress it now.

It seems to be a LZSS-like compression. 1st byte is 0x01, the next 4 bytes are the final size, the rest is the compressed data, with 2-byte flags to declare literal and compressed. Compressed bytes are 16-bit too: 5 bits for length (plus 3) and 11 bits for distance (plus 1).

See the attached files for compressed and uncompressed files.

This is what I've tried without success:

Code: Select all

comtype lzss "11 5 2 2 0"
IDString "\x01"
get SIZE long
savepos OFFSET
get ZSIZE asize
math ZSIZE - OFFSET
clog test OFFSET ZSIZE SIZE


Any help would be infinitely appreciated!
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: LZSS? Compression

Post by aluigi »

Code: Select all

log MEMORY_FILE 0 0
put 0x01 byte MEMORY_FILE
get SIZE asize
put SIZE long MEMORY_FILE
append
comtype lzss_compress "11 5 2 2 0"
clog MEMORY_FILE 0 SIZE SIZE
append
get SIZE asize MEMORY_FILE
log "new_file.dat" 0 SIZE MEMORY_FILE