scmJS docs

MTXM

The terrain the game draws: one 16-bit tile number per tile, including the tiles of placed doodads. A tile number is a tile group of the tileset times 16 plus the tile's place in the group, 0 to 15. The top bit, 0x8000, is not part of the number.

Name MTXM (4D 54 58 4D)
Size 2 bytes per tile: width × height × 2.
Read by The game, at the start of every game, whatever its type.
Required Yes. Without it the map is listed, but every game on it stops at the start with Error loading scenario file.
The game accepts Up to 131072 bytes, the most a 256 × 256 map needs. A longer section refuses the map; a shorter one is taken.
More than one copy Each copy is written over the start of the same space, in file order, so a later copy replaces only as many tiles as it carries.
In scmJS Read, and written again when you change what it holds.

Tile (x, y), counting from 0 at the top left, is at byte (y × width + x) × 2.

Whatever the tiles say, the game makes the whole bottom row of the map, and a block five tiles wide and two high in each bottom corner, ground that nothing can walk on or be built on: that is where the console covers the screen. A ground unit placed there is removed when the game starts. Checked against 1.16.1; Remastered's code does the same.

The game copies the section into a space the size of a 256 × 256 map, which it does not clear first, and uses the first width × height tiles of it. A section shorter than the map leaves the rest of the tiles as they were in memory, which is nothing to rely on. Melee and Use Map Settings both read it.

What a tile number points at#

A tile number is a tile group and a variation: the group is the number divided by 16, and the variation the remainder. Tile 0x0132 is group 19, variation 2. The top bit takes no part in this: the game reads the group from the next eleven bits, so tile 0x8084 draws as tile 0x0084. The game files the bit as a creep flag, but in play it does nothing you can see: Remastered shows no creep there, and a Zerg building that needs creep cannot be placed on it. A group past the end of the tileset's table is drawn as plain ground (tile 0x0020) by Remastered, while StarCraft 1.16.1 reads past the end of the table. The groups are the records of the tileset's CV5 file, 52 bytes each:

Offset Type Holds
0 u16 The terrain type the group belongs to; 1 for a doodad's group
2 u16 Flags: buildability and walkability in the low byte, ground height in the high byte. The game drops the walkability, height and view bits and keeps the others, buildability and creep among them
4 u16 × 4 Links for the left, top, right and bottom sides, which the isometric brush matches (ISOM)
12 u16 × 4 Stack links for the same sides, which say how pieces of a cliff face continue above and below
20 u16 × 16 The megatile of each of the 16 variations

A megatile is a 32 × 32 picture made of sixteen 8 × 8 minitiles, and leads to its pixels as Game data describes. Walkability and height are kept per minitile, in the VF4 file, and that is where the game takes them from: it ignores the walkability and height bits of the group's flags and works out a tile's height from its sixteen minitiles. On a cliff or edge piece the two often disagree, so an editor that shows height from the CV5 flags will be wrong for some of those tiles.

From a tile number through the CV5, VX4, VR4 and WPE files to pixels

A doodad's group keeps other things where terrain groups keep their links: the sprite or unit drawn over it at offset 4, its name in stat_txt.tbl at 8, its number in the tileset's doodad list (the number a DD2 record stores) at 12, and its width and height in tiles at 14 and 16. A doodad spans one group per row of tiles: row r of a doodad whose first group is g is group g + r, and column c is variation c.