ref: a1c6005292984c6c2c6327cf4f6dfa1b5b2e72cb
parent: f6b64cc388c12bb270d6804e0f712026be366f6c
author: qwx <qwx@sciops.net>
date: Thu Aug 27 18:08:00 EDT 2020
fs: improve image files format, storage and handling individual images were stores as individual files as compressed plan 9 images. this results in a combinatorial explosion of files any time a unit is added. one unit typically has 8 team colors, 32 rotations, shadows for each rotation, and potentially multiple frames, meaning even more rotations and shadows. so, for command center, hatchery, scv and drones, with just idle and movement sprites, we exceed 1700 files. an obvious additional consequence is ridiculous loading times at startup. units may have 32 rotations internally, but they actually only have 17 sprites: 8 images [0°,180°[ duplicated once, a single 180° sprite, 7 mirrored images ]180°, and another unique sprite for the 32nd rotation. in addition, images for each of the 8 teams all have the same dimensions and offsets. it would still be nice to have to avoid having special formats or more metadata, so to avoid dealing with offsets, we don't bundle shadow sprites. shadows also may have different dimensions. however, we can bundle team colors and only store 17 rotations, selecting the correct one in the code. we can also concatenate tileset images, all 32x32. this reduces the current file count to about 210. bundling images together in compressed bitmaps reduces space somewhat. it would still be nice to find something better since we'll reach the same problem when we add more and more units and frames.