Cosmo Tileset Format
The Cosmo Tileset Format is the graphics format used by Cosmo's Cosmic Adventures (and later Duke Nukem II) for storing a collection of images, used for nearly all graphics in the game, from tiles to sprites to background images.
The format is quite simple, as it contains no header or index information, consisting simply of Raw EGA data. The file consists of a number of 8x8 tiles divided into EGA planes stored consecutively. These images then may make up larger images such as sprites o backgrounds. Most files are four plane (16-colour) however the "mask" files are five plane (16-colour + transparency.) The planes are stored in the order: transparency (0=opaque, 1=transparent), blue, green, red, intensity. This also applies to Duke Nukem II which is actually a 16-colour game, even though the VGA palette changes cleverly disguise it as 256-colour.
This means each tile will take up eight bytes per plane, or 32 bytes for a 4-plane tile and 40 bytes for a 5-plane tile. This makes it easy to seek to a particular tile's offset, or to calculate the number of tiles in the file based on its size (assuming the number of planes is known in advance.) However this is complicated by the fact that larger files are broken up into 65535 byte ($FFFF) blocks and that those blocks may be padded with random data.
If the tilesets are being displayed on-screen for a human to look at, most of them have an ideal width which makes all the tiles line up across each row. This width depends on the tileset and is shown in the table below. Some tilesets (primarily the ones used for game creatures) will have different widths depending on the creature itself (and these are stored in separate files.)
This is the list of known files in this format, along with the number of planes and the tilecount of each file.
Cosmo's Cosmic Adventures
|actors.mni||5||4797 (file size doesn't divide evenly!)||N/A||Enemy/creature animations|
|bd*.mni||4||720||40||Map backdrop images|
|cartoon.mni||5||1632||N/A||Images for game story|
|masktile.mni||5||1000||40||Masked/transparent tiles for map foreground layer|
|players.mni||5||750||N/A||Main game character animations|
|status.mni||4||228||38||Background graphics for the in-game status bar|
|tiles.mni||4||2000||40||Solid tiles for map background layer|
|fonts.mni||5||100||N/A||Masked font tiles|
The ACTORS.MNI file consists of multiple blocks, each sized up to 65535 bytes. This means that the last 15 bytes of each full block can be ignored as they don't contain enough data to fill a tile (as said before, a masked tile has a size of 40 bytes) and no entry in ACTRINFO.MNI (see Cosmo Tileinfo Format) actually reads those bytes. This restriction might also apply to the other files, but none of them is larger than 64280 bytes.
In FONTS.MNI, a pixel will be solid if the mask bit is set, otherwise it will be transparent (just like in Duke 1). In all the other masked files, the pixel will be transparent if the mask bit is set.
Duke Nukem II
|czone*.mni||4/5||100/160||40||Map background/foreground tiles (see Duke Nukem II CZone Format)|
|drop*.mni||4||720||40||Map backdrop images|
ACTORS.MNI also is in this format, but with mixed entry types. Most entries are 5-plane graphics (masked), but there are also some 2-plane graphics (with one plane used as a mask) included, which store the bigger (8×16 pixel) font used in the menus.
See Major Stryker Tileset Format. The format is identical except most tiles are 16×16 instead, although a couple of tilesets are in Cosmo format.
This file format was reverse engineered by Malvineous, among others. If you find this information helpful in a project you're working on, please give credit where credit is due. (A link back to this wiki would be nice too!)