Mostly done using the following Ruby script:
(Dir.glob('**/*.cpp') + Dir.glob('**/*.h')).each do |file|
s = File.read(file, encoding: 'iso8859-1')
t = s.gsub(/(([\w_.\[\]]+)\s*=\s*new\s+\S+?\[[^\]]+?\](?!\())([^\{\}]*?)\n\s+memset\(\s*\2\s*,\s*0\s*,[^;]*;/m, '\1()\3')
if t != s
File.open(file, 'w') { |io| io.write(t) }
end
end
Previously the upscale test was changing the frame contents with incorrect data
before going back, but the algorithm relies on not changing contents for some
pixels by "skipping" them. Duplicated a bit of code to create a
non-destructive upscale test before decoding the whole frame.
The movies for Crusader: No Remorse have a unique decoder which is not too hard
to implement. Unfortunately, they don't properly implement the "compression"
FourCC, and instead put their ID in the "Stream Handler". Since supporting
them requires a change to the existing Image API, I thought I should make a
pull request for comments.
With this change, the movies in Crusader can all be played nicely.
Symbols for codes shorter than the prefix table index width are stored
in the table. All the entries in the table with an index starting with
the code are set to the symbol value. That way, when decoding it is
possible to get the number of bits corresponding to the table width from
the bitstream and directly find the symbol value. Longer code still need
to be searched for in the codes list.
From what I understand, this has something to do with the image
being either made up from two or three parts. When it's made from
three parts, the frame should be displayed for half again as long
as normal.
This makes the speed of the Zork: Grand Inquisitor video look
about right to me. It's still out of sync, but it doesn't seem to
get *more* out of sync as the video progresses.
Starship Titanic produces lots of "uninitialized value" warnings
at the very beginning of the game, when turning right. This is
because in the very first movie frame it uses codebooks that have
not been loaded. Explicitly set their data to 0 to guarantee
consistent behavior.
All users of BitStream were in fact using a specific, hardcoded variant,
so we can hardcode that variant, removing the need for virtual calls,
and enabling inlining.