Setting Up Modifying the Game's Code
So, you're ready to dive into the code of the game? Let's get started!
In this tutorial, you will learn how to:
This guide will cover the "NCPatcher Standalone" method described in the code template as the steps are more synchronized between all operating systems.
Setting Up the Code Template
Don't put any spaces in your folder name!
You have now set up the code template
Setting up ARM GCC
Pick a location without spaces to install the toolchain!
You have now set up ARM GCC
Setting Up NCPatcher
Now, NCPatcher depends on ncpatcher.json, so lets make it!
If you'd like to learn more about this file, head over to the NCPatcher GitHub!
In your project root, create the following files:
{"$arm_flags": "-masm-syntax-unified -mno-unaligned-access -mfloat-abi=soft -mabi=aapcs","$c_flags": "-Os -fomit-frame-pointer -ffast-math -fno-builtin -nostdlib -nodefaultlibs -nostartfiles -DSDK_GCC -DSDK_FINALROM","$cpp_flags": "-fno-rtti -fno-exceptions -std=c++20","$asm_flags": "-Os -x assembler-with-cpp -fomit-frame-pointer","$ld_flags": "-lgcc -lc -lstdc++ --use-blx","backup": "backup","filesystem": "nsmb","toolchain": "arm-none-eabi-","arm7": {},"arm9": {"target": "arm9.json","build": "build"},"pre-build": [],"post-build": [],"thread-count": 0}
You have now set up NCPatcher
Extracting, Building, and Repackaging Your ROM
If you're on Windows
If you're on macOS/Linux
Now, you need to build the tools.
For NDS Extract:
For NDS Build:
From here on, the instructions will work for all operating systems. If you are on Windows 10, you can use Command Prompt instead of Terminal
Extracting Your ROM
Replace /path/to/ with the actual file path to nds-extract. Also replace "rom" with the actual name of your .nds file
This will extract the contents of your ROM into a folder named nsmb
You have extracted your ROM
Building Your ROM
This step will compile and patch your ROM with any code files found in the source directory in your project root. The Code Template comes with a few examples included in the source directory.
Replace /path/to/ with the actual file path to ncpatcher
You have built your ROM
Repackaging Your ROM
nds-extract depends on buildrules.txt, so let's create it!
rom_header NSNDY/header.bin
arm9_entry KEEP
arm9_load KEEP
arm7_entry KEEP
arm7_load KEEP
fnt nsmb/fnt.bin
file_mode ADJUST
arm9 nsmb/arm9.bin
arm7 nsmb/arm7.bin
arm9ovt nsmb/arm9ovt.bin
arm7ovt nsmb/arm7ovt.bin
icon nsmb/banner.bin
rsa_sig nsmb/rsasig.bin
data nsmb/root
ovt_repl_flag 0xFF
ov9 nsmb/overlay9
ov7 nsmb/overlay7
This step will take the files form the nsmb folder and repackage them into a .nds file
Replace /path/to/ with the actual file path to nds-build.
You have repackaged your ROM