Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/n64decomp/sm64/llms.txt

Use this file to discover all available pages before exploring further.

The SM64 decompilation is organized so that every part of the original game’s source corresponds to a clearly named directory. This page walks through each top-level folder and the most important files inside it.

Top-level directory overview

sm64/
├── actors/        # Per-object geo layout, display lists, and behavior data
├── asm/           # Handwritten MIPS assembly; non-matching stubs
├── assets/        # Animation sequences and demo input recordings
├── bin/           # C files controlling display list and texture ordering
├── build/         # Compiler output (generated; not tracked in git)
├── data/          # Behavior scripts and miscellaneous data tables
├── doxygen/       # Doxygen configuration for generating API docs
├── enhancements/  # Example source modifications and optional features
├── include/       # Header files shared across the codebase
├── levels/        # Per-level scripts, geo layout, and display lists
├── lib/           # Nintendo 64 SDK library code
├── rsp/           # Audio and Fast3D RSP (Reality Signal Processor) microcode
├── sound/         # Music sequences, sound samples, and sound banks
├── src/           # All C source code for the game
├── text/          # Dialog strings, level names, and act names
├── textures/      # Skybox panels and shared texture data
└── tools/         # Build-time asset extraction and conversion scripts

Source code (src/)

The src/ directory contains all game logic written in C. It is divided into six sub-directories:
The largest source directory. Contains Mario’s physics, the object system, rendering, save files, HUD, camera, and all gameplay systems.Key files:
FilePurpose
mario.c / mario.hTop-level Mario state: position, velocity, health, action dispatch
mario_actions_airborne.cAirborne actions: jumping, falling, long jump, ground pound
mario_actions_moving.cGround movement: walking, running, sliding, crouching
mario_actions_submerged.cUnderwater movement and swimming
mario_actions_stationary.cIdle, sitting, sleeping, and transition states
mario_actions_cutscene.cCutscene-controlled Mario states
mario_actions_object.cObject-interaction states: carrying, throwing, riding
mario_actions_automatic.cAutomated movement: pole climbing, vine hanging
mario_step.cStepping and quarter-step collision resolution
mario_misc.cMario model, cap, and miscellaneous helpers
camera.c / camera.hAll camera modes, cutscene cameras, lakitu logic
object_list_processor.cProcesses the active object list each frame
obj_behaviors.cBehavior execution for most interactive objects
obj_behaviors_2.cAdditional behavior execution (overflow from above)
object_collision.cObject-to-object and object-to-Mario collision
object_helpers.cShared utilities used by object behaviors
interaction.cMario-object interaction dispatch (coins, enemies, etc.)
level_update.cPer-frame level tick: area transitions, warp logic
area.cArea loading, geo graph setup, and skybox selection
rendering_graph_node.cGeo graph traversal and display list generation
geo_misc.cMiscellaneous geo node callbacks
save_file.cEEPROM save/load, star flags, course completion
hud.cOn-screen HUD elements: lives, coins, stars, power meter
ingame_menu.cPause menu and in-game selection screens
sound_init.cAudio system initialization and sequence triggering
spawn_object.cObject instantiation from behavior data
spawn_sound.cSound spawning helpers used by objects and Mario
memory.cCustom memory allocator (heap segments)
game_init.cBoot sequence, task scheduling, main game loop entry
main.cN64 entry point and thread setup
shadow.cCircular shadow rendering under Mario and objects
skybox.cScrolling skybox rendering
paintings.cWarp painting animation and entry detection
envfx_snow.cSnow particle effects
envfx_bubbles.cBubble particle effects
moving_texture.cAnimated water and lava texture scrolling
platform_displacement.cCarries Mario on moving platforms
screen_transition.cFade in/out transitions between areas
debug.cDebug display and developer tools
print.cOn-screen text rendering
profiler.cFrame timing profiler
crash_screen.cN64 crash handler display
Contains the interpreters and utilities that drive levels, geo graphs, and object behaviors, plus the core math library.
FilePurpose
behavior_script.c / .hBehavior script bytecode interpreter; runs object bhv scripts
level_script.c / .hLevel script interpreter; loads areas, spawns objects, sets music
geo_layout.c / .hGeo graph script interpreter; builds the scene graph
graph_node.c / .hGeo graph node types and traversal structure
graph_node_manager.cAllocates and frees geo graph nodes
surface_collision.c / .hTriangle-based floor, wall, and ceiling collision queries
surface_load.c / .hLoads collision surface lists into memory for the current area
math_util.c / .hFixed-point and floating-point math, matrix operations, trig
stub.cEmpty stubs for functions stripped in certain versions
Houses the software audio sequencer, sound effect player, and ADSR envelope system. The audio engine runs on the N64’s RSP in tandem with the game thread.The corresponding RSP microcode is in rsp/, and the audio data (samples, banks, sequences) lives in sound/.
Declares and reserves stack memory, heap buffers, and task buffers used by the N64 OS task scheduler.
Self-contained module that renders the interactive face on the title screen (“It’s-a me, Mario!”). Uses its own renderer and input handler, separate from the main game.
Title screen, file select, act select, and debug level select. Also handles star selection and save-slot management UI.

