SCI: Merge and cleanup LZW decompressors #6550
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR ports the LZW decompressor from my SCI tools to ScummVM. This replaces two FreeSCI-era decompressors with one small documented one.
That's right, we're compressing the decompressors.
SCI has two LZW compression formats. They only have two minor differences. The first is the bit order, the second is an off-by-one bug. The bug is so common in LZW implementations that it has a name and made the LZW wiki page: "early change".
I don't think it's known to the SCI community that the formats only differ by these two things. I learned it the hard way when developing my decompressors. I think what usually happens is that the FreeSCI code for the second algorithm just gets ported around. It works, but it's based on disassembly and not very comprehensible. (As the FreeSCI comments acknowledged.)
This decompressor helps generate my sci-scripts repository, where it gets run on every script in almost every game/version, so it's well used. I've also ran it against every LZW-compressed resource in my corpus.
This affects all SCI0-SCI1 games, but it shouldn't change any behavior unless I've messed something up =)