Today and yesterday, I did some fiddling with Galaxy graphics for FMod.
At first, I continued my idea of having a complicated chunk management system with different manager types for the various chunk types and interrupt-like interface hooks. Managing requests and dependencies (for the table chunks) became a terrible mess very quickly, so I scrapped that idea and moved onto a simpler allocation table. Since I would have to have different manager sets for different episodes anyway, I created a class that stores the starting and ending chunk ID of each type of chunk and a generator that makes one of those for the requested episode.
As a precursor to actually reading things, I wrote the Huffman decompressor. It was fairly simply based on the example code on the ModdingWiki. With a quick BinaryTreeNode<T> class, it was loading dictionaries and decompressing non-byte-aligned data shortly.
With that done, and file format documentation at the ready, I began writing the readers for each range. It was surprisingly easy; the hardest part was the bit gymnastics to get the EGA plane data in the right order. The code could probably be cleaned up by using lambdas instead of copy/pasting similar code, but that can always be done later. Once I had pretty much everything in place, I actually ran a test. It failed miserably on essentially the first thing: the fonts. The height was something crazy like 64 and the offsets were way past the end of the chunk. Similar crazy number errors appeared in the tables, which only quietly bungled the data.
Apparently, there are still some things about Huffman compression that I still don't understand. I'm using Levellass's "trivial Huffman dictionary", which is said to work on Keengraph-exported graphics, which is what I'm trying to use. Somehow, the Huffman effect didn't get applied to some of the later bytes. FMod doesn't know which to reverse, though Keen uses them perfectly fine.
No comments:
Post a Comment