Word Rescue Level Format

From ModdingWiki
Jump to navigation Jump to search
Word Rescue Level Format
Word Rescue Level Format.png
Format typeMap/level
Map type2D tile-based
Layer count2
Tile size (pixels)16×16 and 8×8
Viewport (pixels)288×152
Games

Word Rescue stores its levels in files named WRx.Sy where x is the episode (1-3) and y is the level (starting at 0). WR1.S0 is episode 1 level 1, WR3.S11 is episode 3 level 12. A matching equivalent WRx.Dy exists but its purpose is unknown - the game will run unchanged if all the WRx.Dy files are removed!

The format is comprised of two layers and some items (perhaps considered a third layer) with the first (background) layer having 16×16 tiles and the second (attribute) layer having 8×8 tiles. Some of the items use 8×8 coordinates while most use 16×16 coordinates.

File format

Each file begins with a header.

Data type Name Description
UINT16LE mapWidth Width of map, in 16×16 tiles
UINT16LE mapHeight Height of map, in 16×16 tiles
UINT16LE bgColour Background colour (EGA 0-15)
UINT16LE tileset Number in tileset filename (e.g. 0x03 == back3.wr)
UINT16LE backdrop Number in backdrop filename (e.g. 0x04 == drop4.wr)
WR_COORD8 start Starting position
WR_COORD8 end Level exit door location
UINT16LE gruzzleCount Number of gruzzles in level
WR_COORD8 gruzzles[gruzzleCount] Gruzzle coordinates (see below)
UINT16LE dripCount Number of slime drips
DRIP_COORD drips[dripCount] Origin and speed of each slime drip
UINT16LE slimeCount Number of slime buckets in level
WR_COORD16 slimeBuckets[slimeCount] Slime bucket coordinates
UINT16LE bookCount Number of books in level
WR_COORD16 books[bookCount] Book coordinates
WR_COORD16 letters[7] Coordinates of letters in word to spell
UINT16LE animCount Number of animated tiles
WR_COORD16 animations[animCount] Animated tile coordinates
UINT16LE fgCount Number of foreground tiles
WR_COORD16 fgTiles[fgCount] Coordinates of tiles the player should walk behind instead of in front of

For Math Rescue, instead of reading the 7 letters, the following data should be read:

 ? UINT16LE iCount7	(garbage trucks)
+2 VECTOR[iCount7]
 ? UINT16LE iCount8	(teleporter)
+2 VECTOR[iCount8]

Let a VECTOR be defined as follows:

+0 UINT16LE iStartX
+2 UINT16LE iStartY
+4 UINT16LE iEndX
+6 UINT16LE iEndY

The WR_COORD data type is defined as follows. As shown above it is preceded by a count, and then repeated that many times. If the associated count is zero, the WR_COORD structure is omitted entirely. WR_COORD8 values are in units of 8×8 tiles, while WR_COORD16 values are in units of 16×16 tiles. A WR_COORD8 value of (1,2) will be at pixel position (8,16). A WR_COORD16 value of (1,2) will be at pixel position (16,32).

Data type Description
UINT16LE x X-coordinate (in tiles)
UINT16LE y Y-coordinate (in tiles)

Each DRIP_COORD is the same, but with a drip frequency as well:

Data type Description
WR_COORD8 pos Drip origin. Should be directly below an open pipe tile.
UINT16LE maxY Maximum y coordinate of the falling drip. Falling below causes the drip to appear at the initial position again.

The background layer of map data follows next. The data is stored in a basic and quite inefficient RLE coding. Data is stored as a pair of two bytes. The first byte is a count (often one) and the second byte is the value to repeat that many times. Values (second bytes) of 0xFF refer to transparent/background tiles. After expansion there will be mapWidth * mapHeight bytes/tiles.

Immediately following this is the attribute layer, again RLE compressed in the same manner. This layer uses 8×8 tiles instead, so after expansion there will be (mapWidth - 1) * mapHeight * 4 bytes/tiles. The tiles are positioned from X-coordinate 1 (rather than 0), so it is not possible to place tiles in the first column (where x is zero). However because the tiles are 8×8, those at x=1 still overlap the 16×16 background tile at x=0.

The level entrance and exit are also specified in units of 8×8 tiles. The entrance coordinates are of the bottom-middle of where the door image is drawn, and where the player's feet will appear. The exit coordinates are of the top-left of the door image. The door image is 32×40 pixels in size.

Tile mapping

The tileset used is specified in the header (see above.) Each tileset is a 320×200 16-colour PCX file, divided up into 16×16 tiles.

The tile code in the background layer refers directly to an index in the tileset (so a value of 0 refers to the first 16×16 tile in the PCX file.)

Animated tiles are simply a list of coordinates (in the 16×16 space) of which tiles should be animated. The animated tile uses the tile placed in the level at the given coordinates plus the next three tiles to the right of said tile in the tileset image. The tiles must be located in the same line in the tileset due to the way this game stores tile graphics in memory and draws them.

The tile codes in the attribute layer seem to be constants:

Value Purpose
0x00 First question-mark box
0x01 Second question-mark box
0x02 Third question-mark box
0x03 Fourth question-mark box
0x04 Fifth question-mark box
0x05 Sixth question-mark box
0x06 Seventh question-mark box
0x20 Empty space
0x73 Solid tile
0x74 Standing tile (can jump up through it or press down to fall through it)
0xFD Unknown (end of layer?)

The tile attributes for Math Rescue are:

0x00 - "empty" tile
0x01 - "ladder" tile
0x02 - blocking tile
0x03 - sloped tile \
0x04 - sloped tile /
0x69 - number icon


Credits

This format was reverse engineered by Malvineous and K1n9_Duk3. 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!)