I’ve finally finished adding Knowledge Adventure movie v2/v3 support to na_game_tool—just a couple of formats more and I can make a release.
Meanwhile I want to talk about what I discovered.
First of all, the original format still looks too hard to implement, mostly because of its incomprehensible binary specification. With all known samples employing arithmetic coding if you get one thing wrong you won’t get any thing right.
Let’s jump to version 3. As it turned out, it is not a movie file per se but rather an archive containing interleaved chunks of version 2 movie format and optionally an audio track. It even stores the original file names in the header. What’s curious is that version 2 supports embedded audio track just fine.
So now the most interesting part left. Version 2 movies as I described in the previous post use static Huffman coding for multiple streams (like mode bytes, motion vector indices, colours and such). The main thing I didn’t understand back then was its pattern mode: apparently the decoder keeps track of two significant colours used by all blocks in the line (e.g. last column of the raw block, or last pixel of each motion-compensated sub-block, or two colours used in a pattern block) and may re-use them from a neighbouring block for a pattern fill.
There are also some other fun things, like older games using transposed images (i.e. it’s coded as columns in left-to-right mode) while newer games use bottom-to-top coding. And single images are often coded as a sequence of strips (e.g. first you have strip 132 pixels wide, next to it a strip 128 pixels wide and so on until the whole image is decoded).
Actually there are many feature flags in the play there, I’ve ended up implementing just the most common modes and giving up on more complex ones. At least it works on the majority of the files I tried (including the ones extracted from older and newer Knowledge Adventure archive formats—of course na_game_tool supports extracting from them now). The format will be documented shortly after the release (because it’s a thing I usually do when I have nothing better to do) so those willing to do it better will have both the code and the description to work from.
Meanwhile I’ll just chase another pair of some game codecs for completeness sake, make the release, and move to implementing a different multimedia tool…


