shithub: pokered

Download patch

ref: 13e28b0ece7c7888cba792cc6f7219b384213427
parent: 64b4cf624fe2175e2c7539b91bc41b6dae28a00e
parent: db7d941d22d89cf8d6d13cbf768208c5cf2ac2c2
author: Daniel Harding <corrnondacqb@yahoo.com>
date: Mon Jul 20 13:40:25 EDT 2015

Merge pull request #106 from YamaArashi/master

jpab/jpba macros

--- a/constants/misc_constants.asm
+++ b/constants/misc_constants.asm
@@ -121,6 +121,24 @@
 DAYCARE_DATA      EQU 3
 BATTLE_MON_DATA   EQU 4
 
+; player direction constants
+
+PLAYER_DIR_BIT_RIGHT EQU 0
+PLAYER_DIR_BIT_LEFT  EQU 1
+PLAYER_DIR_BIT_DOWN  EQU 2
+PLAYER_DIR_BIT_UP    EQU 3
+
+PLAYER_DIR_RIGHT EQU (1 << PLAYER_DIR_BIT_RIGHT)
+PLAYER_DIR_LEFT  EQU (1 << PLAYER_DIR_BIT_LEFT)
+PLAYER_DIR_DOWN  EQU (1 << PLAYER_DIR_BIT_DOWN)
+PLAYER_DIR_UP    EQU (1 << PLAYER_DIR_BIT_UP)
+
+; flag operations
+
+FLAG_RESET EQU 0
+FLAG_SET   EQU 1
+FLAG_TEST  EQU 2
+
 ; serial
 
 ESTABLISH_CONNECTION_WITH_INTERNAL_CLOCK EQU $01
--- a/engine/HoF_room_pc.asm
+++ b/engine/HoF_room_pc.asm
@@ -29,7 +29,7 @@
 	ld c, 128
 	call DelayFrames
 	xor a
-	ld [wNumCreditsMonsDisplayed - 1], a ; not read
+	ld [wUnusedCD3D], a ; not read
 	ld [wNumCreditsMonsDisplayed], a
 	jp Credits
 
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -187,9 +187,7 @@
 	ld b, $1
 	call GoPAL_SET
 	call HideSprites
-	ld hl, PrintBeginningBattleText
-	ld b, BANK(PrintBeginningBattleText)
-	jp Bankswitch
+	jpab PrintBeginningBattleText
 
 ; when a battle is starting, silhouettes of the player's pic and the enemy's pic are slid onto the screen
 ; the lower of the player's pic (his body) is part of the background, but his head is a sprite
@@ -330,7 +328,7 @@
 	call SaveScreenTilesToBuffer1
 	ld a, [wWhichPokemon]
 	ld c, a
-	ld b, $1
+	ld b, FLAG_SET
 	push bc
 	ld hl, wPartyGainExpFlags
 	predef FlagActionPredef
@@ -359,9 +357,7 @@
 	call PlaySoundWaitForCurrent
 	xor a
 	ld [H_WHOSETURN], a
-	ld hl, AnimationSlideEnemyMonOut
-	ld b, BANK(AnimationSlideEnemyMonOut)
-	jp Bankswitch
+	jpab AnimationSlideEnemyMonOut
 
 WildRanText: ; 3c229 (f:4229)
 	TX_FAR _WildRanText
@@ -938,9 +934,7 @@
 	jr nz, .gainExpFlagsLoop
 	ld a, b
 	ld [wPartyGainExpFlags], a
-	ld hl, GainExperience
-	ld b, BANK(GainExperience)
-	jp Bankswitch
+	jpab GainExperience
 
 EnemyMonFaintedText: ; 0x3c63e
 	TX_FAR _EnemyMonFaintedText
@@ -1087,7 +1081,7 @@
 	ld a, [wPlayerMonNumber]
 	ld c, a
 	ld hl, wPartyGainExpFlags
-	ld b, $0
+	ld b, FLAG_RESET
 	predef FlagActionPredef ; clear gain exp flag for fainted mon
 	ld hl, W_ENEMYBATTSTATUS1
 	res 2, [hl]   ; reset "attacking multiple times" flag
@@ -1187,7 +1181,7 @@
 	ld [wPlayerMonNumber], a
 	ld c, a
 	ld hl, wPartyGainExpFlags
-	ld b, $1
+	ld b, FLAG_SET
 	push bc
 	predef FlagActionPredef
 	pop bc
@@ -1356,7 +1350,7 @@
 	ld [hl],a
 	ld a,[wPlayerMonNumber]
 	ld c,a
-	ld b,1
+	ld b,FLAG_SET
 	push bc
 	predef FlagActionPredef
 	ld hl,wPartyFoughtCurrentEnemyFlags
@@ -2496,7 +2490,7 @@
 	ld a, [wWhichPokemon]
 	ld [wPlayerMonNumber], a
 	ld c, a
-	ld b, $1
+	ld b, FLAG_SET
 	push bc
 	ld hl, wPartyGainExpFlags
 	predef FlagActionPredef
@@ -6302,7 +6296,7 @@
 	predef WriteMonMoves ; get moves based on current level
 .loadMovePPs
 	ld hl, wEnemyMonMoves
-	ld de, wEnemyMonSpecial + 1
+	ld de, wEnemyMonPP - 1
 	predef LoadMovePPs
 	ld hl, W_MONHBASESTATS
 	ld de, wEnemyMonBaseStats
@@ -6332,7 +6326,7 @@
 	ld a, [wd11e]
 	dec a
 	ld c, a
-	ld b, $1
+	ld b, FLAG_SET
 	ld hl, wPokedexSeen
 	predef FlagActionPredef ; mark this mon as seen in the pokedex
 	ld hl, wEnemyMonLevel
@@ -6462,14 +6456,10 @@
 ; does nothing since no stats are ever selected (barring glitches)
 DoubleOrHalveSelectedStats: ; 3ed02 (f:6d02)
 	callab DoubleSelectedStats
-	ld hl, HalveSelectedStats
-	ld b, BANK(HalveSelectedStats)
-	jp Bankswitch
+	jpab HalveSelectedStats
 
 ScrollTrainerPicAfterBattle: ; 3ed12 (f:6d12)
-	ld hl, _ScrollTrainerPicAfterBattle
-	ld b, BANK(_ScrollTrainerPicAfterBattle)
-	jp Bankswitch
+	jpab _ScrollTrainerPicAfterBattle
 
 ApplyBurnAndParalysisPenaltiesToPlayer: ; 3ed1a (f:6d1a)
 	ld a, $1
@@ -6967,7 +6957,7 @@
 	ld [wLetterPrintingDelayFlags], a
 	pop af
 	ld [wMapPalOffset], a
-	ld a, [wd0d4]
+	ld a, [wSavedTilesetType]
 	ld [hTilesetType], a
 	scf
 	ret
@@ -7372,9 +7362,7 @@
 	db "@"
 
 DrainHPEffect: ; 3f2e9 (f:72e9)
-	ld hl, DrainHPEffect_
-	ld b, BANK(DrainHPEffect_)
-	jp Bankswitch
+	jpab DrainHPEffect_
 
 ExplodeEffect: ; 3f2f1 (f:72f1)
 	ld hl, wBattleMonHP
@@ -8209,9 +8197,7 @@
 	ret
 
 OneHitKOEffect: ; 3f884 (f:7884)
-	ld hl, OneHitKOEffect_
-	ld b, BANK(OneHitKOEffect_)
-	jp Bankswitch
+	jpab OneHitKOEffect_
 
 ChargeEffect: ; 3f88c (f:788c)
 	ld hl, W_PLAYERBATTSTATUS1
@@ -8321,19 +8307,13 @@
 	ret
 
 MistEffect: ; 3f941 (f:7941)
-	ld hl, MistEffect_
-	ld b, BANK(MistEffect_)
-	jp Bankswitch
+	jpab MistEffect_
 
 FocusEnergyEffect: ; 3f949 (f:7949)
-	ld hl, FocusEnergyEffect_
-	ld b, BANK(FocusEnergyEffect_)
-	jp Bankswitch
+	jpab FocusEnergyEffect_
 
 RecoilEffect: ; 3f951 (f:7951)
-	ld hl, RecoilEffect_
-	ld b, BANK(RecoilEffect_)
-	jp Bankswitch
+	jpab RecoilEffect_
 
 ConfusionSideEffect: ; 3f959 (f:7959)
 	call BattleRandom
@@ -8387,14 +8367,10 @@
 	jp ConditionalPrintButItFailed
 
 ParalyzeEffect: ; 3f9b1 (f:79b1)
-	ld hl, ParalyzeEffect_
-	ld b, BANK(ParalyzeEffect_)
-	jp Bankswitch
+	jpab ParalyzeEffect_
 
 SubstituteEffect: ; 3f9b9 (f:79b9)
-	ld hl, SubstituteEffect_
-	ld b, BANK(SubstituteEffect_)
-	jp Bankswitch
+	jpab SubstituteEffect_
 
 HyperBeamEffect: ; 3f9c1 (f:79c1)
 	ld hl, W_PLAYERBATTSTATUS2
@@ -8505,9 +8481,7 @@
 	db "@"
 
 LeechSeedEffect: ; 3fa7c (f:7a7c)
-	ld hl, LeechSeedEffect_
-	ld b, BANK(LeechSeedEffect_)
-	jp Bankswitch
+	jpab LeechSeedEffect_
 
 SplashEffect: ; 3fa84 (f:7a84)
 	call PlayCurrentMoveAnimation
@@ -8601,34 +8575,22 @@
 	db "@"
 
 PayDayEffect: ; 3fb0e (f:7b0e)
-	ld hl, PayDayEffect_
-	ld b, BANK(PayDayEffect_)
-	jp Bankswitch
+	jpab PayDayEffect_
 
 ConversionEffect: ; 3fb16 (f:7b16)
-	ld hl, ConversionEffect_
-	ld b, BANK(ConversionEffect_)
-	jp Bankswitch
+	jpab ConversionEffect_
 
 HazeEffect: ; 3fb1e (f:7b1e)
