Oh dang, I didn't even know a script for it existed. I even googled!
I will finish up the extractor anyway, and maybe write a packer for it too.
As for replacing data, it's tricky but it can be done.
You want to do this:
1) Edit decompressed file. Note filesize in bytes.
2) Compress your file with zlib. Note filesize again.
3) From lfm_order.bin fetch the id for the file you want to replace or just cycle thru the list of strings til you find what you're looking for.
4) Open up archive00.lnk and seek to offset 0x20.
5) From 0x20, seek to your ID * 0x20. This should put you at the position where the information of your file is.
6) There are 4 byteswapped values here, they are:
Code:
struct archive_data {
INT64 offset_start;
INT64 decompressedsize;
INT64 offset_stop;
INT64 unknown;
};
You want to modify decompressedsize to the size of your unpacked file.
Note the value of offset_stop.
Leave the rest intact and go to the address from offset_start.
7) At this address there is a 4 byte value which specifies the length of the block + 0x800. You want to replace this with your own (compressed) filesize + 0x800.
8) After setting this, you want to fill everything with 00 up to offset_stop - 4. We don't want to overwrite our new filesize so we cut 4 bytes.
9) Paste your zlib file in there after the filesize, making sure not to overwrite any original data (00 is okay since it's used for padding so you can extend the file slightly). You may come across some other zlib blocks - that's okay, we're not using chunks. Just overwrite them. When you see a LOT of 00's, that's how you know you're approaching the end of file.
10) You then want to add some 00 bytes til you are at an offset in the file that ends with 0. For example 0002E020 or 0002E030. Note the offset you are at.
11) Head back to 0x20 + (id * 0x20) and replace offset_stop with your new value.
12) Save file and fire up the game. Pray to the gods because I haven't tested this yet.