Skip to main content

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.

All C code in sm64dx is formatted with clang-format using a project-provided configuration file. Consistent formatting makes diffs easier to review and keeps the codebase uniform across contributions from many different developers. Before opening a pull request, run the formatting script described below.

Running clang-format

The repository includes a format.sh script that applies clang-format to all relevant source directories in one command:
bash format.sh
This formats files in three locations:
  • src/**/*.c — main game source
  • lib/src/*.c — libultra source
  • enhancements/*.inc.c — enhancement includes
To format one or more specific files instead:
bash format.sh src/game/mario.c src/game/camera.c
Internally, the script invokes:
clang-format -i -style=file <files>
The -style=file flag tells clang-format to read .clang-format from the project root.
Pull requests that include unformatted code will be asked to reformat before merging. Run format.sh as the last step before pushing.

clang-format settings

The .clang-format file at the root of the repository defines the following rules:
SettingValueEffect
IndentWidth4Four spaces per indentation level
UseTabNeverSpaces only — no tab characters
ColumnLimit104Lines wrap at 104 characters
PointerAlignmentRightPointer * is placed next to the variable name
BreakBeforeBracesAttachOpening braces attach to the preceding statement
AllowShortFunctionsOnASingleLinefalseFunctions always use multiple lines
AllowShortIfStatementsOnASingleLinefalseif bodies always use their own line
IndentCaseLabelstruecase labels are indented inside switch
AlignTrailingCommentstrueTrailing comments are column-aligned
SortIncludesfalse#include order is preserved as written
BreakBeforeBinaryOperatorsNonAssignmentBinary operators (except =) break before the operator
BreakBeforeTernaryOperatorstrueTernary ? and : break before the operator
SpaceAfterCStyleCasttrueA space follows C-style casts: (u8) value
The project changed from 3-space to 4-space indentation in Refresh 16 (PR #1189). If you are reading older code or older documentation, the current standard is 4 spaces.

Comment style

Use C-style block comments throughout the codebase:
/* This is a single-line block comment */

/*
 * This is a multi-line block comment
 * describing a more complex behavior.
 */
C++ // line comments are not part of the project style and should be avoided in new contributions.

Naming conventions

KindConventionExample
Functionssnake_casemario_update_geometry
Local variablessnake_casedist_to_floor
Global variablessnake_casegCurrentObject
Macros and #define constantsSCREAMING_SNAKE_CASEMARIO_WALL_KICK
Struct type namesPascalCaseMarioState, Object
Enum valuesSCREAMING_SNAKE_CASEACT_IDLE

clang-tidy checks

The project uses clang-tidy for an additional layer of static analysis. The .clang-tidy configuration at the repository root enables one check:
Checks: '-*,readability-braces-around-statements'
This enforces that all control-flow statements (if, else, for, while) have their bodies wrapped in braces, even when the body is a single statement. The FormatStyle: 'file' setting ensures any auto-fixes applied by clang-tidy also respect the .clang-format rules. The HeaderFilterRegex limits header analysis to files under src/, include/, and enhancements/:
HeaderFilterRegex: '(src|include|enhancements)\/.*\.h$'

Build docs developers (and LLMs) love