ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Tue Dec 01, 2020 1:59 am

All times are UTC




Post new topic  Reply to topic  [ 14 posts ] 
Author Message
 Post subject: Final Fantasy 1 (3DS)
PostPosted: Tue Feb 23, 2016 10:01 am 

Joined: Tue Sep 08, 2015 11:27 am
Posts: 64
Update of the PSP script, same custom compression. All tables are aligned to 0x80 bytes so I've added dummy dstring reads. Original script by aluigi: http://aluigi.altervista.org/bms/ff1psp.bms
Code:
# Final Fantasy 1 PSP
# script for QuickBMS http://quickbms.aluigi.org

get FILES long
get FULLSIZE long
getdstring DUMMY 0x78

for i = 0 < FILES
    getdstring NAME 24
    get PCK_OFFSET long
    get ZSIZE long
    get SIZE long
    savepos INFO_OFFSET

    if ZSIZE != SIZE
        log NAME PCK_OFFSET ZSIZE
    else
        goto PCK_OFFSET

        get XFILES long
        get FULLSIZE long
        getdstring DUMMY 0x78
        for j = 0 < XFILES
            getdstring NAME 24
            get OFFSET long
            get ZSIZE long
            get SIZE long
            getdstring DUMMY 0x5C
            math OFFSET += PCK_OFFSET
            log NAME OFFSET SIZE
        next j
    endif

    goto INFO_OFFSET
    getdstring DUMMY 0x5C
next i


Top
   
PostPosted: Wed Feb 24, 2016 11:11 am 

Joined: Wed Feb 24, 2016 11:08 am
Posts: 35
Thanks! That was something I was looking for!
Could you help me to decompress/recompress the wp16-compressed files inside of the .dpk file?
I want to start a translation for this game^^

I got a Link where someone made a compressor/decompressor for the PSP-Version of this game but the Downloads aren't available anymore.
http://romxhack.esforos.com/compresion- ... a-wp16-t44


Top
   
PostPosted: Wed Feb 24, 2016 12:13 pm 

Joined: Tue Sep 08, 2015 11:27 am
Posts: 64
Right, so it uses LZSS with 32-bit flags, then normal LZSS, 16 bits for uncompressed data, 16-bit compressed data. .: Does QuickBMS have this compression implemented?


Top
   
PostPosted: Wed Feb 24, 2016 1:41 pm 

Joined: Mon Aug 03, 2015 7:51 am
Posts: 4
Here's a little C program that decompresses a WP16-compressed file (given as the first argument) to stdout: http://xen.firefly.nu/up/wp16.c.html. It should work fine on *NIX, don't know how useful it is on Windows though.

So as einstein95 mentioned this compression is very similar to LZSS. First there's a char[4] magic ("Wp16") and 32-bit little-endian filesize. Then there's a 32-bit "flags" field indicating whether each next 16-bit word is to be copied verbatim or to be treated as a backref. The bits in the flags field are indexed byte by byte from least to most significant bit, which is why I store it as u8[4] rather than u32 (to make it easier to index properly). Then there are 32 16-bit words corresponding to the 32 bits of the flag field. If the corresponding flag bit is 1, the word is copied verbatim. If it is 0, it's a backref (read as little-endian) that looks like "dddddddd dddccccc" where d bits form the distance and c bits the count. This indicates to copy (c + 2) words from the output history at distance d, i.e. c=3 d=5 would repeat the last 10 bytes.

That's all there is to it--hopefully someone could write a BMS script to decompress from that description.


Top
   
PostPosted: Thu Feb 25, 2016 4:30 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 11845
Well done FireFly, I will add your function to the next version of quickbms.


Top
   
PostPosted: Thu Feb 25, 2016 8:06 pm 

Joined: Wed Feb 24, 2016 11:08 am
Posts: 35
aluigi wrote:
Well done FireFly, I will add your function to the next version of quickbms.

tell me when it's ready :D
Want to compress/decompress the files :D


Top
   
PostPosted: Thu Feb 25, 2016 9:56 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 11845
Does someone have some sample files?

@ChrisX930
There is no recompression code available, while for decompression you can try the FireFly code (yeah stdout is bad but you can edit the code easily).


Top
   
PostPosted: Thu Feb 25, 2016 10:38 pm 

Joined: Wed Feb 24, 2016 11:08 am
Posts: 35
aluigi wrote:
Does someone have some sample files?

@ChrisX930
There is no recompression code available, while for decompression you can try the FireFly code (yeah stdout is bad but you can edit the code easily).


Hopefully there will be a recompression code sometime.
Uploaded a few PCK-Files (Extracted from dpk-file)


Attachments:
PCK Files.zip [227.26 KiB]
Downloaded 166 times
Top
   
PostPosted: Fri Feb 26, 2016 11:19 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 11845
The code of FireFly seems to work correctly.
Are you sure that recompression is really necessary? Maybe the loading code decompresses them only if they contain the Wp16 magic.
If it's really necessary then an option can be a fake compressor, it's a solution used sometimes to avoid writing a full compressor: basically ignore the compression window and stores the data in readable form with the compressed size bigger than the non-compressed one.


Top
   
PostPosted: Sat Feb 27, 2016 12:48 am 

Joined: Wed Feb 24, 2016 11:08 am
Posts: 35
aluigi wrote:
The code of FireFly seems to work correctly.
Are you sure that recompression is really necessary? Maybe the loading code decompresses them only if they contain the Wp16 magic.
If it's really necessary then an option can be a fake compressor, it's a solution used sometimes to avoid writing a full compressor: basically ignore the compression window and stores the data in readable form with the compressed size bigger than the non-compressed one.

Not sure if we need to recompress them completely. We've to test it out.


Top
   
PostPosted: Tue Mar 01, 2016 9:35 am 

Joined: Wed Feb 24, 2016 11:08 am
Posts: 35
///push


Top
   
PostPosted: Sat Mar 05, 2016 9:45 pm 

Joined: Wed Feb 24, 2016 11:08 am
Posts: 35
//Push
really want to decompress and probably recompress this files :D


Top
   
PostPosted: Sat Mar 05, 2016 10:36 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 11845
Why don't you use the source code provided by Firefly in the meantime?


Top
   
PostPosted: Sun May 01, 2016 10:28 am 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 11845
I forgot to say that quickbms 0.7.4a includes the wp16 algorithm:
http://aluigi.org/bms/wp16.bms


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 14 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited