Monday, December 30, 2013

FMod - Galaxy Levels are Complicated

This FMod development series is monopolizing my blog. It will probably take a break when I resume classes in a week. Until then, old file formats engage!

Despite my tendency to busy myself with many projects at once, within each of those I focus on one task. Continuing from yesterday, I worked on the Galaxy level class. After a more careful read of the existing documentation, I discovered that my Carmack decompressor was incorrect. After changing it to use the right order of bytes, it expanded the chunks much more sensibly. However, there was another problem: some extra bytes are present between the address referenced in the level header and the apparent start of actual data. I determined the offset to be 8, but soon ran into the problem of decompression flags pointing to negative addresses. After digging through ever more obscure documentation, I discovered that four of my eight offset bytes had a purpose: decompressed length. The other four were actually part of the important data; I had dismissed them because they didn't represent the first tile - they were an RLEW flag. After adjusting my reader and writer accordingly, it worked a lot better. I still have one problem left to work out: it starts behaving unpredictably after encountering a far reference.

No comments:

Post a Comment