Headers (include/)

Shared header files used across src/, actors/, and levels/.
FilePurpose
types.hCore type definitions: Vec3f, Vec3s, Mat4, Object, MarioState
object_fields.hMacro accessors for the generic object field array (oFlags, oPosX, etc.)
object_constants.hObject action and flag constants
config.hBuild-time bug fixes and screen/stack size constants, conditioned on VERSION_*
sm64.hGlobal constants: star counts, coin values, health units
macros.hGeneral-purpose macros used throughout the codebase
behavior_data.hExtern declarations for all behavior script arrays
model_ids.hNumeric IDs for all loaded model segments
seq_ids.hSequence (music track) identifiers
sounds.hSound effect identifiers
level_table.hTable of all level IDs
course_table.hTable of all course (star-bearing level) IDs
dialog_ids.hIDs for all in-game dialog boxes
mario_animation_ids.hNumeric IDs for all Mario animations
geo_commands.hMacros for writing geo layout scripts
level_commands.hMacros for writing level scripts
surface_terrains.hSurface type and terrain constants (ice, lava, water, etc.)
ultra64.hNintendo 64 SDK type and function declarations

Levels (levels/)

Each level has its own subdirectory. Inside each level directory you typically find:
  • script.c — level script that loads geometry, sets music, spawns macro objects
  • geo.c — geo layout script for the level’s scene graph
  • leveldata.c — display lists and vertex data
  • collision.c — collision surface data
Level directories include all 15 main courses, the castle interior, castle grounds, courtyard, Bowser stages, bonus levels, and menu/intro areas:
bob/ (Bob-omb Battlefield), wf/ (Whomp’s Fortress), jrb/ (Jolly Roger Bay), ccm/ (Cool, Cool Mountain), bbh/ (Big Boo’s Haunt), hmc/ (Hazy Maze Cave), lll/ (Lethal Lava Land), ssl/ (Shifting Sand Land), ddd/ (Dire, Dire Docks), sl/ (Snowman’s Land), wdw/ (Wet-Dry World), ttm/ (Tall, Tall Mountain), thi/ (Tiny-Huge Island), ttc/ (Tick Tock Clock), rr/ (Rainbow Ride)
castle_inside/, castle_grounds/, castle_courtyard/, sa/ (Secret Aquarium), cotmc/ (Cavern of the Metal Cap), totwc/ (Tower of the Wing Cap), vcutm/ (Vanish Cap Under the Moat), pss/ (Princess’s Secret Slide), wmotr/ (Wing Mario Over the Rainbow)
bowser_1/, bowser_2/, bowser_3/, bitdw/ (Bowser in the Dark World), bitfs/ (Bowser in the Fire Sea), bits/ (Bowser in the Sky)
intro/, ending/, menu/ — title screen, ending cutscene, and file/act select maps. entry.c / entry.h provide the shared level entry point.

Actors (actors/)

Each enemy, NPC, collectible, and interactive object has a subdirectory containing its geo layout script and display list data. Examples include mario/, goomba/, bowser/, koopa/, chain_chomp/, star/, coin/, door/, warp_pipe/, and roughly 150 others. Group files (group0.c through group17.c, common0.c, common1.c) aggregate actors into segment groups for memory management. The _geo.c variants contain only the geo layout scripts for those groups.

Data and assets

DirectoryContents
data/Behavior script tables and miscellaneous data arrays
assets/anims/Animation frame data for Mario and other characters
assets/demos/Recorded demo input sequences played on the title screen
sound/Sequences (.m64), sound banks, and sample data
textures/Skybox face images and generic shared textures
text/Dialog strings, level names, and act names (localized per version)
bin/C files that control the link order of display lists and textures

Assembly (asm/)

Hand-written MIPS assembly for sections that cannot yet be matched by the C compiler. The asm/non_matchings/ subdirectory contains stubs for functions where C reconstruction is in progress.

Tools (tools/)

Build-time Python and C programs used to extract, convert, and assemble assets:
File / directoryPurpose
assemble_sound.pyPackages sound sequences and banks into ROM format
mario_anims_converter.pyConverts animation data for the build
demo_data_converter.pyConverts demo recordings
aifc_decode.cDecodes AIFF-C audio files
aiff_extract_codebook.cExtracts ADPCM codebooks from AIFF files
skyconv.cConverts skybox images
textconv.cConverts dialog and text strings
seq_decoder.pyDecodes binary sequence files
asm-processor/Processes inline assembly embedded in C files for the IDO compiler
ido5.3_compiler/Bundled SGI IDO 5.3 compiler (used for matching builds)
sm64tools/Utilities for ROM inspection and patching
sdk-tools/Nintendo 64 SDK tool wrappers

Miscellaneous

DirectoryContents
lib/Nintendo 64 SDK library object files and headers
rsp/RSP microcode for the audio engine and Fast3D graphics
enhancements/Example patches showing how to extend or modify the game
doxygen/Configuration for generating Doxygen HTML API documentation
build/Generated output directory; contains compiled objects and the final ROM

Build docs developers (and LLMs) love