-	ld hl, HazeEffect_
-	ld b, BANK(HazeEffect_)
-	jp Bankswitch
+	jpab HazeEffect_
 
 HealEffect: ; 3fb26 (f:7b26)
-	ld hl, HealEffect_
-	ld b, BANK(HealEffect_)
-	jp Bankswitch
+	jpab HealEffect_
 
 TransformEffect: ; 3fb2e (f:7b2e)
-	ld hl, TransformEffect_
-	ld b, BANK(TransformEffect_)
-	jp Bankswitch
+	jpab TransformEffect_
 
 ReflectLightScreenEffect: ; 3fb36 (f:7b36)
-	ld hl, ReflectLightScreenEffect_
-	ld b, BANK(ReflectLightScreenEffect_)
-	jp Bankswitch
+	jpab ReflectLightScreenEffect_
 
 NothingHappenedText: ; 3fb3e (f:7b3e)
 	TX_FAR _NothingHappenedText
--- a/engine/battle/experience.asm
+++ b/engine/battle/experience.asm
@@ -15,7 +15,7 @@
 	ld hl, wPartyGainExpFlags
 	ld a, [wWhichPokemon]
 	ld c, a
-	ld b, $2
+	ld b, FLAG_TEST
 	predef FlagActionPredef
 	ld a, c
 	and a ; is mon's gain exp flag set?
@@ -257,7 +257,7 @@
 	ld hl, wCanEvolveFlags
 	ld a, [wWhichPokemon]
 	ld c, a
-	ld b, $1
+	ld b, FLAG_SET
 	predef FlagActionPredef
 	pop hl
 	pop af
@@ -281,7 +281,7 @@
 	ld [hl], a ; clear gain exp flags
 	ld a, [wPlayerMonNumber]
 	ld c, a
-	ld b, $1
+	ld b, FLAG_SET
 	push bc
 	predef FlagActionPredef ; set the gain exp flag for the mon that is currently out
 	ld hl, wPartyFoughtCurrentEnemyFlags
--- a/engine/battle/init_battle_variables.asm
+++ b/engine/battle/init_battle_variables.asm
@@ -1,6 +1,6 @@
 InitBattleVariables: ; 525af (14:65af)
 	ld a, [hTilesetType]
-	ld [wd0d4], a
+	ld [wSavedTilesetType], a
 	xor a
 	ld [wActionResultOrTookBattleTurn], a
 	ld [wBattleResult], a
@@ -35,6 +35,4 @@
 	ld a, $2 ; safari battle
 	ld [W_BATTLETYPE], a
 .notSafariBattle
-	ld hl, PlayBattleMusic
-	ld b, BANK(PlayBattleMusic)
-	jp Bankswitch
+	jpab PlayBattleMusic
--- a/engine/battle/moveEffects/focus_energy_effect.asm
+++ b/engine/battle/moveEffects/focus_energy_effect.asm
@@ -14,9 +14,7 @@
 .alreadyUsing
 	ld c, 50
 	call DelayFrames
-	ld hl, PrintButItFailedText_
-	ld b, BANK(PrintButItFailedText_)
-	jp Bankswitch
+	jpab PrintButItFailedText_
 
 GettingPumpedText: ; 27fb3 (9:7fb3)
 	db $0a
--- a/engine/battle/moveEffects/mist_effect.asm
+++ b/engine/battle/moveEffects/mist_effect.asm
@@ -12,9 +12,7 @@
 	ld hl, ShroudedInMistText
 	jp PrintText
 .mistAlreadyInUse
-	ld hl, PrintButItFailedText_
-	ld b, BANK(PrintButItFailedText_)
-	jp Bankswitch
+	jpab PrintButItFailedText_
 
 ShroudedInMistText: ; 33f52 (c:7f52)
 	TX_FAR _ShroudedInMistText
--- a/engine/battle/moveEffects/paralyze_effect.asm
+++ b/engine/battle/moveEffects/paralyze_effect.asm
@@ -36,18 +36,12 @@
 	ld c, 30
 	call DelayFrames
 	callab PlayCurrentMoveAnimation
-	ld hl, PrintMayNotAttackText
-	ld b, BANK(PrintMayNotAttackText)
-	jp Bankswitch
+	jpab PrintMayNotAttackText
 .didntAffect
 	ld c, 50
 	call DelayFrames
-	ld hl, PrintDidntAffectText
-	ld b, BANK(PrintDidntAffectText)
-	jp Bankswitch
+	jpab PrintDidntAffectText
 .doesntAffect
 	ld c, 50
 	call DelayFrames
-	ld hl, PrintDoesntAffectText
-	ld b, BANK(PrintDoesntAffectText)
-	jp Bankswitch
+	jpab PrintDoesntAffectText
--- a/engine/battle/moveEffects/substitute_effect.asm
+++ b/engine/battle/moveEffects/substitute_effect.asm
@@ -55,9 +55,7 @@
 	call Bankswitch ; jump to routine depending on animation setting
 	ld hl, SubstituteText
 	call PrintText
-	ld hl, DrawHUDsAndHPBars
-	ld b, BANK(DrawHUDsAndHPBars)
-	jp Bankswitch
+	jpab DrawHUDsAndHPBars
 .alreadyHasSubstitute
 	ld hl, HasSubstituteText
 	jr .printText
--- a/engine/evos_moves.asm
+++ b/engine/evos_moves.asm
@@ -5,7 +5,7 @@
 	ld [hl], a
 	ld a, [wWhichPokemon]
 	ld c, a
-	ld b, $1
+	ld b, FLAG_SET
 	call Evolution_FlagAction
 
 ; this is only called after battle
@@ -36,7 +36,7 @@
 	ld a, [wWhichPokemon]
 	ld c, a
 	ld hl, wCanEvolveFlags
-	ld b, $2
+	ld b, FLAG_TEST
 	call Evolution_FlagAction
 	ld a, c
 	and a ; is the mon's bit set?
@@ -217,7 +217,7 @@
 	ld a, [wd11e]
 	dec a
 	ld c, a
-	ld b, $1
+	ld b, FLAG_SET
 	ld hl, wPokedexOwned
 	push bc
 	call Evolution_FlagAction
--- a/engine/give_pokemon.asm
+++ b/engine/give_pokemon.asm
@@ -60,7 +60,7 @@
 	dec a
 	ld c, a
 	ld hl, wPokedexOwned
-	ld b, $1
+	ld b, FLAG_SET
 	predef FlagActionPredef
 	pop af
 	ld [wd11e], a
--- a/engine/hidden_object_functions3.asm
+++ b/engine/hidden_object_functions3.asm
@@ -34,9 +34,7 @@
 .noMatch
 	ld a, $ff
 	ld [$ffdb], a
-	ld b, BANK(PrintCardKeyText)
-	ld hl, PrintCardKeyText
-	jp Bankswitch
+	jpba PrintCardKeyText
 
 ; format: db tileset id, bookshelf tile id, text id
 BookshelfTileIDs: ; fb8b (3:7b8b)
--- a/engine/hidden_object_functions7.asm
+++ b/engine/hidden_object_functions7.asm
@@ -78,7 +78,7 @@
 	ld [H_DOWNARROWBLINKCNT2], a
 	call DisplayTextID
 	xor a
-	ld [wd528], a
+	ld [wPlayerMovingDirection], a
 	ld a, SAFARI_ZONE_ENTRANCE
 	ld [H_DOWNARROWBLINKCNT1], a
 	ld a, $3
@@ -209,7 +209,7 @@
 	call PrintText
 	ld a, [$ffe0]
 	ld c, a
-	ld b, $1
+	ld b, FLAG_SET
 	call CinnabarGymQuiz_1ea8a
 	jp CinnabarGymQuiz_1eb0a
 .asm_1eab8
@@ -222,7 +222,7 @@
 	ld a, [$ffdb]
 	add $2
 	ld c, a
-	ld b, $2
+	ld b, FLAG_TEST
 	ld hl, wd79a
 	predef FlagActionPredef
 	ld a, c
@@ -241,7 +241,7 @@
 
 	ld a, [$ffe0]
 	ld c, a
-	ld b, $2
+	ld b, FLAG_TEST
 	call CinnabarGymQuiz_1ea8a
 	ld a, c
 	and a
@@ -278,7 +278,7 @@
 	ld a, [$ffdb]
 	ld [$ffe0], a
 	ld c, a
-	ld b, $2
+	ld b, FLAG_TEST
 	call CinnabarGymQuiz_1ea8a
 	ld a, c
 	and a
--- a/engine/in_game_trades.asm
+++ b/engine/in_game_trades.asm
@@ -38,7 +38,7 @@
 	ld hl,wCompletedInGameTradeFlags
 	ld a,[wWhichTrade]
 	ld c,a
-	ld b,$2
+	ld b,FLAG_TEST
 	predef FlagActionPredef
 	ld a,c
 	and a
@@ -112,7 +112,7 @@
 	ld hl,wCompletedInGameTradeFlags
 	ld a,[wWhichTrade]
 	ld c,a
-	ld b,$1
+	ld b,FLAG_SET
 	predef FlagActionPredef
 	ld hl, ConnectCableText
 	call PrintText
@@ -159,9 +159,7 @@
 	call LoadGBPal
 	ld c, 10
 	call DelayFrames
-	ld b, BANK(LoadWildData)
-	ld hl, LoadWildData
-	jp Bankswitch
+	jpba LoadWildData
 
 InGameTrade_PrepareTradeData: ; 71cc1 (1c:5cc1)
 	ld hl, wTradedPlayerMonSpecies
--- a/engine/items/itemfinder.asm
+++ b/engine/items/itemfinder.asm
@@ -10,7 +10,7 @@
 	push hl
 	ld hl, wObtainedHiddenItemsFlags
 	ld c, b
-	ld b, $2
+	ld b, FLAG_TEST
 	predef FlagActionPredef
 	ld a, c
 	pop hl
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -400,8 +400,8 @@
 	ld a,[wd11e]
 	dec a
 	ld c,a
