summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build.yml44
-rw-r--r--INSTALL.md560
-rw-r--r--Makefile252
-rw-r--r--README.md5
-rw-r--r--asm/macros/event.inc7
-rwxr-xr-xasmdiff.sh10
-rw-r--r--berry_fix/Makefile53
-rw-r--r--berry_fix/payload/Makefile51
-rw-r--r--berry_fix/payload/include/gba/m4a_internal.h2
-rw-r--r--data/battle_anim_scripts.s30
-rw-r--r--data/battle_scripts_1.s2
-rw-r--r--data/event_scripts.s2
-rw-r--r--data/maps/BattleFrontier_BattlePyramidFloor/scripts.inc2
-rw-r--r--data/maps/BattleFrontier_BattlePyramidTop/scripts.inc6
-rw-r--r--data/maps/BirthIsland_Exterior/scripts.inc2
-rw-r--r--data/maps/EverGrandeCity_ChampionsRoom/scripts.inc6
-rw-r--r--data/maps/EverGrandeCity_DrakesRoom/scripts.inc2
-rw-r--r--data/maps/EverGrandeCity_GlaciasRoom/scripts.inc2
-rw-r--r--data/maps/EverGrandeCity_PhoebesRoom/scripts.inc2
-rw-r--r--data/maps/EverGrandeCity_SidneysRoom/scripts.inc2
-rw-r--r--data/maps/LavaridgeTown/scripts.inc4
-rw-r--r--data/maps/LilycoveCity/scripts.inc4
-rw-r--r--data/maps/LittlerootTown_BrendansHouse_1F/scripts.inc2
-rw-r--r--data/maps/LittlerootTown_BrendansHouse_2F/scripts.inc2
-rw-r--r--data/maps/LittlerootTown_MaysHouse_1F/scripts.inc2
-rw-r--r--data/maps/LittlerootTown_MaysHouse_2F/scripts.inc2
-rw-r--r--data/maps/MagmaHideout_2F_2R/map.json2
-rw-r--r--data/maps/MagmaHideout_4F/map.json2
-rw-r--r--data/maps/MagmaHideout_4F/scripts.inc2
-rw-r--r--data/maps/MeteorFalls_1F_1R/scripts.inc4
-rw-r--r--data/maps/MtChimney/scripts.inc2
-rw-r--r--data/maps/MtPyre_Summit/scripts.inc2
-rw-r--r--data/maps/OldaleTown/scripts.inc2
-rw-r--r--data/maps/PetalburgCity/scripts.inc2
-rw-r--r--data/maps/PetalburgCity_Gym/scripts.inc4
-rw-r--r--data/maps/PetalburgWoods/scripts.inc4
-rw-r--r--data/maps/Route101/scripts.inc2
-rw-r--r--data/maps/Route103/scripts.inc4
-rw-r--r--data/maps/Route104/scripts.inc4
-rw-r--r--data/maps/Route110/scripts.inc4
-rw-r--r--data/maps/Route119/scripts.inc4
-rw-r--r--data/maps/Route121/scripts.inc2
-rw-r--r--data/maps/RustboroCity/scripts.inc6
-rw-r--r--data/maps/RustboroCity_DevonCorp_3F/scripts.inc2
-rw-r--r--data/maps/RusturfTunnel/scripts.inc2
-rw-r--r--data/maps/SeafloorCavern_Room9/scripts.inc2
-rw-r--r--data/maps/SlateportCity/scripts.inc2
-rw-r--r--data/maps/SlateportCity_OceanicMuseum_2F/scripts.inc2
-rw-r--r--data/maps/map_groups.json138
-rw-r--r--data/scripts/contest_hall.inc2
-rw-r--r--data/scripts/item_ball_scripts.inc4
-rw-r--r--data/scripts/players_house.inc4
-rw-r--r--data/text/berry_descriptions.inc258
-rw-r--r--docs/legacy_WSL1_INSTALL.md41
-rw-r--r--gflib/bg.c56
-rw-r--r--gflib/bg.h2
-rw-r--r--gflib/sprite.c7
-rw-r--r--gflib/text.c6
-rw-r--r--include/battle_anim.h2
-rw-r--r--include/constants/battle_string_ids.h2
-rw-r--r--include/constants/contest.h1
-rwxr-xr-xinclude/constants/map_groups.h68
-rwxr-xr-xinclude/ereader_helpers.h1
-rw-r--r--include/gba/m4a_internal.h2
-rw-r--r--include/global.fieldmap.h16
-rw-r--r--include/pokemon.h1
-rw-r--r--include/strings.h4
-rw-r--r--ld_script_modern.txt23
-rw-r--r--libagbsyscall/Makefile52
-rw-r--r--make_tools.mk11
-rwxr-xr-xmap_data_rules.mk4
-rw-r--r--src/apprentice.c27
-rw-r--r--src/battle_ai_script_commands.c29
-rw-r--r--src/battle_anim_dark.c10
-rwxr-xr-xsrc/battle_anim_effects_2.c16
-rw-r--r--src/battle_anim_mons.c2
-rw-r--r--src/battle_anim_sound_tasks.c8
-rwxr-xr-xsrc/battle_anim_throw.c2
-rw-r--r--src/battle_dome.c65
-rw-r--r--src/battle_factory.c2
-rw-r--r--src/battle_factory_screen.c5
-rw-r--r--src/battle_gfx_sfx_util.c6
-rw-r--r--src/battle_interface.c25
-rw-r--r--src/battle_main.c11
-rw-r--r--src/battle_message.c8
-rw-r--r--src/battle_pyramid.c6
-rw-r--r--src/battle_script_commands.c26
-rw-r--r--src/battle_transition.c27
-rw-r--r--src/bike.c29
-rw-r--r--src/contest.c29
-rw-r--r--src/contest_util.c2
-rw-r--r--src/daycare.c2
-rw-r--r--src/egg_hatch.c3
-rw-r--r--src/evolution_scene.c12
-rw-r--r--src/item.c18
-rwxr-xr-xsrc/item_use.c2
-rw-r--r--src/m4a.c15
-rw-r--r--src/main_menu.c19
-rw-r--r--src/mystery_gift.c24
-rw-r--r--src/overworld.c6
-rw-r--r--src/player_pc.c11
-rw-r--r--src/pokemon.c1
-rw-r--r--src/pokemon_animation.c15
-rw-r--r--src/pokemon_size_record.c2
-rw-r--r--src/pokemon_storage_system.c7
-rw-r--r--src/pokemon_summary_screen.c20
-rw-r--r--src/region_map.c2
-rw-r--r--src/rotating_gate.c3
-rw-r--r--src/roulette.c38
-rw-r--r--src/siirtc.c29
-rw-r--r--src/strings.c6
-rw-r--r--src/union_room.c7
-rwxr-xr-xsrc/union_room_chat.c2
-rw-r--r--src/wild_encounter.c4
-rw-r--r--tools/aif2pcm/Makefile10
-rw-r--r--tools/bin2c/Makefile10
-rw-r--r--tools/gbafix/Makefile10
-rw-r--r--tools/gbagfx/Makefile12
-rwxr-xr-xtools/jsonproc/Makefile10
-rw-r--r--tools/mapjson/Makefile10
-rw-r--r--tools/mapjson/mapjson.cpp2
-rw-r--r--tools/mid2agb/Makefile10
-rw-r--r--tools/preproc/Makefile10
-rw-r--r--tools/preproc/c_file.cpp55
-rw-r--r--tools/preproc/c_file.h5
-rw-r--r--tools/preproc/preproc.cpp22
-rw-r--r--tools/ramscrgen/Makefile10
-rw-r--r--tools/rsfont/Makefile10
-rw-r--r--tools/scaninc/Makefile10
129 files changed, 1606 insertions, 998 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 822b386ea..de3a35c40 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -7,11 +7,29 @@ on:
jobs:
build:
- runs-on: ubuntu-18.04
+ runs-on: ubuntu-latest
+ env:
+ GAME_VERSION: EMERALD
+ GAME_REVISION: 0
+ GAME_LANGUAGE: ENGLISH
+ MODERN: 0
+ COMPARE: 1
steps:
- name: Checkout
uses: actions/checkout@master
+ - name: Checkout syms
+ uses: actions/checkout@master
+ with:
+ path: symbols
+ ref: symbols
+
+ - name: Checkout agbcc
+ uses: actions/checkout@master
+ with:
+ path: agbcc
+ repository: pret/agbcc
+
- name: Install binutils
run: sudo apt install gcc-arm-none-eabi binutils-arm-none-eabi
# build-essential, git, and libpng-dev are already installed
@@ -20,16 +38,18 @@ jobs:
- name: Install agbcc
run: |
- git clone https://github.com/pret/agbcc.git
- cd agbcc
./build.sh
./install.sh ../
+ working-directory: agbcc
- name: Compare
- run: make -j${nproc} compare
+ run: make -j${nproc} all syms
- name: Modern
- run: make -j${nproc} modern
+ env:
+ MODERN: 1
+ COMPARE: 0
+ run: make -j${nproc} all
- name: Webhook
if: ${{ github.event_name == 'push' }}
@@ -38,3 +58,17 @@ jobs:
CALCROM_DISCORD_WEBHOOK_AVATAR_URL: https://i.imgur.com/38BQHdd.png
CALCROM_DISCORD_WEBHOOK_URL: ${{ secrets.CALCROM_DISCORD_WEBHOOK_URL }}
run: sh .github/calcrom/webhook.sh pokeemerald
+
+ - name: Move symfiles
+ if: ${{ github.event_name == 'push' }}
+ run: |
+ cp -v *.sym symbols/
+
+ - name: Update symfiles
+ if: ${{ github.event_name == 'push' }}
+ uses: EndBug/add-and-commit@v7
+ with:
+ branch: symbols
+ cwd: "./symbols"
+ add: "*.sym"
+ message: ${{ github.event.commits[0].message }}
diff --git a/INSTALL.md b/INSTALL.md
index 20d55e134..1ad3b4b0c 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -1,95 +1,569 @@
-# Prerequisites
+# Instructions
-| Linux | macOS | Windows 10
-| - | - | -
-| none | [Xcode Command Line Tools Package][xcode] | [Windows Terminal][terminal] and [Windows Subsystem for Linux (WSL)][wsl]
+These instructions explain how to set up the tools required to build **pokeemerald**, which assembles the source files into a ROM.
-[xcode]: https://developer.apple.com/library/archive/technotes/tn2339/_index.html
-[terminal]: https://docs.microsoft.com/windows/terminal/get-started
-[wsl]: https://docs.microsoft.com/windows/wsl/install-win10
+These instructions come with notes which can be expanded by clicking the "<i>Note...</i>" text.
+In general, you should not need to open these unless if you get an error or if you need additional clarification.
-Independently from the specific OS, make sure that the `gcc`, `g++`, `make`, `git`, and `libpng-dev` packages or their equivalents are installed and accessible to the development tools that are used by the project (this means that, for example, on Windows, the packages have to be installed in the WSL environment). The package names and installation methods may vary with each OS.
+If you run into trouble, ask for help on Discord or IRC (see [README.md](README.md)).
-Install the devkitARM toolchain of devkitPro as per [the instructions on their wiki](https://devkitpro.org/wiki/devkitPro_pacman). On Windows, follow the Linux instructions inside WSL as any steps about the Windows installer do not apply.
+## Windows
+Windows has instructions for building with three possible terminals, providing 3 different options in case the user stumbles upon unexpected errors.
+- [Windows 10 (WSL1)](#windows-10-wsl1) (**Fastest, highly recommended**, Windows 10 only)
+- [Windows (msys2)](#windows-msys2) (Second fastest)
+- [Windows (Cygwin)](#windows-cygwin) (Slowest)
-**Debian-based distro users:** This applies to Debian, Ubuntu, and similar distros, including in WSL. If necessary, install the `libarchive13`, `pkg-config`, and `gdebi-core` packages to be able to install devkitPro.
+Unscientific benchmarks suggest **msys2 is 2x slower** than WSL1, and **Cygwin is 5-6x slower** than WSL1.
+<details>
+ <summary><i>Note for advanced users: <b>WSL2</b>...</i></summary>
-**Windows 10 users:** WSL 2 is available in the 1903 release (build 18362) and later, therefore existing WSL 1 and [prerelease WSL](https://docs.microsoft.com/windows/wsl/install-legacy) users are recommended to update. Right-click the Start button or press `Win`+`X`, choose Run, and run `ms-settings:about` to determine the Windows version. Also check Windows Update to make sure your installation is up-to-date.
+> <b>WSL2</b> is an option and is even faster than <b>WSL1</b> 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 <a href="https://github.com/huderlem/porymap">porymap</a>
+> may <a href="https://bugreports.qt.io/browse/QTBUG-86277">have problems with parsing the <code>\\wsl$</code> network drive path</a>.
+</details>
-**Windows 7 and 8.1 users:** pret is no longer focusing on support in pokeemerald for [old versions of Windows](https://support.microsoft.com/help/13853) so consider upgrading to a current release of Windows 10 or try a third-party guide like [this one](https://www.pokecommunity.com/showthread.php?t=425246) instead.
+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.
-# Installation
+## Windows 10 (WSL1)
+WSL1 is the preferred terminal to build **pokeemerald**. 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](#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](#Setting-up-WSL1).
+- Otherwise, **open WSL** and go to [Choosing where to store pokeemerald (WSL1)](#Choosing-where-to-store-pokeemerald-WSL1).
-To set up the repository:
+### Installing WSL1
+1. Open [Windows Powershell **as Administrator**](https://i.imgur.com/QKmVbP9.png), and run the following command (Right Click or Shift+Insert is paste in the Powershell).
- git clone https://github.com/pret/pokeemerald
- git clone https://github.com/pret/agbcc
+ ```powershell
+ dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
+ ```
- cd ./agbcc
- ./build.sh
- ./install.sh ../pokeemerald
+2. Once the process finishes, restart your machine.
- cd ../pokeemerald
+3. 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.
+ <details>
+ <summary><i>Note for advanced users...</i></summary>
+
+ > You can pick a preferred Linux distribution, but setup instructions may differ. Debian should work with the given instructions, but has not been tested.
+ </details>
-To build **pokeemerald.gba** for the first time and confirm it matches the official ROM image:
+4. Open the [Microsoft Store Linux Selection](https://aka.ms/wslstore), click Ubuntu, then click Get, which will install the Ubuntu distribution.
+ <details>
+ <summary><i>Notes...</i></summary>
- make compare
+ > 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).
+ </details>
-If an OK is returned, then the installation went smoothly.
+### Setting up WSL1
+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.
-**Windows users:** Consider adding exceptions for the `pokeemerald` and `agbcc` folders in Windows Security using [these instructions](https://support.microsoft.com/help/4028485). This prevents Microsoft Defender from scanning them which might improve performance while building.
+1. Open **Ubuntu** (e.g. using Search).
+2. 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).
+ <details>
+ <summary><i>Note...</i></summary>
+ > When typing in the password, there will be no visible response, but the terminal will still read in input.
+ </details>
-# Start
+3. Update WSL/Ubuntu before continuing. Do this by running the following command. These commands will likely take a long time to finish:
-To build **pokeemerald.gba** with your changes:
+ ```bash
+ sudo apt update && sudo apt upgrade
+ ```
- make
+> Note: If the repository you plan to build has an **[older revision of the INSTALL.md](https://github.com/pret/pokeemerald/blob/571c598/INSTALL.md)**, then follow the [legacy WSL1 instructions](docs/legacy_WSL1_INSTALL.md) from here.
-**macOS users:** If the base tools are not found in new Terminal sessions after the first successful build, run `echo "if [ -f ~/.bashrc ]; then . ~/.bashrc; fi" >> ~/.bash_profile` once to prevent the issue from occurring again. Verify that the `devkitarm-rules` package is installed as well; if not, install it by running `sudo dkp-pacman -S devkitarm-rules`.
+4. Certain packages are required to build pokeemerald. Install these packages by running the following command:
+ ```bash
+ sudo apt install build-essential binutils-arm-none-eabi git libpng-dev
+ ```
+ <details>
+ <summary><i>Note...</i></summary>
-# Building guidance
+ > If the above command does not work, try the above command but replacing `apt` with `apt-get`.
+ </details>
+
+### Choosing where to store pokeemerald (WSL1)
+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 pokeemerald within Windows.
+
+For example, say you want to store pokeemerald (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:
+
+```bash
+cd /mnt/c/Users/<user>/Desktop/decomps
+```
+
+<details>
+ <summary><i>Notes...</i></summary>
+
+> 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
+</details>
+
+If this works, then proceed to [Installation](#installation).
+
+Otherwise, ask for help on Discord or IRC (see [README.md](README.md)), or continue reading below for [Windows instructions using msys2](#windows-msys2).
+
+## Windows (msys2)
+
+- If devkitARM is **not installed**, then go to [Installing devkitARM](#installing-devkitarm).
+- If devkitARM is installed, but msys2 **hasn't previously been set up for another decompilation project**, then go to [Setting up msys2](#setting-up-msys2).
+- Otherwise, **open msys2** and go to [Choosing where to store pokeemerald (msys2)](#choosing-where-to-store-pokeemerald-msys2).
+
+### Installing devkitARM
+1. Download the devkitPro installer [here](https://github.com/devkitPro/installer/releases).
+2. 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.
+
+### Setting up msys2
+
+Note that in msys2, Copy is Ctrl+Insert and Paste is Shift+Insert.
+
+1. Open msys2 at C:\devkitPro\msys2\msys2_shell.bat.
+
+2. Certain packages are required to build pokeemerald. Install these by running the following command:
+
+ ```bash
+ pacman -S make gcc zlib-devel git
+ ```
+ <details>
+ <summary><i>Note...</i></summary>
+
+ > This command will ask for confirmation, just enter the yes action when prompted.
+ </details>
+
+3. Download [libpng](https://sourceforge.net/projects/libpng/files/libpng16/1.6.37/libpng-1.6.37.tar.xz/download).
+
+4. Change directory to where libpng was downloaded. By default, msys2 will start in the current user's profile folder, located at **C:\Users\\&#8288;_\<user>_**, where *\<user>* is your Windows username. In most cases, libpng should be saved within a subfolder of the profile folder. For example, if libpng was saved to **C:\Users\\_\<user>_\Downloads** (the Downloads location for most users), enter this command:
+
+ ```bash
+ cd Downloads
+ ```
+
+ <details>
+ <summary><i>Notes...</i></summary>
+
+ > Note 1: While not shown, msys uses forward slashes `/` instead of backwards slashes `\` as the directory separator.
+ > Note 2: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "Downloads/My Downloads"`.
+ > Note 3: Windows path names are case-insensitive so adhering to capitalization isn’t needed.
+ > Note 4: If libpng was saved elsewhere, you will need to specify the full path to where libpng was downloaded, e.g. `cd c:/devkitpro/msys2` if it was saved there.
+ </details>
+
+5. Run the following commands to uncompress and install libpng.
+
+ ```bash
+ tar xf libpng-1.6.37.tar.xz
+ cd libpng-1.6.37
+ ./configure --prefix=/usr
+ make check
+ make install
+ ```
+
+6. Then finally, run the following command to change back to the user profile folder.
+
+ ```bash
+ cd
+ ```
+
+### Choosing where to store pokeemerald (msys2)
+At this point, you can choose a folder to store pokeemerald into. If you're okay with storing pokeemerald in the user profile folder, then proceed to [Installation](#installation). Otherwise, you'll need to account for where pokeemerald is stored when changing directory to the pokeemerald folder.
+
+For example, if you want to store pokeemerald (and agbcc) in **C:\Users\\_\<user>_\Desktop\decomps** (where *\<user>* is your **Windows** username), enter this command:
+
+```bash
+cd Desktop/decomps
+```
+
+If this works, then proceed to [Installation](#installation).
+
+Otherwise, ask for help on Discord or IRC (see [README.md](README.md)), or continue reading below for [Windows instructions using Cygwin](#windows-cygwin).
+
+## Windows (Cygwin)
+1. If devkitARM is **not installed**, then follow the instructions used to [install devkitARM](#installing-devkitarm) for the msys2 setup before continuing. *Remember to not continue following the msys2 instructions by mistake!*
+
+2.
+ - If Cygwin is **not installed**, or does not have all of the required packages installed, then go to [Installing Cygwin](#installing-cygwin).
+ - If Cygwin is installed, but **is not configured to work with devkitARM**, then go to [Configuring devkitARM for Cygwin](#configuring-devkitarm-for-cygwin).
+ - Otherwise, **open Cygwin** and go to [Choosing where to store pokeemerald (Cygwin)](#choosing-where-to-store-pokeemerald-cygwin)
+
+### Installing Cygwin
+1. Download [Cygwin](https://cygwin.com/install.html): setup-x86_64.exe for 64-bit Windows, setup-x86.exe for 32-bit.
+
+2. Run the Cygwin setup. Within the Cygwin setup, leave the default settings until the "Choose A Download Site" screen.
+
+3. At "Choose a Download Site", select any mirror within the Available Download Sites.
+
+4. 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 as `make`.
+
+5. 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.
+
+6. Once all required packages have been selected, finish the installation.
+
+### Configuring devkitARM for Cygwin
+
+Note that in Cygwin, Copy is Ctrl+Insert and Paste is Shift+Insert.
+
+1. Open **Cygwin**.
+
+2. Run the following commands to configure devkitPro to work with Cygwin.
+
+ ```bash
+ export DEVKITPRO=/cygdrive/c/devkitpro
+ echo export DEVKITPRO=$DEVKITPRO >> ~/.bashrc
+ export DEVKITARM=$DEVKITPRO/devkitARM
+ echo export DEVKITARM=$DEVKITARM >> ~/.bashrc
+ ```
+
+ <details>
+ <summary><i>Note...</i></summary>
+
+ > Replace the drive letter c with the actual drive letter if it is not c.
+ </details>
+
+### Choosing where to store pokeemerald (Cygwin)
+
+Cygwin has its own file system that's within Windows, at **C:\cygwin64\home\\_\<user>_**. If you don't want to store pokeemerald there, you'll need to account for where pokeemerald is stored when **changing directory** to the pokeemerald folder.
+For example, if you want to store pokeemerald (and agbcc) in **C:\Users\\_\<user>_\Desktop\decomps**, enter this command, where *\<user>* is your **Windows** username:
+```bash
+cd c:/Users/<user>/Desktop/decomps
+```
+Note that the directory **must exist** in Windows. If you want to store pokeemerald 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.
+
+<details>
+ <summary><i>Notes...</i></summary>
+
+> 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
+</details>
+
+If this works, then proceed to [Installation](#installation). Otherwise, ask for help on Discord or IRC (see [README.md](README.md)).
+
+## macOS
+1. If the Xcode Command Line Tools are not installed, download the tools [here](https://developer.apple.com/xcode/resources/), open your Terminal, and run the following command:
+
+ ```bash
+ xcode-select --install
+ ```
+
+2. - If libpng is **not installed**, then go to [Installing libpng (macOS)](#installing-libpng-macos).
+ - If devkitARM is **not installed**, then go to [Installing devkitARM (macOS)](#installing-devkitarm-macos).
+ - Otherwise, **open the Terminal** and go to [Choosing where to store pokeemerald (macOS)](#choosing-where-to-store-pokeemerald-macos)
+
+### Installing libpng (macOS)
+<details>
+ <summary><i>Note for advanced users...</i></summary>
+
+> 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.
+</details>
+
+1. Open the Terminal.
+2. If Homebrew is not installed, then install [Homebrew](https://brew.sh/) by following the instructions on the website.
+3. Run the following command to install libpng.
+
+ ```bash
+ brew install libpng
+ ```
+ libpng is now installed.
+
+ Continue to [Installing devkitARM (macOS)](#installing-devkitarm-macos) if **devkitARM is not installed**, otherwise, go to [Choosing where to store pokeemerald (macOS)](#choosing-where-to-store-pokeemerald-macos).
+
+### Installing devkitARM (macOS)
+1. Download the `devkitpro-pacman-installer.pkg` package from [here](https://github.com/devkitPro/pacman/releases).
+2. Open the package to install devkitPro pacman.
+3. In the Terminal, run the following commands to install devkitARM:
+
+ ```bash
+ 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.
+
+4. After the tools are installed, devkitARM must now be made accessible from anywhere by the system. To do so, run the following commands:
+
+ ```bash
+ export DEVKITPRO=/opt/devkitpro
+ echo "export DEVKITPRO=$DEVKITPRO" >> ~/.bashrc
+ export DEVKITARM=$DEVKITPRO/devkitARM
+ echo "export DEVKITARM=$DEVKITARM" >> ~/.bashrc
+
+ echo "if [ -f ~/.bashrc ]; then . ~/.bashrc; fi" >> ~/.bash_profile
+ ```
+
+### Choosing where to store pokeemerald (macOS)
+At this point, you can choose a folder to store pokeemerald into. If you're okay with storing pokeemerald in the user folder, then proceed to [Installation](#installation). Otherwise, you'll need to account for where pokeemerald is stored when changing directory to the pokeemerald folder.
+
+For example, if you want to store pokeemerald (and agbcc) in **~/Desktop/decomps**, enter this command to **change directory** to the desired folder:
+```bash
+cd Desktop/decomps
+```
+Note that the directory **must exist** in the folder system. If you want to store pokeemerald 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.
+
+<details>
+ <summary><i>Note..</i>.</summary>
+
+> Note: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "Desktop/decomp folder"`
+</details>
+
+If this works, then proceed to [Installation](#installation). Otherwise, ask for help on Discord or IRC (see [README.md](README.md)).
+
+## Linux
+Open Terminal and enter the following commands, depending on which distro you're using.
+
+### Debian/Ubuntu-based distributions
+Run the following command to install the necessary packages:
+```bash
+sudo apt install build-essential binutils-arm-none-eabi git libpng-dev
+```
+Then proceed to [Choosing where to store pokeemerald (Linux)](#choosing-where-to-store-pokeemerald-linux).
+<details>
+ <summary><i>Note for legacy repos...</i></summary>
+
+> If the repository you plan to build has an **[older revision of the INSTALL.md](https://github.com/pret/pokeemerald/blob/571c598/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](#installing-devkitarm-on-debianubuntu-based-distributions).
+</details>
+
+### Other distributions
+_(Specific instructions for other distributions would be greatly appreciated!)_
+
+1. Try to find the required software in its repositories:
+ - `gcc`
+ - `g++`
+ - `make`
+ - `git`
+ - `libpng-dev`
+
+2. Follow the instructions [here](https://devkitpro.org/wiki/devkitPro_pacman) to install devkitPro pacman. As a reminder, the goal is to configure an existing pacman installation to recognize devkitPro's repositories.
+3. Once devkitPro pacman is configured, run the following commands:
+
+ ```bash
+ 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.
+
+### Choosing where to store pokeemerald (Linux)
+At this point, you can choose a folder to store pokeemerald (and agbcc) into. If so, you'll have to account for the modified folder path when changing directory to the pokeemerald folder.
+
+If this works, then proceed to [Installation](#installation). Otherwise, ask for help on Discord or IRC (see [README.md](README.md)).
+
+## Installation
+
+<details>
+ <summary><i>Note for Windows users...</i></summary>
+
+> Consider adding an exception for the `pokeemerald` and/or `decomps` folder in Windows Security using
+> [these instructions](https://support.microsoft.com/help/4028485). This prevents Microsoft Defender from
+> scanning them which might improve performance while building.
+</details>
+
+1. If pokeemerald is not already downloaded (some users may prefer to download pokeemerald via a git client like GitHub Desktop), run:
+
+ ```bash
+ git clone https://github.com/pret/pokeemerald
+ ```
+
+ <details>
+ <summary><i>Note for WSL1...</i></summary>
+
+ > If you get an error stating `fatal: could not set 'core.filemode' to 'false'`, then run the following commands:
+ > ```bash
+ > cd
+ > sudo umount /mnt/c
+ > sudo mount -t drvfs C: /mnt/c -o metadata,noatime
+ > cd <folder where pokeemerald is to be stored>
+ > ```
+ > Where *\<folder where pokeemerald is to be stored>* is the path of the folder [where you chose to store pokeemerald](#Choosing-where-to-store-pokeemerald-WSL1). Then run the `git clone` command again.
+ </details>
+
+2. Install agbcc into pokeemerald. 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 pokeemerald, run the following commands to build and install it into pokeemerald:
+
+ ```bash
+ git clone https://github.com/pret/agbcc
+ cd agbcc
+ ./build.sh
+ ./install.sh ../pokeemerald
+ ```
+
+- **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 pokeemerald:
+
+ ```bash
+ cd agbcc
+ git clean -fX
+ ./build.sh
+ ./install.sh ../pokeemerald
+ ```
+
+- **Otherwise**, if agbcc has been built before on the same terminal, run the following commands to install agbcc into pokeemerald:
+
+ ```bash
+ cd agbcc
+ ./install.sh ../pokeemerald
+ ```
+
+ <details>
+ <summary><i>Note...</i></summary>
+
+ > If building agbcc or pokeemerald results in an error, try deleting the agbcc folder and re-installing agbcc as if it has not been built before.
+ </details>
+
+3. Once agbcc is installed, change directory back to the base directory where pokeemerald and agbcc are stored:
+
+ ```bash
+ cd ..
+ ```
+
+Now you're ready to [build **pokeemerald**](#build-pokeemerald)
+## Build pokeemerald
+If you aren't in the pokeemerald directory already, then **change directory** to the pokeemerald folder:
+```bash
+cd pokeemerald
+```
+To build **pokeemerald.gba** for the first time and confirm it matches the official ROM image (Note: to speed up builds, see [Parallel builds](#parallel-builds)):
+```bash
+make compare
+```
+If an OK is returned, then the installation went smoothly.
+<details>
+<summary>Note for Windows...</summary>
+> 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.
+</details>
+
+To build **pokeemerald.gba** with your changes:
+```bash
+make
+```
+
+# Building guidance
## Parallel builds
See [the GNU docs](https://www.gnu.org/software/make/manual/html_node/Parallel.html) and [this Stack Exchange thread](https://unix.stackexchange.com/questions/208568) for more information.
-To speed up building, run:
-
- make -j$(nproc)
+To speed up building, first get the value of `nproc` by running the following command:
+```bash
+nproc
+```
+Builds can then be sped up by running the following command:
+```bash
+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](https://stackoverflow.com/questions/1715580)).
-
## Debug info
To build **pokeemerald.elf** with enhanced debug info:
+```bash
+make DINFO=1
+```
- make DINFO=1
+## devkitARM's C compiler
+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:
+```bash
+make modern
+```
+Otherwise, follow the instructions below to install devkitARM.
+### Installing devkitARM on WSL1
-## devkitARM's C compiler
+1. `gdebi-core` must be installed beforehand in order to install devkitPro pacman (which facilitates the installation of devkitARM). Install this with the following command:
-This project supports the `arm-none-eabi-gcc` compiler included with devkitARM r52. To build this target, simply run:
+ ```bash
+ sudo apt install gdebi-core
+ ```
+ <details>
+ <summary><i>Note...</i></summary>
- make modern
+ > If the above command does not work, try the above command but replacing `apt` with `apt-get`.
+ </details>
+2. Once `gdebi-core` is done installing, download the devkitPro pacman package [here](https://github.com/devkitPro/pacman/releases). The file to download is `devkitpro-pacman.amd64.deb`.
+3. 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:
-## Other toolchains
+ ```bash
+ cd /mnt/c/Users/<user>/Downloads
+ ```
-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`.
+4. Once the directory has been changed to the folder containing the devkitPro pacman package, run the following commands to install devkitARM.
- make TOOLCHAIN="/path/to/toolchain/here"
+ ```bash
+ 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.
-The following is an example:
+ <details>
+ <summary><i>Note...</i></summary>
- make TOOLCHAIN="/usr/local/arm-none-eabi"
+ > 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.
+ </details>
-To compile the `modern` target with this toolchain, the subdirectories `lib`, `include`, and `arm-none-eabi` must also be present.
+5. Run the following command to set devkitPro related environment variables (alternatively, close and re-open WSL):
+
+ ```bash
+ source /etc/profile.d/devkit-env.sh
+ ```
+
+devkitARM is now installed.
+### Installing devkitARM on Debian/Ubuntu-based distributions
+1. If `gdebi-core` is not installed, run the following command:
+
+ ```bash
+ sudo apt install gdebi-core
+ ```
+2. Download the devkitPro pacman package [here](https://github.com/devkitPro/pacman/releases). The file to download is `devkitpro-pacman.amd64.deb`.
+3. Change directory to where the package was downloaded. Then, run the following commands to install devkitARM:
+
+ ```bash
+ 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.
+
+4. Run the following command to set devkitPro related environment variables (alternatively, close and re-open the Terminal):
+
+ ```bash
+ source /etc/profile.d/devkit-env.sh
+ ```
+
+devkitARM is now installed.
+
+## Other toolchains
+
+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`.
+```bash
+make TOOLCHAIN="/path/to/toolchain/here"
+```
+The following is an example:
+```bash
+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.
# Useful additional tools
diff --git a/Makefile b/Makefile
index d97634399..7b2f79877 100644
--- a/Makefile
+++ b/Makefile
@@ -1,29 +1,34 @@
TOOLCHAIN := $(DEVKITARM)
COMPARE ?= 0
-ifeq ($(CC),)
-HOSTCC := gcc
-else
-HOSTCC := $(CC)
+ifeq (compare,$(MAKECMDGOALS))
+ COMPARE := 1
endif
-ifeq ($(CXX),)
-HOSTCXX := g++
-else
-HOSTCXX := $(CXX)
-endif
+# don't use dkP's base_tools anymore
+# because the redefinition of $(CC) conflicts
+# with when we want to use $(CC) to preprocess files
+# thus, manually create the variables for the bin
+# files, or use arm-none-eabi binaries on the system
+# if dkP is not installed on this system
-ifneq (,$(wildcard $(TOOLCHAIN)/base_tools))
-include $(TOOLCHAIN)/base_tools
-else
+ifneq (,$(TOOLCHAIN))
+ifneq ($(wildcard $(TOOLCHAIN)/bin),)
export PATH := $(TOOLCHAIN)/bin:$(PATH)
+endif
+endif
+
PREFIX := arm-none-eabi-
OBJCOPY := $(PREFIX)objcopy
-export CC := $(PREFIX)gcc
-export AS := $(PREFIX)as
-endif
-export CPP := $(PREFIX)cpp
-export LD := $(PREFIX)ld
+OBJDUMP := $(PREFIX)objdump
+AS := $(PREFIX)as
+
+LD := $(PREFIX)ld
+
+# note: the makefile must be set up so MODERNCC is never called
+# if MODERN=0
+MODERNCC := $(PREFIX)gcc
+PATH_MODERNCC := PATH=$(TOOLCHAIN)/bin:PATH $(MODERNCC)
ifeq ($(OS),Windows_NT)
EXE := .exe
@@ -37,10 +42,42 @@ MAKER_CODE := 01
REVISION := 0
MODERN ?= 0
+ifeq (modern,$(MAKECMDGOALS))
+ MODERN := 1
+endif
+
+# use arm-none-eabi-cpp for macOS
+# as macOS's default compiler is clang
+# and clang's preprocessor will warn on \u
+# when preprocessing asm files, expecting a unicode literal
+# we can't unconditionally use arm-none-eabi-cpp
+# as installations which install binutils-arm-none-eabi
+# don't come with it
+ifneq ($(MODERN),1)
+ ifeq ($(shell uname -s),Darwin)
+ CPP := $(PREFIX)cpp
+ else
+ CPP := $(CC) -E
+ endif
+else
+ CPP := $(PREFIX)cpp
+endif
+
+ROM_NAME := pokeemerald.gba
+ELF_NAME := $(ROM_NAME:.gba=.elf)
+MAP_NAME := $(ROM_NAME:.gba=.map)
+OBJ_DIR_NAME := build/emerald
+
+MODERN_ROM_NAME := pokeemerald_modern.gba
+MODERN_ELF_NAME := $(MODERN_ROM_NAME:.gba=.elf)
+MODERN_MAP_NAME := $(MODERN_ROM_NAME:.gba=.map)
+MODERN_OBJ_DIR_NAME := build/modern
+
SHELL := /bin/bash -o pipefail
ELF = $(ROM:.gba=.elf)
MAP = $(ROM:.gba=.map)
+SYM = $(ROM:.gba=.sym)
C_SUBDIR = src
GFLIB_SUBDIR = gflib
@@ -64,26 +101,26 @@ ASFLAGS := -mcpu=arm7tdmi --defsym MODERN=$(MODERN)
ifeq ($(MODERN),0)
CC1 := tools/agbcc/bin/agbcc$(EXE)
override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm -g
-ROM := pokeemerald.gba
-OBJ_DIR := build/emerald
+ROM := $(ROM_NAME)
+OBJ_DIR := $(OBJ_DIR_NAME)
LIBPATH := -L ../../tools/agbcc/lib
+LIB := $(LIBPATH) -lgcc -lc -L../../libagbsyscall -lagbsyscall
else
-CC1 = $(shell $(CC) --print-prog-name=cc1) -quiet
+CC1 = $(shell $(PATH_MODERNCC) --print-prog-name=cc1) -quiet
override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast -g
-ROM := pokeemerald_modern.gba
-OBJ_DIR := build/modern
-LIBPATH := -L "$(dir $(shell $(CC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(CC) -mthumb -print-file-name=libc.a))"
+ROM := $(MODERN_ROM_NAME)
+OBJ_DIR := $(MODERN_OBJ_DIR_NAME)
+LIBPATH := -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libnosys.a))" -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libc.a))"
+LIB := $(LIBPATH) -lc -lnosys -lgcc -L../../libagbsyscall -lagbsyscall
endif
CPPFLAGS := -iquote include -iquote $(GFLIB_SUBDIR) -Wno-trigraphs -DMODERN=$(MODERN)
-ifeq ($(MODERN),0)
-CPPFLAGS += -I tools/agbcc/include -I tools/agbcc
+ifneq ($(MODERN),1)
+CPPFLAGS += -I tools/agbcc/include -I tools/agbcc -nostdinc -undef
endif
LDFLAGS = -Map ../../$(MAP)
-LIB := $(LIBPATH) -lgcc -lc -L../../libagbsyscall -lagbsyscall
-
SHA1 := $(shell { command -v sha1sum || command -v shasum; } 2>/dev/null) -c
GFX := tools/gbagfx/gbagfx$(EXE)
AIF := tools/aif2pcm/aif2pcm$(EXE)
@@ -95,6 +132,8 @@ FIX := tools/gbafix/gbafix$(EXE)
MAPJSON := tools/mapjson/mapjson$(EXE)
JSONPROC := tools/jsonproc/jsonproc$(EXE)
+PERL := perl
+
TOOLDIRS := $(filter-out tools/agbcc tools/binutils,$(wildcard tools/*))
TOOLBASE = $(TOOLDIRS:tools/%=%)
TOOLS = $(foreach tool,$(TOOLBASE),tools/$(tool)/$(tool)$(EXE))
@@ -111,18 +150,34 @@ MAKEFLAGS += --no-print-directory
# Secondary expansion is required for dependency variables in object rules.
.SECONDEXPANSION:
-.PHONY: all rom clean compare tidy tools mostlyclean clean-tools $(TOOLDIRS) berry_fix libagbsyscall modern
+.PHONY: all rom clean compare tidy tools mostlyclean clean-tools $(TOOLDIRS) berry_fix libagbsyscall modern tidymodern tidynonmodern
infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst __SPACE__, ,$(line))))
# Build tools when building the rom
# Disable dependency scanning for clean/tidy/tools
-ifeq (,$(filter-out all rom compare modern berry_fix libagbsyscall,$(MAKECMDGOALS)))
-$(call infoshell, $(MAKE) tools)
+# Use a separate minimal makefile for speed
+# Since we don't need to reload most of this makefile
+ifeq (,$(filter-out all rom compare modern berry_fix libagbsyscall syms,$(MAKECMDGOALS)))
+$(call infoshell, $(MAKE) -f make_tools.mk)
else
-NODEP := 1
+NODEP ?= 1
endif
+# check if we need to scan dependencies based on the rule
+ifeq (,$(MAKECMDGOALS))
+ SCAN_DEPS ?= 1
+else
+ # clean, tidy, tools, mostlyclean, clean-tools, $(TOOLDIRS), tidymodern, tidynonmodern don't even build the ROM
+ # berry_fix and libagbsyscall do their own thing
+ ifeq (,$(filter-out clean tidy tools mostlyclean clean-tools $(TOOLDIRS) tidymodern tidynonmodern berry_fix libagbsyscall,$(MAKECMDGOALS)))
+ SCAN_DEPS ?= 0
+ else
+ SCAN_DEPS ?= 1
+ endif
+endif
+
+ifeq ($(SCAN_DEPS),1)
C_SRCS_IN := $(wildcard $(C_SUBDIR)/*.c $(C_SUBDIR)/*/*.c $(C_SUBDIR)/*/*/*.c)
C_SRCS := $(foreach src,$(C_SRCS_IN),$(if $(findstring .inc.c,$(src)),,$(src)))
C_OBJS := $(patsubst $(C_SUBDIR)/%.c,$(C_BUILDDIR)/%.o,$(C_SRCS))
@@ -152,17 +207,19 @@ OBJS := $(C_OBJS) $(GFLIB_OBJS) $(C_ASM_OBJS) $(ASM_OBJS) $(DATA_ASM_OBJS) $
OBJS_REL := $(patsubst $(OBJ_DIR)/%,%,$(OBJS))
SUBDIRS := $(sort $(dir $(OBJS)))
+$(shell mkdir -p $(SUBDIRS))
+endif
AUTO_GEN_TARGETS :=
-$(shell mkdir -p $(SUBDIRS))
-
all: rom
tools: $(TOOLDIRS)
+syms: $(SYM)
+
$(TOOLDIRS):
- @$(MAKE) -C $@ CC=$(HOSTCC) CXX=$(HOSTCXX)
+ @$(MAKE) -C $@
rom: $(ROM)
ifeq ($(COMPARE),1)
@@ -170,14 +227,14 @@ ifeq ($(COMPARE),1)
endif
# For contributors to make sure a change didn't affect the contents of the ROM.
-compare: ; @$(MAKE) COMPARE=1
+compare: all
clean: mostlyclean clean-tools
clean-tools:
@$(foreach tooldir,$(TOOLDIRS),$(MAKE) clean -C $(tooldir);)
-mostlyclean: tidy
+mostlyclean: tidynonmodern tidymodern
rm -f $(SAMPLE_SUBDIR)/*.bin
rm -f $(CRY_SUBDIR)/*.bin
rm -f $(MID_SUBDIR)/*.s
@@ -189,13 +246,16 @@ mostlyclean: tidy
@$(MAKE) clean -C berry_fix
@$(MAKE) clean -C libagbsyscall
-tidy:
- rm -f $(ROM) $(ELF) $(MAP)
- rm -r $(OBJ_DIR)
-ifeq ($(MODERN),0)
- @$(MAKE) tidy MODERN=1
-endif
+tidy: tidynonmodern tidymodern
+tidynonmodern:
+ rm -f $(ROM_NAME) $(ELF_NAME) $(MAP_NAME)
+ rm -rf $(OBJ_DIR_NAME)
+
+tidymodern:
+ rm -f $(MODERN_ROM_NAME) $(MODERN_ELF_NAME) $(MODERN_MAP_NAME)
+ rm -rf $(MODERN_OBJ_DIR_NAME)
+
ifneq ($(MODERN),0)
$(C_BUILDDIR)/berry_crush.o: override CFLAGS += -Wno-address-of-packed-member
endif
@@ -223,7 +283,7 @@ sound/%.bin: sound/%.aif ; $(AIF) $< $@
ifeq ($(MODERN),0)
-$(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc
+$(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc$(EXE)
$(C_BUILDDIR)/libc.o: CFLAGS := -O2
$(C_BUILDDIR)/siirtc.o: CFLAGS := -mthumb-interwork
@@ -232,57 +292,89 @@ $(C_BUILDDIR)/agb_flash.o: CFLAGS := -O -mthumb-interwork
$(C_BUILDDIR)/agb_flash_1m.o: CFLAGS := -O -mthumb-interwork
$(C_BUILDDIR)/agb_flash_mx.o: CFLAGS := -O -mthumb-interwork
-$(C_BUILDDIR)/m4a.o: CC1 := tools/agbcc/bin/old_agbcc
+$(C_BUILDDIR)/m4a.o: CC1 := tools/agbcc/bin/old_agbcc$(EXE)
$(C_BUILDDIR)/record_mixing.o: CFLAGS += -ffreestanding
-$(C_BUILDDIR)/librfu_intr.o: CC1 := tools/agbcc/bin/agbcc_arm
+$(C_BUILDDIR)/librfu_intr.o: CC1 := tools/agbcc/bin/agbcc_arm$(EXE)
$(C_BUILDDIR)/librfu_intr.o: CFLAGS := -O2 -mthumb-interwork -quiet
else
$(C_BUILDDIR)/librfu_intr.o: CFLAGS := -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast
endif
-ifeq ($(NODEP),1)
-$(C_BUILDDIR)/%.o: c_dep :=
-else
-$(C_BUILDDIR)/%.o: c_dep = $(shell [[ -f $(C_SUBDIR)/$*.c ]] && $(SCANINC) -I include -I tools/agbcc/include -I gflib $(C_SUBDIR)/$*.c)
-endif
-
ifeq ($(DINFO),1)
override CFLAGS += -g
endif
-$(C_BUILDDIR)/%.o : $(C_SUBDIR)/%.c $$(c_dep)
+# The dep rules have to be explicit or else missing files won't be reported.
+# As a side effect, they're evaluated immediately instead of when the rule is invoked.
+# It doesn't look like $(shell) can be deferred so there might not be a better way.
+
+ifeq ($(SCAN_DEPS),1)
+ifeq ($(NODEP),1)
+$(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.c
+ifeq (,$(KEEP_TEMPS))
+ @echo "$(CC1) <flags> -o $@ $<"
+ @$(CPP) $(CPPFLAGS) $< | $(PREPROC) $< charmap.txt -i | $(CC1) $(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $(AS) $(ASFLAGS) -o $@ -
+else
@$(CPP) $(CPPFLAGS) $< -o $(C_BUILDDIR)/$*.i
@$(PREPROC) $(C_BUILDDIR)/$*.i charmap.txt | $(CC1) $(CFLAGS) -o $(C_BUILDDIR)/$*.s
@echo -e ".text\n\t.align\t2, 0\n" >> $(C_BUILDDIR)/$*.s
$(AS) $(ASFLAGS) -o $@ $(C_BUILDDIR)/$*.s
-
-ifeq ($(NODEP),1)
-$(GFLIB_BUILDDIR)/%.o: c_dep :=
+endif
+else
+define C_DEP
+$1: $2 $$(shell $(SCANINC) -I include -I tools/agbcc/include -I gflib $2)
+ifeq (,$$(KEEP_TEMPS))
+ @echo "$$(CC1) <flags> -o $$@ $$<"
+ @$$(CPP) $$(CPPFLAGS) $$< | $$(PREPROC) $$< charmap.txt -i | $$(CC1) $$(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $$(AS) $$(ASFLAGS) -o $$@ -
else
-$(GFLIB_BUILDDIR)/%.o: c_dep = $(shell [[ -f $(GFLIB_SUBDIR)/$*.c ]] && $(SCANINC) -I include -I tools/agbcc/include -I gflib $(GFLIB_SUBDIR)/$*.c)
+ @$$(CPP) $$(CPPFLAGS) $$< -o $$(C_BUILDDIR)/$3.i
+ @$$(PREPROC) $$(C_BUILDDIR)/$3.i charmap.txt | $$(CC1) $$(CFLAGS) -o $$(C_BUILDDIR)/$3.s
+ @echo -e ".text\n\t.align\t2, 0\n" >> $$(C_BUILDDIR)/$3.s
+ $$(AS) $$(ASFLAGS) -o $$@ $$(C_BUILDDIR)/$3.s
+endif
+endef
+$(foreach src, $(C_SRCS), $(eval $(call C_DEP,$(patsubst $(C_SUBDIR)/%.c,$(C_BUILDDIR)/%.o,$(src)),$(src),$(patsubst $(C_SUBDIR)/%.c,%,$(src)))))
endif
-$(GFLIB_BUILDDIR)/%.o : $(GFLIB_SUBDIR)/%.c $$(c_dep)
+ifeq ($(NODEP),1)
+$(GFLIB_BUILDDIR)/%.o: $(GFLIB_SUBDIR)/%.c $$(c_dep)
+ifeq (,$(KEEP_TEMPS))
+ @echo "$(CC1) <flags> -o $@ $<"
+ @$(CPP) $(CPPFLAGS) $< | $(PREPROC) $< charmap.txt -i | $(CC1) $(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $(AS) $(ASFLAGS) -o $@ -
+else
@$(CPP) $(CPPFLAGS) $< -o $(GFLIB_BUILDDIR)/$*.i
@$(PREPROC) $(GFLIB_BUILDDIR)/$*.i charmap.txt | $(CC1) $(CFLAGS) -o $(GFLIB_BUILDDIR)/$*.s
@echo -e ".text\n\t.align\t2, 0\n" >> $(GFLIB_BUILDDIR)/$*.s
$(AS) $(ASFLAGS) -o $@ $(GFLIB_BUILDDIR)/$*.s
+endif
+else
+define GFLIB_DEP
+$1: $2 $$(shell $(SCANINC) -I include -I tools/agbcc/include -I gflib $2)
+ifeq (,$$(KEEP_TEMPS))
+ @echo "$$(CC1) <flags> -o $$@ $$<"
+ @$$(CPP) $$(CPPFLAGS) $$< | $$(PREPROC) $$< charmap.txt -i | $$(CC1) $$(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $$(AS) $$(ASFLAGS) -o $$@ -
+else
+ @$$(CPP) $$(CPPFLAGS) $$< -o $$(GFLIB_BUILDDIR)/$3.i
+ @$$(PREPROC) $$(GFLIB_BUILDDIR)/$3.i charmap.txt | $$(CC1) $$(CFLAGS) -o $$(GFLIB_BUILDDIR)/$3.s
+ @echo -e ".text\n\t.align\t2, 0\n" >> $$(GFLIB_BUILDDIR)/$3.s
+ $$(AS) $$(ASFLAGS) -o $$@ $$(GFLIB_BUILDDIR)/$3.s
+endif
+endef
+$(foreach src, $(GFLIB_SRCS), $(eval $(call GFLIB_DEP,$(patsubst $(GFLIB_SUBDIR)/%.c,$(GFLIB_BUILDDIR)/%.o, $(src)),$(src),$(patsubst $(GFLIB_SUBDIR)/%.c,%, $(src)))))
+endif
ifeq ($(NODEP),1)
-$(C_BUILDDIR)/%.o: c_asm_dep :=
+$(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.s
+ $(PREPROC) $< charmap.txt | $(CPP) -I include - | $(AS) $(ASFLAGS) -o $@
else
-$(C_BUILDDIR)/%.o: c_asm_dep = $(shell [[ -f $(C_SUBDIR)/$*.s ]] && $(SCANINC) -I "" $(C_SUBDIR)/$*.s)
+define SRC_ASM_DATA_DEP
+$1: $2 $$(shell $(SCANINC) -I include -I "" $2)
+ $$(PREPROC) $$< charmap.txt | $$(CPP) -I include - | $$(AS) $$(ASFLAGS) -o $$@
+endef
+$(foreach src, $(C_ASM_SRCS), $(eval $(call SRC_ASM_DATA_DEP,$(patsubst $(C_SUBDIR)/%.s,$(C_BUILDDIR)/%.o, $(src)),$(src))))
endif
-$(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.s $$(c_asm_dep)
- $(AS) $(ASFLAGS) -o $@ $<
-
-# The dep rules have to be explicit or else missing files won't be reported.
-# As a side effect, they're evaluated immediately instead of when the rule is invoked.
-# It doesn't look like $(shell) can be deferred so there might not be a better way.
-
-
ifeq ($(NODEP),1)
$(ASM_BUILDDIR)/%.o: $(ASM_SUBDIR)/%.s
$(AS) $(ASFLAGS) -o $@ $<
@@ -296,14 +388,10 @@ endif
ifeq ($(NODEP),1)
$(DATA_ASM_BUILDDIR)/%.o: $(DATA_ASM_SUBDIR)/%.s
- $(PREPROC) $< charmap.txt | $(CPP) -I include | $(AS) $(ASFLAGS) -o $@
+ $(PREPROC) $< charmap.txt | $(CPP) -I include - | $(AS) $(ASFLAGS) -o $@
else
-define DATA_ASM_DEP
-$1: $2 $$(shell $(SCANINC) -I include -I "" $2)
- $$(PREPROC) $$< charmap.txt | $$(CPP) -I include | $$(AS) $$(ASFLAGS) -o $$@
-endef
-$(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call DATA_ASM_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src))))
-$(foreach src, $(C_ASM_SRCS), $(eval $(call DATA_ASM_DEP,$(patsubst $(C_SUBDIR)/%.s,$(C_BUILDDIR)/%.o, $(src)),$(src))))
+$(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call SRC_ASM_DATA_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src))))
+endif
endif
$(SONG_BUILDDIR)/%.o: $(SONG_SUBDIR)/%.s
@@ -330,19 +418,27 @@ $(OBJ_DIR)/ld_script.ld: $(LD_SCRIPT) $(LD_SCRIPT_DEPS)
cd $(OBJ_DIR) && sed "s#tools/#../../tools/#g" ../../$(LD_SCRIPT) > ld_script.ld
$(ELF): $(OBJ_DIR)/ld_script.ld $(OBJS) berry_fix libagbsyscall
- cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(OBJS_REL) $(LIB)
+ @echo "cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ <objects> <lib>"
+ @cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(OBJS_REL) $(LIB)
$(FIX) $@ -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(REVISION) --silent
$(ROM): $(ELF)
$(OBJCOPY) -O binary $< $@
$(FIX) $@ -p --silent
-modern: ; @$(MAKE) MODERN=1
+modern: all
berry_fix/berry_fix.gba: berry_fix
berry_fix:
- @$(MAKE) -C berry_fix COMPARE=$(COMPARE) TOOLCHAIN=$(TOOLCHAIN)
+ @$(MAKE) -C berry_fix COMPARE=$(COMPARE) TOOLCHAIN=$(TOOLCHAIN) MODERN=$(MODERN)
libagbsyscall:
- @$(MAKE) -C libagbsyscall TOOLCHAIN=$(TOOLCHAIN)
+ @$(MAKE) -C libagbsyscall TOOLCHAIN=$(TOOLCHAIN) MODERN=$(MODERN)
+
+###################
+### Symbol file ###
+###################
+
+$(SYM): $(ELF)
+ $(OBJDUMP) -t $< | sort -u | grep -E "^0[2389]" | $(PERL) -p -e 's/^(\w{8}) (\w).{6} \S+\t(\w{8}) (\S+)$$/\1 \2 \3 \4/g' > $@
diff --git a/README.md b/README.md
index 2c3447abc..7adbb3e2d 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,5 @@
# Pokémon Emerald
-[![Build Status][travis-badge]][travis]
-
-[travis]: https://travis-ci.org/pret/pokeemerald
-[travis-badge]: https://travis-ci.org/pret/pokeemerald.svg?branch=master
-
This is a decompilation of Pokémon Emerald.
It builds the following ROM:
diff --git a/asm/macros/event.inc b/asm/macros/event.inc
index e25c76de4..73aef33b5 100644
--- a/asm/macros/event.inc
+++ b/asm/macros/event.inc
@@ -345,11 +345,12 @@
.byte 0x32
.endm
- @ Plays the specified (song_number) song. The byte is apparently supposed to be 0x00.
- .macro playbgm song_number:req, unknown:req
+ @ Plays the specified (song_number) song. If save_song is TRUE, the
+ @ specified (song_number) will be saved as if savebgm was called with it.
+ .macro playbgm song_number:req, save_song:req
.byte 0x33
.2byte \song_number
- .byte \unknown
+ .byte \save_song
.endm
@ Saves the specified (song_number) song to be played later.
diff --git a/asmdiff.sh b/asmdiff.sh
index 6ea588131..f5a701074 100755
--- a/asmdiff.sh
+++ b/asmdiff.sh
@@ -1,11 +1,19 @@
#!/bin/bash
-OBJDUMP="$DEVKITARM/bin/arm-none-eabi-objdump -D -bbinary -marmv4t -Mforce-thumb"
+if [[ -d "$DEVKITARM/bin/" ]]; then
+ OBJDUMP_BIN="$DEVKITARM/bin/arm-none-eabi-objdump"
+else
+ OBJDUMP_BIN="arm-none-eabi-objdump"
+fi
+
+OBJDUMP="$OBJDUMP_BIN -D -bbinary -marmv4t -Mforce-thumb"
+
if [ $(($1)) -ge $((0x8000000)) ]; then
OPTIONS="--adjust-vma=0x8000000 --start-address=$(($1)) --stop-address=$(($1 + $2))"
else
OPTIONS="--start-address=$(($1)) --stop-address=$(($1 + $2))"
fi
+
$OBJDUMP $OPTIONS baserom.gba > baserom.dump
$OBJDUMP $OPTIONS pokeemerald.gba > pokeemerald.dump
diff -u baserom.dump pokeemerald.dump
diff --git a/berry_fix/Makefile b/berry_fix/Makefile
index 0ead3804f..464e5f9e9 100644
--- a/berry_fix/Makefile
+++ b/berry_fix/Makefile
@@ -1,29 +1,27 @@
TOOLCHAIN := $(DEVKITARM)
COMPARE ?= 0
-ifeq ($(CC),)
-HOSTCC := gcc
-else
-HOSTCC := $(CC)
+# don't use dkP's base_tools anymore
+# because the redefinition of $(CC) conflicts
+# with when we want to use $(CC) to preprocess files
+# thus, manually create the variables for the bin
+# files, or use arm-none-eabi binaries on the system
+# if dkP is not installed on this system
+
+ifneq (,$(TOOLCHAIN))
+ifneq ($(wildcard $(TOOLCHAIN)/bin),)
+export PATH := $(TOOLCHAIN)/bin:$(PATH)
endif
-
-ifeq ($(CXX),)
-HOSTCXX := g++
-else
-HOSTCXX := $(CXX)
endif
-ifneq (,$(wildcard $(TOOLCHAIN)/base_tools))
-include $(TOOLCHAIN)/base_tools
-else
-export PATH := $(TOOLCHAIN)/bin:$(PATH)
PREFIX := arm-none-eabi-
OBJCOPY := $(PREFIX)objcopy
-export CC := $(PREFIX)gcc
-export AS := $(PREFIX)as
-endif
-export CPP := $(PREFIX)cpp
-export LD := $(PREFIX)ld
+AS := $(PREFIX)as
+LD := $(PREFIX)ld
+
+# note: the makefile must be set up so MODERNCC is never called
+# if MODERN=0
+MODERNCC := $(PREFIX)gcc
ifeq ($(OS),Windows_NT)
EXE := .exe
@@ -31,6 +29,23 @@ else
EXE :=
endif
+# use arm-none-eabi-cpp for macOS
+# as macOS's default compiler is clang
+# and clang's preprocessor will warn on \u
+# when preprocessing asm files, expecting a unicode literal
+# we can't unconditionally use arm-none-eabi-cpp
+# as installations which install binutils-arm-none-eabi
+# don't come with it
+ifneq ($(MODERN),1)
+ ifeq ($(shell uname -s),Darwin)
+ CPP := $(PREFIX)cpp
+ else
+ CPP := $(CC) -E
+ endif
+else
+ CPP := $(PREFIX)cpp
+endif
+
GAME_CODE := AGBJ
MAKER_CODE := 01
REVISION := 0
@@ -166,7 +181,7 @@ $(DATA_ASM_BUILDDIR)/%.o: data_dep = $(shell $(SCANINC) $(DATA_ASM_SUBDIR)/$*.s)
endif
payload:
- @$(MAKE) -C payload COMPARE=$(COMPARE) TOOLCHAIN=$(TOOLCHAIN)
+ @$(MAKE) -C payload COMPARE=$(COMPARE) TOOLCHAIN=$(TOOLCHAIN) MODERN=$(MODERN)
payload/payload.gba: payload
diff --git a/berry_fix/payload/Makefile b/berry_fix/payload/Makefile
index a121fda93..2779c43ba 100644
--- a/berry_fix/payload/Makefile
+++ b/berry_fix/payload/Makefile
@@ -1,29 +1,27 @@
TOOLCHAIN := $(DEVKITARM)
COMPARE ?= 0
-ifeq ($(CC),)
-HOSTCC := gcc
-else
-HOSTCC := $(CC)
+# don't use dkP's base_tools anymore
+# because the redefinition of $(CC) conflicts
+# with when we want to use $(CC) to preprocess files
+# thus, manually create the variables for the bin
+# files, or use arm-none-eabi binaries on the system
+# if dkP is not installed on this system
+
+ifneq (,$(TOOLCHAIN))
+ifneq ($(wildcard $(TOOLCHAIN)/bin),)
+export PATH := $(TOOLCHAIN)/bin:$(PATH)
endif
-
-ifeq ($(CXX),)
-HOSTCXX := g++
-else
-HOSTCXX := $(CXX)
endif
-ifneq (,$(wildcard $(TOOLCHAIN)/base_tools))
-include $(TOOLCHAIN)/base_tools
-else
-export PATH := $(TOOLCHAIN)/bin:$(PATH)
PREFIX := arm-none-eabi-
OBJCOPY := $(PREFIX)objcopy
-export CC := $(PREFIX)gcc
-export AS := $(PREFIX)as
-endif
-export CPP := $(PREFIX)cpp
-export LD := $(PREFIX)ld
+AS := $(PREFIX)as
+LD := $(PREFIX)ld
+
+# note: the makefile must be set up so MODERNCC is never called
+# if MODERN=0
+MODERNCC := $(PREFIX)gcc
ifeq ($(OS),Windows_NT)
EXE := .exe
@@ -31,6 +29,23 @@ else
EXE :=
endif
+# use arm-none-eabi-cpp for macOS
+# as macOS's default compiler is clang
+# and clang's preprocessor will warn on \u
+# when preprocessing asm files, expecting a unicode literal
+# we can't unconditionally use arm-none-eabi-cpp
+# as installations which install binutils-arm-none-eabi
+# don't come with it
+ifneq ($(MODERN),1)
+ ifeq ($(shell uname -s),Darwin)
+ CPP := $(PREFIX)cpp
+ else
+ CPP := $(CC) -E
+ endif
+else
+ CPP := $(PREFIX)cpp
+endif
+
SHELL := /bin/bash -o pipefail
CPPFLAGS := -I ../../tools/agbcc/include -I ../../tools/agbcc -iquote include -nostdinc -undef
diff --git a/berry_fix/payload/include/gba/m4a_internal.h b/berry_fix/payload/include/gba/m4a_internal.h
index 339a0774e..1aca67585 100644
--- a/berry_fix/payload/include/gba/m4a_internal.h
+++ b/berry_fix/payload/include/gba/m4a_internal.h
@@ -419,7 +419,7 @@ void SetPokemonCryPitch(s16 val);
void SetPokemonCryLength(u16 val);
void SetPokemonCryRelease(u8 val);
void SetPokemonCryProgress(u32 val);
-int IsPokemonCryPlaying(struct MusicPlayerInfo *mplayInfo);
+bool32 IsPokemonCryPlaying(struct MusicPlayerInfo *mplayInfo);
void SetPokemonCryChorus(s8 val);
void SetPokemonCryStereo(u32 val);
void SetPokemonCryPriority(u8 val);
diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s
index d1c9bc78b..e7aad6a93 100644
--- a/data/battle_anim_scripts.s
+++ b/data/battle_anim_scripts.s
@@ -1656,12 +1656,12 @@ Explosion1:
Move_DEFENSE_CURL:
loadspritegfx ANIM_TAG_ECLIPSING_ORB
loopsewithpan SE_M_TRI_ATTACK, SOUND_PAN_ATTACKER, 18, 3
- createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, ANIM_ATTACKER, 0
+ createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, ANIM_ATTACKER, 0
createvisualtask AnimTask_DefenseCurlDeformMon, 5
waitforvisualfinish
createsprite gEclipsingOrbSpriteTemplate, ANIM_ATTACKER, 2, 0, 6, 0, 1
waitforvisualfinish
- createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, ANIM_ATTACKER, 1
+ createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, ANIM_ATTACKER, 1
waitforvisualfinish
end
@@ -7254,7 +7254,7 @@ Move_IRON_TAIL:
createvisualtask AnimTask_ShakeMon, 2, ANIM_TARGET, 3, 0, 6, 1
playsewithpan SE_M_VITAL_THROW2, SOUND_PAN_TARGET
waitforvisualfinish
- createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, ANIM_ATTACKER, 1
+ createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, ANIM_ATTACKER, 1
clearmonbg ANIM_TARGET
blendoff
waitforvisualfinish
@@ -7274,7 +7274,7 @@ Move_POISON_TAIL:
createvisualtask AnimTask_ShakeMon, 2, ANIM_TARGET, 3, 0, 6, 1
playsewithpan SE_M_VITAL_THROW2, SOUND_PAN_TARGET
waitforvisualfinish
- createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, ANIM_ATTACKER, 1
+ createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, ANIM_ATTACKER, 1
clearmonbg ANIM_TARGET
blendoff
call PoisonBubblesEffect
@@ -7551,7 +7551,7 @@ Move_DISABLE:
playsewithpan SE_M_DETECT, SOUND_PAN_ATTACKER
createsprite gSpinningSparkleSpriteTemplate, ANIM_ATTACKER, 13, 24, -16
waitforvisualfinish
- createvisualtask AnimTask_GrowAndGreyscale, 5
+ createvisualtask AnimTask_GrowAndGrayscale, 5
loopsewithpan SE_M_BIND, SOUND_PAN_TARGET, 15, 4
waitforvisualfinish
delay 1
@@ -7946,16 +7946,16 @@ Move_PERISH_SONG:
panse_1B SE_M_PERISH_SONG, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, +2, 0
delay 80
createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 0, 16, RGB_BLACK
- createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, 4, 0
- createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, 5, 0
- createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, 6, 0
- createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, 7, 0
+ createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 4, 0
+ createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 5, 0
+ createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 6, 0
+ createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 7, 0
delay 100
createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 3, 16, 0, RGB_BLACK
- createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, 4, 1
- createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, 5, 1
- createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, 6, 1
- createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, 7, 1
+ createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 4, 1
+ createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 5, 1
+ createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 6, 1
+ createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, 7, 1
waitforvisualfinish
end
@@ -9573,7 +9573,7 @@ Move_DOOM_DESIRE:
createvisualtask GetIsDoomDesireHitTurn, 2
delay 1
monbg ANIM_ATK_PARTNER
- createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, ANIM_TARGET, FALSE
+ createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, ANIM_TARGET, FALSE
createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 0, 4, RGB_BLACK
waitforvisualfinish
setalpha 8, 8
@@ -9581,7 +9581,7 @@ Move_DOOM_DESIRE:
createvisualtask AnimTask_ScaleMonAndRestore, 5, -4, -4, 15, ANIM_ATTACKER, 1
waitforvisualfinish
delay 20
- createvisualtask AnimTask_SetGreyscaleOrOriginalPal, 5, ANIM_TARGET, TRUE
+ createvisualtask AnimTask_SetGrayscaleOrOriginalPal, 5, ANIM_TARGET, TRUE
createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 4, 0, RGB_BLACK
waitforvisualfinish
clearmonbg ANIM_ATK_PARTNER
diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s
index 045db19c5..b15c29cfe 100644
--- a/data/battle_scripts_1.s
+++ b/data/battle_scripts_1.s
@@ -1120,7 +1120,7 @@ BattleScript_SubstituteAnim::
healthbarupdate BS_ATTACKER
datahpupdate BS_ATTACKER
BattleScript_SubstituteString::
- printfromtable gSubsituteUsedStringIds
+ printfromtable gSubstituteUsedStringIds
waitmessage B_WAIT_TIME_LONG
goto BattleScript_MoveEnd
BattleScript_AlreadyHasSubstitute::
diff --git a/data/event_scripts.s b/data/event_scripts.s
index 8039be687..432f1294d 100644
--- a/data/event_scripts.s
+++ b/data/event_scripts.s
@@ -736,7 +736,7 @@ EventScript_RegionMap:: @ 827208F
Common_EventScript_PlayBrineysBoatMusic:: @ 82720A0
setflag FLAG_DONT_TRANSITION_MUSIC
- playbgm MUS_SAILING, 0
+ playbgm MUS_SAILING, FALSE
return
Common_EventScript_StopBrineysBoatMusic:: @ 82720A8
diff --git a/data/maps/BattleFrontier_BattlePyramidFloor/scripts.inc b/data/maps/BattleFrontier_BattlePyramidFloor/scripts.inc
index 4f378c4e5..e63e27e4e 100644
--- a/data/maps/BattleFrontier_BattlePyramidFloor/scripts.inc
+++ b/data/maps/BattleFrontier_BattlePyramidFloor/scripts.inc
@@ -33,7 +33,7 @@ BattleFrontier_BattlePyramidFloor_EventScript_ShowMapName:: @ 8252A8F
end
BattleFrontier_BattlePyramidFloor_EventScript_PlayPyramidMusic:: @ 8252A98
- playbgm MUS_B_PYRAMID, 0
+ playbgm MUS_B_PYRAMID, FALSE
setvar VAR_TEMP_E, 1
end
diff --git a/data/maps/BattleFrontier_BattlePyramidTop/scripts.inc b/data/maps/BattleFrontier_BattlePyramidTop/scripts.inc
index 076fae158..568424083 100644
--- a/data/maps/BattleFrontier_BattlePyramidTop/scripts.inc
+++ b/data/maps/BattleFrontier_BattlePyramidTop/scripts.inc
@@ -53,7 +53,7 @@ BattleFrontier_BattlePyramidTop_OnFrame: @ 825516E
.2byte 0
BattleFrontier_BattlePyramidTop_EventScript_PlayPyramidMusic:: @ 8255180
- playbgm MUS_B_PYRAMID_TOP, 0
+ playbgm MUS_B_PYRAMID_TOP, FALSE
setvar VAR_TEMP_E, 1
end
@@ -136,7 +136,7 @@ BattleFrontier_BattlePyramidTop_EventScript_BrandonHeardSilverSpeech:: @ 82552D0
BattleFrontier_BattlePyramidTop_EventScript_BattleBrandonSilver:: @ 82552DA
msgbox BattleFrontier_BattlePyramidTop_Text_BringCourageToOurBattle, MSGBOX_DEFAULT
call BattleFrontier_BattlePyramidTop_EventScript_DoBrandonBattle
- playbgm MUS_B_PYRAMID_TOP, 0
+ playbgm MUS_B_PYRAMID_TOP, FALSE
compare VAR_RESULT, 1
goto_if_eq BattleFrontier_BattlePyramidTop_EventScript_DefeatedBrandonSilver
goto BattleFrontier_BattlePyramid_EventScript_WarpToLobbyLost
@@ -176,7 +176,7 @@ BattleFrontier_BattlePyramidTop_EventScript_BrandonHeardGoldSpeech:: @ 8255388
BattleFrontier_BattlePyramidTop_EventScript_BattleBrandonGold:: @ 8255392
msgbox BattleFrontier_BattlePyramidTop_Text_EverythingYouHave, MSGBOX_DEFAULT
call BattleFrontier_BattlePyramidTop_EventScript_DoBrandonBattle
- playbgm MUS_B_PYRAMID_TOP, 0
+ playbgm MUS_B_PYRAMID_TOP, FALSE
compare VAR_RESULT, 1
goto_if_eq BattleFrontier_BattlePyramidTop_EventScript_DefeatedBrandonGold
goto BattleFrontier_BattlePyramid_EventScript_WarpToLobbyLost
diff --git a/data/maps/BirthIsland_Exterior/scripts.inc b/data/maps/BirthIsland_Exterior/scripts.inc
index c20de3798..5871709ac 100644
--- a/data/maps/BirthIsland_Exterior/scripts.inc
+++ b/data/maps/BirthIsland_Exterior/scripts.inc
@@ -72,7 +72,7 @@ BirthIsland_Exterior_EventScript_Deoxys:: @ 8267FC1
setfieldeffectargument 1, 58
setfieldeffectargument 2, 26
dofieldeffect FLDEFF_DESTROY_DEOXYS_ROCK
- playbgm MUS_RG_ENCOUNTER_DEOXYS, 0
+ playbgm MUS_RG_ENCOUNTER_DEOXYS, FALSE
waitfieldeffect FLDEFF_DESTROY_DEOXYS_ROCK
addobject LOCALID_DEOXYS
applymovement LOCALID_DEOXYS, BirthIsland_Exterior_Movement_DeoxysApproach
diff --git a/data/maps/EverGrandeCity_ChampionsRoom/scripts.inc b/data/maps/EverGrandeCity_ChampionsRoom/scripts.inc
index d41c10d0a..7b75c8752 100644
--- a/data/maps/EverGrandeCity_ChampionsRoom/scripts.inc
+++ b/data/maps/EverGrandeCity_ChampionsRoom/scripts.inc
@@ -42,7 +42,7 @@ EverGrandeCity_ChampionsRoom_Movement_PlayerApproachWallace: @ 8228A42
step_end
EverGrandeCity_ChampionsRoom_EventScript_Wallace:: @ 8228A45
- playbgm MUS_ENCOUNTER_CHAMPION, 0
+ playbgm MUS_ENCOUNTER_CHAMPION, FALSE
msgbox EverGrandeCity_ChampionsRoom_Text_IntroSpeech, MSGBOX_DEFAULT
trainerbattle_no_intro TRAINER_WALLACE, EverGrandeCity_ChampionsRoom_Text_Defeat
goto EverGrandeCity_ChampionsRoom_EventScript_Defeated
@@ -71,11 +71,11 @@ EverGrandeCity_ChampionsRoom_EventScript_Defeated:: @ 8228A61
end
EverGrandeCity_ChampionsRoom_EventScript_PlayMayMusic:: @ 8228ABC
- playbgm MUS_ENCOUNTER_MAY, 0
+ playbgm MUS_ENCOUNTER_MAY, FALSE
return
EverGrandeCity_ChampionsRoom_EventScript_PlayBrendanMusic:: @ 8228AC1
- playbgm MUS_ENCOUNTER_BRENDAN, 0
+ playbgm MUS_ENCOUNTER_BRENDAN, FALSE
return
EverGrandeCity_ChampionsRoom_EventScript_MayAdvice:: @ 8228AC6
diff --git a/data/maps/EverGrandeCity_DrakesRoom/scripts.inc b/data/maps/EverGrandeCity_DrakesRoom/scripts.inc
index feb65d149..38762277f 100644
--- a/data/maps/EverGrandeCity_DrakesRoom/scripts.inc
+++ b/data/maps/EverGrandeCity_DrakesRoom/scripts.inc
@@ -42,7 +42,7 @@ EverGrandeCity_DrakesRoom_EventScript_Drake:: @ 82286F3
lock
faceplayer
goto_if_set FLAG_DEFEATED_ELITE_4_DRAKE, EverGrandeCity_DrakesRoom_EventScript_PostBattleSpeech
- playbgm MUS_ENCOUNTER_ELITE_FOUR, 0
+ playbgm MUS_ENCOUNTER_ELITE_FOUR, FALSE
msgbox EverGrandeCity_DrakesRoom_Text_IntroSpeech, MSGBOX_DEFAULT
trainerbattle_no_intro TRAINER_DRAKE, EverGrandeCity_DrakesRoom_Text_Defeat
goto EverGrandeCity_DrakesRoom_EventScript_Defeated
diff --git a/data/maps/EverGrandeCity_GlaciasRoom/scripts.inc b/data/maps/EverGrandeCity_GlaciasRoom/scripts.inc
index ff04a752a..3529b746c 100644
--- a/data/maps/EverGrandeCity_GlaciasRoom/scripts.inc
+++ b/data/maps/EverGrandeCity_GlaciasRoom/scripts.inc
@@ -41,7 +41,7 @@ EverGrandeCity_GlaciasRoom_EventScript_Glacia:: @ 8228469
lock
faceplayer
goto_if_set FLAG_DEFEATED_ELITE_4_GLACIA, EverGrandeCity_GlaciasRoom_EventScript_PostBattleSpeech
- playbgm MUS_ENCOUNTER_ELITE_FOUR, 0
+ playbgm MUS_ENCOUNTER_ELITE_FOUR, FALSE
msgbox EverGrandeCity_GlaciasRoom_Text_IntroSpeech, MSGBOX_DEFAULT
trainerbattle_no_intro TRAINER_GLACIA, EverGrandeCity_GlaciasRoom_Text_Defeat
goto EverGrandeCity_GlaciasRoom_EventScript_Defeated
diff --git a/data/maps/EverGrandeCity_PhoebesRoom/scripts.inc b/data/maps/EverGrandeCity_PhoebesRoom/scripts.inc
index e98bf4eb3..c922ffe7a 100644
--- a/data/maps/EverGrandeCity_PhoebesRoom/scripts.inc
+++ b/data/maps/EverGrandeCity_PhoebesRoom/scripts.inc
@@ -41,7 +41,7 @@ EverGrandeCity_PhoebesRoom_EventScript_Phoebe:: @ 82281CB
lock
faceplayer
goto_if_set FLAG_DEFEATED_ELITE_4_PHOEBE, EverGrandeCity_PhoebesRoom_EventScript_PostBattleSpeech
- playbgm MUS_ENCOUNTER_ELITE_FOUR, 0
+ playbgm MUS_ENCOUNTER_ELITE_FOUR, FALSE
msgbox EverGrandeCity_PhoebesRoom_Text_IntroSpeech, MSGBOX_DEFAULT
trainerbattle_no_intro TRAINER_PHOEBE, EverGrandeCity_PhoebesRoom_Text_Defeat
goto EverGrandeCity_PhoebesRoom_EventScript_Defeated
diff --git a/data/maps/EverGrandeCity_SidneysRoom/scripts.inc b/data/maps/EverGrandeCity_SidneysRoom/scripts.inc
index 717651b26..4cd8f262e 100644
--- a/data/maps/EverGrandeCity_SidneysRoom/scripts.inc
+++ b/data/maps/EverGrandeCity_SidneysRoom/scripts.inc
@@ -47,7 +47,7 @@ EverGrandeCity_SidneysRoom_EventScript_Sidney:: @ 8227F64
lock
faceplayer
goto_if_set FLAG_DEFEATED_ELITE_4_SIDNEY, EverGrandeCity_SidneysRoom_EventScript_PostBattleSpeech
- playbgm MUS_ENCOUNTER_ELITE_FOUR, 0
+ playbgm MUS_ENCOUNTER_ELITE_FOUR, FALSE
msgbox EverGrandeCity_SidneysRoom_Text_IntroSpeech, MSGBOX_DEFAULT
trainerbattle_no_intro TRAINER_SIDNEY, EverGrandeCity_SidneysRoom_Text_Defeat
goto EverGrandeCity_SidneysRoom_EventScript_Defeated
diff --git a/data/maps/LavaridgeTown/scripts.inc b/data/maps/LavaridgeTown/scripts.inc
index 1f9fe421d..59275c526 100644
--- a/data/maps/LavaridgeTown/scripts.inc
+++ b/data/maps/LavaridgeTown/scripts.inc
@@ -105,11 +105,11 @@ LavaridgeTown_EventScript_RivalExit:: @ 81EA5FF
end
LavaridgeTown_EventScript_PlayMayMusic:: @ 81EA630
- playbgm MUS_ENCOUNTER_MAY, 1
+ playbgm MUS_ENCOUNTER_MAY, TRUE
return
LavaridgeTown_EventScript_PlayBrendanMusic:: @ 81EA635
- playbgm MUS_ENCOUNTER_BRENDAN, 1
+ playbgm MUS_ENCOUNTER_BRENDAN, TRUE
return
LavaridgeTown_EventScript_RivalNoticePlayer:: @ 81EA63A
diff --git a/data/maps/LilycoveCity/scripts.inc b/data/maps/LilycoveCity/scripts.inc
index d54942386..b5748ef60 100644
--- a/data/maps/LilycoveCity/scripts.inc
+++ b/data/maps/LilycoveCity/scripts.inc
@@ -241,7 +241,7 @@ LilycoveCity_EventScript_Rival:: @ 81E2DDE
end
LilycoveCity_EventScript_May:: @ 81E2DF8
- playbgm MUS_ENCOUNTER_MAY, 1
+ playbgm MUS_ENCOUNTER_MAY, TRUE
call_if_set FLAG_DECLINED_RIVAL_BATTLE_LILYCOVE, LilycoveCity_EventScript_MayAskToBattleAgain
call_if_unset FLAG_DECLINED_RIVAL_BATTLE_LILYCOVE, LilycoveCity_EventScript_MayAskToBattle
compare VAR_RESULT, NO
@@ -270,7 +270,7 @@ LilycoveCity_EventScript_DeclineMayBattle:: @ 81E2E5A
end
LilycoveCity_EventScript_Brendan:: @ 81E2E6B
- playbgm MUS_ENCOUNTER_BRENDAN, 1
+ playbgm MUS_ENCOUNTER_BRENDAN, TRUE
call_if_set FLAG_DECLINED_RIVAL_BATTLE_LILYCOVE, LilycoveCity_EventScript_BrendanAskToBattleAgain
call_if_unset FLAG_DECLINED_RIVAL_BATTLE_LILYCOVE, LilycoveCity_EventScript_BrendanAskToBattle
compare VAR_RESULT, NO
diff --git a/data/maps/LittlerootTown_BrendansHouse_1F/scripts.inc b/data/maps/LittlerootTown_BrendansHouse_1F/scripts.inc
index ee677fbff..4b5679ad9 100644
--- a/data/maps/LittlerootTown_BrendansHouse_1F/scripts.inc
+++ b/data/maps/LittlerootTown_BrendansHouse_1F/scripts.inc
@@ -158,7 +158,7 @@ LittlerootTown_BrendansHouse_1F_EventScript_MeetRival:: @ 81F78E2
waitmovement 0
compare VAR_0x8008, 1
call_if_ne LittlerootTown_BrendansHouse_1F_EventScript_PlayerFaceBrendan
- playbgm MUS_ENCOUNTER_BRENDAN, 1
+ playbgm MUS_ENCOUNTER_BRENDAN, TRUE
compare VAR_0x8008, 0
call_if_eq LittlerootTown_BrendansHouse_1F_EventScript_BrendanApproachPlayer0
compare VAR_0x8008, 1
diff --git a/data/maps/LittlerootTown_BrendansHouse_2F/scripts.inc b/data/maps/LittlerootTown_BrendansHouse_2F/scripts.inc
index ab6f55af5..6cfeea7e4 100644
--- a/data/maps/LittlerootTown_BrendansHouse_2F/scripts.inc
+++ b/data/maps/LittlerootTown_BrendansHouse_2F/scripts.inc
@@ -74,7 +74,7 @@ LittlerootTown_BrendansHouse_2F_EventScript_MeetBrendan:: @ 81F8497
applymovement LOCALID_RIVAL, Common_Movement_Delay48
waitmovement 0
delay 10
- playbgm MUS_ENCOUNTER_BRENDAN, 1
+ playbgm MUS_ENCOUNTER_BRENDAN, TRUE
compare VAR_FACING, DIR_NORTH
call_if_eq LittlerootTown_BrendansHouse_2F_EventScript_MeetBrendanNorth
compare VAR_FACING, DIR_SOUTH
diff --git a/data/maps/LittlerootTown_MaysHouse_1F/scripts.inc b/data/maps/LittlerootTown_MaysHouse_1F/scripts.inc
index 1e1bb0e11..f1df425b7 100644
--- a/data/maps/LittlerootTown_MaysHouse_1F/scripts.inc
+++ b/data/maps/LittlerootTown_MaysHouse_1F/scripts.inc
@@ -192,7 +192,7 @@ LittlerootTown_MaysHouse_1F_EventScript_MeetRival:: @ 81F8A8B
waitmovement 0
compare VAR_0x8008, 1
call_if_ne LittlerootTown_MaysHouse_1F_EventScript_PlayerFaceMay
- playbgm MUS_ENCOUNTER_MAY, 1
+ playbgm MUS_ENCOUNTER_MAY, TRUE
compare VAR_0x8008, 0
call_if_eq LittlerootTown_MaysHouse_1F_EventScript_MayApproachPlayer0
compare VAR_0x8008, 1
diff --git a/data/maps/LittlerootTown_MaysHouse_2F/scripts.inc b/data/maps/LittlerootTown_MaysHouse_2F/scripts.inc
index dd22ed670..a0583841c 100644
--- a/data/maps/LittlerootTown_MaysHouse_2F/scripts.inc
+++ b/data/maps/LittlerootTown_MaysHouse_2F/scripts.inc
@@ -74,7 +74,7 @@ LittlerootTown_MaysHouse_2F_EventScript_MeetMay:: @ 81F934A
applymovement LOCALID_RIVAL, Common_Movement_Delay48
waitmovement 0
delay 10
- playbgm MUS_ENCOUNTER_MAY, 1
+ playbgm MUS_ENCOUNTER_MAY, TRUE
compare VAR_FACING, DIR_NORTH
call_if_eq LittlerootTown_MaysHouse_2F_EventScript_MeetMayNorth
compare VAR_FACING, DIR_SOUTH
diff --git a/data/maps/MagmaHideout_2F_2R/map.json b/data/maps/MagmaHideout_2F_2R/map.json
index 4aa6896f6..968c07fb7 100644
--- a/data/maps/MagmaHideout_2F_2R/map.json
+++ b/data/maps/MagmaHideout_2F_2R/map.json
@@ -50,7 +50,7 @@
"movement_range_y": 1,
"trainer_type": "TRAINER_TYPE_NONE",
"trainer_sight_or_berry_tree_id": "0",
- "script": "MagmaHideout_2F_2R_EventScript_MaxElixir",
+ "script": "MagmaHideout_2F_2R_EventScript_ItemMaxElixir",
"flag": "FLAG_ITEM_MAGMA_HIDEOUT_2F_2R_MAX_ELIXIR"
},
{
diff --git a/data/maps/MagmaHideout_4F/map.json b/data/maps/MagmaHideout_4F/map.json
index 94cf295e0..67c11481f 100644
--- a/data/maps/MagmaHideout_4F/map.json
+++ b/data/maps/MagmaHideout_4F/map.json
@@ -115,7 +115,7 @@
"movement_range_y": 1,
"trainer_type": "TRAINER_TYPE_NONE",
"trainer_sight_or_berry_tree_id": "0",
- "script": "MagmaHideout_4F_EventScript_MaxRevive",
+ "script": "MagmaHideout_4F_EventScript_ItemMaxRevive",
"flag": "FLAG_ITEM_MAGMA_HIDEOUT_4F_MAX_REVIVE"
}
],
diff --git a/data/maps/MagmaHideout_4F/scripts.inc b/data/maps/MagmaHideout_4F/scripts.inc
index 50382f44e..199e3c1bc 100644
--- a/data/maps/MagmaHideout_4F/scripts.inc
+++ b/data/maps/MagmaHideout_4F/scripts.inc
@@ -11,7 +11,7 @@ MagmaHideout_4F_MapScripts:: @ 823A55F
MagmaHideout_4F_EventScript_Maxie:: @ 823A560
lockall
- playbgm MUS_ENCOUNTER_MAGMA, 0
+ playbgm MUS_ENCOUNTER_MAGMA, FALSE
msgbox MagmaHideout_4F_Text_MaxieAwakenGroudon, MSGBOX_DEFAULT
closemessage
delay 20
diff --git a/data/maps/MeteorFalls_1F_1R/scripts.inc b/data/maps/MeteorFalls_1F_1R/scripts.inc
index c942e230e..8202267b9 100644
--- a/data/maps/MeteorFalls_1F_1R/scripts.inc
+++ b/data/maps/MeteorFalls_1F_1R/scripts.inc
@@ -21,7 +21,7 @@ MeteorFalls_1F_1R_EventScript_OpenStevensCave:: @ 822BD3A
MeteorFalls_1F_1R_EventScript_MagmaStealsMeteoriteScene:: @ 822BD5F
lockall
- playbgm MUS_ENCOUNTER_MAGMA, 0
+ playbgm MUS_ENCOUNTER_MAGMA, FALSE
applymovement OBJ_EVENT_ID_PLAYER, Common_Movement_FaceDown
waitmovement 0
delay 30
@@ -50,7 +50,7 @@ MeteorFalls_1F_1R_EventScript_MagmaStealsMeteoriteScene:: @ 822BD5F
addobject LOCALID_ARCHIE
addobject LOCALID_AQUA_GRUNT_1
addobject LOCALID_AQUA_GRUNT_2
- playbgm MUS_ENCOUNTER_AQUA, 0
+ playbgm MUS_ENCOUNTER_AQUA, FALSE
applymovement LOCALID_ARCHIE, MeteorFalls_1F_1R_Movement_ArchieArrive
applymovement LOCALID_AQUA_GRUNT_1, MeteorFalls_1F_1R_Movement_AquaGrunt1Arrive
applymovement LOCALID_AQUA_GRUNT_2, MeteorFalls_1F_1R_Movement_AquaGrunt2Arrive
diff --git a/data/maps/MtChimney/scripts.inc b/data/maps/MtChimney/scripts.inc
index c633d9313..061590e1a 100644
--- a/data/maps/MtChimney/scripts.inc
+++ b/data/maps/MtChimney/scripts.inc
@@ -40,7 +40,7 @@ MtChimney_EventScript_ArchieBusyFighting:: @ 822EE02
MtChimney_EventScript_Maxie:: @ 822EE0B
lockall
- playbgm MUS_ENCOUNTER_MAGMA, 0
+ playbgm MUS_ENCOUNTER_MAGMA, FALSE
msgbox MtChimney_Text_MeteoriteWillActivateVolcano, MSGBOX_DEFAULT
applymovement LOCALID_MAXIE, Common_Movement_FacePlayer
waitmovement 0
diff --git a/data/maps/MtPyre_Summit/scripts.inc b/data/maps/MtPyre_Summit/scripts.inc
index c2692ff20..e899c3471 100644
--- a/data/maps/MtPyre_Summit/scripts.inc
+++ b/data/maps/MtPyre_Summit/scripts.inc
@@ -39,7 +39,7 @@ MtPyre_Summit_EventScript_TeamAquaTrigger2:: @ 8232030
end
MtPyre_Summit_EventScript_TeamAquaExits:: @ 823203C
- playbgm MUS_ENCOUNTER_AQUA, 0
+ playbgm MUS_ENCOUNTER_AQUA, FALSE
applymovement OBJ_EVENT_ID_PLAYER, Common_Movement_FaceUp
waitmovement 0
applymovement LOCALID_ARCHIE, Common_Movement_WalkInPlaceFastestDown
diff --git a/data/maps/OldaleTown/scripts.inc b/data/maps/OldaleTown/scripts.inc
index f99c65d2c..593215357 100644
--- a/data/maps/OldaleTown/scripts.inc
+++ b/data/maps/OldaleTown/scripts.inc
@@ -43,7 +43,7 @@ OldaleTown_EventScript_MartEmployee:: @ 81E8EFC
goto_if_set FLAG_RECEIVED_POTION_OLDALE, OldaleTown_EventScript_ExplainPotion
goto_if_set FLAG_TEMP_1, OldaleTown_EventScript_ExplainPotion
setflag FLAG_TEMP_1
- playbgm MUS_FOLLOW_ME, 0
+ playbgm MUS_FOLLOW_ME, FALSE
msgbox OldaleTown_Text_IWorkAtPokemonMart, MSGBOX_DEFAULT
closemessage
switch VAR_FACING
diff --git a/data/maps/PetalburgCity/scripts.inc b/data/maps/PetalburgCity/scripts.inc
index ab77e18e0..5114ea639 100644
--- a/data/maps/PetalburgCity/scripts.inc
+++ b/data/maps/PetalburgCity/scripts.inc
@@ -271,7 +271,7 @@ PetalburgCity_EventScript_ShowGymToPlayer3:: @ 81DC4BE
PetalburgCity_EventScript_ShowGymToPlayer:: @ 81DC4CA
applymovement LOCALID_GYM_BOY, Common_Movement_FacePlayer
waitmovement 0
- playbgm MUS_FOLLOW_ME, 0
+ playbgm MUS_FOLLOW_ME, FALSE
playse SE_PIN
applymovement LOCALID_GYM_BOY, Common_Movement_ExclamationMark
waitmovement 0
diff --git a/data/maps/PetalburgCity_Gym/scripts.inc b/data/maps/PetalburgCity_Gym/scripts.inc
index 2bdd5320f..b2f6b1061 100644
--- a/data/maps/PetalburgCity_Gym/scripts.inc
+++ b/data/maps/PetalburgCity_Gym/scripts.inc
@@ -203,7 +203,7 @@ PetalburgCity_Gym_EventScript_BeginWallyTutorial:: @ 8204AAC
msgbox PetalburgCity_Gym_Text_WouldYouReallyComeWithMe, MSGBOX_DEFAULT
closemessage
setflag FLAG_DONT_TRANSITION_MUSIC
- playbgm MUS_FOLLOW_ME, 0
+ playbgm MUS_FOLLOW_ME, FALSE
compare VAR_0x8008, 0
call_if_eq PetalburgCity_Gym_EventScript_ExitGymWithWallySouth
compare VAR_0x8008, 1
@@ -487,7 +487,7 @@ PetalburgCity_Gym_EventScript_WallysDadArrives:: @ 8204F13
msgbox PetalburgCity_Gym_Text_LetMeBorrowPlayer, MSGBOX_DEFAULT
closemessage
setflag FLAG_DONT_TRANSITION_MUSIC
- playbgm MUS_FOLLOW_ME, 0
+ playbgm MUS_FOLLOW_ME, FALSE
compare VAR_0x8008, 1
call_if_eq PetalburgCity_Gym_EventScript_ExitGymWithWallysDadNorth
compare VAR_0x8008, 2
diff --git a/data/maps/PetalburgWoods/scripts.inc b/data/maps/PetalburgWoods/scripts.inc
index dbdb66b0b..1f1b2edcb 100644
--- a/data/maps/PetalburgWoods/scripts.inc
+++ b/data/maps/PetalburgWoods/scripts.inc
@@ -11,7 +11,7 @@ PetalburgWoods_EventScript_DevonResearcherLeft:: @ 822DFD7
waitmovement 0
msgbox PetalburgWoods_Text_HaveYouSeenShroomish, MSGBOX_DEFAULT
closemessage
- playbgm MUS_ENCOUNTER_AQUA, 0
+ playbgm MUS_ENCOUNTER_AQUA, FALSE
applymovement LOCALID_GRUNT, PetalburgWoods_Movement_AquaEntrance
waitmovement 0
msgbox PetalburgWoods_Text_IWasGoingToAmbushYou, MSGBOX_DEFAULT
@@ -48,7 +48,7 @@ PetalburgWoods_EventScript_DevonResearcherRight:: @ 822E079
waitmovement 0
msgbox PetalburgWoods_Text_HaveYouSeenShroomish, MSGBOX_DEFAULT
closemessage
- playbgm MUS_ENCOUNTER_AQUA, 0
+ playbgm MUS_ENCOUNTER_AQUA, FALSE
applymovement LOCALID_GRUNT, PetalburgWoods_Movement_AquaEntrance
waitmovement 0
msgbox PetalburgWoods_Text_IWasGoingToAmbushYou, MSGBOX_DEFAULT
diff --git a/data/maps/Route101/scripts.inc b/data/maps/Route101/scripts.inc
index 66ce4abc8..b93226147 100644
--- a/data/maps/Route101/scripts.inc
+++ b/data/maps/Route101/scripts.inc
@@ -21,7 +21,7 @@ Route101_EventScript_HideMapNamePopup:: @ 81EBCD5
Route101_EventScript_StartBirchRescue:: @ 81EBCDE
lockall
- playbgm MUS_HELP, 1
+ playbgm MUS_HELP, TRUE
msgbox Route101_Text_HelpMe, MSGBOX_DEFAULT
closemessage
setobjectxy LOCALID_BIRCH, 0, 15
diff --git a/data/maps/Route103/scripts.inc b/data/maps/Route103/scripts.inc
index 965b5ff5c..b096069e7 100644
--- a/data/maps/Route103/scripts.inc
+++ b/data/maps/Route103/scripts.inc
@@ -31,7 +31,7 @@ Route103_EventScript_Rival:: @ 81EC3C1
Route103_EventScript_RivalMay:: @ 81EC3DA
msgbox Route103_Text_MayRoute103Pokemon, MSGBOX_DEFAULT
closemessage
- playbgm MUS_ENCOUNTER_MAY, 1
+ playbgm MUS_ENCOUNTER_MAY, TRUE
applymovement LOCALID_RIVAL, Common_Movement_FacePlayer
waitmovement 0
applymovement LOCALID_RIVAL, Common_Movement_ExclamationMark
@@ -48,7 +48,7 @@ Route103_EventScript_RivalMay:: @ 81EC3DA
Route103_EventScript_RivalBrendan:: @ 81EC434
msgbox Route103_Text_BrendanRoute103Pokemon, MSGBOX_DEFAULT
closemessage
- playbgm MUS_ENCOUNTER_BRENDAN, 1
+ playbgm MUS_ENCOUNTER_BRENDAN, TRUE
applymovement LOCALID_RIVAL, Common_Movement_FacePlayer
waitmovement 0
applymovement LOCALID_RIVAL, Common_Movement_ExclamationMark
diff --git a/data/maps/Route104/scripts.inc b/data/maps/Route104/scripts.inc
index d1faca53a..cb840d9b3 100644
--- a/data/maps/Route104/scripts.inc
+++ b/data/maps/Route104/scripts.inc
@@ -84,11 +84,11 @@ Route104_EventScript_PlayRivalMusic:: @ 81ECD11
return
Route104_EventScript_PlayMayMusic:: @ 81ECD29
- playbgm MUS_ENCOUNTER_MAY, 1
+ playbgm MUS_ENCOUNTER_MAY, TRUE
return
Route104_EventScript_PlayBrendanMusic:: @ 81ECD2E
- playbgm MUS_ENCOUNTER_BRENDAN, 1
+ playbgm MUS_ENCOUNTER_BRENDAN, TRUE
return
Route104_EventScript_RivalEncounter:: @ 81ECD33
diff --git a/data/maps/Route110/scripts.inc b/data/maps/Route110/scripts.inc
index 50f3d1f48..f7be3fb9e 100644
--- a/data/maps/Route110/scripts.inc
+++ b/data/maps/Route110/scripts.inc
@@ -410,11 +410,11 @@ Route110_EventScript_RivalScene:: @ 81EF76E
end
Route110_EventScript_PlayMayMusic:: @ 81EF7E1
- playbgm MUS_ENCOUNTER_MAY, 1
+ playbgm MUS_ENCOUNTER_MAY, TRUE
return
Route110_EventScript_PlayBrendanMusic:: @ 81EF7E6
- playbgm MUS_ENCOUNTER_BRENDAN, 1
+ playbgm MUS_ENCOUNTER_BRENDAN, TRUE
return
Route110_EventScript_MayBattle:: @ 81EF7EB
diff --git a/data/maps/Route119/scripts.inc b/data/maps/Route119/scripts.inc
index 734934d17..37da701a0 100644
--- a/data/maps/Route119/scripts.inc
+++ b/data/maps/Route119/scripts.inc
@@ -74,11 +74,11 @@ Route119_EventScript_RivalEncounter:: @ 81F4488
end
Route119_EventScript_PlayMayMusic:: @ 81F4501
- playbgm MUS_ENCOUNTER_MAY, 1
+ playbgm MUS_ENCOUNTER_MAY, TRUE
return
Route119_EventScript_PlayBrendanMusic:: @ 81F4506
- playbgm MUS_ENCOUNTER_BRENDAN, 1
+ playbgm MUS_ENCOUNTER_BRENDAN, TRUE
return
Route119_EventScript_BattleMay:: @ 81F450B
diff --git a/data/maps/Route121/scripts.inc b/data/maps/Route121/scripts.inc
index fdc191ea8..6dc93cf6b 100644
--- a/data/maps/Route121/scripts.inc
+++ b/data/maps/Route121/scripts.inc
@@ -19,7 +19,7 @@ Route121_EventScript_SafariZoneSign:: @ 81F5E0F
Route121_EventScript_AquaGruntsMoveOut:: @ 81F5E18
lockall
- playbgm MUS_ENCOUNTER_AQUA, 0
+ playbgm MUS_ENCOUNTER_AQUA, FALSE
applymovement LOCALID_GRUNT_2, Common_Movement_WalkInPlaceRight
waitmovement 0
msgbox Route121_Text_OkayMoveOutToMtPyre, MSGBOX_DEFAULT
diff --git a/data/maps/RustboroCity/scripts.inc b/data/maps/RustboroCity/scripts.inc
index 7b1f4a3d8..05bd25247 100644
--- a/data/maps/RustboroCity/scripts.inc
+++ b/data/maps/RustboroCity/scripts.inc
@@ -294,7 +294,7 @@ RustboroCity_EventScript_StolenGoodsTrigger4:: @ 81E09B6
RustboroCity_EventScript_StolenGoodsScene:: @ 81E09CD
msgbox RustboroCity_Text_OutOfTheWay, MSGBOX_DEFAULT
closemessage
- playbgm MUS_ENCOUNTER_AQUA, 0
+ playbgm MUS_ENCOUNTER_AQUA, FALSE
addobject LOCALID_GRUNT
addobject LOCALID_DEVON_EMPLOYEE
applymovement LOCALID_GRUNT, RustboroCity_Movement_GruntEscape
@@ -706,11 +706,11 @@ RustboroCity_EventScript_PlayRivalMusic:: @ 81E0DD1
return
RustboroCity_EventScript_PlayMayMusic:: @ 81E0DE9
- playbgm MUS_ENCOUNTER_MAY, 1
+ playbgm MUS_ENCOUNTER_MAY, TRUE
return
RustboroCity_EventScript_PlayBrendanMusic:: @ 81E0DEE
- playbgm MUS_ENCOUNTER_BRENDAN, 1
+ playbgm MUS_ENCOUNTER_BRENDAN, TRUE
return
RustboroCity_EventScript_RivalTrigger0:: @ 81E0DF3
diff --git a/data/maps/RustboroCity_DevonCorp_3F/scripts.inc b/data/maps/RustboroCity_DevonCorp_3F/scripts.inc
index 34a31c692..9d4c69cd9 100644
--- a/data/maps/RustboroCity_DevonCorp_3F/scripts.inc
+++ b/data/maps/RustboroCity_DevonCorp_3F/scripts.inc
@@ -39,7 +39,7 @@ RustboroCity_DevonCorp_3F_EventScript_MeetPresident:: @ 821246E
waitmovement 0
msgbox RustboroCity_DevonCorp_3F_Text_WordWithPresidentComeWithMe, MSGBOX_DEFAULT
closemessage
- playbgm MUS_FOLLOW_ME, 0
+ playbgm MUS_FOLLOW_ME, FALSE
applymovement LOCALID_DEVON_EMPLOYEE, RustboroCity_DevonCorp_3F_Movement_LeadPlayerToPresident
applymovement OBJ_EVENT_ID_PLAYER, RustboroCity_DevonCorp_3F_Movement_PlayerFollowToPresident
waitmovement 0
diff --git a/data/maps/RusturfTunnel/scripts.inc b/data/maps/RusturfTunnel/scripts.inc
index 17a229ab5..75f5820e0 100644
--- a/data/maps/RusturfTunnel/scripts.inc
+++ b/data/maps/RusturfTunnel/scripts.inc
@@ -316,7 +316,7 @@ RusturfTunnel_EventScript_Peeko:: @ 822D0AF
RusturfTunnel_EventScript_Grunt:: @ 822D0C2
lock
faceplayer
- playbgm MUS_ENCOUNTER_AQUA, 0
+ playbgm MUS_ENCOUNTER_AQUA, FALSE
msgbox RusturfTunnel_Text_GruntIntro, MSGBOX_DEFAULT
trainerbattle_no_intro TRAINER_GRUNT_RUSTURF_TUNNEL, RusturfTunnel_Text_GruntDefeat
msgbox RusturfTunnel_Text_GruntTakePackage, MSGBOX_DEFAULT
diff --git a/data/maps/SeafloorCavern_Room9/scripts.inc b/data/maps/SeafloorCavern_Room9/scripts.inc
index 53386f33c..06ae0d6fe 100644
--- a/data/maps/SeafloorCavern_Room9/scripts.inc
+++ b/data/maps/SeafloorCavern_Room9/scripts.inc
@@ -18,7 +18,7 @@ SeafloorCavern_Room9_EventScript_ArchieAwakenKyogre:: @ 8234DC9
waitmovement 0
applymovement OBJ_EVENT_ID_PLAYER, SeafloorCavern_Room9_Movement_Delay32
waitmovement 0
- playbgm MUS_ENCOUNTER_AQUA, 0
+ playbgm MUS_ENCOUNTER_AQUA, FALSE
msgbox SeafloorCavern_Room9_Text_ArchieHoldItRightThere, MSGBOX_DEFAULT
closemessage
addobject VAR_0x8004
diff --git a/data/maps/SlateportCity/scripts.inc b/data/maps/SlateportCity/scripts.inc
index 983ce9796..ceb2e862a 100644
--- a/data/maps/SlateportCity/scripts.inc
+++ b/data/maps/SlateportCity/scripts.inc
@@ -603,7 +603,7 @@ SlateportCity_EventScript_CaptStern:: @ 81DD1F8
applymovement LOCALID_CAPT_STERN, Common_Movement_WalkInPlaceFastestUp
waitmovement 0
msgbox SlateportCity_Text_OhPlayerWeMadeDiscovery, MSGBOX_DEFAULT
- playbgm MUS_ENCOUNTER_AQUA, 0
+ playbgm MUS_ENCOUNTER_AQUA, FALSE
msgbox SlateportCity_Text_AquaWillAssumeControlOfSubmarine, MSGBOX_DEFAULT
applymovement LOCALID_COOK, Common_Movement_WalkInPlaceFastestLeft
applymovement LOCALID_FAT_MAN, Common_Movement_WalkInPlaceFastestLeft
diff --git a/data/maps/SlateportCity_OceanicMuseum_2F/scripts.inc b/data/maps/SlateportCity_OceanicMuseum_2F/scripts.inc
index bba75dbd1..782e702f6 100644
--- a/data/maps/SlateportCity_OceanicMuseum_2F/scripts.inc
+++ b/data/maps/SlateportCity_OceanicMuseum_2F/scripts.inc
@@ -11,7 +11,7 @@ SlateportCity_OceanicMuseum_2F_EventScript_CaptStern:: @ 820BB00
faceplayer
msgbox SlateportCity_OceanicMuseum_2F_Text_ThankYouForTheParts, MSGBOX_DEFAULT
closemessage
- playbgm MUS_ENCOUNTER_AQUA, 1
+ playbgm MUS_ENCOUNTER_AQUA, TRUE
addobject LOCALID_GRUNT_1
applymovement LOCALID_GRUNT_1, SlateportCity_OceanicMuseum_2F_Movement_FirstGruntEnter
waitmovement 0
diff --git a/data/maps/map_groups.json b/data/maps/map_groups.json
index 4268abbef..ebef431b3 100644
--- a/data/maps/map_groups.json
+++ b/data/maps/map_groups.json
@@ -1,41 +1,41 @@
{
"group_order": [
- "gMapGroup0",
- "gMapGroup1",
- "gMapGroup2",
- "gMapGroup3",
- "gMapGroup4",
- "gMapGroup5",
- "gMapGroup6",
- "gMapGroup7",
- "gMapGroup8",
- "gMapGroup9",
- "gMapGroup10",
- "gMapGroup11",
- "gMapGroup12",
- "gMapGroup13",
- "gMapGroup14",
- "gMapGroup15",
- "gMapGroup16",
- "gMapGroup17",
- "gMapGroup18",
- "gMapGroup19",
- "gMapGroup20",
- "gMapGroup21",
- "gMapGroup22",
- "gMapGroup23",
- "gMapGroup24",
- "gMapGroup25",
- "gMapGroup26",
- "gMapGroup27",
- "gMapGroup28",
- "gMapGroup29",
- "gMapGroup30",
- "gMapGroup31",
- "gMapGroup32",
- "gMapGroup33"
- ],
- "gMapGroup0": [
+ "gMapGroup_TownsAndRoutes",
+ "gMapGroup_IndoorLittleroot",
+ "gMapGroup_IndoorOldale",
+ "gMapGroup_IndoorDewford",
+ "gMapGroup_IndoorLavaridge",
+ "gMapGroup_IndoorFallarbor",
+ "gMapGroup_IndoorVerdanturf",
+ "gMapGroup_IndoorPacifidlog",
+ "gMapGroup_IndoorPetalburg",
+ "gMapGroup_IndoorSlateport",
+ "gMapGroup_IndoorMauville",
+ "gMapGroup_IndoorRustboro",
+ "gMapGroup_IndoorFortree",
+ "gMapGroup_IndoorLilycove",
+ "gMapGroup_IndoorMossdeep",
+ "gMapGroup_IndoorSootopolis",
+ "gMapGroup_IndoorEverGrande",
+ "gMapGroup_IndoorRoute104",
+ "gMapGroup_IndoorRoute111",
+ "gMapGroup_IndoorRoute112",
+ "gMapGroup_IndoorRoute114",
+ "gMapGroup_IndoorRoute116",
+ "gMapGroup_IndoorRoute117",
+ "gMapGroup_IndoorRoute121",
+ "gMapGroup_Dungeons",
+ "gMapGroup_IndoorDynamic",
+ "gMapGroup_SpecialArea",
+ "gMapGroup_IndoorRoute104Prototype",
+ "gMapGroup_IndoorRoute109",
+ "gMapGroup_IndoorRoute110",
+ "gMapGroup_IndoorRoute113",
+ "gMapGroup_IndoorRoute123",
+ "gMapGroup_IndoorRoute119",
+ "gMapGroup_IndoorRoute124"
+ ],
+ "gMapGroup_TownsAndRoutes": [
"PetalburgCity",
"SlateportCity",
"MauvilleCity",
@@ -94,21 +94,21 @@
"Underwater_Route105",
"Underwater_Route125"
],
- "gMapGroup1": [
+ "gMapGroup_IndoorLittleroot": [
"LittlerootTown_BrendansHouse_1F",
"LittlerootTown_BrendansHouse_2F",
"LittlerootTown_MaysHouse_1F",
"LittlerootTown_MaysHouse_2F",
"LittlerootTown_ProfessorBirchsLab"
],
- "gMapGroup2": [
+ "gMapGroup_IndoorOldale": [
"OldaleTown_House1",
"OldaleTown_House2",
"OldaleTown_PokemonCenter_1F",
"OldaleTown_PokemonCenter_2F",
"OldaleTown_Mart"
],
- "gMapGroup3": [
+ "gMapGroup_IndoorDewford": [
"DewfordTown_House1",
"DewfordTown_PokemonCenter_1F",
"DewfordTown_PokemonCenter_2F",
@@ -116,7 +116,7 @@
"DewfordTown_Hall",
"DewfordTown_House2"
],
- "gMapGroup4": [
+ "gMapGroup_IndoorLavaridge": [
"LavaridgeTown_HerbShop",
"LavaridgeTown_Gym_1F",
"LavaridgeTown_Gym_B1F",
@@ -125,7 +125,7 @@
"LavaridgeTown_PokemonCenter_1F",
"LavaridgeTown_PokemonCenter_2F"
],
- "gMapGroup5": [
+ "gMapGroup_IndoorFallarbor": [
"FallarborTown_Mart",
"FallarborTown_BattleTentLobby",
"FallarborTown_BattleTentCorridor",
@@ -135,7 +135,7 @@
"FallarborTown_CozmosHouse",
"FallarborTown_MoveRelearnersHouse"
],
- "gMapGroup6": [
+ "gMapGroup_IndoorVerdanturf": [
"VerdanturfTown_BattleTentLobby",
"VerdanturfTown_BattleTentCorridor",
"VerdanturfTown_BattleTentBattleRoom",
@@ -146,7 +146,7 @@
"VerdanturfTown_FriendshipRatersHouse",
"VerdanturfTown_House"
],
- "gMapGroup7": [
+ "gMapGroup_IndoorPacifidlog": [
"PacifidlogTown_PokemonCenter_1F",
"PacifidlogTown_PokemonCenter_2F",
"PacifidlogTown_House1",
@@ -155,7 +155,7 @@
"PacifidlogTown_House4",
"PacifidlogTown_House5"
],
- "gMapGroup8": [
+ "gMapGroup_IndoorPetalburg": [
"PetalburgCity_WallysHouse",
"PetalburgCity_Gym",
"PetalburgCity_House1",
@@ -164,7 +164,7 @@
"PetalburgCity_PokemonCenter_2F",
"PetalburgCity_Mart"
],
- "gMapGroup9": [
+ "gMapGroup_IndoorSlateport": [
"SlateportCity_SternsShipyard_1F",
"SlateportCity_SternsShipyard_2F",
"SlateportCity_BattleTentLobby",
@@ -180,7 +180,7 @@
"SlateportCity_PokemonCenter_2F",
"SlateportCity_Mart"
],
- "gMapGroup10": [
+ "gMapGroup_IndoorMauville": [
"MauvilleCity_Gym",
"MauvilleCity_BikeShop",
"MauvilleCity_House1",
@@ -190,7 +190,7 @@
"MauvilleCity_PokemonCenter_2F",
"MauvilleCity_Mart"
],
- "gMapGroup11": [
+ "gMapGroup_IndoorRustboro": [
"RustboroCity_DevonCorp_1F",
"RustboroCity_DevonCorp_2F",
"RustboroCity_DevonCorp_3F",
@@ -209,7 +209,7 @@
"RustboroCity_Flat2_3F",
"RustboroCity_House3"
],
- "gMapGroup12": [
+ "gMapGroup_IndoorFortree": [
"FortreeCity_House1",
"FortreeCity_Gym",
"FortreeCity_PokemonCenter_1F",
@@ -221,7 +221,7 @@
"FortreeCity_House5",
"FortreeCity_DecorationShop"
],
- "gMapGroup13": [
+ "gMapGroup_IndoorLilycove": [
"LilycoveCity_CoveLilyMotel_1F",
"LilycoveCity_CoveLilyMotel_2F",
"LilycoveCity_LilycoveMuseum_1F",
@@ -246,7 +246,7 @@
"LilycoveCity_DepartmentStoreRooftop",
"LilycoveCity_DepartmentStoreElevator"
],
- "gMapGroup14": [
+ "gMapGroup_IndoorMossdeep": [
"MossdeepCity_Gym",
"MossdeepCity_House1",
"MossdeepCity_House2",
@@ -261,7 +261,7 @@
"MossdeepCity_GameCorner_1F",
"MossdeepCity_GameCorner_B1F"
],
- "gMapGroup15": [
+ "gMapGroup_IndoorSootopolis": [
"SootopolisCity_Gym_1F",
"SootopolisCity_Gym_B1F",
"SootopolisCity_PokemonCenter_1F",
@@ -278,7 +278,7 @@
"SootopolisCity_MysteryEventsHouse_1F",
"SootopolisCity_MysteryEventsHouse_B1F"
],
- "gMapGroup16": [
+ "gMapGroup_IndoorEverGrande": [
"EverGrandeCity_SidneysRoom",
"EverGrandeCity_PhoebesRoom",
"EverGrandeCity_GlaciasRoom",
@@ -295,33 +295,33 @@
"EverGrandeCity_PokemonCenter_2F",
"EverGrandeCity_PokemonLeague_2F"
],
- "gMapGroup17": [
+ "gMapGroup_IndoorRoute104": [
"Route104_MrBrineysHouse",
"Route104_PrettyPetalFlowerShop"
],
- "gMapGroup18": [
+ "gMapGroup_IndoorRoute111": [
"Route111_WinstrateFamilysHouse",
"Route111_OldLadysRestStop"
],
- "gMapGroup19": [
+ "gMapGroup_IndoorRoute112": [
"Route112_CableCarStation",
"MtChimney_CableCarStation"
],
- "gMapGroup20": [
+ "gMapGroup_IndoorRoute114": [
"Route114_FossilManiacsHouse",
"Route114_FossilManiacsTunnel",
"Route114_LanettesHouse"
],
- "gMapGroup21": [
+ "gMapGroup_IndoorRoute116": [
"Route116_TunnelersRestHouse"
],
- "gMapGroup22": [
+ "gMapGroup_IndoorRoute117": [
"Route117_PokemonDayCare"
],
- "gMapGroup23": [
+ "gMapGroup_IndoorRoute121": [
"Route121_SafariZoneEntrance"
],
- "gMapGroup24": [
+ "gMapGroup_Dungeons": [
"MeteorFalls_1F_1R",
"MeteorFalls_1F_2R",
"MeteorFalls_B1F_1R",
@@ -431,7 +431,7 @@
"AlteringCave",
"MeteorFalls_StevensCave"
],
- "gMapGroup25": [
+ "gMapGroup_IndoorDynamic": [
"SecretBase_RedCave1",
"SecretBase_BrownCave1",
"SecretBase_BlueCave1",
@@ -494,7 +494,7 @@
"BattlePyramidSquare16",
"UnionRoom"
],
- "gMapGroup26": [
+ "gMapGroup_SpecialArea": [
"SafariZone_Northwest",
"SafariZone_North",
"SafariZone_Southwest",
@@ -585,14 +585,14 @@
"NavelRock_Bottom",
"TrainerHill_Elevator"
],
- "gMapGroup27": [
+ "gMapGroup_IndoorRoute104Prototype": [
"Route104_Prototype",
"Route104_PrototypePrettyPetalFlowerShop"
],
- "gMapGroup28": [
+ "gMapGroup_IndoorRoute109": [
"Route109_SeashoreHouse"
],
- "gMapGroup29": [
+ "gMapGroup_IndoorRoute110": [
"Route110_TrickHouseEntrance",
"Route110_TrickHouseEnd",
"Route110_TrickHouseCorridor",
@@ -607,18 +607,18 @@
"Route110_SeasideCyclingRoadNorthEntrance",
"Route110_SeasideCyclingRoadSouthEntrance"
],
- "gMapGroup30": [
+ "gMapGroup_IndoorRoute113": [
"Route113_GlassWorkshop"
],
- "gMapGroup31": [
+ "gMapGroup_IndoorRoute123": [
"Route123_BerryMastersHouse"
],
- "gMapGroup32": [
+ "gMapGroup_IndoorRoute119": [
"Route119_WeatherInstitute_1F",
"Route119_WeatherInstitute_2F",
"Route119_House"
],
- "gMapGroup33": [
+ "gMapGroup_IndoorRoute124": [
"Route124_DivingTreasureHuntersHouse"
],
"connections_include_order": [
diff --git a/data/scripts/contest_hall.inc b/data/scripts/contest_hall.inc
index 51be0027c..db43dfdd0 100644
--- a/data/scripts/contest_hall.inc
+++ b/data/scripts/contest_hall.inc
@@ -916,7 +916,7 @@ ContestHall_EventScript_ContestResults:: @ 827A8A5
setvar VAR_TEMP_9, 1
showcontestresults
setvar VAR_TEMP_9, 0
- playbgm MUS_CONTEST_WINNER, 0
+ playbgm MUS_CONTEST_WINNER, FALSE
return
ContestHall_EventScript_ThatsItForJudging:: @ 827A8FB
diff --git a/data/scripts/item_ball_scripts.inc b/data/scripts/item_ball_scripts.inc
index 82633f77c..f9228134c 100644
--- a/data/scripts/item_ball_scripts.inc
+++ b/data/scripts/item_ball_scripts.inc
@@ -634,7 +634,7 @@ MagmaHideout_1F_EventScript_ItemRareCandy:: @ 82914DE
finditem ITEM_RARE_CANDY
end
-MagmaHideout_2F_2R_EventScript_MaxElixir:: @ 82914EB
+MagmaHideout_2F_2R_EventScript_ItemMaxElixir:: @ 82914EB
finditem ITEM_MAX_ELIXIR
end
@@ -650,7 +650,7 @@ MagmaHideout_3F_2R_EventScript_ItemPPMax:: @ 8291512
finditem ITEM_PP_MAX
end
-MagmaHideout_4F_EventScript_MaxRevive:: @ 829151F
+MagmaHideout_4F_EventScript_ItemMaxRevive:: @ 829151F
finditem ITEM_MAX_REVIVE
end
diff --git a/data/scripts/players_house.inc b/data/scripts/players_house.inc
index 03b8eaf99..427355332 100644
--- a/data/scripts/players_house.inc
+++ b/data/scripts/players_house.inc
@@ -159,7 +159,7 @@ PlayersHouse_1F_EventScript_PetalburgGymReportMale:: @ 829286D
call PlayersHouse_1F_EventScript_MomNoticeGymBroadcast
applymovement OBJ_EVENT_ID_PLAYER, PlayersHouse_1F_Movement_PlayerApproachTVForGymMale
waitmovement 0
- playbgm MUS_ENCOUNTER_INTERVIEWER, 0
+ playbgm MUS_ENCOUNTER_INTERVIEWER, FALSE
msgbox PlayersHouse_1F_Text_MaybeDadWillBeOn, MSGBOX_DEFAULT
closemessage
applymovement VAR_0x8005, PlayersHouse_1F_Movement_MomMakeRoomToSeeTVMale
@@ -184,7 +184,7 @@ PlayersHouse_1F_EventScript_PetalburgGymReportFemale:: @ 82928DC
call PlayersHouse_1F_EventScript_MomNoticeGymBroadcast
applymovement OBJ_EVENT_ID_PLAYER, PlayersHouse_1F_Movement_PlayerApproachTVForGymFemale
waitmovement 0
- playbgm MUS_ENCOUNTER_INTERVIEWER, 0
+ playbgm MUS_ENCOUNTER_INTERVIEWER, FALSE
msgbox PlayersHouse_1F_Text_MaybeDadWillBeOn, MSGBOX_DEFAULT
closemessage
applymovement VAR_0x8005, PlayersHouse_1F_Movement_MomMakeRoomToSeeTVFemale
diff --git a/data/text/berry_descriptions.inc b/data/text/berry_descriptions.inc
deleted file mode 100644
index e5917ca32..000000000
--- a/data/text/berry_descriptions.inc
+++ /dev/null
@@ -1,258 +0,0 @@
-gBerryDescriptionPart1_Cheri:: @ 8589AE4
- .string "Blooms with delicate pretty flowers.$"
-
-gBerryDescriptionPart2_Cheri:: @ 8589B09
- .string "The bright red BERRY is very spicy.$"
-
-gBerryDescriptionPart1_Chesto:: @ 8589B2D
- .string "The BERRY's thick skin and fruit are$"
-
-gBerryDescriptionPart2_Chesto:: @ 8589B52
- .string "very tough. It is dry-tasting all over.$"
-
-gBerryDescriptionPart1_Pecha:: @ 8589B7A
- .string "Very sweet and delicious.$"
-
-gBerryDescriptionPart2_Pecha:: @ 8589B94
- .string "Also very tender - handle with care.$"
-
-gBerryDescriptionPart1_Rawst:: @ 8589BB9
- .string "If the leaves grow long and curly,$"
-
-gBerryDescriptionPart2_Rawst:: @ 8589BDC
- .string "the BERRY seems to grow very bitter.$"
-
-gBerryDescriptionPart1_Aspear:: @ 8589C01
- .string "The hard BERRY is dense with a rich$"
-
-gBerryDescriptionPart2_Aspear:: @ 8589C25
- .string "juice. It is quite sour.$"
-
-gBerryDescriptionPart1_Leppa:: @ 8589C3E
- .string "Grows slower than CHERI and others.$"
-
-gBerryDescriptionPart2_Leppa:: @ 8589C62
- .string "The smaller the BERRY, the tastier.$"
-
-gBerryDescriptionPart1_Oran:: @ 8589C86
- .string "A peculiar BERRY with a mix of flavors.$"
-
-gBerryDescriptionPart2_Oran:: @ 8589CAE
- .string "BERRIES grow in half a day.$"
-
-gBerryDescriptionPart1_Persim:: @ 8589CCA
- .string "Loves sunlight. The BERRY's color$"
-
-gBerryDescriptionPart2_Persim:: @ 8589CEC
- .string "grows vivid when exposed to the sun.$"
-
-gBerryDescriptionPart1_Lum:: @ 8589D11
- .string "Slow to grow. If raised with loving$"
-
-gBerryDescriptionPart2_Lum:: @ 8589D35
- .string "care, it may grow two BERRIES.$"
-
-gBerryDescriptionPart1_Sitrus:: @ 8589D54
- .string "Closely related to ORAN. The large$"
-
-gBerryDescriptionPart2_Sitrus:: @ 8589D77
- .string "BERRY has a well-rounded flavor.$"
-
-gBerryDescriptionPart1_Figy:: @ 8589D98
- .string "The BERRY, which looks chewed up,$"
-
-gBerryDescriptionPart2_Figy:: @ 8589DBA
- .string "brims with spicy substances.$"
-
-gBerryDescriptionPart1_Wiki:: @ 8589DD7
- .string "The BERRY is said to have grown lumpy$"
-
-gBerryDescriptionPart2_Wiki:: @ 8589DFD
- .string "to help POKéMON grip it.$"
-
-gBerryDescriptionPart1_Mago:: @ 8589E16
- .string "The BERRY turns curvy as it grows.$"
-
-gBerryDescriptionPart2_Mago:: @ 8589E39
- .string "The curvier, the sweeter and tastier.$"
-
-gBerryDescriptionPart1_Aguav:: @ 8589E5F
- .string "The flower is dainty. It is rare in its$"
-
-gBerryDescriptionPart2_Aguav:: @ 8589E87
- .string "ability to grow without light.$"
-
-gBerryDescriptionPart1_Iapapa:: @ 8589EA6
- .string "The BERRY is very big and sour.$"
-
-gBerryDescriptionPart2_Iapapa:: @ 8589EC6
- .string "It takes at least a day to grow.$"
-
-gBerryDescriptionPart1_Razz:: @ 8589EE7
- .string "The red BERRY tastes slightly spicy.$"
-
-gBerryDescriptionPart2_Razz:: @ 8589F0C
- .string "It grows quickly in just four hours.$"
-
-gBerryDescriptionPart1_Bluk:: @ 8589F31
- .string "The BERRY is blue on the outside, but$"
-
-gBerryDescriptionPart2_Bluk:: @ 8589F57
- .string "it blackens the mouth when eaten.$"
-
-gBerryDescriptionPart1_Nanab:: @ 8589F79
- .string "This BERRY was the seventh$"
-
-gBerryDescriptionPart2_Nanab:: @ 8589F94
- .string "discovered in the world. It is sweet.$"
-
-gBerryDescriptionPart1_Wepear:: @ 8589FBA
- .string "The flower is small and white. It has a$"
-
-gBerryDescriptionPart2_Wepear:: @ 8589FE2
- .string "delicate balance of bitter and sour.$"
-
-gBerryDescriptionPart1_Pinap:: @ 858A007
- .string "Weak against wind and cold.$"
-
-gBerryDescriptionPart2_Pinap:: @ 858A023
- .string "The fruit is spicy and the skin, sour.$"
-
-gBerryDescriptionPart1_Pomeg:: @ 858A04A
- .string "However much it is watered,$"
-
-gBerryDescriptionPart2_Pomeg:: @ 858A066
- .string "it only grows up to six BERRIES.$"
-
-gBerryDescriptionPart1_Kelpsy:: @ 858A087
- .string "A rare variety shaped like a root.$"
-
-gBerryDescriptionPart2_Kelpsy:: @ 858A0AA
- .string "Grows a very large flower.$"
-
-gBerryDescriptionPart1_Qualot:: @ 858A0C5
- .string "Loves water. Grows strong even in$"
-
-gBerryDescriptionPart2_Qualot:: @ 858A0E7
- .string "locations with constant rainfall.$"
-
-gBerryDescriptionPart1_Hondew:: @ 858A109
- .string "A BERRY that is very valuable and$"
-
-gBerryDescriptionPart2_Hondew:: @ 858A12B
- .string "rarely seen. It is very delicious.$"
-
-gBerryDescriptionPart1_Grepa:: @ 858A14E
- .string "Despite its tenderness and round$"
-
-gBerryDescriptionPart2_Grepa:: @ 858A16F
- .string "shape, the BERRY is unimaginably sour.$"
-
-gBerryDescriptionPart1_Tamato:: @ 858A196
- .string "The BERRY is lip-bendingly spicy.$"
-
-gBerryDescriptionPart2_Tamato:: @ 858A1B8
- .string "It takes time to grow.$"
-
-gBerryDescriptionPart1_Cornn:: @ 858A1CF
- .string "A BERRY from an ancient era. May not$"
-
-gBerryDescriptionPart2_Cornn:: @ 858A1F4
- .string "grow unless planted in quantity.$"
-
-gBerryDescriptionPart1_Magost:: @ 858A215
- .string "A BERRY that is widely said to have$"
-
-gBerryDescriptionPart2_Magost:: @ 858A239
- .string "a finely balanced flavor.$"
-
-gBerryDescriptionPart1_Rabuta:: @ 858A253
- .string "A rare variety that is overgrown with$"
-
-gBerryDescriptionPart2_Rabuta:: @ 858A279
- .string "hair. It is quite bitter.$"
-
-gBerryDescriptionPart1_Nomel:: @ 858A293
- .string "Quite sour. Just one bite makes it$"
-
-gBerryDescriptionPart2_Nomel:: @ 858A2B6
- .string "impossible to taste for three days.$"
-
-gBerryDescriptionPart1_Spelon:: @ 858A2DA
- .string "The vividly red BERRY is very spicy.$"
-
-gBerryDescriptionPart2_Spelon:: @ 858A2FF
- .string "Its warts secrete a spicy substance.$"
-
-gBerryDescriptionPart1_Pamtre:: @ 858A324
- .string "Drifts on the sea from somewhere.$"
-
-gBerryDescriptionPart2_Pamtre:: @ 858A346
- .string "It is thought to grow elsewhere.$"
-
-gBerryDescriptionPart1_Watmel:: @ 858A367
- .string "A huge BERRY, with some over 20$"
-
-gBerryDescriptionPart2_Watmel:: @ 858A387
- .string "inches discovered. Exceedingly sweet.$"
-
-gBerryDescriptionPart1_Durin:: @ 858A3AD
- .string "Bitter to even look at. It is so$"
-
-gBerryDescriptionPart2_Durin:: @ 858A3CE
- .string "bitter, no one has ever eaten it as is.$"
-
-gBerryDescriptionPart1_Belue:: @ 858A3F6
- .string "It is glossy and looks delicious, but$"
-
-gBerryDescriptionPart2_Belue:: @ 858A41C
- .string "it is awfully sour. Takes time to grow.$"
-
-gBerryDescriptionPart1_Liechi:: @ 858A444
- .string "A mysterious BERRY. It is rumored to$"
-
-gBerryDescriptionPart2_Liechi:: @ 858A469
- .string "contain the power of the sea.$"
-
-gBerryDescriptionPart1_Ganlon:: @ 858A487
- .string "A mysterious BERRY. It is rumored to$"
-
-gBerryDescriptionPart2_Ganlon:: @ 858A4AC
- .string "contain the power of the land.$"
-
-gBerryDescriptionPart1_Salac:: @ 858A4CB
- .string "A mysterious BERRY. It is rumored to$"
-
-gBerryDescriptionPart2_Salac:: @ 858A4F0
- .string "contain the power of the sky.$"
-
-gBerryDescriptionPart1_Petaya:: @ 858A50E
- .string "A mysterious BERRY. It is rumored to$"
-
-gBerryDescriptionPart2_Petaya:: @ 858A533
- .string "contain the power of all living things.$"
-
-gBerryDescriptionPart1_Apicot:: @ 858A55B
- .string "A very mystifying BERRY. No telling$"
-
-gBerryDescriptionPart2_Apicot:: @ 858A57F
- .string "what may happen or how it can be used.$"
-
-gBerryDescriptionPart1_Lansat:: @ 858A5A6
- .string "Said to be a legendary BERRY.$"
-
-gBerryDescriptionPart2_Lansat:: @ 858A5C4
- .string "Holding it supposedly brings joy.$"
-
-gBerryDescriptionPart1_Starf:: @ 858A5E6
- .string "So strong, it was abandoned at the$"
-
-gBerryDescriptionPart2_Starf:: @ 858A609
- .string "world's edge. Considered a mirage.$"
-
-gBerryDescriptionPart1_Enigma:: @ 858A62C
- .string "A completely enigmatic BERRY.$"
-
-gBerryDescriptionPart2_Enigma:: @ 858A64A
- .string "Appears to have the power of stars.$"
-
diff --git a/docs/legacy_WSL1_INSTALL.md b/docs/legacy_WSL1_INSTALL.md
new file mode 100644
index 000000000..b9840d1c8
--- /dev/null
+++ b/docs/legacy_WSL1_INSTALL.md
@@ -0,0 +1,41 @@
+### Setting up WSL1 (Legacy Portion)
+
+1. Certain packages are required to build pokeemerald. Install these packages by running the following command:
+
+ ```bash
+ sudo apt install build-essential git libpng-dev gdebi-core
+ ```
+ > Note: If the above command does not work, try the above command but replacing `apt` with `apt-get`.
+
+2. Once the packages have finished installing, download the devkitPro pacman package [here](https://github.com/devkitPro/pacman/releases). The file to download is `devkitpro-pacman.amd64.deb`.
+
+3. WSL has its own file system that's not accessible from Windows, but Windows files *are* accessible from WSL. To install the devkitPro package, you'll need to change to the **current working directory** where the package file was saved.
+
+ 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:
+
+ ```bash
+ cd /mnt/c/Users/<user>/Downloads
+ ```
+
+ > 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>/Downloads folder"`.
+ > Note 3: Windows path names are case-insensitive so adhering to capitalization isn't needed
+
+4. Once the directory has been changed to the folder containing the devkitPro pacman package, run the following commands to install devkitARM.
+
+ ```bash
+ 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.
+
+5. Run the following command to set devkitPro related environment variables (alternatively, close and re-open WSL):
+ ```bash
+ source /etc/profile.d/devkit-env.sh
+ ```
+
+Proceed to [Choosing where to store pokeemerald (WSL1) of the current INSTALL.md](/INSTALL.md#choosing-where-to-store-pokeemerald-WSL1).
diff --git a/gflib/bg.c b/gflib/bg.c
index 3c215c103..ec7c2113b 100644
--- a/gflib/bg.c
+++ b/gflib/bg.c
@@ -55,7 +55,7 @@ void ResetBgs(void)
static void SetBgModeInternal(u8 bgMode)
{
- sGpuBgConfigs.bgVisibilityAndMode &= 0xFFF8;
+ sGpuBgConfigs.bgVisibilityAndMode &= ~0x7;
sGpuBgConfigs.bgVisibilityAndMode |= bgMode;
}
@@ -66,13 +66,11 @@ u8 GetBgMode(void)
void ResetBgControlStructs(void)
{
- struct BgConfig* bgConfigs = &sGpuBgConfigs.configs[0];
- struct BgConfig zeroedConfig = sZeroedBgControlStruct;
int i;
for (i = 0; i < NUM_BACKGROUNDS; i++)
{
- bgConfigs[i] = zeroedConfig;
+ sGpuBgConfigs.configs[i] = sZeroedBgControlStruct;
}
}
@@ -175,36 +173,30 @@ u8 LoadBgVram(u8 bg, const void *src, u16 size, u16 destOffset, u8 mode)
u16 offset;
s8 cursor;
- if (!IsInvalidBg(bg) && sGpuBgConfigs.configs[bg].visible)
- {
- switch (mode)
- {
- case 0x1:
- offset = sGpuBgConfigs.configs[bg].charBaseIndex * BG_CHAR_SIZE;
- break;
- case 0x2:
- offset = sGpuBgConfigs.configs[bg].mapBaseIndex * BG_SCREEN_SIZE;
- break;
- default:
- cursor = -1;
- goto end;
- }
+ if (IsInvalidBg(bg) || !sGpuBgConfigs.configs[bg].visible)
+ return -1;
+ switch (mode)
+ {
+ case 0x1:
+ offset = sGpuBgConfigs.configs[bg].charBaseIndex * BG_CHAR_SIZE;
offset = destOffset + offset;
-
cursor = RequestDma3Copy(src, (void*)(offset + BG_VRAM), size, 0);
-
if (cursor == -1)
- {
return -1;
- }
- }
- else
- {
- return -1;
+ break;
+ case 0x2:
+ offset = sGpuBgConfigs.configs[bg].mapBaseIndex * BG_SCREEN_SIZE;
+ offset = destOffset + offset;
+ cursor = RequestDma3Copy(src, (void*)(offset + BG_VRAM), size, 0);
+ if (cursor == -1)
+ return -1;
+ break;
+ default:
+ cursor = -1;
+ break;
}
-end:
return cursor;
}
@@ -254,17 +246,17 @@ static void SetBgAffineInternal(u8 bg, s32 srcCenterX, s32 srcCenterY, s16 dispC
switch (sGpuBgConfigs.bgVisibilityAndMode & 0x7)
{
+ default:
+ case 0:
+ return;
case 1:
if (bg != 2)
return;
break;
case 2:
- if (bg < 2 || bg >= NUM_BACKGROUNDS)
+ if (bg != 2 && bg != 3)
return;
break;
- case 0:
- default:
- return;
}
src.texX = srcCenterX;
@@ -697,7 +689,7 @@ s32 ChangeBgY(u8 bg, s32 value, u8 op)
return sGpuBgConfigs2[bg].bg_y;
}
-s32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op)
+s32 ChangeBgY_ScreenOff(u8 bg, s32 value, u8 op)
{
u8 mode;
u16 temp1;
diff --git a/gflib/bg.h b/gflib/bg.h
index 3c7eee292..58fd1282c 100644
--- a/gflib/bg.h
+++ b/gflib/bg.h
@@ -59,7 +59,7 @@ u16 GetBgAttribute(u8 bg, u8 attributeId);
s32 ChangeBgX(u8 bg, s32 value, u8 op);
s32 GetBgX(u8 bg);
s32 ChangeBgY(u8 bg, s32 value, u8 op);
-s32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op);
+s32 ChangeBgY_ScreenOff(u8 bg, s32 value, u8 op);
s32 GetBgY(u8 bg);
void SetBgAffine(u8 bg, s32 srcCenterX, s32 srcCenterY, s16 dispCenterX, s16 dispCenterY, s16 scaleX, s16 scaleY, u16 rotationAngle);
u8 Unused_AdjustBgMosaic(u8 a1, u8 a2);
diff --git a/gflib/sprite.c b/gflib/sprite.c
index c66b1e47d..f97ecc712 100644
--- a/gflib/sprite.c
+++ b/gflib/sprite.c
@@ -452,6 +452,10 @@ void SortSprites(void)
// Although this doesn't result in a bug in the ROM,
// the behavior is undefined.
j--;
+#ifdef UBFIX
+ if (j == 0)
+ break;
+#endif
sprite1 = &gSprites[sSpriteOrder[j - 1]];
sprite2 = &gSprites[sSpriteOrder[j]];
@@ -661,8 +665,7 @@ void ResetOamRange(u8 a, u8 b)
for (i = a; i < b; i++)
{
- struct OamData *oamBuffer = gMain.oamBuffer;
- oamBuffer[i] = *(struct OamData *)&gDummyOamData;
+ gMain.oamBuffer[i] = *(struct OamData *)&gDummyOamData;
}
}
diff --git a/gflib/text.c b/gflib/text.c
index 445a7b1be..eb993c421 100644
--- a/gflib/text.c
+++ b/gflib/text.c
@@ -1632,8 +1632,7 @@ void DecompressGlyphFont7(u16 glyphId, bool32 isJapanese)
if (isJapanese == TRUE)
{
- int eff;
- glyphs = gFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & (eff = 0xF))); // shh, no questions, only matching now
+ glyphs = gFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId % 0x10));
DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom);
gCurGlyph.width = 8;
@@ -1761,8 +1760,7 @@ void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese)
if (isJapanese == TRUE)
{
- int eff;
- glyphs = gFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & (eff = 0xF))); // shh, no questions, only matching now
+ glyphs = gFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId % 0x10));
DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom);
gCurGlyph.width = 8;
diff --git a/include/battle_anim.h b/include/battle_anim.h
index 476480489..ad160e74d 100644
--- a/include/battle_anim.h
+++ b/include/battle_anim.h
@@ -143,7 +143,7 @@ void TranslateSpriteLinear(struct Sprite *sprite);
void AnimSpriteOnMonPos(struct Sprite *sprite);
void InitAnimLinearTranslationWithSpeedAndPos(struct Sprite *sprite);
void TranslateSpriteInCircleOverDuration(struct Sprite *sprite);
-void SetGreyscaleOrOriginalPalette(u16 palNum, bool8 restoreOriginal);
+void SetGrayscaleOrOriginalPalette(u16 palNum, bool8 restoreOriginal);
void PrepareAffineAnimInTaskData(struct Task *task, u8 spriteId, const union AffineAnimCmd *affineAnimCmds);
bool8 RunAffineAnimFromTaskData(struct Task *task);
void AnimThrowProjectile(struct Sprite *sprite);
diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h
index f22541272..c8d37aac6 100644
--- a/include/constants/battle_string_ids.h
+++ b/include/constants/battle_string_ids.h
@@ -502,7 +502,7 @@
#define B_MSG_TRANSFORMED 0
#define B_MSG_TRANSFORM_FAILED 1
-// gSubsituteUsedStringIds
+// gSubstituteUsedStringIds
#define B_MSG_SET_SUBSTITUTE 0
#define B_MSG_SUBSTITUTE_FAILED 1
diff --git a/include/constants/contest.h b/include/constants/contest.h
index 28b02e9c0..775dcbe62 100644
--- a/include/constants/contest.h
+++ b/include/constants/contest.h
@@ -4,6 +4,7 @@
#define APPLAUSE_METER_SIZE 5
#define CONTEST_NUM_APPEALS 5
#define CONTEST_LAST_APPEAL (CONTEST_NUM_APPEALS - 1)
+#define MAX_CONTEST_MOVE_HEARTS 8
#define LINK_CONTEST_FLAG_IS_LINK (1 << 0)
#define LINK_CONTEST_FLAG_IS_WIRELESS (1 << 1)
diff --git a/include/constants/map_groups.h b/include/constants/map_groups.h
index c650600e8..eaf40a525 100755
--- a/include/constants/map_groups.h
+++ b/include/constants/map_groups.h
@@ -5,7 +5,7 @@
// DO NOT MODIFY THIS FILE! It is auto-generated from data/maps/map_groups.json
//
-// Map Group 0
+// gMapGroup_TownsAndRoutes
#define MAP_PETALBURG_CITY (0 | (0 << 8))
#define MAP_SLATEPORT_CITY (1 | (0 << 8))
#define MAP_MAUVILLE_CITY (2 | (0 << 8))
@@ -64,21 +64,21 @@
#define MAP_UNDERWATER_ROUTE105 (55 | (0 << 8))
#define MAP_UNDERWATER_ROUTE125 (56 | (0 << 8))
-// Map Group 1
+// gMapGroup_IndoorLittleroot
#define MAP_LITTLEROOT_TOWN_BRENDANS_HOUSE_1F (0 | (1 << 8))
#define MAP_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F (1 | (1 << 8))
#define MAP_LITTLEROOT_TOWN_MAYS_HOUSE_1F (2 | (1 << 8))
#define MAP_LITTLEROOT_TOWN_MAYS_HOUSE_2F (3 | (1 << 8))
#define MAP_LITTLEROOT_TOWN_PROFESSOR_BIRCHS_LAB (4 | (1 << 8))
-// Map Group 2
+// gMapGroup_IndoorOldale
#define MAP_OLDALE_TOWN_HOUSE1 (0 | (2 << 8))
#define MAP_OLDALE_TOWN_HOUSE2 (1 | (2 << 8))
#define MAP_OLDALE_TOWN_POKEMON_CENTER_1F (2 | (2 << 8))
#define MAP_OLDALE_TOWN_POKEMON_CENTER_2F (3 | (2 << 8))
#define MAP_OLDALE_TOWN_MART (4 | (2 << 8))
-// Map Group 3
+// gMapGroup_IndoorDewford
#define MAP_DEWFORD_TOWN_HOUSE1 (0 | (3 << 8))
#define MAP_DEWFORD_TOWN_POKEMON_CENTER_1F (1 | (3 << 8))
#define MAP_DEWFORD_TOWN_POKEMON_CENTER_2F (2 | (3 << 8))
@@ -86,7 +86,7 @@
#define MAP_DEWFORD_TOWN_HALL (4 | (3 << 8))
#define MAP_DEWFORD_TOWN_HOUSE2 (5 | (3 << 8))
-// Map Group 4
+// gMapGroup_IndoorLavaridge
#define MAP_LAVARIDGE_TOWN_HERB_SHOP (0 | (4 << 8))
#define MAP_LAVARIDGE_TOWN_GYM_1F (1 | (4 << 8))
#define MAP_LAVARIDGE_TOWN_GYM_B1F (2 | (4 << 8))
@@ -95,7 +95,7 @@
#define MAP_LAVARIDGE_TOWN_POKEMON_CENTER_1F (5 | (4 << 8))
#define MAP_LAVARIDGE_TOWN_POKEMON_CENTER_2F (6 | (4 << 8))
-// Map Group 5
+// gMapGroup_IndoorFallarbor
#define MAP_FALLARBOR_TOWN_MART (0 | (5 << 8))
#define MAP_FALLARBOR_TOWN_BATTLE_TENT_LOBBY (1 | (5 << 8))
#define MAP_FALLARBOR_TOWN_BATTLE_TENT_CORRIDOR (2 | (5 << 8))
@@ -105,7 +105,7 @@
#define MAP_FALLARBOR_TOWN_COZMOS_HOUSE (6 | (5 << 8))
#define MAP_FALLARBOR_TOWN_MOVE_RELEARNERS_HOUSE (7 | (5 << 8))
-// Map Group 6
+// gMapGroup_IndoorVerdanturf
#define MAP_VERDANTURF_TOWN_BATTLE_TENT_LOBBY (0 | (6 << 8))
#define MAP_VERDANTURF_TOWN_BATTLE_TENT_CORRIDOR (1 | (6 << 8))
#define MAP_VERDANTURF_TOWN_BATTLE_TENT_BATTLE_ROOM (2 | (6 << 8))
@@ -116,7 +116,7 @@
#define MAP_VERDANTURF_TOWN_FRIENDSHIP_RATERS_HOUSE (7 | (6 << 8))
#define MAP_VERDANTURF_TOWN_HOUSE (8 | (6 << 8))
-// Map Group 7
+// gMapGroup_IndoorPacifidlog
#define MAP_PACIFIDLOG_TOWN_POKEMON_CENTER_1F (0 | (7 << 8))
#define MAP_PACIFIDLOG_TOWN_POKEMON_CENTER_2F (1 | (7 << 8))
#define MAP_PACIFIDLOG_TOWN_HOUSE1 (2 | (7 << 8))
@@ -125,7 +125,7 @@
#define MAP_PACIFIDLOG_TOWN_HOUSE4 (5 | (7 << 8))
#define MAP_PACIFIDLOG_TOWN_HOUSE5 (6 | (7 << 8))
-// Map Group 8
+// gMapGroup_IndoorPetalburg
#define MAP_PETALBURG_CITY_WALLYS_HOUSE (0 | (8 << 8))
#define MAP_PETALBURG_CITY_GYM (1 | (8 << 8))
#define MAP_PETALBURG_CITY_HOUSE1 (2 | (8 << 8))
@@ -134,7 +134,7 @@
#define MAP_PETALBURG_CITY_POKEMON_CENTER_2F (5 | (8 << 8))
#define MAP_PETALBURG_CITY_MART (6 | (8 << 8))
-// Map Group 9
+// gMapGroup_IndoorSlateport
#define MAP_SLATEPORT_CITY_STERNS_SHIPYARD_1F (0 | (9 << 8))
#define MAP_SLATEPORT_CITY_STERNS_SHIPYARD_2F (1 | (9 << 8))
#define MAP_SLATEPORT_CITY_BATTLE_TENT_LOBBY (2 | (9 << 8))
@@ -150,7 +150,7 @@
#define MAP_SLATEPORT_CITY_POKEMON_CENTER_2F (12 | (9 << 8))
#define MAP_SLATEPORT_CITY_MART (13 | (9 << 8))
-// Map Group 10
+// gMapGroup_IndoorMauville
#define MAP_MAUVILLE_CITY_GYM (0 | (10 << 8))
#define MAP_MAUVILLE_CITY_BIKE_SHOP (1 | (10 << 8))
#define MAP_MAUVILLE_CITY_HOUSE1 (2 | (10 << 8))
@@ -160,7 +160,7 @@
#define MAP_MAUVILLE_CITY_POKEMON_CENTER_2F (6 | (10 << 8))
#define MAP_MAUVILLE_CITY_MART (7 | (10 << 8))
-// Map Group 11
+// gMapGroup_IndoorRustboro
#define MAP_RUSTBORO_CITY_DEVON_CORP_1F (0 | (11 << 8))
#define MAP_RUSTBORO_CITY_DEVON_CORP_2F (1 | (11 << 8))
#define MAP_RUSTBORO_CITY_DEVON_CORP_3F (2 | (11 << 8))
@@ -179,7 +179,7 @@
#define MAP_RUSTBORO_CITY_FLAT2_3F (15 | (11 << 8))
#define MAP_RUSTBORO_CITY_HOUSE3 (16 | (11 << 8))
-// Map Group 12
+// gMapGroup_IndoorFortree
#define MAP_FORTREE_CITY_HOUSE1 (0 | (12 << 8))
#define MAP_FORTREE_CITY_GYM (1 | (12 << 8))
#define MAP_FORTREE_CITY_POKEMON_CENTER_1F (2 | (12 << 8))
@@ -191,7 +191,7 @@
#define MAP_FORTREE_CITY_HOUSE5 (8 | (12 << 8))
#define MAP_FORTREE_CITY_DECORATION_SHOP (9 | (12 << 8))
-// Map Group 13
+// gMapGroup_IndoorLilycove
#define MAP_LILYCOVE_CITY_COVE_LILY_MOTEL_1F (0 | (13 << 8))
#define MAP_LILYCOVE_CITY_COVE_LILY_MOTEL_2F (1 | (13 << 8))
#define MAP_LILYCOVE_CITY_LILYCOVE_MUSEUM_1F (2 | (13 << 8))
@@ -216,7 +216,7 @@
#define MAP_LILYCOVE_CITY_DEPARTMENT_STORE_ROOFTOP (21 | (13 << 8))
#define MAP_LILYCOVE_CITY_DEPARTMENT_STORE_ELEVATOR (22 | (13 << 8))
-// Map Group 14
+// gMapGroup_IndoorMossdeep
#define MAP_MOSSDEEP_CITY_GYM (0 | (14 << 8))
#define MAP_MOSSDEEP_CITY_HOUSE1 (1 | (14 << 8))
#define MAP_MOSSDEEP_CITY_HOUSE2 (2 | (14 << 8))
@@ -231,7 +231,7 @@
#define MAP_MOSSDEEP_CITY_GAME_CORNER_1F (11 | (14 << 8))
#define MAP_MOSSDEEP_CITY_GAME_CORNER_B1F (12 | (14 << 8))
-// Map Group 15
+// gMapGroup_IndoorSootopolis
#define MAP_SOOTOPOLIS_CITY_GYM_1F (0 | (15 << 8))
#define MAP_SOOTOPOLIS_CITY_GYM_B1F (1 | (15 << 8))
#define MAP_SOOTOPOLIS_CITY_POKEMON_CENTER_1F (2 | (15 << 8))
@@ -248,7 +248,7 @@
#define MAP_SOOTOPOLIS_CITY_MYSTERY_EVENTS_HOUSE_1F (13 | (15 << 8))
#define MAP_SOOTOPOLIS_CITY_MYSTERY_EVENTS_HOUSE_B1F (14 | (15 << 8))
-// Map Group 16
+// gMapGroup_IndoorEverGrande
#define MAP_EVER_GRANDE_CITY_SIDNEYS_ROOM (0 | (16 << 8))
#define MAP_EVER_GRANDE_CITY_PHOEBES_ROOM (1 | (16 << 8))
#define MAP_EVER_GRANDE_CITY_GLACIAS_ROOM (2 | (16 << 8))
@@ -265,33 +265,33 @@
#define MAP_EVER_GRANDE_CITY_POKEMON_CENTER_2F (13 | (16 << 8))
#define MAP_EVER_GRANDE_CITY_POKEMON_LEAGUE_2F (14 | (16 << 8))
-// Map Group 17
+// gMapGroup_IndoorRoute104
#define MAP_ROUTE104_MR_BRINEYS_HOUSE (0 | (17 << 8))
#define MAP_ROUTE104_PRETTY_PETAL_FLOWER_SHOP (1 | (17 << 8))
-// Map Group 18
+// gMapGroup_IndoorRoute111
#define MAP_ROUTE111_WINSTRATE_FAMILYS_HOUSE (0 | (18 << 8))
#define MAP_ROUTE111_OLD_LADYS_REST_STOP (1 | (18 << 8))
-// Map Group 19
+// gMapGroup_IndoorRoute112
#define MAP_ROUTE112_CABLE_CAR_STATION (0 | (19 << 8))
#define MAP_MT_CHIMNEY_CABLE_CAR_STATION (1 | (19 << 8))
-// Map Group 20
+// gMapGroup_IndoorRoute114
#define MAP_ROUTE114_FOSSIL_MANIACS_HOUSE (0 | (20 << 8))
#define MAP_ROUTE114_FOSSIL_MANIACS_TUNNEL (1 | (20 << 8))
#define MAP_ROUTE114_LANETTES_HOUSE (2 | (20 << 8))
-// Map Group 21
+// gMapGroup_IndoorRoute116
#define MAP_ROUTE116_TUNNELERS_REST_HOUSE (0 | (21 << 8))
-// Map Group 22
+// gMapGroup_IndoorRoute117
#define MAP_ROUTE117_POKEMON_DAY_CARE (0 | (22 << 8))
-// Map Group 23
+// gMapGroup_IndoorRoute121
#define MAP_ROUTE121_SAFARI_ZONE_ENTRANCE (0 | (23 << 8))
-// Map Group 24
+// gMapGroup_Dungeons
#define MAP_METEOR_FALLS_1F_1R (0 | (24 << 8))
#define MAP_METEOR_FALLS_1F_2R (1 | (24 << 8))
#define MAP_METEOR_FALLS_B1F_1R (2 | (24 << 8))
@@ -401,7 +401,7 @@
#define MAP_ALTERING_CAVE (106 | (24 << 8))
#define MAP_METEOR_FALLS_STEVENS_CAVE (107 | (24 << 8))
-// Map Group 25
+// gMapGroup_IndoorDynamic
#define MAP_SECRET_BASE_RED_CAVE1 (0 | (25 << 8))
#define MAP_SECRET_BASE_BROWN_CAVE1 (1 | (25 << 8))
#define MAP_SECRET_BASE_BLUE_CAVE1 (2 | (25 << 8))
@@ -464,7 +464,7 @@
#define MAP_BATTLE_PYRAMID_SQUARE16 (59 | (25 << 8))
#define MAP_UNION_ROOM (60 | (25 << 8))
-// Map Group 26
+// gMapGroup_SpecialArea
#define MAP_SAFARI_ZONE_NORTHWEST (0 | (26 << 8))
#define MAP_SAFARI_ZONE_NORTH (1 | (26 << 8))
#define MAP_SAFARI_ZONE_SOUTHWEST (2 | (26 << 8))
@@ -555,14 +555,14 @@
#define MAP_NAVEL_ROCK_BOTTOM (87 | (26 << 8))
#define MAP_TRAINER_HILL_ELEVATOR (88 | (26 << 8))
-// Map Group 27
+// gMapGroup_IndoorRoute104Prototype
#define MAP_ROUTE104_PROTOTYPE (0 | (27 << 8))
#define MAP_ROUTE104_PROTOTYPE_PRETTY_PETAL_FLOWER_SHOP (1 | (27 << 8))
-// Map Group 28
+// gMapGroup_IndoorRoute109
#define MAP_ROUTE109_SEASHORE_HOUSE (0 | (28 << 8))
-// Map Group 29
+// gMapGroup_IndoorRoute110
#define MAP_ROUTE110_TRICK_HOUSE_ENTRANCE (0 | (29 << 8))
#define MAP_ROUTE110_TRICK_HOUSE_END (1 | (29 << 8))
#define MAP_ROUTE110_TRICK_HOUSE_CORRIDOR (2 | (29 << 8))
@@ -577,18 +577,18 @@
#define MAP_ROUTE110_SEASIDE_CYCLING_ROAD_NORTH_ENTRANCE (11 | (29 << 8))
#define MAP_ROUTE110_SEASIDE_CYCLING_ROAD_SOUTH_ENTRANCE (12 | (29 << 8))
-// Map Group 30
+// gMapGroup_IndoorRoute113
#define MAP_ROUTE113_GLASS_WORKSHOP (0 | (30 << 8))
-// Map Group 31
+// gMapGroup_IndoorRoute123
#define MAP_ROUTE123_BERRY_MASTERS_HOUSE (0 | (31 << 8))
-// Map Group 32
+// gMapGroup_IndoorRoute119
#define MAP_ROUTE119_WEATHER_INSTITUTE_1F (0 | (32 << 8))
#define MAP_ROUTE119_WEATHER_INSTITUTE_2F (1 | (32 << 8))
#define MAP_ROUTE119_HOUSE (2 | (32 << 8))
-// Map Group 33
+// gMapGroup_IndoorRoute124
#define MAP_ROUTE124_DIVING_TREASURE_HUNTERS_HOUSE (0 | (33 << 8))
#define MAP_GROUPS_COUNT 34
diff --git a/include/ereader_helpers.h b/include/ereader_helpers.h
index 937cfaca1..064b61ed7 100755
--- a/include/ereader_helpers.h
+++ b/include/ereader_helpers.h
@@ -15,6 +15,7 @@ struct EReaderTrainerHillSet
{
u8 numTrainers;
u8 id;
+ u16 dummy; // Only read in an assert.
u32 checksum;
struct EReaderTrainerHillTrainer trainers[6];
u8 unk_ec0[40];
diff --git a/include/gba/m4a_internal.h b/include/gba/m4a_internal.h
index 2d0e1bb1c..2ccbb18f5 100644
--- a/include/gba/m4a_internal.h
+++ b/include/gba/m4a_internal.h
@@ -447,7 +447,7 @@ void SetPokemonCryPitch(s16 val);
void SetPokemonCryLength(u16 val);
void SetPokemonCryRelease(u8 val);
void SetPokemonCryProgress(u32 val);
-int IsPokemonCryPlaying(struct MusicPlayerInfo *mplayInfo);
+bool32 IsPokemonCryPlaying(struct MusicPlayerInfo *mplayInfo);
void SetPokemonCryChorus(s8 val);
void SetPokemonCryStereo(u32 val);
void SetPokemonCryPriority(u8 val);
diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h
index a3d99ee21..6bafa9747 100644
--- a/include/global.fieldmap.h
+++ b/include/global.fieldmap.h
@@ -142,19 +142,15 @@ struct MapHeader
/* 0x16 */ u8 weather;
/* 0x17 */ u8 mapType;
/* 0x18 */ u8 filler_18[2];
- /* 0x1A */ u8 flags;
+ // fields correspond to the arguments in the map_header_flags macro
+ /* 0x1A */ bool8 allowCycling:1;
+ bool8 allowEscaping:1; // Escape Rope and Dig
+ bool8 allowRunning:1;
+ bool8 showMapName:5; // the last 4 bits are unused
+ // but the 5 bit sized bitfield is required to match
/* 0x1B */ u8 battleType;
};
-// Flags for gMapHeader.flags, as defined in the map_header_flags macro
-#define MAP_ALLOW_CYCLING (1 << 0)
-#define MAP_ALLOW_ESCAPING (1 << 1) // Escape Rope and Dig
-#define MAP_ALLOW_RUNNING (1 << 2)
-#define MAP_SHOW_MAP_NAME (1 << 3)
-#define UNUSED_MAP_FLAGS (1 << 4 | 1 << 5 | 1 << 6 | 1 << 7)
-
-#define SHOW_MAP_NAME_ENABLED ((gMapHeader.flags & (MAP_SHOW_MAP_NAME | UNUSED_MAP_FLAGS)) == MAP_SHOW_MAP_NAME)
-
struct ObjectEvent
{
diff --git a/include/pokemon.h b/include/pokemon.h
index 82cdefeac..3565bd966 100644
--- a/include/pokemon.h
+++ b/include/pokemon.h
@@ -258,7 +258,6 @@ extern const u8 gFacilityClassToPicIndex[];
extern const u8 gFacilityClassToTrainerClass[];
extern const struct BaseStats gBaseStats[];
extern const u8 *const gItemEffectTable[];
-extern const struct Evolution gEvolutionTable[][EVOS_PER_MON];
extern const u32 gExperienceTables[][MAX_LEVEL + 1];
extern const u16 *const gLevelUpLearnsets[];
extern const u8 gPPUpGetMask[];
diff --git a/include/strings.h b/include/strings.h
index 04283db0e..9b3be0538 100644
--- a/include/strings.h
+++ b/include/strings.h
@@ -596,7 +596,7 @@ extern const u8 gText_TooImportantToToss[];
extern const u8 gText_ConfirmTossItems[];
extern const u8 gText_MoveVar1Where[];
-extern const u8 gText_ColorLightShadowDarkGrey[];
+extern const u8 gText_ColorLightShadowDarkGray[];
extern const u8 gText_ColorBlue[];
extern const u8 gText_Friend[];
extern const u8 gText_Tristan[];
@@ -2512,7 +2512,7 @@ extern const u8 gText_MatchCallMay_Intro1[];
extern const u8 gText_MatchCallMay_Intro2[];
// Contest Link
-extern const u8 gText_ColorDarkGrey[];
+extern const u8 gText_ColorDarkGray[];
extern const u8 gText_CommunicationStandby[];
extern const u8 gText_AnnouncingResults[];
extern const u8 gText_PreliminaryResults[];
diff --git a/ld_script_modern.txt b/ld_script_modern.txt
index b69ada864..59d032bb2 100644
--- a/ld_script_modern.txt
+++ b/ld_script_modern.txt
@@ -27,6 +27,8 @@ SECTIONS {
/* .bss starts at 0x3000000 */
src/*.o(.bss);
gflib/*.o(.bss);
+ *libc.a:*.o(.bss*);
+ *libnosys.a:*.o(.bss*);
/* .bss.code starts at 0x3001AA8 */
src/m4a.o(.bss.code);
@@ -34,7 +36,8 @@ SECTIONS {
/* COMMON starts at 0x30022A8 */
src/*.o(COMMON);
gflib/*.o(COMMON);
- *libc.a:sbrkr.o(COMMON);
+ *libc.a:*.o(COMMON);
+ *libnosys.a:*.o(COMMON);
end = .;
. = 0x8000;
}
@@ -44,19 +47,10 @@ SECTIONS {
.text :
ALIGN(4)
{
- src/crt0.o(.text);
- src/*.o(.text);
- gflib/*.o(.text);
- asm/*.o(.text);
- } =0
-
- .text.unlikely :
- ALIGN(4)
- {
- src/crt0.o(.text.unlikely);
- src/*.o(.text.unlikely);
- gflib/*.o(.text.unlikely);
- asm/*.o(.text.unlikely);
+ src/crt0.o(.text*);
+ src/*.o(.text*);
+ gflib/*.o(.text*);
+ asm/*.o(.text*);
} =0
script_data :
@@ -82,6 +76,7 @@ SECTIONS {
*libagbsyscall.a:*.o(.text*);
*libgcc.a:*.o(.text*);
*libc.a:*.o(.text*);
+ *libnosys.a:*.o(.text*);
src/libisagbprn.o(.text);
} =0
diff --git a/libagbsyscall/Makefile b/libagbsyscall/Makefile
index 911cdb237..78f246af4 100644
--- a/libagbsyscall/Makefile
+++ b/libagbsyscall/Makefile
@@ -1,29 +1,28 @@
TOOLCHAIN := $(DEVKITARM)
COMPARE ?= 0
-ifeq ($(CC),)
-HOSTCC := gcc
-else
-HOSTCC := $(CC)
-endif
+# don't use dkP's base_tools anymore
+# because the redefinition of $(CC) conflicts
+# with when we want to use $(CC) to preprocess files
+# thus, manually create the variables for the bin
+# files, or use arm-none-eabi binaries on the system
+# if dkP is not installed on this system
-ifeq ($(CXX),)
-HOSTCXX := g++
-else
-HOSTCXX := $(CXX)
+ifneq (,$(TOOLCHAIN))
+ifneq ($(wildcard $(TOOLCHAIN)/bin),)
+export PATH := $(TOOLCHAIN)/bin:$(PATH)
+endif
endif
-ifneq (,$(wildcard $(TOOLCHAIN)/base_tools))
-include $(TOOLCHAIN)/base_tools
-else
-export PATH := $(TOOLCHAIN)/bin:$(PATH)
PREFIX := arm-none-eabi-
OBJCOPY := $(PREFIX)objcopy
-export CC := $(PREFIX)gcc
-export AS := $(PREFIX)as
-endif
-export CPP := $(PREFIX)cpp
-export LD := $(PREFIX)ld
+AS := $(PREFIX)as
+LD := $(PREFIX)ld
+AR := $(PREFIX)ar
+
+# note: the makefile must be set up so MODERNCC is never called
+# if MODERN=0
+MODERNCC := $(PREFIX)gcc
ifeq ($(OS),Windows_NT)
EXE := .exe
@@ -31,6 +30,23 @@ else
EXE :=
endif
+# use arm-none-eabi-cpp for macOS
+# as macOS's default compiler is clang
+# and clang's preprocessor will warn on \u
+# when preprocessing asm files, expecting a unicode literal
+# we can't unconditionally use arm-none-eabi-cpp
+# as installations which install binutils-arm-none-eabi
+# don't come with it
+ifneq ($(MODERN),1)
+ ifeq ($(shell uname -s),Darwin)
+ CPP := $(PREFIX)cpp
+ else
+ CPP := $(CC) -E
+ endif
+else
+ CPP := $(PREFIX)cpp
+endif
+
ASFLAGS := -mcpu=arm7tdmi
ARFLAGS := rc
diff --git a/make_tools.mk b/make_tools.mk
new file mode 100644
index 000000000..697897a69
--- /dev/null
+++ b/make_tools.mk
@@ -0,0 +1,11 @@
+
+MAKEFLAGS += --no-print-directory
+
+TOOLDIRS := $(filter-out tools/agbcc tools/binutils,$(wildcard tools/*))
+
+.PHONY: all $(TOOLDIRS)
+
+all: $(TOOLDIRS)
+
+$(TOOLDIRS):
+ @$(MAKE) -C $@
diff --git a/map_data_rules.mk b/map_data_rules.mk
index 0203b383d..626cd4724 100755
--- a/map_data_rules.mk
+++ b/map_data_rules.mk
@@ -9,9 +9,9 @@ MAP_EVENTS := $(patsubst $(MAPS_DIR)/%/,$(MAPS_DIR)/%/events.inc,$(MAP_DIRS))
MAP_HEADERS := $(patsubst $(MAPS_DIR)/%/,$(MAPS_DIR)/%/header.inc,$(MAP_DIRS))
$(DATA_ASM_BUILDDIR)/maps.o: $(DATA_ASM_SUBDIR)/maps.s $(LAYOUTS_DIR)/layouts.inc $(LAYOUTS_DIR)/layouts_table.inc $(MAPS_DIR)/headers.inc $(MAPS_DIR)/groups.inc $(MAPS_DIR)/connections.inc $(MAP_CONNECTIONS) $(MAP_HEADERS)
- $(PREPROC) $< charmap.txt | $(CPP) -I include | $(AS) $(ASFLAGS) -o $@
+ $(PREPROC) $< charmap.txt | $(CPP) -I include - | $(AS) $(ASFLAGS) -o $@
$(DATA_ASM_BUILDDIR)/map_events.o: $(DATA_ASM_SUBDIR)/map_events.s $(MAPS_DIR)/events.inc $(MAP_EVENTS)
- $(PREPROC) $< charmap.txt | $(CPP) -I include | $(AS) $(ASFLAGS) -o $@
+ $(PREPROC) $< charmap.txt | $(CPP) -I include - | $(AS) $(ASFLAGS) -o $@
$(MAPS_DIR)/%/header.inc: $(MAPS_DIR)/%/map.json
$(MAPJSON) map emerald $< $(LAYOUTS_DIR)/layouts.json
diff --git a/src/apprentice.c b/src/apprentice.c
index f93a3e30b..00157dc1a 100644
--- a/src/apprentice.c
+++ b/src/apprentice.c
@@ -30,7 +30,7 @@
#include "constants/trainers.h"
#include "constants/moves.h"
-/* Summary of Apprentice, because (as of writing at least) its not very well documented online
+/* Summary of Apprentice, because (as of writing at least) it's not very well documented online
*
* ## Basic info
* In the Battle Tower lobby there is an NPC which asks to be taught by the player
@@ -1107,17 +1107,24 @@ static void TrySetApprenticeHeldItem(void)
if (PLAYER_APPRENTICE.questionsAnswered < NUM_WHICH_MON_QUESTIONS)
return;
+
+ count = 0;
+ for (j = 0; j < APPRENTICE_MAX_QUESTIONS; j++)
+ {
+ if (PLAYER_APPRENTICE.questions[j].questionId == QUESTION_ID_WIN_SPEECH)
+ break;
+ count++;
+ }
- for (count = 0, j = 0; j < APPRENTICE_MAX_QUESTIONS && PLAYER_APPRENTICE.questions[j].questionId != QUESTION_ID_WIN_SPEECH; count++, j++)
- ;
-
- // Make sure the item hasnt already been suggested in previous questions
- for (i = 0; i < count && i < CURRENT_QUESTION_NUM; i++)
+ // Make sure the item hasn't already been suggested in previous questions
+ for (i = 0; i < count; i++)
{
- do {} while(0);
- if (PLAYER_APPRENTICE.questions[i].questionId == QUESTION_ID_WHAT_ITEM
- && PLAYER_APPRENTICE.questions[i].suggestedChange
- && PLAYER_APPRENTICE.questions[i].data == gSpecialVar_0x8005)
+ if (i >= CURRENT_QUESTION_NUM)
+ break;
+ if (PLAYER_APPRENTICE.questions[i].questionId != QUESTION_ID_WHAT_ITEM ||
+ PLAYER_APPRENTICE.questions[i].suggestedChange == 0)
+ continue;
+ if (PLAYER_APPRENTICE.questions[i].data == gSpecialVar_0x8005)
{
PLAYER_APPRENTICE.questions[CURRENT_QUESTION_NUM].suggestedChange = FALSE;
PLAYER_APPRENTICE.questions[CURRENT_QUESTION_NUM].data = gSpecialVar_0x8005;
diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c
index 9fdd4d0c3..b72875036 100644
--- a/src/battle_ai_script_commands.c
+++ b/src/battle_ai_script_commands.c
@@ -1761,7 +1761,11 @@ static void Cmd_if_cant_faint(void)
gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100;
- // This macro is missing the damage 0 = 1 assumption.
+#ifdef BUGFIX
+ // Moves always do at least 1 damage.
+ if (gBattleMoveDamage == 0)
+ gBattleMoveDamage = 1;
+#endif
if (gBattleMons[gBattlerTarget].hp > gBattleMoveDamage)
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
@@ -1877,9 +1881,14 @@ static void Cmd_if_has_move_with_effect(void)
case AI_TARGET_PARTNER:
for (i = 0; i < MAX_MON_MOVES; i++)
{
- // UB: checks sBattler_AI instead of gBattlerTarget.
+ // BUG: checks sBattler_AI instead of gBattlerTarget.
+ #ifndef BUGFIX
if (gBattleMons[sBattler_AI].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i]].effect == gAIScriptPtr[2])
break;
+ #else
+ if (gBattleMons[gBattlerTarget].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i]].effect == gAIScriptPtr[2])
+ break;
+ #endif
}
if (i == MAX_MON_MOVES)
gAIScriptPtr += 7;
@@ -2014,18 +2023,24 @@ static void Cmd_if_holds_item(void)
{
u8 battlerId = BattleAI_GetWantedBattler(gAIScriptPtr[1]);
u16 item;
- u8 var1, var2;
+ u8 itemLo, itemHi;
if ((battlerId & BIT_SIDE) == (sBattler_AI & BIT_SIDE))
item = gBattleMons[battlerId].item;
else
item = BATTLE_HISTORY->itemEffects[battlerId];
- // UB: doesn't properly read an unaligned u16
- var2 = gAIScriptPtr[2];
- var1 = gAIScriptPtr[3];
+ itemHi = gAIScriptPtr[2];
+ itemLo = gAIScriptPtr[3];
- if ((var1 | var2) == item)
+#ifdef BUGFIX
+ // This bug doesn't affect the vanilla game because this script command
+ // is only used to check ITEM_PERSIM_BERRY, whose high byte happens to
+ // be 0.
+ if (((itemHi << 8) | itemLo) == item)
+#else
+ if ((itemLo | itemHi) == item)
+#endif
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
else
gAIScriptPtr += 8;
diff --git a/src/battle_anim_dark.c b/src/battle_anim_dark.c
index c2bfe269b..8000a648c 100644
--- a/src/battle_anim_dark.c
+++ b/src/battle_anim_dark.c
@@ -870,7 +870,7 @@ void AnimTask_MetallicShine(u8 taskId)
paletteNum = 16 + gSprites[spriteId].oam.paletteNum;
if (gBattleAnimArgs[1] == 0)
- SetGreyscaleOrOriginalPalette(paletteNum, FALSE);
+ SetGrayscaleOrOriginalPalette(paletteNum, FALSE);
else
BlendPalette(paletteNum * 16, 16, 11, gBattleAnimArgs[2]);
@@ -900,7 +900,7 @@ static void AnimTask_MetallicShine_Step(u8 taskId)
spriteId = GetAnimBattlerSpriteId(ANIM_ATTACKER);
paletteNum = 16 + gSprites[spriteId].oam.paletteNum;
if (gTasks[taskId].data[1] == 0)
- SetGreyscaleOrOriginalPalette(paletteNum, TRUE);
+ SetGrayscaleOrOriginalPalette(paletteNum, TRUE);
DestroySprite(&gSprites[gTasks[taskId].data[0]]);
GetBattleAnimBg1Data(&animBg);
@@ -925,10 +925,10 @@ static void AnimTask_MetallicShine_Step(u8 taskId)
}
}
-// Changes battler's palette to either greyscale or original.
+// Changes battler's palette to either grayscale or original.
// arg0: which battler
// arg1: FALSE grayscale, TRUE original
-void AnimTask_SetGreyscaleOrOriginalPal(u8 taskId)
+void AnimTask_SetGrayscaleOrOriginalPal(u8 taskId)
{
u8 spriteId;
u8 battler;
@@ -974,7 +974,7 @@ void AnimTask_SetGreyscaleOrOriginalPal(u8 taskId)
}
if (spriteId != SPRITE_NONE)
- SetGreyscaleOrOriginalPalette(gSprites[spriteId].oam.paletteNum + 16, gBattleAnimArgs[1]);
+ SetGrayscaleOrOriginalPalette(gSprites[spriteId].oam.paletteNum + 16, gBattleAnimArgs[1]);
DestroyAnimVisualTask(taskId);
}
diff --git a/src/battle_anim_effects_2.c b/src/battle_anim_effects_2.c
index 5dd584386..0ac5d384b 100755
--- a/src/battle_anim_effects_2.c
+++ b/src/battle_anim_effects_2.c
@@ -89,7 +89,7 @@ static void AnimPerishSongMusicNote_Step1(struct Sprite *);
static void AnimPerishSongMusicNote_Step2(struct Sprite *);
static void AnimGuardRing(struct Sprite *);
static void AnimTask_Withdraw_Step(u8);
-static void AnimTask_GrowAndGreyscale_Step(u8);
+static void AnimTask_GrowAndGrayscale_Step(u8);
static void AnimTask_Minimize_Step(u8);
static void CreateMinimizeSprite(struct Task *, u8);
static void ClonedMinizeSprite_Step(struct Sprite *);
@@ -1996,26 +1996,26 @@ static void AnimGuillotinePincer_Step3(struct Sprite *sprite)
DestroyAnimSprite(sprite);
}
-// Scales up the target mon sprite, and sets the palette to greyscale.
+// Scales up the target mon sprite, and sets the palette to grayscale.
// Used in MOVE_DISABLE.
// No args.
-void AnimTask_GrowAndGreyscale(u8 taskId)
+void AnimTask_GrowAndGrayscale(u8 taskId)
{
u8 spriteId = GetAnimBattlerSpriteId(ANIM_TARGET);
PrepareBattlerSpriteForRotScale(spriteId, ST_OAM_OBJ_BLEND);
SetSpriteRotScale(spriteId, 0xD0, 0xD0, 0);
- SetGreyscaleOrOriginalPalette(gSprites[spriteId].oam.paletteNum + 16, FALSE);
+ SetGrayscaleOrOriginalPalette(gSprites[spriteId].oam.paletteNum + 16, FALSE);
gTasks[taskId].data[0] = 80;
- gTasks[taskId].func = AnimTask_GrowAndGreyscale_Step;
+ gTasks[taskId].func = AnimTask_GrowAndGrayscale_Step;
}
-static void AnimTask_GrowAndGreyscale_Step(u8 taskId)
+static void AnimTask_GrowAndGrayscale_Step(u8 taskId)
{
if (--gTasks[taskId].data[0] == -1)
{
u8 spriteId = GetAnimBattlerSpriteId(ANIM_TARGET);
ResetSpriteRotScale(spriteId);
- SetGreyscaleOrOriginalPalette(gSprites[spriteId].oam.paletteNum + 16, TRUE);
+ SetGrayscaleOrOriginalPalette(gSprites[spriteId].oam.paletteNum + 16, TRUE);
DestroyAnimVisualTask(taskId);
}
}
@@ -3710,7 +3710,7 @@ static void AnimPerishSongMusicNote2(struct Sprite *sprite)
}
if (++sprite->data[0] == sprite->data[1])
- SetGreyscaleOrOriginalPalette(sprite->oam.paletteNum + 16, 0);
+ SetGrayscaleOrOriginalPalette(sprite->oam.paletteNum + 16, 0);
if (sprite->data[0] == sprite->data[1] + 80)
DestroyAnimSprite(sprite);
diff --git a/src/battle_anim_mons.c b/src/battle_anim_mons.c
index 2082512ff..cf5ae6eb2 100644
--- a/src/battle_anim_mons.c
+++ b/src/battle_anim_mons.c
@@ -1310,7 +1310,7 @@ u16 ArcTan2Neg(s16 a, s16 b)
return -var;
}
-void SetGreyscaleOrOriginalPalette(u16 paletteNum, bool8 restoreOriginalColor)
+void SetGrayscaleOrOriginalPalette(u16 paletteNum, bool8 restoreOriginalColor)
{
int i;
struct PlttData *originalColor;
diff --git a/src/battle_anim_sound_tasks.c b/src/battle_anim_sound_tasks.c
index 8fc93c3aa..39d6729e8 100644
--- a/src/battle_anim_sound_tasks.c
+++ b/src/battle_anim_sound_tasks.c
@@ -135,8 +135,10 @@ void SoundTask_PlayCryHighPitch(u8 taskId)
{
if (gBattleAnimArgs[0] == ANIM_ATTACKER)
species = gContestResources->moveAnim->species;
+ #ifndef UBFIX
else
- DestroyAnimVisualTask(taskId); // UB: function should return upon destroying task.
+ DestroyAnimVisualTask(taskId); // UB: task gets destroyed twice.
+ #endif
}
else
{
@@ -179,8 +181,10 @@ void SoundTask_PlayDoubleCry(u8 taskId)
{
if (gBattleAnimArgs[0] == ANIM_ATTACKER)
species = gContestResources->moveAnim->species;
+ #ifndef UBFIX
else
- DestroyAnimVisualTask(taskId); // UB: function should return upon destroying task.
+ DestroyAnimVisualTask(taskId); // UB: task gets destroyed twice.
+ #endif
}
else
{
diff --git a/src/battle_anim_throw.c b/src/battle_anim_throw.c
index 83768b476..4064e250c 100755
--- a/src/battle_anim_throw.c
+++ b/src/battle_anim_throw.c
@@ -1420,7 +1420,7 @@ static void MakeCaptureStars(struct Sprite *sprite)
LoadBallParticleGfx(BALL_MASTER);
for (i = 0; i < ARRAY_COUNT(sCaptureStars); i++)
{
- u8 spriteId = CreateSprite(&sBallParticleSpriteTemplates[4], sprite->pos1.x, sprite->pos1.y, subpriority);
+ u8 spriteId = CreateSprite(&sBallParticleSpriteTemplates[BALL_MASTER], sprite->pos1.x, sprite->pos1.y, subpriority);
if (spriteId != MAX_SPRITES)
{
gSprites[spriteId].sDuration = 24;
diff --git a/src/battle_dome.c b/src/battle_dome.c
index a5cf168ef..ea1e5abba 100644
--- a/src/battle_dome.c
+++ b/src/battle_dome.c
@@ -1211,8 +1211,8 @@ static const u8 gUnknown_0860D1A0[DOME_TOURNAMENT_TRAINERS_COUNT / 2][DOME_ROUND
static const u8 gUnknown_0860D1C0[DOME_TOURNAMENT_TRAINERS_COUNT] = {0, 15, 8, 7, 3, 12, 11, 4, 1, 14, 9, 6, 2, 13, 10, 5};
-// Each tourney trainer has a text describing their potential to win, depending on their seed ranking for the current tourney
-// Dome Ace Tucker has their own separate potential text
+// The first line of text on a trainers info card. It describes their potential to win, based on their seed in the tournament tree.
+// Dome Ace Tucker has their own separate potential text.
static const u8 *const sBattleDomePotentialTexts[DOME_TOURNAMENT_TRAINERS_COUNT + 1] =
{
BattleDome_Text_Potential1, // Highest potential
@@ -1234,7 +1234,7 @@ static const u8 *const sBattleDomePotentialTexts[DOME_TOURNAMENT_TRAINERS_COUNT
BattleDome_Text_PotentialDomeAceTucker,
};
-// The first line of text on a trainers info card that gives information about their battle style (dependent on their party's moves)
+// The second line of text on a trainers info card. It gives information about their battle style (dependent on their party's moves).
static const u8 *const sBattleDomeOpponentStyleTexts[NUM_BATTLE_STYLES] =
{
[DOME_BATTLE_STYLE_RISKY] = BattleDome_Text_StyleRiskDisaster,
@@ -1271,7 +1271,7 @@ static const u8 *const sBattleDomeOpponentStyleTexts[NUM_BATTLE_STYLES] =
[DOME_BATTLE_STYLE_UNUSED4] = BattleDome_Text_StyleSampleMessage4,
};
-// The second line of text on a trainers info card that gives information about their party's stat spread
+// The third line of text on a trainers info card. It that gives information about their party's stat spread (based on their Pokémon's effort values and Nature).
static const u8 *const sBattleDomeOpponentStatsTexts[] =
{
BattleDome_Text_EmphasizesHPAndAtk, // DOME_TEXT_TWO_GOOD_STATS and DOME_TEXT_HP start here
@@ -2766,13 +2766,22 @@ static int GetTypeEffectivenessPoints(int move, int targetSpecies, int arg2)
}
if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
{
- // BUG: TYPE_x2 is not necessary and makes the condition always false if the ability is wonder guard.
+ // BUG: the value of TYPE_x2 does not exist in gTypeEffectiveness, so if defAbility is ABILITY_WONDER_GUARD, the conditional always fails
+ #ifndef BUGFIX
if (TYPE_EFFECT_DEF_TYPE(i) == defType1)
if ((defAbility == ABILITY_WONDER_GUARD && TYPE_EFFECT_MULTIPLIER(i) == TYPE_x2) || defAbility != ABILITY_WONDER_GUARD)
typePower = (typePower * TYPE_EFFECT_MULTIPLIER(i)) / 10;
if (TYPE_EFFECT_DEF_TYPE(i) == defType2 && defType1 != defType2)
if ((defAbility == ABILITY_WONDER_GUARD && TYPE_EFFECT_MULTIPLIER(i) == TYPE_x2) || defAbility != ABILITY_WONDER_GUARD)
typePower = (typePower * TYPE_EFFECT_MULTIPLIER(i)) / 10;
+ #else
+ if (TYPE_EFFECT_DEF_TYPE(i) == defType1)
+ if ((defAbility == ABILITY_WONDER_GUARD && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE) || defAbility != ABILITY_WONDER_GUARD)
+ typePower = (typePower * TYPE_EFFECT_MULTIPLIER(i)) / 10;
+ if (TYPE_EFFECT_DEF_TYPE(i) == defType2 && defType1 != defType2)
+ if ((defAbility == ABILITY_WONDER_GUARD && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE) || defAbility != ABILITY_WONDER_GUARD)
+ typePower = (typePower * TYPE_EFFECT_MULTIPLIER(i)) / 10;
+ #endif
}
i += 3;
}
@@ -5211,40 +5220,38 @@ static u16 GetWinningMove(int winnerTournamentId, int loserTournamentId, u8 roun
}
j = bestId;
- goto LABEL;
- while (j != 0)
+ do
{
- for (j = 0, k = 0; k < MAX_MON_MOVES * FRONTIER_PARTY_SIZE; k++)
+ for (i = 0; i < roundId - 1; i++)
{
- if (bestScore < moveScores[k])
- {
- j = k;
- bestScore = moveScores[k];
- }
- else if (bestScore == moveScores[k] && moveIds[j] < moveIds[k])
- {
- j = k;
- }
+ if (gSaveBlock2Ptr->frontier.domeWinningMoves[sub_81953E8(winnerTournamentId, i)] == moveIds[j])
+ break;
}
- if (i == roundId - 1)
- break;
- LABEL:
+ if (i != roundId - 1)
{
- for (i = 0; i < roundId - 1; i++)
- {
- if (gSaveBlock2Ptr->frontier.domeWinningMoves[sub_81953E8(winnerTournamentId, i)] == moveIds[j])
- break;
- }
- if (i == roundId - 1)
- break;
-
moveScores[j] = 0;
bestScore = 0;
j = 0;
for (k = 0; k < MAX_MON_MOVES * FRONTIER_PARTY_SIZE; k++)
j += moveScores[k];
+ if (j == 0)
+ break;
+ j = 0;
+ for (k = 0; k < MAX_MON_MOVES * FRONTIER_PARTY_SIZE; k++)
+ {
+ if (bestScore < moveScores[k])
+ {
+ j = k;
+ bestScore = moveScores[k];
+ }
+ else if (bestScore == moveScores[k] && moveIds[j] < moveIds[k]) // Yes, these conditions are redundant
+ {
+ j = k;
+ bestScore = moveScores[k];
+ }
+ }
}
- }
+ } while (i != roundId - 1);
if (moveScores[j] == 0)
j = bestId;
diff --git a/src/battle_factory.c b/src/battle_factory.c
index 72772929a..e0bfdfdd0 100644
--- a/src/battle_factory.c
+++ b/src/battle_factory.c
@@ -38,7 +38,7 @@ static void GenerateInitialRentalMons(void);
static void GetOpponentMostCommonMonType(void);
static void GetOpponentBattleStyle(void);
static void RestorePlayerPartyHeldItems(void);
-static u16 GetFactoryMonId(u8 lvlMode, u8 challengeNum, bool8 arg2);
+static u16 GetFactoryMonId(u8 lvlMode, u8 challengeNum, bool8 useBetterRange);
static u8 GetMoveBattleStyle(u16 move);
// Number of moves needed on the team to be considered using a certain battle style
diff --git a/src/battle_factory_screen.c b/src/battle_factory_screen.c
index 680c6e81c..db810e965 100644
--- a/src/battle_factory_screen.c
+++ b/src/battle_factory_screen.c
@@ -4221,12 +4221,17 @@ static void Task_OpenMonPic(u8 taskId)
return;
break;
default:
+ #ifndef UBFIX
DestroyTask(taskId);
+ #endif
// UB: Should not use the task after it has been deleted.
if (gTasks[taskId].tIsSwapScreen == TRUE)
Swap_CreateMonSprite();
else
Select_CreateMonSprite();
+ #ifdef UBFIX
+ DestroyTask(taskId);
+ #endif
return;
}
task->tState++;
diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c
index ba0cab814..88e69665e 100644
--- a/src/battle_gfx_sfx_util.c
+++ b/src/battle_gfx_sfx_util.c
@@ -40,7 +40,7 @@ extern const struct SpriteTemplate gSpriteTemplate_EnemyShadow;
static u8 GetBattlePalaceMoveGroup(u16 move);
static u16 GetBattlePalaceTarget(void);
static void SpriteCB_TrainerSlideVertical(struct Sprite *sprite);
-static bool8 ShouldAnimBeDoneRegardlessOfSubsitute(u8 animId);
+static bool8 ShouldAnimBeDoneRegardlessOfSubstitute(u8 animId);
static void Task_ClearBitWhenBattleTableAnimDone(u8 taskId);
static void Task_ClearBitWhenSpecialAnimDone(u8 taskId);
static void ClearSpritesBattlerHealthboxAnimData(void);
@@ -444,7 +444,7 @@ bool8 TryHandleLaunchBattleTableAnimation(u8 activeBattler, u8 atkBattler, u8 de
return TRUE;
}
if (gBattleSpritesDataPtr->battlerData[activeBattler].behindSubstitute
- && !ShouldAnimBeDoneRegardlessOfSubsitute(tableId))
+ && !ShouldAnimBeDoneRegardlessOfSubstitute(tableId))
{
return TRUE;
}
@@ -480,7 +480,7 @@ static void Task_ClearBitWhenBattleTableAnimDone(u8 taskId)
#undef tBattlerId
-static bool8 ShouldAnimBeDoneRegardlessOfSubsitute(u8 animId)
+static bool8 ShouldAnimBeDoneRegardlessOfSubstitute(u8 animId)
{
switch (animId)
{
diff --git a/src/battle_interface.c b/src/battle_interface.c
index 5518fd21b..50eb5373a 100644
--- a/src/battle_interface.c
+++ b/src/battle_interface.c
@@ -159,7 +159,7 @@ enum
// strings
extern const u8 gText_Slash[];
-extern const u8 gText_HighlightDarkGrey[];
+extern const u8 gText_HighlightDarkGray[];
extern const u8 gText_DynColor2[];
extern const u8 gText_DynColor2Male[];
extern const u8 gText_DynColor1Female[];
@@ -1099,21 +1099,14 @@ static void UpdateLvlInHealthbox(u8 healthboxSpriteId, u8 lvl)
u32 windowId, spriteTileNum;
u8 *windowTileData;
u8 text[16];
- u32 xPos, var1;
- void *objVram;
-
- text[0] = 0xF9;
- text[1] = 5;
+ u32 xPos;
+ u8 *objVram;
+
+ text[0] = CHAR_EXTRA_SYMBOL;
+ text[1] = CHAR_LV_2;
- xPos = (u32) ConvertIntToDecimalStringN(text + 2, lvl, STR_CONV_MODE_LEFT_ALIGN, 3);
- // Alright, that part was unmatchable. It's basically doing:
- // xPos = 5 * (3 - (u32)(&text[2]));
- xPos--;
- xPos--;
- xPos -= ((u32)(text));
- var1 = (3 - xPos);
- xPos = 4 * var1;
- xPos += var1;
+ objVram = ConvertIntToDecimalStringN(text + 2, lvl, STR_CONV_MODE_LEFT_ALIGN, 3);
+ xPos = 5 * (3 - (objVram - (text + 2)));
windowTileData = AddTextPrinterAndCreateWindowOnHealthbox(text, xPos, 3, 2, &windowId);
spriteTileNum = gSprites[healthboxSpriteId].oam.tileNum * TILE_SIZE_4BPP;
@@ -1902,7 +1895,7 @@ static void UpdateNickInHealthbox(u8 healthboxSpriteId, struct Pokemon *mon)
u16 species;
u8 gender;
- StringCopy(gDisplayedStringBattle, gText_HighlightDarkGrey);
+ StringCopy(gDisplayedStringBattle, gText_HighlightDarkGray);
GetMonData(mon, MON_DATA_NICKNAME, nickname);
StringGetEnd10(nickname);
ptr = StringAppend(gDisplayedStringBattle, nickname);
diff --git a/src/battle_main.c b/src/battle_main.c
index c74de896e..977bcbd9c 100644
--- a/src/battle_main.c
+++ b/src/battle_main.c
@@ -1961,10 +1961,10 @@ static u8 CreateNPCTrainerParty(struct Pokemon *party, u16 trainerNum, bool8 fir
if (gTrainers[trainerNum].doubleBattle == TRUE)
personalityValue = 0x80;
- else if (gTrainers[trainerNum].encounterMusic_gender & 0x80)
- personalityValue = 0x78;
+ else if (gTrainers[trainerNum].encounterMusic_gender & F_TRAINER_FEMALE)
+ personalityValue = 0x78; // Use personality more likely to result in a female Pokémon
else
- personalityValue = 0x88;
+ personalityValue = 0x88; // Use personality more likely to result in a male Pokémon
for (j = 0; gTrainers[trainerNum].trainerName[j] != EOS; j++)
nameHash += gTrainers[trainerNum].trainerName[j];
@@ -5148,7 +5148,12 @@ static void ReturnFromBattleToOverworld(void)
if (gBattleTypeFlags & BATTLE_TYPE_ROAMER)
{
UpdateRoamerHPStatus(&gEnemyParty[0]);
+
+#ifndef BUGFIX
if ((gBattleOutcome & B_OUTCOME_WON) || gBattleOutcome == B_OUTCOME_CAUGHT)
+#else
+ if ((gBattleOutcome == B_OUTCOME_WON) || gBattleOutcome == B_OUTCOME_CAUGHT) // Bug: When Roar is used by roamer, gBattleOutcome is B_OUTCOME_PLAYER_TELEPORTED (5).
+#endif // & with B_OUTCOME_WON (1) will return TRUE and deactivates the roamer.
SetRoamerInactive();
}
diff --git a/src/battle_message.c b/src/battle_message.c
index 2e752dcca..ae30a2a62 100644
--- a/src/battle_message.c
+++ b/src/battle_message.c
@@ -383,7 +383,7 @@ static const u8 sText_ThrewPokeblockAtPkmn[] = _("{B_PLAYER_NAME} threw a {POKEB
static const u8 sText_OutOfSafariBalls[] = _("{PLAY_SE SE_DING_DONG}ANNOUNCER: You're out of\nSAFARI BALLS! Game over!\p");
static const u8 sText_OpponentMon1Appeared[] = _("{B_OPPONENT_MON1_NAME} appeared!\p");
static const u8 sText_WildPkmnAppeared[] = _("Wild {B_OPPONENT_MON1_NAME} appeared!\p");
-static const u8 sText_WildPkmnAppeared2[] = _("Wild {B_OPPONENT_MON1_NAME} appeared!\p");
+static const u8 sText_LegendaryPkmnAppeared[] = _("Wild {B_OPPONENT_MON1_NAME} appeared!\p");
static const u8 sText_WildPkmnAppearedPause[] = _("Wild {B_OPPONENT_MON1_NAME} appeared!{PAUSE 127}");
static const u8 sText_TwoWildPkmnAppeared[] = _("Wild {B_OPPONENT_MON1_NAME} and\n{B_OPPONENT_MON2_NAME} appeared!\p");
static const u8 sText_Trainer1WantsToBattle[] = _("{B_TRAINER1_CLASS} {B_TRAINER1_NAME}\nwould like to battle!\p");
@@ -1067,7 +1067,7 @@ const u16 gTransformUsedStringIds[] =
[B_MSG_TRANSFORM_FAILED] = STRINGID_BUTITFAILED
};
-const u16 gSubsituteUsedStringIds[] =
+const u16 gSubstituteUsedStringIds[] =
{
[B_MSG_SET_SUBSTITUTE] = STRINGID_PKMNMADESUBSTITUTE,
[B_MSG_SUBSTITUTE_FAILED] = STRINGID_TOOWEAKFORSUBSTITUTE
@@ -1328,7 +1328,7 @@ static const u8 sText_SpaceIs[] = _(" is");
static const u8 sText_ApostropheS[] = _("'s");
// For displaying names of invalid moves
-static const u8 sATypeMove_Table[][NUMBER_OF_MON_TYPES - 1] =
+static const u8 sATypeMove_Table[NUMBER_OF_MON_TYPES][17] =
{
[TYPE_NORMAL] = _("a NORMAL move"),
[TYPE_FIGHTING] = _("a FIGHTING move"),
@@ -2125,7 +2125,7 @@ void BufferStringBattle(u16 stringID)
else
{
if (gBattleTypeFlags & BATTLE_TYPE_LEGENDARY)
- stringPtr = sText_WildPkmnAppeared2;
+ stringPtr = sText_LegendaryPkmnAppeared;
else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) // interesting, looks like they had something planned for wild double battles
stringPtr = sText_TwoWildPkmnAppeared;
else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL)
diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c
index a41a80bbb..50efeecb4 100644
--- a/src/battle_pyramid.c
+++ b/src/battle_pyramid.c
@@ -1399,8 +1399,12 @@ void GenerateBattlePyramidWildMon(void)
for (i = 0; i < MAX_MON_MOVES; i++)
SetMonMoveSlot(&gEnemyParty[0], wildMons[id].moves[i], i);
- // BUG: Reading outside the array as lvl was used for mon level instead of frontier lvl mode.
+ // UB: Reading outside the array as lvl was used for mon level instead of frontier lvl mode.
+ #ifndef UBFIX
if (gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvl] >= 140)
+ #else
+ if (gSaveBlock2Ptr->frontier.pyramidWinStreaks[gSaveBlock2Ptr->frontier.lvlMode] >= 140)
+ #endif
{
id = (Random() % 17) + 15;
for (i = 0; i < NUM_STATS; i++)
diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c
index 0492caeb5..d927ffb76 100644
--- a/src/battle_script_commands.c
+++ b/src/battle_script_commands.c
@@ -3269,7 +3269,7 @@ static void Cmd_getexp(void)
if (viaExpShare) // at least one mon is getting exp via exp share
{
- *exp = calculatedExp / 2 / viaSentIn;
+ *exp = SAFE_DIV(calculatedExp / 2, viaSentIn);
if (*exp == 0)
*exp = 1;
@@ -3279,7 +3279,7 @@ static void Cmd_getexp(void)
}
else
{
- *exp = calculatedExp / viaSentIn;
+ *exp = SAFE_DIV(calculatedExp, viaSentIn);
if (*exp == 0)
*exp = 1;
gExpShareExp = 0;
@@ -3357,7 +3357,7 @@ static void Cmd_getexp(void)
// get exp getter battlerId
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
- if (!(gBattlerPartyIndexes[2] != gBattleStruct->expGetterMonId) && !(gAbsentBattlerFlags & gBitTable[2]))
+ if (gBattlerPartyIndexes[2] == gBattleStruct->expGetterMonId && !(gAbsentBattlerFlags & gBitTable[2]))
gBattleStruct->expGetterBattlerId = 2;
else
{
@@ -3431,14 +3431,13 @@ static void Cmd_getexp(void)
gBattleMons[0].maxHP = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_MAX_HP);
gBattleMons[0].attack = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_ATK);
gBattleMons[0].defense = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_DEF);
- // Why is this duplicated?
+ // Speed is duplicated, likely due to a copy-paste error.
gBattleMons[0].speed = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPEED);
gBattleMons[0].speed = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPEED);
-
gBattleMons[0].spAttack = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPATK);
gBattleMons[0].spDefense = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPDEF);
}
- // What is else if?
+
if (gBattlerPartyIndexes[2] == gBattleStruct->expGetterMonId && gBattleMons[2].hp && (gBattleTypeFlags & BATTLE_TYPE_DOUBLE))
{
gBattleMons[2].level = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL);
@@ -3446,10 +3445,13 @@ static void Cmd_getexp(void)
gBattleMons[2].maxHP = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_MAX_HP);
gBattleMons[2].attack = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_ATK);
gBattleMons[2].defense = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_DEF);
- // Duplicated again, but this time there's no Sp Defense
gBattleMons[2].speed = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPEED);
+ // Speed is duplicated again, but Special Defense is missing.
+#ifdef BUGFIX
+ gBattleMons[2].spDefense = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPDEF);
+#else
gBattleMons[2].speed = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPEED);
-
+#endif
gBattleMons[2].spAttack = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPATK);
}
gBattleScripting.getexpState = 5;
@@ -6168,7 +6170,13 @@ static void Cmd_recordlastability(void)
{
gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
RecordAbilityBattle(gActiveBattler, gLastUsedAbility);
- gBattlescriptCurrInstr += 1; // UB: Should be + 2, one byte for command and one byte for battlerId argument.
+
+#ifdef BUGFIX
+ // This command occupies two bytes (one for the command id, and one for the battler id parameter).
+ gBattlescriptCurrInstr += 2;
+#else
+ gBattlescriptCurrInstr += 1;
+#endif
}
void BufferMoveToLearnIntoBattleTextBuff2(void)
diff --git a/src/battle_transition.c b/src/battle_transition.c
index 1b484f7c5..461c45e7d 100644
--- a/src/battle_transition.c
+++ b/src/battle_transition.c
@@ -1323,6 +1323,12 @@ static bool8 Phase2_BigPokeball_Func1(struct Task *task)
return FALSE;
}
+#define SOME_VRAM_STORE(ptr, posY, posX, toStore) \
+{ \
+ u32 index = (posY) * 32 + posX; \
+ ptr[index] = toStore; \
+}
+
static bool8 Phase2_BigPokeball_Func2(struct Task *task)
{
s16 i, j;
@@ -1335,7 +1341,7 @@ static bool8 Phase2_BigPokeball_Func2(struct Task *task)
{
for (j = 0; j < 30; j++, BigPokeballMap++)
{
- tilemap[i * 32 + j] = *BigPokeballMap | 0xF000;
+ SOME_VRAM_STORE(tilemap, i, j, *BigPokeballMap | 0xF000);
}
}
sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160);
@@ -1675,12 +1681,6 @@ bool8 FldEff_Pokeball(void)
return FALSE;
}
-#define SOME_VRAM_STORE(ptr, posY, posX, toStore) \
-{ \
- u32 index = (posY) * 32 + posX; \
- ptr[index] = toStore; \
-}
-
static void sub_814713C(struct Sprite *sprite)
{
s16 arr0[ARRAY_COUNT(sUnknown_085C8B96)];
@@ -2142,7 +2142,7 @@ static bool8 Phase2_Mugshot_Func2(struct Task *task)
{
for (j = 0; j < 32; j++, mugshotsMap++)
{
- tilemap[i * 32 + j] = *mugshotsMap | 0xF000;
+ SOME_VRAM_STORE(tilemap, i, j, *mugshotsMap | 0xF000);
}
}
@@ -2960,17 +2960,15 @@ static bool8 Phase2_RectangularSpiral_Func2(struct Task *task)
if (sub_8149048(gUnknown_085C8D38[j / 2], &sRectangularSpiralTransition[j]))
{
- u32 one;
done = FALSE;
var = sRectangularSpiralTransition[j].field_2;
- one = 1;
- if ((j & 1) == one)
+ if ((j % 2) == 1)
var = 0x27D - var;
var2 = var % 32;
- var3 = var / 32 * 32;
+ var3 = var / 32;
- tilemap[var3 + var2] = 0xF002;
+ SOME_VRAM_STORE(tilemap, var3, var2, 0xF002);
}
}
}
@@ -4328,7 +4326,10 @@ static bool8 Phase2_FrontierSquaresScroll_Func5(struct Task *task)
BlendPalettes(PALETTES_ALL, 0x10, 0);
DestroyTask(FindTaskIdByFunc(task->func));
+
+#ifndef UBFIX
task->tState++; // UB: changing value of a destroyed task
+#endif
return FALSE;
}
diff --git a/src/bike.c b/src/bike.c
index bbcda989c..e97a5e04e 100644
--- a/src/bike.c
+++ b/src/bike.c
@@ -614,27 +614,24 @@ static void AcroBikeTransition_WheelieHoppingMoving(u8 direction)
return;
}
collision = GetBikeCollision(direction);
- // TODO: Try to get rid of this goto
- if (collision == 0 || collision == COLLISION_WHEELIE_HOP)
+ if (collision && collision != COLLISION_WHEELIE_HOP)
{
- goto derp;
- }
- else if (collision == COLLISION_LEDGE_JUMP)
- {
- PlayerLedgeHoppingWheelie(direction);
- }
- else if (collision < COLLISION_STOP_SURFING || collision > COLLISION_ROTATING_GATE)
- {
- if (collision < COLLISION_VERTICAL_RAIL)
+ if (collision == COLLISION_LEDGE_JUMP)
{
- AcroBikeTransition_WheelieHoppingStanding(direction);
+ PlayerLedgeHoppingWheelie(direction);
+ return;
}
- else
+ if (collision >= COLLISION_STOP_SURFING && collision <= COLLISION_ROTATING_GATE)
+ {
+ return;
+ }
+ if (collision < COLLISION_VERTICAL_RAIL)
{
- derp:
- PlayerMovingHoppingWheelie(direction);
+ AcroBikeTransition_WheelieHoppingStanding(direction);
+ return;
}
}
+ PlayerMovingHoppingWheelie(direction);
}
static void AcroBikeTransition_SideJump(u8 direction)
@@ -1056,7 +1053,7 @@ void Bike_HandleBumpySlopeJump(void)
bool32 IsRunningDisallowed(u8 metatile)
{
- if (!(gMapHeader.flags & MAP_ALLOW_RUNNING) || IsRunningDisallowedByMetatile(metatile) == TRUE)
+ if (!gMapHeader.allowRunning || IsRunningDisallowedByMetatile(metatile) == TRUE)
return TRUE;
else
return FALSE;
diff --git a/src/contest.c b/src/contest.c
index dbbd6ef63..84d00d8ee 100644
--- a/src/contest.c
+++ b/src/contest.c
@@ -258,6 +258,11 @@ enum {
#define TAG_BLINK_EFFECT_CONTESTANT2 0x80EA
#define TAG_BLINK_EFFECT_CONTESTANT3 0x80EB
+#define TILE_FILLED_APPEAL_HEART 0x5012
+#define TILE_FILLED_JAM_HEART 0x5014
+#define TILE_EMPTY_APPEAL_HEART 0x5035
+#define TILE_EMPTY_JAM_HEART 0x5036
+
enum {
SLIDER_HEART_ANIM_NORMAL,
SLIDER_HEART_ANIM_DISAPPEAR,
@@ -1526,7 +1531,7 @@ static void Task_ShowMoveSelectScreen(u8 taskId)
&& eContestantStatus[gContestPlayerMonIndex].hasJudgesAttention)
{
// Highlight the text because it's a combo move
- moveNameBuffer = StringCopy(moveName, gText_ColorLightShadowDarkGrey);
+ moveNameBuffer = StringCopy(moveName, gText_ColorLightShadowDarkGray);
}
else if (move != MOVE_NONE
&& eContestantStatus[gContestPlayerMonIndex].prevMove == move
@@ -3203,27 +3208,25 @@ static void PrintContestMoveDescription(u16 a)
ContestBG_FillBoxWithIncrementingTile(0, categoryTile, 0x0b, 0x1f, 0x05, 0x01, 0x11, 0x01);
ContestBG_FillBoxWithIncrementingTile(0, categoryTile + 0x10, 0x0b, 0x20, 0x05, 0x01, 0x11, 0x01);
+ // Appeal hearts
if (gContestEffects[gContestMoves[a].effect].appeal == 0xFF)
numHearts = 0;
else
numHearts = gContestEffects[gContestMoves[a].effect].appeal / 10;
- if (numHearts > 8)
- numHearts = 8;
- // Filled-in hearts
- ContestBG_FillBoxWithTile(0, 0x5035, 0x15, 0x1f, 0x08, 0x01, 0x11);
- // Empty hearts
- ContestBG_FillBoxWithTile(0, 0x5012, 0x15, 0x1f, numHearts, 0x01, 0x11);
+ if (numHearts > MAX_CONTEST_MOVE_HEARTS)
+ numHearts = MAX_CONTEST_MOVE_HEARTS;
+ ContestBG_FillBoxWithTile(0, TILE_EMPTY_APPEAL_HEART, 0x15, 0x1f, MAX_CONTEST_MOVE_HEARTS, 0x01, 0x11);
+ ContestBG_FillBoxWithTile(0, TILE_FILLED_APPEAL_HEART, 0x15, 0x1f, numHearts, 0x01, 0x11);
+ // Jam hearts
if (gContestEffects[gContestMoves[a].effect].jam == 0xFF)
numHearts = 0;
else
numHearts = gContestEffects[gContestMoves[a].effect].jam / 10;
- if (numHearts > 8)
- numHearts = 8;
- // Filled-in hearts
- ContestBG_FillBoxWithTile(0, 0x5036, 0x15, 0x20, 0x08, 0x01, 0x11);
- // Empty hearts
- ContestBG_FillBoxWithTile(0, 0x5014, 0x15, 0x20, numHearts, 0x01, 0x11);
+ if (numHearts > MAX_CONTEST_MOVE_HEARTS)
+ numHearts = MAX_CONTEST_MOVE_HEARTS;
+ ContestBG_FillBoxWithTile(0, TILE_EMPTY_JAM_HEART, 0x15, 0x20, MAX_CONTEST_MOVE_HEARTS, 0x01, 0x11);
+ ContestBG_FillBoxWithTile(0, TILE_FILLED_JAM_HEART, 0x15, 0x20, numHearts, 0x01, 0x11);
FillWindowPixelBuffer(WIN_MOVE_DESCRIPTION, PIXEL_FILL(0));
Contest_PrintTextToBg0WindowStd(WIN_MOVE_DESCRIPTION, gContestEffectDescriptionPointers[gContestMoves[a].effect]);
diff --git a/src/contest_util.c b/src/contest_util.c
index decbded2c..88ab4a7d2 100644
--- a/src/contest_util.c
+++ b/src/contest_util.c
@@ -497,7 +497,7 @@ static void LoadContestMonName(u8 monIndex)
struct ContestPokemon *mon = &gContestMons[monIndex];
u8 *str = gDisplayedStringBattle;
if (monIndex == gContestPlayerMonIndex)
- str = StringCopy(gDisplayedStringBattle, gText_ColorDarkGrey);
+ str = StringCopy(gDisplayedStringBattle, gText_ColorDarkGray);
StringCopy(str, mon->nickname);
AddContestTextPrinter(monIndex, gDisplayedStringBattle, 0);
diff --git a/src/daycare.c b/src/daycare.c
index 34b864981..4199bfda6 100644
--- a/src/daycare.c
+++ b/src/daycare.c
@@ -23,6 +23,8 @@
#include "constants/moves.h"
#include "constants/region_map_sections.h"
+extern const struct Evolution gEvolutionTable[][EVOS_PER_MON];
+
// this file's functions
static void ClearDaycareMonMail(struct DaycareMail *mail);
static void SetInitialEggData(struct Pokemon *mon, u16 species, struct DayCare *daycare);
diff --git a/src/egg_hatch.c b/src/egg_hatch.c
index 7a3019f56..576e5c0d9 100644
--- a/src/egg_hatch.c
+++ b/src/egg_hatch.c
@@ -584,6 +584,9 @@ static void Task_EggHatchPlayBGM(u8 taskID)
PlayBGM(MUS_EVOLUTION);
DestroyTask(taskID);
// UB: task is destroyed, yet the value is incremented
+ #ifdef UBFIX
+ return;
+ #endif
}
gTasks[taskID].data[0]++;
}
diff --git a/src/evolution_scene.c b/src/evolution_scene.c
index 39e917161..08f816f4f 100644
--- a/src/evolution_scene.c
+++ b/src/evolution_scene.c
@@ -34,6 +34,8 @@
#include "constants/rgb.h"
#include "constants/items.h"
+extern struct Evolution gEvolutionTable[][EVOS_PER_MON];
+
struct EvoInfo
{
u8 preEvoSpriteId;
@@ -550,8 +552,6 @@ static void CreateShedinja(u16 preEvoSpecies, struct Pokemon* mon)
{
s32 i;
struct Pokemon* shedinja = &gPlayerParty[gPlayerPartyCount];
- const struct Evolution *evos;
- const struct Evolution *evos2;
CopyMon(&gPlayerParty[gPlayerPartyCount], mon, sizeof(struct Pokemon));
SetMonData(&gPlayerParty[gPlayerPartyCount], MON_DATA_SPECIES, &gEvolutionTable[preEvoSpecies][1].targetSpecies);
@@ -572,12 +572,8 @@ static void CreateShedinja(u16 preEvoSpecies, struct Pokemon* mon)
CalculateMonStats(&gPlayerParty[gPlayerPartyCount]);
CalculatePlayerPartyCount();
- // can't match it otherwise, ehh
- evos2 = gEvolutionTable[0];
- evos = evos2 + EVOS_PER_MON * preEvoSpecies;
-
- GetSetPokedexFlag(SpeciesToNationalPokedexNum(evos[1].targetSpecies), FLAG_SET_SEEN);
- GetSetPokedexFlag(SpeciesToNationalPokedexNum(evos[1].targetSpecies), FLAG_SET_CAUGHT);
+ GetSetPokedexFlag(SpeciesToNationalPokedexNum(gEvolutionTable[preEvoSpecies][1].targetSpecies), FLAG_SET_SEEN);
+ GetSetPokedexFlag(SpeciesToNationalPokedexNum(gEvolutionTable[preEvoSpecies][1].targetSpecies), FLAG_SET_CAUGHT);
if (GetMonData(shedinja, MON_DATA_SPECIES) == SPECIES_SHEDINJA
&& GetMonData(shedinja, MON_DATA_LANGUAGE) == LANGUAGE_JAPANESE
diff --git a/src/item.c b/src/item.c
index cc9a09ee0..156034262 100644
--- a/src/item.c
+++ b/src/item.c
@@ -280,10 +280,6 @@ bool8 AddBagItem(u16 itemId, u16 count)
{
// successfully added to already existing item's count
SetBagItemQuantity(&newItems[i].quantity, ownedCount + count);
-
- // goto SUCCESS_ADD_ITEM;
- // is equivalent but won't match
-
memcpy(itemPocket->itemSlots, newItems, itemPocket->capacity * sizeof(struct ItemSlot));
Free(newItems);
return TRUE;
@@ -303,7 +299,7 @@ bool8 AddBagItem(u16 itemId, u16 count)
// don't create another instance of the item if it's at max slot capacity and count is equal to 0
if (count == 0)
{
- goto SUCCESS_ADD_ITEM;
+ break;
}
}
}
@@ -334,7 +330,8 @@ bool8 AddBagItem(u16 itemId, u16 count)
{
// created a new slot and added quantity
SetBagItemQuantity(&newItems[i].quantity, count);
- goto SUCCESS_ADD_ITEM;
+ count = 0;
+ break;
}
}
}
@@ -345,11 +342,9 @@ bool8 AddBagItem(u16 itemId, u16 count)
return FALSE;
}
}
-
- SUCCESS_ADD_ITEM:
- memcpy(itemPocket->itemSlots, newItems, itemPocket->capacity * sizeof(struct ItemSlot));
- Free(newItems);
- return TRUE;
+ memcpy(itemPocket->itemSlots, newItems, itemPocket->capacity * sizeof(struct ItemSlot));
+ Free(newItems);
+ return TRUE;
}
}
@@ -553,7 +548,6 @@ bool8 AddPCItem(u16 itemId, u16 count)
void RemovePCItem(u8 index, u16 count)
{
- // UB: should use GetPCItemQuantity and SetPCItemQuantity functions
gSaveBlock1Ptr->pcItems[index].quantity -= count;
if (gSaveBlock1Ptr->pcItems[index].quantity == 0)
{
diff --git a/src/item_use.c b/src/item_use.c
index 19f50549e..c9087e929 100755
--- a/src/item_use.c
+++ b/src/item_use.c
@@ -910,7 +910,7 @@ static void ItemUseOnFieldCB_EscapeRope(u8 taskId)
bool8 CanUseDigOrEscapeRopeOnCurMap(void)
{
- if (gMapHeader.flags & MAP_ALLOW_ESCAPING)
+ if (gMapHeader.allowEscaping)
return TRUE;
else
return FALSE;
diff --git a/src/m4a.c b/src/m4a.c
index 3bb440f65..105312a40 100644
--- a/src/m4a.c
+++ b/src/m4a.c
@@ -1525,6 +1525,10 @@ void ply_xwave(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track
{
u32 wav;
+#ifdef UBFIX
+ wav = 0;
+#endif
+
READ_XCMD_BYTE(wav, 0) // UB: uninitialized variable
READ_XCMD_BYTE(wav, 1)
READ_XCMD_BYTE(wav, 2)
@@ -1592,6 +1596,10 @@ void ply_xcmd_0C(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *tra
{
u32 unk;
+#ifdef UBFIX
+ unk = 0;
+#endif
+
READ_XCMD_BYTE(unk, 0) // UB: uninitialized variable
READ_XCMD_BYTE(unk, 1)
@@ -1611,6 +1619,7 @@ void ply_xcmd_0C(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *tra
void ply_xcmd_0D(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
u32 unk;
+
#ifdef UBFIX
unk = 0;
#endif
@@ -1703,14 +1712,14 @@ void SetPokemonCryProgress(u32 val)
gPokemonCrySong.unkCmd0DParam = val;
}
-int IsPokemonCryPlaying(struct MusicPlayerInfo *mplayInfo)
+bool32 IsPokemonCryPlaying(struct MusicPlayerInfo *mplayInfo)
{
struct MusicPlayerTrack *track = mplayInfo->tracks;
if (track->chan && track->chan->track == track)
- return 1;
+ return TRUE;
else
- return 0;
+ return FALSE;
}
void SetPokemonCryChorus(s8 val)
diff --git a/src/main_menu.c b/src/main_menu.c
index 38859b860..38e7648d0 100644
--- a/src/main_menu.c
+++ b/src/main_menu.c
@@ -1387,11 +1387,9 @@ static void Task_NewGameBirchSpeechSub_WaitForLotad(u8 taskId)
switch (tState)
{
case 0:
- if (sprite->callback == SpriteCallbackDummy)
- {
- sprite->oam.affineMode = ST_OAM_AFFINE_OFF;
- goto incrementStateAndTimer;
- }
+ if (sprite->callback != SpriteCallbackDummy)
+ return;
+ sprite->oam.affineMode = ST_OAM_AFFINE_OFF;
break;
case 1:
if (gTasks[sBirchSpeechMainTaskId].tTimer >= 96)
@@ -1400,14 +1398,11 @@ static void Task_NewGameBirchSpeechSub_WaitForLotad(u8 taskId)
if (gTasks[sBirchSpeechMainTaskId].tTimer < 0x4000)
gTasks[sBirchSpeechMainTaskId].tTimer++;
}
- break;
- incrementStateAndTimer:
- default:
- tState++;
- if (gTasks[sBirchSpeechMainTaskId].tTimer < 0x4000)
- gTasks[sBirchSpeechMainTaskId].tTimer++;
- break;
+ return;
}
+ tState++;
+ if (gTasks[sBirchSpeechMainTaskId].tTimer < 0x4000)
+ gTasks[sBirchSpeechMainTaskId].tTimer++;
}
#undef tState
diff --git a/src/mystery_gift.c b/src/mystery_gift.c
index 1e00a5788..afbe50e4d 100644
--- a/src/mystery_gift.c
+++ b/src/mystery_gift.c
@@ -558,14 +558,12 @@ bool32 MG_PrintTextOnWindow1AndWaitButton(u8 *textState, const u8 *str)
{
case 0:
AddTextPrinterToWindow1(str);
- goto inc;
+ (*textState)++;
+ break;
case 1:
DrawDownArrow(1, 0xD0, 0x14, 1, FALSE, &sDownArrowCounterAndYCoordIdx[0], &sDownArrowCounterAndYCoordIdx[1]);
if (({JOY_NEW(A_BUTTON | B_BUTTON);}))
- {
- inc:
(*textState)++;
- }
break;
case 2:
DrawDownArrow(1, 0xD0, 0x14, 1, TRUE, &sDownArrowCounterAndYCoordIdx[0], &sDownArrowCounterAndYCoordIdx[1]);
@@ -574,7 +572,7 @@ bool32 MG_PrintTextOnWindow1AndWaitButton(u8 *textState, const u8 *str)
return TRUE;
case 0xFF:
*textState = 2;
- break;
+ return FALSE;
}
return FALSE;
}
@@ -809,8 +807,6 @@ static bool32 ValidateCardOrNews(bool32 cardOrNews)
static bool32 HandleLoadWonderCardOrNews(u8 * state, bool32 cardOrNews)
{
- s32 v0;
-
switch (*state)
{
case 0:
@@ -827,20 +823,18 @@ static bool32 HandleLoadWonderCardOrNews(u8 * state, bool32 cardOrNews)
case 1:
if (cardOrNews == 0)
{
- v0 = FadeToWonderCardMenu();
- check:
- if (v0 != 0)
+ if (!FadeToWonderCardMenu())
{
- goto done;
+ return FALSE;
}
- break;
}
else
{
- v0 = FadeToWonderNewsMenu();
- goto check;
+ if (!FadeToWonderNewsMenu())
+ {
+ return FALSE;
+ }
}
- done:
*state = 0;
return TRUE;
}
diff --git a/src/overworld.c b/src/overworld.c
index 600333a47..979ebb74c 100644
--- a/src/overworld.c
+++ b/src/overworld.c
@@ -962,7 +962,7 @@ static u16 GetCenterScreenMetatileBehavior(void)
bool32 Overworld_IsBikingAllowed(void)
{
- if (!(gMapHeader.flags & MAP_ALLOW_CYCLING))
+ if (!gMapHeader.allowCycling)
return FALSE;
else
return TRUE;
@@ -1687,7 +1687,7 @@ void CB2_ReturnToFieldFadeFromBlack(void)
static void FieldCB_FadeTryShowMapPopup(void)
{
- if (SHOW_MAP_NAME_ENABLED && SecretBaseMapPopupEnabled() == TRUE)
+ if (gMapHeader.showMapName == TRUE && SecretBaseMapPopupEnabled() == TRUE)
ShowMapNamePopup();
FieldCB_WarpExitFadeFromBlack();
}
@@ -1933,7 +1933,7 @@ static bool32 LoadMapInStepsLocal(u8 *state, bool32 a2)
(*state)++;
break;
case 11:
- if (SHOW_MAP_NAME_ENABLED && SecretBaseMapPopupEnabled() == TRUE)
+ if (gMapHeader.showMapName == TRUE && SecretBaseMapPopupEnabled() == TRUE)
ShowMapNamePopup();
(*state)++;
break;
diff --git a/src/player_pc.c b/src/player_pc.c
index e5c3c5a18..a040ba5b6 100644
--- a/src/player_pc.c
+++ b/src/player_pc.c
@@ -1245,7 +1245,6 @@ static void ItemStorage_DoItemSwap(u8 taskId, bool8 a)
{
s16 *data;
u16 b;
- u8 c;
data = gTasks[taskId].data;
b = (playerPCItemPageInfo.itemsAbove + playerPCItemPageInfo.cursorPos);
@@ -1253,21 +1252,17 @@ static void ItemStorage_DoItemSwap(u8 taskId, bool8 a)
DestroyListMenuTask(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos));
if (!a)
{
- c = gUnknown_0203BCC4->unk666;
- if (c != b)
+ if (gUnknown_0203BCC4->unk666 != b)
{
- if (c != b - 1)
+ if (gUnknown_0203BCC4->unk666 != b - 1)
{
- MoveItemSlotInList(gSaveBlock1Ptr->pcItems, c, b);
+ MoveItemSlotInList(gSaveBlock1Ptr->pcItems, gUnknown_0203BCC4->unk666, b);
ItemStorage_RefreshListMenu();
}
}
- else
- goto LABEL_SKIP_CURSOR_DECREMENT;
}
if (gUnknown_0203BCC4->unk666 < b)
playerPCItemPageInfo.cursorPos--;
- LABEL_SKIP_CURSOR_DECREMENT:
SetSwapLineSpritesInvisibility(gUnknown_0203BCC4->spriteIds, 7, TRUE);
gUnknown_0203BCC4->unk666 = 0xFF;
data[5] = ListMenuInit(&gMultiuseListMenuTemplate, playerPCItemPageInfo.itemsAbove, playerPCItemPageInfo.cursorPos);
diff --git a/src/pokemon.c b/src/pokemon.c
index b4eb6f01a..28b402216 100644
--- a/src/pokemon.c
+++ b/src/pokemon.c
@@ -1642,6 +1642,7 @@ static const u8 sMonFrontAnimIdsTable[] =
[SPECIES_LUGIA - 1] = ANIM_GROW_IN_STAGES,
[SPECIES_HO_OH - 1] = ANIM_GROW_VIBRATE,
[SPECIES_CELEBI - 1] = ANIM_RISING_WOBBLE,
+ [SPECIES_TREECKO - 1] = ANIM_V_SQUISH_AND_BOUNCE,
[SPECIES_GROVYLE - 1] = ANIM_V_STRETCH,
[SPECIES_SCEPTILE - 1] = ANIM_V_SHAKE,
[SPECIES_TORCHIC - 1] = ANIM_H_STRETCH,
diff --git a/src/pokemon_animation.c b/src/pokemon_animation.c
index 14a17437c..500916b0e 100644
--- a/src/pokemon_animation.c
+++ b/src/pokemon_animation.c
@@ -2604,9 +2604,9 @@ static void RotateUpSlamDown_0(struct Sprite *sprite)
{
TryFlipX(sprite);
sprite->data[7]--;
- sprite->pos2.x = Cos(sprite->data[7], sprite->data[6]) + sprite->data[6];
+ sprite->pos2.x = sprite->data[6] + Cos(sprite->data[7], sprite->data[6]);
- sprite->pos2.y = -(Sin(sprite->data[7], sprite->data[6] += 0)); // dummy += 0 is needed to match
+ sprite->pos2.y = -(Sin(sprite->data[7], sprite->data[6]));
HandleSetAffineData(sprite, 256, 256, (sprite->data[7] - 128) << 8);
if (sprite->data[7] <= 120)
@@ -2634,9 +2634,9 @@ static void RotateUpSlamDown_2(struct Sprite *sprite)
{
TryFlipX(sprite);
sprite->data[7] += 2;
- sprite->pos2.x = Cos(sprite->data[7], sprite->data[6]) + sprite->data[6];
+ sprite->pos2.x = sprite->data[6] + Cos(sprite->data[7], sprite->data[6]);
- sprite->pos2.y = -(Sin(sprite->data[7], sprite->data[6] += 0)); // dummy += 0 is needed to match
+ sprite->pos2.y = -(Sin(sprite->data[7], sprite->data[6]));
HandleSetAffineData(sprite, 256, 256, (sprite->data[7] - 128) << 8);
if (sprite->data[7] >= 128)
@@ -4066,16 +4066,15 @@ static void VerticalShakeLowTwice(struct Sprite *sprite)
u8 var8 = sprite->data[2];
u8 var9 = sprite->data[6];
u8 var5 = sVerticalShakeData[sprite->data[5]][0];
- u8 var2 = var5;
if (var5 != (u8)-1)
var5 = sprite->data[7];
- else
- var5 = (u8)-1; // needed to match
var6 = sVerticalShakeData[sprite->data[5]][1];
var7 = 0;
- if (var2 != (u8)-2)
+ if (sVerticalShakeData[sprite->data[5]][0] != (u8)-2)
var7 = (var6 - var9) * var5 / var6;
+ else
+ var7 = 0;
if (var5 == (u8)-1)
{
diff --git a/src/pokemon_size_record.c b/src/pokemon_size_record.c
index 4beb9c83f..7c88e5bf1 100644
--- a/src/pokemon_size_record.c
+++ b/src/pokemon_size_record.c
@@ -97,7 +97,7 @@ static void FormatMonSizeRecord(u8 *string, u32 size)
{
#ifdef UNITS_IMPERIAL
//Convert size from centimeters to inches
- size = (double)(size * 10) / (CM_PER_INCH * 10);
+ size = (f64)(size * 10) / (CM_PER_INCH * 10);
#endif
string = ConvertIntToDecimalStringN(string, size / 10, STR_CONV_MODE_LEFT_ALIGN, 8);
diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c
index e5720d914..c82caf0b0 100644
--- a/src/pokemon_storage_system.c
+++ b/src/pokemon_storage_system.c
@@ -5437,15 +5437,16 @@ static bool32 WaitForWallpaperGfxLoad(void)
static void DrawWallpaper(const void *tilemap, s8 direction, u8 offset)
{
- s16 var = (offset * 2) + 3;
+ s16 var = offset * 256;
+ s16 var2 = (offset * 2) + 3;
s16 x = ((sStorage->bg2_X / 8 + 10) + (direction * 24)) & 0x3F;
- CopyRectToBgTilemapBufferRect(2, tilemap, 0, 0, 0x14, 0x12, x, 2, 0x14, 0x12, 0x11, offset << 8, var);
+ CopyRectToBgTilemapBufferRect(2, tilemap, 0, 0, 0x14, 0x12, x, 2, 0x14, 0x12, 0x11, var, var2);
if (direction == 0)
return;
if (direction > 0)
- x *= 1, x += 0x14; // x * 1 is needed to match, but can be safely removed as it makes no functional difference
+ x += 0x14;
else
x -= 4;
diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c
index 8f16321b2..31505b7c9 100644
--- a/src/pokemon_summary_screen.c
+++ b/src/pokemon_summary_screen.c
@@ -119,6 +119,11 @@ enum
SPRITE_ARR_ID_COUNT = SPRITE_ARR_ID_MOVE_SELECTOR2 + MOVE_SELECTOR_SPRITES_COUNT
};
+#define TILE_EMPTY_APPEAL_HEART 0x1039
+#define TILE_FILLED_APPEAL_HEART 0x103A
+#define TILE_FILLED_JAM_HEART 0x103C
+#define TILE_EMPTY_JAM_HEART 0x103D
+
static EWRAM_DATA struct PokemonSummaryScreenData
{
/*0x00*/ union {
@@ -2645,29 +2650,30 @@ static void DrawContestMoveHearts(u16 move)
if (move != MOVE_NONE)
{
+ // Draw appeal hearts
u8 effectValue = gContestEffects[gContestMoves[move].effect].appeal;
if (effectValue != 0xFF)
effectValue /= 10;
- for (i = 0; i < 8; i++)
+ for (i = 0; i < MAX_CONTEST_MOVE_HEARTS; i++)
{
if (effectValue != 0xFF && i < effectValue)
- tilemap[(i / 4 * 32) + (i & 3) + 0x1E6] = 0x103A;
+ tilemap[(i / 4 * 32) + (i & 3) + 0x1E6] = TILE_FILLED_APPEAL_HEART;
else
- tilemap[(i / 4 * 32) + (i & 3) + 0x1E6] = 0x1039;
+ tilemap[(i / 4 * 32) + (i & 3) + 0x1E6] = TILE_EMPTY_APPEAL_HEART;
}
+ // Draw jam hearts
effectValue = gContestEffects[gContestMoves[move].effect].jam;
-
if (effectValue != 0xFF)
effectValue /= 10;
- for (i = 0; i < 8; i++)
+ for (i = 0; i < MAX_CONTEST_MOVE_HEARTS; i++)
{
if (effectValue != 0xFF && i < effectValue)
- tilemap[(i / 4 * 32) + (i & 3) + 0x226] = 0x103C;
+ tilemap[(i / 4 * 32) + (i & 3) + 0x226] = TILE_FILLED_JAM_HEART;
else
- tilemap[(i / 4 * 32) + (i & 3) + 0x226] = 0x103D;
+ tilemap[(i / 4 * 32) + (i & 3) + 0x226] = TILE_EMPTY_JAM_HEART;
}
}
}
diff --git a/src/region_map.c b/src/region_map.c
index bec51ebf0..27e035199 100644
--- a/src/region_map.c
+++ b/src/region_map.c
@@ -1007,7 +1007,7 @@ static void InitMapBasedOnPlayerLocation(void)
break;
case MAP_TYPE_UNDERGROUND:
case MAP_TYPE_UNKNOWN:
- if (gMapHeader.flags & MAP_ALLOW_ESCAPING)
+ if (gMapHeader.allowEscaping)
{
mapHeader = Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->escapeWarp.mapGroup, gSaveBlock1Ptr->escapeWarp.mapNum);
gRegionMap->mapSecId = mapHeader->regionMapSectionId;
diff --git a/src/rotating_gate.c b/src/rotating_gate.c
index 22a0b0bdf..36c23c2a5 100644
--- a/src/rotating_gate.c
+++ b/src/rotating_gate.c
@@ -670,7 +670,8 @@ static void RotatingGate_RotateInDirection(u8 gateId, u32 rotationDirection)
}
else
{
- orientation = ++orientation % GATE_ORIENTATION_MAX;
+ orientation++;
+ orientation = orientation % GATE_ORIENTATION_MAX;
}
RotatingGate_SetGateOrientation(gateId, orientation);
}
diff --git a/src/roulette.c b/src/roulette.c
index cf27fdf9b..adde16199 100644
--- a/src/roulette.c
+++ b/src/roulette.c
@@ -275,7 +275,7 @@ struct RouletteTable
struct Taillow taillow;
u16 ballSpeed;
u16 baseTravelDist;
- float var1C;
+ f32 var1C;
};
struct GridSelection
@@ -340,13 +340,13 @@ static EWRAM_DATA struct Roulette
s16 ballTravelDistFast;
u16 ballTravelDistMed;
u16 ballTravelDistSlow;
- float ballAngle;
- float ballAngleSpeed;
- float ballAngleAccel;
- float ballDistToCenter;
- float ballFallSpeed;
- float ballFallAccel;
- float varA0;
+ f32 ballAngle;
+ f32 ballAngleSpeed;
+ f32 ballAngleAccel;
+ f32 ballDistToCenter;
+ f32 ballFallSpeed;
+ f32 ballFallAccel;
+ f32 varA0;
u8 playTaskId;
u8 spinTaskId;
u8 filler_1[2];
@@ -2896,7 +2896,9 @@ static const union AnimCmd sAnim_CreditDigit[] =
ANIMCMD_FRAME(18, 0), // 9
// BUG: Animation not terminated properly
// Doesn't matter in practice, the frames are set directly and not looped
- //ANIMCMD_END
+#ifdef BUGFIX
+ ANIMCMD_END
+#endif
};
static const union AnimCmd *const sAnims_CreditDigit[] =
@@ -3948,7 +3950,7 @@ static s16 UpdateBallRelativeWheelAngle(struct Sprite *sprite)
static u8 UpdateSlotBelowBall(struct Sprite *sprite)
{
- sRoulette->hitSlot = UpdateBallRelativeWheelAngle(sprite) / (float) DEGREES_PER_SLOT;
+ sRoulette->hitSlot = UpdateBallRelativeWheelAngle(sprite) / (f32)DEGREES_PER_SLOT;
return sRoulette->hitSlot;
}
@@ -4050,7 +4052,7 @@ static void SpriteCB_UnstickBall_ShroomishBallFall(struct Sprite *sprite)
static void SpriteCB_UnstickBall_Shroomish(struct Sprite *sprite)
{
- float slotOffset, ballFallDist, ballFallSpeed;
+ f32 slotOffset, ballFallDist, ballFallSpeed;
UpdateBallPos(sprite);
switch (sprite->sBallAngle)
@@ -4233,7 +4235,7 @@ static void SpriteCB_RollBall_TryLand(struct Sprite *sprite)
}
else // fall left
{
- float temp;
+ f32 temp;
sRoulette->ballAngleSpeed = (temp = sRouletteTables[sRoulette->tableId].var1C) * 2.0f;
slotId = (sRoulette->hitSlot + NUM_ROULETTE_SLOTS - 1) % NUM_ROULETTE_SLOTS;
sRoulette->stuckHitSlot = sRoulette->hitSlot;
@@ -4279,7 +4281,7 @@ static void SpriteCB_RollBall_Slow(struct Sprite *sprite)
{
// Reached slot to land in
sRoulette->ballAngleAccel = 0.0f;
- sRoulette->ballAngleSpeed -= (float)(sRouletteTables[sRoulette->tableId].wheelSpeed)
+ sRoulette->ballAngleSpeed -= (f32)(sRouletteTables[sRoulette->tableId].wheelSpeed)
/ (sRouletteTables[sRoulette->tableId].wheelDelay + 1);
sprite->sState = 4;
sprite->callback = SpriteCB_RollBall_TryLand;
@@ -4304,8 +4306,8 @@ static void SpriteCB_RollBall_Medium(struct Sprite *sprite)
if (sRoulette->ballDistToCenter > 40.0f)
return;
- sRoulette->ballFallSpeed = -(4.0f / (float)(sRoulette->ballTravelDistSlow));
- sRoulette->ballAngleAccel = -(sRoulette->ballAngleSpeed / (float)(sRoulette->ballTravelDistSlow));
+ sRoulette->ballFallSpeed = -(4.0f / (f32)(sRoulette->ballTravelDistSlow));
+ sRoulette->ballAngleAccel = -(sRoulette->ballAngleSpeed / (f32)(sRoulette->ballTravelDistSlow));
sprite->animNum = 2;
sprite->animBeginning = TRUE;
sprite->animEnded = FALSE;
@@ -4320,8 +4322,8 @@ static void SpriteCB_RollBall_Fast(struct Sprite *sprite)
return;
m4aSongNumStartOrChange(SE_ROULETTE_BALL2);
- sRoulette->ballFallSpeed = -(20.0f / (float)(sRoulette->ballTravelDistMed));
- sRoulette->ballAngleAccel = ((1.0f - sRoulette->ballAngleSpeed) / (float)(sRoulette->ballTravelDistMed));
+ sRoulette->ballFallSpeed = -(20.0f / (f32)(sRoulette->ballTravelDistMed));
+ sRoulette->ballAngleAccel = ((1.0f - sRoulette->ballAngleSpeed) / (f32)(sRoulette->ballTravelDistMed));
sprite->animNum = 1;
sprite->animBeginning = TRUE;
sprite->animEnded = FALSE;
@@ -4558,7 +4560,7 @@ static void SpriteCB_ShroomishShakeScreen(struct Sprite *sprite)
static void SpriteCB_ShroomishFall(struct Sprite *sprite)
{
- float timer;
+ f32 timer;
sprite->data[1]++;
timer = sprite->data[1];
sprite->pos2.y = timer * 0.039f * timer;
diff --git a/src/siirtc.c b/src/siirtc.c
index 5c153a841..5f4fc0a23 100644
--- a/src/siirtc.c
+++ b/src/siirtc.c
@@ -71,6 +71,7 @@ static bool8 sLocked;
static int WriteCommand(u8 value);
static int WriteData(u8 value);
static u8 ReadData();
+
static void EnableGpioPortRead();
static void DisableGpioPortRead();
@@ -98,8 +99,12 @@ u8 SiiRtcProbe(void)
errorCode = 0;
+#ifdef BUGFIX
+ if (!(rtc.status & SIIRTCINFO_24HOUR) || (rtc.status & SIIRTCINFO_POWER))
+#else
if ((rtc.status & (SIIRTCINFO_POWER | SIIRTCINFO_24HOUR)) == SIIRTCINFO_POWER
|| (rtc.status & (SIIRTCINFO_POWER | SIIRTCINFO_24HOUR)) == 0)
+#endif
{
// The RTC is in 12-hour mode. Reset it and switch to 24-hour mode.
@@ -131,7 +136,7 @@ u8 SiiRtcProbe(void)
bool8 SiiRtcReset(void)
{
- u8 result;
+ bool8 result;
struct SiiRtcInfo rtc;
if (sLocked == TRUE)
@@ -392,7 +397,11 @@ static int WriteCommand(u8 value)
GPIO_PORT_DATA = (temp << 1) | SCK_HI | CS_HI;
}
- // control reaches end of non-void function
+ // Nothing uses the returned value from this function,
+ // so the undefined behavior is harmless in the vanilla game.
+#ifdef UBFIX
+ return 0;
+#endif
}
static int WriteData(u8 value)
@@ -409,7 +418,11 @@ static int WriteData(u8 value)
GPIO_PORT_DATA = (temp << 1) | SCK_HI | CS_HI;
}
- // control reaches end of non-void function
+ // Nothing uses the returned value from this function,
+ // so the undefined behavior is harmless in the vanilla game.
+#ifdef UBFIX
+ return 0;
+#endif
}
static u8 ReadData()
@@ -418,6 +431,10 @@ static u8 ReadData()
u8 temp;
u8 value;
+#ifdef UBFIX
+ value = 0;
+#endif
+
for (i = 0; i < 8; i++)
{
GPIO_PORT_DATA = CS_HI;
@@ -428,7 +445,7 @@ static u8 ReadData()
GPIO_PORT_DATA = SCK_HI | CS_HI;
temp = ((GPIO_PORT_DATA & SIO_HI) >> 1);
- value = (value >> 1) | (temp << 7); // UB: accessing uninitialized var
+ value = (value >> 1) | (temp << 7);
}
return value;
@@ -436,10 +453,10 @@ static u8 ReadData()
static void EnableGpioPortRead()
{
- GPIO_PORT_READ_ENABLE = 1;
+ GPIO_PORT_READ_ENABLE = TRUE;
}
static void DisableGpioPortRead()
{
- GPIO_PORT_READ_ENABLE = 0;
+ GPIO_PORT_READ_ENABLE = FALSE;
}
diff --git a/src/strings.c b/src/strings.c
index 18cf31fb7..4987e32d2 100644
--- a/src/strings.c
+++ b/src/strings.c
@@ -1229,7 +1229,7 @@ ALIGNED(4) const u8 gText_Facility[] = _("{STR_VAR_1}");
const u8 gText_Give[] = _("Give");
const u8 gText_NoNeed[] = _("No need");
-const u8 gText_ColorLightShadowDarkGrey[] = _("{COLOR LIGHT_GRAY}{SHADOW DARK_GRAY}");
+const u8 gText_ColorLightShadowDarkGray[] = _("{COLOR LIGHT_GRAY}{SHADOW DARK_GRAY}");
const u8 gText_ColorBlue[] = _("{COLOR BLUE}");
const u8 gText_ColorTransparent[] = _("{HIGHLIGHT TRANSPARENT}{COLOR TRANSPARENT}");
const u8 gText_CDot[] = _("C.");
@@ -1239,9 +1239,9 @@ const u8 gText_PreliminaryResults[] = _("The preliminary results!");
const u8 gText_Round2Results[] = _("Round 2 results!");
const u8 gText_ContestantsMonWon[] = _("{STR_VAR_1}'s {STR_VAR_2} won!");
const u8 gText_CommunicationStandby[] = _("Communication standby…");
-const u8 gText_ColorDarkGrey[] = _("{COLOR DARK_GRAY}");
+const u8 gText_ColorDarkGray[] = _("{COLOR DARK_GRAY}");
const u8 gText_ColorDynamic6WhiteDynamic5[] = _("{COLOR_HIGHLIGHT_SHADOW DYNAMIC_COLOR6 WHITE DYNAMIC_COLOR5}"); // Unused
-const u8 gText_HighlightDarkGrey[] = _("{HIGHLIGHT DARK_GRAY}");
+const u8 gText_HighlightDarkGray[] = _("{HIGHLIGHT DARK_GRAY}");
const u8 gText_EmptySpace2[] = _(" "); // Unused
const u8 gText_DynColor2Male[] = _("{COLOR DYNAMIC_COLOR2}♂");
const u8 gText_DynColor1Female[] = _("{COLOR DYNAMIC_COLOR1}♀");
diff --git a/src/union_room.c b/src/union_room.c
index 06d3321c3..395650f28 100644
--- a/src/union_room.c
+++ b/src/union_room.c
@@ -319,8 +319,13 @@ static void StringExpandPlaceholders_AwaitingCommFromAnother(u8 *dst, u8 caseId)
case ACTIVITY_CONTEST_CUTE:
case ACTIVITY_CONTEST_SMART:
case ACTIVITY_CONTEST_TOUGH:
- // UB: argument *dst isn't used, instead it always prints to gStringVar4
+ // BUG: argument *dst isn't used, instead it always prints to gStringVar4
+ // not an issue in practice since Gamefreak never used any other arguments here besides gStringVar4
+ #ifndef BUGFIX
StringExpandPlaceholders(gStringVar4, sText_AwaitingCommunication);
+ #else
+ StringExpandPlaceholders(dst, sText_AwaitingCommunication);
+ #endif
break;
}
}
diff --git a/src/union_room_chat.c b/src/union_room_chat.c
index fb875bbb4..8e9f78280 100755
--- a/src/union_room_chat.c
+++ b/src/union_room_chat.c
@@ -2984,7 +2984,7 @@ static void HideKeyboardSwapMenu(void)
static void PrintChatMessage(u16 row, u8 *str, u8 colorIdx)
{
- // colorIdx: 0 = grey, 1 = red, 2 = green, 3 = blue
+ // colorIdx: 0 = gray, 1 = red, 2 = green, 3 = blue
u8 color[3];
color[0] = TEXT_COLOR_WHITE;
color[1] = colorIdx * 2 + 2;
diff --git a/src/wild_encounter.c b/src/wild_encounter.c
index 767fbe4e7..8bcb17605 100644
--- a/src/wild_encounter.c
+++ b/src/wild_encounter.c
@@ -162,7 +162,7 @@ static u8 ChooseWildMonIndex_Land(void)
return 8;
else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_8 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_9)
return 9;
- else if (rand == ENCOUNTER_CHANCE_LAND_MONS_SLOT_9)
+ else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_9 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_10)
return 10;
else
return 11;
@@ -215,7 +215,7 @@ static u8 ChooseWildMonIndex_Fishing(u8 rod)
wildMonIndex = 7;
if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_7 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_8)
wildMonIndex = 8;
- if (rand == ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_8)
+ if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_8 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_9)
wildMonIndex = 9;
break;
}
diff --git a/tools/aif2pcm/Makefile b/tools/aif2pcm/Makefile
index 77df29152..dd48a8759 100644
--- a/tools/aif2pcm/Makefile
+++ b/tools/aif2pcm/Makefile
@@ -6,12 +6,18 @@ LIBS = -lm
SRCS = main.c extended.c
+ifeq ($(OS),Windows_NT)
+EXE := .exe
+else
+EXE :=
+endif
+
.PHONY: all clean
-all: aif2pcm
+all: aif2pcm$(EXE)
@:
-aif2pcm: $(SRCS)
+aif2pcm$(EXE): $(SRCS)
$(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS)
clean:
diff --git a/tools/bin2c/Makefile b/tools/bin2c/Makefile
index 52806e39c..4dbfab94f 100644
--- a/tools/bin2c/Makefile
+++ b/tools/bin2c/Makefile
@@ -6,10 +6,16 @@ CFLAGS = -Wall -Wextra -Werror -std=c11 -O2
SRCS = bin2c.c
-all: bin2c
+ifeq ($(OS),Windows_NT)
+EXE := .exe
+else
+EXE :=
+endif
+
+all: bin2c$(EXE)
@:
-bin2c: $(SRCS)
+bin2c$(EXE): $(SRCS)
$(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS)
clean:
diff --git a/tools/gbafix/Makefile b/tools/gbafix/Makefile
index 91a60a9e4..efb016c97 100644
--- a/tools/gbafix/Makefile
+++ b/tools/gbafix/Makefile
@@ -3,10 +3,16 @@ CC ?= gcc
SRCS = gbafix.c
-all: gbafix
+ifeq ($(OS),Windows_NT)
+EXE := .exe
+else
+EXE :=
+endif
+
+all: gbafix$(EXE)
@:
-gbafix: $(SRCS)
+gbafix$(EXE): $(SRCS)
$(CC) $(SRCS) -o $@ $(LDFLAGS)
clean:
diff --git a/tools/gbagfx/Makefile b/tools/gbagfx/Makefile
index f0638414d..b4244aa8d 100644
--- a/tools/gbagfx/Makefile
+++ b/tools/gbagfx/Makefile
@@ -6,15 +6,21 @@ LIBS = -lpng -lz
SRCS = main.c convert_png.c gfx.c jasc_pal.c lz.c rl.c util.c font.c huff.c
+ifeq ($(OS),Windows_NT)
+EXE := .exe
+else
+EXE :=
+endif
+
.PHONY: all clean
-all: gbagfx
+all: gbagfx$(EXE)
@:
-gbagfx-debug: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h
+gbagfx-debug$(EXE): $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h
$(CC) $(CFLAGS) -DDEBUG $(SRCS) -o $@ $(LDFLAGS) $(LIBS)
-gbagfx: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h
+gbagfx$(EXE): $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h
$(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS)
clean:
diff --git a/tools/jsonproc/Makefile b/tools/jsonproc/Makefile
index 47198b171..eec73eb7b 100755
--- a/tools/jsonproc/Makefile
+++ b/tools/jsonproc/Makefile
@@ -8,12 +8,18 @@ SRCS := jsonproc.cpp
HEADERS := jsonproc.h inja.hpp nlohmann/json.hpp
+ifeq ($(OS),Windows_NT)
+EXE := .exe
+else
+EXE :=
+endif
+
.PHONY: all clean
-all: jsonproc
+all: jsonproc$(EXE)
@:
-jsonproc: $(SRCS) $(HEADERS)
+jsonproc$(EXE): $(SRCS) $(HEADERS)
$(CXX) $(CXXFLAGS) $(INCLUDES) $(SRCS) -o $@ $(LDFLAGS)
clean:
diff --git a/tools/mapjson/Makefile b/tools/mapjson/Makefile
index c1f703f9f..100e809c6 100644
--- a/tools/mapjson/Makefile
+++ b/tools/mapjson/Makefile
@@ -6,12 +6,18 @@ SRCS := json11.cpp mapjson.cpp
HEADERS := mapjson.h
+ifeq ($(OS),Windows_NT)
+EXE := .exe
+else
+EXE :=
+endif
+
.PHONY: all clean
-all: mapjson
+all: mapjson$(EXE)
@:
-mapjson: $(SRCS) $(HEADERS)
+mapjson$(EXE): $(SRCS) $(HEADERS)
$(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS)
clean:
diff --git a/tools/mapjson/mapjson.cpp b/tools/mapjson/mapjson.cpp
index 5e246ff24..d767b469e 100644
--- a/tools/mapjson/mapjson.cpp
+++ b/tools/mapjson/mapjson.cpp
@@ -395,7 +395,7 @@ string generate_map_constants_text(string groups_filepath, Json groups_data) {
int group_num = 0;
for (auto &group : groups_data["group_order"].array_items()) {
- text << "// Map Group " << group_num << "\n";
+ text << "// " << group.string_value() << "\n";
vector<Json> map_ids;
size_t max_length = 0;
diff --git a/tools/mid2agb/Makefile b/tools/mid2agb/Makefile
index 451d4b39f..553b7859e 100644
--- a/tools/mid2agb/Makefile
+++ b/tools/mid2agb/Makefile
@@ -6,12 +6,18 @@ SRCS := agb.cpp error.cpp main.cpp midi.cpp tables.cpp
HEADERS := agb.h error.h main.h midi.h tables.h
+ifeq ($(OS),Windows_NT)
+EXE := .exe
+else
+EXE :=
+endif
+
.PHONY: all clean
-all: mid2agb
+all: mid2agb$(EXE)
@:
-mid2agb: $(SRCS) $(HEADERS)
+mid2agb$(EXE): $(SRCS) $(HEADERS)
$(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS)
clean:
diff --git a/tools/preproc/Makefile b/tools/preproc/Makefile
index 8c48afea2..1507c973f 100644
--- a/tools/preproc/Makefile
+++ b/tools/preproc/Makefile
@@ -8,12 +8,18 @@ SRCS := asm_file.cpp c_file.cpp charmap.cpp preproc.cpp string_parser.cpp \
HEADERS := asm_file.h c_file.h char_util.h charmap.h preproc.h string_parser.h \
utf8.h
+ifeq ($(OS),Windows_NT)
+EXE := .exe
+else
+EXE :=
+endif
+
.PHONY: all clean
-all: preproc
+all: preproc$(EXE)
@:
-preproc: $(SRCS) $(HEADERS)
+preproc$(EXE): $(SRCS) $(HEADERS)
$(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS)
clean:
diff --git a/tools/preproc/c_file.cpp b/tools/preproc/c_file.cpp
index b996a048c..17a08cc9f 100644
--- a/tools/preproc/c_file.cpp
+++ b/tools/preproc/c_file.cpp
@@ -23,32 +23,59 @@
#include <stdexcept>
#include <string>
#include <memory>
+#include <cstring>
+#include <cerrno>
#include "preproc.h"
#include "c_file.h"
#include "char_util.h"
#include "utf8.h"
#include "string_parser.h"
-CFile::CFile(std::string filename) : m_filename(filename)
+CFile::CFile(const char * filenameCStr, bool isStdin)
{
- FILE *fp = std::fopen(filename.c_str(), "rb");
+ FILE *fp;
+
+ if (isStdin) {
+ fp = stdin;
+ m_filename = std::string{"<stdin>/"}.append(filenameCStr);
+ } else {
+ fp = std::fopen(filenameCStr, "rb");
+ m_filename = std::string(filenameCStr);
+ }
+
+ std::string& filename = m_filename;
if (fp == NULL)
FATAL_ERROR("Failed to open \"%s\" for reading.\n", filename.c_str());
- std::fseek(fp, 0, SEEK_END);
-
- m_size = std::ftell(fp);
+ m_size = 0;
+ m_buffer = (char *)malloc(CHUNK_SIZE + 1);
+ if (m_buffer == NULL) {
+ FATAL_ERROR("Failed to allocate memory to process file \"%s\"!", filename.c_str());
+ }
- if (m_size < 0)
- FATAL_ERROR("File size of \"%s\" is less than zero.\n", filename.c_str());
+ std::size_t numAllocatedBytes = CHUNK_SIZE + 1;
+ std::size_t bufferOffset = 0;
+ std::size_t count;
- m_buffer = new char[m_size + 1];
+ while ((count = std::fread(m_buffer + bufferOffset, 1, CHUNK_SIZE, fp)) != 0) {
+ if (!std::ferror(fp)) {
+ m_size += count;
- std::rewind(fp);
+ if (std::feof(fp)) {
+ break;
+ }
- if (std::fread(m_buffer, m_size, 1, fp) != 1)
- FATAL_ERROR("Failed to read \"%s\".\n", filename.c_str());
+ numAllocatedBytes += CHUNK_SIZE;
+ bufferOffset += CHUNK_SIZE;
+ m_buffer = (char *)realloc(m_buffer, numAllocatedBytes);
+ if (m_buffer == NULL) {
+ FATAL_ERROR("Failed to allocate memory to process file \"%s\"!", filename.c_str());
+ }
+ } else {
+ FATAL_ERROR("Failed to read \"%s\". (error: %s)", filename.c_str(), std::strerror(errno));
+ }
+ }
m_buffer[m_size] = 0;
@@ -56,6 +83,7 @@ CFile::CFile(std::string filename) : m_filename(filename)
m_pos = 0;
m_lineNum = 1;
+ m_isStdin = isStdin;
}
CFile::CFile(CFile&& other) : m_filename(std::move(other.m_filename))
@@ -64,13 +92,14 @@ CFile::CFile(CFile&& other) : m_filename(std::move(other.m_filename))
m_pos = other.m_pos;
m_size = other.m_size;
m_lineNum = other.m_lineNum;
+ m_isStdin = other.m_isStdin;
- other.m_buffer = nullptr;
+ other.m_buffer = NULL;
}
CFile::~CFile()
{
- delete[] m_buffer;
+ free(m_buffer);
}
void CFile::Preproc()
diff --git a/tools/preproc/c_file.h b/tools/preproc/c_file.h
index 7369aba85..49e633a18 100644
--- a/tools/preproc/c_file.h
+++ b/tools/preproc/c_file.h
@@ -30,7 +30,7 @@
class CFile
{
public:
- CFile(std::string filename);
+ CFile(const char * filenameCStr, bool isStdin);
CFile(CFile&& other);
CFile(const CFile&) = delete;
~CFile();
@@ -42,6 +42,7 @@ private:
long m_size;
long m_lineNum;
std::string m_filename;
+ bool m_isStdin;
bool ConsumeHorizontalWhitespace();
bool ConsumeNewline();
@@ -55,4 +56,6 @@ private:
void RaiseWarning(const char* format, ...);
};
+#define CHUNK_SIZE 4096
+
#endif // C_FILE_H
diff --git a/tools/preproc/preproc.cpp b/tools/preproc/preproc.cpp
index c9c6042df..eb2d4c8a2 100644
--- a/tools/preproc/preproc.cpp
+++ b/tools/preproc/preproc.cpp
@@ -103,9 +103,9 @@ void PreprocAsmFile(std::string filename)
}
}
-void PreprocCFile(std::string filename)
+void PreprocCFile(const char * filename, bool isStdin)
{
- CFile cFile(filename);
+ CFile cFile(filename, isStdin);
cFile.Preproc();
}
@@ -132,9 +132,9 @@ char* GetFileExtension(char* filename)
int main(int argc, char **argv)
{
- if (argc != 3)
+ if (argc < 3 || argc > 4)
{
- std::fprintf(stderr, "Usage: %s SRC_FILE CHARMAP_FILE", argv[0]);
+ std::fprintf(stderr, "Usage: %s SRC_FILE CHARMAP_FILE [-i]\nwhere -i denotes if input is from stdin\n", argv[0]);
return 1;
}
@@ -147,9 +147,17 @@ int main(int argc, char **argv)
if ((extension[0] == 's') && extension[1] == 0)
PreprocAsmFile(argv[1]);
- else if ((extension[0] == 'c' || extension[0] == 'i') && extension[1] == 0)
- PreprocCFile(argv[1]);
- else
+ else if ((extension[0] == 'c' || extension[0] == 'i') && extension[1] == 0) {
+ if (argc == 4) {
+ if (argv[3][0] == '-' && argv[3][1] == 'i' && argv[3][2] == '\0') {
+ PreprocCFile(argv[1], true);
+ } else {
+ FATAL_ERROR("unknown argument flag \"%s\".\n", argv[3]);
+ }
+ } else {
+ PreprocCFile(argv[1], false);
+ }
+ } else
FATAL_ERROR("\"%s\" has an unknown file extension of \"%s\".\n", argv[1], extension);
return 0;
diff --git a/tools/ramscrgen/Makefile b/tools/ramscrgen/Makefile
index 4e901a29c..a9375c87a 100644
--- a/tools/ramscrgen/Makefile
+++ b/tools/ramscrgen/Makefile
@@ -8,10 +8,16 @@ HEADERS := ramscrgen.h sym_file.h elf.h char_util.h
.PHONY: all clean
-all: ramscrgen
+ifeq ($(OS),Windows_NT)
+EXE := .exe
+else
+EXE :=
+endif
+
+all: ramscrgen$(EXE)
@:
-ramscrgen: $(SRCS) $(HEADERS)
+ramscrgen$(EXE): $(SRCS) $(HEADERS)
$(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS)
clean:
diff --git a/tools/rsfont/Makefile b/tools/rsfont/Makefile
index 930a92b36..0bc88a42b 100644
--- a/tools/rsfont/Makefile
+++ b/tools/rsfont/Makefile
@@ -8,10 +8,16 @@ SRCS = main.c convert_png.c util.c font.c
.PHONY: all clean
-all: rsfont
+ifeq ($(OS),Windows_NT)
+EXE := .exe
+else
+EXE :=
+endif
+
+all: rsfont$(EXE)
@:
-rsfont: $(SRCS) convert_png.h gfx.h global.h util.h font.h
+rsfont$(EXE): $(SRCS) convert_png.h gfx.h global.h util.h font.h
$(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS)
clean:
diff --git a/tools/scaninc/Makefile b/tools/scaninc/Makefile
index 52e663d8d..96d92f706 100644
--- a/tools/scaninc/Makefile
+++ b/tools/scaninc/Makefile
@@ -8,10 +8,16 @@ HEADERS := scaninc.h asm_file.h c_file.h source_file.h
.PHONY: all clean
-all: scaninc
+ifeq ($(OS),Windows_NT)
+EXE := .exe
+else
+EXE :=
+endif
+
+all: scaninc$(EXE)
@:
-scaninc: $(SRCS) $(HEADERS)
+scaninc$(EXE): $(SRCS) $(HEADERS)
$(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS)
clean: