Duke Nukem II CZone Format

From ModdingWiki
Jump to navigation Jump to search
Duke Nukem II CZone Format
Duke Nukem II CZone Format.png
Format typeTileset
HardwareEGA
Max tile countFixed
PaletteExternal
Tile names?No
Minimum tile size (pixels)8×8
Maximum tile size (pixels)8×8
Plane count4-5
Plane arrangementByte-planar
Transparent pixels?Yes
Hitmap pixels?No
Metadata?None
Supports sub-tilesets?No
Compressed tiles?No
Hidden data?No
Games

The CZone format stores three blocks of data - the behaviour of each tile in a tileset, a collection of images for the "solid" background tiles, and a collection of images for the "masked" foreground tiles.

File format

Data type Name Description
BYTE[3600] attributeData Attribute data
BYTE[32000] solidTileset Graphics for the solid tileset
BYTE[6400] maskedTileset Graphics for the masked tileset

Attribute Data

The attribute data consists of 1000 UINT16LE values (settings for the solid tiles), followed by 800 UINT16LE values (five values for each masked tile). Only the first value for each masked tile is actually used by the game. The remaining 4 values are padding, which simplifies looking up tile attributes in the game's code. Tile references specified in the level files are actually memory offsets, with solid tile references being multiples of 8, and masked tile references being multiples of 40. By padding out the masked tile attributes to 5 values per tile, a tile reference can simply be divided by 8 to get a correct index into the tile attribute array for either solid or masked tiles (since 8/8 is 1, and 40/8 is 5).

Each individual attribute value is a bitmask. The meaning of the bits is as follows:

Bit Description
15 -
14 climbable (chains/ladders)
13 -
12 -
11 -
10 fast animation
9 conveyor belt ->
8 conveyor belt <-
7 can hang on it (pipes, vines etc.)
6 burns away when shot
5 draw in front
4 animate (uses current tile and next 3 tiles)
3 solid/blocking right
2 solid/blocking left
1 solid/blocking up
0 solid/blocking down

Bits 11, 12, 13, and 15 are not used by the game, and simply ignored if they are set. The tileset "czone9" has bit 15 set on some of its tiles (horns), but it has no effect. Most likely a leftover from an earlier point in the game's development.

Solid Tileset

The solid tileset is comprised of 1000 tiles. Each tile is 8x8 pixels, and for best effect when presenting it to a user/designer it should be displayed in a grid 40 tiles wide by 25 tiles high.

The tiles are stored in Cosmo Tileset Format. The first plane is blue, followed by green, red and then intensity.

Since the tiles are 8x8, each plane's scanline fits into one byte. At eight pixels tall that makes each plane occupy eight bytes, and with four planes the whole tile takes up 32 bytes. This means you can seek to any tile with a simple formula:

iOffset = iTileIndex * 32

Masked Tileset

The masked tileset is almost identical to the solid tileset, except that there are only 160 tiles (so only four rows high, but still 40 tiles wide) and of course being a masked tileset, there are five planes. The first plane is transparency, followed by blue, green, red and intensity as with the solid tiles.

Credits

This file format was reverse engineered by Dave Bollinger. Most of this info came from the specs on his website. lethal guitar verified that unknown/unused tile attribute bits are not used by the game, and added some details. 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!)