I think I'll have a shot at this...
It looks to be some sort of dictionary encoding scheme.
[EDIT] Actually it more resembles
LZ77
I may be a bit wrong, please let me know if I missed anything or interpreted the code incorrectly...
First off the general file format:
0x00 headers???
0x04 [no of files]
0x10 [directory] = [directory entry] x [no of files]
[directory entry] - 48 bytes
0x00 file name
0x24 [file data] offset
0x28 file length
0x2C (compressed) data length
[file data] - starts after last directory entry? (compressed)
Compression algorithm
[UPDATED]
Woke up this morning with an itch to code. Had a bit of trouble at first compiling in VC6 (didn't realize it was for *NIX, doh!), but finally managed to get it running.
My test data is fpack/chr/ryu/0000.fpk.
The data looks to be compression CONTROL codes (encode in a bit stream) interspersed with DATA bytes. For example:
Code:
00000340h: 9E 00 FF 02 04 3F FB 10 00 07 55 A0 0C FC 53 20
00000350h: 23 FC 50 F8 4E 18 F8 4B C6 F8 49 F8 46 31 F8 44
The first byte will always be a CONTROL code.
9E = 10011110
We read the first bit, see its a 1, so the NEXT available byte 0x00, is copied verbatim.
Our next bit is 0, it's compressed data. It is type A (0), so the next two bits will decode the length 3 + 2 = 5.
The next available byte 0xFF encodes the distance in the output stream, which is -1.
Since our current output stream contains only 0x00, we will copy it five times.
The next two bits are both 1, so the next two bytes are written as-is, 02 and 04.
We're down to our last bit 0, which is of course compressed data, but we run out of bit information here, so we grab the next CONTROL byte
3F = 0 01 1 1 1 1 1
Continuing our bit reading, the next bit is 0 (type A), and the length bits is 1 + 2 = 3
The distance is 0xFB or -5. This will copy 3 0x00's to the output buffer.
The next 5 bits are all 1's so data is just copied and pointers are advanced.
If the next two bits are 01, then the next two available bytes encode the distance and length as so:
Code:
000003c0h: 50 86 D0 FC 43 50 78 59 06 3C DC CC 31 [b]FA 6C[/b] 06
000003d0h: 29 31 7C 06 1E AC 8C 17 FC 10 61 DC 09 DC 05 86
FA6C = 1111101001101 100
pos = ff4d = -179, length = 4 + 2 = 6
First 13 bits encode distance and the last 3 encode length. If length = 0, then the next available byte encodes the length.
The window size is therefore 8192 bytes or 8kb, and the maximum length is 256.