Talk:RES Format (Stellar 7)

From ModdingWiki
Jump to: navigation, search

Compression

I was able to get an LZW decompressor working beautifully up until some time after code reset 0x100 is encountered. I'm using this source with some compatibility fixes. I'm wondering how much is known about discarding bytes. Using LEVEL1.RES for example, the third compressed block has a code reset about 2/3rds of the way through the finished product. I can finish the decoding if I eat three bytes but the remaining image starts becoming corrupted. The eaten bytes don't look useless either; even the remaining 8 bits in the buffer produce what looks like the next palette number in the output. Any thoughts? Zab 18:31, 3 March 2012 (GMT)

I don't know much about LZW decompression, but in my limited experience there are a bunch of different things that can happen. If 0x100 is a reset sequence, it may not reset the entire dictionary. Upon a reset, the length of the codeword may or may not be restored to its initial length (i.e. if it starts at 9-bits and grows to 12-bits, upon reset it may go back to 9-bits or stay at 12-bits.) There are other things I can't think of right now too. If you can find an already decompressed file and then compare that byte by byte to the compressed data as it is being decompressed, you will know at exactly which byte it goes wrong, and what byte it should have been instead, which could provide some hints. -- Malvineous 13:16, 6 March 2012 (GMT)
I've pounded my head on this plenty. I won't say I've given up but I'm going to put this up in case anyone can help out. Here is the decompression code and two compressed files, both working and non-working with a decompressed size of 32,000 bytes. Any assistance is appreciated. Zab 08:42, 27 March 2012 (GMT)