Compressing LyN engine .bin file

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
yunyl
Posts: 25
Joined: Sat Aug 18, 2018 3:22 pm

Compressing LyN engine .bin file

Post by yunyl »

Hello there aluigi, you made this BMS script for Just Dance 4 (the latest one in your website doesn't work for me so the script below works perfect) that lets us decompress bin archives of LyN Engine.

So fff02f6c_compressed is from Just Dance 4 game files. I use the BMS script and get fff02f6c_decompressed as a result. I wanna know if there is a way to compress fff02f6c_decompressed back to fff02f6c_compressed. I want it to be exactly same as original :geek:

I am asking this because I am trying to mod the game and the engine needs to read it compressed.
https://mega.nz/folder/KBx2VAoY#ZZ5rvKuiM5kcCozuCya42Q
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Compressing LyN engine .bin file

Post by aluigi »

Try the following for building the compressed file:

Code: Select all

comtype lzo1x_compress
math CHUNK_SIZE = 0x40000
math CHUNK_SIZE - 4

get FILE_SIZE asize
xmath CHUNKS "FILE_SIZE / CHUNK_SIZE"
if FILE_SIZE % CHUNK_SIZE
    math CHUNKS + 1
endif

log MEMORY_FILE 0 0
put 1 long MEMORY_FILE
put CHUNKS long MEMORY_FILE
savepos CHUNKS_OFF MEMORY_FILE
for i = 0 < CHUNKS
    put 0 long MEMORY_FILE
next i

append
for i = 0 < CHUNKS
    savepos MEM_OFF MEMORY_FILE

    math SIZE = CHUNK_SIZE
    if SIZE > FILE_SIZE
        math SIZE = FILE_SIZE
    endif
    savepos OFFSET

    clog MEMORY_FILE OFFSET SIZE SIZE
    goto SIZE 0 SEEK_CUR
    math FILE_SIZE - SIZE

    get TMP asize MEMORY_FILE
    math TMP - MEM_OFF

    math MEM_OFF - 4
    putvarchr MEMORY_FILE CHUNKS_OFF TMP long
    math CHUNKS_OFF + 4
next i
append

get TMP asize MEMORY_FILE
get NAME filename
string NAME + ".compressed"
log NAME 0 TMP MEMORY_FILE
yunyl
Posts: 25
Joined: Sat Aug 18, 2018 3:22 pm

Re: Compressing LyN engine .bin file

Post by yunyl »

Thank you, you're the best! :)
yunyl
Posts: 25
Joined: Sat Aug 18, 2018 3:22 pm

Re: Compressing LyN engine .bin file

Post by yunyl »

Hey aluigi, threw an error and crashed, the sizes of the original compressed bin and the one which was compressed with the BMS script you sent are not same. Their content are not identical, you are able to see strings in a hex editor in original compressed bin while you can't with the custom compressed one. They are not identical so the game does not know what to do
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Compressing LyN engine .bin file

Post by aluigi »

If you run the decompression script on the generated file it should work (I tested it).
The compressed file can't be the same of the original one because quickbms and the game use different lzo1x settings (not affecting the decompression), but I have no idea why the game crashes with the new one.