Show whole topic Feb 04, 2009 1:37 pm
beko Offline
Developer, Administrator
Registered since: Jun 04, 2004
Location: Cresbach


Subject: WRL file format
WRL Map Design translated from Docs specification:

First comes the header:

filetyp: 5 bytes, for original maps this is "WRL" + NULL termination + 1 free byte. The Russian WRX maps use the same format. Only WRX and WRL are supported by MAXR.
width: 2 bytes
height: 2 bytes

Now follows the pixeldata for the "minimap" (preview) displayed in the map selction menu. For each pixel 1 byte that refers to an index on the color pallete (more to that later): means width * height pixels.

Now comes the mapdata itself. For each tile an integer with a 2 bytes size refering to a specified terrain tile (more later). This section has the lenghts widht * height * 2 bytes.

Now comes a integer with 2 bytes length describing how many different types of terrain tiles are used on the map. This is basically the total amount of all water, coasts and terrain graphics used on the map.

After that follow the pixeldata for each terrain tile. Every terrain graphic is 64x64 pixel in size. Like on the minimap is there for every pixel a refer onto a color index on the color palette. How many tiles are stored here is definied before. This section has a total lenght of tileamount*64*64 bytes. All tiles are auto-indexed in their order refered by the mapdata read before.

Now follows the palette itself. The palette includes 256 colors for each color value in rgb - always 1 byte in that order. This means this section is 256*3 bytes long. Like before the palette is auto-indexed by order (first color is indexed as 0, last is 255).

Finally follows the tiles type specification. For each terrain 1 byte again. This section is the total amount of read terrain tiles long. Each byte has one of the following values: 0 for normal terrain, 1 for water tile, 2 for coasts and 3 for blocked terrain like mountains.

According to eiko water animations are done by spinning defined color ranges on the palette. The following ranges are spinned:

96 to 102 (7 colors)
103 to 109 (7 colors)
110 to 116 (7 colors)
117 to 122 (6 colors)
123 to 127 (5 colors)

..so drawing water is sort of tricky Embarrassing

Tell me if I got something wrong!
Bernd Kosmahl
"Sir, we are surrounded!" - "Great - we can attack in any direction."