Micro Machines Direction Format

From ModdingWiki
Jump to navigation Jump to search

Direction data for Micro Machines is stored in GAME1\ROUNDn.DIR files, one per round. For every part of a meta-tile it holds the terrain type and the direction the computer controlled cars should drive in. Together these form a flow field that follows the racing line.

File format

The file is a list of 36-byte records, one per meta-tile (in the same order as the .CT file), with no header. The number of meta-tiles is the file size divided by 36. (Round 8's file has 32 spare bytes at the end; round 5's file ends in the middle of its last record.)

Each record is 6×6 bytes, stored row by row. Each byte covers a 16×16 pixel block of the 96×96 pixel meta-tile (2×2 cells of the collision mask).

offset = cell * 36 + (suby / 2) * 6 + (subx / 2)

where subx/suby are the 8-pixel positions within the meta-tile (0-11), as for the collision mask.

Byte layout

Bits Purpose
0-3 Direction index (0-15). For round 2 (powerboats) only bits 0-2 are used.
4 Ramp flag: a car driving off a block with this bit set jumps
4-7 Terrain type (0-15), see below

Terrain

The terrain value picks the effect of the surface: rough ground that slows a car down, water, sand, height levels and so on. Its meaning differs per round. In rounds 1, 2, 3 and 6 only bits 5-7 are used (8 types); rounds 4, 5, 7, 8 and 9 use all four bits. In rounds 4 and 5 (the stepped courses) values 5-14 are height levels: a car cannot climb more than one level at once.

Some vehicle classes ignore rough terrain: tanks ignore values 1-7, and the turbo wheels and four by four classes ignore values 5 and up.

Direction

The direction index is not an angle itself. It is turned into one through a fixed table of 16 headings in the game, which holds each multiple of 16 (0x00-0xF0) exactly once, in the angle convention of the game (0 = up, 64 = right, 256 steps per full turn).

The .MAP attribute bits of the cell change the result:

  • Attribute bit 1 set: the index first goes through a remap table that mirrors the flow field. Which of four remap tables is used comes from bits 5-6 of the meta-tile's .LEV byte.
  • Attribute bit 0 set: the heading is turned around by 180° (XOR 0x80).

This lets one meta-tile be reused for corners in different orientations and for both driving directions.

The computer steers towards this heading. The .BRK file controls its speed.

Credits

This file format was reverse engineered by VorticonCmdr. 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!)