Skip to content

Compiling for Nintendo Switch

fgsfds edited this page Jul 5, 2022 · 10 revisions

1. Build the game for your native platform.

See the upstream wiki for directions. Needed to get the tools required to build the game. If you're using MSYS2 on Windows, switch to the MINGW64/32 environment and build it there.

2. Obtain the toolchain and dependencies.

You will need the latest version of devkitA64 and some Switch portlibs. You can install the dependencies using dkp-pacman:

(dkp-)pacman -S devkitA64 dkp-toolchain-vars switch-dev libnx switch-tools switch-mesa switch-libdrm_nouveau switch-sdl2

3. Build.

Obtain the switch branch of this repo, then cd to its directory and execute

source $DEVKITPRO/switchvars.sh
make -j4

There are additional options that can be enabled at compile time by appending them to the make invocation, e.g. make BETTERCAMERA=1 NODRAWINGDISTANCE=1 -j4:

  • BETTERCAMERA: enables analog camera movement and the camera settings menu (default 0);
  • NODRAWINGDISTANCE: enables the "unlimited draw distance" patch (default 0; some gameplay-related discrepancies may occur);
  • EXT_OPTIONS_MENU: enables the extended options menu (default 1; press R in the pause menu to open it);
  • EXTERNAL_DATA: enables loading resources from external files (the ones in the res folder; if you select this one, don't forget to copy that folder along with the NRO!).

Before executing make, if you wish, you can apply the 60 FPS patch:

git apply enhancements/60fps_ex.patch

4. Run.

The NRO is in build/{lang}_nx. Rename it to sm64.nro and copy it to sdmc:/switch/sm64. Run using hbmenu.

Additional info

By default A/B is bound to B/Y, because switch-sdl2 swaps A/B and X/Y to match the X360 positions and I don't like the fix I used in oldtesting. To rebind to A/X, either use the in-game menu or set these two lines in sm64config.txt:

key_a 0026 1001 1103 
key_b 0033 1003 1101