-	ld b,2
-	ld hl,wPokedexOwned	;Dex_own_flags (pokemon)
+	ld b,FLAG_TEST
+	ld hl,wPokedexOwned
 	predef FlagActionPredef
 	ld a,c
 	push af
@@ -408,7 +408,7 @@
 	ld a,[wd11e]
 	dec a
 	ld c,a
-	ld b,1
+	ld b,FLAG_SET
 	predef FlagActionPredef
 	pop af
 	and a
@@ -499,9 +499,7 @@
 	ld a,[W_ISINBATTLE]
 	and a
 	jp nz,ItemUseNotTime
-	ld b, BANK(DisplayTownMap)
-	ld hl, DisplayTownMap
-	jp Bankswitch ; display Town Map
+	jpba DisplayTownMap
 
 ItemUseBicycle: ; d977 (3:5977)
 	ld a,[W_ISINBATTLE]
@@ -593,14 +591,14 @@
 	jp LoadWalkingPlayerSpriteGraphics
 ; uses a simulated button press to make the player move forward
 .makePlayerMoveForward
-	ld a,[wd52a] ; direction the player is going
-	bit 3,a
+	ld a,[wPlayerDirection] ; direction the player is going
+	bit PLAYER_DIR_BIT_UP,a
 	ld b,D_UP
 	jr nz,.storeSimulatedButtonPress
-	bit 2,a
+	bit PLAYER_DIR_BIT_DOWN,a
 	ld b,D_DOWN
 	jr nz,.storeSimulatedButtonPress
-	bit 1,a
+	bit PLAYER_DIR_BIT_LEFT,a
 	ld b,D_LEFT
 	jr nz,.storeSimulatedButtonPress
 	ld b,D_RIGHT
@@ -806,7 +804,7 @@
 	ld a,[wUsedItemOnWhichPokemon]
 	ld c,a
 	ld hl,wPartyFoughtCurrentEnemyFlags
-	ld b,$02
+	ld b,FLAG_TEST
 	predef FlagActionPredef
 	ld a,c
 	and a
@@ -814,7 +812,7 @@
 	ld a,[wUsedItemOnWhichPokemon]
 	ld c,a
 	ld hl,wPartyGainExpFlags
-	ld b,$01
+	ld b,FLAG_SET
 	predef FlagActionPredef
 .next
 	pop bc
@@ -2552,8 +2550,8 @@
 	dec a
 	ld c,a
 	ld hl,wHPBarMaxHP
-	ld b,$02 ; test bit
-	predef FlagActionPredef ; bitfield operation function
+	ld b,FLAG_TEST
+	predef FlagActionPredef
 	ld a,c
 	and a
 	ret nz
--- a/engine/items/tms.asm
+++ b/engine/items/tms.asm
@@ -17,7 +17,7 @@
 	jr .findTMloop
 .TMfoundLoop
 	pop hl
-	ld b, $2  ; read corresponding bit from TM compatibility array
+	ld b, FLAG_TEST
 	predef_jump FlagActionPredef
 
 ; converts TM/HM number in wd11e into move number
--- a/engine/menu/league_pc.asm
+++ b/engine/menu/league_pc.asm
@@ -110,9 +110,7 @@
 	ld de, wHoFTeamNo
 	ld bc, $0103
 	call PrintNumber
-	ld b, BANK(HoFDisplayMonInfo)
-	ld hl, HoFDisplayMonInfo
-	jp Bankswitch
+	jpba HoFDisplayMonInfo
 
 HallOfFameNoText: ; 76670 (1d:6670)
 	db "HALL OF FAME No   @"
--- a/engine/menu/main_menu.asm
+++ b/engine/menu/main_menu.asm
@@ -107,8 +107,8 @@
 .pressedA
 	call GBPalWhiteOutWithDelay3
 	call ClearScreen
-	ld a,4
-	ld [wd52a],a
+	ld a,PLAYER_DIR_DOWN
+	ld [wPlayerDirection],a
 	ld c,10
 	call DelayFrames
 	ld a,[wNumHoFTeams]
--- a/engine/menu/naming_screen.asm
+++ b/engine/menu/naming_screen.asm
@@ -172,9 +172,7 @@
 	ld a, [W_ISINBATTLE]
 	and a
 	jp z, LoadTextBoxTilePatterns
-	ld hl, LoadHudTilePatterns
-	ld b, BANK(LoadHudTilePatterns)
-	jp Bankswitch
+	jpab LoadHudTilePatterns
 
 .namingScreenButtonFunctions
 	dw .dPadReturnPoint
--- a/engine/menu/pokedex.asm
+++ b/engine/menu/pokedex.asm
@@ -379,7 +379,7 @@
 	ld a,[wd11e]
 	dec a
 	ld c,a
-	ld b,2
+	ld b,FLAG_TEST
 	predef FlagActionPredef
 	ld a,c
 	and a
--- a/engine/menu/prize_menu.asm
+++ b/engine/menu/prize_menu.asm
@@ -179,7 +179,7 @@
 	ld hl,wd141 ; first prize's price
 	add hl,de ; get selected prize's price
 	xor a
-	ld [hCoins - 1],a
+	ld [hUnusedCoinsByte],a
 	ld a,[hli]
 	ld [hCoins],a
 	ld a,[hl]
--- a/engine/overworld/cable_club_npc.asm
+++ b/engine/overworld/cable_club_npc.asm
@@ -111,9 +111,7 @@
 	xor a
 	ld [hld], a
 	ld [hl], a
-	ld hl, LinkMenu
-	ld b, BANK(LinkMenu)
-	jp Bankswitch
+	jpab LinkMenu
 
 CableClubNPCAreaReservedFor2FriendsLinkedByCableText: ; 72b3 (1:72b3)
 	TX_FAR _CableClubNPCAreaReservedFor2FriendsLinkedByCableText
--- a/engine/overworld/hidden_items.asm
+++ b/engine/overworld/hidden_items.asm
@@ -5,7 +5,7 @@
 	ld hl, wObtainedHiddenItemsFlags
 	ld a, [wHiddenItemOrCoinsIndex]
 	ld c, a
-	ld b, $2
+	ld b, FLAG_TEST
 	predef FlagActionPredef
 	ld a, c
 	and a
@@ -31,7 +31,7 @@
 	ld hl, wObtainedHiddenItemsFlags
 	ld a, [wTrainerScreenX]
 	ld c, a
-	ld b, $1
+	ld b, FLAG_SET
 	predef FlagActionPredef
 	ld a, SFX_GET_ITEM_2
 	call PlaySoundWaitForCurrent
@@ -61,13 +61,13 @@
 	ld hl, wObtainedHiddenCoinsFlags
 	ld a, [wHiddenItemOrCoinsIndex]
 	ld c, a
-	ld b, $2
+	ld b, FLAG_TEST
 	predef FlagActionPredef
 	ld a, c
 	and a
 	ret nz
 	xor a
-	ld [hCoins - 1], a
+	ld [hUnusedCoinsByte], a
 	ld [hCoins], a
 	ld [hCoins + 1], a
 	ld a, [wHiddenObjectFunctionArgument]
@@ -102,7 +102,7 @@
 	ld hl, wObtainedHiddenCoinsFlags
 	ld a, [wTrainerScreenX]
 	ld c, a
-	ld b, $1
+	ld b, FLAG_SET
 	predef FlagActionPredef
 	call EnableAutoTextBoxDrawing
 	ld a, [wPlayerCoins]
--- a/engine/overworld/movement.asm
+++ b/engine/overworld/movement.asm
@@ -25,24 +25,24 @@
 	ld a, [wWalkCounter]
 	and a
 	jr nz, .moving
-	ld a, [wd528]
+	ld a, [wPlayerMovingDirection]
 ; check if down
-	bit 2, a
+	bit PLAYER_DIR_BIT_DOWN, a
 	jr z, .checkIfUp
 	xor a ; ld a, SPRITE_FACING_DOWN
 	jr .next
 .checkIfUp
-	bit 3, a
+	bit PLAYER_DIR_BIT_UP, a
 	jr z, .checkIfLeft
 	ld a, SPRITE_FACING_UP
 	jr .next
 .checkIfLeft
-	bit 1, a
+	bit PLAYER_DIR_BIT_LEFT, a
 	jr z, .checkIfRight
 	ld a, SPRITE_FACING_LEFT
 	jr .next
 .checkIfRight
-	bit 0, a
+	bit PLAYER_DIR_BIT_RIGHT, a
 	jr z, .notMoving
 	ld a, SPRITE_FACING_RIGHT
 	jr .next
@@ -405,23 +405,23 @@
 	bit 5, a
 	jr nz, notYetMoving
 	res 7, [hl]
-	ld a, [wd52a]
-	bit 3, a
+	ld a, [wPlayerDirection]
+	bit PLAYER_DIR_BIT_UP, a
 	jr z, .notFacingDown
-	ld c, $0                ; make sprite face down
+	ld c, SPRITE_FACING_DOWN
 	jr .facingDirectionDetermined
 .notFacingDown
-	bit 2, a
+	bit PLAYER_DIR_BIT_DOWN, a
 	jr z, .notFacingUp
-	ld c, $4                ; make sprite face up
+	ld c, SPRITE_FACING_UP
 	jr .facingDirectionDetermined
 .notFacingUp
-	bit 1, a
+	bit PLAYER_DIR_BIT_LEFT, a
 	jr z, .notFacingRight
-	ld c, $c                ; make sprite face right
+	ld c, SPRITE_FACING_RIGHT
 	jr .facingDirectionDetermined
 .notFacingRight
-	ld c, $8                ; make sprite face left
+	ld c, SPRITE_FACING_LEFT
 .facingDirectionDetermined
 	ld a, [H_CURRENTSPRITEOFFSET]
 	add $9
--- a/engine/overworld/saffron_guards.asm
+++ b/engine/overworld/saffron_guards.asm
@@ -10,9 +10,7 @@
 	call IsItemInBag
 	pop hl
 	jr z, .drinkLoop
