Models and textures
The HSD model archive and the TPL texture file, as the game reads them.
- Where
- Model/*.MRG (HSD archives), texture/*.MRG (TPL)
- Model format
- HSD archive (HAL sysdolphin), 601 on the disc
- Texture format
- TPL (magic 0x0020AF30)
- Monster model size limit
- 0x80000 bytes (512 KB)
HSD archives
The game’s 3D engine is HAL Laboratory’s sysdolphin library (HSD), the same family Super Smash Bros. Melee uses, in a different and smaller build: its base library only, without Melee’s object, audio and memory card modules. Every model, scenery piece, camera and light set is an HSD archive:
| Part | Content |
|---|---|
Header, 0x20 bytes |
file size, data size, relocation count, public-symbol count, extern count, version |
| Data block | the objects: joints, meshes, materials, textures, animations |
| Relocation table | the offset of every 32-bit pointer inside the data |
| Public symbols | offset plus name |
| Externs, strings | the names |
On load every pointer is relocated in place. The game looks up a single symbol, scene_data, a structure of four pointers: model sets, camera, light sets and fog. Every archive has a model-set list, a camera and a light-set list; only 41 of the 601 have fog. The game reads only the first two.
A model set names a joint tree and lists its animations: joint animations, material animations and shape animations, one list entry per animation set. Display lists, vertex arrays, texture data and animation keyframes are left in the GameCube’s native big-endian form and drawn as they are.
Monster models: positions, normals and texture coordinates are float arrays indexed by 16-bit numbers and shared by every mesh part of the model; display lists use quads and triangle strips. Skinned monsters keep all their mesh parts on the skeleton root and blend up to ten joint matrices per part. Rigid monsters (Robotic Knight, for example) hang each piece on its own joint. The order of mesh parts matters to the game, which can hide parts by a 256-bit mask over them in order.
Writing an archive back with its pointers in ascending order and its names in a string table reproduces all 601 archives of the disc byte for byte, which suggests the original tool wrote them that way.
TPL textures
A TPL file starts with the magic 0x0020AF30:
| Structure | Size | Fields |
|---|---|---|
| File header (the SDK’s TEXPalette) | 0x0C |
magic, image count, offset of the descriptor table |
| Descriptor | 0x08 |
image header offset, palette header offset |
| Image header | 0x24 |
width and height, GX format, data offset, wrap modes, filters, LOD |
| Palette (CLUT) header | 0x0C |
Offsets become pointers when the game relocates a loaded TPL in place. Texture data and palettes are in the GameCube’s native formats.
The texture archives are SYSTEM.MRG (7 members), MINIMAP.MRG (23 × 0x1240), PICTURE.MRG (188 × 0x1240: 96 × 96 card pictures in CMPR; entries 0xB1-0xBA are empty (all zero) and entry 0xBB is a question-mark placeholder picture), GENERAL.MRG (57) and BASE.MRG (18) at 0x1840 each, EVENT.MRG (9) and EFFECT.MRG (1).
Evidence
The archive loader and the HSD library are part of the decompiled code. The byte-for-byte rebuild of all 601 archives was used to confirm the layout. The counts come from the archives and the offset tables in main.dol.