summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/battle/battle_transition.asm77
-rw-r--r--engine/battle/core.asm48
-rw-r--r--engine/battle/effect_commands.asm4
-rw-r--r--engine/battle/link_result.asm14
-rw-r--r--engine/events/battle_tower/battle_tower.asm22
-rw-r--r--engine/events/bug_contest/display_stats.asm2
-rw-r--r--engine/events/celebi.asm6
-rw-r--r--engine/events/halloffame.asm14
-rw-r--r--engine/events/overworld.asm4
-rw-r--r--engine/events/print_unown_2.asm12
-rw-r--r--engine/games/card_flip.asm2
-rw-r--r--engine/games/unown_puzzle.asm4
-rw-r--r--engine/items/item_effects.asm8
-rw-r--r--engine/link/link.asm14
-rw-r--r--engine/link/mystery_gift.asm6
-rw-r--r--engine/menus/debug.asm8
-rw-r--r--engine/menus/save.asm76
-rw-r--r--engine/movie/trade_animation.asm2
-rw-r--r--engine/overworld/load_map_part.asm6
-rw-r--r--engine/overworld/scripting.asm10
-rw-r--r--engine/overworld/variables.asm2
-rw-r--r--engine/overworld/warp_connection.asm2
-rw-r--r--engine/pokemon/bills_pc.asm6
-rw-r--r--engine/pokemon/correct_nick_errors.asm (renamed from engine/pokemon/check_nick_errors.asm)2
-rw-r--r--engine/pokemon/party_menu.asm2
-rw-r--r--engine/pokemon/stats_screen.asm2
26 files changed, 191 insertions, 164 deletions
diff --git a/engine/battle/battle_transition.asm b/engine/battle/battle_transition.asm
index 1de84421d..42dd440ea 100644
--- a/engine/battle/battle_transition.asm
+++ b/engine/battle/battle_transition.asm
@@ -1,3 +1,11 @@
+; BattleTransitionJumptable.Jumptable indexes
+BATTLETRANSITION_CAVE EQU $01
+BATTLETRANSITION_CAVE_STRONGER EQU $09
+BATTLETRANSITION_NO_CAVE EQU $10
+BATTLETRANSITION_NO_CAVE_STRONGER EQU $18
+BATTLETRANSITION_FINISH EQU $20
+BATTLETRANSITION_END EQU $80
+
DoBattleTransition: ; 8c20f
call .InitGFX
ld a, [rBGP]
@@ -14,7 +22,7 @@ DoBattleTransition: ; 8c20f
.loop
ld a, [wJumptableIndex]
- bit 7, a
+ bit 7, a ; BATTLETRANSITION_END?
jr nz, .done
call BattleTransitionJumptable
call DelayFrame
@@ -145,13 +153,13 @@ INCBIN "gfx/overworld/trainer_battle_pokeball_tiles.2bpp"
BattleTransitionJumptable: ; 8c314
- jumptable .dw, wJumptableIndex
+ jumptable .Jumptable, wJumptableIndex
; 8c323
-.dw ; 8c323 (23:4323)
+.Jumptable ; 8c323 (23:4323)
dw StartTrainerBattle_DetermineWhichAnimation ; 00
- ; Animation 1: cave
+ ; BATTLETRANSITION_CAVE
dw StartTrainerBattle_LoadPokeBallGraphics ; 01
dw StartTrainerBattle_SetUpBGMap ; 02
dw StartTrainerBattle_Flash ; 03
@@ -161,7 +169,7 @@ BattleTransitionJumptable: ; 8c314
dw StartTrainerBattle_SetUpForWavyOutro ; 07
dw StartTrainerBattle_SineWave ; 08
- ; Animation 2: cave, stronger
+ ; BATTLETRANSITION_CAVE_STRONGER
dw StartTrainerBattle_LoadPokeBallGraphics ; 09
dw StartTrainerBattle_SetUpBGMap ; 0a
dw StartTrainerBattle_Flash ; 0b
@@ -171,7 +179,7 @@ BattleTransitionJumptable: ; 8c314
; There is no setup for this one
dw StartTrainerBattle_ZoomToBlack ; 0f
- ; Animation 3: no cave
+ ; BATTLETRANSITION_NO_CAVE
dw StartTrainerBattle_LoadPokeBallGraphics ; 10
dw StartTrainerBattle_SetUpBGMap ; 11
dw StartTrainerBattle_Flash ; 12
@@ -181,7 +189,7 @@ BattleTransitionJumptable: ; 8c314
dw StartTrainerBattle_SetUpForSpinOutro ; 16
dw StartTrainerBattle_SpinToBlack ; 17
- ; Animation 4: no cave, stronger
+ ; BATTLETRANSITION_NO_CAVE_STRONGER
dw StartTrainerBattle_LoadPokeBallGraphics ; 18
dw StartTrainerBattle_SetUpBGMap ; 19
dw StartTrainerBattle_Flash ; 1a
@@ -191,9 +199,19 @@ BattleTransitionJumptable: ; 8c314
dw StartTrainerBattle_SetUpForRandomScatterOutro ; 1e
dw StartTrainerBattle_SpeckleToBlack ; 1f
- ; All animations jump to here.
+ ; BATTLETRANSITION_FINISH
dw StartTrainerBattle_Finish ; 20
+; transition animations
+ const_def
+ const TRANS_CAVE
+ const TRANS_CAVE_STRONGER
+ const TRANS_NO_CAVE
+ const TRANS_NO_CAVE_STRONGER
+
+; transition animation bits
+TRANS_STRONGER_F EQU 0 ; bit set in TRANS_CAVE_STRONGER and TRANS_NO_CAVE_STRONGER
+TRANS_NO_CAVE_F EQU 1 ; bit set in TRANS_NO_CAVE and TRANS_NO_CAVE_STRONGER
StartTrainerBattle_DetermineWhichAnimation: ; 8c365 (23:4365)
; The screen flashes a different number of times depending on the level of
@@ -205,18 +223,18 @@ StartTrainerBattle_DetermineWhichAnimation: ; 8c365 (23:4365)
add 3
ld hl, wEnemyMonLevel
cp [hl]
- jr nc, .okay
- set 0, e
-.okay
+ jr nc, .not_stronger
+ set TRANS_STRONGER_F, e
+.not_stronger
ld a, [wEnvironment]
cp CAVE
- jr z, .okay2
+ jr z, .cave
cp ENVIRONMENT_5
- jr z, .okay2
+ jr z, .cave
cp DUNGEON
- jr z, .okay2
- set 1, e
-.okay2
+ jr z, .cave
+ set TRANS_NO_CAVE_F, e
+.cave
ld hl, .StartingPoints
add hl, de
ld a, [hl]
@@ -225,13 +243,16 @@ StartTrainerBattle_DetermineWhichAnimation: ; 8c365 (23:4365)
; 8c38f (23:438f)
.StartingPoints: ; 8c38f
- db 1, 9
- db 16, 24
+; entries correspond to TRANS_* constants
+ db BATTLETRANSITION_CAVE
+ db BATTLETRANSITION_CAVE_STRONGER
+ db BATTLETRANSITION_NO_CAVE
+ db BATTLETRANSITION_NO_CAVE_STRONGER
; 8c393
StartTrainerBattle_Finish: ; 8c393 (23:4393)
call ClearSprites
- ld a, $80
+ ld a, BATTLETRANSITION_END
ld [wJumptableIndex], a
ret
@@ -322,7 +343,7 @@ StartTrainerBattle_SineWave: ; 8c408 (23:4408)
ret
.end
- ld a, $20
+ ld a, BATTLETRANSITION_FINISH
ld [wJumptableIndex], a
ret
@@ -394,7 +415,7 @@ endr
call DelayFrame
xor a
ld [hBGMapMode], a
- ld a, $20
+ ld a, BATTLETRANSITION_FINISH
ld [wJumptableIndex], a
ret
; 8c490 (23:4490)
@@ -406,6 +427,10 @@ endr
const LOWER_LEFT
const LOWER_RIGHT
+; quadrant bits
+RIGHT_QUADRANT_F EQU 0 ; bit set in UPPER_RIGHT and LOWER_RIGHT
+LOWER_QUADRANT_F EQU 1 ; bit set in LOWER_LEFT and LOWER_RIGHT
+
.spintable ; 8c490
spintable_entry: MACRO
db \1
@@ -451,7 +476,7 @@ ENDM
.loop1
ld [hl], $ff
ld a, [wcf65]
- bit 0, a
+ bit RIGHT_QUADRANT_F, a
jr z, .leftside
inc hl
jr .okay1
@@ -462,7 +487,7 @@ ENDM
jr nz, .loop1
pop hl
ld a, [wcf65]
- bit 1, a
+ bit LOWER_QUADRANT_F, a
ld bc, SCREEN_WIDTH
jr z, .upper
ld bc, -SCREEN_WIDTH
@@ -477,7 +502,7 @@ ENDM
ld c, a
.loop2
ld a, [wcf65]
- bit 0, a
+ bit RIGHT_QUADRANT_F, a
jr z, .leftside2
dec hl
jr .okay2
@@ -530,7 +555,7 @@ StartTrainerBattle_SpeckleToBlack: ; 8c58f (23:458f)
call DelayFrame
xor a
ld [hBGMapMode], a
- ld a, $20
+ ld a, BATTLETRANSITION_FINISH
ld [wJumptableIndex], a
ret
@@ -778,7 +803,7 @@ StartTrainerBattle_ZoomToBlack: ; 8c768 (23:4768)
jr .loop
.done
- ld a, $20
+ ld a, BATTLETRANSITION_FINISH
ld [wJumptableIndex], a
ret
; 8c792 (23:4792)
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index de4830766..ce5088fc2 100644
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -119,8 +119,8 @@ DoBattle: ; 3c000
WildFled_EnemyFled_LinkBattleCanceled: ; 3c0e5
call Call_LoadTempTileMapToTileMap
ld a, [wBattleResult]
- and $c0
- add $2
+ and BATTLERESULT_BITMASK
+ add DRAW
ld [wBattleResult], a
ld a, [wLinkMode]
and a
@@ -128,8 +128,8 @@ WildFled_EnemyFled_LinkBattleCanceled: ; 3c0e5
jr z, .print_text
ld a, [wBattleResult]
- and $c0
- ld [wBattleResult], a
+ and BATTLERESULT_BITMASK
+ ld [wBattleResult], a ; WIN
ld hl, BattleText_EnemyFled
call CheckMobileBattleError
jr nc, .print_text
@@ -575,8 +575,8 @@ CheckContestBattleOver: ; 3c3f5
and a
jr nz, .contest_not_over
ld a, [wBattleResult]
- and $c0
- add $2
+ and BATTLERESULT_BITMASK
+ add DRAW
ld [wBattleResult], a
scf
ret
@@ -2199,8 +2199,8 @@ UpdateBattleStateAndExperienceAfterEnemyFaint: ; 3ce01
call EmptyBattleTextBox
call LoadTileMapToTempTileMap
ld a, [wBattleResult]
- and $c0
- ld [wBattleResult], a
+ and BATTLERESULT_BITMASK
+ ld [wBattleResult], a ; WIN
call IsAnyMonHoldingExpShare
jr z, .skip_exp
ld hl, wEnemyMonBaseStats
@@ -2745,8 +2745,8 @@ PlayerMonFaintHappinessMod: ; 3d1aa
ld [wCurPartyMon], a
callfar ChangeHappiness
ld a, [wBattleResult]
- and %11000000
- add $1
+ and BATTLERESULT_BITMASK
+ add LOSE
ld [wBattleResult], a
ld a, [wWhichMonFaintedFirst]
and a
@@ -3050,8 +3050,8 @@ LostBattle: ; 3d38e
jr nz, .not_tied
ld hl, TiedAgainstText
ld a, [wBattleResult]
- and $c0
- add 2
+ and BATTLERESULT_BITMASK
+ add DRAW
ld [wBattleResult], a
jr .text
@@ -3928,11 +3928,11 @@ TryToRunAwayFromBattle: ; 3d8b3
cp BATTLEACTION_FORFEIT
ld a, DRAW
jr z, .fled
- dec a
+ dec a ; LOSE
.fled
ld b, a
ld a, [wBattleResult]
- and $c0
+ and BATTLERESULT_BITMASK
add b
ld [wBattleResult], a
call StopDangerSound
@@ -5180,8 +5180,8 @@ BattleMenu_Pack: ; 3e1c7
xor a
ld [wWildMon], a
ld a, [wBattleResult]
- and $c0
- ld [wBattleResult], a
+ and BATTLERESULT_BITMASK
+ ld [wBattleResult], a ; WIN
call ClearWindowData
call SetPalettes
scf
@@ -8607,9 +8607,10 @@ DisplayLinkBattleResult: ; 3f77c
.proceed
ld a, [wBattleResult]
and $f
- cp $1
- jr c, .victory
- jr z, .loss
+ cp LOSE
+ jr c, .victory ; WIN
+ jr z, .loss ; LOSE
+ ; DRAW
farcall StubbedTrainerRankings_ColosseumDraws
ld de, .Draw
jr .store_result
@@ -8841,7 +8842,7 @@ BattleEnd_HandleRoamMons: ; 3f998
jr nz, .not_roaming
ld a, [wBattleResult]
and $f
- jr z, .caught_or_defeated_roam_mon
+ jr z, .caught_or_defeated_roam_mon ; WIN
call GetRoamMonHP
ld a, [wEnemyMonHP + 1]
ld [hl], a
@@ -9001,11 +9002,12 @@ AddLastMobileBattleToLinkRecord: ; 3fa42
.StoreResult: ; 3faa0
ld a, [wBattleResult]
and $f
- cp $1
+ cp LOSE
ld bc, sLinkBattleWins + 1 - sLinkBattleResults
- jr c, .okay
+ jr c, .okay ; WIN
ld bc, sLinkBattleLosses + 1 - sLinkBattleResults
- jr z, .okay
+ jr z, .okay ; LOSE
+ ; DRAW
ld bc, sLinkBattleDraws + 1 - sLinkBattleResults
.okay
add hl, bc
diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm
index ea6c22dda..580c25583 100644
--- a/engine/battle/effect_commands.asm
+++ b/engine/battle/effect_commands.asm
@@ -5390,8 +5390,8 @@ INCLUDE "engine/battle/move_effects/teleport.asm"
SetBattleDraw: ; 36804
ld a, [wBattleResult]
- and $c0
- or $2
+ and BATTLERESULT_BITMASK
+ or DRAW
ld [wBattleResult], a
ret
diff --git a/engine/battle/link_result.asm b/engine/battle/link_result.asm
index 8f456da9b..1dbc40aa9 100644
--- a/engine/battle/link_result.asm
+++ b/engine/battle/link_result.asm
@@ -41,20 +41,20 @@ DetermineLinkBattleResult: ; 2b930
.victory
ld a, [wBattleResult]
and $f0
- ld [wBattleResult], a
+ ld [wBattleResult], a ; WIN
ret
.defeat
ld a, [wBattleResult]
and $f0
- add $1
+ add LOSE
ld [wBattleResult], a
ret
.drawn
ld a, [wBattleResult]
and $f0
- add $2
+ add DRAW
ld [wBattleResult], a
ret
@@ -123,16 +123,16 @@ DetermineLinkBattleResult: ; 2b930
jr nz, .finish ; we have a pokemon that's neither fainted nor at full health
ld hl, wOTPartyMon1HP
call .CheckFaintedOrFullHealth
- ld e, $1
+ ld e, $1 ; victory
ret
.finish
ld hl, wOTPartyMon1HP
call .CheckFaintedOrFullHealth
- ld e, $0
+ ld e, $0 ; drawn
ret nz ; we both have pokemon that are neither fainted nor at full health
- ld e, $2
- ld a, $1
+ ld e, $2 ; defeat
+ ld a, $1 ; not drawn
and a
ret
diff --git a/engine/events/battle_tower/battle_tower.asm b/engine/events/battle_tower/battle_tower.asm
index 9dace59b4..d75015d5b 100644
--- a/engine/events/battle_tower/battle_tower.asm
+++ b/engine/events/battle_tower/battle_tower.asm
@@ -64,7 +64,7 @@ Function170114: ; 170114
ld a, $5
call GetSRAMBank
ld hl, $a948
- ld de, wMisc
+ ld de, wc608
ld bc, $f6 ; 246
call CopyBytes
call CloseSRAM
@@ -90,11 +90,11 @@ Function170139: ; 170139
ld b, $0
add hl, bc
call CloseSRAM
-; Store that number in wMisc
+; Store that number in wc608
ld a, h
- ld [wMisc], a
+ ld [wc608], a
ld a, l
- ld [wMisc + 1], a
+ ld [wc608 + 1], a
ld hl, wBT_OTTempMon1DVs
ld a, [wPlayerID]
ld [hli], a
@@ -161,7 +161,7 @@ Function170139: ; 170139
ld hl, $a894
ld bc, NAME_LENGTH_JAPANESE
call CopyBytes
- ld hl, wMisc
+ ld hl, wc608
ld de, $a948
ld bc, $f6
call CopyBytes
@@ -254,7 +254,7 @@ RunBattleTowerTrainer: ; 17024d
farcall HealParty
ld a, [wBattleResult]
ld [wScriptVar], a
- and a
+ and a ; WIN?
jr nz, .lost
ld a, BANK(sNrOfBeatenBattleTowerTrainers)
call GetSRAMBank
@@ -674,7 +674,7 @@ Function1704e1: ; 1704e1
call CopyBytes
ld hl, $a8b2
- ld de, wMisc
+ ld de, wc608
ld bc, $0096
call CopyBytes
@@ -793,7 +793,7 @@ Function1704e1: ; 1704e1
call .PlaceUpDownArrows
ld a, $50
ld [wcd4e], a
- ld hl, wMisc
+ ld hl, wc608
ld a, [wNrOfBeatenBattleTowerTrainers]
ld c, a
xor a
@@ -1441,7 +1441,7 @@ Function1709bb: ; 1709bb (5c:49bb) BattleTowerAction $10
ld a, $5
call GetSRAMBank
ld hl, $b023
- ld de, wMisc
+ ld de, wc608
ld bc, $0069
call CopyBytes
ld a, [$a825]
@@ -1460,14 +1460,14 @@ Function1709bb: ; 1709bb (5c:49bb) BattleTowerAction $10
ld a, $0
call GetSRAMBank
ld hl, wRTC
- ld de, wMisc
+ ld de, wc608
ld bc, $0004
call CopyBytes
call CloseSRAM
ld a, $5
call GetSRAMBank
ld hl, $b08c
- ld de, wMisc
+ ld de, wc608
ld c, $4
.compare_loop
ld a, [de]
diff --git a/engine/events/bug_contest/display_stats.asm b/engine/events/bug_contest/display_stats.asm
index 13b90d0a3..9f6eb50d0 100644
--- a/engine/events/bug_contest/display_stats.asm
+++ b/engine/events/bug_contest/display_stats.asm
@@ -7,7 +7,7 @@ DisplayCaughtContestMonStats: ; cc000
ld hl, wOptions
ld a, [hl]
push af
- set 4, [hl]
+ set NO_TEXT_SCROLL, [hl]
hlcoord 0, 0
ld b, 4
diff --git a/engine/events/celebi.asm b/engine/events/celebi.asm
index 99c22f49f..cb5d08d95 100644
--- a/engine/events/celebi.asm
+++ b/engine/events/celebi.asm
@@ -325,15 +325,15 @@ CelebiEvent_SetBattleType: ; 49bf3
CheckCaughtCelebi: ; 49bf9
ld a, [wBattleResult]
- bit 6, a
+ bit BATTLERESULT_CAUGHT_CELEBI, a
jr z, .false
- ld a, $1
+ ld a, TRUE
ld [wScriptVar], a
jr .done
.false
- xor a
+ xor a ; FALSE
ld [wScriptVar], a
.done
diff --git a/engine/events/halloffame.asm b/engine/events/halloffame.asm
index cf3831066..b6b547aae 100644
--- a/engine/events/halloffame.asm
+++ b/engine/events/halloffame.asm
@@ -143,12 +143,12 @@ AnimateHallOfFame: ; 864c3
GetHallOfFameParty: ; 8653f
- ld hl, wOverworldMap
- ld bc, HOF_LENGTH
+ ld hl, wHallOfFamePokemonList
+ ld bc, wHallOfFamePokemonListEnd - wHallOfFamePokemonList + 1
xor a
call ByteFill
ld a, [wHallOfFameCount]
- ld de, wOverworldMap
+ ld de, wHallOfFamePokemonList
ld [de], a
inc de
ld hl, wPartySpecies
@@ -216,7 +216,7 @@ GetHallOfFameParty: ; 8653f
pop bc
inc c
pop de
- ld hl, HOF_MON_LENGTH
+ ld hl, wHallOfFamePokemonListMon1End - wHallOfFamePokemonListMon1
add hl, de
ld e, l
ld d, h
@@ -224,7 +224,7 @@ GetHallOfFameParty: ; 8653f
jr .next
.done
- ld a, $ff
+ ld a, -1
ld [de], a
ret
; 865b5
@@ -422,7 +422,7 @@ LoadHOFTeam: ; 8671c
cp NUM_HOF_TEAMS
jr nc, .invalid
ld hl, sHallOfFame
- ld bc, HOF_LENGTH
+ ld bc, wHallOfFameTempEnd - wHallOfFameTemp + 1
call AddNTimes
ld a, BANK(sHallOfFame)
call GetSRAMBank
@@ -430,7 +430,7 @@ LoadHOFTeam: ; 8671c
and a
jr z, .absent
ld de, wHallOfFameTemp
- ld bc, HOF_LENGTH
+ ld bc, wHallOfFameTempEnd - wHallOfFameTemp + 1
call CopyBytes
call CloseSRAM
and a
diff --git a/engine/events/overworld.asm b/engine/events/overworld.asm
index 60ed7cdf9..f9d67f0bd 100644
--- a/engine/events/overworld.asm
+++ b/engine/events/overworld.asm
@@ -179,7 +179,7 @@ CheckMapForSomethingToCut: ; c7ce
farcall CheckCutCollision
pop de
jr nc, .fail
- ; Get the location of the current block in wOverworldMap.
+ ; Get the location of the current block in wOverworldMapBlocks.
call GetBlockLocation
ld c, [hl]
; See if that block contains something that can be cut.
@@ -188,7 +188,7 @@ CheckMapForSomethingToCut: ; c7ce
call CheckOverworldTileArrays
pop hl
jr nc, .fail
- ; Back up the wOverworldMap address to wBuffer3
+ ; Back up the wOverworldMapBlocks address to wBuffer3
ld a, l
ld [wBuffer3], a
ld a, h
diff --git a/engine/events/print_unown_2.asm b/engine/events/print_unown_2.asm
index 78611e594..a2c1f47e3 100644
--- a/engine/events/print_unown_2.asm
+++ b/engine/events/print_unown_2.asm
@@ -12,7 +12,7 @@ RotateUnownFrontpic: ; e0000
ld de, wd002
call .Copy
call .Rotate
- ld hl, UnownPrinter_OverworldMapRectangle
+ ld hl, UnownPrinter_GBPrinterRectangle
pop bc
add hl, bc
add hl, bc
@@ -30,7 +30,7 @@ RotateUnownFrontpic: ; e0000
cp 7 * 7
jr c, .loop
- ld hl, wOverworldMap
+ ld hl, wGameboyPrinterRAM
ld de, sScratch
ld bc, 7 * 7 tiles
call CopyBytes
@@ -95,17 +95,17 @@ RotateUnownFrontpic: ; e0000
jr nz, .loop_count
ret
-overworldmaprect: MACRO
+gbprinterrect: MACRO
y = 0
rept \1
x = \1 * (\2 + -1) + y
rept \2
- dw wOverworldMap tile x
+ dw wGameboyPrinterRAM tile x
x = x + -\2
endr
y = y + 1
endr
ENDM
-UnownPrinter_OverworldMapRectangle: ; e008b
- overworldmaprect 7, 7
+UnownPrinter_GBPrinterRectangle: ; e008b
+ gbprinterrect 7, 7
diff --git a/engine/games/card_flip.asm b/engine/games/card_flip.asm
index fbeb3e3b6..8f5131983 100644
--- a/engine/games/card_flip.asm
+++ b/engine/games/card_flip.asm
@@ -12,7 +12,7 @@ ret_e00ed: ; e00ed (38:40ed)
_CardFlip: ; e00ee (38:40ee)
ld hl, wOptions
- set 4, [hl]
+ set NO_TEXT_SCROLL, [hl]
call ClearBGPalettes
call ClearTileMap
call ClearSprites
diff --git a/engine/games/unown_puzzle.asm b/engine/games/unown_puzzle.asm
index 83527ea69..300f07de4 100644
--- a/engine/games/unown_puzzle.asm
+++ b/engine/games/unown_puzzle.asm
@@ -14,8 +14,8 @@ _UnownPuzzle: ; e1190
xor a
ld [hBGMapMode], a
call DisableLCD
- ld hl, wMisc ; includes wPuzzlePieces
- ld bc, wMiscEnd - wMisc
+ ld hl, wc608 ; includes wPuzzlePieces
+ ld bc, wc7e8 - wc608
xor a
call ByteFill
ld hl, UnownPuzzleCursorGFX
diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm
index 0b5285608..597a75e47 100644
--- a/engine/items/item_effects.asm
+++ b/engine/items/item_effects.asm
@@ -537,7 +537,7 @@ PokeBallEffect: ; e8a2
cp BATTLETYPE_CELEBI
jr nz, .not_celebi
ld hl, wBattleResult
- set 6, [hl]
+ set BATTLERESULT_CAUGHT_CELEBI, [hl]
.not_celebi
ld a, [wPartyCount]
@@ -615,7 +615,7 @@ PokeBallEffect: ; e8a2
cp MONS_PER_BOX
jr nz, .BoxNotFullYet
ld hl, wBattleResult
- set 7, [hl]
+ set BATTLERESULT_BOX_FULL, [hl]
.BoxNotFullYet:
ld a, [wCurItem]
cp FRIEND_BALL
@@ -2196,8 +2196,8 @@ PokeDollEffect: ; f48f
inc a
ld [wForcedSwitch], a
ld a, [wBattleResult]
- and $c0
- or $2
+ and BATTLERESULT_BITMASK
+ or DRAW
ld [wBattleResult], a
jp UseItemText
diff --git a/engine/link/link.asm b/engine/link/link.asm
index f6f37619f..e0b7f7972 100644
--- a/engine/link/link.asm
+++ b/engine/link/link.asm
@@ -84,9 +84,9 @@ Gen2ToGen1LinkComms: ; 2805d
call Serial_ExchangeBytes
ld a, SERIAL_NO_DATA_BYTE
ld [de], a
- ld hl, wMisc
- ld de, wPlayerTrademonSpecies
- ld bc, wPlayerTrademonSpecies - wMisc
+ ld hl, wLink_c608
+ ld de, wTrademons
+ ld bc, wTrademons - wLink_c608
call Serial_ExchangeBytes
xor a
ld [rIF], a
@@ -229,9 +229,9 @@ Gen2ToGen2LinkComms: ; 28177
call Serial_ExchangeBytes
ld a, SERIAL_NO_DATA_BYTE
ld [de], a
- ld hl, wMisc
- ld de, wPlayerTrademonSpecies
- ld bc, $c8
+ ld hl, wLink_c608
+ ld de, wTrademons
+ ld bc, wTrademons - wLink_c608
call Serial_ExchangeBytes
ld a, [wLinkMode]
cp LINK_TRADECENTER
@@ -581,7 +581,7 @@ FixDataForLinkTransfer: ; 28434
ld [hli], a
dec b
jr nz, .loop2
- ld hl, wMisc
+ ld hl, wLink_c608
ld a, SERIAL_PREAMBLE_BYTE
ld [hli], a
ld [hli], a
diff --git a/engine/link/mystery_gift.asm b/engine/link/mystery_gift.asm
index c73e4246e..4aed9ee70 100644
--- a/engine/link/mystery_gift.asm
+++ b/engine/link/mystery_gift.asm
@@ -394,7 +394,7 @@ Function104b88: ; 104b88 (41:4b88)
jp nz, Function104d32
call Function104d38
ret nz
- ld hl, wOverworldMap
+ ld hl, wLinkData
ld a, [wca02]
ld b, a
call Function104d4e
@@ -551,7 +551,7 @@ Function104cd2: ; 104cd2 (41:4cd2)
jp nz, Function104d32
call Function104d38
ret nz
- ld hl, wOverworldMap
+ ld hl, wLinkData
ld a, [wca02]
ld b, a
call Function104d4e
@@ -1543,7 +1543,7 @@ Function105777: ; 105777 (41:5777)
ret
Function10578c: ; 10578c (41:578c)
- ld de, wOverworldMap
+ ld de, wLinkData
ld a, BANK(sPlayerData)
call GetSRAMBank
ld hl, sPlayerData + wPlayerName - wPlayerData
diff --git a/engine/menus/debug.asm b/engine/menus/debug.asm
index 4c3110fe1..d148af542 100644
--- a/engine/menus/debug.asm
+++ b/engine/menus/debug.asm
@@ -71,7 +71,7 @@ Function818f4: ; 818f4
ld hl, PokemonPalettes
Function818fd: ; 818fd
- ld de, wOverworldMap
+ ld de, wOverworldMapBlocks
ld c, NUM_POKEMON + 1
.asm_81902
push bc
@@ -87,7 +87,7 @@ Function818fd: ; 818fd
Function81911: ; 81911
ld hl, TrainerPalettes
- ld de, wOverworldMap
+ ld de, wOverworldMapBlocks
ld c, NUM_TRAINER_CLASSES
.asm_81919
push bc
@@ -424,7 +424,7 @@ Function81bf4: ; 81bf4
ld h, $0
add hl, hl
add hl, hl
- ld de, wOverworldMap
+ ld de, wOverworldMapBlocks
add hl, de
ld de, wc608
ld bc, 4
@@ -876,7 +876,7 @@ Function81eca: ; 81eca
ld h, $0
add hl, hl
add hl, hl
- ld de, wOverworldMap
+ ld de, wOverworldMapBlocks
add hl, de
ld e, l
ld d, h
diff --git a/engine/menus/save.asm b/engine/menus/save.asm
index 7984c1612..efde37ffe 100644
--- a/engine/menus/save.asm
+++ b/engine/menus/save.asm
@@ -165,9 +165,9 @@ AddHallOfFameEntry: ; 14b5f
ld a, c
or b
jr nz, .loop
- ld hl, wOverworldMap
+ ld hl, wHallOfFamePokemonList
ld de, sHallOfFame
- ld bc, HOF_LENGTH
+ ld bc, wHallOfFamePokemonListEnd - wHallOfFamePokemonList + 1
call CopyBytes
call CloseSRAM
ret
@@ -943,8 +943,8 @@ endr
; 150f9
SaveBoxAddress: ; 150f9
-; Save box via wMisc.
-; We do this in three steps because the size of wMisc is less than
+; Save box via wBoxPartialData.
+; We do this in three steps because the size of wBoxPartialData is less than
; the size of sBox.
push hl
; Load the first part of the active box.
@@ -953,8 +953,8 @@ SaveBoxAddress: ; 150f9
ld a, BANK(sBox)
call GetSRAMBank
ld hl, sBox
- ld de, wMisc
- ld bc, (wMiscEnd - wMisc)
+ ld de, wBoxPartialData
+ ld bc, (wBoxPartialDataEnd - wBoxPartialData)
call CopyBytes
call CloseSRAM
pop de
@@ -963,23 +963,23 @@ SaveBoxAddress: ; 150f9
push af
push de
call GetSRAMBank
- ld hl, wMisc
- ld bc, (wMiscEnd - wMisc)
+ ld hl, wBoxPartialData
+ ld bc, (wBoxPartialDataEnd - wBoxPartialData)
call CopyBytes
call CloseSRAM
; Load the second part of the active box.
ld a, BANK(sBox)
call GetSRAMBank
- ld hl, sBox + (wMiscEnd - wMisc)
- ld de, wMisc
- ld bc, (wMiscEnd - wMisc)
+ ld hl, sBox + (wBoxPartialDataEnd - wBoxPartialData)
+ ld de, wBoxPartialData
+ ld bc, (wBoxPartialDataEnd - wBoxPartialData)
call CopyBytes
call CloseSRAM
pop de
pop af
- ld hl, (wMiscEnd - wMisc)
+ ld hl, (wBoxPartialDataEnd - wBoxPartialData)
add hl, de
ld e, l
ld d, h
@@ -987,30 +987,30 @@ SaveBoxAddress: ; 150f9
push af
push de
call GetSRAMBank
- ld hl, wMisc
- ld bc, (wMiscEnd - wMisc)
+ ld hl, wBoxPartialData
+ ld bc, (wBoxPartialDataEnd - wBoxPartialData)
call CopyBytes
call CloseSRAM
; Load the third and final part of the active box.
ld a, BANK(sBox)
call GetSRAMBank
- ld hl, sBox + (wMiscEnd - wMisc) * 2
- ld de, wMisc
- ld bc, sBoxEnd - (sBox + (wMiscEnd - wMisc) * 2) ; $8e
+ ld hl, sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2
+ ld de, wBoxPartialData
+ ld bc, sBoxEnd - (sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2) ; $8e
call CopyBytes
call CloseSRAM
pop de
pop af
- ld hl, (wMiscEnd - wMisc)
+ ld hl, (wBoxPartialDataEnd - wBoxPartialData)
add hl, de
ld e, l
ld d, h
; Save it to the final part of the target box.
call GetSRAMBank
- ld hl, wMisc
- ld bc, sBoxEnd - (sBox + (wMiscEnd - wMisc) * 2) ; $8e
+ ld hl, wBoxPartialData
+ ld bc, sBoxEnd - (sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2) ; $8e
call CopyBytes
call CloseSRAM
@@ -1020,8 +1020,8 @@ SaveBoxAddress: ; 150f9
LoadBoxAddress: ; 1517d (5:517d)
-; Load box via wMisc.
-; We do this in three steps because the size of wMisc is less than
+; Load box via wBoxPartialData.
+; We do this in three steps because the size of wBoxPartialData is less than
; the size of sBox.
push hl
ld l, e
@@ -1030,52 +1030,52 @@ LoadBoxAddress: ; 1517d (5:517d)
push af
push hl
call GetSRAMBank
- ld de, wMisc
- ld bc, (wMiscEnd - wMisc)
+ ld de, wBoxPartialData
+ ld bc, (wBoxPartialDataEnd - wBoxPartialData)
call CopyBytes
call CloseSRAM
ld a, BANK(sBox)
call GetSRAMBank
- ld hl, wMisc
+ ld hl, wBoxPartialData
ld de, sBox
- ld bc, (wMiscEnd - wMisc)
+ ld bc, (wBoxPartialDataEnd - wBoxPartialData)
call CopyBytes
call CloseSRAM
pop hl
pop af
- ld de, (wMiscEnd - wMisc)
+ ld de, (wBoxPartialDataEnd - wBoxPartialData)
add hl, de
; Load part 2
push af
push hl
call GetSRAMBank
- ld de, wMisc
- ld bc, (wMiscEnd - wMisc)
+ ld de, wBoxPartialData
+ ld bc, (wBoxPartialDataEnd - wBoxPartialData)
call CopyBytes
call CloseSRAM
ld a, BANK(sBox)
call GetSRAMBank
- ld hl, wMisc
- ld de, sBox + (wMiscEnd - wMisc)
- ld bc, (wMiscEnd - wMisc)
+ ld hl, wBoxPartialData
+ ld de, sBox + (wBoxPartialDataEnd - wBoxPartialData)
+ ld bc, (wBoxPartialDataEnd - wBoxPartialData)
call CopyBytes
call CloseSRAM
pop hl
pop af
; Load part 3
- ld de, (wMiscEnd - wMisc)
+ ld de, (wBoxPartialDataEnd - wBoxPartialData)
add hl, de
call GetSRAMBank
- ld de, wMisc
- ld bc, sBoxEnd - (sBox + (wMiscEnd - wMisc) * 2) ; $8e
+ ld de, wBoxPartialData
+ ld bc, sBoxEnd - (sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2) ; $8e
call CopyBytes
call CloseSRAM
ld a, BANK(sBox)
call GetSRAMBank
- ld hl, wMisc
- ld de, sBox + (wMiscEnd - wMisc) * 2
- ld bc, sBoxEnd - (sBox + (wMiscEnd - wMisc) * 2) ; $8e
+ ld hl, wBoxPartialData
+ ld de, sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2
+ ld bc, sBoxEnd - (sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2) ; $8e
call CopyBytes
call CloseSRAM
diff --git a/engine/movie/trade_animation.asm b/engine/movie/trade_animation.asm
index 04c31df80..0b9c72681 100644
--- a/engine/movie/trade_animation.asm
+++ b/engine/movie/trade_animation.asm
@@ -126,7 +126,7 @@ RunTradeAnimScript: ; 28fa1
ld hl, wOptions
ld a, [hl]
push af
- set 4, [hl]
+ set NO_TEXT_SCROLL, [hl]
call .TradeAnimLayout
ld a, [wcf66]
and a
diff --git a/engine/overworld/load_map_part.asm b/engine/overworld/load_map_part.asm
index 2184ebf7e..9eeef7259 100644
--- a/engine/overworld/load_map_part.asm
+++ b/engine/overworld/load_map_part.asm
@@ -1,9 +1,9 @@
_LoadMapPart:: ; 4d15b
- ld hl, wMisc
+ ld hl, wSurroundingTiles
ld a, [wMetatileStandingY]
and a
jr z, .top_row
- ld bc, WMISC_WIDTH * 2
+ ld bc, SURROUNDING_WIDTH * 2
add hl, bc
.top_row
@@ -25,7 +25,7 @@ _LoadMapPart:: ; 4d15b
dec c
jr nz, .loop2
ld a, l
- add 4
+ add METATILE_WIDTH
ld l, a
jr nc, .carry
inc h
diff --git a/engine/overworld/scripting.asm b/engine/overworld/scripting.asm
index e2918a45b..9aaf98f39 100644
--- a/engine/overworld/scripting.asm
+++ b/engine/overworld/scripting.asm
@@ -1359,7 +1359,7 @@ Script_startbattle:
call BufferScreen
predef StartBattle
ld a, [wBattleResult]
- and $3f
+ and $ff ^ BATTLERESULT_BITMASK
ld [wScriptVar], a
ret
@@ -1378,10 +1378,10 @@ Script_reloadmapafterbattle:
ld hl, wBattleScriptFlags
ld d, [hl]
- ld [hl], $0
+ ld [hl], 0
ld a, [wBattleResult]
- and $3f
- cp $1
+ and $ff ^ BATTLERESULT_BITMASK
+ cp LOSE
jr nz, .notblackedout
ld b, BANK(Script_BattleWhiteout)
ld hl, Script_BattleWhiteout
@@ -1395,7 +1395,7 @@ Script_reloadmapafterbattle:
.was_wild
ld a, [wBattleResult]
- bit 7, a
+ bit BATTLERESULT_BOX_FULL, a
jr z, .done
ld b, BANK(Script_SpecialBillCall)
ld de, Script_SpecialBillCall
diff --git a/engine/overworld/variables.asm b/engine/overworld/variables.asm
index 89026fdba..3adf6df33 100644
--- a/engine/overworld/variables.asm
+++ b/engine/overworld/variables.asm
@@ -146,6 +146,6 @@ _GetVarAction:: ; 80648 (20:4648)
.BattleResult: ; 80728
ld a, [wBattleResult]
- and $3f
+ and $ff ^ BATTLERESULT_BITMASK
jp .loadstringbuffer2
; 80730
diff --git a/engine/overworld/warp_connection.asm b/engine/overworld/warp_connection.asm
index 069b72234..2f5e488cc 100644
--- a/engine/overworld/warp_connection.asm
+++ b/engine/overworld/warp_connection.asm
@@ -392,7 +392,7 @@ CheckMovingOffEdgeOfMap:: ; 104820 (41:4820)
GetCoordOfUpperLeftCorner:: ; 10486d
- ld hl, wOverworldMap
+ ld hl, wOverworldMapBlocks
ld a, [wXCoord]
bit 0, a
jr nz, .increment_then_halve1
diff --git a/engine/pokemon/bills_pc.asm b/engine/pokemon/bills_pc.asm
index 96d6ac310..75cc3fe35 100644
--- a/engine/pokemon/bills_pc.asm
+++ b/engine/pokemon/bills_pc.asm
@@ -2,7 +2,7 @@ _DepositPKMN: ; e2391 (38:6391)
ld hl, wOptions
ld a, [hl]
push af
- set 4, [hl]
+ set NO_TEXT_SCROLL, [hl]
ld a, [wVramState]
push af
xor a
@@ -264,7 +264,7 @@ _WithdrawPKMN: ; e2583 (38:6583)
ld hl, wOptions
ld a, [hl]
push af
- set 4, [hl]
+ set NO_TEXT_SCROLL, [hl]
ld a, [wVramState]
push af
xor a
@@ -507,7 +507,7 @@ _MovePKMNWithoutMail: ; e2759
ld hl, wOptions
ld a, [hl]
push af
- set 4, [hl]
+ set NO_TEXT_SCROLL, [hl]
ld a, [wVramState]
push af
xor a
diff --git a/engine/pokemon/check_nick_errors.asm b/engine/pokemon/correct_nick_errors.asm
index 87ebd6bb3..5d44846bf 100644
--- a/engine/pokemon/check_nick_errors.asm
+++ b/engine/pokemon/correct_nick_errors.asm
@@ -1,4 +1,4 @@
-CheckNickErrors:: ; 669f
+CorrectNickErrors:: ; 669f
; error-check monster nick before use
; must be a peace offering to gamesharkers
diff --git a/engine/pokemon/party_menu.asm b/engine/pokemon/party_menu.asm
index fc1783c71..11edc0412 100644
--- a/engine/pokemon/party_menu.asm
+++ b/engine/pokemon/party_menu.asm
@@ -778,7 +778,7 @@ PrintPartyMenuText: ; 5049a
.gotstring ; 504be
ld a, [wOptions]
push af
- set 4, a ; disable text delay
+ set NO_TEXT_SCROLL, a
ld [wOptions], a
hlcoord 1, 16 ; Coord
call PlaceString
diff --git a/engine/pokemon/stats_screen.asm b/engine/pokemon/stats_screen.asm
index 59d96999f..7e44cb96e 100644
--- a/engine/pokemon/stats_screen.asm
+++ b/engine/pokemon/stats_screen.asm
@@ -772,7 +772,7 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6)
ld hl, .OTNamePointers
call GetNicknamePointer
call CopyNickname
- farcall CheckNickErrors
+ farcall CorrectNickErrors
hlcoord 2, 13
call PlaceString
ld a, [wTempMonCaughtGender]