-	ld b, BANK(RemoveItemByID)
-	ld hl, RemoveItemByID
-	jp Bankswitch
+	jpba RemoveItemByID
 
 GuardDrinksList: ; 5a5b7 (16:65b7)
 	db FRESH_WATER, SODA_POP, LEMONADE, $00
--- a/engine/titlescreen.asm
+++ b/engine/titlescreen.asm
@@ -262,9 +262,7 @@
 	jp MainMenu
 
 .doClearSaveDialogue
-	ld b, BANK(DoClearSaveDialogue)
-	ld hl, DoClearSaveDialogue
-	jp Bankswitch
+	jpba DoClearSaveDialogue
 
 TitleScreenPickNewMon: ; 4496 (1:4496)
 	ld a, vBGMap0 / $100
--- a/engine/trade.asm
+++ b/engine/trade.asm
@@ -199,9 +199,7 @@
 Trade_LoadMonPartySpriteGfx: ; 4120b (10:520b)
 	ld a, %11010000
 	ld [rOBP1], a
-	ld b, BANK(LoadMonPartySpriteGfx)
-	ld hl, LoadMonPartySpriteGfx
-	jp Bankswitch
+	jpba LoadMonPartySpriteGfx
 
 Trade_SwapNames: ; 41217 (10:5217)
 	ld hl, wPlayerName
--- a/home.asm
+++ b/home.asm
@@ -253,9 +253,7 @@
 ; wLoadedMon = base address of pokemon data
 ; W_MONHDEXNUM = base address of base stats
 LoadMonData:: ; 1372 (0:1372)
-	ld hl, LoadMonData_
-	ld b, BANK(LoadMonData_)
-	jp Bankswitch
+	jpab LoadMonData_
 
 
 OverwritewMoves:: ; 137a (0:137a)
@@ -1317,9 +1315,7 @@
 ; subtracts the amount the player paid from their money
 ; sets carry flag if there is enough money and unsets carry flag if not
 SubtractAmountPaidFromMoney:: ; 2b96 (0:2b96)
-	ld b,BANK(SubtractAmountPaidFromMoney_)
-	ld hl,SubtractAmountPaidFromMoney_
-	jp Bankswitch
+	jpba SubtractAmountPaidFromMoney_
 
 ; adds the amount the player sold to their money
 AddAmountSoldToMoney:: ; 2b9e (0:2b9e)
@@ -2077,9 +2073,7 @@
 ChooseFlyDestination:: ; 30a9 (0:30a9)
 	ld hl,wd72e
 	res 4,[hl]
-	ld b, BANK(LoadTownMap_Fly)
-	ld hl, LoadTownMap_Fly
-	jp Bankswitch
+	jpba LoadTownMap_Fly
 
 ; causes the text box to close without waiting for a button press after displaying text
 DisableWaitingAfterTextDisplay:: ; 30b6 (0:30b6)
@@ -2097,9 +2091,7 @@
 ; 01: successful
 ; 02: not able to be used right now, no extra menu displayed (only certain items use this)
 UseItem:: ; 30bc (0:30bc)
-	ld b,BANK(UseItem_)
-	ld hl,UseItem_
-	jp Bankswitch
+	jpba UseItem_
 
 ; confirms the item toss and then tosses the item
 ; INPUT:
@@ -2201,14 +2193,10 @@
 	dw PewterMuseumGuyMovementScriptPointerTable
 	dw PewterGymGuyMovementScriptPointerTable
 .playerStepOutFromDoor
-	ld b, BANK(PlayerStepOutFromDoor)
-	ld hl, PlayerStepOutFromDoor
-	jp Bankswitch
+	jpba PlayerStepOutFromDoor
 
 EndNPCMovementScript:: ; 314e (0:314e)
-	ld b, BANK(_EndNPCMovementScript)
-	ld hl, _EndNPCMovementScript
-	jp Bankswitch
+	jpba _EndNPCMovementScript
 
 EmptyFunc2:: ; 3156 (0:3156)
 	ret
@@ -2309,7 +2297,7 @@
 	call ReadTrainerHeaderInfo     ; read flag's byte ptr
 	ld a, [wTrainerHeaderFlagBit]
 	ld c, a
-	ld b, $2
+	ld b, FLAG_TEST
 	call TrainerFlagAction      ; read trainer's flag
 	ld a, c
 	and a
@@ -2404,7 +2392,7 @@
 	call ReadTrainerHeaderInfo
 	ld a, [wTrainerHeaderFlagBit]
 	ld c, a
-	ld b, $1
+	ld b, FLAG_SET
 	call TrainerFlagAction   ; flag trainer as fought
 	ld a, [W_ENEMYMONORTRAINERCLASS]
 	cp $c8
@@ -2434,9 +2422,7 @@
 
 ; calls TrainerWalkUpToPlayer
 TrainerWalkUpToPlayer_Bank0:: ; 32cf (0:32cf)
-	ld b, BANK(TrainerWalkUpToPlayer)
-	ld hl, TrainerWalkUpToPlayer
-	jp Bankswitch
+	jpba TrainerWalkUpToPlayer
 
 ; sets opponent type and mon set/lvl based on the engaging trainer data
 InitBattleEnemyParameters:: ; 32d7 (0:32d7)
@@ -2484,7 +2470,7 @@
 	ret z
 	ld a, $2
 	call ReadTrainerHeaderInfo       ; read trainer flag's byte ptr
-	ld b, $2
+	ld b, FLAG_TEST
 	ld a, [wTrainerHeaderFlagBit]
 	ld c, a
 	call TrainerFlagAction        ; read trainer flag
@@ -2726,9 +2712,7 @@
 
 DisplayPokedex:: ; 349b (0:349b)
 	ld [wd11e], a
-	ld b, BANK(_DisplayPokedex)
-	ld hl, _DisplayPokedex
-	jp Bankswitch
+	jpba _DisplayPokedex
 
 SetSpriteFacingDirectionAndDelay:: ; 34a6 (0:34a6)
 	call SetSpriteFacingDirection
@@ -2937,9 +2921,7 @@
 	ret
 
 GetTrainerName:: ; 359e (0:359e)
-	ld b, BANK(GetTrainerName_)
-	ld hl, GetTrainerName_
-	jp Bankswitch
+	jpba GetTrainerName_
 
 
 HasEnoughMoney::
@@ -3604,9 +3586,7 @@
 ; [wRemoveMonFromBox] == 0 specifies the party.
 ; [wRemoveMonFromBox] != 0 specifies the current box.
 RemovePokemon:: ; 391f (0:391f)
-	ld hl, _RemovePokemon
-	ld b, BANK(_RemovePokemon)
-	jp Bankswitch
+	jpab _RemovePokemon
 
 AddPartyMon:: ; 3927 (0:3927)
 	push hl
@@ -4590,9 +4570,7 @@
 	ld [W_CURENEMYLVL], a
 	xor a ; PLAYER_PARTY_DATA
 	ld [wMonDataLocation], a
-	ld b, BANK(_GivePokemon)
-	ld hl, _GivePokemon
-	jp Bankswitch
+	jpba _GivePokemon
 
 
 Random::
@@ -4613,9 +4591,7 @@
 
 
 Func_3ead:: ; 3ead (0:3ead)
-	ld b, BANK(CinnabarGymQuiz_1eb0a)
-	ld hl, CinnabarGymQuiz_1eb0a
-	jp Bankswitch
+	jpba CinnabarGymQuiz_1eb0a
 
 CheckForHiddenObjectOrBookshelfOrCardKeyDoor:: ; 3eb5 (0:3eb5)
 	ld a, [H_LOADEDROMBANK]
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -1,9 +1,7 @@
 HandleMidJump::
 ; Handle the player jumping down
 ; a ledge in the overworld.
-	ld b, BANK(_HandleMidJump)
-	ld hl, _HandleMidJump
-	jp Bankswitch
+	jpba _HandleMidJump
 
 EnterMap::
 ; Load a new map.
@@ -136,43 +134,43 @@
 	call UpdateSprites
 	ld a,$01
 	ld [wcc4b],a
-	ld a,[wd528] ; the direction that was pressed last time
+	ld a,[wPlayerMovingDirection] ; the direction that was pressed last time
 	and a
 	jp z,OverworldLoop
 ; if a direction was pressed last time
-	ld [wd529],a ; save the last direction
+	ld [wPlayerLastStopDirection],a ; save the last direction
 	xor a
-	ld [wd528],a ; zero the direction
+	ld [wPlayerMovingDirection],a ; zero the direction
 	jp OverworldLoop
 .checkIfDownButtonIsPressed
 	ld a,[hJoyHeld] ; current joypad state
 	bit 7,a ; down button
 	jr z,.checkIfUpButtonIsPressed
-	ld a,$01
-	ld [wSpriteStateData1 + 3],a
-	ld a,$04
+	ld a,1
+	ld [wSpriteStateData1 + 3],a ; delta Y
+	ld a,PLAYER_DIR_DOWN
 	jr .handleDirectionButtonPress
 .checkIfUpButtonIsPressed
 	bit 6,a ; up button
 	jr z,.checkIfLeftButtonIsPressed
-	ld a,$ff
-	ld [wSpriteStateData1 + 3],a
-	ld a,$08
+	ld a,-1
+	ld [wSpriteStateData1 + 3],a ; delta Y
+	ld a,PLAYER_DIR_UP
 	jr .handleDirectionButtonPress
 .checkIfLeftButtonIsPressed
 	bit 5,a ; left button
 	jr z,.checkIfRightButtonIsPressed
-	ld a,$ff
-	ld [wSpriteStateData1 + 5],a
-	ld a,$02
+	ld a,-1
+	ld [wSpriteStateData1 + 5],a ; delta X
+	ld a,PLAYER_DIR_LEFT
 	jr .handleDirectionButtonPress
 .checkIfRightButtonIsPressed
 	bit 4,a ; right button
 	jr z,.noDirectionButtonsPressed
