I'm trying to hack a Star Ocean game (Star Ocean First Departure, PSP) but everything is in these SLZ files. All Google can come up with is this article:
http://www.gamedev.net/reference/articles/article294.aspBasically, according to the algorithm, to decompress you read one byte (the tag) which tells you whether or not the next 8 "chunks" are compressed (a set bit means compressed). For example, if a tag FE was read, it'd be 1111 1110, meaning that the next 7 chunks are compressed and then the 8th is not (so just read it that one byte as it is). For compressed chunks, two bytes are read which determine the offset (in the history) and length as follows:
O11 O10 O9 O8 L3 L2 L1 L0 O7 O6 O5 O4 O3 O2 O1 O0
which allows a maximum history size of 4096 bytes.
Another version, which allows a history of 2048 bytes, is specified as follows:
O10 O9 O8 L5 L3 L2 L1 L0 O7 O6 O5 O4 O3 O2 O1 O0
Now, in these SLZ files I found, it at first seemed that it followed the algorithm in that article, but instead a set bit would mean uncompressed. I found several files that verified this, and there was one that had FF followed by ABCDEFGH and then another FF followed by IJKLMNOP and so on.
Here's one small sample SLZ file I found that precedes an AT3 sound file in the file pack (one huge binary file). I played the sound files and they are all BGM files, and all of them have the exact same SLZ file preceding them except that the At05 you see below is At06, At07, etc.
Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
15D5B810 53 4C 5A 02 44 00 00 00 F4 00 00 00 00 00 00 00 SLZ.D...ô.......
15D5B820 FF FF FF F4 00 41 74 30 35 F7 16 00 64 20 F1 80 ÿÿÿô.At05÷..d ñ€
15D5B830 04 04 00 FF 05 00 00 00 10 00 00 D6 07 00 01 FF ...ÿ.......Ö...ÿ
15D5B840 00 F1 06 E0 06 E0 06 E0 06 E0 80 06 E0 06 E0 06 .ñ.à.à.à.à€.à.à.
15D5B850 E0 06 E0 06 E0 06 E0 0C 70 F0 79 00 FF FE 0A 40 à.à.à.à.pðy.ÿþ.@
15D5B860 A0 80 00 €.
The first 16 bytes consist of the header. The header consists of SLZ followed by some byte which I have not found the meaninh to yet, an int for the data size (in little-endian), another int for the uncompressed size, and another 4 bytes which always seem to be zero (I haven't paid much attention to the header yet).
Anyways, on to the data and
the problem: First, there is an FF, saying that the next 8 bytes are not compressed, and then an F7 (11110111) which says the first 4 bytes are uncompressed, and then there is a offset-length pair, and then 3 more uncompressed bytes (so 9 in total). After 9 bytes, we get to another FF, so it seems like everything is following the algorithm.
However, 8 bytes later, there is 07 (00000111), saying the next 5 chunks are compressed. This is where everything starts to not follow the algorithm. According to the algorithm, if you read first null byte (for compressed data), then you quit the routine (what exactly is meant by "the routine" is not explained). Going with this, everything seems okay (assuming the offset-length pairs are valid) until I hit "E0 06" - a length of 0 (okay it's little-endian but back at the first compressed chunk, there'd be 80 F1)?? And then these pairs with E0's repeat until the end of the file, way past what the last tag specified.
So now I am confused. The file seems to follow the algorithm with the FF tags and the F7 tag (the 9 bytes before another FF), but then after that, everything is messed up and now I doubt that this file follows the SLZ in that article.
I didn't think so at first. No way some Japanese developers would use some article on gamdev right? I looked everywhere but couldn't find anything else. These SLZ files were used for the PSX Star Ocean games too (or so I heard), which were made around the time the article was first published. I also found the algorithm being mentioned in some text about open source Amiga code. From a Google search for the author's name, I learned that he now is a successful game developer who has worked on all sorts of games. Now it seems that it is very well possible that the developers used the article, but from what I've looked at, it doesn't

Maybe I am understanding the algorithm wrong? That C code he provides is so old I gave up on trying to even compile it. It's even harder to understand (I am not into low level programming at all), so all I have is the description (which just describes decompressing for some reason).
I have been going at this for weeks (whenever I felt like it) and I'm about to give up. Has anyone ever heard of any other "SLZ" algorithm? Even Google Japan returns nothing...