The SM64 decompilation exposes two layers of configuration. Runtime behaviour — bug fixes, hardware feature flags, screen dimensions, and stack sizes — is controlled by preprocessor defines inDocumentation 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.
include/config.h. The toolchain and ROM target are controlled by Makefile variables that you pass on the make command line. This page documents both layers in full.
include/config.h
config.h is described in its own header comment as “a catch-all file for configuring various bugfixes and other settings in SM64.” Every define here is evaluated at compile time via the C preprocessor.
Bug fixes
Nintendo introduced a number of bug fixes in regional versions released after the original Japanese launch. Each fix is individually togglable via aBUGFIX_* define. The default value for each define is a logical OR expression: it evaluates to 1 (enabled) whenever the active VERSION_* token matches one of the listed versions, and 0 otherwise.
config.h.BUGFIX_MAX_LIVES — coin overflow sets wrong life count
BUGFIX_MAX_LIVES — coin overflow sets wrong life count
BUGFIX_KING_BOB_OMB_FADE_MUSIC — boss music does not fade after King Bob-omb
BUGFIX_KING_BOB_OMB_FADE_MUSIC — boss music does not fade after King Bob-omb
BUGFIX_KOOPA_RACE_MUSIC — warp stops Koopa race music in Bob-omb Battlefield
BUGFIX_KOOPA_RACE_MUSIC — warp stops Koopa race music in Bob-omb Battlefield
BUGFIX_PIRANHA_PLANT_STATE_RESET — Piranha Plants do not reset when player leaves
BUGFIX_PIRANHA_PLANT_STATE_RESET — Piranha Plants do not reset when player leaves
BUGFIX_PIRANHA_PLANT_SLEEP_DAMAGE — sleeping Piranha Plants damage Mario
BUGFIX_PIRANHA_PLANT_SLEEP_DAMAGE — sleeping Piranha Plants damage Mario
BUGFIX_STAR_BOWSER_KEY — star shown when picking up a Bowser key
BUGFIX_STAR_BOWSER_KEY — star shown when picking up a Bowser key
BUGFIX_DIALOG_TIME_STOP — Mario enters time stop before ready to speak
BUGFIX_DIALOG_TIME_STOP — Mario enters time stop before ready to speak
BUGFIX_BOWSER_COLLIDE_BITS_DEAD — Bowser collision persists in BitS after defeat
BUGFIX_BOWSER_COLLIDE_BITS_DEAD — Bowser collision persists in BitS after defeat
BUGFIX_BOWSER_FALLEN_OFF_STAGE — Bowser retains speed after falling off the stage
BUGFIX_BOWSER_FALLEN_OFF_STAGE — Bowser retains speed after falling off the stage
BUGFIX_BOWSER_FADING_OUT — Bowser looks incorrect while fading out
BUGFIX_BOWSER_FADING_OUT — Bowser looks incorrect while fading out
Hardware feature flags
ENABLE_RUMBLE
1 explicitly if you want to add rumble support to a JP, US, or EU build.
Screen dimensions
Stack sizes
STACKSIZE (8 KB) is the stack for thread5_game_loop, the main game thread. IDLE_STACKSIZE (2 KB) is for the idle thread. UNUSED_STACKSIZE (5 KB) is allocated but not actively used by any thread in the shipped code.
Border height
BORDER_HEIGHT controls the number of blank scanlines added at the top and bottom of the screen. On NTSC hardware (JP, US, SH, CN) this is 8 pixels; on PAL hardware (EU) it is 1 pixel. When building for a non-N64 target (TARGET_N64 = 0), the border is removed entirely since there is no hardware blanking requirement.
Makefile build variables
These variables are passed on themake command line. For example:
make clean before changing any build variable that affects code generation to avoid stale objects.
VERSION
VERSION_* preprocessor define is set, which in turn gates version-specific code in config.h and elsewhere.
| Value | Region | Year | Notes |
|---|---|---|---|
jp | Japan | 1996 | Original release. Most BUGFIX_* defines are inactive. |
us | North America | 1996 | Default. All major bug fixes active. |
eu | PAL / Europe | 1997 | Adds multilingual text support (English, German, French). |
sh | Japan (Shindou) | 1997 | Includes Rumble Pak support. |
cn | China (iQue) | 2003 | iQue Player port. Includes Rumble Pak support. Uses a different linker and compiler for some files. |
sm64.<VERSION>.z64, placed in build/<VERSION>/.
GRUCODE
| Value | Name | Default for | Notes |
|---|---|---|---|
f3d_old | Fast3D (original) | jp, us | Sets F3D_OLD=1. |
f3d_new | Fast3D 2.0H | eu, sh, cn | Sets F3D_NEW=1. |
f3dex | Fast3DEX | — | Sets F3DEX_GBI=1 and F3DEX_GBI_SHARED=1. |
f3dex2 | Fast3DEX2 | — | Sets F3DEX_GBI_2=1 and F3DEX_GBI_SHARED=1. |
f3dzex | Fast3DZEX | — | Experimental. Used in Animal Crossing (Dōbutsu no Mori). Sets F3DZEX_GBI_2=1. |
COMPARE automatically, since the resulting ROM will not match the original SHA-1 hash.
COMPILER
| Value | Compiler | Effect |
|---|---|---|
ido | SGI IRIS Development Option (IDO 5.3) | Default. Required to produce a matching ROM. Uses -mips2. |
gcc | GNU C Compiler (cross-compiled for MIPS) | Forces NON_MATCHING=1, uses -mips3 and -O2. |
COMPILER=ido, the build can use either qemu-irix (USE_QEMU_IRIX=1) or a statically recompiled IDO binary (USE_QEMU_IRIX=0, the default). The MIPS cross-compiler prefix is detected automatically from whichever of mips-linux-gnu-, mips64-linux-gnu-, or mips64-elf- is found on PATH.
NON_MATCHING
| Value | Behaviour |
|---|---|
0 | Matching build. Requires COMPILER=ido. Enables COMPARE=1 by default. |
1 | Non-matching build. Enables AVOID_UB=1 and forces COMPARE=0. Automatically set when COMPILER=gcc or TARGET_N64=0. |
NON_MATCHING=1, the preprocessor defines NON_MATCHING=1 and AVOID_UB=1 are passed to the compiler.
AVOID_UB and the BAD_RETURN macro
WhenNON_MATCHING=1, the AVOID_UB=1 preprocessor define is enabled. This activates portable replacements for code that relies on undefined behaviour present in IDO’s code generation. The primary example is the BAD_RETURN macro used in certain functions where the original IDO compiler happened to produce correct output from technically undefined C.
The BAD_RETURN macro is defined in the codebase to emit a return value in a way that avoids UB under GCC while still matching the IDO output when AVOID_UB is not set.
COMPARE
1, the build system verifies the SHA-1 hash of the generated ROM against the known-good hash for the selected version after linking. A mismatch prints a warning but does not abort the build.
COMPARE is automatically set to 0 when:
NON_MATCHING=1is active- A non-default
GRUCODEis selected for the currentVERSION TARGET_N64=0
COMPARE=0 explicitly.
TARGET_N64
1 (the default), the build targets real N64 hardware. This enables -DTARGET_N64, -D_LANGUAGE_C, and -DTARGET_N64 in the compiler flags, and adds include/libc to the include path.
Setting TARGET_N64=0 is the entry point for PC ports and other non-N64 targets. It automatically forces NON_MATCHING=1 and sets BORDER_HEIGHT to 0.
CROSS
The MIPS toolchain prefix is auto-detected in this order:mips-linux-gnu-mips64-linux-gnu-mips64-elf-
Summary table
| Variable | Default | Valid values | Description |
|---|---|---|---|
VERSION | us | jp us eu sh cn | Game region to build |
GRUCODE | version-dependent | f3d_old f3dex f3dex2 f3d_new f3dzex | RSP microcode |
COMPILER | ido | ido gcc | C compiler |
NON_MATCHING | 0 | 0 1 | Allow non-matching output |
COMPARE | 1 | 0 1 | Verify ROM SHA-1 after build |
TARGET_N64 | 1 | 0 1 | Build for N64 hardware |
CROSS | auto-detected | any MIPS toolchain prefix | MIPS toolchain prefix |
USE_QEMU_IRIX | 0 | 0 1 | Use qemu-irix for IDO compiler |
VERBOSE | 0 | 0 1 | Print full build commands |
COLOR | 1 | 0 1 | Colorize build output |