-	ld a,$01
-	ld [wSpriteStateData1 + 5],a
+	ld a,1 ; PLAYER_DIR_RIGHT
+	ld [wSpriteStateData1 + 5],a ; delta X
 .handleDirectionButtonPress
-	ld [wd52a],a ; new direction
+	ld [wPlayerDirection],a ; new direction
 	ld a,[wd730]
 	bit 7,a ; are we simulating button presses?
 	jr nz,.noDirectionChange ; ignore direction changes if we are
@@ -179,9 +177,9 @@
 	ld a,[wcc4b]
 	and a
 	jr z,.noDirectionChange
-	ld a,[wd52a] ; new direction
+	ld a,[wPlayerDirection] ; new direction
 	ld b,a
-	ld a,[wd529] ; old direction
+	ld a,[wPlayerLastStopDirection] ; old direction
 	cp b
 	jr z,.noDirectionChange
 ; the code below is strange
@@ -189,28 +187,28 @@
 ; also, it does a seemingly pointless loop afterwards
 	swap a ; put old direction in upper half
 	or b ; put new direction in lower half
-	cp a,$48 ; change dir from down to up
+	cp a,(PLAYER_DIR_DOWN << 4) | PLAYER_DIR_UP ; change dir from down to up
 	jr nz,.notDownToUp
-	ld a,$02
-	ld [wd528],a
+	ld a,PLAYER_DIR_LEFT
+	ld [wPlayerMovingDirection],a
 	jr .oddLoop
 .notDownToUp
-	cp a,$84 ; change dir from up to down
+	cp a,(PLAYER_DIR_UP << 4) | PLAYER_DIR_DOWN ; change dir from up to down
 	jr nz,.notUpToDown
-	ld a,$01
-	ld [wd528],a
+	ld a,PLAYER_DIR_RIGHT
+	ld [wPlayerMovingDirection],a
 	jr .oddLoop
 .notUpToDown
-	cp a,$12 ; change dir from right to left
+	cp a,(PLAYER_DIR_RIGHT << 4) | PLAYER_DIR_LEFT ; change dir from right to left
 	jr nz,.notRightToLeft
-	ld a,$04
-	ld [wd528],a
+	ld a,PLAYER_DIR_DOWN
+	ld [wPlayerMovingDirection],a
 	jr .oddLoop
 .notRightToLeft
-	cp a,$21 ; change dir from left to right
+	cp a,(PLAYER_DIR_LEFT << 4) | PLAYER_DIR_RIGHT ; change dir from left to right
 	jr nz,.oddLoop
-	ld a,$08
-	ld [wd528],a
+	ld a,PLAYER_DIR_UP
+	ld [wPlayerMovingDirection],a
 .oddLoop
 	ld hl,wFlags_0xcd60
 	set 2,[hl]
@@ -217,14 +215,14 @@
 	ld hl,wcc4b
 	dec [hl]
 	jr nz,.oddLoop
-	ld a,[wd52a]
-	ld [wd528],a
+	ld a,[wPlayerDirection]
+	ld [wPlayerMovingDirection],a
 	call NewBattle
 	jp c,.battleOccurred
 	jp OverworldLoop
 .noDirectionChange
-	ld a,[wd52a] ; current direction
-	ld [wd528],a ; save direction
+	ld a,[wPlayerDirection] ; current direction
+	ld [wPlayerMovingDirection],a ; save direction
 	call UpdateSprites
 	ld a,[wWalkBikeSurfState]
 	cp a,$02 ; surfing
@@ -355,9 +353,7 @@
 	ld a,[wd72e]
 	bit 4,a
 	jr nz,.noBattle
-	ld b, BANK(InitBattle)
-	ld hl, InitBattle
-	jp Bankswitch
+	jpba InitBattle
 .noBattle
 	and a
 	ret
@@ -570,7 +566,7 @@
 	jp .loadNewMap
 .checkEastMap
 	ld b,a
-	ld a,[wd525] ; map width
+	ld a,[wCurrentMapWidth2] ; map width
 	cp b
 	jr nz,.checkNorthMap
 	ld a,[W_MAPCONN4PTR]
@@ -632,7 +628,7 @@
 	jp .loadNewMap
 .checkSouthMap
 	ld b,a
-	ld a,[wd524]
+	ld a,[wCurrentMapHeight2]
 	cp b
 	jr nz,.didNotEnterConnectedMap
 	ld a,[W_MAPCONN2PTR]
@@ -783,9 +779,7 @@
 	jp SpecialEnterMap
 
 LeaveMapAnim::
-	ld b, BANK(_LeaveMapAnim)
-	ld hl, _LeaveMapAnim
-	jp Bankswitch
+	jpba _LeaveMapAnim
 
 LoadPlayerSpriteGraphics::
 ; Load sprite graphics based on whether the player is standing, biking, or surfing.
@@ -870,7 +864,7 @@
 LoadTileBlockMap:: ; 09fc (0:09fc)
 ; fill C6E8-CBFB with the background tile
 	ld hl,wOverworldMap
-	ld a,[wd3ad] ; background tile number
+	ld a,[wMapBackgroundTile]
 	ld d,a
 	ld bc,$0514
 .backgroundTileLoop
@@ -1063,15 +1057,15 @@
 IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23)
 	xor a
 	ld [hSpriteIndexOrTextID],a
-	ld a,[wd4b0] ; number of signs in the map
+	ld a,[wNumSigns]
 	and a
 	jr z,.extendRangeOverCounter
 ; if there are signs
 	predef GetTileAndCoordsInFrontOfPlayer ; get the coordinates in front of the player in de
-	ld hl,wd4b1 ; start of sign coordinates
-	ld a,[wd4b0] ; number of signs in the map
+	ld hl,wSignCoords
+	ld a,[wNumSigns]
 	ld b,a
-	ld c,$00
+	ld c,0
 .signLoop
 	inc c
 	ld a,[hli] ; sign Y
@@ -1087,8 +1081,8 @@
 ; found sign
 	push hl
 	push bc
-	ld hl,wd4d1 ; start of sign text ID's
-	ld b,$00
+	ld hl,wSignTextIDs
+	ld b,0
 	dec c
 	add hl,bc
 	ld a,[hl]
@@ -1103,7 +1097,7 @@
 .extendRangeOverCounter
 	predef GetTileAndCoordsInFrontOfPlayer ; get the tile in front of the player in c
 	ld hl,W_TILESETTALKINGOVERTILES ; list of tiles that extend talking range (counter tiles)
-	ld b,$03
+	ld b,3
 	ld d,$20 ; talking range in pixels (long range)
 .counterTilesLoop
 	ld a,[hli]
@@ -1117,7 +1111,7 @@
 IsSpriteInFrontOfPlayer:: ; 0b6b (0:0b6b)
 	ld d,$10 ; talking range in pixels (normal range)
 IsSpriteInFrontOfPlayer2:: ; 0b6d (0:0b6d)
-	ld bc,$3c40 ; Y and X position of player sprite
+	lb bc, $3c, $40 ; Y and X position of player sprite
 	ld a,[wSpriteStateData1 + 9] ; direction the player is facing
 .checkIfPlayerFacingUp
 	cp SPRITE_FACING_UP
@@ -1126,7 +1120,7 @@
 	ld a,b
 	sub d
 	ld b,a
-	ld a,$08
+	ld a,PLAYER_DIR_UP
 	jr .doneCheckingDirection
 .checkIfPlayerFacingDown
 	cp SPRITE_FACING_DOWN
@@ -1135,7 +1129,7 @@
 	ld a,b
 	add d
 	ld b,a
-	ld a,$04
+	ld a,PLAYER_DIR_DOWN
 	jr .doneCheckingDirection
 .checkIfPlayerFacingRight
 	cp SPRITE_FACING_RIGHT
@@ -1144,7 +1138,7 @@
 	ld a,c
 	add d
 	ld c,a
-	ld a,$01
+	ld a,PLAYER_DIR_RIGHT
 	jr .doneCheckingDirection
 .playerFacingLeft
 ; facing left
@@ -1151,9 +1145,9 @@
 	ld a,c
 	sub d
 	ld c,a
-	ld a,$02
+	ld a,PLAYER_DIR_LEFT
 .doneCheckingDirection
-	ld [wd52a],a
+	ld [wPlayerDirection],a
 	ld a,[W_NUMSPRITES] ; number of sprites
 	and a
 	ret z
@@ -1208,7 +1202,7 @@
 	ld a,[wSimulatedJoypadStatesIndex]
 	and a
 	jr nz,.noCollision ; no collisions when the player's movements are being controlled by the game
-	ld a,[wd52a] ; the direction that the player is trying to go in
+	ld a,[wPlayerDirection] ; the direction that the player is trying to go in
 	ld d,a
 	ld a,[wSpriteStateData1 + 12] ; the player sprite's collision data (bit field) (set in the sprite movement code)
 	and d ; check if a sprite is in the direction the player is trying to go
@@ -1899,7 +1893,7 @@
 	ld a,[wd730]
 	bit 7,a
 	jp nz,.noCollision ; return and clear carry if button presses are being simulated
-	ld a,[wd52a] ; the direction that the player is trying to go in
+	ld a,[wPlayerDirection] ; the direction that the player is trying to go in
 	ld d,a
 	ld a,[wSpriteStateData1 + 12] ; the player sprite's collision data (bit field) (set in the sprite movement code)
 	and d ; check if a sprite is in the direction the player is trying to go
@@ -2079,17 +2073,17 @@
 	call CopyMapConnectionHeader
 .getObjectDataPointer
 	ld a,[hli]
-	ld [wd3a9],a
+	ld [wObjectDataPointerTemp],a
 	ld a,[hli]
-	ld [wd3aa],a
+	ld [wObjectDataPointerTemp + 1],a
 	push hl
-	ld a,[wd3a9]
+	ld a,[wObjectDataPointerTemp]
 	ld l,a
-	ld a,[wd3aa]
+	ld a,[wObjectDataPointerTemp + 1]
 	ld h,a ; hl = base of object data
