All C code in sm64dx is formatted withDocumentation 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.
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 aformat.sh script that applies clang-format to all relevant source directories in one command:
src/**/*.c— main game sourcelib/src/*.c— libultra sourceenhancements/*.inc.c— enhancement includes
-style=file flag tells clang-format to read .clang-format from the project root.
clang-format settings
The.clang-format file at the root of the repository defines the following rules:
| Setting | Value | Effect |
|---|---|---|
IndentWidth | 4 | Four spaces per indentation level |
UseTab | Never | Spaces only — no tab characters |
ColumnLimit | 104 | Lines wrap at 104 characters |
PointerAlignment | Right | Pointer * is placed next to the variable name |
BreakBeforeBraces | Attach | Opening braces attach to the preceding statement |
AllowShortFunctionsOnASingleLine | false | Functions always use multiple lines |
AllowShortIfStatementsOnASingleLine | false | if bodies always use their own line |
IndentCaseLabels | true | case labels are indented inside switch |
AlignTrailingComments | true | Trailing comments are column-aligned |
SortIncludes | false | #include order is preserved as written |
BreakBeforeBinaryOperators | NonAssignment | Binary operators (except =) break before the operator |
BreakBeforeTernaryOperators | true | Ternary ? and : break before the operator |
SpaceAfterCStyleCast | true | A 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:// line comments are not part of the project style and should be avoided in new contributions.
Naming conventions
| Kind | Convention | Example |
|---|---|---|
| Functions | snake_case | mario_update_geometry |
| Local variables | snake_case | dist_to_floor |
| Global variables | snake_case | gCurrentObject |
Macros and #define constants | SCREAMING_SNAKE_CASE | MARIO_WALL_KICK |
| Struct type names | PascalCase | MarioState, Object |
| Enum values | SCREAMING_SNAKE_CASE | ACT_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:
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/: