Terrain Format

* Nibble = 4 bits
* Byte = 8 bits
* Word = 2 bytes (Short)

All values are unsigned.

Data in the format is read left to right, top to bottom (bitmap pixel locations, minitile locations, etc.)

The following formats are organized from the topmost level to the bottom-most level (excluding dddata.bin.)

## CV5

Description: This file defines the various tile groups that are referenced by the TILE/MTXM sections of the CHK (3 nibbles for the group, 1 nibble for the tile.)

Struct Size: 52 bytes

Max ID [referencing this file]: 0-4095

For tile and edge pieces (IDs 0-1023):

* Word - Index?
* Nibble - Unknown
* Nibble - Buildable
	+ 0 = Buildable
	+ 4 = Creep?
	+ 8 = Unbuildable
* Nibble - Ground Height - Deprecated? Some values are incorrect.
* Nibble - Unknown/Unused?
* Word - Left Edge? (not fully understood.)
* Word - Top Edge? (not fully understood.)
* Word - Right Edge? (not fully understood.)
* Word - Bottom Edge? (not fully understood.)
* Word - Unknown/Unused
* Word - Unknown - Edge piece has rows above it. (Recently noticed; not fully understood.)
	+ 1 = Basic edge piece.
	+ 2 = Right edge piece.
	+ 3 = Left edge piece.
* Word - Unknown/Unused
* Word - Unknown - Edge piece has rows below it. (Recently noticed; not fully understood.)
	+ 1 = Basic edge piece.
	+ 2 = Right edge piece.
	+ 3 = Left edge piece.
* 16 Words - MegaTile References (VF4/VX4)

For doodads (IDs 1024+):

* Word - Index? (Always 1?)
* Nibble - Unknown
* Nibble - Buildable
	+ 0 = Buildable
	+ 4 = Creep?
	+ 8 = Unbuildable
* Nibble - Ground Height (Deprecated?)
* Nibble - Overlay Flags:
	+ 0x0 - None
	+ 0x1 - Sprites.dat Reference
	+ 0x2 - Units.dat Reference (unit sprite)
	+ 0x4 - Overlay is Flipped
* Word - Overlay ID (Sprites.dat or Units.dat reference, depending on Overlay Flags)
* Word - Unknown/Unused
* Word - Doodad Group String (1-based stat\_txt.tbl index)
* Word - Unknown/Unused
* Word - dddata.bin Index
* Word - Doodad Width (in tiles)
* Word - Doodad Height (in tiles)
* Word - Unknown/Unused
* 16 Words - MegaTile References (VF4/VX4)

## VF4

Description: MiniTile flags for each Megatile. Referenced by CV5.

Struct Size: 32 Bytes

Max ID: 0-65535 (1 word)

* 16 Words - MiniTile Flags:
	+ 0x0001 - Walkable
	+ 0x0002 - Mid
	+ 0x0004 - High (Mid and High unchecked = Low)
	+ 0x0008 - Blocks View
	+ 0x0010 - Ramp - Appears on the middle minitiles of most ramps/stairs.
	+ Rest unknown/unused.

## VX4

Description: MiniTile graphic references for each MegaTile. Referenced by CV5.

Struct Size: 32 Bytes

Max ID: 0-65535 (1 word)

* 16 Words - For each:
	+ 15 Bits - Graphical References (VR4) ((AND 65534)/2 to find)
	+ 1 Bit - Horizontal flipped flag (AND 1 to find)

## VR4

Description: Graphical Data for minitiles. Referenced by VX4.

Struct Size: 64 Bytes

Max ID: 32767 (15 bits)

* 64 Bytes[/b] - 1 byte WPE reference.

## WPE

Description: 256-color RGB Palette.

struct Size: 4 Bytes (Entire file is always 1024 bytes.)

Max ID: 0-255 (1 byte)

* Byte - Red
* Byte - Green
* Byte - Blue
* Byte - Null (0)

## DDDATA.BIN

Description: Doodad placeability. Referenced by CV5.

Struct Size: 512 Bytes (Entire file is 256KB.)

Max ID: 1-511

* 256 Words - CV5 Group ID references for placeability. Only the first (Doodad Width \* Height) words are used for each doodad. 0 is used for tiles that are null and placeable anywhere.