-	ld de,wd3ad ; background tile ID
+	ld de,wMapBackgroundTile
 	ld a,[hli]
-	ld [de],a ; save background tile ID
+	ld [de],a
 .loadWarpData
 	ld a,[hli]
 	ld [wNumberOfWarps],a
@@ -2109,16 +2103,16 @@
 	jr nz,.warpLoop
 .loadSignData
 	ld a,[hli] ; number of signs
-	ld [wd4b0],a ; save the number of signs
+	ld [wNumSigns],a
 	and a ; are there any signs?
 	jr z,.loadSpriteData ; if not, skip this
 	ld c,a
-	ld de,wd4d1 ; base address of sign text IDs
+	ld de,wSignTextIDs
 	ld a,d
-	ld [$ff95],a
+	ld [hSignCoordPointer],a
 	ld a,e
-	ld [$ff96],a
-	ld de,wd4b1 ; base address of sign coordinates
+	ld [hSignCoordPointer + 1],a
+	ld de,wSignCoords
 .signLoop
 	ld a,[hli]
 	ld [de],a
@@ -2127,17 +2121,17 @@
 	ld [de],a
 	inc de
 	push de
-	ld a,[$ff95]
+	ld a,[hSignCoordPointer]
 	ld d,a
-	ld a,[$ff96]
+	ld a,[hSignCoordPointer + 1]
 	ld e,a
 	ld a,[hli]
 	ld [de],a
 	inc de
 	ld a,d
-	ld [$ff95],a
+	ld [hSignCoordPointer],a
 	ld a,e
-	ld [$ff96],a
+	ld [hSignCoordPointer + 1],a
 	pop de
 	dec c
 	jr nz,.signLoop
@@ -2265,10 +2259,10 @@
 	pop hl ; restore hl from before going to the warp/sign/sprite data (this value was saved for seemingly no purpose)
 	ld a,[W_CURMAPHEIGHT] ; map height in 4x4 tile blocks
 	add a ; double it
-	ld [wd524],a ; store map height in 2x2 tile blocks
+	ld [wCurrentMapHeight2],a ; store map height in 2x2 tile blocks
 	ld a,[W_CURMAPWIDTH] ; map width in 4x4 tile blocks
 	add a ; double it
-	ld [wd525],a ; map width in 2x2 tile blocks
+	ld [wCurrentMapWidth2],a ; map width in 2x2 tile blocks
 	ld a,[W_CURMAP]
 	ld c,a
 	ld b,$00
--- a/hram.asm
+++ b/hram.asm
@@ -82,6 +82,9 @@
 
 hSpritePriority EQU $FF94
 
+; 2 bytes
+hSignCoordPointer EQU $FF95
+
 hNPCMovementDirections2Index EQU $FF95
 
 ; CalcPositionOfPlayerRelativeToNPC
@@ -136,6 +139,9 @@
 ; 0 = target is to the east or aligned
 ; 1 = target is to the west
 hNPCPlayerRelativePosFlags EQU $FF9D
+
+; some code zeroes this for no reason when writing a coin amount
+hUnusedCoinsByte EQU $FF9F
 
 hMoney EQU $FF9F ; 3-byte BCD number
 hCoins EQU $FFA0 ; 2-byte BCD number
--- a/macros.asm
+++ b/macros.asm
@@ -53,6 +53,18 @@
 	call Bankswitch
 	ENDM
 
+jpba: MACRO
+	ld b, BANK(\1)
+	ld hl, \1
+	jp Bankswitch
+	ENDM
+
+jpab: MACRO
+	ld hl, \1
+	ld b, BANK(\1)
+	jp Bankswitch
+	ENDM
+
 bcd2: MACRO
     dn ((\1) / 1000) % 10, ((\1) / 100) % 10
     dn ((\1) / 10) % 10, (\1) % 10
--- a/main.asm
+++ b/main.asm
@@ -2038,7 +2038,7 @@
 	ld a, [wd11e]
 	dec a
 	ld c, a
-	ld b, $1
+	ld b, FLAG_SET
 	ld hl, wPokedexSeen
 	predef FlagActionPredef
 	ld a, $1
@@ -3235,7 +3235,7 @@
 	cp ROUTE_1
 	jr nc, .notInTown
 	ld c, a
-	ld b, $1
+	ld b, FLAG_SET
 	ld hl, W_TOWNVISITEDFLAG   ; mark town as visited (for flying)
 	predef FlagActionPredef
 .notInTown
@@ -3319,7 +3319,7 @@
 	ld hl, W_MISSABLEOBJECTFLAGS
 	ld a, [wd048]
 	ld c, a
-	ld b, $1
+	ld b, FLAG_SET
 	call MissableObjectFlagAction ; set flag iff Item is hidden
 .asm_f19d
 	ld hl, wd048
@@ -3343,7 +3343,7 @@
 	ld a, [hli]
 	jr nz, .loop
 	ld c, a
-	ld b, $2
+	ld b, FLAG_TEST
 	ld hl, W_MISSABLEOBJECTFLAGS
 	call MissableObjectFlagAction
 	ld a, c
@@ -3362,7 +3362,7 @@
 	ld hl, W_MISSABLEOBJECTFLAGS
 	ld a, [wcc4d]
 	ld c, a
-	ld b, $0
+	ld b, FLAG_RESET
 	call MissableObjectFlagAction   ; reset "removed" flag
 	jp UpdateSprites
 
@@ -3372,7 +3372,7 @@
 	ld hl, W_MISSABLEOBJECTFLAGS
 	ld a, [wcc4d]
 	ld c, a
-	ld b, $1
+	ld b, FLAG_SET
 	call MissableObjectFlagAction   ; set "removed" flag
 	jp UpdateSprites
 
@@ -3642,7 +3642,7 @@
 	ld a, [wd11e]
 	dec a
 	ld c, a
-	ld b, $2
+	ld b, FLAG_TEST
 	ld hl, wPokedexOwned
 	call FlagAction
 	ld a, c
@@ -3650,7 +3650,7 @@
 	ld a, [wd11e]
 	dec a
 	ld c, a
-	ld b, $1
+	ld b, FLAG_SET
 	push bc
 	call FlagAction
 	pop bc
@@ -3882,7 +3882,7 @@
 	ld a, [wd11e]
 	dec a
 	ld c, a
-	ld b, $1
+	ld b, FLAG_SET
 	ld hl, wPokedexOwned
 	push bc
 	call FlagAction ; add to owned pokemon
--- a/scripts/celadongamecorner.asm
+++ b/scripts/celadongamecorner.asm
@@ -170,7 +170,7 @@
 	ld c, $3
 	predef SubBCDPredef
 	xor a
-	ld [hCoins - 1], a
+	ld [hUnusedCoinsByte], a
 	ld [hCoins], a
 	ld a, $50
 	ld [hCoins + 1], a
@@ -238,7 +238,7 @@
 	call Has9990Coins
 	jr nc, .asm_48d8e
 	xor a
-	ld [hCoins - 1], a
+	ld [hUnusedCoinsByte], a
 	ld [hCoins], a
 	ld a, $10
 	ld [hCoins + 1], a
@@ -320,7 +320,7 @@
 	call Has9990Coins
 	jr nc, .asm_48e18
 	xor a
-	ld [hCoins - 1], a
+	ld [hUnusedCoinsByte], a
 	ld [hCoins], a
 	ld a, $20
 	ld [hCoins + 1], a
@@ -373,7 +373,7 @@
 	call Has9990Coins
 	jr z, .asm_48e7a
 	xor a
-	ld [hCoins - 1], a
+	ld [hUnusedCoinsByte], a
 	ld [hCoins], a
 	ld a, $20
 	ld [hCoins + 1], a
--- a/scripts/celadonmartelevator.asm
+++ b/scripts/celadonmartelevator.asm
@@ -55,9 +55,7 @@
 	db $02, CELADON_MART_5
 
 CeladonMartElevatorScript_48654: ; 48654 (12:4654)
-	ld b, BANK(ShakeElevator)
-	ld hl, ShakeElevator
-	jp Bankswitch
+	jpba ShakeElevator
 
 CeladonMartElevatorTextPointers: ; 4865c (12:465c)
 	dw CeladonMartElevatorText1
--- a/scripts/celadonmartroof.asm
+++ b/scripts/celadonmartroof.asm
@@ -135,9 +135,7 @@
 	jp PrintText
 
 RemoveItemByIDBank12: ; 484e6 (12:44e6)
-	ld b, BANK(RemoveItemByID)
-	ld hl, RemoveItemByID
-	jp Bankswitch
+	jpba RemoveItemByID
 
 CeladonMartRoofText_484ee: ; 484ee (12:44ee)
 	TX_FAR _CeladonMartRoofText_484ee
--- a/scripts/ceruleancity.asm
+++ b/scripts/ceruleancity.asm
@@ -44,15 +44,15 @@
 	jr nc, .asm_194f7
 	ld a, [wCoordIndex]
 	cp $1
-	ld a, $8
+	ld a, PLAYER_DIR_UP
 	ld b, SPRITE_FACING_DOWN
 	jr nz, .asm_194e6
-	ld a, $4
+	ld a, PLAYER_DIR_DOWN
 	ld b, SPRITE_FACING_UP
 .asm_194e6
-	ld [wd528], a
+	ld [wPlayerMovingDirection], a
 	ld a, b
-	ld [wSpriteStateData1 + $29], a
+	ld [wSpriteStateData1 + 2 * $10 + $9], a
 	call Delay3
 	ld a, $2
 	ld [hSpriteIndexOrTextID], a
--- a/scripts/cinnabargym.asm
+++ b/scripts/cinnabargym.asm
@@ -54,14 +54,14 @@
 	ld [H_SPRITEINDEX], a
 	cp $4
 	jr nz, .asm_757c3
-	ld a, $4
-	ld [wd528], a
+	ld a, PLAYER_DIR_DOWN
+	ld [wPlayerMovingDirection], a
 	ld de, MovementData_757d7
 	jr .asm_757cb
 .asm_757c3
 	ld de, MovementData_757da
