The sm64dx repository is a full decompilation of Super Mario 64 across five regional releases (JP, US, EU, Shindou, and iQue). The source tree separates hand-written C from extracted ROM assets, RSP microcode, build tooling, and level data into distinct directories so that each concern can be tracked, compiled, and compared independently. Understanding this layout is the first step to navigating the codebase.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Project516/sm64dx/llms.txt
Use this file to discover all available pages before exploring further.
Top-level directory tree
Directory reference
actors/
actors/
Contains per-object data tightly coupled to individual game objects: geo layout scripts that describe a model’s scene-graph hierarchy, display lists that emit RDP draw calls, and C files that hold behavior entry points. Each actor is typically a folder of
.inc.c files #included into a single translation unit so the linker can place them in the correct ROM segment.asm/
asm/
Handwritten MIPS assembly for routines that could not be decompiled to matching C—primarily hot paths in the graphics pipeline and certain math routines. The
non_matchings/ sub-directory collects stubs that compile correctly but do not yet produce byte-identical output to the original ROM.assets/
assets/
ROM-extracted binary data that does not live in C source. The
anims/ folder stores packed animation value and index arrays for every character animation; demos/ holds the controller input recordings played back on the title screen.bin/
bin/
Small C files whose sole purpose is to control link-time ordering of display lists and texture segments. They exist because the original ROM places certain data in specific positions within its segments, and the linker script must be able to reference them by symbol.
data/
data/
Contains
behavior_data.c, the single translation unit that #includes every behaviors/*.inc.c file and the shared behavior script tables. This aggregation pattern keeps individual behavior files small while allowing all behaviors to share a single compiled object and segment.include/
include/
Project-wide headers consumed by every subsystem. Key files are described in the Headers reference section below.
levels/
levels/
One sub-directory per level, each containing a
leveldata.c (display lists and collision meshes), a script.c (level script commands that set up the area), and a geo.c (geo layout commands that build the scene graph). The top-level level_commands.h and geo_commands.h headers provide the macro vocabulary used in these scripts.lib/
lib/
A snapshot of the Nintendo 64 SDK’s
libultra library. This code is compiled as-is from the original SDK; it provides the OS, controller, audio, and RCP interfaces (<PR/ultratypes.h>, <ultra64.h>, etc.).rsp/
rsp/
RSP (Reality Signal Processor) assembly in
.s format. The two main workloads are the audio synthesis ucode (mixed into PCM frames) and the Fast3D / F3DEX / F3DEX2 graphics microcode variants selected at build time via the GRUCODE variable.sound/
sound/
Binary sound banks (
.aiff-derived), sequence files (.m64 MIDI-like format), and bank definition JSON used by the build system to assemble the sound ROM. These are extracted from the original ROM and are not C source.text/
text/
Localized string tables for dialog, level names, and act names. The
.h.in template files are pre-processed by the build system to produce version-specific headers for JP, US, EU, Shindou, and iQue encodings.tools/
tools/
Python scripts (
extract_assets.py, diff.py, first-diff.py) and shell utilities used during the build. extract_assets.py reads the original ROM and writes extracted assets into assets/ and sound/.src/ subsystem breakdown
src/audio/
The audio driver: sequence player, synthesis engine, heap allocator, and load/DMA routines. Shindou-specific variants (
synthesis_sh.c, load_sh.c, port_sh.c) handle the Shindou release’s different audio session layout. See Audio system for a detailed breakdown.src/buffers/
Statically sized buffers allocated at link time: the main thread stack, the game/audio heap blocks, and the RSP task yield buffers. Keeping buffers in their own translation unit lets the linker script place them in specific BSS segments.
src/engine/
The four core script-processing engines—geo layout, level script, behavior script, and surface collision—plus
math_util.c (vector/matrix math) and surface_load.c (spatial hashing for collision triangles). See Game engine for details.src/game/
The bulk of the game: Mario’s action state machine, object list processing, camera, HUD, save files, interaction logic, area management, and all per-object behavior files in the
behaviors/ sub-directory. See Mario actions and Object behaviors.src/goddard/
A self-contained renderer for the Goddard (interactive Mario face) intro screen. It has its own math library, display-list emitter, and object system that is separate from the main game engine.
src/menu/
Title screen, file-select screen, act-select screen, and the debug level-select menu. These share some rendering helpers with
src/game/ but are compiled separately to allow version-specific differences.Headers reference
Theinclude/ directory provides types and constants consumed across the entire project.
types.h
Defines the core data structures:
MarioState, Object, ObjectNode, Surface, GraphNode, GraphNodeObject, Animation, AnimInfo, Controller, ObjectHitbox, and the primitive typedefs (Vec3f, Vec3s, Mat4, BehaviorScript, LevelScript, GeoLayout, etc.). Almost every C file in src/ includes this header directly or transitively.config.h
A single configuration header with
#define flags for version-specific bug fixes (BUGFIX_* macros), rumble pak support (ENABLE_RUMBLE), screen dimensions (SCREEN_WIDTH, SCREEN_HEIGHT), and stack size constants. Consumers #include it via types.h.object_fields.h
Provides the
OBJECT_FIELD_* macro family that maps named object fields (oPosX, oForwardVel, oFaceAngleYaw, etc.) to indices into Object.rawData. This indirection keeps field access portable between 32-bit and 64-bit host builds.object_constants.h
Enumerates action IDs, interaction types (
INTERACT_BOUNCE_TOP, INTERACT_DAMAGE, etc.), object flags, and other integer constants referenced by behavior scripts and the interaction system.seq_ids.h / sounds.h
seq_ids.h declares the SeqId enum covering all 35 background music and event sequences. sounds.h encodes sound effect identifiers as packed 32-bit words combining bank, sound ID, priority, and status nibbles.