---===[ SM64DS LEVEL FORMAT DOC ]===---
By Mega-Mario
---===[ WHERE TO FIND THE DATA ]===---
In a clean ROM, the level data is found in overlays 8 to 59 (one overlay per level).
However, that level data has no unified structure, and is all surrounded with code and
data relating to certain objects, so it is a pain to modify without breaking the game.
SM64DSe, since version 1.1, creates new overlays (typically overlays 103 to 154), and moves
each level's data in its new overlay, restructuring it in a more unified structure. The new
overlays are also programmed to load the old overlays they are replacing, so that objects
relying on the old overlays still work.
---===[ LEVEL HEADERS ]===---
Level header as generated by SM64DSe v1.1 (patch version 2).
Offset Size Desc
00 84 Overlay initializer/deinitializer code
54 1 Object bank 0 setting
55 1 Object bank 1 setting
56 1 Object bank 2 setting
57 1 Object bank 3 setting
58 1 Object bank 4 setting
59 1 Object bank 5 setting
5A 1 Object bank 6 setting
5B 1 Zero
5C 4 Object bank 7 setting
60 4 Address of the CLPS chunk
64 4 Address of the 'misc' objects table
68 2 Internal file ID of the level model (.bmd)
6A 2 Internal file ID of the level collision map (.kcl)
6C 2 Internal file ID of the minimap tileset (.icg)
6E 2 Internal file ID of the minimap palette (.icl)
70 4 Address of the level area data
74 1 Number of level areas
75 1 Zero (?)
76 2 Scale factor for minimap coordinates
78 1 bit0-3: ??? (always 0xF), bit4-7: sky/background (0=none, or 1-11)
79 3 Zero (?)
7C 24 Reserved for future use
94 ... Level data
This header is generated by SM64DSe's patching, and isn't found under this form in the original game data.
However, the block from 0x60 to 0x7C (28 bytes) can be found in a similar format in the original level overlays,
but at varying offsets. The block from 0x54 to 0x5B (7 bytes) is originally hardcoded in the game binary.
The dword at 0x5C isn't an original feature of the game engine-- it is made possible by the new level format only.
All the data past 0x94 is copied from the original level overlays.
---===[ LEVEL AREA DATA ]===---
Each entry is 12 bytes. Number determined by header[0x74].
Offset Size Desc
00 4 Address of the objects table (NULL = no table)
04 4 Address of the texture animation data (NULL = no data)
08 1 Minimap tilemap index
09 3 ???
The objects table uses the same format as the one header[0x64] points to.
Except it typically only contains objects of type 0 and 5. The other object
types are contained by the header[0x64] table.
---===[ OBJECT TABLES ]===---
First part: 8 bytes
Offset Size Desc
00 4 Number of entries in table
04 4 Address of the object table
Object table: 8 bytes per entry
Offset Size Desc
00 1 Bit0-4: object type; Bit5-7: layer (0=all stars, 1-7=star 1..7)
01 1 Number of objects
02 2 Zero (?)
04 4 Address of the object list
Valid object types:
* 0: level objects, standard format (16 bytes per object)
* 1: level entrances (16 bytes per object)
* 2: path nodes (6 bytes per object)
* 3: paths (6 bytes per object)
* 4: views/camera anchors (14 bytes per object)
* 5: level objects, simple format (8 bytes per object)
* 6: teleport source points (8 bytes per object)
* 7: teleport dest. points (8 bytes per object)
* 8: fog (8 bytes per object)
* 9: doors/inter-area warps (12 bytes per object)
* 10: level exits (14 bytes per object)
* 11: minimap tilemap file IDs (2 bytes per object)
* 12: unknown (2 bytes per object)
* 14: unknown (4 bytes per object)
---===[ OBJECT TYPE 0: LEVEL OBJECTS (STANDARD) ]===---
16 bytes per object.
Offset Size Desc
00 2 Object ID
02 2 X position (divide by 1000 to obtain 3D coordinate)
04 2 Y position
06 2 Z position
08 2 Object-specific parameter (2)
0A 2 Y rotation (0x0400 = 90°)
0C 2 Object-specific parameter (3)
0E 2 Object-specific parameter (1)
The first two object-specific parameters (2 and 3 in SM64DSe) should be X and Z rotation, respectively.
However, most objects ignore them. A few objects use them as X/Z rotation, and some other objects use it for other purposes.
---===[ OBJECT TYPE 1: ENTRANCES ]===---
16 bytes per object.
Offset Size Desc
00 2 Must be zero (?)
02 2 X position
04 2 Y position
06 2 Z position
08 2 Parameter (?)
0A 2 Y rotation
0C 2 Parameter (?)
0E 2 Parameter (meaning=idk; weird)
---===[ OBJECT TYPE 2: PATH NODES ]===---
6 bytes per object.
Offset Size Desc
00 2 X position
02 2 Y position
04 2 Z position
06 6 Parameters (?)
---===[ OBJECT TYPE 3: PATHS ]===---
6 bytes per object.
Offset Size Desc
can't remember... wait
---===[ OBJECT TYPE 4: VIEWS/CAMERA ANCHORS ]===---
14 bytes per object.
---===[ OBJECT TYPE 5: LEVEL OBJECTS (SIMPLE) ]===---
8 bytes per object. This format is commonly used for objects like trees and coins, that don't require extensive parameters.
Offset Size Desc
00 2 bit0-8: object ID; bit 9-15: object-specific parameter (1)
02 2 X position
04 2 Y position
06 2 Z position
---===[ TEXTURE ANIMATION DATA ]===---
24 bytes per entry.
Offset Size Desc
00 4 Total number of frames?
04 4 Address of the scale values table (4 bytes each, 20:12 fixedpoint)
08 4 Address of the rotation values table (2 bytes each, 0x0400 = 90°)
0C 4 Address of the translation values table (4 bytes each, 20:12 fixedpoint. Translation orientation defined by rotation)
10 4 Number of animations
14 4 Address of the animation data
Animation data: 28 bytes per entry.
Offset Size Desc
00 4 ???
04 4 Address of the name of the material with the texture to animate (null-terminated ascii string)
08 4 ???
0C 2 Number of scale values
0E 2 Start offset in dwords in the scale values table
10 2 Number of rotation values
12 2 Start offset in words in the rotation values table
14 2 Number of translation values
16 2 Start offset in dwords in the translation values table
18 4 ???