-	ld a, $1
-	ld [wd528], a
+	ld a, PLAYER_DIR_RIGHT
+	ld [wPlayerMovingDirection], a
 .asm_757cb
 	call MoveSprite
 	ld a, $1
@@ -99,7 +99,7 @@
 	ld a, [wTrainerHeaderFlagBit]
 	ld [$ffdb], a
 	ld c, a
-	ld b, $2
+	ld b, FLAG_TEST
 	ld hl, wd79a
 	call CinnabarGymScript_757f1
 	ld a, c
@@ -113,13 +113,13 @@
 	ld a, [wTrainerHeaderFlagBit]
 	ld [$ffdb], a
 	ld c, a
-	ld b, $1
+	ld b, FLAG_SET
 	ld hl, wd79a
 	call CinnabarGymScript_757f1
 	ld a, [wTrainerHeaderFlagBit]
 	sub $2
 	ld c, a
-	ld b, $1
+	ld b, FLAG_SET
 	ld hl, wd79c
 	call CinnabarGymScript_757f1
 	call Func_3ead
--- a/scripts/cinnabarisland.asm
+++ b/scripts/cinnabarisland.asm
@@ -24,8 +24,8 @@
 	ld a, [W_XCOORD]
 	cp $12
 	ret nz
-	ld a, $8
-	ld [wd528], a
+	ld a, PLAYER_DIR_UP
+	ld [wPlayerMovingDirection], a
 	ld a, $8
 	ld [hSpriteIndexOrTextID], a
 	call DisplayTextID
--- a/scripts/fightingdojo.asm
+++ b/scripts/fightingdojo.asm
@@ -42,9 +42,9 @@
 	ret nz
 	ld a, $1
 	ld [wcf0d], a
+	ld a, PLAYER_DIR_RIGHT
+	ld [wPlayerMovingDirection], a
 	ld a, $1
-	ld [wd528], a
-	ld a, $1
 	ld [H_SPRITEINDEX], a
 	ld a, SPRITE_FACING_LEFT
 	ld [hSpriteFacingDirection], a
@@ -61,8 +61,8 @@
 	ld a, [wcf0d]
 	and a
 	jr z, .asm_5cde4
-	ld a, $1
-	ld [wd528], a
+	ld a, PLAYER_DIR_RIGHT
+	ld [wPlayerMovingDirection], a
 	ld a, $1
 	ld [H_SPRITEINDEX], a
 	ld a, SPRITE_FACING_LEFT
--- a/scripts/gary.asm
+++ b/scripts/gary.asm
@@ -139,8 +139,8 @@
 	ld a, [wd730]
 	bit 0, a
 	ret nz
-	ld a, $2
-	ld [wd528], a
+	ld a, PLAYER_DIR_LEFT
+	ld [wPlayerMovingDirection], a
 	ld a, $1
 	ld [H_SPRITEINDEX], a
 	ld a, SPRITE_FACING_LEFT
--- a/scripts/halloffameroom.asm
+++ b/scripts/halloffameroom.asm
@@ -80,19 +80,19 @@
 	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
+	ld a, PLAYER_DIR_RIGHT
+	ld [wPlayerMovingDirection], a
 	ld a, $1
-	ld [wd528], a
-	ld a, $1
 	ld [H_SPRITEINDEX], a
 	call SetSpriteMovementBytesToFF
-	ld a, $8
+	ld a, SPRITE_FACING_LEFT
 	ld [hSpriteFacingDirection], a
 	call SetSpriteFacingDirectionAndDelay
 	call Delay3
 	xor a
 	ld [wJoyIgnore], a
-	inc a
-	ld [wd528], a
+	inc a ; PLAYER_DIR_RIGHT
+	ld [wPlayerMovingDirection], a
 	ld a, $1
 	ld [hSpriteIndexOrTextID], a
 	call DisplayTextID
--- a/scripts/lab4.asm
+++ b/scripts/lab4.asm
@@ -112,6 +112,4 @@
 	jp TextScriptEnd
 
 LoadFossilItemAndMonNameBank1D: ; 75de8 (1d:5de8)
-	ld b, BANK(LoadFossilItemAndMonName)
-	ld hl, LoadFossilItemAndMonName
-	jp Bankswitch
+	jpba LoadFossilItemAndMonName
--- a/scripts/oakslab.asm
+++ b/scripts/oakslab.asm
@@ -178,8 +178,8 @@
 	ld a, D_UP
 	ld [wSimulatedJoypadStatesEnd], a
 	call StartSimulatingJoypadStates
-	ld a, $8
-	ld [wd528], a
+	ld a, PLAYER_DIR_UP
+	ld [wPlayerMovingDirection], a
 
 	ld a, $7
 	ld [W_OAKSLABCURSCRIPT], a
@@ -354,8 +354,8 @@
 	xor a ; SPRITE_FACING_DOWN
 	ld [hSpriteFacingDirection], a
 	call SetSpriteFacingDirectionAndDelay
-	ld a, $8
-	ld [wd528], a
+	ld a, PLAYER_DIR_UP
+	ld [wPlayerMovingDirection], a
 	ld c, BANK(Music_MeetRival)
 	ld a, MUSIC_MEET_RIVAL
 	call PlayMusic
@@ -414,8 +414,8 @@
 	set 7, [hl]
 	xor a
 	ld [wJoyIgnore], a
-	ld a, $8
-	ld [wd528], a
+	ld a, PLAYER_DIR_UP
+	ld [wPlayerMovingDirection], a
 	ld a, $c
 	ld [W_OAKSLABCURSCRIPT], a
 	ret
@@ -423,8 +423,8 @@
 OaksLabScript12: ; 1ce03 (7:4e03)
 	ld a, $f0
 	ld [wJoyIgnore], a
-	ld a, $8
-	ld [wd528], a
+	ld a, PLAYER_DIR_UP
+	ld [wPlayerMovingDirection], a
 	call UpdateSprites
 	ld a, $1
 	ld [wSpriteIndex], a
--- a/scripts/pallettown.asm
+++ b/scripts/pallettown.asm
@@ -28,8 +28,8 @@
 	ret nz
 	xor a
 	ld [hJoyHeld],a
-	ld a,4
-	ld [wd528],a
+	ld a,PLAYER_DIR_DOWN
+	ld [wPlayerMovingDirection],a
 	ld a,$FF
 	call PlaySound ; stop music
 	ld a, BANK(Music_MeetProfOak)
@@ -190,8 +190,8 @@
 	ld [wEmotionBubbleSpriteIndex],a ; player's sprite
 	ld [wWhichEmotionBubble],a ; EXCLAMATION_BUBBLE
 	predef EmotionBubble
-	ld a,4
-	ld [wd528],a
+	ld a,PLAYER_DIR_DOWN
+	ld [wPlayerMovingDirection],a
 	jp TextScriptEnd
 
 OakWalksUpText: ; 18fce (6:4fce)
--- a/scripts/pokemontower2.asm
+++ b/scripts/pokemontower2.asm
@@ -33,15 +33,15 @@
 	res 6, [hl]
 	ld a, [wCoordIndex]
 	cp $1
-	ld a, $8
+	ld a, PLAYER_DIR_UP
 	ld b, SPRITE_FACING_DOWN
 	jr nz, .asm_60544
 	ld hl, wd764
 	set 6, [hl]
-	ld a, $2
+	ld a, PLAYER_DIR_LEFT
 	ld b, SPRITE_FACING_RIGHT
 .asm_60544
-	ld [wd528], a
+	ld [wPlayerMovingDirection], a
 	ld a, $1
 	ld [H_SPRITEINDEX], a
 	ld a, b
--- a/scripts/redshouse2f.asm
+++ b/scripts/redshouse2f.asm
@@ -11,8 +11,8 @@
 RedsHouse2FScript0: ; 5c0c0 (17:40c0)
 	xor a
 	ld [hJoyHeld],a
-	ld a,8
-	ld [wd528],a
+	ld a,PLAYER_DIR_UP
+	ld [wPlayerMovingDirection],a
 	ld a,1
 	ld [W_REDSHOUSE2CURSCRIPT],a
 	ret
--- a/scripts/route22.asm
+++ b/scripts/route22.asm
@@ -67,8 +67,8 @@
 	ld [hJoyHeld], a
 	ld a, $f0
 	ld [wJoyIgnore], a
-	ld a, $2
-	ld [wd528], a
+	ld a, PLAYER_DIR_LEFT
+	ld [wPlayerMovingDirection], a
 	ld a, [wd7eb]
 	bit 0, a ; is this the rival battle at the beginning of the game?
 	jr nz, .firstRivalBattle
@@ -111,8 +111,8 @@
 	ld a, [wcf0d]
 	cp $1
 	jr nz, .asm_50f78
-	ld a, $4
-	ld [wd528], a
+	ld a, PLAYER_DIR_DOWN
+	ld [wPlayerMovingDirection], a
 	ld a, SPRITE_FACING_UP
 	jr .asm_50f7a
 .asm_50f78
@@ -270,13 +270,13 @@
 	ld a, [wcf0d]
 	cp $1
 	jr nz, .asm_510a1
-	ld a, $4
-	ld [wd528], a
+	ld a, PLAYER_DIR_DOWN
+	ld [wPlayerMovingDirection], a
 	ld a, SPRITE_FACING_UP
 	jr .asm_510a8
 .asm_510a1
-	ld a, $2
-	ld [wd528], a
+	ld a, PLAYER_DIR_LEFT
+	ld [wPlayerMovingDirection], a
 	ld a, SPRITE_FACING_RIGHT
 .asm_510a8
 	ld [hSpriteFacingDirection], a
@@ -314,13 +314,13 @@
 	ld a, [wcf0d]
 	cp $1
 	jr nz, .asm_510fb
-	ld a, $4
-	ld [wd528], a
+	ld a, PLAYER_DIR_DOWN
+	ld [wPlayerMovingDirection], a
 	ld a, SPRITE_FACING_UP
 	jr .asm_51102
 .asm_510fb
