These instructions explain how to set up the tools required to build pokefirered, which assembles the source files into a ROM.
These instructions come with notes which can be expanded by clicking the "Note..." text. In general, you should not need to open these unless if you get an error or if you need additional clarification.
If you run into trouble, ask for help on Discord or IRC (see README.md).
Windows has instructions for building with three possible terminals, providing 3 different options in case the user stumbles upon unexpected errors.
- Windows 10/11 (WSL1) (Fastest, highly recommended, Windows 10 and 11 only)
- Windows (msys2) (Second fastest)
- Windows (Cygwin) (Slowest)
Unscientific benchmarks suggest msys2 is 2x slower than WSL1, and Cygwin is 5-6x slower than WSL1.
Note for advanced users: WSL2...
WSL2 is an option and is even faster than WSL1 if files are stored on the WSL2 file system, but some tools may have trouble interacting with the WSL2 file system over the network drive. For example, tools which use Qt versions before 5.15.2 such as porymap may have problems with parsing the
\wsl$
network drive path.
All of the Windows instructions assume that the default drive is C:\. If this differs to your actual drive letter, then replace C with the correct drive letter when reading the instructions.
A note of caution: As Windows 7 is officially unsupported by Microsoft and Windows 8 has very little usage, some maintainers are unwilling to maintain the Windows 7/8 instructions. Thus, these instructions may break in the future with fixes taking longer than fixes to the Windows 10 instructions.
WSL1 is the preferred terminal to build pokefirered. The following instructions will explain how to install WSL1 (referred to interchangeably as WSL).
- If WSL (Debian or Ubuntu) is not installed, then go to Installing WSL1.
- Otherwise, if WSL is installed, but it hasn't previously been set up for another decompilation project, then go to Setting up WSL1.
- Otherwise, open WSL and go to Choosing where to store pokefirered (WSL1).
-
Open Windows Powershell as Administrator, and run the following command (Right Click or Shift+Insert is paste in the Powershell).
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
-
Once the process finishes, restart your machine.
-
The next step is to choose and install a Linux distribution from the Microsoft Store. The following instructions will assume Ubuntu as the Linux distribution of choice.
Note for advanced users...
You can pick a preferred Linux distribution, but setup instructions may differ. Debian should work with the given instructions, but has not been tested.
-
Open the Microsoft Store Linux Selection, click Ubuntu, then click Get, which will install the Ubuntu distribution.
Notes...
Note 1: If a dialog pops up asking for you to sign into a Microsoft Account, then just close the dialog.
Note 2: If the link does not work, then open the Microsoft Store manually, and search for the Ubuntu app (choose the one with no version number).
Some tips before proceeding:
- In WSL, Copy and Paste is either done via
- right-click (selection + right click to Copy, right click with no selection to Paste)
- Ctrl+Shift+C/Ctrl+Shift+V (enabled by right-clicking the title bar, going to Properties, then checking the checkbox next to "Use Ctrl+Shift+C/V as Copy/Paste").
- Some of the commands that you'll run will ask for your WSL password and/or confirmation to perform the stated action. This is to be expected, just enter your WSL password and/or the yes action when necessary.
-
Open Ubuntu (e.g. using Search).
-
WSL/Ubuntu will set up its own installation when it runs for the first time. Once WSL/Ubuntu finishes installing, it will ask for a username and password (to be input in).
Note...
When typing in the password, there will be no visible response, but the terminal will still read in input.
-
Update WSL/Ubuntu before continuing. Do this by running the following command. These commands will likely take a long time to finish:
sudo apt update && sudo apt upgrade
Note: If the repository you plan to build has an older revision of the INSTALL.md, then follow the legacy WSL1 instructions from here.
-
Certain packages are required to build pokefirered. Install these packages by running the following command:
sudo apt install build-essential binutils-arm-none-eabi git libpng-dev
Note...
If the above command does not work, try the above command but replacing
apt
withapt-get
.
WSL has its own file system that's not natively accessible from Windows, but Windows files are accessible from WSL. So you're going to want to store pokefirered within Windows.
For example, say you want to store pokefirered (and agbcc) in C:\Users\<user>\Desktop\decomps. First, ensure that the folder already exists. Then, enter this command to change directory to said folder, where <user> is your Windows username:
cd /mnt/c/Users/<user>/Desktop/decomps
Notes...
Note 1: The Windows C:\ drive is called /mnt/c/ in WSL.
Note 2: If the path has spaces, then the path must be wrapped with quotations, e.g.cd "/mnt/c/users/<user>/Desktop/decomp folder"
.
Note 3: Windows path names are case-insensitive so adhering to capitalization isn't needed
If this works, then proceed to Installation.
Otherwise, ask for help on Discord or IRC (see README.md), or continue reading below for Windows instructions using msys2.
- If devkitARM is not installed, then go to Installing devkitARM.
- If devkitARM is installed, but msys2 hasn't previously been set up for another decompilation project, then go to Setting up msys2.
- Otherwise, open msys2 and go to Choosing where to store pokefirered (msys2).
- Download the devkitPro installer here.
- Run the devkitPro installer. In the "Choose Components" screen, uncheck everything except GBA Development unless if you plan to install other devkitPro components for other purposes. Keep the install location as C:\devkitPro and leave the Start Menu option unchanged.
Note that in msys2, Copy is Ctrl+Insert and Paste is Shift+Insert.
-
Open msys2 at C:\devkitPro\msys2\mingw64.exe or run
C:\devkitPro\msys2\msys2_shell.bat -mingw64
. -
Certain packages are required to build pokefirered. Install these by running the following command:
pacman -S make zlib-devel git mingw-w64-x86_64-gcc mingw-w64-x86_64-libpng
Note...
This command will ask for confirmation, just enter the yes action when prompted.
At this point, you can choose a folder to store pokefirered into. If you're okay with storing pokefirered in the user profile folder, then proceed to Installation. Otherwise, you'll need to account for where pokefirered is stored when changing directory to the pokefirered folder.
For example, if you want to store pokefirered (and agbcc) in C:\Users\<user>\Desktop\decomps (where <user> is your Windows username), enter this command:
cd Desktop/decomps
If this works, then proceed to Installation.
Otherwise, ask for help on Discord or IRC (see README.md), or continue reading below for Windows instructions using Cygwin.
-
If devkitARM is not installed, then follow the instructions used to install devkitARM for the msys2 setup before continuing. Remember to not continue following the msys2 instructions by mistake!
-
- If Cygwin is not installed, or does not have all of the required packages installed, then go to Installing Cygwin.
- If Cygwin is installed, but is not configured to work with devkitARM, then go to Configuring devkitARM for Cygwin.
- Otherwise, open Cygwin and go to Choosing where to store pokefirered (Cygwin)
-
Download Cygwin: setup-x86_64.exe for 64-bit Windows, setup-x86.exe for 32-bit.
-
Run the Cygwin setup. Within the Cygwin setup, leave the default settings until the "Choose A Download Site" screen.
-
At "Choose a Download Site", select any mirror within the Available Download Sites.
-
At "Select Packages", set the view to "Full" (top left) and search for the following packages:
make
git
gcc-core
gcc-g++
libpng-devel
To quickly find these, use the search bar and type the name of each package. Ensure that the selected package name is the exact same as the one you're trying to download, e.g.
cmake
is NOT the same asmake
. -
For each package, double click on the text that says "Skip" next to each package to select the most recent version to install. If the text says anything other than "Skip", (e.g. Keep or a version number), then the package is or will be installed and you don't need to do anything.
-
Once all required packages have been selected, finish the installation.
Note that in Cygwin, Copy is Ctrl+Insert and Paste is Shift+Insert.
-
Open Cygwin.
-
Run the following commands to configure devkitPro to work with Cygwin.
export DEVKITPRO=/cygdrive/c/devkitpro echo export DEVKITPRO=$DEVKITPRO >> ~/.bashrc export DEVKITARM=$DEVKITPRO/devkitARM echo export DEVKITARM=$DEVKITARM >> ~/.bashrc
Note...
Replace the drive letter c with the actual drive letter if it is not c.
Cygwin has its own file system that's within Windows, at C:\cygwin64\home\<user>. If you don't want to store pokefirered there, you'll need to account for where pokefirered is stored when changing directory to the pokefirered folder.
For example, if you want to store pokefirered (and agbcc) in C:\Users\<user>\Desktop\decomps, enter this command, where <user> is your Windows username:
cd c:/Users/<user>/Desktop/decomps
Note that the directory must exist in Windows. If you want to store pokefirered in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Windows Explorer) before executing the cd
command.
Notes...
Note 1: If the path has spaces, then the path must be wrapped with quotations, e.g.
cd "c:/users/<user>/Desktop/decomp folder"
.
Note 2: Windows path names are case-insensitive so adhering to capitalization isn't needed
If this works, then proceed to Installation. Otherwise, ask for help on Discord or IRC (see README.md).
-
If the Xcode Command Line Tools are not installed, download the tools here, open your Terminal, and run the following command:
xcode-select --install
-
- If libpng is not installed, then go to Installing libpng (macOS).
- If devkitARM is not installed, then go to Installing devkitARM (macOS).
- Otherwise, open the Terminal and go to Choosing where to store pokefirered (macOS)
Note for advanced users...
This guide installs libpng via Homebrew as it is the easiest method, however advanced users can install libpng through other means if they so desire.
Note for Apple Silicon (M1) Mac users...
Currently, Homebrew and libng must be installed via Rosetta on Apple Silicon Macs. Before continuing, create a Terminal shell profile with Rosetta. Be sure to run the commands corresponding to Apple Silicon (M1).
-
Open the Terminal.
-
If Homebrew is not installed, then install Homebrew by following the instructions on the website.
-
Run the following command to install libpng.
brew install libpng # Intel Macs /usr/local/bin/brew install libpng # Apple Silicon (M1) Macs
libpng is now installed.
Continue to Installing devkitARM (macOS) if devkitARM is not installed, otherwise, go to Choosing where to store pokefirered (macOS).
-
Download the
devkitpro-pacman-installer.pkg
package from here. -
Open the package to install devkitPro pacman.
-
In the Terminal, run the following commands to install devkitARM:
sudo dkp-pacman -Sy sudo dkp-pacman -S gba-dev sudo dkp-pacman -S devkitarm-rules
The command with gba-dev will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation.
-
After the tools are installed, devkitARM must now be made accessible from anywhere by the system. To do so, run the following commands:
export DEVKITPRO=/opt/devkitpro echo "export DEVKITPRO=$DEVKITPRO" >> ~/.bashrc # Intel Macs echo "export DEVKITPRO=$DEVKITPRO" >> ~/.zshrc # Apple Silicon (M1) Macs export DEVKITARM=$DEVKITPRO/devkitARM echo "export DEVKITARM=$DEVKITARM" >> ~/.bashrc # Intel Macs echo "export DEVKITARM=$DEVKITARM" >> ~/.zshrc # Apple Silicon (M1) Macs echo "if [ -f ~/.bashrc ]; then . ~/.bashrc; fi" >> ~/.bash_profile # Intel Macs echo "if [ -f ~/.zshrc ]; then . ~/.zshrc; fi" >> ~/.zprofile # Apple Silicon (M1) Macs
At this point, you can choose a folder to store pokefirered into. If you're okay with storing pokefirered in the user folder, then proceed to Installation. Otherwise, you'll need to account for where pokefirered is stored when changing directory to the pokefirered folder.
For example, if you want to store pokefirered (and agbcc) in ~/Desktop/decomps, enter this command to change directory to the desired folder:
cd Desktop/decomps
Note that the directory must exist in the folder system. If you want to store pokefirered in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Finder) before executing the cd
command.
Note...
Note: If the path has spaces, then the path must be wrapped with quotations, e.g.
cd "Desktop/decomp folder"
If this works, then proceed to Installation. Otherwise, ask for help on Discord or IRC (see README.md).
Open Terminal and enter the following commands, depending on which distro you're using.
Run the following command to install the necessary packages:
sudo apt install build-essential binutils-arm-none-eabi git libpng-dev
Then proceed to Choosing where to store pokefirered (Linux).
Note for legacy repos...
If the repository you plan to build has an older revision of the INSTALL.md, then you will have to install devkitARM. Install all the above packages except binutils-arm-none-eabi, and follow the instructions to install devkitARM on Debian/Ubuntu-based distributions.
(Specific instructions for other distributions would be greatly appreciated!)
-
Try to find the required software in its repositories:
gcc
g++
make
git
libpng-dev
-
Follow the instructions here to install devkitPro pacman. As a reminder, the goal is to configure an existing pacman installation to recognize devkitPro's repositories.
-
Once devkitPro pacman is configured, run the following commands:
sudo pacman -Sy sudo pacman -S gba-dev
The last command will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation.
At this point, you can choose a folder to store pokefirered (and agbcc) into. If so, you'll have to account for the modified folder path when changing directory to the pokefirered folder.
If this works, then proceed to Installation. Otherwise, ask for help on Discord or IRC (see README.md).
Note for Windows users...
Consider adding an exception for the
pokefirered
and/ordecomps
folder in Windows Security using these instructions. This prevents Microsoft Defender from scanning them which might improve performance while building.
-
If pokefirered is not already downloaded (some users may prefer to download pokefirered via a git client like GitHub Desktop), run:
git clone https://github.com/pret/pokefirered
Note for WSL1...
If you get an error stating
fatal: could not set 'core.filemode' to 'false'
, then run the following commands:cd sudo umount /mnt/c sudo mount -t drvfs C: /mnt/c -o metadata,noatime cd <folder where pokefirered is to be stored>
Where <folder where pokefirered is to be stored> is the path of the folder where you chose to store pokefirered. Then run the
git clone
command again. -
Install agbcc into pokefirered. The commands to run depend on certain conditions. You should only follow one of the listed instructions:
-
If agbcc has not been built before in the folder where you chose to store pokefirered, run the following commands to build and install it into pokefirered:
git clone https://github.com/pret/agbcc cd agbcc ./build.sh ./install.sh ../pokefirered
-
Otherwise, if agbcc has been built before (e.g. if the git clone above fails), but was last built on a different terminal than the one currently used (only relevant to Windows, e.g. switching from msys2 to WSL1), then run the following commands to build and install it into pokefirered:
cd agbcc git clean -fX ./build.sh ./install.sh ../pokefirered
-
Otherwise, if agbcc has been built before on the same terminal, run the following commands to install agbcc into pokefirered:
cd agbcc ./install.sh ../pokefirered
Note...
> If building agbcc or pokefirered results in an error, try deleting the agbcc folder and re-installing agbcc as if it has not been built before.
-
Once agbcc is installed, change directory back to the base directory where pokefirered and agbcc are stored:
cd ..
Now you're ready to build pokefirered
If you aren't in the pokefirered directory already, then change directory to the pokefirered folder:
cd pokefirered
To build pokefirered.gba (Note: to speed up builds, see Parallel builds):
make
If it has built successfully you will have the output file pokefirered.gba in your project folder.
Note for Windows...
> If you switched terminals since the last build (e.g. from msys2 to WSL1), you must run `make clean-tools` once before any subsequent `make` commands.Pokemon FireRed and LeafGreen were both released together. As such, this project is capable of building both ROMs. To do so, simply run
make leafgreen
This project can also build the version 1.1 ROMs of both FireRed and LeafGreen. To build each, run
make firered_rev1 # for FireRed 1.1
make leafgreen_rev1 # for LeafGreen 1.1
See the GNU docs and this Stack Exchange thread for more information.
To speed up building, first get the value of nproc
by running the following command:
nproc
Builds can then be sped up by running the following command:
make -j<output of nproc>
Replace <output of nproc>
with the number that the nproc
command returned.
nproc
is not available on macOS. The alternative is sysctl -n hw.ncpu
(relevant Stack Overflow thread).
For contributing, or if you'd simply like to verify that your ROM is identical to the original game, run:
make compare # or compare_leafgreen, compare_firered_rev1, compare_leafgreen_rev1
If it matches, you will see the following at the end of the output:
pokefirered.gba: OK
If there are any changes from the original game, you will instead see:
pokefirered.gba: FAILED
shasum: WARNING: 1 computed checksum did NOT match
This project supports the arm-none-eabi-gcc
compiler included with devkitARM. If devkitARM (a.k.a. gba-dev) has already been installed as part of the platform-specific instructions, simply run:
make modern # or leafgreen_modern, firered_rev1_modern, leafgreen_rev1_modern
Otherwise, follow the instructions below to install devkitARM.
-
gdebi-core
must be installed beforehand in order to install devkitPro pacman (which facilitates the installation of devkitARM). Install this with the following command:sudo apt install gdebi-core
Note...
If the above command does not work, try the above command but replacing
apt
withapt-get
. -
Once
gdebi-core
is done installing, download the devkitPro pacman package here. The file to download isdevkitpro-pacman.amd64.deb
. -
Change directory to where the package was downloaded. For example, if the package file was saved to C:\Users\<user>\Downloads (the Downloads location for most users), enter this command, where *<user> is your Windows username:
cd /mnt/c/Users/<user>/Downloads
-
Once the directory has been changed to the folder containing the devkitPro pacman package, run the following commands to install devkitARM.
sudo gdebi devkitpro-pacman.amd64.deb sudo dkp-pacman -Sy sudo dkp-pacman -S gba-dev
The last command will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation.
Note...
Note:
devkitpro-pacman.amd64.deb
is the expected filename of the devkitPro package downloaded (for the first command). If the downloaded package filename differs, then use that filename instead. -
Run the following command to set devkitPro related environment variables (alternatively, close and re-open WSL):
source /etc/profile.d/devkit-env.sh
devkitARM is now installed.
-
If
gdebi-core
is not installed, run the following command:sudo apt install gdebi-core
-
Download the devkitPro pacman package here. The file to download is
devkitpro-pacman.amd64.deb
. -
Change directory to where the package was downloaded. Then, run the following commands to install devkitARM:
sudo gdebi devkitpro-pacman.amd64.deb sudo dkp-pacman -Sy sudo dkp-pacman -S gba-dev
The last command will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation.
Note:
devkitpro-pacman.amd64.deb
is the expected filename of the devkitPro package downloaded (for the first command). If the downloaded package filename differs, then use that filename instead. -
Run the following command to set devkitPro related environment variables (alternatively, close and re-open the Terminal):
source /etc/profile.d/devkit-env.sh
devkitARM is now installed.
To build using a toolchain other than devkitARM, override the TOOLCHAIN
environment variable with the path to your toolchain, which must contain the subdirectory bin
.
make TOOLCHAIN="/path/to/toolchain/here"
The following is an example:
make TOOLCHAIN="/usr/local/arm-none-eabi"
To compile the modern
target with this toolchain, the subdirectories lib
, include
, and arm-none-eabi
must also be present.
- porymap for viewing and editing maps
- poryscript for scripting (VS Code extension)
- Tilemap Studio for viewing and editing tilemaps