Repository navigation
Map file
Based on these Original findings:
Disa maps are usually straightforward, except when they are not. The MPD format acts as a container for all the map's information, such as where tiles and enemies are placed. Textures and models are stored in separate MPP files, with one containing the original SD textures and another prefixed with "NEW_" for the fancy HD textures.
| Name | Format | Info |
|---|---|---|
| Header | mpdfileHeader | |
| Chunks | vector<mpdfileChunk> | |
| ├── Chunk header | mpdfileChunkHeader | |
| ├── Objects | std::array<mpdfileChunkObject, 32> | Maps Models |
| ├── Event Tiles | std::array<mpdfileChunkEventTile, 16> | |
| └── Base tile | mpdfileTile | Not used by the game |
| Tiles | vector<mpdfileTile> | |
| Actors | vector<mpdfileActopr> |
struct mpdfileHeader// 16 bytes
{
unsigned short number_of_chunks; //number of chunks in map
unsigned short number_of_actors; //number of actors (enemies) in map
unsigned short unknown1;
unsigned short unknown2; //the rest is kinda 0
unsigned short unknown3;
unsigned short unknown4;
unsigned short unknown5;
unsigned short unknown6;
}A chunk holds up to 32 objects (models), 16 even tiles and infinite amount of tiles. Why the chunks are needed in the first place, don’t ask me. As basically all maps only use one. But you can rotate and transform a chunk and all of its content inside freely, which never was used in game and creates stage results, but its fun regardless.
Additionally, there's a base tile that duplicates all the data from the tile where the player spawns. Why they choose to copy everything instead of simply saving the coordinates (x,z) of its location on the map, I have no clue, but I suppose it gets the job done. And yes, if there are multiple chunks, only the first one is utilized; the others appear to be dead data.
struct mpdfileChunkHeader { // 64 bytes
float map_offset_x, map_offset_y, map_offset_z, map_offset_w;
float xRot, yRot, zRot, wRot; //works but totaly broken ingame
float map_offset2_x, map_offset2_y, map_offset2_z; //why there are two offsets I don't know
unsigned short number_of_tiles;
unsigned short unknown2;
unsigned short index;
unsigned char unknown_data2[14];
};
struct mpdfileChunkDef{
mpdfileChunkHeader header;
std::array<mpdfileChunkObject, 32> objects; //80 - (80 + 1152 bytes)
std::array<mpdfileChunkEventTile, 16> eventTiles; // 1232 - (1232+ 64)
mpdfileTile baseTile; // Player span location
};
struct mpdfileChunk{
mpdfileChunkDef info;
std::vector<mpdfileTile> tiles;
};So first come the chunks that are fixed size, the tiles are stored separately after the chunks in a big list. The amount of them for each chunk you can find in it's header.
Objects refer to models, and each chunk can hold a maximum of 32 of them. If an object is not used, it's set to be invisible. The MPD file doesn't actually contain any geometry; instead, it's stored inside the MPP file.
In addition to transformations, the texture scroll speed for certain textures, like water, is also stored. Transformation may seem straightforward at first, but for some reason, it's overly complicated and over-engineered.
struct mpdfileChunkObject //36 bytes
{
short x, y, z; // y is negative for some reason?
short xRot, yRot, zRot; // in degree
short xScale, yScale, zScale; // 0-100
short unk10;
unsigned char unk11, model_id, visible, unk12;
char textureScrollX, textureScrollY; //this defines the speed and direction of texture scroll for flaged textures
unsigned char pad[10];
};How the transformation is applied is very weird. Instead of applying the values directly to a single node in the scene graph, the translation plus a fixed scale is applied to the object node, while rotation and scale are applied to each root node of the object itself.
I use OpenGl, so my up axis is Y.
struct mpdfileTexdata textures[12]; The faces of a tile can have a up to two sets of UV Maps, one for a Base Color and one for a Decal Layer. Usage is indicated if textureIndex is zero or not. The top face of the tile can additionally have a shadow map, which functions the same as a decal. (The shadow map seams to be drawn by hand)
Base color:[N, W, S, E, Top], Decal:[N, W, S, E, Top], Shadowmap:[Top], [Unknown (is always zero?) ]
Each entry consists of:
typedef struct { //8 bytes total
unsigned char u,
unsigned char stretch; //?
unsigned char v,
unsigned char width;
unsigned char size_stretch; //?
unsigned char height;
unsigned char textureIndex;
unsigned char transform; //rotation(0b11) - mirrorX(0b100) - mirrorZ(0b1000) - decalMode(0b110000)
} __attribute__((packed, aligned(1))) mpdfileTexdata;Each tile consists of:
typedef struct {
mpdfileTexdata textures[12]; // Base color: N, E, S, W, Top; Decal layer: N, E, S, W, Top; Shadowmap; Unknown (is always zero?)
/*
* NW2-----NE3
* | |
* | |
* SW0-----SE1
*/
std::array<char, 4> cornersTop; // Height in each corner of the tile, negative = up; (SW, SE, NW, NE)
std::array<char, 2> sideN; //North bottom points, are usualy 0 if side face is hidden or starts from ground
std::array<char, 2> sideE; //East bottom points, are usualy 0 if side face is hidden or starts from ground
std::array<char, 2> sideS; //South bottom points, are usualy 0 if side face is hidden or starts from ground
std::array<char, 2> sideW; //West bottom points, are usualy 0 if side face is hidden or starts from ground
unsigned char unk2[4]; // TBD
unsigned char visible;
char x, z; //position of tile
unsigned char unk4, unk5, unk6, unk7;
unsigned char mobility; // 0 = Unlimited, 1 = Fly only, 2 = Impassable
unsigned char geo_color;
unsigned char geo_mark; // 0 = No geopanel, 100 = Has geopanel
unsigned char pad2[6];
} __attribute__((packed, aligned(1))) mpdfileTile;