Map Matrix

From ProjectPokemon Wiki
Jump to navigation Jump to search

The Map Matrix or World Layout is a file type that describes a single floor of a map or the entire Overworld as a whole. The map matrix may have up to 3 sections. The land data maps are always implied, while the map definitions and mystery zone maps can be toggled on or off.

Format

 pseudo_struct MapMatrix {
   uint8_t width;
   uint8_t height;
   uint8_t has_map_definition_ids;
   uint8_t has_mystery_zone;
   uint8_t namelen;
   char name[namelen];
   if(has_map_definition_ids) {
     uint16_t map_id[width*height];
   }
   if(has_mystery_zone) {
     uint8_t mystery_zone[width*height];
   }
   uint16_t land_data_map_id[width*height];
 }
 

Map Definitions

Map definitions link boundaries to a given map. When the boundaries are crossed, the map with that ID is loaded. This is mainly used with the overworld to simulate routes and towns.

Mystery Zones

Mystery zone definitions are also generally only found in the overworld. These work similarly to the Map definitions but exist past the boundaries of where the user is expected to be. Mystery zones provide a safe way of handling users as well providing a little bit of extra map information that makes it look like the world does not immediately come to an end.

Land Data Maps

These maps hold the model and terrain data for the actual region. Each block is usually 32x32 "steps" in shape. Nearby maps are drawn together at the edge of the map currently loaded so that the layout looks consistent and does not need additional loading. However, because certain textures are only available and loaded at a given time, Gates can be used to forcibly reset the land data.

Handling Missing Chunks

If the data for a map does not include Map Definitions or Mystery Zones, certain things are implied. Regardless of the map id that is currently defined for the active map tile, the map of the warp is always used. If the same map is used consistently, the map definitions can be omitted. This is why certain houses that have the same interior do not need separate models; they all just use the same map matrix and load into them.

Mystery zones can easily be omitted because Caves and Houses just do not bother with extra safeguards. They also just show plain black space in the outside regardless.