pokeemerald Documentation

repository·master·Indexed 25 days ago

https://github.com/pret/pokeemerald

A decompilation project for Pokémon Emerald that enables developers to build and modify the game ROM. This documentation covers environment setup across WSL1, Windows (msys2, Cygwin), macOS, and Linux, as well as technical details on the gMain struct, interrupt callbacks, and the wav2agb tool for converting .wav files to GBA-compatible formats.

Tokens
6.2K
Snippets
18
Records
51
Agent score
85%

What's inside pokeemerald

  1. Overview of Pokémon Emerald Decompilation

    master

    This repository is a decompilation of the Pokémon Emerald ROM. It is designed to build a specific ROM file with the following checksum for verification:

    • Filename: pokeemerald.gba
    • SHA1: f3ae088181bf583e55daf962a92bb46f4f1d07b7
  2. Install pokeemerald on Windows using Cygwin

    master

    To set up a Windows environment using Cygwin, follow these steps:

    1. Install devkitARM: If not already installed, follow the msys2 instructions for devkitARM.
    2. Install Cygwin: Download the appropriate setup executable from cygwin.com. During installation, at the 'Select Packages' screen, set the view to 'Full' and install the following packages:
      • make
      • git
      • gcc-core
      • gcc-g++
      • libpng-devel
    3. Configure devkitARM for Cygwin: Open Cygwin and run the following commands to set environment variables (replace c with your actual drive letter if different):
    export DEVKITPRO=/cygdrive/c/devkitpro
    echo export DEVKITPRO=$DEVKITPRO >> ~/.bashrc
    export DEVKITARM=$DEVKITPRO/devkitARM
    echo export DEVKITARM=$DEVKITARM >> ~/.bashrc
    1. Navigate to your project: Use the cd command with Windows-style paths. For example, to access a folder on your Desktop:
    cd c:/Users/<user>/Desktop/decomps

    Note: If the path contains spaces, wrap it in quotes: cd "c:/users/<user>/Desktop/decomp folder"

  3. Install devkitARM on other Linux distributions

    master

    If your distribution is not listed, follow these steps:

    1. Ensure gcc, g++, make, git, and libpng-dev are installed via your package manager.
    2. Configure your existing pacman installation to recognize devkitPro repositories by following the devkitPro pacman instructions.
    3. Install the GBA development tools:
    sudo pacman -Sy
    sudo pacman -S gba-dev

    (When prompted by gba-dev, press Enter to select all, then enter Y to proceed.)

  4. Add or update the agbl chunk in WAV files

    master

    The --set-agbl option allows you to embed a custom agbl RIFF chunk into a .wav file. This is used to specify a precise loop-end position to match vanilla samples or handle specific sample requirements. When using --set-agbl, the tool outputs a modified .wav file rather than converting to .s or .bin.

    Loop-end value types:

    • Positive value: An absolute sample position.
    • Negative value: An offset from the end of the file.

    Note: If no output file is specified, the input file is modified in place.

  5. Install devkitPro on WSL1

    master

    Follow these steps to install the devkitPro toolchain on WSL1:

    1. Download the devkitpro-pacman.amd64.deb package from the devkitPro pacman releases.
    2. Navigate to your Windows Downloads folder within WSL. The Windows C:\ drive is mapped to /mnt/c/. If your path contains spaces, wrap it in quotes.
    3. Install the downloaded package using gdebi.
    4. Use dkp-pacman to sync and install the gba-dev toolchain.

    When prompted by sudo dkp-pacman -S gba-dev, press Enter to select all packages and then type Y to proceed.

  6. Clone the pokeemerald repository

    master

    Download the source code by cloning the repository via git.

    Note for WSL1 users: If you encounter the error fatal: could not set 'core.filemode' to 'false', you must remount your C: drive with metadata support before cloning:

    cd
    sudo umount /mnt/c
    sudo mount -t drvfs C: /mnt/c -o metadata,noatime
    cd <folder where pokeemerald is to be stored>

    Then run the clone command again.

    git clone https://github.com/pret/pokeemerald
  7. Install agbcc into pokeemerald

    master

    Agbcc must be installed into the pokeemerald directory. Choose the command sequence that matches your current state:

    1. If agbcc has never been built in this folder: Build and install it from scratch.

    2. If agbcc was built previously but on a different terminal (e.g., switching from msys2 to WSL1): Clean the previous build before installing.

    3. If agbcc was already built on the same terminal: Simply run the install script.

    Tip: If building fails, try deleting the agbcc folder and starting from step 1.

    # Option 1: First time build
    git clone https://github.com/pret/agbcc
    cd agbcc
    ./build.sh
    ./install.sh ../pokeemerald
    
    # Option 2: Rebuild after switching terminals
    cd agbcc
    git clean -fX
    ./build.sh
    ./install.sh ../pokeemerald
    
    # Option 3: Already built on this terminal
    cd agbcc
    ./install.sh ../pokeemerald
  8. Speed up builds with parallel execution

    master
    To accelerate the build process, use the -j flag with make followed by the number of available CPU cores. You can determine the number of cores using the nproc command (or sysctl -n hw.ncpu on macOS).
  9. Install WSL1 for Windows 10/11

    master

    WSL1 is the fastest and highly recommended method for building pokeemerald on Windows.

    1. Open Windows PowerShell as Administrator.
    2. Run the installation command.
    3. Restart your machine.
    4. Open Windows PowerShell as Administrator again and set the version to WSL1.