MLVL (File Format): Difference between revisions

Jump to navigation Jump to search
no edit summary
>Aruki
>Aruki
No edit summary
Line 8: Line 8:


The format largely defines properties related to each area in general and how they link together, as well as things that apply to the world on a global scale across all areas, such as the skybox.
The format largely defines properties related to each area in general and how they link together, as well as things that apply to the world on a global scale across all areas, such as the skybox.
Remember that all resource IDs are 32 bits in Prime 1/2, and 64 bits in Prime 3/DKCR.
=== Header ===


{| class="wikitable"
{| class="wikitable"
! Type
! Type
! Size
! Count
! Description
! Name
! Notes
! MP1
! MP1
! MP2
! MP2
Line 23: Line 20:
|-
|-
| u32
| u32
| 4
| 1
| '''Magic'''; always 0xDEAFBABE
| '''Magic'''
| Always <code>0xDEAFBABE</code>
| {{check}}
| {{check}}
| {{check}}
| {{check}}
Line 31: Line 29:
|-
|-
| u32
| u32
| 4
| 1
| '''Version'''; see below
| '''Version'''
| [[#Version|See below]]
| {{check}}
| {{check}}
| {{check}}
| {{check}}
Line 38: Line 37:
| {{check}}
| {{check}}
|-
|-
| [[STRG (File Format)|STRG]]
| Asset ID ([[STRG (File Format)|STRG]])
| 4/8
| 1
| '''World name'''
| '''World Name ID'''
| [[STRG (File Format)|STRG]] file for the world name.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
Line 46: Line 46:
| {{check}}
| {{check}}
|-
|-
| [[STRG (File Format)|STRG]]
| Asset ID ([[STRG (File Format)|STRG]])
| 4
| 1
| '''Dark World Name'''
| '''Dark World Name ID'''
| [[STRG (File Format)|STRG]] file for the Dark World name.
| {{nocheck}}
| {{nocheck}}
| {{check}}
| {{check}}
Line 55: Line 56:
|-
|-
| u32
| u32
| 4
| 1
| '''Temple Key World Index'''
| '''Temple Key World Index'''
| Controls which temple key icons appear on the map screen. Appears in Prime 3 but always 0.
| {{nocheck}}
| {{nocheck}}
| {{check}}
| {{check}}
Line 64: Line 66:
| bool
| bool
| 1
| 1
| '''Has Time Attack''' (if false, the next 5 values aren't present)
| '''Has Time Attack'''
| Indicates whether this world has a Time Attack mode. '''If false, the next five values are not present.'''
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
Line 72: Line 75:
| string
| string
| 1
| 1
| '''Level Number''' (such as 1-2, 2-2, etc; unknown use)
| '''Level Number'''
| String of the world/level number; for example, "1-1". Purpose unknown.
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
Line 79: Line 83:
|-
|-
| float
| float
| 4
| 1
| '''Time Attack Bronze Time'''
| '''Time Attack Bronze Time'''
| Target time for a bronze medal in Time Attack.
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
Line 87: Line 92:
|-
|-
| float
| float
| 4
| 1
| '''Time Attack Silver Time'''
| '''Time Attack Silver Time'''
| Target time for a silver medal in Time Attack.
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
Line 95: Line 101:
|-
|-
| float
| float
| 4
| 1
| '''Time Attack Gold Time'''
| '''Time Attack Gold Time'''
| Target time for a gold medal in Time Attack.
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
Line 103: Line 110:
|-
|-
| float
| float
| 4
| 1
| '''Time Attack Shiny Gold Time'''
| '''Time Attack Shiny Gold Time'''
| Target time for a shiny gold medal in Time Attack.
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
Line 110: Line 118:
| {{check}}
| {{check}}
|-
|-
| [[SAVW (File Format)|SAVW]]
| Asset ID ([[SAVW (File Format)|SAVW]])
| 4/8
| 1
| '''SaveWorld ID'''
| '''World Save Info ID'''
| Asset ID for this world's [[SAVW (File Format)|SAVW]] file.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
Line 118: Line 127:
| {{check}}
| {{check}}
|-
|-
| [[CMDL (File Format)|CMDL]]
| Asset ID ([[CMDL (File Format)|CMDL]])
| 4/8
| 1
| '''World skybox CMDL ID'''
| '''Default Skybox ID'''
| [[CMDL (File Format)|CMDL]] file for this world's default skybox model. This can be overridden per-area by AreaAttributes objects.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
|}
==== Version ====
These are the known version numbers:
{| class="wikitable"
! ID
! Game
|-
|-
| 0xD
| u32
| Metroid Prime Demo
| 1
| '''Memory Relay Count'''
| Count of all outgoing connections from Memory Relay instances in this world.
| {{check}}
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
|-
| [[#Memory Relay|Memory Relay]]
| ''Memory Relay Count''
| '''Memory Relay Array'''
| Array describing all outgoing Memory Relay connections in this world. Memory Relays connected to multiple objects are listed multiple times.
| {{check}}
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
|-
|-
| 0x11
| u32
| Metroid Prime
| 1
| '''Area Count'''
| Count of areas in this world.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
|-
|-
| 0x14
| u32
| Metroid Prime 2 Demo
| 1
| {{unknown|Unknown}}
| Always 1?
| {{check}}
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
|-
|-
| 0x17
| [[#Area|Area]]
| Metroid Prime 2
| ''Area Count''
| '''Area Array'''
| Array defining all areas that appear in this world.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
|-
|-
| 0x19
| Asset ID ([[MAPW (File Format)|MAPW]])
| Metroid Prime 3
| 1
| '''World Map ID'''
| ID of this world's [[MAPW (File Format)|MAPW]] file.
| {{check}}
| {{check}}
| {{check}}
| {{nocheck}}
|-
|-
| 0x1B
| u8
| Donkey Kong Country Returns
| 1
|}
| {{unknown|Unknown}}
 
| This is presumably the same unknown value as at the beginning of the [[Scriptable Layers (Metroid Prime)|SCLY]] format. Always 0.
=== Memory Relays ===
| {{check}}
 
| {{check}}
This section is only present in Prime 1. It contains a list of all Memory Relay objects used in the world and what objects they're connected to. If a Memory Relay is connected to multiple objects, it will show up multiple times.
| {{check}}
 
| {{nocheck}}
The section starts with a 32-bit count value, then each relay is structured as:
 
{| class="wikitable"
! Offset
! Type
! Size
! Description
! MP1
! MP2
! MP3
! DKCR
|-
|-
| 0x0
| u32
| u32
| 4
| 1
| '''Memory Relay instance ID'''
| '''Script Instance Count'''
| The MLVL format embeds a script layer. This script layer is used in the MP1 demo for storing Dock instances, but it's unused in all retail builds, so this is always 0.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
|-
|-
| 0x4
| u32
| u32
| 4
| 1
| '''Target instance ID'''
| '''Audio Group Count'''
| Count of all audio groups used in this world.
| {{check}}
| {{check}}
| {{nocheck}}
| {{nocheck}}
Line 188: Line 217:
| {{nocheck}}
| {{nocheck}}
|-
|-
| 0x8
| [[#Audio Group|Audio Group]]
| u16
| ''Audio Group Count''
| 2
| '''Audio Group Array'''
| '''Message'''
| Array describing all audio groups used in this world.
| {{check}}
| {{check}}
| {{nocheck}}
| {{nocheck}}
Line 197: Line 226:
| {{nocheck}}
| {{nocheck}}
|-
|-
| 0x10
| string
| u8
| 1
| 1
| '''Active'''
| {{unknown|Unknown}}
| Always empty, so the only value that ever appears here is the terminating 0.
| {{check}}
| {{check}}
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
|}
=== Areas ===
This section defines every area in the world and how they connect to other areas.
{| class="wikitable"
! Type
! Size
! Description
! MP1
! MP2
! MP3
! DKCR
|-
|-
| u32
| u32
| 4
| 1
| '''Area count'''
| '''Area Count'''
| Will be equal to the earlier area count.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
Line 228: Line 244:
| {{check}}
| {{check}}
|-
|-
| u32
| [[#Area Layer Flags|Area Layer Flags]]
| 4
| ''Area Count''
| {{unknown|'''Unknown'''}}; always 1?
| '''Area Layer Flags'''
| This array initializes the default active state for all script layers in each area.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
|}
==== Area Header ====
{| class="wikitable"
! Type
! Size
! Description
! MP1
! MP2
! MP3
! DKCR
|-
|-
| [[STRG (File Format)|STRG]]
| u32
| 4/8
| 1
| '''Area name'''
| '''Layer Name Count'''
| Count of layer names in the next array.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
Line 256: Line 262:
| {{check}}
| {{check}}
|-
|-
| float[12]
| string
| 0x30
| ''Layer Name Count''
| '''Transform matrix'''
| '''Layer Name Array'''
| Array of all layer names in the world.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
Line 264: Line 271:
| {{check}}
| {{check}}
|-
|-
| float[6]
| u32
| 0x18
| 1
| '''Bounding box'''
| '''Layer State ID Count'''
| Count of layer state IDs in the next array.
| {{nocheck}}
| {{nocheck}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
|-
| [[Saved State ID]]
| ''Layer State ID Count''
| '''Layer State ID Array'''
| Array of saved state IDs for each layer. These IDs are responsible for storing the layer's active state in the save file and are referenced by ScriptLayerController objects.
| {{nocheck}}
| {{nocheck}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
|-
|-
| [[MREA (File Format)|MREA]]
| u32
| 4/8
| 1
| '''Area MREA'''
| '''Area Count'''
| Identical to the previous two area counts.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
Line 280: Line 298:
| {{check}}
| {{check}}
|-
|-
| u32/u64
| u32
| 4/8
| ''Area Count''
| '''Area ID'''; used by layer-switching objects
| '''Area Layer Name Offset Array'''
| Each value is an offset into the layer name array and points to where the layer names for each area begins.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
|-
| colspan=8 {{unknown|End of file}}
|}
|}


==== Attached Areas ====
=== Version ===


This part contains a small table listing what areas within the world are attached (connected) to this one. This is done by using indices into the MLVL's area table; so an index of 0 indicates the first area listed in the MLVL, for example.
These are the known version numbers:


{| class="wikitable"
{| class="wikitable"
! Type
! ID
! Size
! Game
! Description
|-
! MP1
| 0xD
! MP2
| Metroid Prime Demo
! MP3
|-
! DKCR
| 0x11
| Metroid Prime
|-
| 0x14
| Metroid Prime 2 Demo
|-
| 0x17
| Metroid Prime 2
|-
|-
| u32
| 0x19
| 4
| Metroid Prime 3
| '''Attached area index count''' (AC)
| {{check}}
| {{check}}
| {{check}}
| {{nocheck}}
|-
|-
| u16[]
| 0x1B
| 2 &times; AC
| Donkey Kong Country Returns
| '''Attached area indices'''
| {{check}}
| {{check}}
| {{check}}
| {{nocheck}}
|}
|}


==== Dependency List ====
=== Memory Relay ===


This section is only present in Prime 1 and 2. It starts with what's essentially 2 embedded [[DGRP (File Format)|DGRP]] files: a 32-bit count value followed by a list of resources used by the area. There are two of these tables, and the first is always empty in release versions.
This structure only appears in Prime 1. It describes an outgoing connection from a Memory Relay to another script instance. Any Memory Relays connected to multiple objects will appear in the array multiple times.
 
Following that is a small array. The purpose of this array is to distinguish which resources are used by which layers, to avoid wasting time loading resources used by objects that aren't active. It's an array of offsets into the dependency table, each one marking the start of that layer's dependency list.


{| class="wikitable"
{| class="wikitable"
! Offset
! Offset
! Type
! Type
! Size
! Name
! Description
! Notes
! MP1
! MP2
! MP3
! DKCR
|-
|-
| 0x0
| 0x0
| u32
| u32
| 4
| '''Memory Relay Instance ID'''
| '''Layer count''' (LC)
| Instance ID of the sender Memory Relay.
| {{check}}
| {{check}}
| {{nocheck}}
| {{nocheck}}
|-
|-
| 0x4
| 0x4
| u32[]
| u32
| 4 &times; LC
| '''Target Instance ID'''
| '''Layer dependency offsets'''
| Instance ID of the receiver object.
| {{check}}
|-
| {{check}}
| 0x8
| {{nocheck}}
| u16
| {{nocheck}}
| '''Message'''
| Script message sent to the receiver object.
|-
| 0x10
| bool
| '''Active'''
| Whether this Memory Relay object is active by default; almost always 0.
|-
| 0x11
| colspan=3 {{unknown|End of Memory Relay connection}}
|}
|}


==== Docks ====
=== Area ===


This section is only present in the Prime trilogy.
This structure defines a single area and describes its position in the world and how it connects to other areas.


{| class="wikitable"
{| class="wikitable"
! Type
! Type
! Count
! Count
! Description
! Name
! Notes
! MP1
! MP1
! MP2
! MP2
Line 367: Line 385:
! DKCR
! DKCR
|-
|-
| u32
| Asset ID ([[STRG (File Format)|STRG]])
| 1
| 1
| '''Dock count''' (DC)
| '''Area Name ID'''
| [[STRG (File Format)|STRG]] ID for the area name.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
|-
| float
| 12
| '''Area Transform'''
| Area's transform matrix. Most area data is pre-transformed, but there are a few things that need to be transformed by this array.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{nocheck}}
|-
|-
| [[#Dock|Dock]]
| float
| DC
| 6
| '''Docks'''
| '''Area Bounding Box'''
| This is the bounding box of the area's collision mesh and is equivalent to the bounding box found in the [[MREA (File Format)|MREA]] collision section.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{nocheck}}
|}
===== Dock =====
{| class="wikitable"
! Type
! Count
! Description
! MP1
! MP2
! MP3
! DKCR
|-
|-
| u32
| Asset ID ([[MREA (File Format)|MREA]])
| 1
| 1
| '''Connecting dock count''' (DC)
| '''Area MREA ID'''
| ID of this area's [[MREA (File Format)|MREA]] file.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{nocheck}}
|-
|-
| [[#Connecting Dock|Connecting dock]]
| Asset ID
| DC
| 1
| '''Connecting docks'''
| '''Internal Area ID'''
| Doesn't actually refer to an asset, but has the same length as an asset ID. This ID is used internally by some things to refer to this area, such as Script Layer Controllers.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{nocheck}}
|-
|-
| u32
| u32
| 1
| 1
| '''Dock coordinate count''' (CC)
| '''Attached Area Count'''
| Count of areas attached to this one.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
Line 419: Line 439:
| {{nocheck}}
| {{nocheck}}
|-
|-
| vec3
| u16
| CC
| ''Attached Area Count''
| '''Dock coordinates'''
| '''Attached Area Index Array'''
| Array of area indices attached to this one.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{nocheck}}
| {{nocheck}}
|}
===== Connecting Dock =====
{| class="wikitable"
! Type
! Count
! Description
! MP1
! MP2
! MP3
! DKCR
|-
|-
| u32
| [[#Area Dependencies|Area Dependencies]]
| 1
| 1
| '''Area index'''
| '''Dependencies'''
| {{check}}
| Asset dependencies in this area. See below for details. Starting in Prime 3, this section has been moved inside the [[MREA (File Format)|MREA]] file.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
|-
|-
| u32
| u32
| 1
| 1
| '''Dock index'''
| '''Dock Count'''
| Count of Dock instances in this area. Should be equal to the attached area count.
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{nocheck}}
| {{nocheck}}
|}
==== REL Module List ====
This section is only present in Echoes. It contains a list of .rel files used by the area. Like the dependencies, it is followed by an array of offsets to distinguish which .rels are used by which layers. There are two offsets per layer; the reason for this is currently unknown, but the second offset is essentially an end index.
{| class="wikitable"
! Type
! Count
! Description
! MP1
! MP2
! MP3
! DKCR
|-
|-
| u32
| [[#Dock|Dock]]
| 1
| ''Dock Count''
| '''.rel count''' (RC)
| '''Dock Array'''
| {{nocheck}}
| Array describing all docks in this area.
| {{check}}
| {{check}}
| {{check}}
| {{nocheck}}
| {{nocheck}}
|-
| string
| RC
| '''.rel filenames''' (all zero-terminated)
| {{nocheck}}
| {{check}}
| {{check}}
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
|-
|-
| u32
| [[#Area Module Dependencies|Area Module Dependencies]]
| 1
| 1
| '''.rel offset count''' (OC)
| '''Module Dependencies'''
| REL module dependencies in this area. See below for details. The equivalent section in Prime 3 and DKCR describing RSO modules has been moved inside the [[MREA (File Format)|MREA]] format.
| {{nocheck}}
| {{nocheck}}
| {{check}}
| {{check}}
Line 494: Line 485:
|-
|-
| u32
| u32
| OC
| 1
| '''.rel offsets'''
| {{unknown|Unknown}}
| {{nocheck}}
| Always 0?
| {{check}}
| {{nocheck}}
| {{nocheck}}
|}
 
==== Area Footer ====
 
{| class="wikitable"
! Type
! Size
! Description
! MP1
! MP2
! MP3
! DKCR
|-
| u32
| 4
| {{unknown|'''Unknown'''; always 0}}
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
Line 523: Line 495:
| string
| string
| 1
| 1
| '''Internal area name''' (zero-terminated)
| '''Internal Area Name'''
| Internal name of this area. Does not appear ingame.
| {{nocheck}}
| {{nocheck}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
| {{check}}
|-
| colspan=8 {{unknown|End of area}}
|}
|}


=== World Map ===
==== Area Dependencies ====


This section is only present in the Prime trilogy. It sets the [[MAPW (File Format)|MAPW]] file used for this world.
This is a data chunk appearing in the area definition in Metroid Prime 1 and 2 that lists all assets needed to load the area. It's extremely important that this list be optimized and complete, as all assets listed here will be perpetually kept in memory as long as the area itself is in memory; the list also specifies the order that assets are loaded in, so '''it must be grouped by load order to roughly match the [[PAK (File Format)|PAK]] file for optimized load times'''. Assets that are missing will still be dynamically loaded after the area itself is loaded, but this will cause the game to freeze up until the load is finished. There are a few exceptions that are excluded from this list in the original game files (and should be excluded in custom MLVLs as well to avoid out-of-memory crashes):


{| class="wikitable"
* [[SCAN (File Format)|SCAN]] files and their dependencies are not included in the list. These are loaded dynamically after the area itself is finished loading.
! Type
* [[ANCS (File Format)|ANCS]] per-character dependencies for PlayerActor script instances are not included; this allows the game to avoid keeping assets in memory for suits that the player doesn't have. The exception is the Empty Suit character (character index 5), which is a low-memory-overhead character that allows for the list to include all common assets that are stored in the file per-character (such as particle effects).
! Size
* The skybox model and its dependencies are not included.
! Description
! MP1
! MP2
! MP3
! DKCR
|-
| [[MAPW (File Format)|MAPW]]
| 4/8
| '''World map'''
| {{check}}
| {{check}}
| {{check}}
| {{nocheck}}
|}


=== Script Layer ===
The dependency list is split by layer; after the dependencies itself, an array of offsets into the dependency list is provided that allows the game to only load assets for layers that are currently active. The last offset points to all common resources used by the area that aren't layer-specific. With that in mind, every layer needs to have a full list of its required assets even if they're also used by other layers. There's no harm in including an asset multiple times, as if an asset is already in memory then it'll simply be skipped over.


In the MP1 demo, this script layer is used to store all docks across the entire world. In all other builds/games, this layer is always empty and unused. Unknown whether there's a way to actually use it (all attempts so far result in a crash).
This data chunk still exists in Prime 3 and DKCR, but it's been moved inside the [[MREA (File Format)|MREA]] format.


{| class="wikitable"
{| class="wikitable"
! Type
! Type
! Size
! Count
! Description
! Name
! MP1
! Notes
! MP2
|-
! MP3
| u32
! DKCR
| 1
| '''Dependency Count'''
| Count of dependencies.
|-
| [[#Dependency|Dependency]]
| ''Dependency Count''
| '''Dependency Array'''
| Array of all asset dependencies in this area.
|-
|-
| u8
| u32
| 1
| 1
| {{unknown|'''Unknown'''; always 0}}
| '''Dependency Offset Count'''
| {{check}}
| Count of dependency offsets. This will be equal to the area script layer count + 1.
| {{check}}
| {{check}}
| {{nocheck}}
|-
|-
| u32
| u32
| 4
| ''Dependency Offset Count''
| '''Instance Count'''; always 0
| '''Dependency Offset Array'''
| {{check}}
| Array of offsets into the dependency array. There is one offset per script layer, with the offset referring to the index of that layer's first dependency. There is a final extra offset that points to area dependencies that are not layer-specific.
| {{check}}
| {{check}}
| {{nocheck}}
|}
|}


=== Audio Groups ===
===== Dependency =====
 
This section is only present in Prime 1. It contains a list of audio groups (AGSC files) used in this world. It begins with a 32-bit count value, then each audio group is defined as:


{| class="wikitable"
{| class="wikitable"
! Offset
! Type
! Type
! Size
! Count
! Description
! Name
! MP1
! MP2
! MP3
! DKCR
|-
|-
| u32
| 0x0
| 4
| Asset ID
| '''Group ID'''
| 1
| {{check}}
| '''Dependency Asset ID'''
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
|-
|-
| [[AGSC (File Format)|AGSC]]
| 0x4
| char
| 4
| 4
| '''Audio Group file'''
| '''Dependency Asset Type'''
| {{check}}
| {{nocheck}}
| {{nocheck}}
| {{nocheck}}
|}
|}


There's a string following this, at the end of the AGSC table.
==== Dock ====


{| class="wikitable"
{| class="wikitable"
! Type
! Type
! Size
! Count
! Description
! Name
! MP1
! Notes
! MP2
|-
! MP3
| u32
! DKCR
| 1
| '''Connecting Dock Count'''
| Count of docks connecting to this one. Typically 1 (but there are docks in Prime 3 that connect to multiple areas).
|-
| [[#Connecting Dock|Connecting Dock]]
| ''Connecting Dock Count''
| '''Connecting Dock Array'''
| Array describing all docks connected to this one.
|-
|-
| string
| u32
| 1
| 1
| {{unknown|'''Unknown'''; always empty}}
| '''Dock Coordinate Count'''
| {{check}}
| Array of dock coordinates in the next array.
| {{nocheck}}
|-
| {{nocheck}}
| Vector3
| {{nocheck}}
| ''Dock Coordinate Count''
| '''Dock Coordinates'''
| Exact purpose/function of this is not known yet.
|}
|}


=== Layer Info ===
===== Connecting Dock =====
 
The final section of the file contains some metadata related to each layer.
 
==== Layer Flags ====
 
This part attaches a set of 64-bit flags to every area, where each bit corresponds to a layer; if the bit is set, then that indicates that the corresponding layer will be enabled by default (on a new save file). Since the flags are 64 bits, that means the maximum number of layers that can be present in one area is 64.
 
After a 32-bit area count, the following structure is repeated for each area:


{| class="wikitable"
{| class="wikitable"
! Offset
! Type
! Type
! Size
! Name
! Description
! Notes
! MP1
! MP2
! MP3
! DKCR
|-
|-
| 0x0
| u32
| u32
| 4
| '''Area Index'''
| '''Area layer count'''
| Index of the area this dock is in.
| {{check}}
|  
| {{check}}
| {{check}}
| {{check}}
|-
|-
| u64
| 0x4
| 8
| u32
| '''Area layer flags'''
| '''Dock Index'''
| {{check}}
| Index of this dock within its area.
| {{check}}
| {{check}}
| {{check}}
|}
|}


==== Layer Names ====
==== Area Module Dependencies ====


This is a very simple list of layer name strings. For info on how each layer is actually attached to its corresponding area, check the [[#Layer Name Offsets|Layer Name Offsets]] section.
This is a data chunk appearing in the area definitions that describes all REL modules that must be linked in for this area to run. These are tied to script objects. The list is split per-layer so that only modules being used by the active layer are linked in; modules will appear once in the list for each layer that uses it. After the REL list, there is an array of offsets that points to the starting index in the list for each script layer, similar to the regular area dependencies list. For an unknown reason, the offsets list contains two offsets per layer. The first one refers to the layer's start index while the second one is usually empty, which effectively makes it an end index.


{| class="wikitable"
{| class="wikitable"
! Type
! Type
! Count
! Count
! Description
! Name
! MP1
! Notes
! MP2
! MP3
! DKCR
|-
|-
| u32
| u32
| 1
| 1
| '''Layer count''' (LC)
| '''REL Module Count'''
| {{check}}
| Count of REL modules in the next array.
| {{check}}
| {{check}}
| {{check}}
|-
|-
| string
| string
| LC
| ''REL Module Count''
| '''Layer names''' (zero-terminated)
| '''REL Module Array'''
| {{check}}
| REL modules used by this area. Each array entry is the filename of a .REL module.
| {{check}}
|-
| {{check}}
| u32
| {{check}}
| 1
| '''REL Offset Count'''
| Count of REL offsets in the next array. Should be equal to the area script layer count * 2.
|-
| u32
| ''REL Offset Count''
| '''REL Offset Array'''
| Array of offsets into the ''REL Module Array''. There are two offsets per script layer, with the first one being that layer's start index and the second one effectively being that layer's end index.
|}
|}


==== Layer IDs ====
=== Audio Group ===


This array is only present in Prime 3 and DKCR, and is used by layer-switching objects.
This structure is only present in Prime 1 and describes an [[AGSC (File Format)|AGSC]] file being used in this world.


{| class="wikitable"
{| class="wikitable"
! Offset
! Type
! Type
! Size
! Name
! Description
! Notes
! MP1
! MP2
! MP3
! DKCR
|-
|-
| 0x0
| u32
| u32
| 4
| '''Group ID'''
| '''Layer ID count''' (IC)
| Group ID for this audio group. This is the same value that can be found in the Project chunk in the referenced [[AGSC (File Format)|AGSC]] file.
| {{nocheck}}
|-
| {{nocheck}}
| 0x4
| {{check}}
| Asset ID ([[AGSC (File Format)|AGSC]])
| {{check}}
| '''AGSC ID'''
| The [[AGSC (File Format)|AGSC]] file for this audio group.
|-
|-
| u128
| 0x8
| 0x10 &times; IC
| colspan=3 {{unknown|End of audio group definition}}
| '''Layer ID'''
| {{nocheck}}
| {{nocheck}}
| {{check}}
| {{check}}
|}
|}


==== Layer Name Offsets ====
=== Area Layer Flags ===


The final layer info section provides one offset into the layer name table per area. This can be used to attach a layer's name to its corresponding data within the area.
This is a small structure that determines which areas are active by default. It contains a layer count and then a 64-bit flag, with each bit corresponding to a particular layer; if the bit is set, then the layer will be active on a new save file. The low-order bits correspond to the lower layer indices. Bits for layers that don't exist are defaulted to on.
 
Note that due to the size of these flags as well as a few other pieces of data in other formats, the maximum number of layers that can be contained in a single area is 64.


{| class="wikitable"
{| class="wikitable"
! Offset
! Type
! Type
! Count
! Name
! Description
! Notes
! MP1
! MP2
! MP3
! DKCR
|-
|-
| 0x0
| u32
| u32
| 1
| '''Layer Count'''
| '''Area count''' (AC)
| Count of layers in this area.
| {{check}}
|-
| {{check}}
| 0x4
| {{check}}
| u64
| {{check}}
| '''Layer Flags'''
| See above for a description of how these work.
|-
|-
| u32
| 0x8
| AC
| colspan=3 {{unknown|End of area layer flags}}
| '''Area layer names offsets'''
| {{check}}
| {{check}}
| {{check}}
| {{check}}
|}
|}


Anonymous user

Navigation menu