MREA (Metroid Prime 3): Difference between revisions
Jump to navigation
Jump to search
no edit summary
>Aruki |
>Aruki No edit summary |
||
Line 1: | Line 1: | ||
The ''' | ''See [[MREA (File Format)]] for the other revisions of this format.'' | ||
The '''MREA format''', which defines areas/levels, received another large layout overhaul in Metroid Prime 3. The level geometry data received the biggest update, with a new material format, lot of things being moved around, and a few entirely new sections being introduced. | |||
{{research|moderate|There are a few sections we know nothing about.}} | |||
__TOC__ | __TOC__ | ||
== | == Format == | ||
MREA files are split up into a number of 32-byte aligned sections. Every section both starts and ends on a 32-byte boundary. These are used to separate different parts of the file; different types of sections typically indicate different sets of data. The header declares the section count and the size of each one; using these is the only way to navigate the file. | |||
=== Header === | |||
The header is identical between MP3 and DKCR. | |||
{| class="wikitable" | {| class="wikitable" | ||
!Offset | ! Offset | ||
!Size | ! Type | ||
!Description | ! Size | ||
! Description | |||
|- | |- | ||
|0x0 | | 0x0 | ||
|4 | | u32 | ||
|'''Magic Number''' 0xDEADBEEF | | 4 | ||
| '''Magic Number'''; always 0xDEADBEEF | |||
|- | |- | ||
|0x4 | | 0x4 | ||
|4 | | u32 | ||
|'''Version'''; see hub article | | 4 | ||
| '''Version'''; see [[MREA (File Format)|hub article]] | |||
|- | |- | ||
|0x8 | | 0x8 | ||
|48 | | float[12] | ||
|''' | | 48 | ||
| '''Transform matrix''' (transform of the area in world space) | |||
|- | |- | ||
|0x38 | | 0x38 | ||
|4 | | u32 | ||
|'''Mesh | | 4 | ||
| '''Mesh count''' | |||
|- | |- | ||
|0x3C | | 0x3C | ||
|4 | | u32 | ||
|'''Layer Count''' | | 4 | ||
| '''Layer Count''' | |||
|- | |- | ||
|0x40 | | 0x40 | ||
|4 | | u32 | ||
|'''Section Count''' | | 4 | ||
| '''Section Count''' (SC) | |||
|- | |- | ||
| | | 0x44 | ||
|4 | | u32 | ||
|'''Compressed Block Count''' | | 4 | ||
| '''Compressed Block Count''' | |||
|- | |- | ||
| | | 0x48 | ||
|4 | | u32 | ||
|'''Section Number Count''' | | 4 | ||
| '''Section Number Count''' | |||
|- | |||
| 0x4C | |||
| u32[SC] | |||
| - | |||
| '''Section Numbers''' | |||
|- | |||
| colspan=4 {{unknown|End of main header data; pad to 32 bytes before compressed section definitions}} | |||
|} | |} | ||
==Compressed | ==== Compressed Sections ==== | ||
Compressed sections are defined in the same manner as Metroid Prime 2. The MREA format contains compressed blocks that can each contain a number of regular file sections within them. These blocks are compressed using segmented LZO1X-999 in Metroid Prime 3, and segmented zlib in Donkey Kong Country Returns. Compressed sections are padded to 32 bytes, but their padding is located at the beginning of the section rather than the end, so it's required to account for the padding before you start decompressing. The compressed data is segmented, which means there's multiple segments of data that are compressed/decompressed separately. Each segment starts with a 16-bit size value. The size value is signed; a negative value indicates the segment is not compressed (this is done when compressing a segment doesn't reduce its size). Each segment is 0x4000 bytes large when decompressed (except the last one). | |||
Compressed sections are defined after the main header. After reading them, pad to 32 bytes before the section numbers portion of the header starts. | |||
{| class="wikitable" | {| class="wikitable" | ||
!Type | ! Offset | ||
!Description | ! Type | ||
! Size | |||
! Description | |||
|- | |||
| 0x0 | |||
| u32 | |||
| 4 | |||
| '''Buffer size''' | |||
|- | |- | ||
| | | 0x4 | ||
| | | u32 | ||
| 4 | |||
| '''Uncompressed data size''' | |||
|- | |- | ||
| | | 0x8 | ||
|Section | | u32 | ||
| 4 | |||
| '''Compressed data size''' | |||
|- | |||
| 0xC | |||
| u32 | |||
| 4 | |||
| '''Section count''' | |||
|} | |} | ||
==== Section Numbers ==== | |||
The section numbers portion of the header indicates the index of each major data chunk. Some of these chunks contain multiple sections; in that case the number will point to the first section of the chunk. Each number is a short 8-byte struct: | |||
{| class="wikitable" | |||
! Offset | |||
! Type | |||
! Size | |||
! Description | |||
|- | |||
| 0x0 | |||
| char[4] | |||
| 4 | |||
| Section type | |||
|- | |||
| 0x4 | |||
| u32 | |||
| 4 | |||
| Section number | |||
|} | |||
Here are all the possible section numbers and what they are: | |||
{| class="wikitable" | {| class="wikitable" | ||
Line 89: | Line 145: | ||
|- | |- | ||
| GPUD | | GPUD | ||
| | | GPU Data (level geometry) | ||
|- | |- | ||
| LITE | | LITE | ||
Line 119: | Line 175: | ||
|} | |} | ||
=== Materials === | === Materials === | ||
[[Materials (Metroid Prime 3)|Materials]] are identical to those found in [[CMDL (Metroid Prime 3)|CMDL]] files. | [[Materials (Metroid Prime 3)|Materials]] are identical to those found in [[CMDL (Metroid Prime 3)|CMDL]] files. |