summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRangi <35663410+Rangi42@users.noreply.github.com>2020-10-30 12:26:04 -0400
committerGitHub <noreply@github.com>2020-10-30 12:26:04 -0400
commitd831e40b99853c8e29e3939bb100b6ecf03b1028 (patch)
tree7d97e9277ee405a77046481100bf11adbc325367
parent26ddba8cfd8f035c06bd6419b64a6c4d7dbc226f (diff)
parentdb72c5103e807c4960ff62ca1764cac151288586 (diff)
Merge pull request #64 from Rangi42/unreferenced
Comment, remove, or revise many unreferenced labels
-rwxr-xr-x.travis/webhook.sh2
-rw-r--r--INSTALL.md75
-rw-r--r--audio/cries.asm8
-rw-r--r--audio/engine.asm15
-rw-r--r--audio/music/magnettrain.asm2
-rw-r--r--audio/sfx.asm10
-rw-r--r--constants/collision_constants.asm4
-rw-r--r--constants/engine_flags.asm2
-rw-r--r--constants/gfx_constants.asm1
-rw-r--r--constants/hardware_constants.asm11
-rw-r--r--constants/map_constants.asm2
-rw-r--r--constants/map_data_constants.asm2
-rw-r--r--constants/misc_constants.asm2
-rw-r--r--constants/pokemon_constants.asm1
-rw-r--r--constants/pokemon_data_constants.asm3
-rw-r--r--constants/serial_constants.asm5
-rw-r--r--constants/trainer_constants.asm2
-rw-r--r--constants/wram_constants.asm17
-rw-r--r--data/battle/effect_command_pointers.asm4
-rw-r--r--data/collision/collision_permissions.asm (renamed from data/collision_permissions.asm)0
-rw-r--r--data/collision/collision_stdscripts.asm (renamed from data/events/collision_stdscripts.asm)0
-rw-r--r--data/collision/field_move_blocks.asm (renamed from data/events/field_move_blocks.asm)3
-rw-r--r--data/decorations/decorations.asm5
-rw-r--r--data/events/special_pointers.asm16
-rw-r--r--data/maps/blocks.asm94
-rw-r--r--data/maps/landmarks.asm12
-rw-r--r--data/moves/animations.asm6
-rw-r--r--data/moves/tmhm_moves.asm1
-rw-r--r--data/phone/text/elm.asm1
-rw-r--r--data/phone/text/landmarks.asm89
-rw-r--r--data/player_names.asm6
-rw-r--r--data/pokemon/palettes.asm1
-rw-r--r--data/radio/oaks_pkmn_talk_routes.asm3
-rw-r--r--data/sprite_anims/framesets.asm18
-rw-r--r--data/sprite_anims/oam.asm11
-rw-r--r--data/text/battle.asm4
-rw-r--r--data/text/common_2.asm3
-rw-r--r--data/text/unused_sweet_honey.asm16
-rw-r--r--docs/bugs_and_glitches.md4
-rw-r--r--engine/battle/ai/items.asm8
-rw-r--r--engine/battle/battle_transition.asm36
-rw-r--r--engine/battle/core.asm60
-rw-r--r--engine/battle/effect_commands.asm19
-rw-r--r--engine/battle/menu.asm6
-rw-r--r--engine/battle/move_effects/baton_pass.asm2
-rw-r--r--engine/battle/move_effects/beat_up.asm20
-rw-r--r--engine/battle/move_effects/present.asm2
-rw-r--r--engine/battle_anims/anim_commands.asm7
-rw-r--r--engine/battle_anims/core.asm8
-rw-r--r--engine/battle_anims/functions.asm4
-rw-r--r--engine/debug/color_picker.asm16
-rw-r--r--engine/debug/debug_room.asm6
-rw-r--r--engine/events/bug_contest/judging.asm3
-rw-r--r--engine/events/daycare.asm2
-rw-r--r--engine/events/engine_flags.asm2
-rw-r--r--engine/events/field_moves.asm2
-rw-r--r--engine/events/heal_machine_anim.asm4
-rw-r--r--engine/events/magnet_train.asm2
-rw-r--r--engine/events/npc_trade.asm9
-rw-r--r--engine/events/overworld.asm9
-rw-r--r--engine/events/poisonstep.asm2
-rw-r--r--engine/events/print_unown_2.asm18
-rw-r--r--engine/events/prof_oaks_pc.asm10
-rw-r--r--engine/events/specials.asm13
-rw-r--r--engine/events/std_collision.asm2
-rw-r--r--engine/events/treemons.asm2
-rw-r--r--engine/games/card_flip.asm5
-rw-r--r--engine/games/dummy_game.asm12
-rw-r--r--engine/games/slot_machine.asm2
-rw-r--r--engine/games/unown_puzzle.asm6
-rw-r--r--engine/gfx/cgb_layouts.asm21
-rw-r--r--engine/gfx/color.asm72
-rw-r--r--engine/gfx/load_font.asm2
-rw-r--r--engine/gfx/load_pics.asm5
-rw-r--r--engine/gfx/sgb_layouts.asm10
-rw-r--r--engine/gfx/sprite_anims.asm4
-rw-r--r--engine/items/item_effects.asm52
-rw-r--r--engine/items/items.asm2
-rw-r--r--engine/items/pack.asm4
-rw-r--r--engine/items/tmhm.asm3
-rw-r--r--engine/link/init_list.asm4
-rw-r--r--engine/link/link.asm89
-rw-r--r--engine/link/mystery_gift.asm971
-rw-r--r--engine/link/mystery_gift_2.asm28
-rw-r--r--engine/link/mystery_gift_3.asm4
-rw-r--r--engine/link/time_capsule.asm12
-rw-r--r--engine/menus/intro_menu.asm11
-rw-r--r--engine/menus/main_menu.asm15
-rw-r--r--engine/menus/menu_2.asm21
-rw-r--r--engine/menus/naming_screen.asm3
-rw-r--r--engine/menus/trainer_card.asm15
-rw-r--r--engine/movie/credits.asm2
-rw-r--r--engine/movie/evolution_animation.asm1
-rw-r--r--engine/movie/intro.asm3
-rw-r--r--engine/movie/trade_animation.asm4
-rw-r--r--engine/overworld/cmd_queue.asm4
-rw-r--r--engine/overworld/decorations.asm31
-rw-r--r--engine/overworld/events.asm60
-rw-r--r--engine/overworld/load_map_part.asm1
-rw-r--r--engine/overworld/map_object_action.asm3
-rw-r--r--engine/overworld/map_objects.asm13
-rw-r--r--engine/overworld/map_setup.asm2
-rw-r--r--engine/overworld/overworld.asm2
-rw-r--r--engine/overworld/player_movement.asm2
-rw-r--r--engine/overworld/scripting.asm24
-rw-r--r--engine/overworld/time.asm16
-rw-r--r--engine/phone/phone.asm6
-rw-r--r--engine/phone/scripts/elm.asm2
-rw-r--r--engine/phone/scripts/generic.asm7
-rw-r--r--engine/pokedex/pokedex.asm10
-rw-r--r--engine/pokegear/pokegear.asm16
-rw-r--r--engine/pokegear/radio.asm9
-rw-r--r--engine/pokemon/bills_pc.asm52
-rw-r--r--engine/pokemon/breedmon_level_growth.asm4
-rw-r--r--engine/pokemon/evolve.asm4
-rw-r--r--engine/pokemon/mail.asm21
-rw-r--r--engine/pokemon/mail_2.asm14
-rw-r--r--engine/pokemon/move_mon.asm7
-rw-r--r--engine/pokemon/party_menu.asm6
-rw-r--r--engine/pokemon/switchpartymons.asm20
-rw-r--r--engine/printer/printer.asm4
-rw-r--r--engine/printer/printer_serial.asm6
-rw-r--r--engine/smallflag.asm4
-rw-r--r--engine/tilesets/tileset_anims.asm14
-rw-r--r--gfx/font.asm4
-rw-r--r--gfx/mail.asm7
-rw-r--r--gfx/mail/sentret.pngbin116 -> 135 bytes
-rw-r--r--gfx/mail/unused_grass.pngbin92 -> 0 bytes
-rw-r--r--gfx/tileset_palette_maps.asm2
-rw-r--r--home/audio.asm2
-rw-r--r--home/battle.asm4
-rw-r--r--home/decompress.asm9
-rw-r--r--home/game_time.asm4
-rw-r--r--home/gfx.asm8
-rw-r--r--home/init.asm14
-rw-r--r--home/joypad.asm4
-rw-r--r--home/map.asm49
-rw-r--r--home/menu.asm3
-rw-r--r--home/movement.asm2
-rw-r--r--home/names.asm4
-rw-r--r--home/print_bcd.asm7
-rw-r--r--home/print_num.asm5
-rw-r--r--home/serial.asm96
-rw-r--r--home/text.asm28
-rw-r--r--home/video.asm22
-rw-r--r--home/warp_connection.asm5
-rw-r--r--home/window.asm2
-rw-r--r--hram.asm14
-rw-r--r--macros/code.asm1
-rw-r--r--macros/data.asm4
-rw-r--r--macros/gfx.asm8
-rw-r--r--macros/scripts/audio.asm5
-rw-r--r--macros/scripts/battle_anims.asm4
-rw-r--r--macros/scripts/maps.asm2
-rw-r--r--macros/wram.asm1
-rw-r--r--main.asm2
-rw-r--r--maps/AzaleaTown.asm3
-rw-r--r--maps/BlackthornDragonSpeechHouse.asm6
-rw-r--r--maps/BlackthornGym1F.asm2
-rw-r--r--maps/BurnedTowerB1F.asm2
-rw-r--r--maps/CeladonDeptStore6F.asm3
-rw-r--r--maps/CeladonGameCorner.asm3
-rw-r--r--maps/CeladonMansion3F.asm3
-rw-r--r--maps/CeladonMansionRoof.asm6
-rw-r--r--maps/CherrygroveCity.asm2
-rw-r--r--maps/CianwoodCity.asm4
-rw-r--r--maps/DragonsDenB1F.asm2
-rw-r--r--maps/EarlsPokemonAcademy.asm6
-rw-r--r--maps/EcruteakCity.asm3
-rw-r--r--maps/ElmsHouse.asm6
-rw-r--r--maps/ElmsLab.asm5
-rw-r--r--maps/GoldenrodBikeShop.asm3
-rw-r--r--maps/GoldenrodDeptStore2F.asm6
-rw-r--r--maps/GoldenrodDeptStore5F.asm2
-rw-r--r--maps/GoldenrodFlowerShop.asm9
-rw-r--r--maps/GoldenrodUnderground.asm2
-rw-r--r--maps/IlexForest.asm3
-rw-r--r--maps/KurtsHouse.asm1
-rw-r--r--maps/LakeOfRageMagikarpHouse.asm6
-rw-r--r--maps/LavRadioTower1F.asm3
-rw-r--r--maps/LavenderNameRater.asm3
-rw-r--r--maps/MahoganyRedGyaradosSpeechHouse.asm6
-rw-r--r--maps/ManiasHouse.asm5
-rw-r--r--maps/NewBarkTown.asm2
-rw-r--r--maps/OaksLab.asm2
-rw-r--r--maps/OlivineGoodRodHouse.asm3
-rw-r--r--maps/OlivineGym.asm2
-rw-r--r--maps/OlivineLighthouse6F.asm7
-rw-r--r--maps/PlayersHouse2F.asm3
-rw-r--r--maps/Pokecenter2F.asm14
-rw-r--r--maps/RadioTower2F.asm3
-rw-r--r--maps/Route12SuperRodHouse.asm3
-rw-r--r--maps/Route25.asm2
-rw-r--r--maps/Route29.asm3
-rw-r--r--maps/Route2NuggetHouse.asm3
-rw-r--r--maps/Route32.asm20
-rw-r--r--maps/Route34.asm4
-rw-r--r--maps/Route36.asm2
-rw-r--r--maps/Route36NationalParkGate.asm9
-rw-r--r--maps/Route39Farmhouse.asm2
-rw-r--r--maps/Route41.asm3
-rw-r--r--maps/Route43Gate.asm2
-rw-r--r--maps/Route45.asm2
-rw-r--r--maps/RuinsOfAlphOutside.asm2
-rw-r--r--maps/RuinsOfAlphResearchCenter.asm4
-rw-r--r--maps/TeamRocketBaseB2F.asm2
-rw-r--r--maps/TinTower9F.asm6
-rw-r--r--maps/TradeCenter.asm7
-rw-r--r--maps/UnionCave1F.asm3
-rw-r--r--maps/VermilionFishingSpeechHouse.asm3
-rw-r--r--sram.asm26
-rw-r--r--wram.asm417
212 files changed, 1774 insertions, 1696 deletions
diff --git a/.travis/webhook.sh b/.travis/webhook.sh
index 49a9a471..cd41fc91 100755
--- a/.travis/webhook.sh
+++ b/.travis/webhook.sh
@@ -4,7 +4,7 @@ set -e
root="$(readlink -e "$(dirname "$0")/..")"
# Report unnamed symbols
-content="$("$root/tools/unnamed.py" -r "$root" "$root/pokegold.sym" | head)"
+content="$("$root/tools/unnamed.py" "$root/pokegold.sym" | head -n 20)"
curl -H 'Content-Type: application/json' -X POST "$POKEGOLD_DISCORD_WEBHOOK_URL" -d@- << EOF
{
diff --git a/INSTALL.md b/INSTALL.md
index 3f775962..defeb7e3 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -4,10 +4,17 @@ These instructions explain how to set up the tools required to build **pokegold*
If you run into trouble, ask for help on IRC or Discord (see [README.md](README.md)).
+
## Windows 10
Download and install [**Windows Subsystem for Linux**](https://docs.microsoft.com/en-us/windows/wsl/install-win10). Then open the **WSL terminal**.
+Update WSL's software before continuing. If you chose Debian, Ubuntu, or another distribution that uses `apt-get`, then enter this command:
+
+```bash
+apt-get update && apt-get upgrade
+```
+
WSL has its own file system that's not accessible from Windows, but Windows files *are* accessible from WSL. So you're going to want to install pokegold within Windows. You'll have to change the **current working directory** every time you open WSL.
For example, if you want to store pokegold in **C:\Users\\*\<user>*\Desktop**, enter this command:
@@ -18,9 +25,10 @@ cd /mnt/c/Users/<user>/Desktop
(The Windows `C:\` drive is called `/mnt/c/` in WSL. Replace *\<user>* in the example path with your username.)
-If successful, follow [the regular Linux instructions](#linux) below for whatever distribution you installed for WSL.
+If this works, then follow [the instructions for **Linux**](#linux) below for whatever distribution you installed for WSL.
+
+Otherwise, continue reading below for [the older Windows instructions](#windows).
-Otherwise, continue reading below for [the regular Windows instructions](#windows).
## Windows
@@ -34,9 +42,9 @@ Run setup and leave the default settings. At the "**Select Packages**" step, cho
Double click on the text that says "**Skip**" next to each package to select the most recent version to install.
-Then download [**rgbds**](https://github.com/gbdev/rgbds/releases/): the latest **win64.zip** or **win32.zip** release. Extract it and put all the `exe` and `dll` files individually in **C:\cygwin64\usr\local\bin**.
+Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/windows) for Windows with Cygwin to install **rgbds 0.4.1**.
-**Note: If you already have an older rgbds, you will need to update to 0.4.1.** Ignore this if you have never installed rgbds before. If a version newer than 0.4.1 does not work, try downloading 0.4.1.
+**Note:** If you already have an older rgbds, you will need to update to 0.4.1. Ignore this if you have never installed rgbds before. If a version newer than 0.4.1 does not work, try downloading 0.4.1.
Now open the **Cygwin terminal** and enter the following commands.
@@ -52,20 +60,18 @@ cd /cygdrive/c/Users/<user>/Desktop
Now you're ready to [build **pokegold**](#build-pokegold).
+
## macOS
Install [**Homebrew**](https://brew.sh/). Follow the official instructions.
-Open **Terminal** and enter the following commands.
+Open **Terminal** and prepare to enter commands.
-To install **rgbds**:
-
-```bash
-brew install rgbds
-```
+Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/macos) for macOS to install **rgbds 0.4.1**.
Now you're ready to [build **pokegold**](#build-pokegold).
+
## Linux
Open **Terminal** and enter the following commands, depending on which distro you're using.
@@ -78,30 +84,46 @@ To install the software required for **pokegold**:
sudo apt-get install make gcc git
```
-To install **rgbds**:
+Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/source) to build **rgbds 0.4.1** from source.
+
+### OpenSUSE
+
+To install the software required for **pokegold**:
```bash
-sudo apt-get install pkg-config flex bison libpng-dev
-git clone -b v0.4.1 --depth=1 https://github.com/gbdev/rgbds
-sudo make -C rgbds install
+sudo zypper install make gcc git
```
-### OpenSUSE
+Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/source) to build **rgbds 0.4.1** from source.
+
+### Arch Linux
To install the software required for **pokegold**:
```bash
-sudo zypper install make gcc git
+sudo pacman -S make gcc git rgbds
+```
+
+Then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/arch) for Arch Linux to install **rgbds 0.4.1**.
+
+If you want to compile and install **rgbds** yourself instead, then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/source) to build **rgbds 0.4.1** from source.
+
+### Termux
+
+To install the software required for **pokegold**:
+
+```bash
+sudo apt install make clang git sed
```
To install **rgbds**:
```bash
-sudo zypper install pkg-config flex bison libpng16-devel
-git clone -b v0.4.1 --depth=1 https://github.com/gbdev/rgbds
-sudo make -C rgbds install
+sudo apt install rgbds
```
+If you want to compile and install **rgbds** yourself instead, then follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/source) to build **rgbds 0.4.1** from source.
+
### Other distros
If your distro is not listed here, try to find the required software in its repositories:
@@ -111,22 +133,11 @@ If your distro is not listed here, try to find the required software in its repo
- `git`
- `rgbds`
-If `rgbds` is not available, you'll also need these:
-
-- `pkg-config`
-- `flex`
-- `bison`
-- `libpng` (and the development headers)
-
-To install **rgbds**:
-
-```bash
-git clone -b v0.4.1 --depth=1 https://github.com/gbdev/rgbds
-sudo make -C rgbds install
-```
+If `rgbds` is not available, you'll need to follow the [**rgbds** instructions](https://rgbds.gbdev.io/install/source) to build **rgbds 0.4.1** from source.
Now you're ready to [build **pokegold**](#build-pokegold).
+
## Build pokegold
To download the **pokegold** source files:
diff --git a/audio/cries.asm b/audio/cries.asm
index 352ce321..cf2ead18 100644
--- a/audio/cries.asm
+++ b/audio/cries.asm
@@ -464,7 +464,7 @@ Cry_Sentret_Ch6:
square_note 8, 15, 1, 1824
sound_ret
-Cry_Sentret_Ch8:
+Cry_Sentret_Ch8: ; unreferenced
noise_note 8, 3, -3, 0
noise_note 8, 9, 2, 0
sound_ret
@@ -1082,7 +1082,7 @@ Cry_Weepinbell:
channel 6, Cry_Weepinbell_Ch6
channel 8, Cry_Weepinbell_Ch8
-Cry_Unused_Ch5:
+Cry_Unused_Ch5: ; unreferenced
duty_cycle_pattern 3, 3, 0, 0
square_note 15, 14, 0, 1920
square_note 15, 15, 0, 1924
@@ -1092,7 +1092,7 @@ Cry_Unused_Ch5:
square_note 8, 7, 1, 1924
sound_ret
-Cry_Unused_Ch6:
+Cry_Unused_Ch6: ; unreferenced
duty_cycle_pattern 0, 0, 1, 1
square_note 15, 10, 0, 1857
square_note 15, 11, 0, 1859
@@ -1102,7 +1102,7 @@ Cry_Unused_Ch6:
square_note 8, 3, 1, 1862
sound_ret
-Cry_Unused_Ch8:
+Cry_Unused_Ch8: ; unreferenced
noise_note 2, 15, 2, 76
noise_note 6, 14, 0, 58
noise_note 15, 13, 0, 58
diff --git a/audio/engine.asm b/audio/engine.asm
index ea3e467e..d394067c 100644
--- a/audio/engine.asm
+++ b/audio/engine.asm
@@ -38,15 +38,16 @@ _InitSound::
dec e
jr nz, .clearsound
- ld hl, wChannels ; start of channel data
- ld de, wChannelsEnd - wChannels ; length of area to clear (entire sound wram area)
-.clearchannels
+ ld hl, wAudio
+ ld de, wAudioEnd - wAudio
+.clearaudio
xor a
ld [hli], a
dec de
ld a, e
or d
- jr nz, .clearchannels
+ jr nz, .clearaudio
+
ld a, MAX_VOLUME
ld [wVolume], a
call MusicOn
@@ -1614,9 +1615,9 @@ Music_JumpIf:
ret
MusicEE:
+; unused
; conditional jump
; checks a byte in ram corresponding to the current channel
-; doesn't seem to be set by any commands
; params: 2
; ll hh ; pointer
@@ -1666,15 +1667,15 @@ MusicEE:
ret
MusicF9:
+; unused
; sets some flag
-; seems to be unused
; params: 0
ld a, TRUE
ld [wUnusedMusicF9Flag], a
ret
MusicE2:
-; seems to have been dummied out
+; unused
; params: 1
call GetMusicByte
ld hl, CHANNEL_FIELD2C
diff --git a/audio/music/magnettrain.asm b/audio/music/magnettrain.asm
index f0c49d59..428acc4b 100644
--- a/audio/music/magnettrain.asm
+++ b/audio/music/magnettrain.asm
@@ -246,7 +246,7 @@ Music_MagnetTrain_Ch4:
drum_note 12, 16
sound_ret
-.sub1: ; unused
+.sub1: ; unreferenced
drum_note 9, 1
drum_note 8, 1
drum_note 8, 1
diff --git a/audio/sfx.asm b/audio/sfx.asm
index 166c726e..5dcb27cf 100644
--- a/audio/sfx.asm
+++ b/audio/sfx.asm
@@ -21,7 +21,8 @@ Sfx_Menu:
Sfx_ReadText:
Sfx_ReadText2:
channel_count 1
- channel 5, Sfx_ReadText2_Ch5
+ channel 5, Sfx_ReadText_Ch5
+ assert Sfx_ReadText_Ch5 == Sfx_ReadText2_Ch5
Sfx_Poison:
channel_count 1
@@ -467,6 +468,7 @@ Sfx_Unknown5F:
channel 6, Sfx_Unknown5F_Ch6
Sfx_Sandstorm:
channel 8, Sfx_Sandstorm_Ch8
+ assert Sfx_Sandstorm_Ch8 == Sfx_Unknown5F_Ch8
Sfx_HangUp:
channel_count 1
@@ -490,6 +492,10 @@ Sfx_DexFanfare5079:
channel 6, Sfx_LevelUp_Ch6
channel 7, Sfx_LevelUp_Ch7
channel 8, Sfx_LevelUp_Ch8
+ assert Sfx_LevelUp_Ch5 == Sfx_DexFanfare5079_Ch5
+ assert Sfx_LevelUp_Ch6 == Sfx_DexFanfare5079_Ch6
+ assert Sfx_LevelUp_Ch7 == Sfx_DexFanfare5079_Ch7
+ assert Sfx_LevelUp_Ch8 == Sfx_DexFanfare5079_Ch8
Sfx_LevelUp_Ch5:
Sfx_DexFanfare5079_Ch5:
@@ -942,7 +948,7 @@ Sfx_Fanfare2:
channel 6, Sfx_Fanfare2_Ch6
channel 8, Sfx_Fanfare2_Ch8
-Sfx_Unused:
+Sfx_Unused: ; unreferenced
channel_count 4
channel 5, Sfx_Unused_Ch5
channel 6, Sfx_Unused_Ch6
diff --git a/constants/collision_constants.asm b/constants/collision_constants.asm
index c965b2f5..54d6ac54 100644
--- a/constants/collision_constants.asm
+++ b/constants/collision_constants.asm
@@ -1,11 +1,11 @@
-; collision permissions (see data/collision_permissions.asm)
+; collision permissions (see data/collision/collision_permissions.asm)
LAND_TILE EQU $00
WATER_TILE EQU $01
WALL_TILE EQU $0f
TALK EQU $10
; collision data types (see data/tilesets/*_collision.asm)
-; TileCollisionTable indexes (see data/collision_permissions.asm)
+; TileCollisionTable indexes (see data/collision/collision_permissions.asm)
COLL_FLOOR EQU $00
COLL_01 EQU $01 ; garbage
COLL_03 EQU $03 ; garbage
diff --git a/constants/engine_flags.asm b/constants/engine_flags.asm
index 2f8f9260..d97c8033 100644
--- a/constants/engine_flags.asm
+++ b/constants/engine_flags.asm
@@ -15,7 +15,7 @@
const ENGINE_MOM_SAVING_MONEY
const ENGINE_MOM_ACTIVE
; wUnusedTwoDayTimerOn
- const ENGINE_0A
+ const ENGINE_UNUSED_TWO_DAY_TIMER_ON
; wStatusFlags
const ENGINE_POKEDEX
const ENGINE_UNOWN_DEX
diff --git a/constants/gfx_constants.asm b/constants/gfx_constants.asm
index dde6a63e..cd03d860 100644
--- a/constants/gfx_constants.asm
+++ b/constants/gfx_constants.asm
@@ -21,6 +21,7 @@ SCREEN_META_WIDTH EQU 6 ; metatiles
SCREEN_META_HEIGHT EQU 5 ; metatiles
SURROUNDING_WIDTH EQU SCREEN_META_WIDTH * METATILE_WIDTH ; tiles
SURROUNDING_HEIGHT EQU SCREEN_META_HEIGHT * METATILE_WIDTH ; tiles
+MAP_CONNECTION_PADDING_WIDTH EQU 3 ; metatiles
HP_BAR_LENGTH EQU 6 ; tiles
EXP_BAR_LENGTH EQU 8 ; tiles
diff --git a/constants/hardware_constants.asm b/constants/hardware_constants.asm
index 970acd2f..f9014380 100644
--- a/constants/hardware_constants.asm
+++ b/constants/hardware_constants.asm
@@ -71,10 +71,10 @@ rTIMA EQU $ff05 ; Timer counter (R/W)
rTMA EQU $ff06 ; Timer Modulo (R/W)
rTAC EQU $ff07 ; Timer Control (R/W)
rTAC_ON EQU 2
-rTAC_4096_HZ EQU 0
-rTAC_262144_HZ EQU 1
-rTAC_65536_HZ EQU 2
-rTAC_16384_HZ EQU 3
+rTAC_4096_HZ EQU %00
+rTAC_262144_HZ EQU %01
+rTAC_65536_HZ EQU %10
+rTAC_16384_HZ EQU %11
rIF EQU $ff0f ; Interrupt Flag (R/W)
rNR10 EQU $ff10 ; Channel 1 Sweep register (R/W)
rNR11 EQU $ff11 ; Channel 1 Sound length/Wave pattern duty (R/W)
@@ -147,6 +147,9 @@ rHDMA3 EQU $ff53 ; CGB Mode Only - New DMA Destination, High
rHDMA4 EQU $ff54 ; CGB Mode Only - New DMA Destination, Low
rHDMA5 EQU $ff55 ; CGB Mode Only - New DMA Length/Mode/Start
rRP EQU $ff56 ; CGB Mode Only - Infrared Communications Port
+rRP_LED_ON EQU 0
+rRP_RECEIVING EQU 1
+rRP_ENABLE_READ_MASK EQU %11000000
rBGPI EQU $ff68 ; CGB Mode Only - Background Palette Index
rBGPI_AUTO_INCREMENT EQU 7 ; increment rBGPI after write to rBGPD
rBGPD EQU $ff69 ; CGB Mode Only - Background Palette Data
diff --git a/constants/map_constants.asm b/constants/map_constants.asm
index 33b1e25b..9e80b883 100644
--- a/constants/map_constants.asm
+++ b/constants/map_constants.asm
@@ -1,5 +1,5 @@
newgroup: MACRO
-const_value = const_value + 1
+ const_skip
__map_value__ = 1
ENDM
diff --git a/constants/map_data_constants.asm b/constants/map_data_constants.asm
index 386d7229..1679e6cd 100644
--- a/constants/map_data_constants.asm
+++ b/constants/map_data_constants.asm
@@ -66,7 +66,7 @@ NUM_MAP_PALETTES EQU const_value
shift_const NORTH
; SpawnPoints indexes (see data/maps/spawn_points.asm)
-const_value = -1
+ const_def -1
const SPAWN_N_A
const SPAWN_HOME
const SPAWN_DEBUG
diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm
index ca9bc937..3847cf89 100644
--- a/constants/misc_constants.asm
+++ b/constants/misc_constants.asm
@@ -18,6 +18,8 @@ GS_VERSION EQU 0
ELIF DEF(_SILVER)
GS_VERSION EQU 1
ENDC
+; Pokémon Pikachu 2, a step counter / virtual pet device (used by Mystery Gift)
+POKEMON_PIKACHU_2_VERSION EQU 3
; save file corruption check values
SAVE_CHECK_VALUE_1 EQU 99
diff --git a/constants/pokemon_constants.asm b/constants/pokemon_constants.asm
index d336521a..068998e2 100644
--- a/constants/pokemon_constants.asm
+++ b/constants/pokemon_constants.asm
@@ -12,6 +12,7 @@
; - AlphabeticalPokedexOrder (see data/pokemon/dex_order_alpha.asm)
; - NewPokedexOrder (see data/pokemon/dex_order_new.asm)
; - Pokered_MonIndices (see data/pokemon/gen1_order.asm)
+; - Footprints (see gfx/footprints.asm)
const_def 1
const BULBASAUR ; 01
const IVYSAUR ; 02
diff --git a/constants/pokemon_data_constants.asm b/constants/pokemon_data_constants.asm
index 7729161e..6946b692 100644
--- a/constants/pokemon_data_constants.asm
+++ b/constants/pokemon_data_constants.asm
@@ -160,7 +160,7 @@ NUM_TREEMON_SETS EQU const_value
const TREEMON_SCORE_RARE ; 2
; ChangeHappiness arguments (see data/happiness_changes.asm)
-const_value = 1
+ const_def 1
const HAPPINESS_GAINLEVEL ; 01
const HAPPINESS_USEDITEM ; 02
const HAPPINESS_USEDXITEM ; 03
@@ -179,7 +179,6 @@ const_value = 1
const HAPPINESS_ENERGYROOT ; 10
const HAPPINESS_REVIVALHERB ; 11
const HAPPINESS_GROOMING ; 12
- const HAPPINESS_GAINLEVELATHOME ; 13
; significant happiness values
BASE_HAPPINESS EQU 70
diff --git a/constants/serial_constants.asm b/constants/serial_constants.asm
index 81eadbf4..ddb6f4fd 100644
--- a/constants/serial_constants.asm
+++ b/constants/serial_constants.asm
@@ -29,3 +29,8 @@ SERIAL_NO_DATA_BYTE EQU $fe
SERIAL_PATCH_LIST_PART_TERMINATOR EQU $ff
SERIAL_PREAMBLE_LENGTH EQU 6
+
+; timeout duration after exchanging a byte
+SERIAL_LINK_BYTE_TIMEOUT EQU $5000
+
+MAX_MYSTERY_GIFT_PARTNERS EQU 5
diff --git a/constants/trainer_constants.asm b/constants/trainer_constants.asm
index deb8791a..3e685928 100644
--- a/constants/trainer_constants.asm
+++ b/constants/trainer_constants.asm
@@ -3,7 +3,7 @@ __trainer_class__ = 0
trainerclass: MACRO
\1 EQU __trainer_class__
__trainer_class__ = __trainer_class__ + 1
-const_value = 1
+ const_def 1
ENDM
; trainer class ids
diff --git a/constants/wram_constants.asm b/constants/wram_constants.asm
index 9150cc21..131621d3 100644
--- a/constants/wram_constants.asm
+++ b/constants/wram_constants.asm
@@ -21,8 +21,12 @@ AUTO_INPUT EQU $ff
const TEMPMON ; 3
const WILDMON ; 4
-; wGameTimerPause::
-GAMETIMERPAUSE_TIMER_PAUSED_F EQU 0
+; wGameTimerPaused::
+GAME_TIMER_PAUSED_F EQU 0
+
+; wJoypadDisable::
+JOYPAD_DISABLE_MON_FAINT_F EQU 6
+JOYPAD_DISABLE_SGB_TRANSFER_F EQU 7
; wOptions::
TEXT_DELAY_MASK EQU %111
@@ -79,11 +83,12 @@ LEFT_MASK EQU 1 << LEFT
RIGHT_MASK EQU 1 << RIGHT
; wFacingDirection::
+ const_def NUM_DIRECTIONS - 1, -1
+ shift_const FACE_DOWN ; 8
+ shift_const FACE_UP ; 4
+ shift_const FACE_LEFT ; 2
+ shift_const FACE_RIGHT ; 1
FACE_CURRENT EQU 0
-FACE_DOWN EQU 8
-FACE_UP EQU 4
-FACE_LEFT EQU 2
-FACE_RIGHT EQU 1
; wPokemonWithdrawDepositParameter::
PC_WITHDRAW EQU 0
diff --git a/data/battle/effect_command_pointers.asm b/data/battle/effect_command_pointers.asm
index d5c044d7..d1f747a1 100644
--- a/data/battle/effect_command_pointers.asm
+++ b/data/battle/effect_command_pointers.asm
@@ -63,7 +63,7 @@ BattleCommandPointers:
dw BattleCommand_Charge
dw BattleCommand_CheckCharge
dw BattleCommand_TrapTarget
- dw BattleCommand3c
+ dw BattleCommand_Unused3C
dw BattleCommand_Rampage
dw BattleCommand_CheckRampage
dw BattleCommand_ConstantDamage
@@ -96,7 +96,7 @@ BattleCommandPointers:
dw BattleCommand_Endure
dw BattleCommand_CheckCurl
dw BattleCommand_RolloutPower
- dw BattleCommand5d
+ dw BattleCommand_Unused5D
dw BattleCommand_FuryCutter
dw BattleCommand_Attract
dw BattleCommand_HappinessPower
diff --git a/data/collision_permissions.asm b/data/collision/collision_permissions.asm
index 57172ca5..57172ca5 100644
--- a/data/collision_permissions.asm
+++ b/data/collision/collision_permissions.asm
diff --git a/data/events/collision_stdscripts.asm b/data/collision/collision_stdscripts.asm
index 5c94c62f..5c94c62f 100644
--- a/data/events/collision_stdscripts.asm
+++ b/data/collision/collision_stdscripts.asm
diff --git a/data/events/field_move_blocks.asm b/data/collision/field_move_blocks.asm
index fea80f53..444be14b 100644
--- a/data/events/field_move_blocks.asm
+++ b/data/collision/field_move_blocks.asm
@@ -1,3 +1,4 @@
+; these blocks all use COLL_CUT_TREE in one quadrant
CutTreeBlockPointers:
; tileset, block list pointer
dbw TILESET_JOHTO, .johto
@@ -42,6 +43,8 @@ CutTreeBlockPointers:
db $0f, $17, 0
db -1 ; end
+
+; these blocks all use COLL_WHIRLPOOL in one quadrant
WhirlpoolBlockPointers:
dbw TILESET_JOHTO, .johto
db -1 ; end
diff --git a/data/decorations/decorations.asm b/data/decorations/decorations.asm
index 947bca1b..e3ec28f1 100644
--- a/data/decorations/decorations.asm
+++ b/data/decorations/decorations.asm
@@ -48,7 +48,8 @@ DecorationIDs:
db DECO_BIG_SNORLAX_DOLL ; 1a
db DECO_BIG_ONIX_DOLL ; 1b
db DECO_BIG_LAPRAS_DOLL ; 1c
-TrophyIDs:
+
db DECO_GOLD_TROPHY_DOLL ; 33
db DECO_SILVER_TROPHY_DOLL ; 34
- db -1
+
+ db -1 ; end
diff --git a/data/events/special_pointers.asm b/data/events/special_pointers.asm
index c2a625fe..a25b6ab2 100644
--- a/data/events/special_pointers.asm
+++ b/data/events/special_pointers.asm
@@ -60,8 +60,8 @@ SpecialsPointers::
add_special UnownPuzzle
add_special SlotMachine
add_special CardFlip
- add_special DummyNonfunctionalGameCornerGame
- add_special ClearBGPalettesBufferScreen
+ add_special UnusedDummyGame ; unused
+ add_special ClearBGPalettesBufferScreen ; unused
add_special FadeOutPalettes
add_special FadeBlackQuickly
add_special FadeInPalettes
@@ -69,21 +69,21 @@ SpecialsPointers::
add_special ReloadSpritesNoPalettes, 2
add_special ClearBGPalettes
add_special UpdateTimePals
- add_special ClearTilemap
+ add_special ClearTilemap ; unused as special
add_special UpdateSprites
add_special UpdatePlayerSprite
add_special GameCornerPrizeMonCheckDex
- add_special UnusedSetSeenMon
+ add_special UnusedSetSeenMon ; unused
add_special WaitSFX, 3
add_special PlayMapMusic
add_special RestartMapMusic
add_special HealMachineAnim
add_special SurfStartStep
- add_special FindPartyMonAboveLevel
- add_special FindPartyMonAtLeastThatHappy
+ add_special FindPartyMonAboveLevel ; unused
+ add_special FindPartyMonAtLeastThatHappy ; unused
add_special FindPartyMonThatSpecies
add_special FindPartyMonThatSpeciesYourTrainerID
- add_special UnusedCheckUnusedTwoDayTimer
+ add_special UnusedCheckUnusedTwoDayTimer ; unused
add_special DayCareMon1
add_special DayCareMon2
add_special SelectRandomBugContestContestants
@@ -127,4 +127,4 @@ SpecialsPointers::
add_special InitialSetDSTFlag
add_special InitialClearDSTFlag
add_special MrChrono
- add_special DummySpecial_c389
+ add_special UnusedDummySpecial ; unused
diff --git a/data/maps/blocks.asm b/data/maps/blocks.asm
index 94c8ff86..38297736 100644
--- a/data/maps/blocks.asm
+++ b/data/maps/blocks.asm
@@ -15,7 +15,7 @@ Route44_Blocks:
Route28_Blocks:
INCBIN "maps/Route28.blk"
-BetaPlayersHouse2F_Blocks:
+BetaPlayersHouse2F_Blocks: ; unreferenced
INCBIN "maps/unused/BetaPlayersHouse2F.blk"
CeladonCity_Blocks:
@@ -30,25 +30,25 @@ Route2_Blocks:
ElmsHouse_Blocks:
INCBIN "maps/ElmsHouse.blk"
-BetaSproutTower1_Blocks:
+BetaSproutTower1_Blocks: ; unreferenced
INCBIN "maps/unused/BetaSproutTower1.blk"
Route11_Blocks:
INCBIN "maps/Route11.blk"
-BetaSproutTower5_Blocks:
+BetaSproutTower5_Blocks: ; unreferenced
INCBIN "maps/unused/BetaSproutTower5.blk"
Route15_Blocks:
INCBIN "maps/Route15.blk"
-BetaSproutTower9_Blocks:
+BetaSproutTower9_Blocks: ; unreferenced
INCBIN "maps/unused/BetaSproutTower9.blk"
Route19_Blocks:
INCBIN "maps/Route19.blk"
-BetaBlackthornCity_Blocks:
+BetaBlackthornCity_Blocks: ; unreferenced
INCBIN "maps/unused/BetaBlackthornCity.blk"
Route10South_Blocks:
@@ -94,7 +94,7 @@ Route25_Blocks:
Route24_Blocks:
INCBIN "maps/Route24.blk"
-BetaVioletCity_Blocks:
+BetaVioletCity_Blocks: ; unreferenced
INCBIN "maps/unused/BetaVioletCity.blk"
Route3_Blocks:
@@ -103,25 +103,25 @@ Route3_Blocks:
PewterCity_Blocks:
INCBIN "maps/PewterCity.blk"
-BetaSilverCaveOutside_Blocks:
+BetaSilverCaveOutside_Blocks: ; unreferenced
INCBIN "maps/unused/BetaSilverCaveOutside.blk"
-BetaSproutTower2_Blocks:
+BetaSproutTower2_Blocks: ; unreferenced
INCBIN "maps/unused/BetaSproutTower2.blk"
Route12_Blocks:
INCBIN "maps/Route12.blk"
-BetaGoldenrodCity_Blocks:
+BetaGoldenrodCity_Blocks: ; unreferenced
INCBIN "maps/unused/BetaGoldenrodCity.blk"
Route20_Blocks:
INCBIN "maps/Route20.blk"
-BetaSproutTower6_Blocks:
+BetaSproutTower6_Blocks: ; unreferenced
INCBIN "maps/unused/BetaSproutTower6.blk"
-BetaPokecenter_Blocks:
+BetaPokecenter_Blocks: ; unreferenced
INCBIN "maps/unused/BetaPokecenter.blk"
Route30_Blocks:
@@ -145,7 +145,7 @@ FuchsiaCity_Blocks:
Route38_Blocks:
INCBIN "maps/Route38.blk"
-BetaCianwoodCity_Blocks:
+BetaCianwoodCity_Blocks: ; unreferenced
INCBIN "maps/unused/BetaCianwoodCity.blk"
OlivineTimsHouse_Blocks:
@@ -214,10 +214,10 @@ Route29Route46Gate_Blocks:
Route5SaffronGate_Blocks:
INCBIN "maps/NorthSouthGate.blk"
-BetaEcruteakCity_Blocks:
+BetaEcruteakCity_Blocks: ; unreferenced
INCBIN "maps/unused/BetaEcruteakCity.blk"
-BetaCherrygroveCity_Blocks:
+BetaCherrygroveCity_Blocks: ; unreferenced
INCBIN "maps/unused/BetaCherrygroveCity.blk"
CinnabarIsland_Blocks:
@@ -229,7 +229,7 @@ Route4_Blocks:
Route8_Blocks:
INCBIN "maps/Route8.blk"
-BetaSproutTower3_Blocks:
+BetaSproutTower3_Blocks: ; unreferenced
INCBIN "maps/unused/BetaSproutTower3.blk"
ViridianCity_Blocks:
@@ -241,13 +241,13 @@ Route13_Blocks:
Route21_Blocks:
INCBIN "maps/Route21.blk"
-BetaSproutTower7_Blocks:
+BetaSproutTower7_Blocks: ; unreferenced
INCBIN "maps/unused/BetaSproutTower7.blk"
Route17_Blocks:
INCBIN "maps/Route17.blk"
-BetaMahoganyTown_Blocks:
+BetaMahoganyTown_Blocks: ; unreferenced
INCBIN "maps/unused/BetaMahoganyTown.blk"
Route31_Blocks:
@@ -280,16 +280,16 @@ Route17Route18Gate_Blocks:
Route31VioletGate_Blocks:
INCBIN "maps/EastWestGate.blk"
-BetaAzaleaTown_Blocks:
+BetaAzaleaTown_Blocks: ; unreferenced
INCBIN "maps/unused/BetaAzaleaTown.blk"
VermilionCity_Blocks:
INCBIN "maps/VermilionCity.blk"
-BetaOlivineCity_Blocks:
+BetaOlivineCity_Blocks: ; unreferenced
INCBIN "maps/unused/BetaOlivineCity.blk"
-BetaNewBarkTown_Blocks:
+BetaNewBarkTown_Blocks: ; unreferenced
INCBIN "maps/unused/BetaNewBarkTown.blk"
ElmsLab_Blocks:
@@ -316,7 +316,7 @@ SECTION "Map Blocks 2", ROMX
Route14_Blocks:
INCBIN "maps/Route14.blk"
-BetaSproutTower8_Blocks:
+BetaSproutTower8_Blocks: ; unreferenced
INCBIN "maps/unused/BetaSproutTower8.blk"
OlivineMart_Blocks:
@@ -337,7 +337,7 @@ CherrygroveMart_Blocks:
Route10North_Blocks:
INCBIN "maps/Route10North.blk"
-BetaLakeOfRage_Blocks:
+BetaLakeOfRage_Blocks: ; unreferenced
INCBIN "maps/unused/BetaLakeOfRage.blk"
OlivinePokecenter1F_Blocks:
@@ -363,25 +363,25 @@ SaffronPokecenter1F_Blocks:
CherrygrovePokecenter1F_Blocks:
INCBIN "maps/Pokecenter1F.blk"
-BetaPewterMuseumOfScience1F_Blocks:
+BetaPewterMuseumOfScience1F_Blocks: ; unreferenced
INCBIN "maps/unused/BetaPewterMuseumOfScience1F.blk"
-BetaPewterMuseumOfScience2F_Blocks:
+BetaPewterMuseumOfScience2F_Blocks: ; unreferenced
INCBIN "maps/unused/BetaPewterMuseumOfScience2F.blk"
EarlsPokemonAcademy_Blocks:
INCBIN "maps/EarlsPokemonAcademy.blk"
-BetaCinnabarPokemonLabHallway_Blocks:
+BetaCinnabarPokemonLabHallway_Blocks: ; unreferenced
INCBIN "maps/unused/BetaCinnabarPokemonLabHallway.blk"
-BetaCinnabarPokemonLabRoom1_Blocks:
+BetaCinnabarPokemonLabRoom1_Blocks: ; unreferenced
INCBIN "maps/unused/BetaCinnabarPokemonLabRoom1.blk"
-BetaCinnabarPokemonLabRoom2_Blocks:
+BetaCinnabarPokemonLabRoom2_Blocks: ; unreferenced
INCBIN "maps/unused/BetaCinnabarPokemonLabRoom2.blk"
-BetaCinnabarPokemonLabRoom3_Blocks:
+BetaCinnabarPokemonLabRoom3_Blocks: ; unreferenced
INCBIN "maps/unused/BetaCinnabarPokemonLabRoom3.blk"
GoldenrodDeptStore1F_Blocks:
@@ -424,7 +424,7 @@ CeladonMansion3F_Blocks:
CeladonMansionRoof_Blocks:
INCBIN "maps/CeladonMansionRoof.blk"
-BetaHouse_Blocks:
+BetaHouse_Blocks: ; unreferenced
INCBIN "maps/unused/BetaHouse.blk"
CeladonGameCorner_Blocks:
@@ -446,7 +446,7 @@ VioletNicknameSpeechHouse_Blocks:
VioletKylesHouse_Blocks:
INCBIN "maps/House2.blk"
-BetaUnionCave_Blocks:
+BetaUnionCave_Blocks: ; unreferenced
INCBIN "maps/unused/BetaUnionCave.blk"
UnionCaveB1F_Blocks:
@@ -466,7 +466,7 @@ Route5UndergroundPathEntrance_Blocks:
Route6UndergroundPathEntrance_Blocks:
INCBIN "maps/UndergroundPathEntrance.blk"
-BetaCapsuleHouse_Blocks:
+BetaCapsuleHouse_Blocks: ; unreferenced
INCBIN "maps/unused/BetaCapsuleHouse.blk"
KurtsHouse_Blocks:
@@ -478,7 +478,7 @@ GoldenrodMagnetTrainStation_Blocks:
RuinsOfAlphOutside_Blocks:
INCBIN "maps/RuinsOfAlphOutside.blk"
-BetaRuinsOfAlphUnsolvedPuzzleRoom_Blocks:
+BetaRuinsOfAlphUnsolvedPuzzleRoom_Blocks: ; unreferenced
INCBIN "maps/unused/BetaRuinsOfAlphUnsolvedPuzzleRoom.blk"
RuinsOfAlphHoOhChamber_Blocks:
@@ -493,19 +493,19 @@ RuinsOfAlphInnerChamber_Blocks:
SproutTower1F_Blocks:
INCBIN "maps/SproutTower1F.blk"
-BetaSproutTowerCutOut1_Blocks:
+BetaSproutTowerCutOut1_Blocks: ; unreferenced
INCBIN "maps/unused/BetaSproutTowerCutOut1.blk"
SproutTower2F_Blocks:
INCBIN "maps/SproutTower2F.blk"
-BetaSproutTowerCutOut2_Blocks:
+BetaSproutTowerCutOut2_Blocks: ; unreferenced
INCBIN "maps/unused/BetaSproutTowerCutOut2.blk"
SproutTower3F_Blocks:
INCBIN "maps/SproutTower3F.blk"
-BetaSproutTowerCutOut3_Blocks:
+BetaSproutTowerCutOut3_Blocks: ; unreferenced
INCBIN "maps/unused/BetaSproutTowerCutOut3.blk"
RadioTower1F_Blocks:
@@ -583,7 +583,7 @@ GoldenrodDeptStoreB1F_Blocks:
GoldenrodUndergroundWarehouse_Blocks:
INCBIN "maps/GoldenrodUndergroundWarehouse.blk"
-BetaElevator_Blocks:
+BetaElevator_Blocks: ; unreferenced
INCBIN "maps/unused/BetaElevator.blk"
TinTower1F_Blocks:
@@ -622,7 +622,7 @@ BurnedTower1F_Blocks:
BurnedTowerB1F_Blocks:
INCBIN "maps/BurnedTowerB1F.blk"
-BetaCaveTestMap_Blocks:
+BetaCaveTestMap_Blocks: ; unreferenced
INCBIN "maps/unused/BetaCaveTestMap.blk"
MountMortar1FOutside_Blocks:
@@ -685,16 +685,16 @@ SilverCaveRoom2_Blocks:
SilverCaveRoom3_Blocks:
INCBIN "maps/SilverCaveRoom3.blk"
-BetaRocketHideoutB2F_Blocks:
+BetaRocketHideoutB2F_Blocks: ; unreferenced
INCBIN "maps/unused/BetaRocketHideoutB2F.blk"
-BetaRocketHideoutB1F_Blocks:
+BetaRocketHideoutB1F_Blocks: ; unreferenced
INCBIN "maps/unused/BetaRocketHideoutB1F.blk"
-BetaRocketHideout1F_Blocks:
+BetaRocketHideout1F_Blocks: ; unreferenced
INCBIN "maps/unused/BetaRocketHideout1F.blk"
-BetaRocketHideoutB3F_Blocks:
+BetaRocketHideoutB3F_Blocks: ; unreferenced
INCBIN "maps/unused/BetaRocketHideoutB3F.blk"
MahoganyMart1F_Blocks:
@@ -710,7 +710,7 @@ TeamRocketBaseB2F_Blocks:
TeamRocketBaseB3F_Blocks:
INCBIN "maps/TeamRocketBaseB3F.blk"
-BetaRoute23_Blocks:
+BetaRoute23_Blocks: ; unreferenced
INCBIN "maps/unused/BetaRoute23.blk"
IndigoPlateauPokecenter1F_Blocks:
@@ -746,7 +746,7 @@ MahoganyGym_Blocks:
OlivineGym_Blocks:
INCBIN "maps/OlivineGym.blk"
-BetaUnknownGym_Blocks:
+BetaUnknownGym_Blocks: ; unreferenced
INCBIN "maps/unused/BetaUnknownGym.blk"
CianwoodGym_Blocks:
@@ -779,7 +779,7 @@ OlivineLighthouse6F_Blocks:
SECTION "Map Blocks 3", ROMX
-BetaSlowpokeWell1F_Blocks:
+BetaSlowpokeWell1F_Blocks: ; unreferenced
INCBIN "maps/unused/BetaSlowpokeWell1F.blk"
SlowpokeWellB1F_Blocks:
@@ -824,7 +824,7 @@ FastShip1F_Blocks:
FastShipB1F_Blocks:
INCBIN "maps/FastShipB1F.blk"
-BetaFastShipInsideCutOut_Blocks:
+BetaFastShipInsideCutOut_Blocks: ; unreferenced
INCBIN "maps/unused/BetaFastShipInsideCutOut.blk"
FastShipCabins_NNW_NNE_NE_Blocks:
@@ -913,13 +913,13 @@ PewterGym_Blocks:
CeladonGym_Blocks:
INCBIN "maps/CeladonGym.blk"
-BetaCeladonMansion1F_Blocks:
+BetaCeladonMansion1F_Blocks: ; unreferenced
INCBIN "maps/unused/BetaCeladonMansion1F.blk"
CeladonCafe_Blocks:
INCBIN "maps/CeladonCafe.blk"
-BetaCeladonMansion2F_Blocks:
+BetaCeladonMansion2F_Blocks: ; unreferenced
INCBIN "maps/unused/BetaCeladonMansion2F.blk"
RockTunnel1F_Blocks:
diff --git a/data/maps/landmarks.asm b/data/maps/landmarks.asm
index 8e25aca2..2ab7fcff 100644
--- a/data/maps/landmarks.asm
+++ b/data/maps/landmarks.asm
@@ -127,7 +127,7 @@ WhirlIslandsName: db "WHIRL¯ISLANDS@"
MtMortarName: db "MT.MORTAR@"
DragonsDenName: db "DRAGON'S¯DEN@"
IcePathName: db "ICE PATH@"
-NotApplicableName: db "N/A@" ; "オバケやしき" ("HAUNTED HOUSE") in Japanese
+NotApplicableName: db "N/A@" ; unreferenced ; "オバケやしき" ("HAUNTED HOUSE") in Japanese
PalletTownName: db "PALLET TOWN@"
ViridianCityName: db "VIRIDIAN¯CITY@"
PewterCityName: db "PEWTER CITY@"
@@ -143,11 +143,11 @@ VictoryRoadName: db "VICTORY¯ROAD@"
MtMoonName: db "MT.MOON@"
RockTunnelName: db "ROCK TUNNEL@"
LavRadioTowerName: db "LAV¯RADIO TOWER@"
-SilphCoName: db "SILPH CO.@"
-SafariZoneName: db "SAFARI ZONE@"
+SilphCoName: db "SILPH CO.@" ; unreferenced
+SafariZoneName: db "SAFARI ZONE@" ; unreferenced
SeafoamIslandsName: db "SEAFOAM¯ISLANDS@"
-PokemonMansionName: db "#MON¯MANSION@"
-CeruleanCaveName: db "CERULEAN¯CAVE@"
+PokemonMansionName: db "#MON¯MANSION@" ; unreferenced
+CeruleanCaveName: db "CERULEAN¯CAVE@" ; unreferenced
Route1Name: db "ROUTE 1@"
Route2Name: db "ROUTE 2@"
Route3Name: db "ROUTE 3@"
@@ -198,7 +198,7 @@ DarkCaveName: db "DARK CAVE@"
IlexForestName: db "ILEX¯FOREST@"
BurnedTowerName: db "BURNED¯TOWER@"
FastShipName: db "FAST SHIP@"
-ViridianForestName: db "VIRIDIAN¯FOREST@"
+ViridianForestName: db "VIRIDIAN¯FOREST@" ; unreferenced
DiglettsCaveName: db "DIGLETT's¯CAVE@"
TohjoFallsName: db "TOHJO FALLS@"
UndergroundName: db "UNDERGROUND@"
diff --git a/data/moves/animations.asm b/data/moves/animations.asm
index 379b897c..e215957a 100644
--- a/data/moves/animations.asm
+++ b/data/moves/animations.asm
@@ -481,7 +481,7 @@ BattleAnim_SendOutMon:
BattleAnim_ReturnMon:
anim_sound 0, 0, SFX_BALL_POOF
-.anim:
+BattleAnimSub_Return:
anim_bgeffect ANIM_BG_RETURN_MON, $0, BG_EFFECT_USER, $0
anim_wait 32
anim_ret
@@ -1314,7 +1314,7 @@ BattleAnim_RazorWind:
anim_wait 24
anim_ret
-BattleAnim_Sonicboom_JP:
+BattleAnim_Sonicboom_JP: ; unreferenced
anim_2gfx ANIM_GFX_WHIP, ANIM_GFX_HIT
.loop
anim_sound 3, 0, SFX_RAZOR_WIND
@@ -4104,7 +4104,7 @@ BattleAnim_BatonPass:
anim_1gfx ANIM_GFX_MISC
anim_obj ANIM_OBJ_BATON_PASS, 44, 104, $20
anim_sound 0, 0, SFX_BATON_PASS
- anim_call BattleAnim_ReturnMon.anim
+ anim_call BattleAnimSub_Return
anim_wait 64
anim_ret
diff --git a/data/moves/tmhm_moves.asm b/data/moves/tmhm_moves.asm
index 2834e7df..e2c44f23 100644
--- a/data/moves/tmhm_moves.asm
+++ b/data/moves/tmhm_moves.asm
@@ -32,6 +32,7 @@ endr
db 0 ; end
+; unused
db 0
db 0
db 0
diff --git a/data/phone/text/elm.asm b/data/phone/text/elm.asm
index a1450ca2..9fb91821 100644
--- a/data/phone/text/elm.asm
+++ b/data/phone/text/elm.asm
@@ -197,7 +197,6 @@ ElmPhoneGiftText:
para "See you later!"
done
-; unused
ElmPhoneGotAholdOfSomethingNeatText:
text "Hello, <PLAYER>?"
line "How's it going?"
diff --git a/data/phone/text/landmarks.asm b/data/phone/text/landmarks.asm
index 175f6111..4943c3b1 100644
--- a/data/phone/text/landmarks.asm
+++ b/data/phone/text/landmarks.asm
@@ -1,67 +1,22 @@
-PhoneNationalParkText:
- db "NATIONAL PARK@"
-
-PhoneLighthouseText:
- db "LIGHTHOUSE@"
-
-; unreferenced
-PhoneUndergroundText:
- db "UNDERGROUND@"
-
-PhoneDarkCaveText:
- db "DARK CAVE@"
-
-PhoneMtMortarText:
- db "MT.MORTAR@"
-
-PhoneRoute26Text:
- db "ROUTE 26@"
-
-PhoneRoute27Text:
- db "ROUTE 27@"
-
-PhoneRoute30Text:
- db "ROUTE 30@"
-
-PhoneRoute31Text:
- db "ROUTE 31@"
-
-PhoneRoute32Text:
- db "ROUTE 32@"
-
-PhoneRoute33Text:
- db "ROUTE 33@"
-
-PhoneRoute34Text:
- db "ROUTE 34@"
-
-PhoneRoute35Text:
- db "ROUTE 35@"
-
-PhoneRoute36Text:
- db "ROUTE 36@"
-
-; unreferenced
-PhoneRoute37Text:
- db "ROUTE 37@"
-
-PhoneRoute38Text:
- db "ROUTE 38@"
-
-PhoneRoute39Text:
- db "ROUTE 39@"
-
-PhoneRoute42Text:
- db "ROUTE 42@"
-
-PhoneRoute43Text:
- db "ROUTE 43@"
-
-PhoneRoute44Text:
- db "ROUTE 44@"
-
-PhoneRoute45Text:
- db "ROUTE 45@"
-
-PhoneRoute46Text:
- db "ROUTE 46@"
+PhoneNationalParkText: db "NATIONAL PARK@"
+PhoneLighthouseText: db "LIGHTHOUSE@"
+PhoneUndergroundText: db "UNDERGROUND@" ; unreferenced
+PhoneDarkCaveText: db "DARK CAVE@"
+PhoneMtMortarText: db "MT.MORTAR@"
+PhoneRoute26Text: db "ROUTE 26@"
+PhoneRoute27Text: db "ROUTE 27@"
+PhoneRoute30Text: db "ROUTE 30@"
+PhoneRoute31Text: db "ROUTE 31@"
+PhoneRoute32Text: db "ROUTE 32@"
+PhoneRoute33Text: db "ROUTE 33@"
+PhoneRoute34Text: db "ROUTE 34@"
+PhoneRoute35Text: db "ROUTE 35@"
+PhoneRoute36Text: db "ROUTE 36@"
+PhoneRoute37Text: db "ROUTE 37@" ; unreferenced
+PhoneRoute38Text: db "ROUTE 38@"
+PhoneRoute39Text: db "ROUTE 39@"
+PhoneRoute42Text: db "ROUTE 42@"
+PhoneRoute43Text: db "ROUTE 43@"
+PhoneRoute44Text: db "ROUTE 44@"
+PhoneRoute45Text: db "ROUTE 45@"
+PhoneRoute46Text: db "ROUTE 46@"
diff --git a/data/player_names.asm b/data/player_names.asm
index 0155dac4..3291ea66 100644
--- a/data/player_names.asm
+++ b/data/player_names.asm
@@ -1,8 +1,8 @@
NameMenuHeader:
- db STATICMENU_NO_TOP_SPACING
+ db STATICMENU_NO_TOP_SPACING ; flags
menu_coords 0, 0, 10, TEXTBOX_Y - 1
dw .Names
- db 1
+ db 1 ; default option
.Names:
db STATICMENU_CURSOR | STATICMENU_PLACE_TITLE | STATICMENU_DISABLE_B ; flags
@@ -21,5 +21,5 @@ ELIF DEF(_SILVER)
db "OSCAR@"
db "MAX@"
ENDC
- db 2
+ db 2 ; ????
db "NAME@" ; title
diff --git a/data/pokemon/palettes.asm b/data/pokemon/palettes.asm
index e6fbf844..36d2c662 100644
--- a/data/pokemon/palettes.asm
+++ b/data/pokemon/palettes.asm
@@ -3,6 +3,7 @@ PokemonPalettes:
; Each back.gbcpal is generated from the corresponding .png, and
; only the middle two colors are included, not black or white.
+; (Back sprites are used since they are the same in Gold and Silver.)
; Shiny palettes are defined directly, not generated.
; 000
diff --git a/data/radio/oaks_pkmn_talk_routes.asm b/data/radio/oaks_pkmn_talk_routes.asm
index 254dd8e5..db244740 100644
--- a/data/radio/oaks_pkmn_talk_routes.asm
+++ b/data/radio/oaks_pkmn_talk_routes.asm
@@ -1,6 +1,7 @@
; Oak's Pokémon Talk will list wild Pokémon on these maps.
-OaksPKMNTalkRoutes:; there are NUM_OAKS_POKEMON_TALK_ROUTES entries
+OaksPKMNTalkRoutes:
+; there are NUM_OAKS_POKEMON_TALK_ROUTES entries
map_id ROUTE_29
map_id ROUTE_46
map_id ROUTE_30
diff --git a/data/sprite_anims/framesets.asm b/data/sprite_anims/framesets.asm
index 6104dbb7..4ae8d6b7 100644
--- a/data/sprite_anims/framesets.asm
+++ b/data/sprite_anims/framesets.asm
@@ -291,45 +291,45 @@ ENDC
frame SPRITE_ANIM_OAMSET_MAGNET_TRAIN_RED_2, 8, OAM_X_FLIP
dorestart
-; unused
+.Frameset_Unknown1: ; unreferenced
frame SPRITE_ANIM_OAMSET_UNUSED_43, 8
frame SPRITE_ANIM_OAMSET_UNUSED_44, 8
dorestart
-; unused
+.Frameset_Unknown2: ; unreferenced
frame SPRITE_ANIM_OAMSET_UNUSED_45, 8
frame SPRITE_ANIM_OAMSET_UNUSED_46, 8
dorestart
-; unused
+.Frameset_Unknown3: ; unreferenced
frame SPRITE_ANIM_OAMSET_UNUSED_47, 8
frame SPRITE_ANIM_OAMSET_UNUSED_48, 8
dorestart
-; unused
+.Frameset_Unknown4: ; unreferenced
frame SPRITE_ANIM_OAMSET_UNUSED_49, 1
frame SPRITE_ANIM_OAMSET_UNUSED_49, 1, OAM_X_FLIP
frame SPRITE_ANIM_OAMSET_UNUSED_49, 1, OAM_X_FLIP, OAM_Y_FLIP
frame SPRITE_ANIM_OAMSET_UNUSED_49, 1, OAM_Y_FLIP
dorestart
-; unused
+.Frameset_Unknown5: ; unreferenced
frame SPRITE_ANIM_OAMSET_UNUSED_4A, 32
endanim
-; unused
+.Frameset_Unknown6: ; unreferenced
frame SPRITE_ANIM_OAMSET_UNUSED_4B, 32
endanim
-; unused
+.Frameset_Unknown7: ; unreferenced
frame SPRITE_ANIM_OAMSET_UNUSED_4C, 32
endanim
-; unused
+.Frameset_Unknown8: ; unreferenced
frame SPRITE_ANIM_OAMSET_UNUSED_4D, 32
endanim
-; unused
+.Frameset_Unknown9: ; unreferenced
frame SPRITE_ANIM_OAMSET_UNUSED_4E, 3
dowait 3
dorestart
diff --git a/data/sprite_anims/oam.asm b/data/sprite_anims/oam.asm
index cc43267d..d34d3a03 100644
--- a/data/sprite_anims/oam.asm
+++ b/data/sprite_anims/oam.asm
@@ -141,7 +141,7 @@ ENDC
dbsprite -1, 0, 0, 0, $00, 7 | Y_FLIP
dbsprite 0, 0, 0, 0, $00, 7 | X_FLIP | Y_FLIP
-; unused
+.OAMData_Unknown1: ; unreferenced
db 4
dbsprite -1, -1, 0, 0, $00, 0 | PRIORITY
dbsprite 0, -1, 0, 0, $00, 0 | X_FLIP | PRIORITY
@@ -265,7 +265,7 @@ ENDC
dbsprite 1, 0, 4, 4, $17, 0
dbsprite 1, 1, 4, 4, $18, 0
-; unused
+.OAMData_Unknown2: ; unreferenced
db 36
dbsprite -3, -3, 0, 0, $00, 0
dbsprite -2, -3, 0, 0, $01, 0
@@ -762,7 +762,7 @@ ELIF DEF(_SILVER)
dbsprite 3, -2, 0, 0, $1c, 0
dbsprite 4, -2, 0, 0, $1e, 0
-.OAMData_GSIntroLugia3:
+.OAMData_GSIntroLugia3: ; unreferenced
db 17
dbsprite -5, -2, 0, 0, $3c, 0
dbsprite -5, 0, 0, 0, $3e, 0
@@ -782,7 +782,7 @@ ELIF DEF(_SILVER)
dbsprite 3, -1, 0, 0, $56, 0
dbsprite 4, -1, 0, 0, $58, 0
-.OAMData_GSIntroLugia4:
+.OAMData_GSIntroLugia4: ; unreferenced
db 17
dbsprite -5, -2, 0, 0, $5a, 0
dbsprite -5, 0, 0, 0, $5c, 0
@@ -802,8 +802,7 @@ ELIF DEF(_SILVER)
dbsprite 3, -1, 0, 0, $74, 0
dbsprite 4, -1, 0, 0, $76, 0
-; unused / copy of intro4
-.OAMData_GSIntroLugia5:
+.OAMData_GSIntroLugia5: ; unreferenced
db 17
dbsprite -5, -2, 0, 0, $5a, 0
dbsprite -5, 0, 0, 0, $5c, 0
diff --git a/data/text/battle.asm b/data/text/battle.asm
index fe14f938..811a8e8c 100644
--- a/data/text/battle.asm
+++ b/data/text/battle.asm
@@ -340,7 +340,7 @@ BattleText_StringBuffer1GrewToLevel:
text_decimal wCurPartyLevel, 1, 3
text "!@"
sound_dex_fanfare_50_79
- db "@"
+ text_end
BattleText_WildMonIsEating:
text "Wild @"
@@ -1073,7 +1073,7 @@ BeatUpAttackText:
; BUG: Pokémon names 8-10 characters long can overflow the textbox,
; printing as "Enemy 1234567890 can't": up to 21 characters, over 18.
-CantReceiveGiftText:
+PresentFailedText:
text "<TARGET> can't"
line "receive the gift!"
prompt
diff --git a/data/text/common_2.asm b/data/text/common_2.asm
index 5f5f0e5d..b7a537c6 100644
--- a/data/text/common_2.asm
+++ b/data/text/common_2.asm
@@ -160,7 +160,6 @@ _RodNothingText::
text "Not even a nibble!"
prompt
-; unreferenced
_UnusedNothingHereText::
text "Looks like there's"
line "nothing here."
@@ -1265,7 +1264,7 @@ _LinkAbnormalMonText::
_LinkAskTradeForText::
text "Trade @"
- text_ram wceef
+ text_ram wBufferTrademonNick
text_start
line "for @"
text_ram wStringBuffer1
diff --git a/data/text/unused_sweet_honey.asm b/data/text/unused_sweet_honey.asm
index 04ceae2e..d4970118 100644
--- a/data/text/unused_sweet_honey.asm
+++ b/data/text/unused_sweet_honey.asm
@@ -8,7 +8,7 @@
; Most of these texts seem to be associated with a single NPC.
; The last text is associated with a second NPC, probably a Butterfree.
-UnusedSweetHoneyText:
+UnusedSweetHoneyText: ; unreferenced
text "My #MON is an"
line "expert at collect-"
cont "ing SWEET HONEY."
@@ -17,7 +17,7 @@ UnusedSweetHoneyText:
line "with you."
done
-UnusedSweetHoneyBagFullText:
+UnusedSweetHoneyBagFullText: ; unreferenced
text "I want to give you"
line "some SWEET HONEY,"
@@ -25,17 +25,17 @@ UnusedSweetHoneyBagFullText:
line "room for it."
done
-UnusedSweetHoneyGiveText:
+UnusedSweetHoneyGiveText: ; unreferenced
text "Here you go! Have"
line "some SWEET HONEY!"
done
-UnusedGotSweetHoneyText:
+UnusedGotSweetHoneyText: ; unreferenced
text "<PLAYER> received"
line "SWEET HONEY."
done
-UnusedSweetHoneyAfterText1:
+UnusedSweetHoneyAfterText1: ; unreferenced
text "My little brother"
line "takes SWEET HONEY"
@@ -46,7 +46,7 @@ UnusedSweetHoneyAfterText1:
line "up to?"
done
-UnusedSweetHoneyAfterText2:
+UnusedSweetHoneyAfterText2: ; unreferenced
text "Did you put SWEET"
line "HONEY on a tree?"
@@ -54,7 +54,7 @@ UnusedSweetHoneyAfterText2:
line "it?"
done
-UnusedSweetHoneyAfterText3:
+UnusedSweetHoneyAfterText3: ; unreferenced
text "Did you put SWEET"
line "HONEY on a tree?"
@@ -63,6 +63,6 @@ UnusedSweetHoneyAfterText3:
cont "be drawn to it."
done
-UnusedSweetHoneyButterfreeText:
+UnusedSweetHoneyButterfreeText: ; unreferenced
text "BUTTERFREE: Freeh!"
done
diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md
index 965700b7..c30f74fb 100644
--- a/docs/bugs_and_glitches.md
+++ b/docs/bugs_and_glitches.md
@@ -70,12 +70,12 @@ All the bugs documented here were fixed in Pokémon Crystal. Any that weren't ar
## Present's text overflows when it fails to heal an enemy Pokémon with a long name
-**Fix:** Edit `CantReceiveGiftText` in [data/text/battle.asm](https://github.com/pret/pokegold/blob/master/data/text/battle.asm):
+**Fix:** Edit `PresentFailedText` in [data/text/battle.asm](https://github.com/pret/pokegold/blob/master/data/text/battle.asm):
```diff
-; BUG: Pokémon names 8-10 characters long can overflow the textbox,
-; printing as "Enemy 1234567890 can't": up to 21 characters, over 18.
- CantReceiveGiftText:
+ PresentFailedText:
- text "<TARGET> can't"
- line "receive the gift!"
+ text "<TARGET>"
diff --git a/engine/battle/ai/items.asm b/engine/battle/ai/items.asm
index b375b54c..16e9ef20 100644
--- a/engine/battle/ai/items.asm
+++ b/engine/battle/ai/items.asm
@@ -25,7 +25,7 @@ AI_SwitchOrTryItem:
ld hl, TrainerClassAttributes + TRNATTR_AI_ITEM_SWITCH
ld bc, NUM_TRAINER_ATTRIBUTES
call AddNTimes
-.ok
+
bit SWITCH_OFTEN_F, [hl]
jp nz, SwitchOften
bit SWITCH_RARELY_F, [hl]
@@ -141,7 +141,7 @@ SwitchSometimes:
ld [wEnemySwitchMonIndex], a
jp AI_TrySwitch
-CheckSubstatusCantRun:
+CheckSubstatusCantRun: ; unreferenced
ld a, [wEnemySubStatus5]
bit SUBSTATUS_CANT_RUN, a
ret
@@ -204,7 +204,7 @@ AI_TryItem:
inc hl
jr c, .loop
-.used_item
+; used item
xor a
ld [de], a
inc a
@@ -247,7 +247,7 @@ AI_TryItem:
cp e
jr nc, .yes
-.no
+.no ; unreferenced
and a
ret
diff --git a/engine/battle/battle_transition.asm b/engine/battle/battle_transition.asm
index 105248f0..f5b4effe 100644
--- a/engine/battle/battle_transition.asm
+++ b/engine/battle/battle_transition.asm
@@ -208,7 +208,7 @@ StartTrainerBattle_NextScene:
StartTrainerBattle_SetUpBGMap:
call StartTrainerBattle_NextScene
xor a
- ld [wce64], a
+ ld [wBattleTransitionCounter], a
ldh [hBGMapMode], a
ret
@@ -222,7 +222,7 @@ StartTrainerBattle_Flash:
ld a, [wTimeOfDayPalset]
cp DARKNESS_PALSET
jr z, .done
- ld hl, wce64
+ ld hl, wBattleTransitionCounter
ld a, [hl]
inc [hl]
srl a
@@ -240,7 +240,7 @@ StartTrainerBattle_Flash:
.done
xor a
- ld [wce64], a
+ ld [wBattleTransitionCounter], a
scf
ret
@@ -271,12 +271,12 @@ StartTrainerBattle_SetUpForWavyOutro:
ld a, $90
ldh [hLYOverrideEnd], a
xor a
- ld [wce64], a
- ld [wce65], a
+ ld [wBattleTransitionCounter], a
+ ld [wBattleTransitionSineWaveOffset], a
ret
StartTrainerBattle_SineWave:
- ld a, [wce64]
+ ld a, [wBattleTransitionCounter]
cp $60
jr nc, .end
call .DoSineWave
@@ -288,10 +288,10 @@ StartTrainerBattle_SineWave:
ret
.DoSineWave:
- ld hl, wce65
+ ld hl, wBattleTransitionSineWaveOffset
ld a, [hl]
inc [hl]
- ld hl, wce64
+ ld hl, wBattleTransitionCounter
ld d, [hl]
add [hl]
ld [hl], a
@@ -319,13 +319,13 @@ StartTrainerBattle_SetUpForSpinOutro:
farcall RespawnPlayerAndOpponent
call StartTrainerBattle_NextScene
xor a
- ld [wce64], a
+ ld [wBattleTransitionCounter], a
ret
StartTrainerBattle_SpinToBlack:
xor a
ldh [hBGMapMode], a
- ld a, [wce64]
+ ld a, [wBattleTransitionCounter]
ld e, a
ld d, 0
ld hl, .spin_quadrants
@@ -335,13 +335,13 @@ endr
ld a, [hli]
cp -1
jr z, .end
- ld [wce65], a
+ ld [wBattleTransitionSpinQuadrant], a
call .load
ld a, 1
ldh [hBGMapMode], a
call DelayFrame
call DelayFrame
- ld hl, wce64
+ ld hl, wBattleTransitionCounter
inc [hl]
ret
@@ -396,7 +396,7 @@ ENDM
spin_quadrant LOWER_LEFT, .wedge1, 1, 11
db -1
-.load
+.load:
ld a, [hli]
ld e, a
ld a, [hli]
@@ -411,7 +411,7 @@ ENDM
inc de
.loop1
ld [hl], BATTLETRANSITION_BLACK
- ld a, [wce65]
+ ld a, [wBattleTransitionSpinQuadrant]
bit RIGHT_QUADRANT_F, a
jr z, .leftside
inc hl
@@ -422,7 +422,7 @@ ENDM
dec c
jr nz, .loop1
pop hl
- ld a, [wce65]
+ ld a, [wBattleTransitionSpinQuadrant]
bit LOWER_QUADRANT_F, a
ld bc, SCREEN_WIDTH
jr z, .upper
@@ -437,7 +437,7 @@ ENDM
jr z, .loop
ld c, a
.loop2
- ld a, [wce65]
+ ld a, [wBattleTransitionSpinQuadrant]
bit RIGHT_QUADRANT_F, a
jr z, .leftside2
dec hl
@@ -459,13 +459,13 @@ StartTrainerBattle_SetUpForRandomScatterOutro:
farcall RespawnPlayerAndOpponent
call StartTrainerBattle_NextScene
ld a, $10
- ld [wce64], a
+ ld [wBattleTransitionCounter], a
ld a, 1
ldh [hBGMapMode], a
ret
StartTrainerBattle_SpeckleToBlack:
- ld hl, wce64
+ ld hl, wBattleTransitionCounter
ld a, [hl]
and a
jr z, .done
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index 4a580aca..0587c750 100644
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -1644,7 +1644,7 @@ HandleWeather:
cp USING_EXTERNAL_CLOCK
jr z, .enemy_first
-.player_first
+; player first
call SetPlayerTurn
call .SandstormDamage
call SetEnemyTurn
@@ -2609,7 +2609,7 @@ AskUseNextPokemon:
ForcePlayerMonChoice:
call EmptyBattleTextbox
call LoadStandardMenuHeader
- call SetUpBattlePartyMenu_NoLoop
+ call SetUpBattlePartyMenu
call ForcePickPartyMonInBattle
ld a, [wLinkMode]
cp LINK_COLOSSEUM
@@ -2681,9 +2681,8 @@ PlayerPartyMonEntrance:
call SetPlayerTurn
jp SpikesDamage
-SetUpBattlePartyMenu_NoLoop:
+SetUpBattlePartyMenu:
call ClearBGPalettes
-SetUpBattlePartyMenu: ; switch to fullscreen menu?
farcall LoadPartyMenuGFX
farcall InitPartyMenuWithCancel
farcall InitPartyMenuGFX
@@ -2818,10 +2817,11 @@ PlayerMonFaintedAnimation:
jp MonFaintedAnimation
MonFaintedAnimation:
- ld a, [wd8ba]
+ ld a, [wJoypadDisable]
push af
- set 6, a
- ld [wd8ba], a
+ set JOYPAD_DISABLE_MON_FAINT_F, a
+ ld [wJoypadDisable], a
+
ld b, 7
.OuterLoop:
@@ -2864,7 +2864,7 @@ MonFaintedAnimation:
jr nz, .OuterLoop
pop af
- ld [wd8ba], a
+ ld [wJoypadDisable], a
ret
.Spaces:
@@ -3296,7 +3296,7 @@ OfferSwitch:
ld a, [wMenuCursorY]
dec a
jr nz, .said_no
- call SetUpBattlePartyMenu_NoLoop
+ call SetUpBattlePartyMenu
call PickSwitchMonInBattle
jr c, .canceled_switch
ld a, [wCurBattleMon]
@@ -4404,7 +4404,7 @@ CheckDanger:
PrintPlayerHUD:
ld de, wBattleMonNick
hlcoord 10, 7
- call ret_3df99
+ call Battle_DummyFunction
call PlaceString
push bc
@@ -4490,7 +4490,7 @@ DrawEnemyHUD:
call GetBaseData
ld de, wEnemyMonNick
hlcoord 1, 0
- call ret_3df99
+ call Battle_DummyFunction
call PlaceString
ld h, b
ld l, c
@@ -4619,7 +4619,8 @@ UpdateHPPal:
ret z
jp FinishBattleAnim
-ret_3df99:
+Battle_DummyFunction:
+; called before placing either battler's nickname in the HUD
ret
BattleMenu:
@@ -7167,13 +7168,13 @@ AnimateExpBar:
jp z, .finish
ldh a, [hProduct + 3]
- ld [wceef], a
+ ld [wExperienceGained + 2], a
push af
ldh a, [hProduct + 2]
- ld [wceee], a
+ ld [wExperienceGained + 1], a
push af
xor a
- ld [wceed], a
+ ld [wExperienceGained], a
xor a ; PARTYMON
ld [wMonType], a
predef CopyMonToTempMon
@@ -7185,10 +7186,10 @@ AnimateExpBar:
call CalcExpBar
push bc
ld hl, wTempMonExp + 2
- ld a, [wceef]
+ ld a, [wExperienceGained + 2]
add [hl]
ld [hld], a
- ld a, [wceee]
+ ld a, [wExperienceGained + 1]
adc [hl]
ld [hld], a
jr nc, .NoOverflow
@@ -7487,7 +7488,8 @@ HandleSafariAngerEatingStatus: ; unreferenced
jr .finish
.angry
- dec hl ; wSafariMonAngerCount
+ dec hl
+ assert wSafariMonEating - 1 == wSafariMonAngerCount
ld a, [hl]
and a
ret z
@@ -8005,7 +8007,7 @@ CheckPayDay:
call StdBattleTextbox
ret
-PlayerPickedUpPayDayMoney:
+PlayerPickedUpPayDayMoney: ; unreferenced
text_far _PlayerPickedUpPayDayMoney
text_end
@@ -8180,7 +8182,6 @@ ReadAndPrintLinkBattleRecord:
lb bc, 2, 4
call PrintNum
-.quit
ret
.PrintZerosIfNoSaveFileExists:
@@ -8392,7 +8393,7 @@ AddLastLinkBattleToLinkRecord:
.FindOpponentAndAppendRecord:
ld b, NUM_LINK_BATTLE_RECORDS
ld hl, sLinkBattleRecord1End - 1
- ld de, wceed
+ ld de, wLinkBattleRecordBuffer
.loop3
push bc
push de
@@ -8421,16 +8422,16 @@ AddLastLinkBattleToLinkRecord:
add b
add b
ld e, a
- ld d, $0
- ld hl, wceed
+ ld d, 0
+ ld hl, wLinkBattleRecordBuffer
add hl, de
push hl
ld a, c
add c
add c
ld e, a
- ld d, $0
- ld hl, wceed
+ ld d, 0
+ ld hl, wLinkBattleRecordBuffer
add hl, de
ld d, h
ld e, l
@@ -8462,7 +8463,7 @@ AddLastLinkBattleToLinkRecord:
ld hl, sLinkBattleRecord
call AddNTimes
push hl
- ld de, wceed
+ ld de, wLinkBattleRecordBuffer
ld bc, LINK_BATTLE_RECORD_LENGTH
call CopyBytes
pop hl
@@ -8476,7 +8477,7 @@ AddLastLinkBattleToLinkRecord:
push hl
ld bc, LINK_BATTLE_RECORD_LENGTH
call CopyBytes
- ld hl, wceed
+ ld hl, wLinkBattleRecordBuffer
ld bc, LINK_BATTLE_RECORD_LENGTH
pop de
call CopyBytes
@@ -8556,14 +8557,15 @@ InitBattleDisplay:
call OpenSRAM
ld hl, sDecompressScratch
- ld bc, sScratchAttrmap - sDecompressScratch
+ ld bc, BG_MAP_WIDTH * BG_MAP_HEIGHT
ld a, " "
call ByteFill
ld de, sDecompressScratch
hlbgcoord 0, 0
- lb bc, BANK(.BlankBGMap), $40
+ lb bc, BANK(@), (BG_MAP_WIDTH * BG_MAP_HEIGHT) / LEN_2BPP_TILE
call Request2bpp
+
call CloseSRAM
ret
diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm
index a5ae950f..12f7a101 100644
--- a/engine/battle/effect_commands.asm
+++ b/engine/battle/effect_commands.asm
@@ -145,7 +145,7 @@ BattleCommand_CheckTurn:
and a
jp nz, CheckEnemyTurn
-CheckPlayerTurn:
+; check player turn
ld hl, wPlayerSubStatus4
bit SUBSTATUS_RECHARGE, [hl]
jr z, .no_recharge
@@ -2592,7 +2592,7 @@ PlayerAttackDamage:
cp SPECIAL
jr nc, .special
-.physical
+; physical
ld hl, wEnemyMonDefense
ld a, [hli]
ld b, a
@@ -2660,7 +2660,6 @@ PlayerAttackDamage:
ret
TruncateHL_BC:
-.loop
; Truncate 16-bit values hl and bc to 8-bit values b and c respectively.
; b = hl, c = bc
@@ -2821,9 +2820,9 @@ EnemyAttackDamage:
ld a, [hl]
cp SPECIAL
- jr nc, .Special
+ jr nc, .special
-.physical
+; physical
ld hl, wBattleMonDefense
ld a, [hli]
ld b, a
@@ -2847,7 +2846,7 @@ EnemyAttackDamage:
ld hl, wEnemyAttack
jr .thickclub
-.Special:
+.special
ld hl, wBattleMonSpclDef
ld a, [hli]
ld b, a
@@ -5669,7 +5668,7 @@ BattleCommand_Charge:
text_far _BattleDugText
text_end
-BattleCommand3c:
+BattleCommand_Unused3C:
; unused
ret
@@ -6075,7 +6074,7 @@ INCLUDE "engine/battle/move_effects/conversion.asm"
BattleCommand_ResetStats:
; resetstats
- ld a, 7 ; neutral
+ ld a, BASE_STAT_LEVEL
ld hl, wPlayerStatLevels
call .Fill
ld hl, wEnemyStatLevels
@@ -6098,7 +6097,7 @@ BattleCommand_ResetStats:
jp StdBattleTextbox
.Fill:
- ld b, wPlayerStatLevelsEnd - wPlayerStatLevels
+ ld b, NUM_LEVEL_STATS
.next
ld [hli], a
dec b
@@ -6440,7 +6439,7 @@ INCLUDE "engine/battle/move_effects/sandstorm.asm"
INCLUDE "engine/battle/move_effects/rollout.asm"
-BattleCommand5d:
+BattleCommand_Unused5D:
; unused
ret
diff --git a/engine/battle/menu.asm b/engine/battle/menu.asm
index 6a942f6c..e9a7e593 100644
--- a/engine/battle/menu.asm
+++ b/engine/battle/menu.asm
@@ -3,8 +3,7 @@ LoadBattleMenu:
call LoadMenuHeader
jr CommonBattleMenu
-SafariBattleMenu:
-; untranslated
+SafariBattleMenu: ; unreferenced
ld hl, SafariBattleMenuHeader
call LoadMenuHeader
jr CommonBattleMenu
@@ -12,7 +11,8 @@ SafariBattleMenu:
ContestBattleMenu:
ld hl, ContestBattleMenuHeader
call LoadMenuHeader
-; fallthrough
+ ; fallthrough
+
CommonBattleMenu:
ld a, [wBattleMenuCursorBuffer]
ld [wMenuCursorBuffer], a
diff --git a/engine/battle/move_effects/baton_pass.asm b/engine/battle/move_effects/baton_pass.asm
index bf9e3235..236acc82 100644
--- a/engine/battle/move_effects/baton_pass.asm
+++ b/engine/battle/move_effects/baton_pass.asm
@@ -17,7 +17,7 @@ BattleCommand_BatonPass:
; Transition into switchmon menu
call LoadStandardMenuHeader
- farcall SetUpBattlePartyMenu_NoLoop
+ farcall SetUpBattlePartyMenu
farcall ForcePickSwitchMonInBattle
diff --git a/engine/battle/move_effects/beat_up.asm b/engine/battle/move_effects/beat_up.asm
index 8546c37d..32e0112c 100644
--- a/engine/battle/move_effects/beat_up.asm
+++ b/engine/battle/move_effects/beat_up.asm
@@ -14,7 +14,7 @@ BattleCommand_BeatUp:
call DelayFrames
xor a
ld [wPlayerRolloutCount], a
- ld [wceed], a
+ ld [wCurBeatUpPartyMon], a
ld [wBeatUpHitAtLeastOnce], a
jr .got_mon
@@ -23,10 +23,10 @@ BattleCommand_BeatUp:
ld b, a
ld a, [wPartyCount]
sub b
- ld [wceed], a
+ ld [wCurBeatUpPartyMon], a
.got_mon
- ld a, [wceed]
+ ld a, [wCurBeatUpPartyMon]
ld hl, wPartyMonNicknames
call GetNick
ld a, MON_HP
@@ -34,7 +34,7 @@ BattleCommand_BeatUp:
ld a, [hli]
or [hl]
jp z, .beatup_fail ; fainted
- ld a, [wceed]
+ ld a, [wCurBeatUpPartyMon]
ld c, a
ld a, [wCurBattleMon]
; BUG: this can desynchronize link battles
@@ -88,7 +88,7 @@ BattleCommand_BeatUp:
xor a
ld [wEnemyRolloutCount], a
- ld [wceed], a
+ ld [wCurBeatUpPartyMon], a
ld [wBeatUpHitAtLeastOnce], a
jr .enemy_got_mon
@@ -97,7 +97,7 @@ BattleCommand_BeatUp:
ld b, a
ld a, [wOTPartyCount]
sub b
- ld [wceed], a
+ ld [wCurBeatUpPartyMon], a
.enemy_got_mon
ld a, [wBattleMode]
@@ -108,7 +108,7 @@ BattleCommand_BeatUp:
and a
jr nz, .linked
- ld a, [wceed]
+ ld a, [wCurBeatUpPartyMon]
ld c, a
ld b, 0
ld hl, wOTPartySpecies
@@ -119,7 +119,7 @@ BattleCommand_BeatUp:
jr .got_enemy_nick
.linked
- ld a, [wceed]
+ ld a, [wCurBeatUpPartyMon]
ld hl, wOTPartyMonNicknames
ld bc, NAME_LENGTH
call AddNTimes
@@ -133,7 +133,7 @@ BattleCommand_BeatUp:
or [hl]
jp z, .beatup_fail
- ld a, [wceed]
+ ld a, [wCurBeatUpPartyMon]
ld b, a
ld a, [wCurOTMon]
cp b
@@ -213,7 +213,7 @@ GetBeatupMonLocation:
ld hl, wOTPartyMon1Species
.got_species
- ld a, [wceed]
+ ld a, [wCurBeatUpPartyMon]
add hl, bc
call GetPartyLocation
pop bc
diff --git a/engine/battle/move_effects/present.asm b/engine/battle/move_effects/present.asm
index 33e172fb..0577e76b 100644
--- a/engine/battle/move_effects/present.asm
+++ b/engine/battle/move_effects/present.asm
@@ -67,7 +67,7 @@ BattleCommand_Present:
add a
jr nc, .do_animation
call AnimateFailedMove
- ld hl, CantReceiveGiftText
+ ld hl, PresentFailedText
call StdBattleTextbox
.do_animation
jp EndMoveEffect
diff --git a/engine/battle_anims/anim_commands.asm b/engine/battle_anims/anim_commands.asm
index 7fb80d82..9bba60a3 100644
--- a/engine/battle_anims/anim_commands.asm
+++ b/engine/battle_anims/anim_commands.asm
@@ -218,7 +218,8 @@ BattleAnim_ClearOAM:
ld c, NUM_SPRITE_OAM_STRUCTS
.loop
ld a, [hl]
- and $ff ^ (PALETTE_MASK | VRAM_BANK_1) ; PAL_BATTLE_OB_ENEMY (0)
+ and $ff ^ (PALETTE_MASK | VRAM_BANK_1) ; zeros out the palette bits
+ assert PAL_BATTLE_OB_ENEMY == 0
ld [hli], a
rept SPRITEOAMSTRUCT_LENGTH - 1
inc hl
@@ -978,7 +979,7 @@ GetMinimizePic:
and a
jr z, .player
- ld de, sScratch + $1a tiles
+ ld de, sScratch + (3 * 7 + 5) tiles
call CopyMinimizePic
ld hl, vTiles2 tile $00
ld de, sScratch
@@ -987,7 +988,7 @@ GetMinimizePic:
jr .done
.player
- ld de, sScratch + $160
+ ld de, sScratch + (3 * 6 + 4) tiles
call CopyMinimizePic
ld hl, vTiles2 tile $31
ld de, sScratch
diff --git a/engine/battle_anims/core.asm b/engine/battle_anims/core.asm
index adba64e0..d756a447 100644
--- a/engine/battle_anims/core.asm
+++ b/engine/battle_anims/core.asm
@@ -263,14 +263,12 @@ InitBattleAnimBuffer:
jr nz, .no_sub
ld a, [wFXAnimID]
cp KINESIS
- jr z, .kinesis
+ jr z, .do_sub
cp SOFTBOILED
- jr z, .softboiled
+ jr z, .do_sub
cp MILK_DRINK
jr nz, .no_sub
-.kinesis
-.softboiled
-.milk_drink
+.do_sub
pop af
sub 1 * 8
jr .done
diff --git a/engine/battle_anims/functions.asm b/engine/battle_anims/functions.asm
index 95b3a101..2a72cf12 100644
--- a/engine/battle_anims/functions.asm
+++ b/engine/battle_anims/functions.asm
@@ -4293,14 +4293,14 @@ BattleAnim_Cosine_e:
ld e, a
ret
-BattleAnim_AbsSinePrecise:
+BattleAnim_AbsSinePrecise: ; unreferenced
ld a, e
call BattleAnim_Sine
ld e, l
ld d, h
ret
-BattleAnim_AbsCosinePrecise:
+BattleAnim_AbsCosinePrecise: ; unreferenced
ld a, e
call BattleAnim_Cosine
ld e, l
diff --git a/engine/debug/color_picker.asm b/engine/debug/color_picker.asm
index b5d196b1..2ebf4861 100644
--- a/engine/debug/color_picker.asm
+++ b/engine/debug/color_picker.asm
@@ -32,7 +32,7 @@
const DEBUGCOLORMAIN_INITTMHM ; 4
const DEBUGCOLORMAIN_TMHMJOYPAD ; 5
-DebugColorPicker:
+DebugColorPicker: ; unreferenced
; A debug menu to test monster and trainer palettes at runtime.
ldh a, [hCGB]
and a
@@ -913,13 +913,13 @@ DebugColor_FillBoxWithByte:
ret
DebugColor_PushSGBPals:
- ld a, [wd8ba]
+ ld a, [wJoypadDisable]
push af
- set 7, a
- ld [wd8ba], a
+ set JOYPAD_DISABLE_SGB_TRANSFER_F, a
+ ld [wJoypadDisable], a
call _DebugColor_PushSGBPals
pop af
- ld [wd8ba], a
+ ld [wJoypadDisable], a
ret
_DebugColor_PushSGBPals:
@@ -1053,7 +1053,7 @@ INCBIN "gfx/debug/up_arrow.2bpp"
DebugColor_GFX:
INCBIN "gfx/debug/color_test.2bpp"
-TilesetColorPicker:
+TilesetColorPicker: ; unreferenced
; A debug menu to test tileset palettes at runtime.
; dummied out
ret
@@ -1456,9 +1456,9 @@ DebugTileset_PlaceCursor: ; unreferenced
inc c
ret
-; unused
+.clearsprites: ; unreferenced
call ClearSprites
ret
-; unused
+.dummy: ; unreferenced
ret
diff --git a/engine/debug/debug_room.asm b/engine/debug/debug_room.asm
index 12259ce9..19f7f9e0 100644
--- a/engine/debug/debug_room.asm
+++ b/engine/debug/debug_room.asm
@@ -1147,9 +1147,9 @@ DebugRoom_BoxStructStrings:
.Move4: db "MOVE 4@"
.ID0: db "ID[0]@"
.ID1: db "ID[1]@"
-.BaseExp0: db "BASE EXP[0]@"
-.BaseExp1: db "BASE EXP[1]@"
-.BaseExp2: db "BASE EXP[2]@"
+.BaseExp0: db "BASE EXP[0]@" ; unreferenced
+.BaseExp1: db "BASE EXP[1]@" ; unreferenced
+.BaseExp2: db "BASE EXP[2]@" ; unreferenced
.HPExp0: db "HP EXP[0]@"
.HPExp1: db "HP EXP[1]@"
.AttkExp0: db "ATTK EXP[0]@"
diff --git a/engine/events/bug_contest/judging.asm b/engine/events/bug_contest/judging.asm
index 4f55fd78..da48eb96 100644
--- a/engine/events/bug_contest/judging.asm
+++ b/engine/events/bug_contest/judging.asm
@@ -67,7 +67,8 @@ ContestJudging_ThirdPlaceScoreText:
LoadContestantName:
; If a = 1, get your name.
- dec a ; BUG_CONTEST_PLAYER
+ assert BUG_CONTEST_PLAYER == 1
+ dec a
jr z, .player
; Find the pointer for the trainer class of the Bug Catching Contestant whose ID is in a.
ld c, a
diff --git a/engine/events/daycare.asm b/engine/events/daycare.asm
index 2edf2def..4648e9d2 100644
--- a/engine/events/daycare.asm
+++ b/engine/events/daycare.asm
@@ -160,7 +160,7 @@ DayCareAskDepositPokemon:
scf
ret
-.DaycareDummyText:
+.DaycareDummyText: ; unreferenced
text_far _DaycareDummyText
text_end
diff --git a/engine/events/engine_flags.asm b/engine/events/engine_flags.asm
index aebbacdc..13f9a9a8 100644
--- a/engine/events/engine_flags.asm
+++ b/engine/events/engine_flags.asm
@@ -57,7 +57,7 @@ EngineFlagAction::
jr z, .set ; b = 1
; Return the given flag in c.
-.check
+; check
ld a, [de]
and c
ld c, a
diff --git a/engine/events/field_moves.asm b/engine/events/field_moves.asm
index 39c92b2e..8085084f 100644
--- a/engine/events/field_moves.asm
+++ b/engine/events/field_moves.asm
@@ -421,7 +421,7 @@ FlyFunction_FrameTimer:
ret
.SpawnLeaf:
- ld hl, wce65
+ ld hl, wFrameCounter2
ld a, [hl]
inc [hl]
and $7
diff --git a/engine/events/heal_machine_anim.asm b/engine/events/heal_machine_anim.asm
index 7cf2f03a..ae2daa86 100644
--- a/engine/events/heal_machine_anim.asm
+++ b/engine/events/heal_machine_anim.asm
@@ -56,7 +56,7 @@ HealMachineAnim:
.Pointers:
; entries correspond to HEALMACHINE_* constants
dw .Pokecenter
- dw .ElmLab
+ dw .ElmsLab
dw .HallOfFame
healmachineanimseq: MACRO
@@ -68,7 +68,7 @@ ENDM
.Pokecenter:
healmachineanimseq LOADGFX, PCLOADBALLS, PLAYMUSIC, FINISH
-.ElmLab:
+.ElmsLab:
healmachineanimseq LOADGFX, PCLOADBALLS, PLAYMUSIC, FINISH
.HallOfFame:
healmachineanimseq LOADGFX, HOFLOADBALLS, HOFPLAYSFX, FINISH
diff --git a/engine/events/magnet_train.asm b/engine/events/magnet_train.asm
index b6b6e995..13b080aa 100644
--- a/engine/events/magnet_train.asm
+++ b/engine/events/magnet_train.asm
@@ -56,7 +56,7 @@ MagnetTrain:
ld [wRequested2bppSource + 1], a
ld [wRequested2bppDest], a
ld [wRequested2bppDest + 1], a
- ld [wRequested2bpp], a
+ ld [wRequested2bppSize], a
call ClearTilemap
pop af
diff --git a/engine/events/npc_trade.asm b/engine/events/npc_trade.asm
index d4e450c2..94773f2f 100644
--- a/engine/events/npc_trade.asm
+++ b/engine/events/npc_trade.asm
@@ -56,11 +56,12 @@ NPCTrade::
call DisableSpriteUpdates
ld a, [wJumptableIndex]
push af
- ld a, [wce64]
+ ; wTradeDialog aliases wFrameCounter, which TradeAnimation uses
+ ld a, [wTradeDialog]
push af
predef TradeAnimation
pop af
- ld [wce64], a
+ ld [wTradeDialog], a
pop af
ld [wJumptableIndex], a
call ReturnToMapWithSpeechTextbox
@@ -107,7 +108,7 @@ Trade_GetDialog:
ld e, NPCTRADE_DIALOG
call GetTradeAttribute
ld a, [hl]
- ld [wce64], a
+ ld [wTradeDialog], a
ret
DoNPCTrade:
@@ -366,7 +367,7 @@ PrintTradeText:
rept 6
add hl, de
endr
- ld a, [wce64]
+ ld a, [wTradeDialog]
ld e, a
add hl, de
add hl, de
diff --git a/engine/events/overworld.asm b/engine/events/overworld.asm
index 7aaaca90..e5b90447 100644
--- a/engine/events/overworld.asm
+++ b/engine/events/overworld.asm
@@ -268,7 +268,7 @@ CheckOverworldTileArrays:
xor a
ret
-INCLUDE "data/events/field_move_blocks.asm"
+INCLUDE "data/collision/field_move_blocks.asm"
FlashFunction:
call .CheckUseFlash
@@ -284,7 +284,6 @@ FlashFunction:
ld a, [wTimeOfDayPalset]
cp DARKNESS_PALSET
jr nz, .notadarkcave
-.useflash
call UseFlash
ld a, $81
ret
@@ -1391,7 +1390,7 @@ HasRockSmash:
ld d, ROCK_SMASH
call CheckPartyMove
jr nc, .yes
-.no
+; no
ld a, 1
jr .done
.yes
@@ -1596,7 +1595,7 @@ RodNothingText:
text_far _RodNothingText
text_end
-UnusedNothingHereText: ; unused
+UnusedNothingHereText: ; unreferenced
text_far _UnusedNothingHereText
text_end
@@ -1702,7 +1701,7 @@ Script_GetOnBike_Register:
special UpdatePlayerSprite
end
-; unused
+Overworld_DummyFunction: ; unreferenced
nop
ret
diff --git a/engine/events/poisonstep.asm b/engine/events/poisonstep.asm
index e6de6f19..827f6941 100644
--- a/engine/events/poisonstep.asm
+++ b/engine/events/poisonstep.asm
@@ -149,6 +149,6 @@ DoPoisonStep::
text_far _PoisonFaintText
text_end
-.PoisonWhiteoutText:
+.PoisonWhiteoutText: ; unreferenced
text_far _PoisonWhiteoutText
text_end
diff --git a/engine/events/print_unown_2.asm b/engine/events/print_unown_2.asm
index aaeeec76..4926bf53 100644
--- a/engine/events/print_unown_2.asm
+++ b/engine/events/print_unown_2.asm
@@ -9,7 +9,7 @@ RotateUnownFrontpic:
push bc
push hl
push bc
- ld de, wceed
+ ld de, wPrintedUnownTileSource
call .Copy
call .Rotate
ld hl, UnownPrinter_GBPrinterRectangle
@@ -19,10 +19,10 @@ RotateUnownFrontpic:
ld a, [hli]
ld e, a
ld d, [hl]
- ld hl, wcefd
+ ld hl, wPrintedUnownTileDest
call .Copy
pop hl
- ld bc, $10
+ ld bc, LEN_2BPP_TILE
add hl, bc
pop bc
inc c
@@ -30,7 +30,7 @@ RotateUnownFrontpic:
cp 7 * 7
jr c, .loop
- ld hl, wGameboyPrinterRAM
+ ld hl, wGameboyPrinter2bppSource
ld de, sScratch
ld bc, 7 * 7 tiles
call CopyBytes
@@ -44,7 +44,7 @@ RotateUnownFrontpic:
ret
.Copy:
- ld c, $10
+ ld c, LEN_2BPP_TILE
.loop_copy
ld a, [hli]
ld [de], a
@@ -54,18 +54,18 @@ RotateUnownFrontpic:
ret
.Rotate:
- ld hl, wcefd
+ ld hl, wPrintedUnownTileDest
ld e, %10000000
ld d, 8
.loop_decompress
push hl
- ld hl, wceed
+ ld hl, wPrintedUnownTileSource
call .CountSetBit
pop hl
ld a, b
ld [hli], a
push hl
- ld hl, wceee
+ ld hl, wPrintedUnownTileSource + 1
call .CountSetBit
pop hl
ld a, b
@@ -100,7 +100,7 @@ y = 0
rept \1
x = \1 * (\2 - 1) + y
rept \2
- dw wGameboyPrinterRAM tile x
+ dw wGameboyPrinter2bppSource tile x
x = x - \2
endr
y = y + 1
diff --git a/engine/events/prof_oaks_pc.asm b/engine/events/prof_oaks_pc.asm
index 40230d5b..b272e3fb 100644
--- a/engine/events/prof_oaks_pc.asm
+++ b/engine/events/prof_oaks_pc.asm
@@ -36,18 +36,18 @@ Rate:
ld hl, wPokedexSeen
ld b, wEndPokedexSeen - wPokedexSeen
call CountSetBits
- ld [wceed], a
+ ld [wTempPokedexSeenCount], a
ld hl, wPokedexCaught
ld b, wEndPokedexCaught - wPokedexCaught
call CountSetBits
- ld [wceee], a
+ ld [wTempPokedexCaughtCount], a
; print appropriate rating
call .UpdateRatingBuffers
ld hl, OakPCText3
call PrintText
call JoyWaitAorB
- ld a, [wceee]
+ ld a, [wTempPokedexCaughtCount]
ld hl, OakRatings
call FindOakRating
push de
@@ -57,10 +57,10 @@ Rate:
.UpdateRatingBuffers:
ld hl, wStringBuffer3
- ld de, wceed
+ ld de, wTempPokedexSeenCount
call .UpdateRatingBuffer
ld hl, wStringBuffer4
- ld de, wceee
+ ld de, wTempPokedexCaughtCount
call .UpdateRatingBuffer
ret
diff --git a/engine/events/specials.asm b/engine/events/specials.asm
index 3cedbf17..0b3e3560 100644
--- a/engine/events/specials.asm
+++ b/engine/events/specials.asm
@@ -15,7 +15,7 @@ Special::
INCLUDE "data/events/special_pointers.asm"
-DummySpecial_c389:
+UnusedDummySpecial:
ret
GameCornerPrizeMonCheckDex:
@@ -205,7 +205,7 @@ CardFlip:
call StartGameCornerGame
ret
-DummyNonfunctionalGameCornerGame:
+UnusedDummyGame:
call CheckCoinsAndCoinCase
ret c
ld a, BANK(_DummyGame)
@@ -414,17 +414,17 @@ GameboyCheck:
ldh a, [hCGB]
and a
jr nz, .cgb
-
ldh a, [hSGB]
and a
jr nz, .sgb
-
-.gb
+; gb
xor a ; GBCHECK_GB
jr .done
+
.sgb
ld a, GBCHECK_SGB
jr .done
+
.cgb
ld a, GBCHECK_CGB
.done
@@ -459,5 +459,4 @@ TrainerHouse:
ld [wScriptVar], a
jp CloseSRAM
-; unused
- nop
+ nop ; unused
diff --git a/engine/events/std_collision.asm b/engine/events/std_collision.asm
index 8c54c041..5ab11268 100644
--- a/engine/events/std_collision.asm
+++ b/engine/events/std_collision.asm
@@ -23,7 +23,7 @@ CheckFacingTileForStdScript::
xor a
ret
-INCLUDE "data/events/collision_stdscripts.asm"
+INCLUDE "data/collision/collision_stdscripts.asm"
Script_JumpStdFromRAM:
sjump wJumpStdScriptBuffer
diff --git a/engine/events/treemons.asm b/engine/events/treemons.asm
index c96df83a..42d89d1f 100644
--- a/engine/events/treemons.asm
+++ b/engine/events/treemons.asm
@@ -208,7 +208,7 @@ GetTreeScore:
cp 5
jr c, .good
-.bad
+; bad
xor a ; TREEMON_SCORE_BAD
ret
diff --git a/engine/games/card_flip.asm b/engine/games/card_flip.asm
index ba73f202..ab4ec624 100644
--- a/engine/games/card_flip.asm
+++ b/engine/games/card_flip.asm
@@ -1,7 +1,8 @@
CARDFLIP_LIGHT_OFF EQU "♂" ; $ef
CARDFLIP_LIGHT_ON EQU "♀" ; $f5
-CARDFLIP_DECK_SIZE EQU 4 * 6
+CARDFLIP_DECK_SIZE EQUS "(wDeckEnd - wDeck)"
+ assert wDiscardPileEnd - wDiscardPile == wDeckEnd - wDeck
DummyGameGFX:
; Graphics for an unused Game Corner
@@ -577,7 +578,7 @@ CardFlip_CopyOAM:
jr nz, .loop
ret
-CardFlip_ShiftDigitsUpOnePixel:
+CardFlip_ShiftDigitsUpOnePixel: ; unreferenced
; The top rows of digits 1-9 become the bottom rows of 0-8,
; so this routine relies on the top rows being blank.
ld de, vTiles0 tile "0"
diff --git a/engine/games/dummy_game.asm b/engine/games/dummy_game.asm
index a1ab49f2..648346fc 100644
--- a/engine/games/dummy_game.asm
+++ b/engine/games/dummy_game.asm
@@ -20,7 +20,7 @@ _DummyGame:
ld a, BANK(DummyGameGFX)
call FarCopyBytes
ld a, $8
- ld hl, wc508
+ ld hl, wSpriteAnimDict
ld [hli], a
ld [hl], $0
hlcoord 0, 0
@@ -133,11 +133,11 @@ endr
.next_try
dec [hl]
xor a
- ld [wce64], a
+ ld [wDummyGameCardChoice], a
ld hl, wJumptableIndex
inc [hl]
.PickCard1:
- ld a, [wce64]
+ ld a, [wDummyGameCardChoice]
and a
ret z
dec a
@@ -155,13 +155,13 @@ endr
call DummyGame_Card2Coord
call DummyGame_PlaceCard
xor a
- ld [wce64], a
+ ld [wDummyGameCardChoice], a
ld hl, wJumptableIndex
inc [hl]
ret
.PickCard2:
- ld a, [wce64]
+ ld a, [wDummyGameCardChoice]
and a
ret z
dec a
@@ -527,7 +527,7 @@ DummyGame_InterpretJoypad_AnimateCursor:
add hl, bc
ld a, [hl]
inc a
- ld [wce64], a
+ ld [wDummyGameCardChoice], a
ret
.pressed_left
diff --git a/engine/games/slot_machine.asm b/engine/games/slot_machine.asm
index 68a56bbc..47f1cc42 100644
--- a/engine/games/slot_machine.asm
+++ b/engine/games/slot_machine.asm
@@ -248,7 +248,7 @@ DebugPrintSlotBias: ; unreferenced
AnimateSlotReelIcons: ; unreferenced
; This animation was present in pokegold-spaceworld.
- ld hl, wce66
+ ld hl, wUnusedSlotReelIconDelay
ld a, [hl]
inc [hl]
and $7
diff --git a/engine/games/unown_puzzle.asm b/engine/games/unown_puzzle.asm
index 35caada2..48e36b89 100644
--- a/engine/games/unown_puzzle.asm
+++ b/engine/games/unown_puzzle.asm
@@ -504,13 +504,13 @@ CheckSolvedUnownPuzzle:
RedrawUnownPuzzlePieces:
call GetCurrentPuzzlePieceVTileCorner
- ld [wceed], a
+ ld [wUnownPuzzleCornerTile], a
xor a
call GetUnownPuzzleCoordData ; get pixel positions
ld a, [hli]
ld b, [hl]
ld c, a
- ld a, [wceed]
+ ld a, [wUnownPuzzleCornerTile]
cp $e0
jr z, .NoPiece
ld hl, .OAM_HoldingPiece
@@ -532,7 +532,7 @@ RedrawUnownPuzzlePieces:
add c
ld [de], a ; x
inc de
- ld a, [wceed]
+ ld a, [wUnownPuzzleCornerTile]
add [hl]
ld [de], a ; tile id
inc hl
diff --git a/engine/gfx/cgb_layouts.asm b/engine/gfx/cgb_layouts.asm
index 5fb23062..56b7d372 100644
--- a/engine/gfx/cgb_layouts.asm
+++ b/engine/gfx/cgb_layouts.asm
@@ -17,19 +17,18 @@ LoadSGBLayoutCGB:
ld l, a
ld h, 0
add hl, hl
- ld de, .dw
+ ld de, .Jumptable
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
- ld de, .ReturnFromJumpTable
+ ld de, .done
push de
jp hl
-
-.ReturnFromJumpTable:
+.done:
ret
-.dw
+.Jumptable:
dw _CGB_BattleGrayscale
dw _CGB_BattleColors
dw _CGB_PokegearPals
@@ -43,7 +42,7 @@ LoadSGBLayoutCGB:
dw _CGB_PartyMenu
dw _CGB_Evolution
dw _CGB_GSTitleScreen
- dw _CGB0d
+ dw _CGB_Unused0D
dw _CGB_MoveList
dw _CGB_BetaPikachuMinigame
dw _CGB_PokedexSearchOption
@@ -60,7 +59,7 @@ LoadSGBLayoutCGB:
dw _CGB_TradeTube
dw _CGB_TrainerOrMonFrontpicPals
dw _CGB_MysteryGift
- dw _CGB1e
+ dw _CGB_Unused1E
dw _CGB_Pokedex_5x5
_CGB_BattleGrayscale:
@@ -303,12 +302,12 @@ _CGB_BillsPC:
ldh [hCGBPalUpdate], a
ret
-Function95a0: ; unreferenced
+_CGB_Unknown: ; unreferenced
ld hl, BillsPCOrangePalette
call LoadHLPaletteIntoDE
jr .GotPalette
-.GetMonPalette:
+.GetMonPalette: ; unreferenced
ld bc, wTempMonDVs
call GetPlayerOrMonPalettePointer
call LoadPalette_White_Col1_Col2_Black
@@ -568,7 +567,7 @@ _CGB_GSTitleScreen:
ldh [hCGBPalUpdate], a
ret
-_CGB0d:
+_CGB_Unused0D:
ld hl, PalPacket_Diploma + 1
call CopyFourPalettes
call WipeAttrmap
@@ -831,7 +830,7 @@ _CGB_PlayerOrMonFrontpicPals:
call ApplyPals
ret
-_CGB1e:
+_CGB_Unused1E:
ld de, wBGPals1
ld a, [wCurPartySpecies]
call GetMonPalettePointer
diff --git a/engine/gfx/color.asm b/engine/gfx/color.asm
index d03724f8..18ae76a8 100644
--- a/engine/gfx/color.asm
+++ b/engine/gfx/color.asm
@@ -15,31 +15,31 @@ CheckShininess:
; Attack
ld a, [hl]
and 1 << SHINY_ATK_BIT
- jr z, .NotShiny
+ jr z, .not_shiny
; Defense
ld a, [hli]
and $f
cp SHINY_DEF_VAL
- jr nz, .NotShiny
+ jr nz, .not_shiny
; Speed
ld a, [hl]
and $f0
cp SHINY_SPD_VAL << 4
- jr nz, .NotShiny
+ jr nz, .not_shiny
; Special
ld a, [hl]
and $f
cp SHINY_SPC_VAL
- jr nz, .NotShiny
+ jr nz, .not_shiny
-.Shiny:
+; shiny
scf
ret
-.NotShiny:
+.not_shiny
and a
ret
@@ -49,30 +49,30 @@ Unused_CheckShininess:
; Attack
ld a, [hl]
cp 10 << 4
- jr c, .NotShiny
+ jr c, .not_shiny
; Defense
ld a, [hli]
and $f
cp 10
- jr c, .NotShiny
+ jr c, .not_shiny
; Speed
ld a, [hl]
cp 10 << 4
- jr c, .NotShiny
+ jr c, .not_shiny
; Special
ld a, [hl]
and $f
cp 10
- jr c, .NotShiny
+ jr c, .not_shiny
-.Shiny:
+; shiny
scf
ret
-.NotShiny:
+.not_shiny
and a
ret
@@ -144,6 +144,7 @@ SGB_ApplyPartyMenuHPPals:
Intro_LoadMagikarpPalettes:
call CheckCGB
ret z
+
; CGB only
ld hl, .BGPal
ld de, wBGPals1
@@ -715,13 +716,13 @@ endr
ret
PushSGBPals:
- ld a, [wd8ba]
+ ld a, [wJoypadDisable]
push af
- set 7, a
- ld [wd8ba], a
+ set JOYPAD_DISABLE_SGB_TRANSFER_F, a
+ ld [wJoypadDisable], a
call _PushSGBPals
pop af
- ld [wd8ba], a
+ ld [wJoypadDisable], a
ret
_PushSGBPals:
@@ -767,12 +768,14 @@ _PushSGBPals:
InitSGBBorder:
call CheckCGB
ret nz
+
; SGB/DMG only
di
- ld a, [wd8ba]
+ ld a, [wJoypadDisable]
push af
- set 7, a
- ld [wd8ba], a
+ set JOYPAD_DISABLE_SGB_TRANSFER_F, a
+ ld [wJoypadDisable], a
+
xor a
ldh [rJOYP], a
ldh [hSGB], a
@@ -792,13 +795,14 @@ InitSGBBorder:
.skip
pop af
- ld [wd8ba], a
+ ld [wJoypadDisable], a
ei
ret
InitCGBPals::
call CheckCGB
ret z
+
; CGB only
ld a, BANK(vTiles3)
ldh [rVBK], a
@@ -894,7 +898,7 @@ PushSGBBorder:
.LoadSGBBorderPointers:
ld hl, SGBBorderGFX
- ld de, SGBBorderMap
+ ld de, SGBBorderMapAndPalettes
ret
SGB_ClearVRAM:
@@ -1091,24 +1095,24 @@ INCLUDE "data/sgb_ctrl_packets.asm"
PredefPals:
INCLUDE "gfx/sgb/predef.pal"
-IF DEF(_GOLD)
-SGBBorderMap:
+SGBBorderMapAndPalettes:
; interleaved tile ids and palette ids, without the center 20x18 screen area
+IF DEF(_GOLD)
INCBIN "gfx/sgb/gold_border.sgb.tilemap"
-SGBBorderPalettes:
-; assumed to come after SGBBorderMap
-INCLUDE "gfx/sgb/gold_border.pal"
-SGBBorderGFX:
-INCBIN "gfx/sgb/gold_border.2bpp"
-
ELIF DEF(_SILVER)
-SGBBorderMap:
-; interleaved tile ids and palette ids, without the center 20x18 screen area
INCBIN "gfx/sgb/silver_border.sgb.tilemap"
-SGBBorderPalettes:
-; assumed to come after SGBBorderMap
+ENDC
+; four SGB palettes of 16 colors each; only the first 4 colors are used
+IF DEF(_GOLD)
+INCLUDE "gfx/sgb/gold_border.pal"
+ELIF DEF(_SILVER)
INCLUDE "gfx/sgb/silver_border.pal"
+ENDC
+
SGBBorderGFX:
+IF DEF(_GOLD)
+INCBIN "gfx/sgb/gold_border.2bpp"
+ELIF DEF(_SILVER)
INCBIN "gfx/sgb/silver_border.2bpp"
ENDC
@@ -1225,7 +1229,7 @@ INCLUDE "gfx/diploma/diploma.pal"
PartyMenuOBPals:
INCLUDE "gfx/stats/party_menu_ob.pal"
-UnusedBattleObjectPals:
+UnusedBattleObjectPals: ; unreferenced
INCLUDE "gfx/battle_anims/unused_battle_anims.pal"
GSTitleBGPals:
diff --git a/engine/gfx/load_font.asm b/engine/gfx/load_font.asm
index f8289ded..b41badc2 100644
--- a/engine/gfx/load_font.asm
+++ b/engine/gfx/load_font.asm
@@ -94,7 +94,7 @@ LoadStatsScreenPageTilesGFX:
call Get2bpp
ret
-LoadFontsBattleLevel:
+LoadFontsBattleLevel: ; unreferenced
ld de, FontBattleExtra + 14 tiles
ld hl, vTiles2 tile "<LV>" ; $6e
lb bc, BANK(FontBattleExtra), 1
diff --git a/engine/gfx/load_pics.asm b/engine/gfx/load_pics.asm
index 9109a7f9..34bffdb7 100644
--- a/engine/gfx/load_pics.asm
+++ b/engine/gfx/load_pics.asm
@@ -69,7 +69,6 @@ GetFrontpic:
cp EGG + 1
ret nc
-.is_a_pokemon
push de
call GetBaseData
ld a, [wBasePicSize]
@@ -133,13 +132,13 @@ GetMonBackpic:
cp EGG + 1
ret nc
-.is_a_pokemon
push de
ld a, BANK(sDecompressBuffer)
call OpenSRAM
; These are assumed to be at the same address in their respective banks.
- ld hl, PokemonPicPointers ; UnownPicPointers
+ assert PokemonPicPointers == UnownPicPointers
+ ld hl, PokemonPicPointers
ld a, [wCurPartySpecies]
ld d, BANK(PokemonPicPointers)
cp UNOWN
diff --git a/engine/gfx/sgb_layouts.asm b/engine/gfx/sgb_layouts.asm
index 2ed648f6..1b2799bf 100644
--- a/engine/gfx/sgb_layouts.asm
+++ b/engine/gfx/sgb_layouts.asm
@@ -35,7 +35,7 @@ LoadSGBLayout:
dw .SGB_PartyMenu
dw .SGB_Evolution
dw .SGB_GSTitleScreen
- dw .SGB0d
+ dw .SGB_Unused0D
dw .SGB_MoveList
dw .SGB_BetaPikachuMinigame
dw .SGB_PokedexSearchOption
@@ -52,7 +52,7 @@ LoadSGBLayout:
dw .SGB_TradeTube
dw .SGB_TrainerOrMonFrontpicPals
dw .SGB_MysteryGift
- dw .SGB1e
+ dw .SGB_Unused1E
dw .SGB_Pokedex_5x5
.SGB_BattleGrayscale:
@@ -403,7 +403,7 @@ endr
ld de, BlkPacket_AllPal0
ret
-.SGB0d:
+.SGB_Unused0D:
.SGB_TrainerCard:
ld hl, PalPacket_Diploma
ld de, BlkPacket_AllPal0
@@ -443,7 +443,7 @@ endr
ld de, wSGBPals + PALPACKET_LENGTH
ret
-.SGB1e:
+.SGB_Unused1E:
ld hl, PalPacket_Pal01
ld de, wSGBPals
ld bc, PALPACKET_LENGTH
@@ -456,7 +456,7 @@ endr
add hl, hl
ld de, PokemonPalettes
add hl, de
- ld a, [wce65]
+ ld a, [wUnusedSGB1eColorOffset]
and 3
sla a
sla a
diff --git a/engine/gfx/sprite_anims.asm b/engine/gfx/sprite_anims.asm
index 2a4cc868..93b69a3c 100644
--- a/engine/gfx/sprite_anims.asm
+++ b/engine/gfx/sprite_anims.asm
@@ -1066,7 +1066,7 @@ AnimSeq_SlotsGolem:
AnimSeq_SlotsChansey:
callfar Slots_AnimateChansey
- ld hl, wce64
+ ld hl, wSlotsDelay
ld a, [hl]
cp $2
ret nz
@@ -1091,7 +1091,7 @@ AnimSeq_SlotsChanseyEgg:
jr c, .move_right
call DeinitializeSprite
ld a, $4
- ld [wce64], a
+ ld [wSlotsDelay], a
ld de, SFX_PLACE_PUZZLE_PIECE_DOWN
call PlaySFX
ret
diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm
index a00aee8c..7b43eb82 100644
--- a/engine/items/item_effects.asm
+++ b/engine/items/item_effects.asm
@@ -1029,14 +1029,13 @@ LevelBallMultiplier:
ld b, $ff
ret
-; These two texts were carried over from gen 1.
-; They are not used in gen 2, and are dummied out.
+; BallDodgedText and BallMissedText were used in Gen 1.
-BallDodgedText:
+BallDodgedText: ; unreferenced
text_far _BallDodgedText
text_end
-BallMissedText:
+BallMissedText: ; unreferenced
text_far _BallMissedText
text_end
@@ -1864,14 +1863,14 @@ LoadCurHPIntoBuffer5:
ld [wBuffer5], a
ret
-LoadHPIntoBuffer5:
+LoadHPIntoBuffer5: ; unreferenced
ld a, d
ld [wBuffer6], a
ld a, e
ld [wBuffer5], a
ret
-LoadHPFromBuffer5:
+LoadHPFromBuffer5: ; unreferenced
ld a, [wBuffer6]
ld d, a
ld a, [wBuffer5]
@@ -2133,11 +2132,12 @@ INCLUDE "data/items/x_stats.asm"
PokeFluteEffect:
ld a, [wBattleMode]
and a
- jr nz, .dummy
-.dummy
+ jr nz, .in_battle
+ ; overworld flute code was dummied out here
+.in_battle
xor a
- ld [wceed], a
+ ld [wPokeFluteCuredSleep], a
ld b, $ff ^ SLP
@@ -2160,7 +2160,7 @@ PokeFluteEffect:
and b
ld [hl], a
- ld a, [wceed]
+ ld a, [wPokeFluteCuredSleep]
and a
ld hl, .PlayedFluteText
jp z, PrintText
@@ -2169,22 +2169,22 @@ PokeFluteEffect:
ld a, [wLowHealthAlarm]
and 1 << DANGER_ON_F
- jr nz, .dummy2
-.dummy2
+ jr nz, .dummy
+ ; more code was dummied out here
+.dummy
ld hl, .FluteWakeUpText
jp PrintText
.CureSleep:
ld de, PARTYMON_STRUCT_LENGTH
ld c, PARTY_LENGTH
-
.loop
ld a, [hl]
push af
and SLP
jr z, .not_asleep
- ld a, 1
- ld [wceed], a
+ ld a, TRUE
+ ld [wPokeFluteCuredSleep], a
.not_asleep
pop af
and b
@@ -2253,7 +2253,7 @@ ItemfinderEffect:
RestorePPEffect:
ld a, [wCurItem]
- ld [wceed], a
+ ld [wTempRestorePPItem], a
.loop
; Party Screen opens to choose on which mon to use the Item
@@ -2262,14 +2262,14 @@ RestorePPEffect:
jp c, PPRestoreItem_Cancel
.loop2
- ld a, [wceed]
+ ld a, [wTempRestorePPItem]
cp MAX_ELIXER
jp z, Elixer_RestorePPofAllMoves
cp ELIXER
jp z, Elixer_RestorePPofAllMoves
ld hl, RaiseThePPOfWhichMoveText
- ld a, [wceed]
+ ld a, [wTempRestorePPItem]
cp PP_UP
jr z, .ppup
ld hl, RestoreThePPOfWhichMoveText
@@ -2300,7 +2300,7 @@ RestorePPEffect:
call CopyName1
pop hl
- ld a, [wceed]
+ ld a, [wTempRestorePPItem]
cp PP_UP
jp nz, Not_PP_Up
@@ -2315,7 +2315,6 @@ RestorePPEffect:
jr c, .do_ppup
.CantUsePPUpOnSketch:
-.pp_is_maxed_out
ld hl, PPIsMaxedOutText
call PrintText
jr .loop2
@@ -2450,7 +2449,7 @@ RestorePP:
cp b
jr nc, .dont_restore
- ld a, [wceed]
+ ld a, [wTempRestorePPItem]
cp MAX_ELIXER
jr z, .restore_all
cp MAX_ETHER
@@ -2612,16 +2611,17 @@ WontHaveAnyEffectMessage:
ld hl, ItemWontHaveEffectText
jr CantUseItemMessage
-BelongsToSomeoneElseMessage:
+BelongsToSomeoneElseMessage: ; unreferenced
ld hl, ItemBelongsToSomeoneElseText
jr CantUseItemMessage
-CyclingIsntAllowedMessage:
+CyclingIsntAllowedMessage: ; unreferenced
ld hl, NoCyclingText
jr CantUseItemMessage
-CantGetOnYourBikeMessage:
+CantGetOnYourBikeMessage: ; unreferenced
ld hl, ItemCantGetOnText
+ ; fallthrough
CantUseItemMessage:
; Item couldn't be used.
@@ -2673,11 +2673,11 @@ ItemUsedText:
text_far _ItemUsedText
text_end
-ItemGotOnText:
+ItemGotOnText: ; unreferenced
text_far _ItemGotOnText
text_end
-ItemGotOffText:
+ItemGotOffText: ; unreferenced
text_far _ItemGotOffText
text_end
diff --git a/engine/items/items.asm b/engine/items/items.asm
index 78b0e2cd..42381b41 100644
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -481,7 +481,7 @@ GetNumberedTMHM:
jr c, .done
cp ITEM_DC - (TM01 - 1) - 1
jr c, .skip_one
-.skip_two
+; skip two
inc a
.skip_one
inc a
diff --git a/engine/items/pack.asm b/engine/items/pack.asm
index b3e1c5f1..994c7c5a 100644
--- a/engine/items/pack.asm
+++ b/engine/items/pack.asm
@@ -1520,7 +1520,7 @@ PC_Mart_BallsPocketMenuHeader:
dba PlaceMenuItemQuantity
dba UpdateItemDescription
-PackNoItemText:
+PackNoItemText: ; unreferenced
text_far _PackNoItemText
text_end
@@ -1560,7 +1560,7 @@ PackEmptyText:
text_far _PackEmptyText
text_end
-YouCantUseItInABattleText:
+YouCantUseItInABattleText: ; unreferenced
text_far _YouCantUseItInABattleText
text_end
diff --git a/engine/items/tmhm.asm b/engine/items/tmhm.asm
index e7c622d7..0a14ca50 100644
--- a/engine/items/tmhm.asm
+++ b/engine/items/tmhm.asm
@@ -76,7 +76,6 @@ ChooseMonToLearnTMHM:
ld bc, 12
call CopyBytes
call ClearBGPalettes
-ChooseMonToLearnTMHM_NoRefresh:
farcall LoadPartyMenuGFX
farcall InitPartyMenuWithCancel
farcall InitPartyMenuGFX
@@ -158,7 +157,7 @@ TeachTMHM:
and a
ret
-.unused
+.didnt_use ; unreferenced
ld a, 2
ld [wItemEffectSucceeded], a
.learned_move
diff --git a/engine/link/init_list.asm b/engine/link/init_list.asm
index b85cf001..3e16d349 100644
--- a/engine/link/init_list.asm
+++ b/engine/link/init_list.asm
@@ -44,9 +44,9 @@ InitList:
ld a, h
ld [wListPointer + 1], a
ld a, e
- ld [wUnusedCFFE], a
+ ld [wUnusedNamesPointer], a
ld a, d
- ld [wUnusedCFFE + 1], a
+ ld [wUnusedNamesPointer + 1], a
ld bc, ItemAttributes
ld a, c
ld [wItemAttributesPtr], a
diff --git a/engine/link/link.asm b/engine/link/link.asm
index 789e3d5e..2d8d458b 100644
--- a/engine/link/link.asm
+++ b/engine/link/link.asm
@@ -25,10 +25,11 @@ LinkCommunications:
hlcoord 4, 10
ld de, String_PleaseWait
call PlaceString
- ld hl, wce5d
- xor a ; LOW($5000)
+ ld hl, wLinkByteTimeout
+ assert LOW(SERIAL_LINK_BYTE_TIMEOUT) == 0
+ xor a ; LOW(SERIAL_LINK_BYTE_TIMEOUT)
ld [hli], a
- ld [hl], HIGH($5000)
+ ld [hl], HIGH(SERIAL_LINK_BYTE_TIMEOUT)
ld a, [wLinkMode]
cp LINK_TIMECAPSULE
jp nz, Gen2ToGen2LinkComms
@@ -82,9 +83,9 @@ Gen2ToGen1LinkComms:
call Serial_ExchangeBytes
ld a, SERIAL_NO_DATA_BYTE
ld [de], a
- ld hl, wLink_c508
+ ld hl, wc508
ld de, wTrademons
- ld bc, wTrademons - wLink_c508
+ ld bc, wTrademons - wc508
call Serial_ExchangeBytes
xor a
ldh [rIF], a
@@ -105,8 +106,8 @@ Gen2ToGen1LinkComms:
ld de, wLinkData
ld bc, $1a2
call Link_CopyOTData
- ld de, wPlayerTrademonSpecies
- ld hl, wTimeCapsulePartyMon1Species
+ ld de, wPlayerTrademon
+ ld hl, wTimeCapsulePlayerData
ld c, 2
.loop
ld a, [de]
@@ -160,12 +161,12 @@ Gen2ToGen1LinkComms:
.done_party
ld [de], a
- ld hl, wTimeCapsulePartyMon1Species
+ ld hl, wTimeCapsulePlayerData
call Link_ConvertPartyStruct1to2
ld a, LOW(wOTPartyMonOT)
- ld [wUnusedCFFE], a
+ ld [wUnusedNamesPointer], a
ld a, HIGH(wOTPartyMonOT)
- ld [wUnusedCFFE + 1], a
+ ld [wUnusedNamesPointer + 1], a
ld de, MUSIC_NONE
call PlayMusic
ldh a, [hSerialConnectionStatus]
@@ -226,9 +227,9 @@ Gen2ToGen2LinkComms:
call Serial_ExchangeBytes
ld a, SERIAL_NO_DATA_BYTE
ld [de], a
- ld hl, wLink_c508
+ ld hl, wc508
ld de, wTrademons
- ld bc, wTrademons - wLink_c508
+ ld bc, wTrademons - wc508
call Serial_ExchangeBytes
ld a, [wLinkMode]
cp LINK_TRADECENTER
@@ -251,8 +252,8 @@ Gen2ToGen2LinkComms:
ld de, wLinkData
ld bc, $1b9
call Link_CopyOTData
- ld de, wPlayerTrademonSpecies
- ld hl, wLinkPlayerPartyMon1Species
+ ld de, wPlayerTrademon
+ ld hl, wLinkPlayerData
ld c, 2
.loop1
ld a, [de]
@@ -377,9 +378,9 @@ Gen2ToGen2LinkComms:
ld bc, wOTPartyDataEnd - wOTPartyMons
call CopyBytes
ld a, LOW(wOTPartyMonOT)
- ld [wUnusedCFFE], a
+ ld [wUnusedNamesPointer], a
ld a, HIGH(wOTPartyMonOT)
- ld [wUnusedCFFE + 1], a
+ ld [wUnusedNamesPointer + 1], a
ld de, MUSIC_NONE
call PlayMusic
ldh a, [hSerialConnectionStatus]
@@ -451,6 +452,8 @@ LinkTimeout:
text_end
ExchangeBytes:
+; This is similar to Serial_ExchangeBytes,
+; but without a SERIAL_PREAMBLE_BYTE check.
ld a, TRUE
ldh [hSerialIgnoringInitialData], a
.loop
@@ -461,9 +464,9 @@ ExchangeBytes:
ld b, a
inc hl
ld a, 48
-.delay_cycles
+.wait
dec a
- jr nz, .delay_cycles
+ jr nz, .wait
ldh a, [hSerialIgnoringInitialData]
and a
ld a, b
@@ -514,7 +517,7 @@ FixDataForLinkTransfer:
ld [hli], a
dec b
jr nz, .loop2
- ld hl, wLink_c508
+ ld hl, wc508
ld a, SERIAL_PREAMBLE_BYTE
ld [hli], a
ld [hli], a
@@ -525,7 +528,7 @@ FixDataForLinkTransfer:
ld [hli], a
dec b
jr nz, .loop3
- ld hl, wTimeCapsulePartyMon1 - 1 + PARTY_LENGTH
+ ld hl, wTimeCapsulePlayerData - 1 + PARTY_LENGTH
ld de, wc512
lb bc, 0, 0
.loop4
@@ -1301,13 +1304,13 @@ LinkTrade_TradeStatsMenu:
pop af
ld [wMenuCursorY], a
dec a
- ld [wceed], a
+ ld [wCurTradePartyMon], a
ld [wPlayerLinkAction], a
call Serial_PrintWaitingTextAndSyncAndExchangeNybble
ld a, [wOtherPlayerLinkMode]
cp $f
jp z, InitTradeMenuDisplay
- ld [wceee], a
+ ld [wCurOTTradePartyMon], a
call LinkTradePlaceArrow
ld c, 100
call DelayFrames
@@ -1331,7 +1334,7 @@ LinkTrade_TradeStatsMenu:
xor a
ld [wce57], a
ld [wOtherPlayerLinkAction], a
- ld a, [wceee]
+ ld a, [wCurOTTradePartyMon]
ld hl, wOTPartySpecies
ld c, a
ld b, 0
@@ -1407,7 +1410,7 @@ LinkTradeCheckCancel:
jr nz, .loop1
ExitLinkCommunications:
xor a
- ld [wd8b7], a
+ ld [wUnusedLinkCommunicationByte], a
xor a
ldh [rSB], a
ldh [hSerialSend], a
@@ -1471,7 +1474,7 @@ LinkTrade:
ld b, 4
ld c, 18
call LinkTextboxAtHL
- ld a, [wceed]
+ ld a, [wCurTradePartyMon]
ld hl, wPartySpecies
ld c, a
ld b, 0
@@ -1480,10 +1483,10 @@ LinkTrade:
ld [wNamedObjectIndexBuffer], a
call GetPokemonName
ld hl, wStringBuffer1
- ld de, wceef
+ ld de, wBufferTrademonNick
ld bc, MON_NAME_LENGTH
call CopyBytes
- ld a, [wceee]
+ ld a, [wCurOTTradePartyMon]
ld hl, wOTPartySpecies
ld c, a
ld b, 0
@@ -1562,7 +1565,7 @@ LinkTrade:
.do_trade:
ld hl, sPartyMail
- ld a, [wceed]
+ ld a, [wCurTradePartyMon]
ld bc, MAIL_STRUCT_LENGTH
call AddNTimes
ld a, BANK(sPartyMail)
@@ -1571,7 +1574,7 @@ LinkTrade:
ld e, l
ld bc, MAIL_STRUCT_LENGTH
add hl, bc
- ld a, [wceed]
+ ld a, [wCurTradePartyMon]
ld c, a
.copy_mail
inc c
@@ -1592,7 +1595,7 @@ LinkTrade:
call AddNTimes
push hl
ld hl, wc8f4
- ld a, [wceee]
+ ld a, [wCurOTTradePartyMon]
ld bc, MAIL_STRUCT_LENGTH
call AddNTimes
pop de
@@ -1607,7 +1610,7 @@ LinkTrade:
ld bc, NAME_LENGTH
call CopyBytes
; species
- ld a, [wceed]
+ ld a, [wCurTradePartyMon]
ld hl, wPartySpecies
ld b, 0
ld c, a
@@ -1616,7 +1619,7 @@ LinkTrade:
ld [wPlayerTrademonSpecies], a
push af
; OT name
- ld a, [wceed]
+ ld a, [wCurTradePartyMon]
ld hl, wPartyMonOT
call SkipNames
ld de, wPlayerTrademonOTName
@@ -1624,7 +1627,7 @@ LinkTrade:
call CopyBytes
; ID
ld hl, wPartyMon1ID
- ld a, [wceed]
+ ld a, [wCurTradePartyMon]
call GetPartyLocation
ld a, [hli]
ld [wPlayerTrademonID], a
@@ -1632,7 +1635,7 @@ LinkTrade:
ld [wPlayerTrademonID + 1], a
; DVs
ld hl, wPartyMon1DVs
- ld a, [wceed]
+ ld a, [wCurTradePartyMon]
call GetPartyLocation
ld a, [hli]
ld [wPlayerTrademonDVs], a
@@ -1646,7 +1649,7 @@ LinkTrade:
ld bc, NAME_LENGTH
call CopyBytes
; species
- ld a, [wceee]
+ ld a, [wCurOTTradePartyMon]
ld hl, wOTPartySpecies
ld b, 0
ld c, a
@@ -1654,7 +1657,7 @@ LinkTrade:
ld a, [hl]
ld [wOTTrademonSpecies], a
; OT name
- ld a, [wceee]
+ ld a, [wCurOTTradePartyMon]
ld hl, wOTPartyMonOT
call SkipNames
ld de, wOTTrademonOTName
@@ -1662,7 +1665,7 @@ LinkTrade:
call CopyBytes
; ID
ld hl, wOTPartyMon1ID
- ld a, [wceee]
+ ld a, [wCurOTTradePartyMon]
call GetPartyLocation
ld a, [hli]
ld [wOTTrademonID], a
@@ -1670,21 +1673,21 @@ LinkTrade:
ld [wOTTrademonID + 1], a
; DVs
ld hl, wOTPartyMon1DVs
- ld a, [wceee]
+ ld a, [wCurOTTradePartyMon]
call GetPartyLocation
ld a, [hli]
ld [wOTTrademonDVs], a
ld a, [hl]
ld [wOTTrademonDVs + 1], a
- ld a, [wceed]
+ ld a, [wCurTradePartyMon]
ld [wCurPartyMon], a
ld hl, wPartySpecies
ld b, 0
ld c, a
add hl, bc
ld a, [hl]
- ld [wceed], a
+ ld [wCurTradePartyMon], a
xor a ; REMOVE_PARTY
ld [wPokemonWithdrawDepositParameter], a
@@ -1694,14 +1697,14 @@ LinkTrade:
ld [wCurPartyMon], a
ld a, TRUE
ld [wForceEvolution], a
- ld a, [wceee]
+ ld a, [wCurOTTradePartyMon]
push af
ld hl, wOTPartySpecies
ld b, 0
ld c, a
add hl, bc
ld a, [hl]
- ld [wceee], a
+ ld [wCurOTTradePartyMon], a
ld c, 100
call DelayFrames
@@ -2129,7 +2132,7 @@ CheckLinkTimeout_Receptionist:
ld a, $1
ld [wPlayerLinkAction], a
ld hl, wLinkTimeoutFrames
- ld a, $3
+ ld a, 3
ld [hli], a
xor a
ld [hl], a
diff --git a/engine/link/mystery_gift.asm b/engine/link/mystery_gift.asm
index dcea2e8c..f6ddc93a 100644
--- a/engine/link/mystery_gift.asm
+++ b/engine/link/mystery_gift.asm
@@ -1,3 +1,27 @@
+; hMGRole values
+IR_RECEIVER EQU 1
+IR_SENDER EQU 2
+
+; hMGStatusFlags error bits
+MG_WRONG_CHECKSUM_F EQU 0
+MG_TIMED_OUT_F EQU 1
+MG_CANCELED_F EQU 4
+MG_WRONG_PREFIX_F EQU 7
+
+; hMGStatusFlags values
+MG_WRONG_CHECKSUM EQU 1 << MG_WRONG_CHECKSUM_F
+MG_TIMED_OUT EQU 1 << MG_TIMED_OUT_F
+MG_CANCELED EQU 1 << MG_CANCELED_F
+MG_WRONG_PREFIX EQU 1 << MG_WRONG_PREFIX_F
+MG_NOT_OKAY EQU MG_WRONG_CHECKSUM | MG_TIMED_OUT | MG_CANCELED | MG_WRONG_PREFIX
+MG_OKAY EQU $ff ^ MG_NOT_OKAY
+MG_START_END EQU %11111111
+
+REGION_PREFIX EQU $96
+REGION_CODE EQU $90 ; USA
+
+MESSAGE_PREFIX EQU $5a
+
DoMysteryGift:
call ClearTilemap
call ClearSprites
@@ -7,22 +31,24 @@ DoMysteryGift:
ld de, .String_PressAToLink_BToCancel
call PlaceString
call WaitBGMap
- farcall PrepMysteryGiftDataToSend
- call MysteryGift_ClearTrainerData
- ld a, $2
- ld [wc901], a
- ld a, $14
- ld [wc902], a
- ldh a, [rIE]
- push af
- call Function29fc9
+ ; Prepare the first of two messages for wMysteryGiftPartnerData
+ farcall StageDataForMysteryGift
+ call ClearMysteryGiftTrainer
+ ld a, 2
+ ld [wMysteryGiftMessageCount], a
+ ld a, wMysteryGiftPartnerDataEnd - wMysteryGiftPartnerData
+ ld [wMysteryGiftStagedDataLength], a
+ ldh a, [rIE]
+ push af
+ call ExchangeMysteryGiftData
ld d, a
xor a
ldh [rIF], a
pop af
ldh [rIE], a
+
push de
call ClearTilemap
call EnableLCD
@@ -31,15 +57,16 @@ DoMysteryGift:
call GetSGBLayout
call SetPalettes
pop de
+
hlcoord 2, 8
ld a, d
ld de, .MysteryGiftCanceledText ; Link has been canceled
- cp $10
+ cp MG_CANCELED
jp z, .LinkCanceled
- cp $6c
+ cp MG_OKAY
jp nz, .CommunicationError
- ld a, [wc800]
- cp 3
+ ld a, [wMysteryGiftGameVersion]
+ cp POKEMON_PIKACHU_2_VERSION
jr z, .skip_checks
call .CheckAlreadyGotFiveGiftsToday
ld hl, .MysteryGiftFiveADayText ; Only 5 gifts a day
@@ -54,25 +81,27 @@ DoMysteryGift:
ld a, [wMysteryGiftPartnerBackupItem]
and a
jr nz, .FriendNotReady
- ld a, [wc800]
- cp 3
+ ld a, [wMysteryGiftGameVersion]
+ cp POKEMON_PIKACHU_2_VERSION
jr z, .skip_append_save
call .AddMysteryGiftPartnerID
- ld a, [wc800]
- cp 4
+ ld a, [wMysteryGiftGameVersion]
+ cp 4 ; ???
jr z, .skip_append_save
call .SaveMysteryGiftTrainerName
.skip_append_save
ld a, [wMysteryGiftPartnerSentDeco]
and a
- jr z, .item
+ jr z, .SentItem
+; sent decoration
ld a, [wMysteryGiftPartnerWhichDeco]
ld c, a
farcall MysteryGiftGetDecoration
push bc
- call MysteryGift_CheckAndSetDecorationAlreadyReceived
+ call CheckAndSetMysteryGiftDecorationAlreadyReceived
pop bc
- jr nz, .item
+ jr nz, .SentItem
+; keep the decoration if it wasn't already received
callfar GetDecorationName_c
ld h, d
ld l, e
@@ -82,17 +111,17 @@ DoMysteryGift:
ld hl, .MysteryGiftSentHomeText ; sent decoration to home
jr .PrintTextAndExit
-.item
+.SentItem:
call GetMysteryGiftBank
ld a, [wMysteryGiftPartnerWhichItem]
ld c, a
- farcall MysteryGiftGetItemHeldEffect
+ farcall MysteryGiftGetItem
ld a, c
ld [sBackupMysteryGiftItem], a
ld [wNamedObjectIndexBuffer], a
call CloseSRAM
call GetItemName
- ld hl, .MysteryGiftSentText ; sent item
+ ld hl, .MysteryGiftSentText ; sent item/decoration
jr .PrintTextAndExit
.LinkCanceled:
@@ -110,6 +139,7 @@ DoMysteryGift:
.FriendNotReady:
ld hl, .YourFriendIsNotReadyText ; friend not ready
+ ; fallthrough
.PrintTextAndExit:
call PrintText
@@ -159,7 +189,7 @@ DoMysteryGift:
.CheckAlreadyGotFiveGiftsToday:
call GetMysteryGiftBank
ld a, [sNumDailyMysteryGiftPartnerIDs]
- cp $5
+ cp MAX_MYSTERY_GIFT_PARTNERS
jp CloseSRAM
.CheckAlreadyGotAGiftFromThatPerson:
@@ -195,9 +225,9 @@ DoMysteryGift:
ld hl, sNumDailyMysteryGiftPartnerIDs
ld a, [hl]
inc [hl]
- ld hl, sDailyMysteryGiftPartnerIDs ; inc hl
+ ld hl, sDailyMysteryGiftPartnerIDs ; could have done "inc hl" instead
ld e, a
- ld d, $0
+ ld d, 0
add hl, de
add hl, de
ld a, [wMysteryGiftPartnerID]
@@ -208,223 +238,264 @@ DoMysteryGift:
.SaveMysteryGiftTrainerName:
call GetMysteryGiftBank
- ld a, $1
+ ld a, TRUE
ld [sMysteryGiftTrainerHouseFlag], a
ld hl, wMysteryGiftPartnerName
ld de, sMysteryGiftPartnerName
ld bc, NAME_LENGTH
call CopyBytes
- ld a, $1
+ assert sMysteryGiftPartnerName + NAME_LENGTH == sMysteryGiftUnusedFlag
+ ld a, TRUE
ld [de], a
inc de
- ld hl, wMysteryGiftTrainerData
- ld bc, (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 2
+ assert sMysteryGiftUnusedFlag + 1 == sMysteryGiftTrainer
+ ld hl, wMysteryGiftTrainer
+ ld bc, wMysteryGiftTrainerEnd - wMysteryGiftTrainer
call CopyBytes
jp CloseSRAM
-Function29fc9:
+ExchangeMysteryGiftData:
farcall ClearChannels
- call Function2a18c
+ call InitializeIRCommunicationInterrupts
-.loop2
- call Function2a1c4
- call Function2a20b
+.restart
+ call BeginIRCommunication
+ call InitializeIRCommunicationRoles
ldh a, [hMGStatusFlags]
- cp $10
- jp z, Function2a103
- cp $6c
- jr nz, .loop2
-
- ldh a, [hPrintNumBuffer + 8]
- cp $2
- jr z, Function2a055
- ld hl, hPrintNumBuffer
- ld b, $1
- call Function2a184
- jr nz, .ly_loop
- call Function2a07c
- jp nz, Function2a103
- jr Function2a03d
+ cp MG_CANCELED
+ jp z, EndOrContinueMysteryGiftIRCommunication
+ cp MG_OKAY
+ jr nz, .restart
+
+ ldh a, [hMGRole]
+ cp IR_SENDER
+ jr z, SenderExchangeMysteryGiftDataPayloads
+; receiver
+ ld hl, hMGExchangedByte
+ ld b, 1
+ call TryReceivingIRDataBlock
+ jr nz, .failed
+ call ReceiveMysteryGiftDataPayload_GotRegionPrefix
+ jp nz, EndOrContinueMysteryGiftIRCommunication
+ jr ReceiverExchangeMysteryGiftDataPayloads_GotPayload
+
+.failed
; Delay frame
-.ly_loop
+.wait_frame
ldh a, [rLY]
cp LY_VBLANK
- jr c, .ly_loop
+ jr c, .wait_frame
+
ld c, LOW(rRP)
- ld a, $c0
+ ld a, rRP_ENABLE_READ_MASK
ldh [c], a
- ld b, 240 ; This might have been intended as a 4-second timeout buffer.
- ; However, it is reset with each frame.
-.loop3
- push bc
- call MysteryGift_ReadJoypad
- ld b, $2
+ ld b, 60 * 4 ; 4 seconds
+.continue
+ push bc
+ call MysteryGift_UpdateJoypad
+ ld b, 1 << rRP_RECEIVING
ld c, LOW(rRP)
- ; Delay frame
-.ly_loop2
+.in_vblank
ldh a, [c]
and b
ld b, a
ldh a, [rLY]
cp LY_VBLANK
- jr nc, .ly_loop2
-.ly_loop3
+ jr nc, .in_vblank
+.wait_vblank
ldh a, [c]
and b
ld b, a
ldh a, [rLY]
cp LY_VBLANK
- jr c, .ly_loop3
-
+ jr c, .wait_vblank
ld a, b
pop bc
+ ; Restart if the 4-second timeout has elapsed
dec b
- jr z, .loop2 ; we never jump here
+ jr z, .restart
+ ; Restart if rRP is not receiving data
or a
- jr nz, .loop2
- ; Check if we've pressed the B button
+ jr nz, .restart
+ ; Check if we've pressed the B button to cancel
ldh a, [hMGJoypadReleased]
bit B_BUTTON_F, a
- jr z, .loop3
- ld a, $10
+ jr z, .continue
+ ld a, MG_CANCELED
ldh [hMGStatusFlags], a
- jp Function2a103
-
-Function2a037:
- call Function2a073
- jp nz, Function2a103
-; fallthrough
-Function2a03d:
- call Function2a166
- jp nz, Function2a103
- call Function2a0bb
- jp nz, Function2a103
- call Function2a171
- jp nz, Function2a103
- call Function2a461
- jp Function2a103
-
-Function2a055:
- call Function2a0bb
- jp nz, Function2a103
- call Function2a171
- jp nz, Function2a103
- call Function2a073
- jp nz, Function2a103
- call Function2a166
- jp nz, Function2a103
- call Function2a45c
- jp Function2a103
-
-Function2a073:
- ld hl, hPrintNumBuffer
- ld b, $1
- call Function2a184
+ jp EndOrContinueMysteryGiftIRCommunication
+
+ReceiverExchangeMysteryGiftDataPayloads:
+ ; Receive the data payload
+ call ReceiveMysteryGiftDataPayload
+ jp nz, EndOrContinueMysteryGiftIRCommunication
+ ; fallthrough
+ReceiverExchangeMysteryGiftDataPayloads_GotPayload:
+ ; Switch roles
+ call BeginSendingIRCommunication
+ jp nz, EndOrContinueMysteryGiftIRCommunication
+ ; Send the data payload
+ call SendMysteryGiftDataPayload
+ jp nz, EndOrContinueMysteryGiftIRCommunication
+ ; Switch roles
+ call BeginReceivingIRCommunication
+ jp nz, EndOrContinueMysteryGiftIRCommunication
+ ; Receive an empty block
+ call ReceiveEmptyIRDataBlock
+ jp EndOrContinueMysteryGiftIRCommunication
+
+SenderExchangeMysteryGiftDataPayloads:
+ ; Send the data payload
+ call SendMysteryGiftDataPayload
+ jp nz, EndOrContinueMysteryGiftIRCommunication
+ ; Switch roles
+ call BeginReceivingIRCommunication
+ jp nz, EndOrContinueMysteryGiftIRCommunication
+ ; Receive the data payload
+ call ReceiveMysteryGiftDataPayload
+ jp nz, EndOrContinueMysteryGiftIRCommunication
+ ; Switch roles
+ call BeginSendingIRCommunication
+ jp nz, EndOrContinueMysteryGiftIRCommunication
+ ; Send an empty block
+ call SendEmptyIRDataBlock
+ jp EndOrContinueMysteryGiftIRCommunication
+
+ReceiveMysteryGiftDataPayload:
+ ; Receive the region prefix
+ ld hl, hMGExchangedByte
+ ld b, 1
+ call TryReceivingIRDataBlock
ret nz
-; fallthrough
-Function2a07c:
- call Function2a461
+ ; fallthrough
+ReceiveMysteryGiftDataPayload_GotRegionPrefix:
+ ; Receive an empty block
+ call ReceiveEmptyIRDataBlock
ldh a, [hMGStatusFlags]
- cp $6c
+ cp MG_OKAY
ret nz
- ldh a, [hPrintNumBuffer]
- cp $96
- jp nz, Function2a160
- ld a, $90
- ldh [hPrintNumBuffer], a
- call Function2a166
+ ; Verify the received region prefix
+ ldh a, [hMGExchangedByte]
+ cp REGION_PREFIX
+ jp nz, WrongMysteryGiftRegion
+ ld a, REGION_CODE
+ ldh [hMGExchangedByte], a
+ ; Switch roles
+ call BeginSendingIRCommunication
ret nz
- ld hl, hPrintNumBuffer
- ld b, $1
- call Function2a17c
+ ; Send the region code
+ ld hl, hMGExchangedByte
+ ld b, 1
+ call TrySendingIRDataBlock
ret nz
- call Function2a45c
+ ; Send an empty block
+ call SendEmptyIRDataBlock
ldh a, [hMGStatusFlags]
- cp $6c
+ cp MG_OKAY
ret nz
- call Function2a171
+ ; Switch roles
+ call BeginReceivingIRCommunication
ret nz
- ld hl, wMysteryGiftTrainerData
- ld a, [wc902]
+ ; Receive the staged data
+ ld hl, wMysteryGiftTrainer
+ ld a, [wMysteryGiftStagedDataLength]
ld b, a
- call Function2a184
+ call TryReceivingIRDataBlock
ret nz
- call Function2a461
+ ; Receive an empty block
+ call ReceiveEmptyIRDataBlock
ldh a, [hMGStatusFlags]
- cp $6c
+ cp MG_OKAY
ret
-Function2a0bb:
- ld a, $96
- ldh [hPrintNumBuffer], a
- ld hl, hPrintNumBuffer
- ld b, $1
- call Function2a17c
+SendMysteryGiftDataPayload:
+ ; Send the region prefix
+ ld a, REGION_PREFIX
+ ldh [hMGExchangedByte], a
+ ld hl, hMGExchangedByte
+ ld b, 1
+ call TrySendingIRDataBlock
ret nz
- call Function2a45c
+ ; Send an empty block
+ call SendEmptyIRDataBlock
ldh a, [hMGStatusFlags]
- cp $6c
+ cp MG_OKAY
ret nz
- call Function2a171
+ ; Switch roles
+ call BeginReceivingIRCommunication
ret nz
- ld hl, hPrintNumBuffer
- ld b, $1
- call Function2a184
+ ; Receive the region code
+ ld hl, hMGExchangedByte
+ ld b, 1
+ call TryReceivingIRDataBlock
ret nz
- call Function2a461
+ ; Receive an empty block
+ call ReceiveEmptyIRDataBlock
ldh a, [hMGStatusFlags]
- cp $6c
+ cp MG_OKAY
ret nz
- ldh a, [hPrintNumBuffer]
- cp $90
- jp nz, Function2a160
- call Function2a166
+ ; Verify the received region code
+ ldh a, [hMGExchangedByte]
+ cp REGION_CODE
+ jp nz, WrongMysteryGiftRegion
+ ; Switch roles
+ call BeginSendingIRCommunication
ret nz
- ld hl, wLinkData
- ld a, [wc902]
+ ; Send the staged data
+ ld hl, wMysteryGiftStaging
+ ld a, [wMysteryGiftStagedDataLength]
ld b, a
- call Function2a17c
+ call TrySendingIRDataBlock
ret nz
- call Function2a45c
+ ; Send an empty block
+ call SendEmptyIRDataBlock
ldh a, [hMGStatusFlags]
- cp $6c
+ cp MG_OKAY
ret
-Function2a103:
+EndOrContinueMysteryGiftIRCommunication:
nop
ldh a, [hMGStatusFlags]
- cp $10
+ ; Quit if player canceled
+ cp MG_CANCELED
jr z, .quit
- cp $6c
+ ; Quit if there was a communication error
+ cp MG_OKAY
jr nz, .quit
- ld hl, wc901
+ ; Quit if all messages are sent/received
+ ld hl, wMysteryGiftMessageCount
dec [hl]
jr z, .quit
- ld hl, wMysteryGiftTrainerData
+ ; Quit if communicating with Pokémon Pikachu 2 device
+ ld hl, wMysteryGiftTrainer
ld de, wMysteryGiftPartnerData
ld bc, wMysteryGiftPartnerDataEnd - wMysteryGiftPartnerData
call CopyBytes
- ld a, [wMysteryGiftTrainerData]
- cp $3
+ ld a, [wMysteryGiftTrainer] ; first byte is the version
+ cp POKEMON_PIKACHU_2_VERSION
jr nc, .quit
+
+ ; Prepare the second message for wMysteryGiftTrainer
farcall StagePartyDataForMysteryGift
- call MysteryGift_ClearTrainerData
- ld a, $26
- ld [wc902], a
- ldh a, [hPrintNumBuffer + 8]
- cp $2
- jr z, .asm_2a143
- call Function2a171
- jr nz, Function2a103
- jp Function2a037
-
-.asm_2a143
- call Function2a166
- jr nz, Function2a103
- jp Function2a055
-
-.quit:
+ call ClearMysteryGiftTrainer
+ ld a, wMysteryGiftTrainerEnd - wMysteryGiftTrainer
+ ld [wMysteryGiftStagedDataLength], a
+
+ ldh a, [hMGRole]
+ cp IR_SENDER
+ jr z, .sender
+; receiver
+ call BeginReceivingIRCommunication
+ jr nz, EndOrContinueMysteryGiftIRCommunication
+ jp ReceiverExchangeMysteryGiftDataPayloads
+
+.sender
+ call BeginSendingIRCommunication
+ jr nz, EndOrContinueMysteryGiftIRCommunication
+ jp SenderExchangeMysteryGiftDataPayloads
+
+.quit
xor a
ldh [rIF], a
ldh a, [rIE]
@@ -434,50 +505,50 @@ Function2a103:
call DelayFrame
ldh a, [hMGStatusFlags]
push af
- call Function2a1ce
+ call EndIRCommunication
pop af
ret
-Function2a160:
- ld a, $80
+WrongMysteryGiftRegion:
+ ld a, MG_WRONG_PREFIX
ldh [hMGStatusFlags], a
and a
ret
-Function2a166:
- call Function2a1c4
- call Function2a274
+BeginSendingIRCommunication:
+ call BeginIRCommunication
+ call SendIRHelloMessage
ldh a, [hMGStatusFlags]
- cp $6c
+ cp MG_OKAY
ret
-Function2a171:
- call Function2a1c4
- call Function2a22c
+BeginReceivingIRCommunication:
+ call BeginIRCommunication
+ call ReceiveIRHelloMessage
ldh a, [hMGStatusFlags]
- cp $6c
+ cp MG_OKAY
ret
-Function2a17c:
- call Function2a2c1
+TrySendingIRDataBlock:
+ call SendIRDataBlock
ldh a, [hMGStatusFlags]
- cp $6c
+ cp MG_OKAY
ret
-Function2a184:
- call Function2a385
+TryReceivingIRDataBlock:
+ call ReceiveIRDataBlock
ldh a, [hMGStatusFlags]
- cp $6c
+ cp MG_OKAY
ret
-Function2a18c:
- call Function2a1a2
+InitializeIRCommunicationInterrupts:
+ call StartFastIRTimer
ld a, 1 << TIMER
ldh [rIE], a
xor a
ldh [rIF], a
- call Function2a1c4
-; runs for ~$40400 cycles
+ call BeginIRCommunication
+; waits for ~$40400 cycles = ~0.25 seconds
xor a
ld b, a
.busy_wait
@@ -487,69 +558,76 @@ Function2a18c:
jr nz, .busy_wait
ret
-Function2a1a2:
+StartFastIRTimer:
+; Starts a 65,536 Hz timer that interrupts every 3 increments (21,845 Hz).
xor a
ldh [rTAC], a
- ld a, $fe
+ ld a, -2
ldh [rTMA], a
ldh [rTIMA], a
- ld a, $2
+ ld a, rTAC_65536_HZ
ldh [rTAC], a
- or $4
+ or 1 << rTAC_ON
ldh [rTAC], a
ret
-Function2a1b4:
+StartSlowIRTimer:
+; Starts a 65,536 Hz timer that interrupts every 256 increments (256 Hz).
xor a
ldh [rTAC], a
ldh [rTMA], a
ldh [rTIMA], a
- ld a, $2
+ ld a, rTAC_65536_HZ
ldh [rTAC], a
- or $4
+ or 1 << rTAC_ON
ldh [rTAC], a
ret
-Function2a1c4:
- ld a, $c0
- call Function2a2ba
- ld a, $1
- ldh [hPrintNumBuffer + 8], a
+BeginIRCommunication:
+ ld a, rRP_ENABLE_READ_MASK
+ call ToggleIRCommunication
+ ld a, IR_RECEIVER
+ ldh [hMGRole], a
ret
-Function2a1ce:
+EndIRCommunication:
xor a
- call Function2a2ba
- ld a, $2
+ call ToggleIRCommunication
+ ld a, rTAC_65536_HZ
ldh [rTAC], a
ret
-Function2a1d7:
+ReceiveInfraredLEDOn:
+; Count interrupts of the partner's IR LED on; quit after 256-d interrupts.
+.recv_loop
inc d
ret z
xor a
ldh [rIF], a
halt
ldh a, [c]
- bit 1, a
- jr z, Function2a1d7
+ bit rRP_RECEIVING, a
+ jr z, .recv_loop
or a
ret
-Function2a1e5:
+ReceiveInfraredLEDOff:
+; Count interrupts of the partner's IR LED off; quit after 256-d interrupts.
+.no_recv_loop
inc d
ret z
xor a
ldh [rIF], a
halt
ldh a, [c]
- bit 1, a
- jr nz, Function2a1e5
+ bit rRP_RECEIVING, a
+ jr nz, .no_recv_loop
or a
ret
-Function2a1f3:
- ld a, $c1
+SendInfraredLEDOn:
+; Holds the IR LED on for d-1 interrupts.
+ ld a, rRP_ENABLE_READ_MASK | (1 << rRP_LED_ON)
ldh [c], a
.wait
dec d
@@ -559,8 +637,9 @@ Function2a1f3:
halt
jr .wait
-Function2a1ff:
- ld a, $c0
+SendInfraredLEDOff:
+; Holds the IR LED off for d-1 interrupts.
+ ld a, rRP_ENABLE_READ_MASK
ldh [c], a
.wait
dec d
@@ -570,175 +649,204 @@ Function2a1ff:
halt
jr .wait
-Function2a20b:
- ld d, $0
+InitializeIRCommunicationRoles:
+ ld d, 0
ld e, d
- ld a, $1
- ldh [hPrintNumBuffer + 8], a
+
+ ld a, IR_RECEIVER
+ ldh [hMGRole], a
.loop
- call MysteryGift_ReadJoypad
- ld b, $2
+ call MysteryGift_UpdateJoypad
+ ld b, 1 << rRP_RECEIVING
ld c, LOW(rRP)
+ ; Check if we've pressed the B button to cancel
ldh a, [hMGJoypadReleased]
bit B_BUTTON_F, a
- jr z, .next
- ld a, $10
+ jr z, .not_canceled
+ ld a, MG_CANCELED
ldh [hMGStatusFlags], a
ret
-.next
- bit 0, a
- jr nz, Function2a268
+.not_canceled
+ ; Check if we've pressed the A button to start sending
+ bit A_BUTTON_F, a
+ jr nz, SendIRHelloMessageAfterDelay
+ ; If rRP is not receiving data, keep checking for input
ldh a, [c]
and b
jr nz, .loop
+ ; fallthrough
-Function2a22c:
+ReceiveIRHelloMessage:
ld c, LOW(rRP)
- ld d, $0
+ ld d, 0
ld e, d
- call Function2a1e5
- jp z, Function2a370
+
+ call ReceiveInfraredLEDOff
+ jp z, InfraredLEDReceiveTimedOut
ld d, e
- call Function2a1d7
- jp z, Function2a370
- call Function2a1e5
- jp z, Function2a370
- call Function2a1d7
- jp z, Function2a370
- ld a, $6c
+ call ReceiveInfraredLEDOn
+ jp z, InfraredLEDReceiveTimedOut
+ call ReceiveInfraredLEDOff
+ jp z, InfraredLEDReceiveTimedOut
+ call ReceiveInfraredLEDOn
+ jp z, InfraredLEDReceiveTimedOut
+
+ ld a, MG_OKAY
ldh [hMGStatusFlags], a
- ld d, $3d
- call Function2a1ff
- ld d, $5
- call Function2a1f3
- ld d, $15
- call Function2a1ff
- ld d, $5
- call Function2a1f3
- ld d, $5
- call Function2a1ff
+
+ ld d, 61
+ call SendInfraredLEDOff
+ ld d, 5
+ call SendInfraredLEDOn
+ ld d, 21
+ call SendInfraredLEDOff
+ ld d, 5
+ call SendInfraredLEDOn
+ ld d, 5
+ call SendInfraredLEDOff
ret
-Function2a268:
+SendIRHelloMessageAfterDelay:
; Wait a random amount of time
call Random
ld e, a
and $f
ld d, a
-.loop
+.wait_loop
dec de
ld a, d
or e
- jr nz, .loop
-Function2a274:
- ld a, $2
- ldh [hPrintNumBuffer + 8], a
+ jr nz, .wait_loop
+ ; fallthrough
+
+SendIRHelloMessage:
+ ld a, IR_SENDER
+ ldh [hMGRole], a
+
ld c, LOW(rRP)
- ld d, $0
+ ld d, 0
ld e, d
- ld d, $3d
- call Function2a1ff
- ld d, $5
- call Function2a1f3
- ld d, $15
- call Function2a1ff
- ld d, $5
- call Function2a1f3
- ld d, $5
- call Function2a1ff
+
+ ld d, 61
+ call SendInfraredLEDOff
+ ld d, 5
+ call SendInfraredLEDOn
+ ld d, 21
+ call SendInfraredLEDOff
+ ld d, 5
+ call SendInfraredLEDOn
+ ld d, 5
+ call SendInfraredLEDOff
+
ld d, e
- call Function2a1e5
- jp z, Function2a370
+ call ReceiveInfraredLEDOff
+ jp z, InfraredLEDReceiveTimedOut
ld d, e
- call Function2a1d7
- jp z, Function2a370
- call Function2a1e5
- jp z, Function2a370
- call Function2a1d7
- jp z, Function2a370
- ld d, $3d
- call Function2a1ff
- ld a, $6c
+ call ReceiveInfraredLEDOn
+ jp z, InfraredLEDReceiveTimedOut
+ call ReceiveInfraredLEDOff
+ jp z, InfraredLEDReceiveTimedOut
+ call ReceiveInfraredLEDOn
+ jp z, InfraredLEDReceiveTimedOut
+
+ ld d, 61
+ call SendInfraredLEDOff
+
+ ld a, MG_OKAY
ldh [hMGStatusFlags], a
ret
-Function2a2ba:
+ToggleIRCommunication:
ldh [rRP], a
- ld a, $ff
+ ld a, MG_START_END
ldh [hMGStatusFlags], a
ret
-Function2a2c1:
+SendIRDataBlock:
+; Send b bytes of data in three messages:
+; 1. two bytes: MESSAGE_PREFIX and the length b
+; 2. b bytes: the actual data
+; 3. two bytes: a little-endian checksum
+; Then receive a one-byte acknowledgement message: the status.
xor a
- ldh [hPrintNumBuffer + 4], a
- ldh [hPrintNumBuffer + 5], a
+ ldh [hMGChecksum + 0], a
+ ldh [hMGChecksum + 1], a
push hl
push bc
ld c, LOW(rRP)
- ld d, $3d
- call Function2a1ff
- ld hl, hPrintNumBuffer + 1
- ld a, $5a
+ ld d, 61
+ call SendInfraredLEDOff
+ ld hl, hMGExchangedWord
+ ld a, MESSAGE_PREFIX
ld [hli], a
ld [hl], b
dec hl
- ld b, $2
- call Function2a304
+ ld b, 2
+ call SendIRDataMessage
pop bc
pop hl
- call Function2a304
- ldh a, [hPrintNumBuffer + 4]
- ldh [hPrintNumBuffer + 1], a
- ldh a, [hPrintNumBuffer + 5]
- ldh [hPrintNumBuffer + 2], a
+ call SendIRDataMessage
+ ldh a, [hMGChecksum + 0]
+ ldh [hMGExchangedWord + 0], a
+ ldh a, [hMGChecksum + 1]
+ ldh [hMGExchangedWord + 1], a
push hl
- ld hl, hPrintNumBuffer + 1
- ld b, $2
- call Function2a304
+ ld hl, hMGExchangedWord
+ ld b, 2
+ call SendIRDataMessage
ld hl, hMGStatusFlags
- ld b, $1
- call Function2a3dd
- ldh a, [hPrintNumBuffer + 1]
- ldh [hPrintNumBuffer + 4], a
- ldh a, [hPrintNumBuffer + 2]
- ldh [hPrintNumBuffer + 5], a
+ ld b, 1
+ call ReceiveIRDataMessage
+ ldh a, [hMGExchangedWord + 0]
+ ldh [hMGChecksum + 0], a
+ ldh a, [hMGExchangedWord + 1]
+ ldh [hMGChecksum + 1], a
pop hl
ret
-Function2a304:
+SendIRDataMessage:
+; Send b bytes of data one bit at a time, and update the checksum.
ld c, LOW(rRP)
- ld d, $5
- call Function2a1ff
- ld d, $5
- call Function2a1f3
- ld d, $15
- call Function2a1ff
+
+ ld d, 5
+ call SendInfraredLEDOff
+ ld d, 5
+ call SendInfraredLEDOn
+ ld d, 21
+ call SendInfraredLEDOff
+
+ ; b = -b - 1; then count up to 0
ld a, b
cpl
ld b, a
- ld a, $f4
+
+ ld a, -12
ldh [rTMA], a
-.main_loop
+.byte_loop
inc b
jr z, .done
- ld a, $8
- ldh [hPrintNumBuffer + 3], a
+ ld a, 8
+ ldh [hMGNumBits], a
+ ; Get the next data byte
ld a, [hli]
ld e, a
- ldh a, [hPrintNumBuffer + 4]
+ ; Add the next data byte to the checksum
+ ldh a, [hMGChecksum + 0]
add e
- ldh [hPrintNumBuffer + 4], a
- ldh a, [hPrintNumBuffer + 5]
+ ldh [hMGChecksum + 0], a
+ ldh a, [hMGChecksum + 1]
adc 0
- ldh [hPrintNumBuffer + 5], a
-.inner_loop
+ ldh [hMGChecksum + 1], a
+ ; Send each bit of the byte
+.bit_loop
xor a
ldh [rIF], a
halt
- ld a, $c1
+ ld a, rRP_ENABLE_READ_MASK | (1 << rRP_LED_ON)
ldh [rRP], a
- ld d, $1
+ ; Turn the LED off for longer if the bit is 1
+ ld d, 1
ld a, e
rlca
ld e, a
@@ -746,9 +854,9 @@ Function2a304:
inc d
.wait
ldh a, [rTIMA]
- cp $f8
+ cp -8
jr c, .wait
- ld a, $c0
+ ld a, rRP_ENABLE_READ_MASK
ldh [rRP], a
dec d
jr z, .no_halt
@@ -756,133 +864,145 @@ Function2a304:
ldh [rIF], a
halt
.no_halt
- ldh a, [hPrintNumBuffer + 3]
+ ldh a, [hMGNumBits]
dec a
- jr z, .main_loop
- ldh [hPrintNumBuffer + 3], a
- jr .inner_loop
+ jr z, .byte_loop
+ ldh [hMGNumBits], a
+ jr .bit_loop
.done
- ld a, $fe
+ ld a, -2
ldh [rTMA], a
xor a
ldh [rIF], a
halt
- ld d, $5
- call Function2a1f3
- ld d, $11
- call Function2a1ff
+
+ ld d, 5
+ call SendInfraredLEDOn
+ ld d, 17
+ call SendInfraredLEDOff
ret
-Function2a370:
+InfraredLEDReceiveTimedOut:
ldh a, [hMGStatusFlags]
- or $2
+ or MG_TIMED_OUT
ldh [hMGStatusFlags], a
ret
-Function2a377:
+ReceivedWrongIRChecksum:
ldh a, [hMGStatusFlags]
- or $1
+ or MG_WRONG_CHECKSUM
ldh [hMGStatusFlags], a
ret
-Function2a37e:
+ReceivedWrongIRMessagePrefix:
ldh a, [hMGStatusFlags]
- or $80
+ or MG_WRONG_PREFIX
ldh [hMGStatusFlags], a
ret
-Function2a385:
+ReceiveIRDataBlock:
+; Receive b bytes of data in three messages:
+; 1. two bytes: MESSAGE_PREFIX and the length b
+; 2. b bytes: the actual data
+; 3. two bytes: a little-endian checksum
+; Then send a one-byte acknowledgement message: the status.
xor a
- ldh [hPrintNumBuffer + 4], a
- ldh [hPrintNumBuffer + 5], a
+ ldh [hMGChecksum + 0], a
+ ldh [hMGChecksum + 1], a
push bc
push hl
- ld hl, hPrintNumBuffer + 1
- ld b, $2
- call Function2a3dd
- ldh a, [hPrintNumBuffer + 2]
- ldh [hPrintNumBuffer + 7], a
+ ld hl, hMGExchangedWord
+ ld b, 2
+ call ReceiveIRDataMessage
+ ldh a, [hMGExchangedWord + 1]
+ ldh [hMGUnusedMsgLength], a
ld b, a
pop hl
pop af
cp b
- jp c, Function2a37e
- ldh a, [hPrintNumBuffer + 1]
- cp $5a
- jp nz, Function2a37e
- call Function2a3dd
- ldh a, [hPrintNumBuffer + 4]
+ jp c, ReceivedWrongIRMessagePrefix
+ ldh a, [hMGExchangedWord + 0]
+ cp MESSAGE_PREFIX
+ jp nz, ReceivedWrongIRMessagePrefix
+ call ReceiveIRDataMessage
+ ldh a, [hMGChecksum + 0]
ld d, a
- ldh a, [hPrintNumBuffer + 5]
+ ldh a, [hMGChecksum + 1]
ld e, a
push hl
push de
- ld hl, hPrintNumBuffer + 1
- ld b, $2
- call Function2a3dd
+ ld hl, hMGExchangedWord
+ ld b, 2
+ call ReceiveIRDataMessage
pop de
- ld hl, hPrintNumBuffer + 1
+ ld hl, hMGExchangedWord
ld a, [hli]
xor d
ld b, a
ld a, [hl]
xor e
or b
- call nz, Function2a377
+ call nz, ReceivedWrongIRChecksum
push de
- ld d, $3d
- call Function2a1ff
+
+ ld d, 61
+ call SendInfraredLEDOff
+
ld hl, hMGStatusFlags
- ld b, $1
- call Function2a304
+ ld b, 1
+ call SendIRDataMessage
+
pop de
pop hl
ld a, d
- ldh [hPrintNumBuffer + 4], a
+ ldh [hMGChecksum + 0], a
ld a, e
- ldh [hPrintNumBuffer + 5], a
+ ldh [hMGChecksum + 1], a
ret
-Function2a3dd:
+ReceiveIRDataMessage:
ld c, LOW(rRP)
- ld d, $0
- call Function2a1e5
- jp z, Function2a370
- ld d, $0
- call Function2a1d7
- jp z, Function2a370
- ld d, $0
- call Function2a1e5
- jp z, Function2a370
+
+ ld d, 0
+ call ReceiveInfraredLEDOff
+ jp z, InfraredLEDReceiveTimedOut
+ ld d, 0
+ call ReceiveInfraredLEDOn
+ jp z, InfraredLEDReceiveTimedOut
+ ld d, 0
+ call ReceiveInfraredLEDOff
+ jp z, InfraredLEDReceiveTimedOut
+
ld a, b
cpl
ld b, a
xor a
ldh [hMGPrevTIMA], a
- call Function2a1b4
+
+ call StartSlowIRTimer
.main_loop
inc b
jr z, .done
- ld a, $8
- ldh [hPrintNumBuffer + 3], a
+ ld a, 8
+ ldh [hMGNumBits], a
.inner_loop
- ld d, $0
-.wait_one
+ ld d, 0
+.recv_loop
inc d
- jr z, .got_one
+ jr z, .recv_done
ldh a, [c]
- bit 1, a
- jr z, .wait_one
- ld d, $0
-.got_one
-.wait_zero
+ bit rRP_RECEIVING, a
+ jr z, .recv_loop
+ ld d, 0
+.recv_done
+.send_loop
inc d
- jr z, .got_zero
+ jr z, .send_done
ldh a, [c]
- bit 1, a
- jr nz, .wait_zero
-.got_zero
+ bit rRP_RECEIVING, a
+ jr nz, .send_loop
+.send_done
ldh a, [hMGPrevTIMA]
ld d, a
ldh a, [rTIMA]
@@ -895,9 +1015,9 @@ Function2a3dd:
.zero
res 0, e
.ok
- ldh a, [hPrintNumBuffer + 3]
+ ldh a, [hMGNumBits]
dec a
- ldh [hPrintNumBuffer + 3], a
+ ldh [hMGNumBits], a
jr z, .continue
ld a, e
rlca
@@ -907,34 +1027,35 @@ Function2a3dd:
.continue
ld a, e
ld [hli], a
- ldh a, [hPrintNumBuffer + 4]
+ ldh a, [hMGChecksum + 0]
add e
- ldh [hPrintNumBuffer + 4], a
- ldh a, [hPrintNumBuffer + 5]
+ ldh [hMGChecksum + 0], a
+ ldh a, [hMGChecksum + 1]
adc 0
- ldh [hPrintNumBuffer + 5], a
+ ldh [hMGChecksum + 1], a
jr .main_loop
.done
- call Function2a1a2
+ call StartFastIRTimer
xor a
ldh [rIF], a
- ld d, $0
- call Function2a1d7
- jp z, Function2a370
- ld d, $10
- call Function2a1ff
+ ld d, 0
+ call ReceiveInfraredLEDOn
+ jp z, InfraredLEDReceiveTimedOut
+
+ ld d, 16
+ call SendInfraredLEDOff
ret
-Function2a45c:
- ld b, $0
- jp Function2a2c1
+SendEmptyIRDataBlock:
+ ld b, 0
+ jp SendIRDataBlock
-Function2a461:
- ld b, $0
- jp Function2a385
+ReceiveEmptyIRDataBlock:
+ ld b, 0
+ jp ReceiveIRDataBlock
-MysteryGift_ReadJoypad:
+MysteryGift_UpdateJoypad:
; We can only get four inputs at a time.
; We take d-pad first for no particular reason.
ld a, R_DPAD
@@ -979,9 +1100,10 @@ endr
ldh [rJOYP], a
ret
-MysteryGift_CheckAndSetDecorationAlreadyReceived:
+CheckAndSetMysteryGiftDecorationAlreadyReceived:
+; Return nz if decoration c was already received; otherwise receive it.
call GetMysteryGiftBank
- ld d, $0
+ ld d, 0
ld b, CHECK_FLAG
ld hl, sMysteryGiftDecorationsReceived
lda_predef SmallFarFlagAction
@@ -1001,12 +1123,12 @@ MysteryGift_CheckAndSetDecorationAlreadyReceived:
xor a
ret
-MysteryGift_CopyReceivedDecosToPC:
+CopyMysteryGiftReceivedDecorationsToPC:
call GetMysteryGiftBank
- ld c, $0
+ ld c, 0
.loop
push bc
- ld d, $0
+ ld d, 0
ld b, CHECK_FLAG
ld hl, sMysteryGiftDecorationsReceived
predef SmallFarFlagAction
@@ -1020,57 +1142,68 @@ MysteryGift_CopyReceivedDecosToPC:
.skip
inc c
ld a, c
- cp TrophyIDs - DecorationIDs
+ cp NUM_NON_TROPHY_DECOS
jr c, .loop
jp CloseSRAM
UnlockMysteryGift:
+; If [sMysteryGiftUnlocked] was -1, this sets both
+; [sMysteryGiftUnlocked] and [sMysteryGiftItem] to 0.
call GetMysteryGiftBank
ld hl, sMysteryGiftUnlocked
ld a, [hl]
inc a
jr nz, .ok
ld [hld], a
+ assert sMysteryGiftUnlocked - 1 == sMysteryGiftItem
ld [hl], a
.ok
jp CloseSRAM
-Function2a4f6:
+ResetDailyMysteryGiftLimitIfUnlocked:
call GetMysteryGiftBank
ld a, [sNumDailyMysteryGiftPartnerIDs]
- cp $ff
- jr z, .okay
+ cp -1 ; locked?
+ jr z, .dont_clear
xor a
ld [sNumDailyMysteryGiftPartnerIDs], a
-.okay
+.dont_clear
jp CloseSRAM
BackupMysteryGift:
+; Copies [sMysteryGiftItem] to [sBackupMysteryGiftItem],
+; and [sMysteryGiftUnlocked] to [sNumDailyMysteryGiftPartnerIDs].
call GetMysteryGiftBank
ld hl, sMysteryGiftItem
ld de, sBackupMysteryGiftItem
ld a, [hli]
ld [de], a
inc de
+ assert sMysteryGiftItem + 1 == sMysteryGiftUnlocked
+ assert sBackupMysteryGiftItem + 1 == sNumDailyMysteryGiftPartnerIDs
ld a, [hl]
ld [de], a
jp CloseSRAM
RestoreMysteryGift:
+; Copies [sBackupMysteryGiftItem] to [sMysteryGiftItem],
+; and [sNumDailyMysteryGiftPartnerIDs] to [sMysteryGiftUnlocked].
call GetMysteryGiftBank
ld hl, sBackupMysteryGiftItem
ld de, sMysteryGiftItem
ld a, [hli]
ld [de], a
inc de
+ assert sBackupMysteryGiftItem + 1 == sNumDailyMysteryGiftPartnerIDs
+ assert sMysteryGiftItem + 1 == sMysteryGiftUnlocked
ld a, [hl]
ld [de], a
jp CloseSRAM
-MysteryGift_ClearTrainerData:
- ld hl, wMysteryGiftTrainerData
+ClearMysteryGiftTrainer:
+ ld hl, wMysteryGiftTrainer
xor a
- ld b, wMysteryGiftTrainerDataEnd - wMysteryGiftTrainerData
+ ld b, wMysteryGiftTrainerEnd - wMysteryGiftTrainer
.loop
ld [hli], a
dec b
@@ -1078,5 +1211,5 @@ MysteryGift_ClearTrainerData:
ret
GetMysteryGiftBank:
- ld a, BANK(sBackupMysteryGiftItem)
+ ld a, BANK(sMysteryGiftData)
jp OpenSRAM
diff --git a/engine/link/mystery_gift_2.asm b/engine/link/mystery_gift_2.asm
index 493db05c..af3715e0 100644
--- a/engine/link/mystery_gift_2.asm
+++ b/engine/link/mystery_gift_2.asm
@@ -1,24 +1,24 @@
-PrepMysteryGiftDataToSend:
+StageDataForMysteryGift:
ld de, wMysteryGiftStaging
- ld a, $1 + GS_VERSION
+ ld a, GS_VERSION + 1
ld [de], a
- inc de ; wc701
+ inc de ; wMysteryGiftStaging+1
ld a, BANK(sGameData)
call OpenSRAM
ld hl, sPlayerData + wPlayerID - wPlayerData
ld a, [hli]
ld [de], a
ld b, a
- inc de ; wc702
+ inc de ; wMysteryGiftStaging+2
ld a, [hl]
ld [de], a
ld c, a
- inc de ; wc703
+ inc de ; wMysteryGiftStaging+3
push bc
ld hl, sPlayerData + wPlayerName - wPlayerData
ld bc, NAME_LENGTH
call CopyBytes
- push de ; wc70e
+ push de ; wMysteryGiftStaging+14
ld hl, sPokemonData + wPokedexCaught - wPokemonData
ld b, wEndPokedexCaught - wPokedexCaught
call CountSetBits
@@ -26,30 +26,30 @@ PrepMysteryGiftDataToSend:
pop bc
ld a, [wNumSetBits]
ld [de], a
- inc de ; wc70f
+ inc de ; wMysteryGiftStaging+15
call CloseSRAM
call Random
and 1
ld [de], a
- inc de ; wc710
+ inc de ; wMysteryGiftStaging+16
call .RandomSample
ld [de], a
- inc de ; wc711
+ inc de ; wMysteryGiftStaging+17
ld a, c
ld c, b
ld b, a
call .RandomSample
ld [de], a
- inc de ; wc712
+ inc de ; wMysteryGiftStaging+18
ld a, BANK(sBackupMysteryGiftItem)
call OpenSRAM
ld a, [sBackupMysteryGiftItem]
ld [de], a
inc de
- ld a, [sBackupMysteryGiftItem + 1]
+ ld a, [sNumDailyMysteryGiftPartnerIDs]
ld [de], a
- ld a, $14
- ld [wc900], a
+ ld a, wMysteryGiftPlayerDataEnd - wMysteryGiftPlayerData
+ ld [wUnusedMysteryGiftStagedDataLength], a
call CloseSRAM
ld hl, wMysteryGiftStaging
ld de, wMysteryGiftPlayerData
@@ -121,7 +121,7 @@ PrepMysteryGiftDataToSend:
pop de
ret
-MysteryGiftGetItemHeldEffect:
+MysteryGiftGetItem:
ld a, c
cp MysteryGiftItems.End - MysteryGiftItems
jr nc, MysteryGiftFallbackItem
diff --git a/engine/link/mystery_gift_3.asm b/engine/link/mystery_gift_3.asm
index bc12d9c8..4a8d92c4 100644
--- a/engine/link/mystery_gift_3.asm
+++ b/engine/link/mystery_gift_3.asm
@@ -45,8 +45,8 @@ StagePartyDataForMysteryGift:
.party_end
ld a, -1
ld [de], a
- ld a, $26
- ld [wc900], a
+ ld a, wMysteryGiftTrainerEnd - wMysteryGiftTrainer
+ ld [wUnusedMysteryGiftStagedDataLength], a
jp CloseSRAM
InitMysteryGiftLayout:
diff --git a/engine/link/time_capsule.asm b/engine/link/time_capsule.asm
index 158e7ec9..3c1cfb5f 100644
--- a/engine/link/time_capsule.asm
+++ b/engine/link/time_capsule.asm
@@ -1,11 +1,11 @@
; These functions seem to be related to backwards compatibility
ValidateOTTrademon:
- ld a, [wceee]
+ ld a, [wCurOTTradePartyMon]
ld hl, wOTPartyMon1Species
call GetPartyLocation
push hl
- ld a, [wceee]
+ ld a, [wCurOTTradePartyMon]
inc a
ld c, a
ld b, 0
@@ -30,7 +30,7 @@ ValidateOTTrademon:
cp LINK_TIMECAPSULE
jr nz, .normal
ld hl, wOTPartySpecies
- ld a, [wceee]
+ ld a, [wCurOTTradePartyMon]
ld c, a
ld b, 0
add hl, bc
@@ -65,11 +65,11 @@ ValidateOTTrademon:
ret
CheckAnyOtherAliveMonsForTrade:
- ld a, [wceed]
+ ld a, [wCurTradePartyMon]
ld d, a
ld a, [wPartyCount]
ld b, a
- ld c, $0
+ ld c, 0
.loop
ld a, c
cp d
@@ -87,7 +87,7 @@ CheckAnyOtherAliveMonsForTrade:
inc c
dec b
jr nz, .loop
- ld a, [wceee]
+ ld a, [wCurOTTradePartyMon]
ld hl, wOTPartyMon1HP
call GetPartyLocation
ld a, [hli]
diff --git a/engine/menus/intro_menu.asm b/engine/menus/intro_menu.asm
index 2155bdc3..9b744f72 100644
--- a/engine/menus/intro_menu.asm
+++ b/engine/menus/intro_menu.asm
@@ -87,12 +87,13 @@ _ResetWRAM:
ld [wRoamMon2MapNumber], a
ld [wRoamMon3MapNumber], a
- ld a, BANK(sMysteryGiftItem)
+ ld a, BANK(sMysteryGiftItem) ; aka BANK(sMysteryGiftUnlocked)
call OpenSRAM
ld hl, sMysteryGiftItem
xor a
ld [hli], a
- dec a
+ assert sMysteryGiftItem + 1 == sMysteryGiftUnlocked
+ dec a ; -1
ld [hl], a
call CloseSRAM
@@ -280,7 +281,7 @@ Continue:
ld c, 20
call DelayFrames
farcall JumpRoamMons
- farcall MysteryGift_CopyReceivedDecosToPC
+ farcall CopyMysteryGiftReceivedDecorationsToPC
farcall ClockContinue
ld a, [wSpawnAfterChampion]
cp SPAWN_LANCE
@@ -343,8 +344,8 @@ FinishContinueFunction:
.loop
xor a
ld [wDontPlayMapMusicOnReload], a
- ld hl, wGameTimerPause
- set GAMETIMERPAUSE_TIMER_PAUSED_F, [hl]
+ ld hl, wGameTimerPaused
+ set GAME_TIMER_PAUSED_F, [hl]
farcall OverworldLoop
ld a, [wSpawnAfterChampion]
cp SPAWN_RED
diff --git a/engine/menus/main_menu.asm b/engine/menus/main_menu.asm
index 6f8727a7..eb34cb26 100644
--- a/engine/menus/main_menu.asm
+++ b/engine/menus/main_menu.asm
@@ -28,8 +28,8 @@ MainMenu:
call ClearTilemapEtc
ld b, SCGB_DIPLOMA
call GetSGBLayout
- ld hl, wGameTimerPause
- res GAMETIMERPAUSE_TIMER_PAUSED_F, [hl]
+ ld hl, wGameTimerPaused
+ res GAME_TIMER_PAUSED_F, [hl]
call MainMenu_GetWhichMenu
ld [wWhichIndexSet], a
call MainMenu_PrintCurrentTimeAndDay
@@ -132,7 +132,7 @@ MainMenu_GetWhichMenu:
ld a, BANK(sNumDailyMysteryGiftPartnerIDs)
call OpenSRAM
ld a, [sNumDailyMysteryGiftPartnerIDs]
- cp -1
+ cp -1 ; locked?
call CloseSRAM
ld a, MAINMENU_CONTINUE
ret z
@@ -218,20 +218,19 @@ MainMenu_PrintCurrentTimeAndDay:
call PrintNum
ret
-.min
-; unused
+.minString: ; unreferenced
db "min.@"
.PrintTimeNotSet:
hlcoord 1, 14
- ld de, .TimeNotSet
+ ld de, .TimeNotSetString
call PlaceString
ret
-.TimeNotSet:
+.TimeNotSetString:
db "TIME NOT SET@"
-.MainMenuTimeUnknownText:
+.MainMenuTimeUnknownText: ; unreferenced
text_far _MainMenuTimeUnknownText
text_end
diff --git a/engine/menus/menu_2.asm b/engine/menus/menu_2.asm
index 6566e48d..83040f84 100644
--- a/engine/menus/menu_2.asm
+++ b/engine/menus/menu_2.asm
@@ -109,7 +109,8 @@ CoinString:
db "COIN@"
ShowMoney_TerminatorString:
db "@"
- db "@" ; unused
+UnusedEmptyString: ; unreferenced
+ db "@"
StartMenu_PrintSafariGameStatus: ; unreferenced
ld hl, wOptions
@@ -157,18 +158,18 @@ StartMenu_PrintBugContestStatus:
set NO_TEXT_SCROLL, [hl]
call StartMenu_DrawBugContestStatusBox
hlcoord 1, 5
- ld de, .Balls_EN
+ ld de, .BallsString
call PlaceString
hlcoord 8, 5
ld de, wParkBallsRemaining
lb bc, PRINTNUM_LEFTALIGN | 1, 2
call PrintNum
hlcoord 1, 1
- ld de, .CAUGHT
+ ld de, .CaughtString
call PlaceString
ld a, [wContestMon]
and a
- ld de, .None
+ ld de, .NoneString
jr z, .no_contest_mon
ld [wNamedObjectIndexBuffer], a
call GetPokemonName
@@ -180,7 +181,7 @@ StartMenu_PrintBugContestStatus:
and a
jr z, .skip_level
hlcoord 1, 3
- ld de, .LEVEL
+ ld de, .LevelString
call PlaceString
ld a, [wContestMonLevel]
ld h, b
@@ -194,15 +195,15 @@ StartMenu_PrintBugContestStatus:
ld [wOptions], a
ret
-.Balls_JP:
+.BallsJPString: ; unreferenced
db "ボール   こ@"
-.CAUGHT:
+.CaughtString:
db "CAUGHT@"
-.Balls_EN:
+.BallsString:
db "BALLS:@"
-.None:
+.NoneString:
db "None@"
-.LEVEL:
+.LevelString:
db "LEVEL@"
Kurt_SelectApricorn:
diff --git a/engine/menus/naming_screen.asm b/engine/menus/naming_screen.asm
index a0b5cba3..39d930ab 100644
--- a/engine/menus/naming_screen.asm
+++ b/engine/menus/naming_screen.asm
@@ -253,6 +253,7 @@ NamingScreen_InitText:
NamingScreen_ApplyTextInputMode:
call NamingScreen_IsTargetBox
jr nz, .not_box
+ assert BoxNameInputLower - NameInputLower == BoxNameInputUpper - NameInputUpper
ld hl, BoxNameInputLower - NameInputLower
add hl, de
ld d, h
@@ -865,7 +866,7 @@ INCBIN "gfx/naming_screen/cursor.2bpp"
INCLUDE "data/text/name_input_chars.asm"
-NamingScreenGFX_End: ; unused
+NamingScreenGFX_End: ; unreferenced
INCBIN "gfx/naming_screen/end.1bpp"
NamingScreenGFX_MiddleLine:
diff --git a/engine/menus/trainer_card.asm b/engine/menus/trainer_card.asm
index 6f2ef316..1610749c 100644
--- a/engine/menus/trainer_card.asm
+++ b/engine/menus/trainer_card.asm
@@ -44,10 +44,10 @@ TrainerCard:
call ClearTilemap
call DisableLCD
- ld hl, ChrisCardPic
+ ld hl, ChrisPicAndTrainerCardGFX
ld de, vTiles2
- ld bc, 41 tiles
- ld a, BANK(ChrisCardPic)
+ ld bc, (35 + 6) tiles
+ ld a, BANK(ChrisPicAndTrainerCardGFX)
call FarCopyBytes
ld hl, CardStatusGFX
@@ -307,7 +307,8 @@ TrainerCard_Page1_PrintDexCaught_GameTime:
db "#DEX"
next "PLAY TIME@"
- db "@" ; unused
+.Unused: ; unreferenced
+ db "@"
.Badges:
db "BADGES▶@"
@@ -619,8 +620,10 @@ TrainerCard_JohtoBadgesOAM:
db $1c, $20, $24, $20 | (1 << 7)
db $1c | (1 << 7), $20, $24, $20 | (1 << 7)
-ChrisCardPic: INCBIN "gfx/trainer_card/chris_card.2bpp"
-CardGFX: INCBIN "gfx/trainer_card/trainer_card.2bpp"
+ChrisPicAndTrainerCardGFX:
+INCBIN "gfx/trainer_card/chris_card.2bpp"
+INCBIN "gfx/trainer_card/trainer_card.2bpp"
+
CardStatusGFX: INCBIN "gfx/trainer_card/card_status.2bpp"
LeaderGFX: INCBIN "gfx/trainer_card/leaders.2bpp"
diff --git a/engine/movie/credits.asm b/engine/movie/credits.asm
index 1c8bc31f..a1b91d7e 100644
--- a/engine/movie/credits.asm
+++ b/engine/movie/credits.asm
@@ -193,7 +193,7 @@ Credits_RequestGFX:
xor a
ldh [hBGMapMode], a
ld a, 8
- ld [wRequested2bpp], a
+ ld [wRequested2bppSize], a
jp Credits_Next
Credits_LYOverride:
diff --git a/engine/movie/evolution_animation.asm b/engine/movie/evolution_animation.asm
index e6d975b0..b3af9a72 100644
--- a/engine/movie/evolution_animation.asm
+++ b/engine/movie/evolution_animation.asm
@@ -65,7 +65,6 @@ EvolutionAnimation:
ld c, TRUE
call .GetSGBLayout
-.AnimationSequence:
call ClearJoypad
lb bc, 1, 16 ; flash b times, wait c frames in between
.loop
diff --git a/engine/movie/intro.asm b/engine/movie/intro.asm
index 6ef0a933..7ff23fce 100644
--- a/engine/movie/intro.asm
+++ b/engine/movie/intro.asm
@@ -719,7 +719,8 @@ IntroScene9:
db %00000000
db -1
- ret ; unused
+Intro_DummyFunction: ; unreferenced
+ ret
Intro_InitNote:
ld a, [wIntroSpriteStateFlag]
diff --git a/engine/movie/trade_animation.asm b/engine/movie/trade_animation.asm
index 6877514a..f99e9e0c 100644
--- a/engine/movie/trade_animation.asm
+++ b/engine/movie/trade_animation.asm
@@ -212,7 +212,7 @@ DoTradeAnimation:
jr nz, .finished
call .DoTradeAnimCommand
callfar PlaySpriteAnimations
- ld hl, wce65
+ ld hl, wFrameCounter2
inc [hl]
call DelayFrame
and a
@@ -1269,7 +1269,7 @@ LinkTradeAnim_LoadTradeMonSpecies:
ret
TradeAnim_FlashBGPals:
- ld a, [wce65]
+ ld a, [wFrameCounter2]
and $7
ret nz
ldh a, [rBGP]
diff --git a/engine/overworld/cmd_queue.asm b/engine/overworld/cmd_queue.asm
index 6a598438..1994220e 100644
--- a/engine/overworld/cmd_queue.asm
+++ b/engine/overworld/cmd_queue.asm
@@ -148,7 +148,7 @@ CmdQueues_IncAnonJumptableIndex:
inc [hl]
ret
-CmdQueues_DecAnonJumptableIndex:
+CmdQueues_DecAnonJumptableIndex: ; unreferenced
ld hl, CMDQUEUE_05
add hl, bc
dec [hl]
@@ -163,7 +163,7 @@ CmdQueue_Type1:
CmdQueue_Type4:
call CmdQueues_AnonJumptable
- ; anonymous dw
+.anon_dw
dw .zero
dw .one
diff --git a/engine/overworld/decorations.asm b/engine/overworld/decorations.asm
index e7a882ae..059f915a 100644
--- a/engine/overworld/decorations.asm
+++ b/engine/overworld/decorations.asm
@@ -44,7 +44,7 @@ _PlayerDecorationMenu:
.MenuData:
db STATICMENU_CURSOR | STATICMENU_WRAP ; flags
db 0 ; items
- dw wceed
+ dw wNumOwnedDecoCategories
dw PlaceNthMenuStrings
dw .pointers
@@ -75,7 +75,7 @@ _PlayerDecorationMenu:
ld a, 7
call .AppendToStringBuffer2
ld hl, wStringBuffer2
- ld de, wceed
+ ld de, wDecoNameBuffer
ld bc, ITEM_NAME_LENGTH
call CopyBytes
ret
@@ -133,10 +133,11 @@ _PlayerDecorationMenu:
Deco_FillTempWithMinusOne:
xor a
- ld hl, wceed
+ ld hl, wNumOwnedDecoCategories
ld [hli], a
+ assert wNumOwnedDecoCategories + 1 == wOwnedDecoCategories
ld a, -1
- ld bc, $10
+ ld bc, 16
call ByteFill
ret
@@ -161,10 +162,11 @@ CheckAllDecorationFlags:
ret
AppendDecoIndex:
- ld hl, wceed
+ ld hl, wNumOwnedDecoCategories
inc [hl]
+ assert wNumOwnedDecoCategories + 1 == wOwnedDecoCategories
ld e, [hl]
- ld d, $0
+ ld d, 0
add hl, de
ld [hl], a
ret
@@ -176,7 +178,7 @@ FindOwnedDecosInCategory:
pop hl
call CheckAllDecorationFlags
pop bc
- ld a, [wceed]
+ ld a, [wNumOwnedDecoCategories]
and a
ret z
@@ -335,7 +337,7 @@ DecoExitMenu:
ret
PopulateDecoCategoryMenu:
- ld a, [wceed]
+ ld a, [wNumOwnedDecoCategories]
and a
jr z, .empty
cp 8
@@ -353,9 +355,10 @@ PopulateDecoCategoryMenu:
ret
.beyond_eight
- ld hl, wceed
+ ld hl, wNumOwnedDecoCategories
ld e, [hl]
dec [hl]
+ assert wNumOwnedDecoCategories + 1 == wOwnedDecoCategories
ld d, 0
add hl, de
ld [hl], -1
@@ -395,7 +398,7 @@ PopulateDecoCategoryMenu:
.NonscrollingMenuData:
db STATICMENU_CURSOR | STATICMENU_WRAP ; flags
db 0 ; items
- dw wceed
+ dw wDecoNameBuffer
dw DecorationMenuFunction
dw DecorationAttributes
@@ -409,10 +412,10 @@ PopulateDecoCategoryMenu:
db SCROLLINGMENU_DISPLAY_ARROWS ; flags
db 8, 0 ; rows, columns
db SCROLLINGMENU_ITEMS_NORMAL ; item format
- dbw 0, wceed ; text pointer
+ dbw 0, wDecoNameBuffer ; text pointer
dba DecorationMenuFunction
- dbw 0, 0
- dbw 0, 0
+ dbw 0, NULL
+ dbw 0, NULL
GetDecorationData:
ld hl, DecorationAttributes
@@ -932,7 +935,7 @@ GetDecorationID:
pop hl
ret
-SetAllDecorationFlags:
+SetAllDecorationFlags: ; unreferenced
ld hl, DecorationIDs
.loop
ld a, [hli]
diff --git a/engine/overworld/events.asm b/engine/overworld/events.asm
index f21ea17b..ee2facbe 100644
--- a/engine/overworld/events.asm
+++ b/engine/overworld/events.asm
@@ -25,76 +25,76 @@ OverworldLoop::
DisableEvents:
xor a
- ld [wScriptFlags3], a
+ ld [wScriptFlags2], a
ret
EnableEvents::
ld a, $ff
- ld [wScriptFlags3], a
+ ld [wScriptFlags2], a
ret
-CheckBit5_ScriptFlags3:
- ld hl, wScriptFlags3
+CheckBit5_ScriptFlags2:
+ ld hl, wScriptFlags2
bit 5, [hl]
ret
-DisableWarpsConnxns:
- ld hl, wScriptFlags3
+DisableWarpsConnxns: ; unreferenced
+ ld hl, wScriptFlags2
res 2, [hl]
ret
-DisableCoordEvents:
- ld hl, wScriptFlags3
+DisableCoordEvents: ; unreferenced
+ ld hl, wScriptFlags2
res 1, [hl]
ret
-DisableStepCount:
- ld hl, wScriptFlags3
+DisableStepCount: ; unreferenced
+ ld hl, wScriptFlags2
res 0, [hl]
ret
-DisableWildEncounters:
- ld hl, wScriptFlags3
+DisableWildEncounters: ; unreferenced
+ ld hl, wScriptFlags2
res 4, [hl]
ret
-EnableWarpsConnxns:
- ld hl, wScriptFlags3
+EnableWarpsConnxns: ; unreferenced
+ ld hl, wScriptFlags2
set 2, [hl]
ret
-EnableCoordEvents:
- ld hl, wScriptFlags3
+EnableCoordEvents: ; unreferenced
+ ld hl, wScriptFlags2
set 1, [hl]
ret
-EnableStepCount:
- ld hl, wScriptFlags3
+EnableStepCount: ; unreferenced
+ ld hl, wScriptFlags2
set 0, [hl]
ret
EnableWildEncounters:
- ld hl, wScriptFlags3
+ ld hl, wScriptFlags2
set 4, [hl]
ret
CheckWarpConnxnScriptFlag:
- ld hl, wScriptFlags3
+ ld hl, wScriptFlags2
bit 2, [hl]
ret
CheckCoordEventScriptFlag:
- ld hl, wScriptFlags3
+ ld hl, wScriptFlags2
bit 1, [hl]
ret
CheckStepCountScriptFlag:
- ld hl, wScriptFlags3
+ ld hl, wScriptFlags2
bit 0, [hl]
ret
CheckWildEncountersScriptFlag:
- ld hl, wScriptFlags3
+ ld hl, wScriptFlags2
bit 4, [hl]
ret
@@ -133,7 +133,7 @@ EnterMap:
ld [wMapStatus], a
ret
-UnusedWait30Frames:
+UnusedWait30Frames: ; unreferenced
ld c, 30
call DelayFrames
ret
@@ -245,7 +245,7 @@ PlayerEvents:
and a
ret nz
- call Dummy_CheckScriptFlags3Bit5 ; This is a waste of time
+ call Dummy_CheckScriptFlags2Bit5 ; This is a waste of time
call CheckTrainerBattle_GetPlayerEvent
jr c, .ok
@@ -382,8 +382,8 @@ SetMinTwoStepWildEncounterCooldown:
ld [wWildEncounterCooldown], a
ret
-Dummy_CheckScriptFlags3Bit5:
- call CheckBit5_ScriptFlags3
+Dummy_CheckScriptFlags2Bit5:
+ call CheckBit5_ScriptFlags2
ret z
call SetXYCompareFlags
ret
@@ -468,8 +468,8 @@ CheckTimeEvents:
scf
ret
-.unused
- ld a, 8
+.unused ; unreferenced
+ ld a, $8 ; ???
scf
ret
@@ -800,7 +800,7 @@ PlayerMovement:
CheckMenuOW:
xor a
ldh [hMenuReturn], a
- ldh [hUnusedFFA3], a
+ ldh [hUnusedByte], a
ldh a, [hJoyPressed]
bit SELECT_F, a
diff --git a/engine/overworld/load_map_part.asm b/engine/overworld/load_map_part.asm
index 4e8e228b..c91d8c98 100644
--- a/engine/overworld/load_map_part.asm
+++ b/engine/overworld/load_map_part.asm
@@ -136,7 +136,6 @@ ForceApplyFlashlight4: ; unreferenced
decoord 8, 8
ld bc, (SURROUNDING_WIDTH + 1) * 8
add hl, bc
-.loop
ld a, [hli]
ld [de], a
inc de
diff --git a/engine/overworld/map_object_action.asm b/engine/overworld/map_object_action.asm
index 4913386c..8a153f59 100644
--- a/engine/overworld/map_object_action.asm
+++ b/engine/overworld/map_object_action.asm
@@ -246,7 +246,8 @@ SetFacingBoulderDust:
and 2
ld a, FACING_BOULDER_DUST_1
jr z, .ok
- inc a ; FACING_BOULDER_DUST_2
+ inc a
+ assert FACING_BOULDER_DUST_1 + 1 == FACING_BOULDER_DUST_2
.ok
ld [hl], a
ret
diff --git a/engine/overworld/map_objects.asm b/engine/overworld/map_objects.asm
index db82248e..3d3b1cab 100644
--- a/engine/overworld/map_objects.asm
+++ b/engine/overworld/map_objects.asm
@@ -2823,18 +2823,17 @@ InitSprites:
.InitSprite:
xor a
-.skip1
ld hl, OBJECT_FLAGS2
add hl, bc
ld e, [hl]
bit OBJ_FLAGS2_7, e
- jr z, .skip2
+ jr z, .not_priority
or PRIORITY
-.skip2
+.not_priority
bit USE_OBP1_F, e
- jr z, .skip3
+ jr z, .not_obp_num
or OBP_NUM
-.skip3
+.not_obp_num
ld hl, OBJECT_PALETTE
add hl, bc
ld d, a
@@ -2844,9 +2843,9 @@ InitSprites:
ld d, a
xor a
bit OVERHEAD_F, e
- jr z, .skip4
+ jr z, .not_overhead
or PRIORITY
-.skip4
+.not_overhead
ldh [hCurSpriteOAMFlags], a
ld hl, OBJECT_SPRITE_TILE
add hl, bc
diff --git a/engine/overworld/map_setup.asm b/engine/overworld/map_setup.asm
index e1a7ebec..e13c2216 100644
--- a/engine/overworld/map_setup.asm
+++ b/engine/overworld/map_setup.asm
@@ -82,7 +82,7 @@ LoadMapObjects:
farcall InitializeVisibleSprites
ret
-; unused
+MapSetup_DummyFunction: ; unreferenced
ret
ResetPlayerObjectAction:
diff --git a/engine/overworld/overworld.asm b/engine/overworld/overworld.asm
index 0d285d2a..40157524 100644
--- a/engine/overworld/overworld.asm
+++ b/engine/overworld/overworld.asm
@@ -119,7 +119,7 @@ AddOutdoorSprites:
dec c
jr nz, .loop
- ld a, [wUnusedD05A]
+ ld a, [wUnusedAddOutdoorSpritesReturnValue]
ld c, a
ret
diff --git a/engine/overworld/player_movement.asm b/engine/overworld/player_movement.asm
index a958429c..c18d3b46 100644
--- a/engine/overworld/player_movement.asm
+++ b/engine/overworld/player_movement.asm
@@ -311,7 +311,7 @@ DoPlayerMovement::
scf
ret
-; unused
+.unused ; unreferenced
xor a
ret
diff --git a/engine/overworld/scripting.asm b/engine/overworld/scripting.asm
index 19fd15db..ffb878a9 100644
--- a/engine/overworld/scripting.asm
+++ b/engine/overworld/scripting.asm
@@ -432,11 +432,11 @@ Script_verbosegiveitem:
ld de, GiveItemScript
jp ScriptCall
-ret_96e71:
+GiveItemScript_DummyFunction:
ret
GiveItemScript:
- callasm ret_96e71
+ callasm GiveItemScript_DummyFunction
writetext .ReceivedItemText
iffalse .Full
waitsfx
@@ -1518,8 +1518,6 @@ Script_getcurlandmarkname:
ld a, [wMapNumber]
ld c, a
call GetWorldMapLocation
-
-ConvertLandmarkToText:
ld e, a
farcall GetLandmarkName
ld de, wStringBuffer1
@@ -1589,7 +1587,7 @@ Script_givepokemail:
push bc
inc hl
ld bc, MAIL_MSG_LENGTH
- ld de, wceed
+ ld de, wMonMailMessageBuffer
ld a, [wScriptBank]
call FarCopyBytes
pop bc
@@ -2059,8 +2057,7 @@ Script_warpcheck:
farcall EnableEvents
ret
-Script_enableevents:
-; unused
+Script_enableevents: ; unreferenced
farcall EnableEvents
ret
@@ -2090,7 +2087,8 @@ Script_writeunusedbytebuffer:
ld [wUnusedScriptByteBuffer], a
ret
- db closetext_command ; unused
+UnusedClosetextScript: ; unreferenced
+ closetext
Script_closetext:
ldh a, [hOAMUpdate]
@@ -2208,11 +2206,11 @@ Script_endall:
ret
Script_halloffame:
- ld hl, wGameTimerPause
- res GAMETIMERPAUSE_TIMER_PAUSED_F, [hl]
+ ld hl, wGameTimerPaused
+ res GAME_TIMER_PAUSED_F, [hl]
farcall HallOfFame
- ld hl, wGameTimerPause
- set GAMETIMERPAUSE_TIMER_PAUSED_F, [hl]
+ ld hl, wGameTimerPaused
+ set GAME_TIMER_PAUSED_F, [hl]
jr ReturnFromCredits
Script_credits:
@@ -2224,7 +2222,7 @@ ReturnFromCredits:
call StopScript
ret
-; unused
+Script_checkver_duplicate: ; unreferenced
ld a, [.gs_version]
ld [wScriptVar], a
ret
diff --git a/engine/overworld/time.asm b/engine/overworld/time.asm
index a829cd4f..a109a417 100644
--- a/engine/overworld/time.asm
+++ b/engine/overworld/time.asm
@@ -158,7 +158,7 @@ CheckPokerusTick::
xor a
ret
-SetUnusedTwoDayTimer:
+SetUnusedTwoDayTimer: ; unreferenced
ld a, 2
ld hl, wUnusedTwoDayTimer
ld [hl], a
@@ -175,12 +175,12 @@ CheckUnusedTwoDayTimer:
call UpdateTimeRemaining
ret
-; unused
+UnusedSetSwarmFlag: ; unreferenced
ld hl, wDailyFlags1
set DAILYFLAGS1_SWARM_F, [hl]
ret
-; unused
+UnusedCheckSwarmFlag: ; unreferenced
and a
ld hl, wDailyFlags1
bit DAILYFLAGS1_SWARM_F, [hl]
@@ -227,7 +227,7 @@ DoMysteryGiftIfDayHasPassed:
ld hl, wBuffer1
call InitOneDayCountdown
call CloseSRAM
- farcall Function2a4f6
+ farcall ResetDailyMysteryGiftLimitIfUnlocked
.not_timed_out
ld a, BANK(sMysteryGiftTimer)
@@ -263,7 +263,7 @@ UpdateTimeRemaining:
scf
ret
-GetSecondsSinceIfLessThan60:
+GetSecondsSinceIfLessThan60: ; unreferenced
ld a, [wDaysSince]
and a
jr nz, GetTimeElapsed_ExceedsUnitLimit
@@ -285,7 +285,7 @@ GetMinutesSinceIfLessThan60:
ld a, [wMinutesSince]
ret
-GetHoursSinceIfLessThan24:
+GetHoursSinceIfLessThan24: ; unreferenced
ld a, [wDaysSince]
and a
jr nz, GetTimeElapsed_ExceedsUnitLimit
@@ -304,7 +304,7 @@ CalcDaysSince:
xor a
jr _CalcDaysSince
-CalcHoursDaysSince:
+CalcHoursDaysSince: ; unreferenced
inc hl
xor a
jr _CalcHoursDaysSince
@@ -378,7 +378,7 @@ CopyDayToHL:
ld [hl], a
ret
-CopyDayHourToHL:
+CopyDayHourToHL: ; unreferenced
ld a, [wCurDay]
ld [hli], a
ldh a, [hHours]
diff --git a/engine/phone/phone.asm b/engine/phone/phone.asm
index 00cbec75..af0c3931 100644
--- a/engine/phone/phone.asm
+++ b/engine/phone/phone.asm
@@ -145,7 +145,7 @@ CheckPhoneCall::
farcall CheckReceiveCallTimer
ret
-; unused
+.unused ; unreferenced
ret
FarInitCallReceiveDelay: ; unreferenced
@@ -444,7 +444,7 @@ Script_SpecialBillCall::
ld e, PHONE_BILL
jp LoadCallerScript
-LoadElmCallScript:
+Script_SpecialElmCall: ; unreferenced
callasm .LoadElmScript
pause 30
sjump Script_ReceivePhoneCall
@@ -723,7 +723,7 @@ PhoneJustTalkToThemText:
text_far _PhoneJustTalkToThemText
text_end
-PhoneThankYouTextScript:
+PhoneThankYouTextScript: ; unreferenced
writetext PhoneThankYouText
end
diff --git a/engine/phone/scripts/elm.asm b/engine/phone/scripts/elm.asm
index b93bdc22..6a5a37c7 100644
--- a/engine/phone/scripts/elm.asm
+++ b/engine/phone/scripts/elm.asm
@@ -95,7 +95,7 @@ ElmPhoneCallerScript:
specialphonecall SPECIALCALL_NONE
end
-.unused
+.neat ; unreferenced
writetext ElmPhoneGotAholdOfSomethingNeatText
specialphonecall SPECIALCALL_NONE
end
diff --git a/engine/phone/scripts/generic.asm b/engine/phone/scripts/generic.asm
index 4587c739..82032641 100644
--- a/engine/phone/scripts/generic.asm
+++ b/engine/phone/scripts/generic.asm
@@ -74,8 +74,8 @@ PhoneScript_GreetPhone_Female:
promptbutton
end
-; Huey
Phone_GenericCall_Male_SkipMon:
+; only used by HueyPhoneCalleeScript and HueyPhoneCallerScript
special RandomPhoneMon
scall PhoneScript_Random2
ifequal 0, Phone_LookingAwesome_Male_SkipMon
@@ -83,8 +83,7 @@ Phone_GenericCall_Male_SkipMon:
promptbutton
sjump PhoneScript_SeeYouLater
-; unused
-Phone_GenericCall_Female_SkipMon:
+Phone_GenericCall_Female_SkipMon: ; unreferenced
special RandomPhoneMon
scall PhoneScript_Random2
ifequal 0, Phone_DressedUp_Female_SkipMon
@@ -92,13 +91,11 @@ Phone_GenericCall_Female_SkipMon:
promptbutton
sjump PhoneScript_ByeBye
-; Huey
Phone_LookingAwesome_Male_SkipMon:
writetext PhoneMaleLookingAwesomeText
promptbutton
sjump PhoneScript_ByeBye
-; unused
Phone_DressedUp_Female_SkipMon:
writetext PhoneFemaleDressedUpText
promptbutton
diff --git a/engine/pokedex/pokedex.asm b/engine/pokedex/pokedex.asm
index fe89a551..23840d1d 100644
--- a/engine/pokedex/pokedex.asm
+++ b/engine/pokedex/pokedex.asm
@@ -91,7 +91,7 @@ InitPokedex:
ld [wJumptableIndex], a
ld [wPrevDexEntryJumptableIndex], a
ld [wPrevDexEntryBackup], a
- ld [wce66], a
+ ld [wUnusedPokedexByte], a
call Pokedex_CheckUnlockedUnownMode
@@ -1166,7 +1166,7 @@ Pokedex_DrawDexEntryScreenBG:
call Pokedex_PlaceFrontpicTopLeftCorner
ret
-.Unused:
+.Number: ; unreferenced
db $5c, $5d, -1 ; No.
.Height:
db "HT ?", $5e, "??", $5f, -1 ; HT ?'??"
@@ -2487,14 +2487,14 @@ Pokedex_LoadUnownFont:
ld a, BANK(sScratch)
call OpenSRAM
ld hl, UnownFont
- ld de, sScratch + $188
+ ld de, sDecompressBuffer
ld bc, 39 tiles
ld a, BANK(UnownFont)
call FarCopyBytes
- ld hl, sScratch + $188
+ ld hl, sDecompressBuffer
ld bc, (NUM_UNOWN + 1) tiles
call Pokedex_InvertTiles
- ld de, sScratch + $188
+ ld de, sDecompressBuffer
ld hl, vTiles2 tile FIRST_UNOWN_CHAR
lb bc, BANK(Pokedex_LoadUnownFont), NUM_UNOWN + 1
call Request2bpp
diff --git a/engine/pokegear/pokegear.asm b/engine/pokegear/pokegear.asm
index be155618..6586774e 100644
--- a/engine/pokegear/pokegear.asm
+++ b/engine/pokegear/pokegear.asm
@@ -92,7 +92,7 @@ PokeGear:
ld [wJumptableIndex], a ; POKEGEARSTATE_CLOCKINIT
ld [wPokegearCard], a ; POKEGEARCARD_CLOCK
ld [wPokegearMapRegion], a ; JOHTO_REGION
- ld [wce66], a
+ ld [wUnusedPokegearByte], a
ld [wPokegearPhoneScrollPosition], a
ld [wPokegearPhoneCursorPosition], a
ld [wPokegearPhoneSelectedPerson], a
@@ -1257,7 +1257,7 @@ PokegearPhoneContactSubmenu:
dw .Call
dw .Cancel
-; unused
+GetAMPMHours: ; unreferenced
ldh a, [hHours]
cp 12
jr c, .am
@@ -1428,7 +1428,7 @@ UpdateRadioStation:
ldh [hBGMapMode], a
ret
-; unused
+LoadPokegearRadioChannelPointer: ; unreferenced
ld [wPokegearRadioChannelBank], a
ld a, [hli]
ld [wPokegearRadioChannelAddr], a
@@ -1520,7 +1520,7 @@ RadioChannels:
jr z, .johto
cp KANTO_LANDMARK
jr c, .johto
-.kanto
+; kanto
and a
ret
@@ -1989,7 +1989,7 @@ _FlyMap:
lb bc, BANK(FlyMapLabelBorderGFX), 6
call Request1bpp
call FlyMap
- call ret_91bfd
+ call Pokegear_DummyFunction
ld b, SCGB_POKEGEAR_PALS
call GetSGBLayout
call SetPalettes
@@ -2194,7 +2194,7 @@ HasVisitedSpawn:
INCLUDE "data/maps/flypoints.asm"
-ret_91bfd:
+Pokegear_DummyFunction:
ret
FlyMap:
@@ -2216,7 +2216,7 @@ FlyMap:
; The first 46 locations are part of Johto. The rest are in Kanto.
cp KANTO_LANDMARK
jr nc, .KantoFlyMap
-.JohtoFlyMap:
+; Johto fly map
; Note that .NoKanto should be modified in tandem with this branch
push af
ld a, JOHTO_FLYPOINT ; first Johto flypoint
@@ -2512,7 +2512,7 @@ Pokedex_GetArea:
jr z, .johto
cp KANTO_LANDMARK
jr c, .johto
-.kanto
+; kanto
ld a, [wTownMapCursorLandmark]
and a
jr z, .clear
diff --git a/engine/pokegear/radio.asm b/engine/pokegear/radio.asm
index 2cc8c1bb..459cf1ac 100644
--- a/engine/pokegear/radio.asm
+++ b/engine/pokegear/radio.asm
@@ -119,7 +119,7 @@ PrintRadioLine:
ld [wRadioTextDelay], a
ret
-ReplacePeriodsWithSpaces:
+ReplacePeriodsWithSpaces: ; unreferenced
push hl
ld b, SCREEN_WIDTH * 2
.loop
@@ -127,7 +127,6 @@ ReplacePeriodsWithSpaces:
cp "."
jr nz, .next
ld [hl], " "
-
.next
inc hl
dec b
@@ -313,6 +312,7 @@ OaksPKMNTalk8:
; so no need for a retry loop
call Random
maskbits NUM_OAKS_POKEMON_TALK_ADVERBS
+ assert_power_of_2 NUM_OAKS_POKEMON_TALK_ADVERBS
ld e, a
ld d, 0
ld hl, .Adverbs
@@ -412,6 +412,7 @@ OaksPKMNTalk9:
; so no need for a retry loop
call Random
maskbits NUM_OAKS_POKEMON_TALK_ADJECTIVES
+ assert_power_of_2 NUM_OAKS_POKEMON_TALK_ADJECTIVES
ld e, a
ld d, 0
ld hl, .Adjectives
@@ -1091,6 +1092,7 @@ PeoplePlaces5:
; so no need for a retry loop
call Random
maskbits NUM_PNP_PEOPLE_ADJECTIVES
+ assert_power_of_2 NUM_PNP_PEOPLE_ADJECTIVES
ld e, a
ld d, 0
ld hl, .Adjectives
@@ -1224,6 +1226,7 @@ PeoplePlaces7:
; so no need for a retry loop
call Random
maskbits NUM_PNP_PLACES_ADJECTIVES
+ assert_power_of_2 NUM_PNP_PLACES_ADJECTIVES
ld e, a
ld d, 0
ld hl, .Adjectives
@@ -1378,7 +1381,7 @@ CopyRadioTextToRAM:
cp TX_FAR
jp z, FarCopyRadioText
ld de, wRadioText
- ld bc, SCREEN_WIDTH * 2
+ ld bc, 2 * SCREEN_WIDTH
jp CopyBytes
StartRadioStation:
diff --git a/engine/pokemon/bills_pc.asm b/engine/pokemon/bills_pc.asm
index 6e3125db..3be170ec 100644
--- a/engine/pokemon/bills_pc.asm
+++ b/engine/pokemon/bills_pc.asm
@@ -101,7 +101,7 @@ _DepositPKMN:
ld [wJumptableIndex], a
ret
-.go_back
+.go_back ; unreferenced
ld hl, wJumptableIndex
dec [hl]
ret
@@ -343,7 +343,7 @@ _WithdrawPKMN:
ld [wJumptableIndex], a
ret
-.unused
+.go_back ; unreferenced
ld hl, wJumptableIndex
dec [hl]
ret
@@ -594,7 +594,7 @@ _MovePKMNWithoutMail:
ld [wJumptableIndex], a
ret
-.unused
+.go_back ; unreferenced
ld hl, wJumptableIndex
dec [hl]
ret
@@ -767,9 +767,9 @@ BillsPC_InitRAM:
call ByteFill
xor a
ld [wJumptableIndex], a
- ld [wce64], a
- ld [wce65], a
- ld [wce66], a
+ ld [wUnusedBillsPCData], a
+ ld [wUnusedBillsPCData+1], a
+ ld [wUnusedBillsPCData+2], a
ld [wBillsPC_CursorPosition], a
ld [wBillsPC_ScrollPosition], a
ret
@@ -1362,20 +1362,20 @@ copy_box_data: MACRO
jr z, .done\@
and a
jr z, .done\@
- ld [de], a
+ ld [de], a ; species
inc de
ld a, [wBillsPC_LoadedBox]
- ld [de], a
+ ld [de], a ; box number
inc de
- ld a, [wceee]
- ld [de], a
+ ld a, [wBillsPCTempListIndex]
+ ld [de], a ; list index
inc a
- ld [wceee], a
+ ld [wBillsPCTempListIndex], a
inc de
inc hl
- ld a, [wceef]
+ ld a, [wBillsPCTempBoxCount]
inc a
- ld [wceef], a
+ ld [wBillsPCTempBoxCount], a
jr .loop\@
.done\@
@@ -1384,7 +1384,7 @@ if \1
endc
ld a, -1
ld [de], a
- ld a, [wceef]
+ ld a, [wBillsPCTempBoxCount]
inc a
ld [wBillsPC_NumMonsInBox], a
ENDM
@@ -1396,8 +1396,8 @@ CopyBoxmonSpecies:
call ByteFill
ld de, wBillsPCPokemonList
xor a
- ld [wceee], a
- ld [wceef], a
+ ld [wBillsPCTempListIndex], a
+ ld [wBillsPCTempBoxCount], a
ld a, [wBillsPC_LoadedBox]
and a
jr z, .party
@@ -2200,7 +2200,7 @@ PCString_ReleasedPKMN: db "Released <PK><MN>.@"
PCString_Bye: db "Bye,@"
PCString_Stored: db "Stored @"
PCString_Got: db "Got @"
-PCString_Non: db "Non.@"
+PCString_Non: db "Non.@" ; unreferenced
PCString_BoxFull: db "The BOX is full.@"
PCString_PartyFull: db "The party's full!@"
PCString_NoReleasingEGGS: db "No releasing EGGS!@"
@@ -2246,16 +2246,16 @@ _ChangeBox_MenuHeader:
dw .MenuData
db 1 ; default option
-.MenuData
+.MenuData:
db SCROLLINGMENU_CALL_FUNCTION3_NO_SWITCH | SCROLLINGMENU_ENABLE_FUNCTION3 ; flags
db 4, 0 ; rows, columns
db SCROLLINGMENU_ITEMS_NORMAL ; item format
- dba .boxes
- dba .boxnames
+ dba .Boxes
+ dba .PrintBoxNames
dba NULL
dba BillsPC_PrintBoxCountAndCapacity
-.boxes
+.Boxes:
db NUM_BOXES
x = 1
rept NUM_BOXES
@@ -2264,7 +2264,7 @@ x = x + 1
endr
db -1
-.boxnames
+.PrintBoxNames:
push de
ld a, [wMenuSelection]
dec a
@@ -2433,7 +2433,7 @@ BillsPC_ChangeBoxSubmenu:
.Name:
ld b, NAME_BOX
- ld de, wceed
+ ld de, wBoxNameBuffer
farcall NamingScreen
call ClearTilemap
call LoadStandardFont
@@ -2443,17 +2443,17 @@ BillsPC_ChangeBoxSubmenu:
call GetBoxName
ld e, l
ld d, h
- ld hl, wceed
+ ld hl, wBoxNameBuffer
ld c, BOX_NAME_LENGTH - 1
call InitString
ld a, [wMenuSelection]
dec a
call GetBoxName
- ld de, wceed
+ ld de, wBoxNameBuffer
call CopyName2
ret
- hlcoord 11, 7 ; unused
+ hlcoord 11, 7 ; unreferenced
.MenuHeader:
db MENU_BACKUP_TILES ; flags
diff --git a/engine/pokemon/breedmon_level_growth.asm b/engine/pokemon/breedmon_level_growth.asm
index c6356dd6..f64bd6ca 100644
--- a/engine/pokemon/breedmon_level_growth.asm
+++ b/engine/pokemon/breedmon_level_growth.asm
@@ -1,5 +1,5 @@
GetBreedMon1LevelGrowth:
- ld hl, wBreedMon1Stats
+ ld hl, wBreedMon1
ld de, wTempMon
ld bc, BOXMON_STRUCT_LENGTH
call CopyBytes
@@ -13,7 +13,7 @@ GetBreedMon1LevelGrowth:
ret
GetBreedMon2LevelGrowth:
- ld hl, wBreedMon2Stats
+ ld hl, wBreedMon2
ld de, wTempMon
ld bc, BOXMON_STRUCT_LENGTH
call CopyBytes
diff --git a/engine/pokemon/evolve.asm b/engine/pokemon/evolve.asm
index e538a040..3619d2da 100644
--- a/engine/pokemon/evolve.asm
+++ b/engine/pokemon/evolve.asm
@@ -327,7 +327,7 @@ EvolveAfterBattle_MasterLoop:
inc hl
jp .loop
-; unused
+.UnusedReturnToMap: ; unreferenced
pop hl
.ReturnToMap:
pop de
@@ -512,7 +512,7 @@ FillMoves:
ld a, [wEvolutionOldSpecies]
and a
jr z, .CheckMove
- ld a, [wceed]
+ ld a, [wPrevPartyLevel]
cp b
jr nc, .GetMove
diff --git a/engine/pokemon/mail.asm b/engine/pokemon/mail.asm
index 9da39149..94006146 100644
--- a/engine/pokemon/mail.asm
+++ b/engine/pokemon/mail.asm
@@ -8,7 +8,7 @@ SendMailToPC:
cp MAILBOX_CAPACITY
jr nc, .full
ld bc, MAIL_STRUCT_LENGTH
- ld hl, sMailbox
+ ld hl, sMailboxes
call AddNTimes
ld d, h
ld e, l
@@ -44,7 +44,7 @@ DeleteMailFromPC:
call OpenSRAM
ld a, b
push bc
- ld hl, sMailbox
+ ld hl, sMailboxes
ld bc, MAIL_STRUCT_LENGTH
call AddNTimes
push hl
@@ -73,7 +73,7 @@ DeleteMailFromPC:
ReadMailMessage:
ld a, b
- ld hl, sMailbox
+ ld hl, sMailboxes
ld bc, MAIL_STRUCT_LENGTH
call AddNTimes
ld d, h
@@ -87,7 +87,7 @@ MoveMailFromPCToParty:
push bc
ld a, b
ld bc, MAIL_STRUCT_LENGTH
- ld hl, sMailbox
+ ld hl, sMailboxes
call AddNTimes
push hl
ld a, [wCurPartyMon]
@@ -206,7 +206,7 @@ GivePokeMail::
call AddNTimes
ld d, h
ld e, l
- ld hl, wceed
+ ld hl, wMonMailMessageBuffer
ld bc, MAIL_MSG_LENGTH + 1
ld a, BANK(sPartyMail)
call OpenSRAM
@@ -314,19 +314,19 @@ _PlayerMailBoxMenu:
text_end
InitMail:
-; initialize wMailboxCount and beyond with incrementing values, one per mail
-; set z if no mail
+; return z if no mail
ld a, BANK(sMailboxCount)
call OpenSRAM
ld a, [sMailboxCount]
call CloseSRAM
+
+; initialize wMailboxCount from sMailboxCount
ld hl, wMailboxCount
- ld [hli], a
+ ld [hli], a ; now hl = wMailboxItems
and a
-
jr z, .done ; if no mail, we're done
- ; load values in memory with incrementing values starting at wMailboxCount
+; initialize wMailboxItems with incrementing values starting at 1
ld b, a
ld a, 1
.loop
@@ -334,6 +334,7 @@ InitMail:
inc a
dec b
jr nz, .loop
+
.done
ld [hl], -1 ; terminate
diff --git a/engine/pokemon/mail_2.asm b/engine/pokemon/mail_2.asm
index c728b533..b5168580 100644
--- a/engine/pokemon/mail_2.asm
+++ b/engine/pokemon/mail_2.asm
@@ -385,7 +385,7 @@ LoadBlueSkyMailGFX:
ld de, BlueSkyMailGrassGFX
ld c, 1 * LEN_1BPP_TILE
call LoadMailGFX_Color3
- ld de, MailDragoniteGFX
+ ld de, MailDragoniteAndSentretGFX
ld c, 23 * LEN_1BPP_TILE
call LoadMailGFX_Color3
ld de, MailCloudGFX
@@ -748,7 +748,7 @@ Mail_Place14TileAlternatingRow:
ld b, 14 / 2
jr Mail_PlaceAlternatingRow
-Mail_Place16TileAlternatingRow:
+Mail_Place16TileAlternatingRow: ; unreferenced
push af
ld b, 16 / 2
jr Mail_PlaceAlternatingRow
@@ -756,6 +756,7 @@ Mail_Place16TileAlternatingRow:
Mail_Place18TileAlternatingRow:
push af
ld b, 18 / 2
+ ; fallthrough
Mail_PlaceAlternatingRow:
.loop
@@ -793,16 +794,16 @@ Mail_PlaceAlternatingColumn:
pop af
ret
-Mail_Draw7TileRow:
- ld b, $7
+Mail_Draw7TileRow: ; unreferenced
+ ld b, 7
jr Mail_DrawRowLoop
Mail_Draw13TileRow:
- ld b, $d
+ ld b, 13
jr Mail_DrawRowLoop
Mail_Draw16TileRow:
- ld b, $10
+ ld b, 16
jr Mail_DrawRowLoop
Mail_DrawTopBottomBorder:
@@ -811,6 +812,7 @@ Mail_DrawTopBottomBorder:
Mail_DrawFullWidthBorder:
ld b, SCREEN_WIDTH
+ ; fallthrough
Mail_DrawRowLoop:
.loop
diff --git a/engine/pokemon/move_mon.asm b/engine/pokemon/move_mon.asm
index 36c74140..fe2a0886 100644
--- a/engine/pokemon/move_mon.asm
+++ b/engine/pokemon/move_mon.asm
@@ -780,7 +780,7 @@ RetrieveMonFromDayCareMan:
call WaitSFX
call GetBreedMon1LevelGrowth
ld a, b
- ld [wceed], a
+ ld [wPrevPartyLevel], a
ld a, e
ld [wCurPartyLevel], a
xor a
@@ -795,12 +795,12 @@ RetrieveMonFromDayCareLady:
call WaitSFX
call GetBreedMon2LevelGrowth
ld a, b
- ld [wceed], a
+ ld [wPrevPartyLevel], a
ld a, e
ld [wCurPartyLevel], a
ld a, PC_DEPOSIT
ld [wPokemonWithdrawDepositParameter], a
- jp RetrieveBreedmon
+ jp RetrieveBreedmon ; pointless
RetrieveBreedmon:
ld hl, wPartyCount
@@ -1723,7 +1723,6 @@ GivePoke::
ld d, h
ld e, l
pop hl
-.otnameloop
ld a, [wScriptBank]
call FarCopyBytes
ld a, [wCurPartyMon]
diff --git a/engine/pokemon/party_menu.asm b/engine/pokemon/party_menu.asm
index 1f63ba12..f10248e4 100644
--- a/engine/pokemon/party_menu.asm
+++ b/engine/pokemon/party_menu.asm
@@ -680,12 +680,10 @@ TeachWhichPKMNString:
MoveToWhereString:
db "Move to where?@"
-ChooseAFemalePKMNString:
-; unused
+ChooseAFemalePKMNString: ; unreferenced
db "Choose a ♀<PK><MN>.@"
-ChooseAMalePKMNString:
-; unused
+ChooseAMalePKMNString: ; unreferenced
db "Choose a ♂<PK><MN>.@"
ToWhichPKMNString:
diff --git a/engine/pokemon/switchpartymons.asm b/engine/pokemon/switchpartymons.asm
index 24d19df6..2c00b34b 100644
--- a/engine/pokemon/switchpartymons.asm
+++ b/engine/pokemon/switchpartymons.asm
@@ -65,7 +65,7 @@ _SwitchPartyMons:
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
push hl
- ld de, wceed
+ ld de, wSwitchMonBuffer
ld bc, PARTYMON_STRUCT_LENGTH
call CopyBytes
ld a, [wBuffer3]
@@ -77,14 +77,14 @@ _SwitchPartyMons:
ld bc, PARTYMON_STRUCT_LENGTH
call CopyBytes
pop de
- ld hl, wceed
+ ld hl, wSwitchMonBuffer
ld bc, PARTYMON_STRUCT_LENGTH
call CopyBytes
ld a, [wBuffer2]
ld hl, wPartyMonOT
call SkipNames
push hl
- call .CopyNameTowceed
+ call .CopyNameToSwitchMonBuffer
ld a, [wBuffer3]
ld hl, wPartyMonOT
call SkipNames
@@ -92,13 +92,13 @@ _SwitchPartyMons:
push hl
call .CopyName
pop de
- ld hl, wceed
+ ld hl, wSwitchMonBuffer
call .CopyName
ld hl, wPartyMonNicknames
ld a, [wBuffer2]
call SkipNames
push hl
- call .CopyNameTowceed
+ call .CopyNameToSwitchMonBuffer
ld hl, wPartyMonNicknames
ld a, [wBuffer3]
call SkipNames
@@ -106,14 +106,14 @@ _SwitchPartyMons:
push hl
call .CopyName
pop de
- ld hl, wceed
+ ld hl, wSwitchMonBuffer
call .CopyName
ld hl, sPartyMail
ld a, [wBuffer2]
ld bc, MAIL_STRUCT_LENGTH
call AddNTimes
push hl
- ld de, wceed
+ ld de, wSwitchMonBuffer
ld bc, MAIL_STRUCT_LENGTH
ld a, BANK(sPartyMail)
call OpenSRAM
@@ -127,7 +127,7 @@ _SwitchPartyMons:
ld bc, MAIL_STRUCT_LENGTH
call CopyBytes
pop de
- ld hl, wceed
+ ld hl, wSwitchMonBuffer
ld bc, MAIL_STRUCT_LENGTH
call CopyBytes
call CloseSRAM
@@ -136,8 +136,8 @@ _SwitchPartyMons:
pop hl
ret
-.CopyNameTowceed:
- ld de, wceed
+.CopyNameToSwitchMonBuffer:
+ ld de, wSwitchMonBuffer
.CopyName:
ld bc, NAME_LENGTH
diff --git a/engine/printer/printer.asm b/engine/printer/printer.asm
index a6e0f956..5b17c52f 100644
--- a/engine/printer/printer.asm
+++ b/engine/printer/printer.asm
@@ -443,9 +443,11 @@ CheckCancelPrint:
ret
.pressed_b
- ld a, [wc980]
+ ld a, [wUnusedGameboyPrinterSafeCancelFlag]
cp $0c
jr nz, .cancel
+
+; wait for printer activity to finish before canceling?
.loop
ld a, [wPrinterOpcode]
and a
diff --git a/engine/printer/printer_serial.asm b/engine/printer/printer_serial.asm
index 9d0bd907..f717ad38 100644
--- a/engine/printer/printer_serial.asm
+++ b/engine/printer/printer_serial.asm
@@ -304,7 +304,7 @@ Printer_ResetData:
xor a
ld [wPrinterSendByteCounter], a
ld [wPrinterSendByteCounter + 1], a
- ld hl, wGameboyPrinterRAM
+ ld hl, wGameboyPrinter2bppSource
ld bc, wGameboyPrinter2bppSourceEnd - wGameboyPrinter2bppSource
call Printer_ByteFill
ret
@@ -435,10 +435,10 @@ PrinterDataPacket3:
PrinterDataPacket4:
db 4, 0, $00, 0
dw 4
-PrinterDataPacket5: ; unused
+PrinterDataPacket5: ; unreferenced
db 8, 0, $00, 0
dw 8
-PrinterDataPacket6: ; unused
+PrinterDataPacket6: ; unreferenced
db 15, 0, $00, 0
dw 15
diff --git a/engine/smallflag.asm b/engine/smallflag.asm
index 04cbfcc2..316ae6aa 100644
--- a/engine/smallflag.asm
+++ b/engine/smallflag.asm
@@ -36,9 +36,9 @@ SmallFarFlagAction:
jr z, .set ; 1 = SET_FLAG
dec b
jr z, .check ; 2 = CHECK_FLAG
-; 0 = RESET_FLAG
+ ; 0 = RESET_FLAG
-.reset
+; reset
ld a, c
cpl
and [hl]
diff --git a/engine/tilesets/tileset_anims.asm b/engine/tilesets/tileset_anims.asm
index 0cef55bb..384d2ad9 100644
--- a/engine/tilesets/tileset_anims.asm
+++ b/engine/tilesets/tileset_anims.asm
@@ -1,9 +1,12 @@
- db 0 ; unused
+DummyPredef3A_DummyData: ; unreferenced
+ db 0
DummyPredef3A:
ret
- ret ; unused
+DummyPredef3A_DummyFunction: ; unreferenced
+ ret
+
_AnimateTileset::
; Iterate over a given pointer array of
@@ -279,7 +282,7 @@ ScrollTileRightLeft:
jr nz, ScrollTileLeft
jr ScrollTileRight
-ScrollTileUpDown:
+ScrollTileUpDown: ; unreferenced
; Scroll up for 4 ticks, then down for 4 ticks.
ld a, [wTileAnimationTimer]
inc a
@@ -665,7 +668,7 @@ AnimateWaterPalette:
cp %100 ; frame 4
jr z, .color2
-.color1
+; color1
ld hl, wBGPals1 palette PAL_BG_WATER color 1
ld a, [hli]
ldh [rBGPD], a
@@ -754,4 +757,5 @@ WhirlpoolTiles2: INCBIN "gfx/tilesets/whirlpool/2.2bpp"
WhirlpoolTiles3: INCBIN "gfx/tilesets/whirlpool/3.2bpp"
WhirlpoolTiles4: INCBIN "gfx/tilesets/whirlpool/4.2bpp"
- ret ; unused
+TilesetAnims_DummyFunction: ; unreferenced
+ ret
diff --git a/gfx/font.asm b/gfx/font.asm
index b4602fb4..679141e3 100644
--- a/gfx/font.asm
+++ b/gfx/font.asm
@@ -33,13 +33,13 @@ INCBIN "gfx/battle/expbar.2bpp"
TownMapGFX:
INCBIN "gfx/pokegear/town_map.2bpp.lz"
-UnusedWeekdayKanjiGFX:
+UnusedWeekdayKanjiGFX: ; unreferenced
INCBIN "gfx/font/unused_weekday_kanji.2bpp"
PokegearPhoneIconGFX:
INCBIN "gfx/font/phone_icon.2bpp"
-UnusedBoldFontGFX:
+UnusedBoldFontGFX: ; unreferenced
INCBIN "gfx/font/unused_bold_font.1bpp"
TextboxSpaceGFX:
diff --git a/gfx/mail.asm b/gfx/mail.asm
index f8b3f289..fe42eb88 100644
--- a/gfx/mail.asm
+++ b/gfx/mail.asm
@@ -55,15 +55,10 @@ INCBIN "gfx/mail/ditto.1bpp"
MailMewGFX:
INCBIN "gfx/mail/mew.1bpp"
-MailDragoniteGFX:
+MailDragoniteAndSentretGFX:
INCBIN "gfx/mail/dragonite.1bpp"
-
-MailSentretGFX:
INCBIN "gfx/mail/sentret.1bpp"
-MailUnusedGrassGFX:
-INCBIN "gfx/mail/unused_grass.1bpp"
-
PortraitMailLargePokeballGFX:
INCBIN "gfx/mail/large_pokeball.1bpp"
diff --git a/gfx/mail/sentret.png b/gfx/mail/sentret.png
index b277a2c9..0bfff0d6 100644
--- a/gfx/mail/sentret.png
+++ b/gfx/mail/sentret.png
Binary files differ
diff --git a/gfx/mail/unused_grass.png b/gfx/mail/unused_grass.png
deleted file mode 100644
index bdc18dba..00000000
--- a/gfx/mail/unused_grass.png
+++ /dev/null
Binary files differ
diff --git a/gfx/tileset_palette_maps.asm b/gfx/tileset_palette_maps.asm
index c0a72820..2fdd32f2 100644
--- a/gfx/tileset_palette_maps.asm
+++ b/gfx/tileset_palette_maps.asm
@@ -85,7 +85,7 @@ INCLUDE "gfx/tilesets/lighthouse_palette_map.asm"
TilesetPlayersRoomPalMap:
INCLUDE "gfx/tilesets/players_room_palette_map.asm"
-UnusedMuseumPalMap:
+UnusedMuseumPalMap: ; unreferenced
INCLUDE "gfx/tilesets/unused_museum_palette_map.asm"
TilesetIcePathPalMap:
diff --git a/home/audio.asm b/home/audio.asm
index 410dad55..a1158427 100644
--- a/home/audio.asm
+++ b/home/audio.asm
@@ -409,7 +409,7 @@ SpecialMapMusic::
and a
ret
-.bike
+.bike ; unreferenced
ld de, MUSIC_BICYCLE
scf
ret
diff --git a/home/battle.asm b/home/battle.asm
index c0bcaad3..f471ba1e 100644
--- a/home/battle.asm
+++ b/home/battle.asm
@@ -252,6 +252,6 @@ PushLYOverrides::
ld a, HIGH(wLYOverrides)
ld [wRequested2bppDest + 1], a
- ld a, (wLYOverridesEnd - wLYOverrides) / 16
- ld [wRequested2bpp], a
+ ld a, (wLYOverridesEnd - wLYOverrides) / LEN_2BPP_TILE
+ ld [wRequested2bppSize], a
ret
diff --git a/home/decompress.asm b/home/decompress.asm
index 0ac2c0b6..a072b1e7 100644
--- a/home/decompress.asm
+++ b/home/decompress.asm
@@ -80,7 +80,6 @@ LZ_LONG_HI EQU %00000011
cp LZ_LONG
jr nz, .short
-.long
; The count is now 10 bits.
; Read the next 3 bits.
@@ -133,7 +132,7 @@ LZ_LONG_HI EQU %00000011
cp LZ_ZERO
jr z, .Zero
-.Literal:
+; Literal
; Read literal data for bc bytes.
.lloop
dec c
@@ -215,10 +214,8 @@ LZ_LONG_HI EQU %00000011
bit 7, a ; sign
jr z, .positive
-.negative
-; hl = de - a
- ; Since we can't subtract a from de,
- ; Make it negative and add de.
+; negative
+ ; hl = de + -a
and %01111111
cpl
add e
diff --git a/home/game_time.asm b/home/game_time.asm
index b0039952..33d7bcc1 100644
--- a/home/game_time.asm
+++ b/home/game_time.asm
@@ -20,8 +20,8 @@ GameTimer::
ret nz
; Is the timer paused?
- ld hl, wGameTimerPause
- bit GAMETIMERPAUSE_TIMER_PAUSED_F, [hl]
+ ld hl, wGameTimerPaused
+ bit GAME_TIMER_PAUSED_F, [hl]
ret z
; Is the timer already capped?
diff --git a/home/gfx.asm b/home/gfx.asm
index efb0499a..42929935 100644
--- a/home/gfx.asm
+++ b/home/gfx.asm
@@ -137,7 +137,7 @@ Request2bpp::
cp TILES_PER_CYCLE
jr nc, .cycle
- ld [wRequested2bpp], a
+ ld [wRequested2bppSize], a
call DelayFrame
pop af
@@ -149,7 +149,7 @@ Request2bpp::
.cycle
ld a, TILES_PER_CYCLE
- ld [wRequested2bpp], a
+ ld [wRequested2bppSize], a
call DelayFrame
ld a, c
@@ -182,7 +182,7 @@ Request1bpp::
cp TILES_PER_CYCLE
jr nc, .cycle
- ld [wRequested1bpp], a
+ ld [wRequested1bppSize], a
call DelayFrame
pop af
@@ -194,7 +194,7 @@ Request1bpp::
.cycle
ld a, TILES_PER_CYCLE
- ld [wRequested1bpp], a
+ ld [wRequested1bppSize], a
call DelayFrame
ld a, c
diff --git a/home/init.asm b/home/init.asm
index fc04cfd1..052a3685 100644
--- a/home/init.asm
+++ b/home/init.asm
@@ -5,8 +5,8 @@ Reset::
call ClearPalettes
ei
- ld hl, wd8ba
- set 7, [hl]
+ ld hl, wJoypadDisable
+ set JOYPAD_DISABLE_SGB_TRANSFER_F, [hl]
ld c, 32
call DelayFrames
@@ -43,7 +43,7 @@ Init::
ldh [rOBP1], a
ldh [rTMA], a
ldh [rTAC], a
- ld [wceeb], a
+ ld [wBetaTitleSequenceOpeningType], a
ld a, %100 ; Start timer at 4096Hz
ldh [rTAC], a
@@ -161,11 +161,13 @@ ClearVRAM::
BlankBGMap::
ld a, " "
- jr .fill
-; unused; would fill BG Map with value in l
+ jr FillBGMap
+
+FillBGMap_l:: ; unreferenced
ld a, l
+ ; fallthrough
-.fill
+FillBGMap::
ld de, vBGMap1 - vBGMap0
ld l, e
.loop
diff --git a/home/joypad.asm b/home/joypad.asm
index 66d5649e..effe8e89 100644
--- a/home/joypad.asm
+++ b/home/joypad.asm
@@ -27,8 +27,8 @@ UpdateJoypad::
; hJoypadSum: pressed so far
; Any of these three bits can be used to disable input.
- ld a, [wd8ba]
- and %11010000
+ ld a, [wJoypadDisable]
+ and (1 << JOYPAD_DISABLE_MON_FAINT_F) | (1 << JOYPAD_DISABLE_SGB_TRANSFER_F) | (1 << 4)
ret nz
; If we're saving, input is disabled.
diff --git a/home/map.asm b/home/map.asm
index 2701f477..22719788 100644
--- a/home/map.asm
+++ b/home/map.asm
@@ -124,12 +124,12 @@ LoadMetatiles::
ld a, [wOverworldMapAnchor + 1]
ld d, a
ld hl, wSurroundingTiles
- ld b, SURROUNDING_HEIGHT / METATILE_WIDTH ; 5
+ ld b, SCREEN_META_HEIGHT
.row
push de
push hl
- ld c, SURROUNDING_WIDTH / METATILE_WIDTH ; 6
+ ld c, SCREEN_META_WIDTH
.col
push de
@@ -195,7 +195,7 @@ endr
add hl, de
pop de
ld a, [wMapWidth]
- add 6
+ add MAP_CONNECTION_PADDING_WIDTH * 2
add e
ld e, a
jr nc, .ok2
@@ -562,45 +562,43 @@ GetMapScreenCoords::
ld hl, wOverworldMapBlocks
ld a, [wXCoord]
bit 0, a
- jr nz, .increment_then_halve1
+ jr nz, .odd_x
+; even x
srl a
- add $1
- jr .resume
-
-.increment_then_halve1
- add $1
+ add 1
+ jr .got_block_x
+.odd_x
+ add 1
srl a
-
-.resume
+.got_block_x
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [wMapWidth]
- add $6
+ add MAP_CONNECTION_PADDING_WIDTH * 2
ld c, a
- ld b, $0
+ ld b, 0
ld a, [wYCoord]
bit 0, a
- jr nz, .increment_then_halve2
+ jr nz, .odd_y
+; even y
srl a
- add $1
- jr .resume2
-
-.increment_then_halve2
- add $1
+ add 1
+ jr .got_block_y
+.odd_y
+ add 1
srl a
-
-.resume2
+.got_block_y
call AddNTimes
ld a, l
ld [wOverworldMapAnchor], a
ld a, h
ld [wOverworldMapAnchor + 1], a
ld a, [wYCoord]
- and $1
+ and 1
ld [wMetatileStandingY], a
ld a, [wXCoord]
- and $1
+ and 1
ld [wMetatileStandingX], a
ret
@@ -2009,7 +2007,8 @@ GetMapEnvironment::
pop hl
ret
- ret ; unused
+Map_DummyFunction:: ; unreferenced
+ ret
GetAnyMapEnvironment::
push hl
diff --git a/home/menu.asm b/home/menu.asm
index 7bc6454d..ed17e05e 100644
--- a/home/menu.asm
+++ b/home/menu.asm
@@ -251,6 +251,7 @@ MenuBoxCoord2Tile::
ld c, a
ld a, [wMenuBorderTopCoord]
ld b, a
+ ; fallthrough
Coord2Tile::
; Return the address of wTilemap(c, b) in hl.
@@ -294,7 +295,7 @@ MenuTextbox::
pop hl
jp PrintText
-; unused
+Menu_DummyFunction:: ; unreferenced
ret
LoadMenuTextbox::
diff --git a/home/movement.asm b/home/movement.asm
index f329a3c3..c5d9d12b 100644
--- a/home/movement.asm
+++ b/home/movement.asm
@@ -2,7 +2,7 @@ InitMovementBuffer::
ld [wMovementBufferObject], a
xor a
ld [wMovementBufferCount], a
- ld a, $0 ; useless
+ ld a, BANK(wMovementBuffer)
ld [wUnusedMovementBufferBank], a
ld a, LOW(wMovementBuffer)
ld [wUnusedMovementBufferPointer], a
diff --git a/home/names.asm b/home/names.asm
index e3da8793..58cc0fbb 100644
--- a/home/names.asm
+++ b/home/names.asm
@@ -56,9 +56,9 @@ GetName::
.done
ld a, e
- ld [wUnusedCFFE], a
+ ld [wUnusedNamesPointer], a
ld a, d
- ld [wUnusedCFFE + 1], a
+ ld [wUnusedNamesPointer + 1], a
pop de
pop bc
diff --git a/home/print_bcd.asm b/home/print_bcd.asm
index 74e2d161..4182eadf 100644
--- a/home/print_bcd.asm
+++ b/home/print_bcd.asm
@@ -33,10 +33,11 @@ PrintBCDNumber::
jr nz, .loop
bit PRINTNUM_LEADINGZEROS_F, b
jr z, .done ; if so, we are done
-.numberEqualsZero ; if every digit of the BCD number is zero
+; every digit of the BCD number is zero
bit PRINTNUM_LEFTALIGN_F, b
jr nz, .skipLeftAlignmentAdjustment
- dec hl ; if the string is left-aligned, it needs to be moved back one space
+; the string is left-aligned; it needs to be moved back one space
+ dec hl
.skipLeftAlignmentAdjustment
bit PRINTNUM_MONEY_F, b
jr z, .skipCurrencySymbol
@@ -53,7 +54,7 @@ PrintBCDDigit::
and %00001111
and a
jr z, .zeroDigit
-.nonzeroDigit
+; nonzero digit
bit PRINTNUM_LEADINGZEROS_F, b ; have any non-space characters been printed?
jr z, .outputDigit
; if bit 7 is set, then no numbers have been printed yet
diff --git a/home/print_num.asm b/home/print_num.asm
index d9cf15f5..62f03f5a 100644
--- a/home/print_num.asm
+++ b/home/print_num.asm
@@ -35,7 +35,6 @@ PrintNum::
cp 2
jr z, .word
; maximum 3 bytes
-.long
ld a, [de]
ldh [hPrintNumBuffer + 1], a
inc de
@@ -81,7 +80,7 @@ PrintNum::
cp 6
jr z, .six
-.seven
+; seven
ld a, HIGH(1000000 >> 8)
ldh [hPrintNumBuffer + 4], a
ld a, HIGH(1000000) ; mid
@@ -301,7 +300,7 @@ PrintNum::
inc hl
ret
-PrintHexNumber:: ; unreferenced
+PrintHexNumber::
; Print the c-byte value from de to hl as hexadecimal digits.
.loop
push bc
diff --git a/home/serial.asm b/home/serial.asm
index a317b5c7..0e42b9c0 100644
--- a/home/serial.asm
+++ b/home/serial.asm
@@ -49,13 +49,13 @@ Serial::
xor a
ldh [rSB], a
+
ld a, 3
ldh [rDIV], a
-
-.wait_bit_7
+.delay_loop
ldh a, [rDIV]
bit 7, a
- jr nz, .wait_bit_7
+ jr nz, .delay_loop
ld a, (0 << rSC_ON) | (0 << rSC_CLOCK)
ldh [rSC], a
@@ -81,8 +81,9 @@ Serial::
reti
Serial_ExchangeBytes::
- ld a, $1
+ ld a, TRUE
ldh [hSerialIgnoringInitialData], a
+
.loop
ld a, [hl]
ldh [hSerialSend], a
@@ -90,10 +91,12 @@ Serial_ExchangeBytes::
push bc
ld b, a
inc hl
- ld a, $30
+
+ ld a, 48
.wait
dec a
jr nz, .wait
+
ldh a, [hSerialIgnoringInitialData]
and a
ld a, b
@@ -116,7 +119,7 @@ Serial_ExchangeBytes::
ret
Serial_ExchangeByte::
-.loop
+.timeout_loop
xor a
ldh [hSerialReceivedNewData], a
ldh a, [hSerialConnectionStatus]
@@ -127,16 +130,16 @@ Serial_ExchangeByte::
ld a, (1 << rSC_ON) | (1 << rSC_CLOCK)
ldh [rSC], a
.not_player_2
-.loop2
+.loop
ldh a, [hSerialReceivedNewData]
and a
- jr nz, .reset_ffcc
+ jr nz, .await_new_data
ldh a, [hSerialConnectionStatus]
cp USING_EXTERNAL_CLOCK
- jr nz, .not_player_1_or_wLinkTimeoutFrames_zero
- call CheckwLinkTimeoutFramesNonzero
- jr z, .not_player_1_or_wLinkTimeoutFrames_zero
- call .delay_15_cycles
+ jr nz, .not_player_1_or_timed_out
+ call CheckLinkTimeoutFramesNonzero
+ jr z, .not_player_1_or_timed_out
+ call .ShortDelay
push hl
ld hl, wLinkTimeoutFrames + 1
inc [hl]
@@ -146,51 +149,52 @@ Serial_ExchangeByte::
.no_rollover_up
pop hl
- call CheckwLinkTimeoutFramesNonzero
- jr nz, .loop2
+ call CheckLinkTimeoutFramesNonzero
+ jr nz, .loop
jp SerialDisconnected
-.not_player_1_or_wLinkTimeoutFrames_zero
+.not_player_1_or_timed_out
ldh a, [rIE]
and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
cp 1 << SERIAL
- jr nz, .loop2
- ld a, [wce5d]
+ jr nz, .loop
+ ld a, [wLinkByteTimeout]
dec a
- ld [wce5d], a
- jr nz, .loop2
- ld a, [wce5d + 1]
+ ld [wLinkByteTimeout], a
+ jr nz, .loop
+ ld a, [wLinkByteTimeout + 1]
dec a
- ld [wce5d + 1], a
- jr nz, .loop2
+ ld [wLinkByteTimeout + 1], a
+ jr nz, .loop
ldh a, [hSerialConnectionStatus]
cp USING_EXTERNAL_CLOCK
- jr z, .reset_ffcc
+ jr z, .await_new_data
ld a, 255
-.delay_255_cycles
+.long_delay_loop
dec a
- jr nz, .delay_255_cycles
+ jr nz, .long_delay_loop
-.reset_ffcc
+.await_new_data
xor a
ldh [hSerialReceivedNewData], a
ldh a, [rIE]
and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
sub 1 << SERIAL
- jr nz, .rIE_not_equal_8
+ jr nz, .non_serial_interrupts_enabled
- ; LOW($5000)
- ld [wce5d], a
- ld a, HIGH($5000)
- ld [wce5d + 1], a
+ ; a == 0
+ assert LOW(SERIAL_LINK_BYTE_TIMEOUT) == 0
+ ld [wLinkByteTimeout], a
+ ld a, HIGH(SERIAL_LINK_BYTE_TIMEOUT)
+ ld [wLinkByteTimeout + 1], a
-.rIE_not_equal_8
+.non_serial_interrupts_enabled
ldh a, [hSerialReceive]
cp SERIAL_NO_DATA_BYTE
ret nz
- call CheckwLinkTimeoutFramesNonzero
- jr z, .linkTimeoutFrames_zero
+ call CheckLinkTimeoutFramesNonzero
+ jr z, .timed_out
push hl
ld hl, wLinkTimeoutFrames + 1
ld a, [hl]
@@ -202,10 +206,10 @@ Serial_ExchangeByte::
.no_rollover
pop hl
- call CheckwLinkTimeoutFramesNonzero
+ call CheckLinkTimeoutFramesNonzero
jr z, SerialDisconnected
-.linkTimeoutFrames_zero
+.timed_out
ldh a, [rIE]
and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
cp 1 << SERIAL
@@ -214,16 +218,16 @@ Serial_ExchangeByte::
ld a, [hl]
ldh [hSerialSend], a
call DelayFrame
- jp .loop
+ jp .timeout_loop
-.delay_15_cycles
+.ShortDelay:
ld a, 15
-.delay_cycles
+.short_delay_loop
dec a
- jr nz, .delay_cycles
+ jr nz, .short_delay_loop
ret
-CheckwLinkTimeoutFramesNonzero::
+CheckLinkTimeoutFramesNonzero::
push hl
ld hl, wLinkTimeoutFrames
ld a, [hli]
@@ -231,8 +235,10 @@ CheckwLinkTimeoutFramesNonzero::
pop hl
ret
+; This sets wLinkTimeoutFrames to $ffff, since
+; a is always 0 when it is called.
SerialDisconnected::
- dec a ; a is always 0 when this is called
+ dec a
ld [wLinkTimeoutFrames], a
ld [wLinkTimeoutFrames + 1], a
ret
@@ -273,9 +279,7 @@ Serial_PrintWaitingTextAndSyncAndExchangeNybble::
Serial_SyncAndExchangeNybble:: ; unreferenced
call LoadTilemapToTempTilemap
callfar PlaceWaitingText
- jp WaitLinkTransfer
-
-; One "giant" leap for machinekind
+ jp WaitLinkTransfer ; pointless
WaitLinkTransfer::
ld a, $ff
@@ -283,7 +287,7 @@ WaitLinkTransfer::
.loop
call LinkTransfer
call DelayFrame
- call CheckwLinkTimeoutFramesNonzero
+ call CheckLinkTimeoutFramesNonzero
jr z, .check
push hl
ld hl, wLinkTimeoutFrames + 1
diff --git a/home/text.asm b/home/text.asm
index 9d3428ac..77b8911c 100644
--- a/home/text.asm
+++ b/home/text.asm
@@ -138,6 +138,7 @@ RadioTerminator::
PrintText::
call SetUpTextbox
+ ; fallthrough
PrintTextboxText::
bccoord TEXTBOX_INNERX, TEXTBOX_INNERY
@@ -154,6 +155,7 @@ SetUpTextbox::
PlaceString::
push hl
+ ; fallthrough
PlaceNextChar::
ld a, [de]
@@ -164,7 +166,9 @@ PlaceNextChar::
pop hl
ret
- pop de ; unused
+DummyChar:: ; unreferenced
+ pop de
+ ; fallthrough
NextChar::
inc de
@@ -238,18 +242,19 @@ ENDM
.not_diacritic
cp FIRST_REGULAR_TEXT_CHAR
jr nc, .place
-
+; dakuten or handakuten
cp "パ"
jr nc, .handakuten
-
-.dakuten
+; dakuten
cp FIRST_HIRAGANA_DAKUTEN_CHAR
jr nc, .hiragana_dakuten
+; katakana dakuten
add "カ" - "ガ"
- jr .katakana_dakuten
+ jr .place_dakuten
+
.hiragana_dakuten
add "か" - "が"
-.katakana_dakuten
+.place_dakuten
ld b, "゙" ; dakuten
call Diacritic
jr .place
@@ -257,11 +262,13 @@ ENDM
.handakuten
cp "ぱ"
jr nc, .hiragana_handakuten
+; katakana handakuten
add "ハ" - "パ"
- jr .katakana_handakuten
+ jr .place_handakuten
+
.hiragana_handakuten
add "は" - "ぱ"
-.katakana_handakuten
+.place_handakuten
ld b, "゚" ; handakuten
call Diacritic
@@ -298,12 +305,13 @@ PlaceKokoWa: print_name PlaceKokoWaText
PlaceMoveTargetsName::
ldh a, [hBattleTurn]
xor 1
- jr PlaceMoveUsersName.place
+ jr PlaceBattlersName
PlaceMoveUsersName::
ldh a, [hBattleTurn]
+ ; fallthrough
-.place:
+PlaceBattlersName:
push de
and a
jr nz, .enemy
diff --git a/home/video.asm b/home/video.asm
index dcf7b47c..a9592558 100644
--- a/home/video.asm
+++ b/home/video.asm
@@ -159,7 +159,7 @@ UpdateBGMap::
THIRD_HEIGHT EQU SCREEN_HEIGHT / 3
-.bottom
+; bottom
ld de, 2 * THIRD_HEIGHT * SCREEN_WIDTH
add hl, de
ld sp, hl
@@ -240,11 +240,11 @@ endr
ret
Serve1bppRequest::
- ld a, [wRequested1bpp]
+ ld a, [wRequested1bppSize]
and a
ret z
-; Copy [wRequested1bpp] 1bpp tiles from [wRequested1bppSource] to [wRequested1bppDest]
+; Copy [wRequested1bppSize] 1bpp tiles from [wRequested1bppSource] to [wRequested1bppDest]
ld [hSPBuffer], sp
@@ -262,11 +262,11 @@ Serve1bppRequest::
ld l, a
; # tiles to copy
- ld a, [wRequested1bpp]
+ ld a, [wRequested1bppSize]
ld b, a
xor a
- ld [wRequested1bpp], a
+ ld [wRequested1bppSize], a
.next
@@ -309,11 +309,11 @@ endr
ret
Serve2bppRequest::
- ld a, [wRequested2bpp]
+ ld a, [wRequested2bppSize]
and a
ret z
-; Copy [wRequested2bpp] 2bpp tiles from [wRequested2bppSource] to [wRequested2bppDest]
+; Copy [wRequested2bppSize] 2bpp tiles from [wRequested2bppSource] to [wRequested2bppDest]
ld [hSPBuffer], sp
@@ -331,11 +331,11 @@ Serve2bppRequest::
ld l, a
; # tiles to copy
- ld a, [wRequested2bpp]
+ ld a, [wRequested2bppSize]
ld b, a
xor a
- ld [wRequested2bpp], a
+ ld [wRequested2bppSize], a
.next
@@ -385,10 +385,10 @@ AnimateTileset::
rst Bankswitch
ret
-; unused
+Video_DummyFunction:: ; unreferenced
ret
-; unused
+EnableSpriteDisplay:: ; unreferenced
ld hl, rLCDC
set 1, [hl]
ret
diff --git a/home/warp_connection.asm b/home/warp_connection.asm
index 3c4c5929..ae8edcdb 100644
--- a/home/warp_connection.asm
+++ b/home/warp_connection.asm
@@ -459,7 +459,8 @@ EnterMapWarp::
; MOUNT_MOON_SQUARE and TIN_TOWER_ROOF are outdoor maps within indoor maps.
; Dig and Escape Rope should not take you to them.
ld a, [wPrevMapGroup]
- cp GROUP_MOUNT_MOON_SQUARE ; aka GROUP_TIN_TOWER_ROOF
+ cp GROUP_MOUNT_MOON_SQUARE
+ assert GROUP_MOUNT_MOON_SQUARE == GROUP_TIN_TOWER_ROOF
jr nz, .not_mt_moon_or_tin_tower
ld a, [wPrevMapNumber]
cp MAP_MOUNT_MOON_SQUARE
@@ -497,8 +498,6 @@ EnterMapWarp::
ld a, c
cp TILESET_POKECENTER
ret nz
-
-.pokecenter
ld a, [wPrevMapGroup]
ld [wLastSpawnMapGroup], a
ld a, [wPrevMapNumber]
diff --git a/home/window.asm b/home/window.asm
index c903cdd8..e8e0604d 100644
--- a/home/window.asm
+++ b/home/window.asm
@@ -92,6 +92,6 @@ SafeUpdateSprites::
ldh [hOAMUpdate], a
ret
-; unused
+SetCarryFlag:: ; unreferenced
scf
ret
diff --git a/hram.asm b/hram.asm
index edc9599c..47cd297b 100644
--- a/hram.asm
+++ b/hram.asm
@@ -7,6 +7,7 @@ hRTCDayLo:: db
hRTCHours:: db
hRTCMinutes:: db
hRTCSeconds:: db
+
ds 2
hHours:: db
@@ -27,7 +28,7 @@ hVBlank:: db
hMapEntryMethod:: db
hMenuReturn:: db
-hUnusedFFA3:: db
+hUnusedByte:: db
hJoypadReleased:: db
hJoypadPressed:: db
@@ -49,7 +50,6 @@ hMoveMon:: db
UNION
hMapObjectIndexBuffer:: db
hObjectStructIndexBuffer:: db
-
NEXTU
hConnectionStripLength:: db
hConnectedMapWidth:: db
@@ -85,8 +85,14 @@ NEXTU
hPrintNumBuffer:: ds 10
NEXTU
-; miscellaneous
- ds 9
+; Mystery Gift
+hMGExchangedByte:: db
+hMGExchangedWord:: dw
+hMGNumBits:: db
+hMGChecksum:: dw
+ ds 1
+hMGUnusedMsgLength:: db
+hMGRole:: db
hMGStatusFlags:: db
ENDU
diff --git a/macros/code.asm b/macros/code.asm
index e393d495..a5d8c756 100644
--- a/macros/code.asm
+++ b/macros/code.asm
@@ -38,6 +38,7 @@ maskbits: MACRO
; maskbits 26
; cp 26
; jr nc, .loop
+ assert 0 < (\1) && (\1) <= $100, "bitmask must be 8-bit"
x = 1
rept 8
if x + 1 < (\1)
diff --git a/macros/data.asm b/macros/data.asm
index b6cedbf7..a2b1f23c 100644
--- a/macros/data.asm
+++ b/macros/data.asm
@@ -25,6 +25,10 @@ percent EQUS "* $ff / 100"
; e.g. 1 out_of 2 == 50 percent + 1 == $80
out_of EQUS "* $100 /"
+assert_power_of_2: MACRO
+ assert (\1) & ((\1) - 1) == 0, "\1 must be a power of 2"
+ENDM
+
; Constant data (db, dw, dl) macros
dwb: MACRO
diff --git a/macros/gfx.asm b/macros/gfx.asm
index 2c67cfc8..b42b1440 100644
--- a/macros/gfx.asm
+++ b/macros/gfx.asm
@@ -1,5 +1,13 @@
+assert_valid_rgb: MACRO
+rept _NARG
+ assert 0 <= (\1) && (\1) <= 31, "RGB channel must be 0-31"
+ shift
+endr
+ENDM
+
RGB: MACRO
rept _NARG / 3
+ assert_valid_rgb \1, \2, \3
dw palred (\1) + palgreen (\2) + palblue (\3)
shift 3
endr
diff --git a/macros/scripts/audio.asm b/macros/scripts/audio.asm
index 2776c293..127f2d1e 100644
--- a/macros/scripts/audio.asm
+++ b/macros/scripts/audio.asm
@@ -1,8 +1,12 @@
channel_count: MACRO
+ assert 0 < (\1) && (\1) <= NUM_MUSIC_CHANS, \
+ "channel_count must be 1-{d:NUM_MUSIC_CHANS}"
_num_channels = \1 - 1
ENDM
channel: MACRO
+ assert 0 < (\1) && (\1) <= NUM_CHANNELS, \
+ "channel id must be 1-{d:NUM_CHANNELS}"
dn (_num_channels << 2), \1 - 1 ; channel id
dw \2 ; address
_num_channels = 0
@@ -46,6 +50,7 @@ FIRST_MUSIC_CMD EQU const_value
const octave_cmd ; $d0
octave: MACRO
+ assert 0 < (\1) && (\1) < 8, "octave must be 1-8"
db octave_cmd | 8 - (\1) ; octave
ENDM
diff --git a/macros/scripts/battle_anims.asm b/macros/scripts/battle_anims.asm
index 123a262a..a6ebe431 100644
--- a/macros/scripts/battle_anims.asm
+++ b/macros/scripts/battle_anims.asm
@@ -1,7 +1,5 @@
anim_wait: MACRO
-if \1 >= $d0
- fail "anim_wait argument must be less than $d0."
-endc
+ assert (\1) < $d0, "anim_wait argument must be less than $d0"
db \1
ENDM
diff --git a/macros/scripts/maps.asm b/macros/scripts/maps.asm
index d9ffd83e..a30e0c06 100644
--- a/macros/scripts/maps.asm
+++ b/macros/scripts/maps.asm
@@ -1,5 +1,7 @@
map_id: MACRO
;\1: map id
+ assert DEF(GROUP_\1) && DEF(MAP_\1), \
+ "Missing 'map_const \1' in constants/map_constants.asm"
db GROUP_\1, MAP_\1
ENDM
diff --git a/macros/wram.asm b/macros/wram.asm
index a2aa71df..b514bbde 100644
--- a/macros/wram.asm
+++ b/macros/wram.asm
@@ -77,7 +77,6 @@ battle_struct: MACRO
\1Species:: db
\1Item:: db
\1Moves:: ds NUM_MOVES
-\1MovesEnd::
\1DVs:: dw
\1PP:: ds NUM_MOVES
\1Happiness:: db
diff --git a/main.asm b/main.asm
index 8f5883cd..4b25387f 100644
--- a/main.asm
+++ b/main.asm
@@ -350,7 +350,7 @@ INCLUDE "engine/movie/intro.asm"
SECTION "bank3E", ROMX
INCLUDE "engine/gfx/load_font.asm"
-INCLUDE "data/collision_permissions.asm"
+INCLUDE "data/collision/collision_permissions.asm"
Shrink1Pic:
INCBIN "gfx/new_game/shrink1.2bpp.lz"
diff --git a/maps/AzaleaTown.asm b/maps/AzaleaTown.asm
index 27f87951..0afb71de 100644
--- a/maps/AzaleaTown.asm
+++ b/maps/AzaleaTown.asm
@@ -138,8 +138,7 @@ AzaleaTownSlowpokeScript:
closetext
end
-UnusedWoosterScript:
-; unused
+UnusedWoosterScript: ; unreferenced
faceplayer
opentext
writetext WoosterText
diff --git a/maps/BlackthornDragonSpeechHouse.asm b/maps/BlackthornDragonSpeechHouse.asm
index 80fe72f5..a8a0ecfa 100644
--- a/maps/BlackthornDragonSpeechHouse.asm
+++ b/maps/BlackthornDragonSpeechHouse.asm
@@ -18,12 +18,10 @@ BlackthornDragonSpeechHouseDratiniScript:
closetext
end
-; unused
-BlackthornDragonSpeechHousePictureBookshelf:
+BlackthornDragonSpeechHousePictureBookshelf: ; unreferenced
jumpstd PictureBookshelfScript
-; unused
-BlackthornDragonSpeechHouseMagazineBookshelf:
+BlackthornDragonSpeechHouseMagazineBookshelf: ; unreferenced
jumpstd MagazineBookshelfScript
BlackthornDragonSpeechHouseGrannyText:
diff --git a/maps/BlackthornGym1F.asm b/maps/BlackthornGym1F.asm
index 050dc7f1..3afdfec2 100644
--- a/maps/BlackthornGym1F.asm
+++ b/maps/BlackthornGym1F.asm
@@ -251,7 +251,7 @@ BlackthornGymClairText_YouKeptMeWaiting:
line "this TM."
done
-BlackthornGymText_ReceivedTM24:
+BlackthornGymText_ReceivedTM24: ; unreferenced
text "<PLAYER> received"
line "TM24."
done
diff --git a/maps/BurnedTowerB1F.asm b/maps/BurnedTowerB1F.asm
index 6c5cf833..fe91b47d 100644
--- a/maps/BurnedTowerB1F.asm
+++ b/maps/BurnedTowerB1F.asm
@@ -65,7 +65,7 @@ ReleaseTheBeasts:
special InitRoamMons
end
-UnusedEnteiScript:
+UnusedEnteiScript: ; unreferenced
opentext
writetext UnusedEnteiText
cry ENTEI
diff --git a/maps/CeladonDeptStore6F.asm b/maps/CeladonDeptStore6F.asm
index fe27df8c..a0d4a0dc 100644
--- a/maps/CeladonDeptStore6F.asm
+++ b/maps/CeladonDeptStore6F.asm
@@ -93,8 +93,7 @@ CeladonDeptStore6FVendingMachine:
CeladonDeptStore6FDirectory:
jumptext CeladonDeptStore6FDirectoryText
-; unused
-CeladonDeptStore6FElevatorButton:
+CeladonDeptStore6FElevatorButton: ; unreferenced
jumpstd ElevatorButtonScript
CeladonVendingText:
diff --git a/maps/CeladonGameCorner.asm b/maps/CeladonGameCorner.asm
index 619b4767..f94a097d 100644
--- a/maps/CeladonGameCorner.asm
+++ b/maps/CeladonGameCorner.asm
@@ -141,8 +141,7 @@ CeladonGameCornerSodaCanScript:
closetext
end
-CeladonGameCornerUnusedMovementData:
-; unreferenced
+CeladonGameCornerUnusedMovementData: ; unreferenced
step RIGHT
turn_head LEFT
step_end
diff --git a/maps/CeladonMansion3F.asm b/maps/CeladonMansion3F.asm
index 6012e1a7..8c818267 100644
--- a/maps/CeladonMansion3F.asm
+++ b/maps/CeladonMansion3F.asm
@@ -57,8 +57,7 @@ GameFreakGraphicArtistScript:
closetext
end
-.CancelPrinting:
-; unused
+.CancelPrinting: ; unreferenced
writetext GameFreakGraphicArtistErrorText
waitbutton
closetext
diff --git a/maps/CeladonMansionRoof.asm b/maps/CeladonMansionRoof.asm
index 3464a1f4..6630b22c 100644
--- a/maps/CeladonMansionRoof.asm
+++ b/maps/CeladonMansionRoof.asm
@@ -5,10 +5,10 @@ CeladonMansionRoof_MapScripts:
def_callbacks
-CeladonMansionRoofGraffiti:
- jumptext CeladonMansionRoofGraffitiText
+CeladonMansionRoofSign: ; unreferenced
+ jumptext CeladonMansionRoofSignText
-CeladonMansionRoofGraffitiText:
+CeladonMansionRoofSignText:
text "I KNOW EVERYTHING!"
done
diff --git a/maps/CherrygroveCity.asm b/maps/CherrygroveCity.asm
index 35546fcd..60a13914 100644
--- a/maps/CherrygroveCity.asm
+++ b/maps/CherrygroveCity.asm
@@ -317,7 +317,7 @@ CherrygroveCity_RivalPushesYouOutOfTheWay:
turn_head UP
step_end
-CherrygroveCity_UnusedMovementData:
+CherrygroveCity_UnusedMovementData: ; unreferenced
step LEFT
turn_head DOWN
step_end
diff --git a/maps/CianwoodCity.asm b/maps/CianwoodCity.asm
index 45adb946..a198c4b9 100644
--- a/maps/CianwoodCity.asm
+++ b/maps/CianwoodCity.asm
@@ -58,8 +58,7 @@ CianwoodCityPokefanM:
CianwoodCityLass:
jumptextfaceplayer CianwoodCityLassText
-CianwoodCityUnusedScript:
-; unreferenced
+CianwoodCityUnusedScript: ; unreferenced
jumptextfaceplayer CianwoodCityUnusedText
CianwoodCitySign:
@@ -172,7 +171,6 @@ CianwoodCityLassText:
done
CianwoodCityUnusedText:
-; unused
text "There are several"
line "islands between"
cont "here and OLIVINE."
diff --git a/maps/DragonsDenB1F.asm b/maps/DragonsDenB1F.asm
index a5073faf..99d65cbd 100644
--- a/maps/DragonsDenB1F.asm
+++ b/maps/DragonsDenB1F.asm
@@ -161,7 +161,7 @@ DragonShrineRisingBadgeExplanationText:
line "have this TM."
done
-NotifyReceiveDragonbreath:
+Text_ReceivedTM24: ; unreferenced
text "<PLAYER> received"
line "TM24."
done
diff --git a/maps/EarlsPokemonAcademy.asm b/maps/EarlsPokemonAcademy.asm
index fdda6324..75d5649e 100644
--- a/maps/EarlsPokemonAcademy.asm
+++ b/maps/EarlsPokemonAcademy.asm
@@ -138,8 +138,7 @@ AcademyNotebook:
closetext
end
-AcademyStickerMachine:
-; unused
+AcademyStickerMachine: ; unreferenced
jumptext AcademyStickerMachineText
AcademyBookshelf:
@@ -271,8 +270,7 @@ AcademyBlackboardText:
line "battle."
done
-AcademyBlackboardText2:
-; unused
+AcademyBlackboardText2: ; unreferenced
text "Read which topic?"
done
diff --git a/maps/EcruteakCity.asm b/maps/EcruteakCity.asm
index 33462cb6..120bef56 100644
--- a/maps/EcruteakCity.asm
+++ b/maps/EcruteakCity.asm
@@ -84,8 +84,7 @@ EcruteakCityMartSign:
EcruteakCityHiddenHyperPotion:
hiddenitem HYPER_POTION, EVENT_ECRUTEAK_CITY_HIDDEN_HYPER_POTION
-UnusedMissingDaughterText:
-; unused
+UnusedMissingDaughterText: ; unreferenced
text "Oh, no. Oh, no…"
para "My daughter is"
diff --git a/maps/ElmsHouse.asm b/maps/ElmsHouse.asm
index ec124148..836b3aef 100644
--- a/maps/ElmsHouse.asm
+++ b/maps/ElmsHouse.asm
@@ -43,15 +43,13 @@ ElmsSonText:
cont "professor!"
done
-ElmsHouseLabFoodText:
-; unused
+ElmsHouseLabFoodText: ; unreferenced
text "There's some food"
line "here. It must be"
cont "for the LAB."
done
-ElmsHousePokemonFoodText:
-; unused
+ElmsHousePokemonFoodText: ; unreferenced
text "There's some food"
line "here. This must be"
cont "for #MON."
diff --git a/maps/ElmsLab.asm b/maps/ElmsLab.asm
index 17b460dd..09fd2971 100644
--- a/maps/ElmsLab.asm
+++ b/maps/ElmsLab.asm
@@ -555,8 +555,7 @@ ElmsLabTravelTip4:
ElmsLabTrashcan:
jumptext ElmsLabTrashcanText
-ElmsLabTrashcan2:
-; unused
+ElmsLabTrashcan2: ; unreferenced
jumpstd TrashCanScript
ElmsLabBookshelf:
@@ -1064,7 +1063,7 @@ ElmGiveTicketText2:
line "PROF.OAK in KANTO!"
done
-ElmsLabSignpostText_Egg:
+ElmsLabMonEggText: ; unreferenced
text "It's the #MON"
line "EGG being studied"
cont "by PROF.ELM."
diff --git a/maps/GoldenrodBikeShop.asm b/maps/GoldenrodBikeShop.asm
index 14121e02..d788589d 100644
--- a/maps/GoldenrodBikeShop.asm
+++ b/maps/GoldenrodBikeShop.asm
@@ -39,8 +39,7 @@ GoldenrodBikeShopClerkScript:
closetext
end
-GoldenrodBikeShopJustReleasedCompactBike:
-; unused
+GoldenrodBikeShopJustReleasedCompactBike: ; unreferenced
jumptext GoldenrodBikeShopJustReleasedCompactBikeText
GoldenrodBikeShopBicycle:
diff --git a/maps/GoldenrodDeptStore2F.asm b/maps/GoldenrodDeptStore2F.asm
index 6047b790..2a0e4272 100644
--- a/maps/GoldenrodDeptStore2F.asm
+++ b/maps/GoldenrodDeptStore2F.asm
@@ -39,8 +39,7 @@ GoldenrodDeptStore2FDirectory:
GoldenrodDeptStore2FElevatorButton:
jumpstd ElevatorButtonScript
-GoldenrodDeptStore2FUnusedText1:
-; unused
+GoldenrodDeptStore2FUnusedText1: ; unreferenced
text "We intend to sell"
line "items for #MON"
cont "to hold."
@@ -50,8 +49,7 @@ GoldenrodDeptStore2FUnusedText1:
cont "MON hold it."
done
-GoldenrodDeptStore2FUnusedText2:
-; unused
+GoldenrodDeptStore2FUnusedText2: ; unreferenced
text "Giving #MON"
line "items to hold dur-"
cont "ing battle could "
diff --git a/maps/GoldenrodDeptStore5F.asm b/maps/GoldenrodDeptStore5F.asm
index f35c0af1..b7b1ea1c 100644
--- a/maps/GoldenrodDeptStore5F.asm
+++ b/maps/GoldenrodDeptStore5F.asm
@@ -105,7 +105,7 @@ Carrie:
faceplayer
opentext
special GameboyCheck
- ifnotequal GBCHECK_CGB, .NotGBC ; This is a dummy check from Gold/Silver
+ ifnotequal GBCHECK_CGB, .NotGBC
writetext GoldenrodDeptStore5FCarrieMysteryGiftExplanationText
waitbutton
closetext
diff --git a/maps/GoldenrodFlowerShop.asm b/maps/GoldenrodFlowerShop.asm
index 4d54b95d..50033e2c 100644
--- a/maps/GoldenrodFlowerShop.asm
+++ b/maps/GoldenrodFlowerShop.asm
@@ -44,16 +44,13 @@ FlowerShopFloriaScript:
closetext
end
-FlowerShopShelf1:
-; unused
+FlowerShopShelf1: ; unreferenced
jumpstd PictureBookshelfScript
-FlowerShopShelf2:
-; unused
+FlowerShopShelf2: ; unreferenced
jumpstd MagazineBookshelfScript
-FlowerShopRadio:
-; unused
+FlowerShopRadio: ; unreferenced
jumpstd Radio2Script
GoldenrodFlowerShopTeacherBetterThanWhitneyText:
diff --git a/maps/GoldenrodUnderground.asm b/maps/GoldenrodUnderground.asm
index 44980aa9..b4ce3b18 100644
--- a/maps/GoldenrodUnderground.asm
+++ b/maps/GoldenrodUnderground.asm
@@ -58,7 +58,7 @@ GoldenrodUnderground_MapScripts:
ifequal FRIDAY, .Friday
ifequal SATURDAY, .Saturday
-.Sunday:
+; Sunday
disappear GOLDENRODUNDERGROUND_GRAMPS
disappear GOLDENRODUNDERGROUND_OLDER_HAIRCUT_BROTHER
appear GOLDENRODUNDERGROUND_YOUNGER_HAIRCUT_BROTHER
diff --git a/maps/IlexForest.asm b/maps/IlexForest.asm
index 33054d05..6eceac57 100644
--- a/maps/IlexForest.asm
+++ b/maps/IlexForest.asm
@@ -297,8 +297,7 @@ IlexForestHiddenSuperPotion:
IlexForestHiddenFullHeal:
hiddenitem FULL_HEAL, EVENT_ILEX_FOREST_HIDDEN_FULL_HEAL
-IlexForestBoulder:
-; unused
+IlexForestBoulder: ; unreferenced
jumpstd StrengthBoulderScript
IlexForestSignpost:
diff --git a/maps/KurtsHouse.asm b/maps/KurtsHouse.asm
index 98dc2eaf..793fb081 100644
--- a/maps/KurtsHouse.asm
+++ b/maps/KurtsHouse.asm
@@ -85,7 +85,6 @@ Kurt1:
iftrue .GiveLoveBall
writetext KurtsHouseKurtBallsFromApricornsText
promptbutton
-.CheckApricorns:
checkitem RED_APRICORN
iftrue .AskApricorn
checkitem BLU_APRICORN
diff --git a/maps/LakeOfRageMagikarpHouse.asm b/maps/LakeOfRageMagikarpHouse.asm
index c827872e..abd9fe53 100644
--- a/maps/LakeOfRageMagikarpHouse.asm
+++ b/maps/LakeOfRageMagikarpHouse.asm
@@ -83,8 +83,7 @@ MagikarpLengthRaterScript:
closetext
end
-LakeOfRageMagikarpHouseUnusedRecordSign:
-; unused
+LakeOfRageMagikarpHouseUnusedRecordSign: ; unreferenced
jumptext LakeOfRageMagikarpHouseUnusedRecordText
MagikarpHouseBookshelf:
@@ -205,7 +204,8 @@ LakeOfRageMagikarpHouseUnusedRecordText:
text_ram wStringBuffer4
text_end
- text_end ; unused
+LakeOfRageMagikarpHouseUnusedDummyText: ; unreferenced
+ text_end
LakeOfRageMagikarpHouse_MapEvents:
db 0, 0 ; filler
diff --git a/maps/LavRadioTower1F.asm b/maps/LavRadioTower1F.asm
index 4cd54e6f..e1430ad0 100644
--- a/maps/LavRadioTower1F.asm
+++ b/maps/LavRadioTower1F.asm
@@ -72,8 +72,7 @@ LavRadioTower1FDirectory:
LavRadioTower1FPokeFluteSign:
jumptext LavRadioTower1FPokeFluteSignText
-LavRadioTower1FReferenceLibrary:
-; unreferenced
+LavRadioTower1FReferenceLibrary: ; unreferenced
jumptext LavRadioTower1FReferenceLibraryText
LavRadioTower1FReceptionistText:
diff --git a/maps/LavenderNameRater.asm b/maps/LavenderNameRater.asm
index 2809d315..02bb67ee 100644
--- a/maps/LavenderNameRater.asm
+++ b/maps/LavenderNameRater.asm
@@ -18,8 +18,7 @@ LavenderNameRater:
closetext
end
-LavenderNameRaterUnusedBookshelf:
-; unused
+LavenderNameRaterUnusedBookshelf: ; unreferenced
jumpstd DifficultBookshelfScript
LavenderNameRater_MapEvents:
diff --git a/maps/MahoganyRedGyaradosSpeechHouse.asm b/maps/MahoganyRedGyaradosSpeechHouse.asm
index 78ddf6ce..0fdce56c 100644
--- a/maps/MahoganyRedGyaradosSpeechHouse.asm
+++ b/maps/MahoganyRedGyaradosSpeechHouse.asm
@@ -26,12 +26,10 @@ MahoganyRedGyaradosSpeechHouseTeacherScript:
closetext
end
-MahoganyRedGyaradosSpeechHouseUnusedBookshelf1:
-; unused
+MahoganyRedGyaradosSpeechHouseUnusedBookshelf1: ; unreferenced
jumpstd PictureBookshelfScript
-MahoganyRedGyaradosSpeechHouseUnusedBookshelf2:
-; unused
+MahoganyRedGyaradosSpeechHouseUnusedBookshelf2: ; unreferenced
jumpstd MagazineBookshelfScript
MahoganyRedGyaradosSpeechHouseBlackBeltText:
diff --git a/maps/ManiasHouse.asm b/maps/ManiasHouse.asm
index 7d8cfee4..bb6b97c9 100644
--- a/maps/ManiasHouse.asm
+++ b/maps/ManiasHouse.asm
@@ -83,7 +83,7 @@ ManiaScript:
closetext
end
-.nothingleft
+.nothingleft ; unreferenced
writetext ManiaText_ShuckleIsYourLastMon
waitbutton
closetext
@@ -95,8 +95,7 @@ ManiaScript:
closetext
end
-ManiasHouseUnusedBookshelf:
-; unused
+ManiasHouseUnusedBookshelf: ; unreferenced
jumpstd PictureBookshelfScript
ManiaText_AskLookAfterShuckle:
diff --git a/maps/NewBarkTown.asm b/maps/NewBarkTown.asm
index 37099708..95d410ef 100644
--- a/maps/NewBarkTown.asm
+++ b/maps/NewBarkTown.asm
@@ -137,7 +137,7 @@ NewBarkTownElmsLabSign:
NewBarkTownElmsHouseSign:
jumptext NewBarkTownElmsHouseSignText
-MrChronoScript:
+MrChronoScript: ; unreferenced
faceplayer
opentext
writetext MrChronoText
diff --git a/maps/OaksLab.asm b/maps/OaksLab.asm
index 492d9eb1..cbb43d08 100644
--- a/maps/OaksLab.asm
+++ b/maps/OaksLab.asm
@@ -9,7 +9,7 @@ OaksLab_MapScripts:
def_callbacks
-.DummyScene:
+.DummyScene: ; unreferenced
end
Oak:
diff --git a/maps/OlivineGoodRodHouse.asm b/maps/OlivineGoodRodHouse.asm
index 8c128992..fde165b4 100644
--- a/maps/OlivineGoodRodHouse.asm
+++ b/maps/OlivineGoodRodHouse.asm
@@ -35,8 +35,7 @@ GoodRodGuru:
closetext
end
-GoodRodHouseBookshelf:
-; unused
+GoodRodHouseBookshelf: ; unreferenced
jumpstd PictureBookshelfScript
OfferGoodRodText:
diff --git a/maps/OlivineGym.asm b/maps/OlivineGym.asm
index 27bb6100..2b59ca1c 100644
--- a/maps/OlivineGym.asm
+++ b/maps/OlivineGym.asm
@@ -145,7 +145,7 @@ Jasmine_BadgeSpeech:
line "this too…"
done
-Text_ReceivedTM09:
+Text_ReceivedTM09: ; unreferenced
text "<PLAYER> received"
line "TM09."
done
diff --git a/maps/OlivineLighthouse6F.asm b/maps/OlivineLighthouse6F.asm
index ad99fb99..6f9e43dd 100644
--- a/maps/OlivineLighthouse6F.asm
+++ b/maps/OlivineLighthouse6F.asm
@@ -27,7 +27,7 @@ OlivineLighthouseJasmine:
.BroughtSecretpotion:
writetext JasmineCureAmphyText
yesorno
- iffalse .no
+ iffalse .Refused
writetext PlayerHandedSecretpotionText
promptbutton
takeitem SECRETPOTION
@@ -84,7 +84,7 @@ OlivineLighthouseJasmine:
disappear OLIVINELIGHTHOUSE6F_JASMINE
end
-.no:
+.Refused:
writetext JasmineISeeText
waitbutton
closetext
@@ -97,8 +97,7 @@ OlivineLighthouseJasmine:
closetext
end
-OlivineLighthouseUnusedDummyScript:
-; unused
+.Unused: ; unreferenced
end
OlivineLighthouseAmphy:
diff --git a/maps/PlayersHouse2F.asm b/maps/PlayersHouse2F.asm
index 16be3544..30e9ef51 100644
--- a/maps/PlayersHouse2F.asm
+++ b/maps/PlayersHouse2F.asm
@@ -11,8 +11,7 @@ PlayersHouse2F_MapScripts:
callback MAPCALLBACK_NEWMAP, .InitializeRoom
callback MAPCALLBACK_TILES, .SetUpTileDecorations
-; unused
-.Null:
+.DummyScene: ; unreferenced
end
.InitializeRoom:
diff --git a/maps/Pokecenter2F.asm b/maps/Pokecenter2F.asm
index b4178834..545d72a2 100644
--- a/maps/Pokecenter2F.asm
+++ b/maps/Pokecenter2F.asm
@@ -80,7 +80,7 @@ LinkReceptionistScript_Trade:
iffalse .LinkedToFirstGen
special CheckBothSelectedSameRoom
iffalse .IncompatibleRooms
- writetext Text_PleaseComeIn2
+ writetext Text_PleaseComeIn
waitbutton
closetext
applymovementlasttalked Pokecenter2FMovementData_ReceptionistWalksUpAndLeft_LookRight
@@ -141,7 +141,7 @@ LinkReceptionistScript_Battle:
iffalse .LinkedToFirstGen
special CheckBothSelectedSameRoom
iffalse .IncompatibleRooms
- writetext Text_PleaseComeIn2
+ writetext Text_PleaseComeIn
waitbutton
closetext
applymovementlasttalked Pokecenter2FMovementData_ReceptionistWalksUpAndLeft_LookRight
@@ -223,7 +223,7 @@ LinkReceptionistScript_TimeCapsule:
.OK:
special EnterTimeCapsule
- writetext Text_PleaseComeIn2
+ writetext Text_PleaseComeIn
waitbutton
closetext
readvar VAR_FACING
@@ -469,11 +469,11 @@ Text_PleaseComeAgain:
text "Please come again."
prompt
-Text_PleaseComeIn:
+Text_PleaseComeInDuplicate: ; unreferenced
text "Please come in."
prompt
-Text_TemporaryStagingInLinkRoom:
+Text_TemporaryStagingInLinkRoom: ; unreferenced
text "We'll put you in"
line "the link room for"
cont "the time being."
@@ -489,11 +489,11 @@ Text_IncompatibleRooms:
line "a different room."
prompt
-Text_PleaseComeIn2:
+Text_PleaseComeIn:
text "Please come in."
done
-Text_PleaseEnter:
+Text_PleaseEnter: ; unreferenced
text "Please enter."
prompt
diff --git a/maps/RadioTower2F.asm b/maps/RadioTower2F.asm
index 1f27519b..1923d535 100644
--- a/maps/RadioTower2F.asm
+++ b/maps/RadioTower2F.asm
@@ -14,8 +14,7 @@ RadioTower2F_MapScripts:
def_callbacks
-RadioTower2FUnusedDummyScene:
-; unused
+RadioTower2FUnusedDummyScene: ; unreferenced
end
RadioTower2FSuperNerdScript:
diff --git a/maps/Route12SuperRodHouse.asm b/maps/Route12SuperRodHouse.asm
index cef05c18..10cb41ce 100644
--- a/maps/Route12SuperRodHouse.asm
+++ b/maps/Route12SuperRodHouse.asm
@@ -32,8 +32,7 @@ Route12SuperRodHouseFishingGuruScript:
closetext
end
-SuperRodHouseBookshelf:
-; unused
+SuperRodHouseBookshelf: ; unreferenced
jumpstd PictureBookshelfScript
OfferSuperRodText:
diff --git a/maps/Route25.asm b/maps/Route25.asm
index a20cb3f2..4ddb215f 100644
--- a/maps/Route25.asm
+++ b/maps/Route25.asm
@@ -423,7 +423,7 @@ BillsHouseSignText:
line "BILL'S HOUSE"
done
-; unused
+UnusedBillsHouseSignText: ; unreferenced
text "BILL'S HOUSE"
done
diff --git a/maps/Route29.asm b/maps/Route29.asm
index 4b8d6bb1..3009c4b6 100644
--- a/maps/Route29.asm
+++ b/maps/Route29.asm
@@ -322,8 +322,7 @@ Route29FisherText:
line "progress."
done
-; unused
-Text_WaitingForDay:
+Route29CooltrainerMText_WaitingForDay: ; unreferenced
text "I'm waiting for"
line "#MON that"
diff --git a/maps/Route2NuggetHouse.asm b/maps/Route2NuggetHouse.asm
index 147d72d6..93e8fbeb 100644
--- a/maps/Route2NuggetHouse.asm
+++ b/maps/Route2NuggetHouse.asm
@@ -23,8 +23,7 @@ Route2NuggetHouseFisherScript:
closetext
end
-Route2NuggetHouseBookshelf:
-; unused
+Route2NuggetHouseBookshelf: ; unreferenced
jumpstd DifficultBookshelfScript
Route2NuggetHouseFisherText:
diff --git a/maps/Route32.asm b/maps/Route32.asm
index 40ae7860..2141c593 100644
--- a/maps/Route32.asm
+++ b/maps/Route32.asm
@@ -466,7 +466,6 @@ Route32CooltrainerMText_AideIsWaiting:
done
Route32CooltrainerMText_UnusedSproutTower:
-; unused
text "Have you gone to"
line "SPROUT TOWER?"
@@ -589,9 +588,7 @@ FisherRalphAfterText:
line "long friends!"
done
-; --- start a segment of unused text
-
-Route32UnusedFisher1SeenText:
+Route32UnusedFisher1SeenText: ; unreferenced
text "I keep catching"
line "the same #MON…"
@@ -600,29 +597,29 @@ Route32UnusedFisher1SeenText:
cont "around for me."
done
-Route32UnusedFisher1BeatenText:
+Route32UnusedFisher1BeatenText: ; unreferenced
text "Nothing ever goes"
line "right for me now…"
done
-Route32UnusedFisher1AfterText:
+Route32UnusedFisher1AfterText: ; unreferenced
text "How come the guy"
line "next to me catches"
cont "good #MON?"
done
-Route32UnusedFisher2SeenText:
+Route32UnusedFisher2SeenText: ; unreferenced
text "Heh, I'm on a roll"
line "today. How about a"
cont "battle, kid?"
done
-Route32UnusedFisher2BeatenText:
+Route32UnusedFisher2BeatenText: ; unreferenced
text "Oof. I wasn't"
line "lucky that time."
done
-Route32UnusedFisher2AfterText:
+Route32UnusedFisher2AfterText: ; unreferenced
text "You have to have a"
line "good ROD if you"
@@ -630,8 +627,6 @@ Route32UnusedFisher2AfterText:
line "#MON."
done
-; --- end a segment of unused texts
-
FisherHenrySeenText:
text "My #MON?"
line "Freshly caught!"
@@ -745,8 +740,7 @@ BirdKeeperPeterAfterText:
cont "in VIOLET CITY."
done
-Route32UnusedText:
-; unused
+Route32UnusedText: ; unreferenced
text "The fishermen"
line "yelled at me for"
cont "bugging them…"
diff --git a/maps/Route34.asm b/maps/Route34.asm
index a0496422..747ff561 100644
--- a/maps/Route34.asm
+++ b/maps/Route34.asm
@@ -372,8 +372,7 @@ TrainerCooltrainerfKate:
closetext
end
-Route34IlexForestSign:
-; unused
+Route34IlexForestSign: ; unreferenced
jumptext Route34IlexForestSignText
Route34Sign:
@@ -604,7 +603,6 @@ CooltrainerfKateAfterText:
done
Route34IlexForestSignText:
-; unused
text "ILEX FOREST"
line "Through the Gate"
done
diff --git a/maps/Route36.asm b/maps/Route36.asm
index 7f60bb72..9884cd50 100644
--- a/maps/Route36.asm
+++ b/maps/Route36.asm
@@ -307,7 +307,7 @@ RockSmashGuyText2:
cont "have this."
done
-UnusedReceivedTM08Text:
+Text_ReceivedTM08: ; unreferenced
text "<PLAYER> received"
line "TM08."
done
diff --git a/maps/Route36NationalParkGate.asm b/maps/Route36NationalParkGate.asm
index 93361f13..6d17da10 100644
--- a/maps/Route36NationalParkGate.asm
+++ b/maps/Route36NationalParkGate.asm
@@ -463,7 +463,7 @@ BugCatchingContestant10BScript:
closetext
end
-UnusedBugCatchingContestExplanationSign:
+UnusedBugCatchingContestExplanationSign: ; unreferenced
; duplicate of BugCatchingContestExplanationSign in Route35NationalParkGate.asm
jumptext UnusedBugCatchingContestExplanationText
@@ -795,10 +795,9 @@ BugCatchingContestant10BStillCompetingText:
line "win."
done
-UnusedSudowoodoText:
-; This text is unused and unreferenced in the final game.
-; The tree Pokémon is Sudowoodo.
-; The Silph Scope 2 was later reworked into the Squirtbottle.
+UnusedSilphScope2Text: ; unreferenced
+; This text is referring to Sudowoodo.
+; The SILPHSCOPE2 was later reworked into the SQUIRTBOTTLE.
text "I hear there's a"
line "#MON that looks"
cont "just like a tree."
diff --git a/maps/Route39Farmhouse.asm b/maps/Route39Farmhouse.asm
index 0d11179b..5765fdbd 100644
--- a/maps/Route39Farmhouse.asm
+++ b/maps/Route39Farmhouse.asm
@@ -172,7 +172,7 @@ FarmerFText_HealedMiltank:
line "fer your trouble."
done
-Text_ReceivedTM13:
+Text_ReceivedTM13: ; unreferenced
text "<PLAYER> received"
line "TM13."
done
diff --git a/maps/Route41.asm b/maps/Route41.asm
index 8272b93a..1c446ad1 100644
--- a/maps/Route41.asm
+++ b/maps/Route41.asm
@@ -125,8 +125,7 @@ TrainerSwimmermMathew:
closetext
end
-Route41Rock:
-; unused
+Route41Rock: ; unreferenced
jumpstd SmashRockScript
Route41HiddenMaxEther:
diff --git a/maps/Route43Gate.asm b/maps/Route43Gate.asm
index 9c4499ca..65e7f3ea 100644
--- a/maps/Route43Gate.asm
+++ b/maps/Route43Gate.asm
@@ -233,7 +233,7 @@ OfficerText_FoundTM:
cont "you take it away?"
done
-Text_ReceivedTM30:
+Text_ReceivedTM30: ; unreferenced
text "<PLAYER> received"
line "TM30."
done
diff --git a/maps/Route45.asm b/maps/Route45.asm
index 6a077e90..9da24312 100644
--- a/maps/Route45.asm
+++ b/maps/Route45.asm
@@ -386,7 +386,7 @@ CooltrainerfKellyAfterBattleText:
cont "to harm #MON."
done
-Route45DummyText:
+Route45DummyText: ; unreferenced
text "I'm pretty good at"
line "#MON too."
done
diff --git a/maps/RuinsOfAlphOutside.asm b/maps/RuinsOfAlphOutside.asm
index 3b74ee26..cf26ca46 100644
--- a/maps/RuinsOfAlphOutside.asm
+++ b/maps/RuinsOfAlphOutside.asm
@@ -79,7 +79,7 @@ TrainerPsychicNathan:
closetext
end
-TrainerSuperNerdStan:
+TrainerSuperNerdStan: ; unreferenced
trainer SUPER_NERD, STAN, EVENT_BEAT_SUPER_NERD_STAN, SuperNerdStanSeenText, SuperNerdStanBeatenText, 0, .Script
.Script:
diff --git a/maps/RuinsOfAlphResearchCenter.asm b/maps/RuinsOfAlphResearchCenter.asm
index de7e2c83..a29c9d3b 100644
--- a/maps/RuinsOfAlphResearchCenter.asm
+++ b/maps/RuinsOfAlphResearchCenter.asm
@@ -150,8 +150,7 @@ RuinsOfAlphResearchCenterPrinter:
closetext
end
-RuinsOfAlphResearchCenterPhoto:
-; unreferenced
+RuinsOfAlphResearchCenterPhoto: ; unreferenced
jumptext RuinsOfAlphResearchCenterProfSilktreePhotoText
RuinsOfAlphResearchCenterBookshelf:
@@ -302,7 +301,6 @@ RuinsOfAlphResearchCenterUnownPrinterText:
done
RuinsOfAlphResearchCenterProfSilktreePhotoText:
-; unused
text "It's a photo of"
line "the RESEARCH"
diff --git a/maps/TeamRocketBaseB2F.asm b/maps/TeamRocketBaseB2F.asm
index c5de430a..3f7e2eef 100644
--- a/maps/TeamRocketBaseB2F.asm
+++ b/maps/TeamRocketBaseB2F.asm
@@ -730,7 +730,7 @@ RocketBaseLanceElectrodeDoneText:
cont "any need for it."
done
-RocketBaseReceivedHM06Text: ; unused
+RocketBaseReceivedHM06Text: ; unreferenced
text "<PLAYER> received"
line "HM06."
done
diff --git a/maps/TinTower9F.asm b/maps/TinTower9F.asm
index 3685200b..803a65fd 100644
--- a/maps/TinTower9F.asm
+++ b/maps/TinTower9F.asm
@@ -3,13 +3,11 @@ TinTower9F_MapScripts:
def_callbacks
-TinTower9FUnusedHoOhText:
-; unused
+TinTower9FUnusedHoOhText: ; unreferenced
text "HO-OH: Shaoooh!"
done
-TinTower9FUnusedLugiaText:
-; unused
+TinTower9FUnusedLugiaText: ; unreferenced
text "LUGIA: Gyaaan!"
done
diff --git a/maps/TradeCenter.asm b/maps/TradeCenter.asm
index 2282d9d5..40405518 100644
--- a/maps/TradeCenter.asm
+++ b/maps/TradeCenter.asm
@@ -39,15 +39,14 @@ TradeCenterConsoleScript:
newloadmap MAPSETUP_LINKRETURN
end
-TradeCenterFriendScript:
-; unreferenced
+TradeCenterFriendScript: ; unreferenced
opentext
- writetext .FriendReadyText
+ writetext TradeCenterFriendReadyText
waitbutton
closetext
end
-.FriendReadyText:
+TradeCenterFriendReadyText:
text "Your friend is"
line "ready."
done
diff --git a/maps/UnionCave1F.asm b/maps/UnionCave1F.asm
index 84883678..5a79ff3b 100644
--- a/maps/UnionCave1F.asm
+++ b/maps/UnionCave1F.asm
@@ -81,8 +81,7 @@ UnionCave1FXAttack:
UnionCave1FAwakening:
itemball AWAKENING
-UnionCave1FUnusedSign:
-; unused
+UnionCave1FUnusedSign: ; unreferenced
jumptext UnionCave1FUnusedSignText
HikerRussellSeenText:
diff --git a/maps/VermilionFishingSpeechHouse.asm b/maps/VermilionFishingSpeechHouse.asm
index c855b636..377ac53f 100644
--- a/maps/VermilionFishingSpeechHouse.asm
+++ b/maps/VermilionFishingSpeechHouse.asm
@@ -12,8 +12,7 @@ FishingDude:
FishingDudesHousePhoto:
jumptext FishingDudesHousePhotoText
-FishingDudesHouseBookshelf:
-; unused
+FishingDudesHouseBookshelf: ; unreferenced
jumpstd PictureBookshelfScript
FishingDudeText:
diff --git a/sram.asm b/sram.asm
index b9354382..3651798a 100644
--- a/sram.asm
+++ b/sram.asm
@@ -1,14 +1,13 @@
SECTION "Scratch", SRAM
-sScratch::
-
UNION
-sDecompressScratch:: ds $188
-sDecompressBuffer:: ds 7 * 7 tiles
+sScratch::
+sDecompressScratch::
+ ds $60 tiles
NEXTU
-sScratchTilemap:: ds BG_MAP_WIDTH * BG_MAP_HEIGHT
-sScratchAttrmap:: ds $200
+ ds $188
+sDecompressBuffer:: ds 7 * 7 tiles
ENDU
@@ -31,7 +30,7 @@ sPartyMon5MailBackup:: mailmsg sPartyMon5MailBackup
sPartyMon6MailBackup:: mailmsg sPartyMon6MailBackup
sMailboxCount:: db
-sMailbox::
+sMailboxes::
sMailbox1:: mailmsg sMailbox1
sMailbox2:: mailmsg sMailbox2
sMailbox3:: mailmsg sMailbox3
@@ -44,7 +43,7 @@ sMailbox9:: mailmsg sMailbox9
sMailbox10:: mailmsg sMailbox10
sMailboxCountBackup:: db
-sMailboxBackup::
+sMailboxesBackup::
sMailbox1Backup:: mailmsg sMailbox1Backup
sMailbox2Backup:: mailmsg sMailbox2Backup
sMailbox3Backup:: mailmsg sMailbox3Backup
@@ -56,20 +55,20 @@ sMailbox8Backup:: mailmsg sMailbox8Backup
sMailbox9Backup:: mailmsg sMailbox9Backup
sMailbox10Backup:: mailmsg sMailbox10Backup
+sMysteryGiftData::
sMysteryGiftItem:: db
sMysteryGiftUnlocked:: db
sBackupMysteryGiftItem:: db
sNumDailyMysteryGiftPartnerIDs:: db
-sDailyMysteryGiftPartnerIDs:: ds 5 * 2 ; maximum 5 per day, 2 bytes per ID
+sDailyMysteryGiftPartnerIDs:: ds MAX_MYSTERY_GIFT_PARTNERS * 2
sMysteryGiftDecorationsReceived:: flag_array NUM_NON_TROPHY_DECOS
ds 4
-sMysteryGiftTimer:: db
-sMysteryGiftTimerStartDay:: db
+sMysteryGiftTimer:: dw
ds 1
sMysteryGiftTrainerHouseFlag:: db
sMysteryGiftPartnerName:: ds NAME_LENGTH
- ds 1
-sMysteryGiftTrainer:: ds (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 2
+sMysteryGiftUnusedFlag:: db
+sMysteryGiftTrainer:: ds wMysteryGiftTrainerEnd - wMysteryGiftTrainer
sBackupMysteryGiftItemEnd::
ds $30
@@ -96,7 +95,6 @@ SECTION "SRAM Window Stack", SRAM
sWindowStackBottom::
ds $800 - 1
-sWindowStack::
sWindowStackTop::
ds 1
diff --git a/wram.asm b/wram.asm
index 9fef28a1..94ce297d 100644
--- a/wram.asm
+++ b/wram.asm
@@ -8,18 +8,16 @@ INCLUDE "vram.asm"
SECTION "Audio RAM", WRAM0
-wMusic::
-
; nonzero if playing
wMusicPlaying:: db
-wChannels::
+wAudio::
+
wChannel1:: channel_struct wChannel1
wChannel2:: channel_struct wChannel2
wChannel3:: channel_struct wChannel3
wChannel4:: channel_struct wChannel4
-wSFXChannels::
wChannel5:: channel_struct wChannel5
wChannel6:: channel_struct wChannel6
wChannel7:: channel_struct wChannel7
@@ -109,12 +107,12 @@ wSFXDuration:: db
wCurSFX::
; id of sfx currently playing
db
-wChannelsEnd::
+
+wAudioEnd::
wMapMusic:: db
wDontPlayMapMusicOnReload:: db
-wMusicEnd::
SECTION "WRAM", WRAM0
@@ -301,7 +299,7 @@ wHallOfFameTemp:: hall_of_fame wHallOfFameTemp
NEXTU
; link engine data
-wLink_c508:: ds 10
+wc508:: ds 10
wc512:: ds 10
NEXTU
@@ -321,10 +319,6 @@ wDebugWhiteTileColor:: ds 2
wDebugLightTileColor:: ds 2
wDebugDarkTileColor:: ds 2
wDebugBlackTileColor:: ds 2
-
-NEXTU
-; dummy game
-wc508:: dw
ENDU
; This union spans 280 bytes.
@@ -362,7 +356,7 @@ NEXTU
wPokegearPhoneLoadNameBuffer:: db
wPokegearPhoneCursorPosition:: db
wPokegearPhoneScrollPosition:: db
-wPokegearPhoneSelectedPerson:: db ; cd3
+wPokegearPhoneSelectedPerson:: db
wPokegearPhoneSubmenuCursor:: db
wPokegearMapCursorObjectPointer:: dw
wPokegearMapCursorLandmark:: db
@@ -376,7 +370,6 @@ NEXTU
wTrademons::
wPlayerTrademon:: trademon wPlayerTrademon
wOTTrademon:: trademon wOTTrademon
-wTrademonsEnd::
wTradeAnimAddress:: dw
wLinkPlayer1Name:: ds NAME_LENGTH
wLinkPlayer2Name:: ds NAME_LENGTH
@@ -419,18 +412,15 @@ wSlotsEnd::
NEXTU
; card flip
-wCardFlip::
-wDeck:: ds 24
+wDeck:: ds 4 * 6
wDeckEnd::
wCardFlipNumCardsPlayed:: db
wCardFlipFaceUpCard:: db
-wDiscardPile:: ds 24
+wDiscardPile:: ds 4 * 6
wDiscardPileEnd::
-wCardFlipEnd::
NEXTU
; dummy game
-wDummyGame::
wDummyGameCards:: ds 9 * 5
wDummyGameCardsEnd::
wDummyGameLastCardPicked:: db
@@ -442,7 +432,6 @@ wDummyGameNumberTriesRemaining:: db
wDummyGameLastMatches:: ds 5
wDummyGameCounter:: db
wDummyGameNumCardsMatched:: db
-wDummyGameEnd::
NEXTU
; beta poker game
@@ -474,16 +463,11 @@ NEXTU
wDecompressScratch:: ds 40 tiles
NEXTU
-; GB Printer screen RAM
-wGameboyPrinterRAM::
-wGameboyPrinterScreen:: ds SCREEN_HEIGHT * SCREEN_WIDTH
-wGameboyPrinterScreenEnd::
-
-NEXTU
; GB Printer data
+wGameboyPrinterRAM::
wGameboyPrinter2bppSource:: ds 40 tiles
wGameboyPrinter2bppSourceEnd::
-wc980:: db
+wUnusedGameboyPrinterSafeCancelFlag:: db
wPrinterRowIndex:: db
; Printer data
@@ -504,7 +488,6 @@ wPrinterSendByteCounter:: dw
; tilemap backup?
wPrinterTilemapBuffer:: ds SCREEN_HEIGHT * SCREEN_WIDTH
-wPrinterTilemapBufferEnd::
wPrinterStatus:: db
ds 1
; High nibble is for margin before the image, low nibble is for after.
@@ -570,7 +553,6 @@ wTimeCapsulePartyMon5:: red_party_struct wTimeCapsulePartyMon5
wTimeCapsulePartyMon6:: red_party_struct wTimeCapsulePartyMon6
wTimeCapsulePartyMonOTNames:: ds PARTY_LENGTH * NAME_LENGTH
wTimeCapsulePartyMonNicks:: ds PARTY_LENGTH * MON_NAME_LENGTH
-wTimeCapsulePlayerDataEnd::
NEXTU
; link player data
@@ -583,25 +565,19 @@ wLinkPlayerPartyMon5:: party_struct wLinkPlayerPartyMon5
wLinkPlayerPartyMon6:: party_struct wLinkPlayerPartyMon6
wLinkPlayerPartyMonOTNames:: ds PARTY_LENGTH * NAME_LENGTH
wLinkPlayerPartyMonNicks:: ds PARTY_LENGTH * MON_NAME_LENGTH
-wLinkPlayerDataEnd::
ENDU
NEXTU
; mystery gift data
-UNION
-wMysteryGiftPartyTemp:: ds (1 + 1 + NUM_MOVES) * PARTY_LENGTH
-
-NEXTU
wMysteryGiftStaging:: ds 80
-ENDU
-wMysteryGiftTrainerData:: ds (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 2
-wMysteryGiftTrainerDataEnd::
+wMysteryGiftTrainer:: ds 1 + (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 1
+wMysteryGiftTrainerEnd::
ds 138
wMysteryGiftPartnerData::
-wc800:: db
+wMysteryGiftGameVersion:: db
wMysteryGiftPartnerID:: dw
wMysteryGiftPartnerName:: ds NAME_LENGTH
wMysteryGiftPartnerDexCaught:: db
@@ -655,9 +631,9 @@ wCreditsBlankFrame2bppEnd::
NEXTU
; mystery gift data
-wc900:: db
-wc901:: db
-wc902:: db
+wUnusedMysteryGiftStagedDataLength:: db
+wMysteryGiftMessageCount:: db
+wMysteryGiftStagedDataLength:: db
NEXTU
; link
@@ -687,7 +663,6 @@ wAnimObject07:: battle_anim_struct wAnimObject07
wAnimObject08:: battle_anim_struct wAnimObject08
wAnimObject09:: battle_anim_struct wAnimObject09
wAnimObject10:: battle_anim_struct wAnimObject10
-wActiveAnimObjectsEnd::
wActiveBGEffects::
wBGEffect1:: battle_bg_effect wBGEffect1
@@ -695,7 +670,6 @@ wBGEffect2:: battle_bg_effect wBGEffect2
wBGEffect3:: battle_bg_effect wBGEffect3
wBGEffect4:: battle_bg_effect wBGEffect4
wBGEffect5:: battle_bg_effect wBGEffect5
-wActiveBGEffectsEnd::
wLastAnimObjectIndex:: db
@@ -772,9 +746,7 @@ ENDU
wEnemyTrainerItem1:: db
wEnemyTrainerItem2:: db
wEnemyTrainerBaseReward:: db
-
- ds 3
-
+wEnemyTrainerAIFlags:: ds 3
wOTClassName:: ds TRAINER_CLASS_NAME_LENGTH
wCurOTMon:: db
@@ -804,71 +776,17 @@ wAttackMissed::
; nonzero for a miss
db
-wPlayerSubStatus1::
-; bit
-; 0 nightmare
-; 1 curse
-; 2 protect
-; 3 identified
-; 4 perish song
-; 5 endure
-; 6 rollout
-; 7 in love
- db
-wPlayerSubStatus2::
-; bit
-; 0 curled
-; 1-7 unused
- db
-wPlayerSubStatus3::
-; bit
-; 0 bide
-; 1 rampage
-; 2 in loop
-; 3 flinched
-; 4 charged
-; 5 underground
-; 6 flying
-; 7 confused
- db
-wPlayerSubStatus4::
-; bit
-; 0 x accuracy
-; 1 mist
-; 2 focus energy
-; 3
-; 4 substitute
-; 5 recharge
-; 6 rage
-; 7 leech seed
- db
-wPlayerSubStatus5::
-; bit
-; 0 toxic
-; 1
-; 2
-; 3 transformed
-; 4 encored
-; 5 lock-on
-; 6 destiny bond
-; 7 can't run
- db
+wPlayerSubStatus1:: db
+wPlayerSubStatus2:: db
+wPlayerSubStatus3:: db
+wPlayerSubStatus4:: db
+wPlayerSubStatus5:: db
-wEnemySubStatus1::
-; see wPlayerSubStatus1
- db
-wEnemySubStatus2::
-; see wPlayerSubStatus2
- db
-wEnemySubStatus3::
-; see wPlayerSubStatus3
- db
-wEnemySubStatus4::
-; see wPlayerSubStatus4
- db
-wEnemySubStatus5::
-; see wPlayerSubStatus5
- db
+wEnemySubStatus1:: db
+wEnemySubStatus2:: db
+wEnemySubStatus3:: db
+wEnemySubStatus4:: db
+wEnemySubStatus5:: db
wPlayerRolloutCount:: db
wPlayerConfuseCount:: db
@@ -889,7 +807,7 @@ wEnemyFuryCutterCount:: db
wEnemyProtectCount:: db
wPlayerDamageTaken:: dw
-wEnemyDamageTaken:: dw
+wEnemyDamageTaken:: dw
wBattleReward:: ds 3
@@ -903,56 +821,53 @@ wTurnEnded:: db
ds 1
wPlayerStats::
-wPlayerAttack:: dw
+wPlayerAttack:: dw
wPlayerDefense:: dw
-wPlayerSpeed:: dw
-wPlayerSpAtk:: dw
-wPlayerSpDef:: dw
+wPlayerSpeed:: dw
+wPlayerSpAtk:: dw
+wPlayerSpDef:: dw
ds 1
wEnemyStats::
-wEnemyAttack:: dw
+wEnemyAttack:: dw
wEnemyDefense:: dw
-wEnemySpeed:: dw
-wEnemySpAtk:: dw
-wEnemySpDef:: dw
+wEnemySpeed:: dw
+wEnemySpAtk:: dw
+wEnemySpDef:: dw
ds 1
wPlayerStatLevels::
-; 07 neutral
-wPlayerAtkLevel:: db
-wPlayerDefLevel:: db
-wPlayerSpdLevel:: db
+wPlayerAtkLevel:: db
+wPlayerDefLevel:: db
+wPlayerSpdLevel:: db
wPlayerSAtkLevel:: db
wPlayerSDefLevel:: db
-wPlayerAccLevel:: db
-wPlayerEvaLevel:: db
+wPlayerAccLevel:: db
+wPlayerEvaLevel:: db
ds 1
-wPlayerStatLevelsEnd::
wEnemyStatLevels::
-; 07 neutral
-wEnemyAtkLevel:: db
-wEnemyDefLevel:: db
-wEnemySpdLevel:: db
+wEnemyAtkLevel:: db
+wEnemyDefLevel:: db
+wEnemySpdLevel:: db
wEnemySAtkLevel:: db
wEnemySDefLevel:: db
-wEnemyAccLevel:: db
-wEnemyEvaLevel:: db
+wEnemyAccLevel:: db
+wEnemyEvaLevel:: db
ds 1
-wEnemyTurnsTaken:: db
+wEnemyTurnsTaken:: db
wPlayerTurnsTaken:: db
ds 1
wPlayerSubstituteHP:: db
-wEnemySubstituteHP:: db
+wEnemySubstituteHP:: db
wUnusedPlayerLockedMove:: db
ds 1
wCurPlayerMove:: db
-wCurEnemyMove:: db
+wCurEnemyMove:: db
wLinkBattleRNCount::
; how far through the prng stream
@@ -965,7 +880,7 @@ wCurEnemyMoveNum:: db
wEnemyHPAtTimeOfPlayerSwitch:: dw
wPayDayMoney:: ds 3
-wSafariMonAngerCount:: db
+wSafariMonAngerCount:: db ; unreferenced
wSafariMonEating:: db
ds 1
wEnemyBackupDVs:: dw ; used when enemy is transformed
@@ -1050,7 +965,7 @@ wEnemyFutureSightCount:: db
wGivingExperienceToExpShareHolders:: db
-wBackupEnemyMonBaseStats:: ds 5
+wBackupEnemyMonBaseStats:: ds NUM_EXP_STATS
wBackupEnemyMonCatchRate:: db
wBackupEnemyMonBaseExp:: db
@@ -1157,7 +1072,7 @@ wPlayerLinkAction:: db
wce57:: db
ds 3
wLinkTimeoutFrames:: dw
-wce5d:: dw
+wLinkByteTimeout:: dw
wMonType:: db
@@ -1170,12 +1085,6 @@ wNamedObjectTypeBuffer:: db
wJumptableIndex:: db
UNION
-; unidentified
-wce64:: db
-wce65:: db
-wce66:: db
-
-NEXTU
; intro data
wIntroSceneFrameCounter:: db
wIntroSceneTimer:: db
@@ -1196,11 +1105,13 @@ NEXTU
wPrevDexEntryJumptableIndex:: db
wPrevDexEntryBackup::
wPokedexStatus:: db
+wUnusedPokedexByte:: db
NEXTU
; pokegear
wPokegearCard:: db
wPokegearMapRegion:: db
+wUnusedPokegearByte:: db
NEXTU
; pack
@@ -1215,12 +1126,22 @@ wTrainerCardBadgeTileID:: db
wTrainerCardBadgeAttributes:: db
NEXTU
-; card flip data
+; slot machine
+wSlotsDelay:: db
+ ds 1
+wUnusedSlotReelIconDelay:: db
+
+NEXTU
+; card flip
wCardFlipCursorY:: db
wCardFlipCursorX:: db
wCardFlipWhichCard:: db
NEXTU
+; dummy game
+wDummyGameCardChoice:: db
+
+NEXTU
; magnet train
wMagnetTrainOffset:: db
wMagnetTrainPosition:: db
@@ -1233,6 +1154,16 @@ wUnownPuzzleCursorPosition:: db
wUnownPuzzleHeldPiece:: db
NEXTU
+; battle transitions
+wBattleTransitionCounter:: db
+wBattleTransitionSineWaveOffset::
+wBattleTransitionSpinQuadrant:: db
+
+NEXTU
+; bill's pc
+wUnusedBillsPCData:: ds 3
+
+NEXTU
; debug mon color picker
wDebugColorRGBJumptableIndex:: db
wDebugColorCurColor:: db
@@ -1250,17 +1181,18 @@ wFrameCounter::
wMomBankDigitCursorPosition::
wNamingScreenLetterCase::
wHallOfFameMonCounter::
-wSlotsDelay::
+wTradeDialog::
+ db
+wFrameCounter2::
+wPrinterQueueLength::
+wUnusedSGB1eColorOffset::
db
-wPrinterQueueLength:: db
ENDU
-wRequested2bpp::
wRequested2bppSize:: db
wRequested2bppSource:: dw
wRequested2bppDest:: dw
-wRequested1bpp::
wRequested1bppSize:: db
wRequested1bppSource:: dw
wRequested1bppDest:: dw
@@ -1404,17 +1336,20 @@ wOverworldDelay:: db
wTextDelayFrames:: db
wVBlankOccurred:: db
-wceeb:: db
+wBetaTitleSequenceOpeningType::
+; This selected the title screen animation (fire/notes) in pokegold-spaceworld.
+ db
wDefaultSpawnpoint:: db
UNION
-; mail temp storage
-wTempMail:: mailmsg wTempMail
+; mon buffer
+wBufferMonNick:: ds MON_NAME_LENGTH
+wBufferMonOT:: ds NAME_LENGTH
+wBufferMon:: party_struct wBufferMon
NEXTU
; magnet train
-wMagnetTrain:: ; used only for BANK(wMagnetTrain)
wMagnetTrainDirection:: db
wMagnetTrainInitPosition:: db
wMagnetTrainHoldPosition:: db
@@ -1427,11 +1362,8 @@ wCreditsPos:: dw
wCreditsTimer:: db
NEXTU
-; mon buffer
-wBufferMonNick:: ds MON_NAME_LENGTH
-wBufferMonOT:: ds NAME_LENGTH
-wBufferMon:: party_struct wBufferMon
- ds 8
+; mail temp storage
+wTempMail:: mailmsg wTempMail
NEXTU
; bug-catching contest
@@ -1465,6 +1397,8 @@ wTownMapCursorLandmark:: db
wTownMapCursorObjectPointer:: dw
NEXTU
wTownMapCursorCoordinates:: dw
+wStartFlypoint:: db
+wEndFlypoint:: db
ENDU
NEXTU
@@ -1481,7 +1415,6 @@ wNumRadioLinesPrinted:: db
wOaksPKMNTalkSegmentCounter:: db
ds 5
wRadioText:: ds 2 * SCREEN_WIDTH
-wRadioTextEnd::
NEXTU
; lucky number show
@@ -1504,12 +1437,21 @@ wBankOfBoxToPrint:: db
wWhichBoxToPrint:: db
NEXTU
+; Unown printing
+wPrintedUnownTileSource:: ds 1 tiles
+wPrintedUnownTileDest:: ds 1 tiles
+
+NEXTU
; trainer HUD data
ds 1
wPlaceBallsDirection:: db
wTrainerHUDTiles:: ds 4
NEXTU
+; battle exp gain
+wExperienceGained:: ds 3
+
+NEXTU
; earthquake data buffer
wEarthquakeMovementDataBuffer:: ds 5
@@ -1518,13 +1460,62 @@ NEXTU
wSwitchItemBuffer:: ds 2 ; may store 1 or 2 bytes
NEXTU
+; switching pokemon in party
+; may store NAME_LENGTH, PARTYMON_STRUCT_LENGTH, or MAIL_STRUCT_LENGTH bytes
+wSwitchMonBuffer:: ds 48
+
+NEXTU
+; giving pokemon mail
+wMonMailMessageBuffer:: ds MAIL_MSG_LENGTH + 1
+
+NEXTU
+; bill's pc
+UNION
+wBoxNameBuffer:: ds BOX_NAME_LENGTH
+NEXTU
+ ds 1
+wBillsPCTempListIndex:: db
+wBillsPCTempBoxCount:: db
+ENDU
+
+NEXTU
+; prof. oak's pc
+wTempPokedexSeenCount:: db
+wTempPokedexCaughtCount:: db
+
+NEXTU
+; player's room pc
+UNION
+wDecoNameBuffer:: ds ITEM_NAME_LENGTH
+NEXTU
+wNumOwnedDecoCategories:: db
+wOwnedDecoCategories:: ds 16
+ENDU
+
+NEXTU
+; trade
+wCurTradePartyMon:: db
+wCurOTTradePartyMon:: db
+wBufferTrademonNick:: ds MON_NAME_LENGTH
+
+NEXTU
+; link battle record data
+wLinkBattleRecordBuffer::
+wLinkBattleRecordName:: ds NAME_LENGTH
+wLinkBattleRecordWins:: dw
+wLinkBattleRecordLosses:: dw
+wLinkBattleRecordDraws:: dw
+
+NEXTU
; miscellaneous
wTempDayOfWeek::
-wKeepSevenBiasChance:: ; used in the slots to handle the favoring of 7 symbol streaks
+wPrevPartyLevel::
+wCurBeatUpPartyMon::
+wUnownPuzzleCornerTile::
+wKeepSevenBiasChance::
+wPokeFluteCuredSleep::
+wTempRestorePPItem::
db
- ds 2
-wStartFlypoint:: db
-wEndFlypoint:: db
NEXTU
; debug color picker
@@ -1546,23 +1537,9 @@ wDebugRoomPagedValuesPtr:: dw
ENDC
NEXTU
-; link battle record data
-wLinkBattleRecordName:: ds NAME_LENGTH
-wLinkBattleRecordWins:: dw
-wLinkBattleRecordLosses:: dw
-wLinkBattleRecordDraws:: dw
-
-NEXTU
-; unidentified
-wceed:: db
-wceee:: db
-wceef:: db
-
- ds 13
-
-wcefd:: ds 1
-
- ds 43
+; Every previous NEXTU takes up 60 or fewer bytes,
+; except the initial "mon buffer" UNION.
+ ds 60
UNION
; trainer data
@@ -1792,11 +1769,10 @@ wCurMessageScrollPosition:: db
wCurMessageIndex:: db
wMailboxCount:: db
wMailboxItems:: ds MAILBOX_CAPACITY
-wMailboxEnd::
ENDU
wListPointer:: dw
-wUnusedCFFE:: dw
+wUnusedNamesPointer:: dw
SECTION "WRAM 1", WRAMX
@@ -1864,7 +1840,7 @@ wPrevMapNumber:: db
ds 17
-wUnusedD05A:: db
+wUnusedAddOutdoorSpritesReturnValue:: db
wBGMapAnchor:: dw
@@ -1947,9 +1923,8 @@ wEvolutionPicOffset:: db
wEvolutionCanceled:: db
NEXTU
-
+; link
ds 9
-
wd0dc:: ds 1
NEXTU
@@ -1969,7 +1944,7 @@ wTempEnemyMonSpecies:: db
wTempBattleMonSpecies:: db
wEnemyMon:: battle_struct wEnemyMon
-wEnemyMonBaseStats:: ds 5
+wEnemyMonBaseStats:: ds NUM_EXP_STATS
wEnemyMonCatchRate:: db
wEnemyMonBaseExp:: db
wEnemyMonEnd::
@@ -2087,9 +2062,8 @@ wMapEventStatus:: db
wScriptFlags::
; bit 3: priority jump
db
+ ds 1
wScriptFlags2::
- db
-wScriptFlags3::
; bit 0: count steps
; bit 1: coord events
; bit 2: warps and connections
@@ -2198,15 +2172,15 @@ wSavedAtLeastOnce:: db
wSpawnAfterChampion:: db
; init time set at newgame
-wStartDay:: db
-wStartHour:: db
+wStartDay:: db
+wStartHour:: db
wStartMinute:: db
wStartSecond:: db
wRTC:: ds 4
-wDSTBackupDay:: db
-wDSTBackupHours:: db
+wDSTBackupDay:: db
+wDSTBackupHours:: db
wDSTBackupMinutes:: db
wDSTBackupSeconds:: db
@@ -2253,7 +2227,6 @@ wPlayerData2::
NEXTU
wObject11Struct:: object_struct wObject11
wObject12Struct:: object_struct wObject12
-wObjectStructsEnd::
ENDU
wCmdQueue:: ds CMDQUEUE_CAPACITY * CMDQUEUE_ENTRY_SIZE
@@ -2277,7 +2250,6 @@ wMap12Object:: map_object wMap12
wMap13Object:: map_object wMap13
wMap14Object:: map_object wMap14
wMap15Object:: map_object wMap15
-wMapObjectsEnd::
wObjectMasks:: ds NUM_OBJECTS
@@ -2316,23 +2288,18 @@ wJohtoBadges:: flag_array NUM_JOHTO_BADGES
wKantoBadges:: flag_array NUM_KANTO_BADGES
wTMsHMs:: ds NUM_TMS + NUM_HMS
-wTMsHMsEnd::
wNumItems:: db
wItems:: ds MAX_ITEMS * 2 + 1
-wItemsEnd::
wNumKeyItems:: db
wKeyItems:: ds MAX_KEY_ITEMS + 1
-wKeyItemsEnd::
wNumBalls:: db
wBalls:: ds MAX_BALLS * 2 + 1
-wBallsEnd::
wNumPCItems:: db
wPCItems:: ds MAX_PC_ITEMS * 2 + 1
-wPCItemsEnd::
wPokegearFlags::
; bit 0: map
@@ -2424,17 +2391,19 @@ wMountMoonSquareSceneID:: db
wEventFlags:: flag_array NUM_EVENTS
-wd8b7:: db
+wUnusedLinkCommunicationByte:: db
-wGameTimerPause:: db
+wGameTimerPaused::
+; bit 7: game timer paused
+ db
ds 1
-wd8ba::
+wJoypadDisable::
; bits 4, 6, or 7 can be used to disable joypad input
; bit 4
-; bit 6: mon fainted?
-; bit 7: SGB flag?
+; bit 6: ongoing mon faint animation
+; bit 7: ongoing sgb data transfer
db
ds 1
@@ -2604,10 +2573,9 @@ wDayCareMan::
; bit 0: monster 1 in day-care
db
-wBreedMon1::
-wBreedMon1Nick:: ds MON_NAME_LENGTH
-wBreedMon1OT:: ds NAME_LENGTH
-wBreedMon1Stats:: box_struct wBreedMon1
+wBreedMon1Nick:: ds MON_NAME_LENGTH
+wBreedMon1OT:: ds NAME_LENGTH
+wBreedMon1:: box_struct wBreedMon1
wDayCareLady::
; bit 7: active
@@ -2621,10 +2589,9 @@ wBreedMotherOrNonDitto::
; nz: no
db
-wBreedMon2::
-wBreedMon2Nick:: ds MON_NAME_LENGTH
-wBreedMon2OT:: ds NAME_LENGTH
-wBreedMon2Stats:: box_struct wBreedMon2
+wBreedMon2Nick:: ds MON_NAME_LENGTH
+wBreedMon2OT:: ds NAME_LENGTH
+wBreedMon2:: box_struct wBreedMon2
wEggNick:: ds MON_NAME_LENGTH
wEggOT:: ds NAME_LENGTH
@@ -2669,22 +2636,6 @@ wOTPartyEnd:: db ; older code doesn't check PartyCount
ENDU
UNION
-; catch tutorial dude pack
-wDudeBag::
-wDudeNumItems:: db
-wDudeItems:: ds 2 * 4
-wDudeItemsEnd:: db
-
-wDudeNumKeyItems:: db
-wDudeKeyItems:: ds 18
-wDudeKeyItemsEnd:: db
-
-wDudeNumBalls:: db
-wDudeBalls:: ds 2 * 4
-wDudeBallsEnd:: db
-wDudeBagEnd::
-
-NEXTU
; ot party mons
wOTPartyMons::
wOTPartyMon1:: party_struct wOTPartyMon1
@@ -2698,6 +2649,17 @@ wOTPartyMonsEnd::
wOTPartyMonOT:: ds NAME_LENGTH * PARTY_LENGTH
wOTPartyMonNicknames:: ds MON_NAME_LENGTH * PARTY_LENGTH
wOTPartyDataEnd::
+
+NEXTU
+; catch tutorial dude pack
+wDudeNumItems:: db
+wDudeItems:: ds 2 * 4 + 1
+
+wDudeNumKeyItems:: db
+wDudeKeyItems:: ds 18 + 1
+
+wDudeNumBalls:: db
+wDudeBalls:: ds 2 * 4 + 1
ENDU
wPokemonDataEnd::
@@ -2709,7 +2671,6 @@ SECTION "Stack", WRAMX
ds 2
wStackBottom::
ds $fc
-wStack::
wStackTop::
ds 1