Tuesday, January 7, 2014

FMod - One Last Hurrah for Huffman

With full Keen Dreams support in the graphics part of FMod, the last (important) thing left to do about that strange episode was to edit its levels. Since Carmack compression didn't exist at the time of its release, they used Huffman on the map chunks instead. They also applied Huffman to the level headers, giving the compressed length of the main header in the super header.

Since the uncompressed structure is identical, I copy/pasted a lot of code from the GalaxyLevels class into the new DreamsLevels. Since the only existing thing using Huffman was GalaxyGraphics, I centralized some methods relating to IO of the dictionaries. People haven't done a lot in the way of modding Dreams, so I had to manually rip the map superheader out of the executable for testing. I am very confident as to the correctness of the place I took it from; there's no other instance of ABCDh followed by a relatively sparse region. However, I am considerably less certain that I took the maps' Huffman dictionary from the right place; I can't get the decompressed data to make sense no matter what I do to it. I'm almost 100% sure that my decompression and dictionary reader algorithms are right and that it's just a question of using the right dictionary.

No comments:

Post a Comment