-	ld a, $2
-	ld [wd528], a
+	ld a, PLAYER_DIR_LEFT
+	ld [wPlayerMovingDirection], a
 	ld a, SPRITE_FACING_RIGHT
 .asm_51102
 	ld [hSpriteFacingDirection], a
--- a/scripts/route23.asm
+++ b/scripts/route23.asm
@@ -52,7 +52,7 @@
 	ld [hSpriteIndexOrTextID], a
 	ld a, c
 	ld [wWhichBadge], a
-	ld b, $2
+	ld b, FLAG_TEST
 	ld hl, wd7ed
 	predef FlagActionPredef
 	ld a, c
@@ -193,7 +193,7 @@
 	ld a, [wWhichBadge]
 	inc a
 	ld c, a
-	ld b, $2
+	ld b, FLAG_TEST
 	ld hl, W_OBTAINEDBADGES
 	predef FlagActionPredef
 	ld a, c
@@ -210,7 +210,7 @@
 	call PrintText
 	ld a, [wWhichBadge]
 	ld c, a
-	ld b, $1
+	ld b, FLAG_SET
 	ld hl, wd7ed
 	predef FlagActionPredef
 	ld a, $2
--- a/scripts/route5gate.asm
+++ b/scripts/route5gate.asm
@@ -22,8 +22,8 @@
 	ld hl, CoordsData_1df8f
 	call ArePlayerCoordsInArray
 	ret nc
-	ld a, $2
-	ld [wd528], a
+	ld a, PLAYER_DIR_LEFT
+	ld [wPlayerMovingDirection], a
 	xor a
 	ld [hJoyHeld], a
 	callba RemoveGuardDrink
--- a/scripts/route6gate.asm
+++ b/scripts/route6gate.asm
@@ -16,8 +16,8 @@
 	ld hl, CoordsData_1e08c
 	call ArePlayerCoordsInArray
 	ret nc
-	ld a, $1
-	ld [wd528], a
+	ld a, PLAYER_DIR_RIGHT
+	ld [wPlayerMovingDirection], a
 	xor a
 	ld [hJoyHeld], a
 	callba RemoveGuardDrink
--- a/scripts/route7gate.asm
+++ b/scripts/route7gate.asm
@@ -28,8 +28,8 @@
 	ld hl, CoordsData_1e167
 	call ArePlayerCoordsInArray
 	ret nc
-	ld a, $8
-	ld [wd528], a
+	ld a, PLAYER_DIR_UP
+	ld [wPlayerMovingDirection], a
 	xor a
 	ld [hJoyHeld], a
 	callba RemoveGuardDrink
--- a/scripts/route8gate.asm
+++ b/scripts/route8gate.asm
@@ -27,8 +27,8 @@
 	ld hl, CoordsData_1e22c
 	call ArePlayerCoordsInArray
 	ret nc
-	ld a, $2
-	ld [wd528], a
+	ld a, PLAYER_DIR_LEFT
+	ld [wPlayerMovingDirection], a
 	xor a
 	ld [hJoyHeld], a
 	callba RemoveGuardDrink
--- a/scripts/safarizoneentrance.asm
+++ b/scripts/safarizoneentrance.asm
@@ -72,8 +72,8 @@
 	ret
 
 .SafariZoneEntranceScript5
-	ld a, $4
-	ld [wd528], a
+	ld a, PLAYER_DIR_DOWN
+	ld [wPlayerMovingDirection], a
 	ld hl, wd790
 	bit 6, [hl]
 	res 6, [hl]
--- a/scripts/silphco11.asm
+++ b/scripts/silphco11.asm
@@ -199,7 +199,7 @@
 	db $FF
 
 SilphCo11Script_6221a: ; 6221a (18:621a)
-	ld [wd528], a
+	ld [wPlayerMovingDirection], a
 	ld a, $3
 	ld [H_SPRITEINDEX], a
 	ld a, b
@@ -213,11 +213,11 @@
 	ld a, [wcf0d]
 	cp $1
 	jr z, .asm_6223c
-	ld a, $2
+	ld a, PLAYER_DIR_LEFT
 	ld b, SPRITE_FACING_RIGHT
 	jr .asm_62240
 .asm_6223c
-	ld a, $8
+	ld a, PLAYER_DIR_UP
 	ld b, SPRITE_FACING_DOWN
 .asm_62240
 	call SilphCo11Script_6221a
@@ -247,11 +247,11 @@
 	ld a, [wcf0d]
 	cp $1
 	jr z, .asm_62284
-	ld a, $2
+	ld a, PLAYER_DIR_LEFT
 	ld b, SPRITE_FACING_RIGHT
 	jr .asm_62288
 .asm_62284
-	ld a, $8
+	ld a, PLAYER_DIR_UP
 	ld b, SPRITE_FACING_DOWN
 .asm_62288
 	call SilphCo11Script_6221a
--- a/scripts/silphco7.asm
+++ b/scripts/silphco7.asm
@@ -127,8 +127,8 @@
 	ld [hJoyHeld], a
 	ld a, $f0
 	ld [wJoyIgnore], a
-	ld a, $4
-	ld [wd528], a
+	ld a, PLAYER_DIR_DOWN
+	ld [wPlayerMovingDirection], a
 	ld a, $ff
 	ld [wc0ee], a
 	call PlaySound
@@ -209,8 +209,8 @@
 	ld [wJoyIgnore], a
 	ld hl, wd82f
 	set 0, [hl]
-	ld a, $4
-	ld [wd528], a
+	ld a, PLAYER_DIR_DOWN
+	ld [wPlayerMovingDirection], a
 	ld a, $9
 	ld [H_SPRITEINDEX], a
 	ld a, SPRITE_FACING_UP
--- a/scripts/ssanne2.asm
+++ b/scripts/ssanne2.asm
@@ -74,8 +74,8 @@
 	ld a, [W_XCOORD]
 	cp $25
 	jr nz, .asm_61426
-	ld a, $2
-	ld [wd528], a
+	ld a, PLAYER_DIR_LEFT
+	ld [wPlayerMovingDirection], a
 	ld a, SPRITE_FACING_RIGHT
 	jr .asm_61427
 .asm_61426
--- a/scripts/viridiangym.asm
+++ b/scripts/viridiangym.asm
@@ -128,9 +128,7 @@
 	ld [W_CURMAPSCRIPT], a
 	ret
 .asm_74980
-	ld b, BANK(LoadSpinnerArrowTiles)
-	ld hl, LoadSpinnerArrowTiles
-	jp Bankswitch
+	jpba LoadSpinnerArrowTiles
 
 ViridianGymScript3: ; 74988 (1d:4988)
 	ld a, [W_ISINBATTLE]
--- a/wram.asm
+++ b/wram.asm
@@ -733,6 +733,8 @@
 ; which entry from TradeMons to select
 
 wTrainerSpriteOffset:: ; cd3d
+
+wUnusedCD3D:: ; cd3d
 	ds 1
 
 wSSAnneSmokeX:: ; cd3e
@@ -1699,8 +1701,12 @@
 	flag_array 50 + 5
 	ds 1
 
-wd0d4:: ds 3 ; temp storage for hTilesetType
+wSavedTilesetType:: ; d0d4
+; saved at the start of a battle and then written back at the end of the battle
+	ds 1
 
+	ds 2
+
 W_MONHPADDING:: ; d0d7
 
 
@@ -2064,10 +2070,15 @@
 ; sprite set ID for the current map
 	ds 1
 
-wd3a9:: ds 1 ; used when getting the object data pointer
-wd3aa:: ds 3 ; second part of the pointer
-wd3ad:: ds 1 ; used as the beginning value for copying warp data
+wObjectDataPointerTemp:: ; d3a9
+	ds 2
 
+	ds 2
+
+wMapBackgroundTile:: ; d3ad
+; the tile shown outside the boundaries of the map
+	ds 1
+
 wNumberOfWarps:: ; d3ae
 ; number of warps in current map
 	ds 1
@@ -2082,10 +2093,18 @@
 
 	ds 128
 
-wd4b0:: ds 1 ; number of signs on the map
-wd4b1:: ds 32 ; starting address for sign coords
-wd4d1:: ds 16 ; starting address for sign text IDs
+wNumSigns:: ; d4b0
+; number of signs in the current map (up to 16)
+	ds 1
 
+wSignCoords:: ; d4b1
+; 2 bytes each
+; Y, X
+	ds 32
+
+wSignTextIDs:: ; d4d1
+	ds 16
+
 W_NUMSPRITES:: ; d4e1
 ; number of sprites on the current map
 	ds 1
@@ -2105,16 +2124,35 @@
 ; two bytes per sprite (trainer class/item ID, trainer set ID)
 	ds 32
 
-wd524:: ds 1 ; map height in 2x2 metatiles, also used with checking connections
-wd525:: ds 1 ; map width in 2x2 metatiles, also used with checking connections
+wCurrentMapHeight2:: ; d524
+; map height in 2x2 meta-tiles
+	ds 1
 
+wCurrentMapWidth2:: ; d525
+; map width in 2x2 meta-tiles
+	ds 1
+
 wMapViewVRAMPointer:: ; d526
 ; the address of the upper left corner of the visible portion of the BG tile map in VRAM
 	ds 2
 
-wd528:: ds 1 ; additional storage for directions
-wd529:: ds 1 ; same case as above, but used differently
-wd52a:: ds 1 ; same case as above
+; In the comments for the player direction variables below, "moving" refers to
+; both walking and changing facing direction without taking a step.
+
+wPlayerMovingDirection:: ; d528
+; if the player is moving, the current direction
+; if the player is not moving, zero
+; map scripts write to this in order to change the player's facing direction
+	ds 1
+
+wPlayerLastStopDirection:: ; d529
+; the direction in which the player was moving before the player last stopped
+	ds 1
+
+wPlayerDirection:: ; d52a
+; if the player is moving, the current direction
+; if the player is not moving, the last the direction in which the player moved
+	ds 1
 
 W_TILESETBANK:: ; d52b
 	ds 1