shithub: pokered

Download patch

ref: 91793015e53dbed09576f825d39e71bc59bf90a5
parent: daf4fc87ae66e2c3d56840774efba10a9b903ee3
author: YamaArashi <shadow962@live.com>
date: Tue Sep 9 16:55:19 EDT 2014

Labelled and commented mostly sprite-related things

--- a/audio.asm
+++ b/audio.asm
@@ -563,7 +563,7 @@
 	ld a, [hli]
 	ld c, [hl]
 	call PlayMusic
-	jp Func_2307
+	jp PlayDefaultMusic
 
 PokedexRatingSfxPointers: ; 7d162 (1f:5162)
 	db (SFX_1f_51 - SFX_Headers_1f) / 3, BANK(SFX_1f_51)
--- a/constants/misc_constants.asm
+++ b/constants/misc_constants.asm
@@ -18,3 +18,8 @@
 HOF_MON       EQU $10
 HOF_TEAM      EQU PARTY_LENGTH * HOF_MON
 NUM_HOF_TEAMS EQU 50
+
+NPC_MOVEMENT_DOWN  EQU $00
+NPC_MOVEMENT_UP    EQU $40
+NPC_MOVEMENT_LEFT  EQU $80
+NPC_MOVEMENT_RIGHT EQU $C0
\ No newline at end of file
--- a/constants/sprite_constants.asm
+++ b/constants/sprite_constants.asm
@@ -86,4 +86,12 @@
 
 ; different kinds of people events
 ITEM    EQU $80
-TRAINER EQU $40
\ No newline at end of file
+TRAINER EQU $40
+
+BOULDER_MOVEMENT_BYTE_2 EQU $10
+
+; sprite facing directions
+SPRITE_FACING_DOWN  EQU $00
+SPRITE_FACING_UP    EQU $04
+SPRITE_FACING_LEFT  EQU $08
+SPRITE_FACING_RIGHT EQU $0C
\ No newline at end of file
--- a/data/mapObjects/fuchsiahouse2.asm
+++ b/data/mapObjects/fuchsiahouse2.asm
@@ -12,7 +12,7 @@
 	db $3 ; people
 	db SPRITE_WARDEN, $3 + 4, $2 + 4, $ff, $ff, $1 ; person
 	db SPRITE_BALL, $3 + 4, $8 + 4, $ff, $ff, ITEM | $2, RARE_CANDY
-	db SPRITE_BOULDER, $4 + 4, $8 + 4, $ff, $10, $3 ; person
+	db SPRITE_BOULDER, $4 + 4, $8 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $3 ; person
 
 	; warp-to
 	EVENT_DISP FUCHSIA_HOUSE_2_WIDTH, $7, $4
--- a/data/mapObjects/seafoamislands1.asm
+++ b/data/mapObjects/seafoamislands1.asm
@@ -13,8 +13,8 @@
 	db $0 ; signs
 
 	db $2 ; people
-	db SPRITE_BOULDER, $a + 4, $12 + 4, $ff, $10, $1 ; person
-	db SPRITE_BOULDER, $7 + 4, $1a + 4, $ff, $10, $2 ; person
+	db SPRITE_BOULDER, $a + 4, $12 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $1 ; person
+	db SPRITE_BOULDER, $7 + 4, $1a + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $2 ; person
 
 	; warp-to
 	EVENT_DISP SEAFOAM_ISLANDS_1_WIDTH, $11, $4
--- a/data/mapObjects/seafoamislands2.asm
+++ b/data/mapObjects/seafoamislands2.asm
@@ -13,8 +13,8 @@
 	db $0 ; signs
 
 	db $2 ; people
-	db SPRITE_BOULDER, $6 + 4, $11 + 4, $ff, $10, $1 ; person
-	db SPRITE_BOULDER, $6 + 4, $16 + 4, $ff, $10, $2 ; person
+	db SPRITE_BOULDER, $6 + 4, $11 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $1 ; person
+	db SPRITE_BOULDER, $6 + 4, $16 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $2 ; person
 
 	; warp-to
 	EVENT_DISP SEAFOAM_ISLANDS_2_WIDTH, $2, $4 ; SEAFOAM_ISLANDS_3
--- a/data/mapObjects/seafoamislands3.asm
+++ b/data/mapObjects/seafoamislands3.asm
@@ -13,8 +13,8 @@
 	db $0 ; signs
 
 	db $2 ; people
-	db SPRITE_BOULDER, $6 + 4, $12 + 4, $ff, $10, $1 ; person
-	db SPRITE_BOULDER, $6 + 4, $17 + 4, $ff, $10, $2 ; person
+	db SPRITE_BOULDER, $6 + 4, $12 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $1 ; person
+	db SPRITE_BOULDER, $6 + 4, $17 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $2 ; person
 
 	; warp-to
 	EVENT_DISP SEAFOAM_ISLANDS_3_WIDTH, $3, $5 ; SEAFOAM_ISLANDS_2
--- a/data/mapObjects/seafoamislands4.asm
+++ b/data/mapObjects/seafoamislands4.asm
@@ -13,10 +13,10 @@
 	db $0 ; signs
 
 	db $6 ; people
-	db SPRITE_BOULDER, $e + 4, $5 + 4, $ff, $10, $1 ; person
-	db SPRITE_BOULDER, $f + 4, $3 + 4, $ff, $10, $2 ; person
-	db SPRITE_BOULDER, $e + 4, $8 + 4, $ff, $10, $3 ; person
-	db SPRITE_BOULDER, $e + 4, $9 + 4, $ff, $10, $4 ; person
+	db SPRITE_BOULDER, $e + 4, $5 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $1 ; person
+	db SPRITE_BOULDER, $f + 4, $3 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $2 ; person
+	db SPRITE_BOULDER, $e + 4, $8 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $3 ; person
+	db SPRITE_BOULDER, $e + 4, $9 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $4 ; person
 	db SPRITE_BOULDER, $6 + 4, $12 + 4, $ff, $ff, $5 ; person
 	db SPRITE_BOULDER, $6 + 4, $13 + 4, $ff, $ff, $6 ; person
 
--- a/data/mapObjects/victoryroad1.asm
+++ b/data/mapObjects/victoryroad1.asm
@@ -13,9 +13,9 @@
 	db SPRITE_BLACK_HAIR_BOY_1, $2 + 4, $3 + 4, $ff, $d0, TRAINER | $2, COOLTRAINER_M + $C8, $5
 	db SPRITE_BALL, $0 + 4, $b + 4, $ff, $ff, ITEM | $3, TM_43
 	db SPRITE_BALL, $2 + 4, $9 + 4, $ff, $ff, ITEM | $4, RARE_CANDY
-	db SPRITE_BOULDER, $f + 4, $5 + 4, $ff, $10, $5 ; person
-	db SPRITE_BOULDER, $2 + 4, $e + 4, $ff, $10, $6 ; person
-	db SPRITE_BOULDER, $a + 4, $2 + 4, $ff, $10, $7 ; person
+	db SPRITE_BOULDER, $f + 4, $5 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $5 ; person
+	db SPRITE_BOULDER, $2 + 4, $e + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $6 ; person
+	db SPRITE_BOULDER, $a + 4, $2 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $7 ; person
 
 	; warp-to
 	EVENT_DISP VICTORY_ROAD_1_WIDTH, $11, $8
--- a/data/mapObjects/victoryroad2.asm
+++ b/data/mapObjects/victoryroad2.asm
@@ -23,9 +23,9 @@
 	db SPRITE_BALL, $9 + 4, $12 + 4, $ff, $ff, ITEM | $8, FULL_HEAL
 	db SPRITE_BALL, $b + 4, $9 + 4, $ff, $ff, ITEM | $9, TM_05
 	db SPRITE_BALL, $0 + 4, $b + 4, $ff, $ff, ITEM | $a, GUARD_SPEC_
-	db SPRITE_BOULDER, $e + 4, $4 + 4, $ff, $10, $b ; person
-	db SPRITE_BOULDER, $5 + 4, $5 + 4, $ff, $10, $c ; person
-	db SPRITE_BOULDER, $10 + 4, $17 + 4, $ff, $10, $d ; person
+	db SPRITE_BOULDER, $e + 4, $4 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $b ; person
+	db SPRITE_BOULDER, $5 + 4, $5 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $c ; person
+	db SPRITE_BOULDER, $10 + 4, $17 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $d ; person
 
 	; warp-to
 	EVENT_DISP VICTORY_ROAD_2_WIDTH, $8, $0 ; VICTORY_ROAD_1
--- a/data/mapObjects/victoryroad3.asm
+++ b/data/mapObjects/victoryroad3.asm
@@ -16,10 +16,10 @@
 	db SPRITE_LASS, $3 + 4, $d + 4, $ff, $d3, TRAINER | $4, COOLTRAINER_F + $C8, $3
 	db SPRITE_BALL, $5 + 4, $1a + 4, $ff, $ff, ITEM | $5, MAX_REVIVE
 	db SPRITE_BALL, $7 + 4, $7 + 4, $ff, $ff, ITEM | $6, TM_47
-	db SPRITE_BOULDER, $3 + 4, $16 + 4, $ff, $10, $7 ; person
-	db SPRITE_BOULDER, $c + 4, $d + 4, $ff, $10, $8 ; person
-	db SPRITE_BOULDER, $a + 4, $18 + 4, $ff, $10, $9 ; person
-	db SPRITE_BOULDER, $f + 4, $16 + 4, $ff, $10, $a ; person
+	db SPRITE_BOULDER, $3 + 4, $16 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $7 ; person
+	db SPRITE_BOULDER, $c + 4, $d + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $8 ; person
+	db SPRITE_BOULDER, $a + 4, $18 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $9 ; person
+	db SPRITE_BOULDER, $f + 4, $16 + 4, $ff, BOULDER_MOVEMENT_BYTE_2, $a ; person
 
 	; warp-to
 	EVENT_DISP VICTORY_ROAD_3_WIDTH, $7, $17 ; VICTORY_ROAD_2
--- a/engine/battle/4_2.asm
+++ b/engine/battle/4_2.asm
@@ -88,7 +88,7 @@
 	db "@"
 
 Func_13870: ; 13870 (4:7870)
-	ld a, [wcc57]
+	ld a, [wNPCMovementScriptPointerTableNum]
 	and a
 	ret nz
 	ld a, [wd736]
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -1411,50 +1411,50 @@
 	ld [hli], a
 	ret
 
-Func_79337: ; 79337 (1e:5337)
+AdjustOAMBlockXPos: ; 79337 (1e:5337)
 	ld l, e
 	ld h, d
 
-Func_79339: ; 79339 (1e:5339)
+AdjustOAMBlockXPos2: ; 79339 (1e:5339)
 	ld de, $4
-.asm_7933c
+.loop
 	ld a, [wd08a]
 	ld b, a
 	ld a, [hl]
 	add b
 	cp $a8
-	jr c, .asm_7934a
+	jr c, .skipPuttingEntryOffScreen
 	dec hl
 	ld a, $a0
 	ld [hli], a
-.asm_7934a
+.skipPuttingEntryOffScreen
 	ld [hl], a
 	add hl, de
 	dec c
-	jr nz, .asm_7933c
+	jr nz, .loop
 	ret
 
-Func_79350: ; 79350 (1e:5350)
+AdjustOAMBlockYPos: ; 79350 (1e:5350)
 	ld l, e
 	ld h, d
 
-Func_79352: ; 79352 (1e:5352)
+AdjustOAMBlockYPos2: ; 79352 (1e:5352)
 	ld de, $4
-.asm_79355
+.loop
 	ld a, [wd08a]
 	ld b, a
 	ld a, [hl]
 	add b
 	cp $70
-	jr c, .asm_79363
+	jr c, .skipSettingPreviousEntrysAttribute
 	dec hl
-	ld a, $a0
+	ld a, $a0 ; bug, sets previous OAM entry's attribute
 	ld [hli], a
-.asm_79363
+.skipSettingPreviousEntrysAttribute
 	ld [hl], a
 	add hl, de
 	dec c
-	jr nz, .asm_79355
+	jr nz, .loop
 	ret
 
 AnimationBlinkEnemyMon: ; 79369 (1e:5369)
--- a/engine/evolve_trade.asm
+++ b/engine/evolve_trade.asm
@@ -41,4 +41,4 @@
 	callab TryEvolvingMon
 	xor a
 	ld [W_ISLINKBATTLE], a ; W_ISLINKBATTLE
-	jp Func_2307
+	jp PlayDefaultMusic
--- a/engine/evos_moves.asm
+++ b/engine/evos_moves.asm
@@ -254,7 +254,7 @@
 	ret nz
 	ld a, [wd121]
 	and a
-	call nz, Func_2307
+	call nz, PlayDefaultMusic
 	ret
 
 ; checks if the evolved mon's name is different from the standard name (i.e. it has a nickname)
--- a/engine/hidden_object_functions7.asm
+++ b/engine/hidden_object_functions7.asm
@@ -357,7 +357,7 @@
 	ld a, (SFX_02_3a - SFX_Headers_02) / 3
 	call PlaySound
 	call WaitForSoundToFinish
-	call Func_2307
+	call PlayDefaultMusic
 	ld hl, wd7f2
 	set 3, [hl]
 	ret
--- a/engine/in_game_trades.asm
+++ b/engine/in_game_trades.asm
@@ -150,7 +150,7 @@
 
 Func_71ca2: ; 71ca2 (1c:5ca2)
 	call GBPalWhiteOutWithDelay3
-	call Func_3dbe
+	call RestoreScreenTilesAndReloadTilePatterns
 	call ReloadTilesetTilePatterns
 	call LoadScreenTilesFromBuffer2
 	call Delay3
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -517,7 +517,7 @@
 	call ItemUseReloadOverworldData
 	xor a
 	ld [wd700],a ; change player state to walking
-	call Func_2307 ; play walking music
+	call PlayDefaultMusic ; play walking music
 	ld hl,GotOffBicycleText
 	jr .printText
 .tryToGetOnBike
@@ -529,7 +529,7 @@
 	inc a
 	ld [wd700],a ; change player state to bicycling
 	ld hl,GotOnBicycleText
-	call Func_2307 ; play bike riding music
+	call PlayDefaultMusic ; play bike riding music
 .printText
 	jp PrintText
 
@@ -551,7 +551,7 @@
 	set 7,[hl]
 	ld a,2
 	ld [wd700],a ; change player state to surfing
-	call Func_2307 ; play surfing music
+	call PlayDefaultMusic ; play surfing music
 	ld hl,SurfingGotOnText
 	jp PrintText
 .tryToStopSurfing
@@ -589,28 +589,28 @@
 	ld [wd700],a ; change player state to walking
 	dec a
 	ld [wJoyIgnore],a
-	call Func_2307 ; play walking music
+	call PlayDefaultMusic ; play walking music
 	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 b,%01000000 ; Up key
+	ld b,D_UP
 	jr nz,.storeSimulatedButtonPress
 	bit 2,a
-	ld b,%10000000 ; Down key
+	ld b,D_DOWN
 	jr nz,.storeSimulatedButtonPress
 	bit 1,a
-	ld b,%00100000 ; Left key
+	ld b,D_LEFT
 	jr nz,.storeSimulatedButtonPress
-	ld b,%00010000 ; Right key
+	ld b,D_RIGHT
 .storeSimulatedButtonPress
 	ld a,b
-	ld [wccd3],a ; base address of simulated button presses
+	ld [wSimulatedJoypadStatesEnd],a
 	xor a
-	ld [wcd39],a
+	ld [wWastedByteCD39],a
 	inc a
-	ld [wcd38],a ; index of current simulated button press
+	ld [wSimulatedJoypadStatesIndex],a
 	ret
 
 SurfingGotOnText: ; da4c (3:5a4c)
@@ -1727,7 +1727,7 @@
 	ld a,[wc028]
 	cp a,$b8
 	jr z,.musicWaitLoop
-	call Func_2307 ; start playing normal music again
+	call PlayDefaultMusic ; start playing normal music again
 .done
 	jp TextScriptEnd ; end text
 
--- a/engine/menu/diploma.asm
+++ b/engine/menu/diploma.asm
@@ -61,7 +61,7 @@
 	ld hl, wd730
 	res 6, [hl]
 	call GBPalWhiteOutWithDelay3
-	call Func_3dbe
+	call RestoreScreenTilesAndReloadTilePatterns
 	call Delay3
 	jp GBPalNormal
 
--- a/engine/menu/naming_screen.asm
+++ b/engine/menu/naming_screen.asm
@@ -33,7 +33,7 @@
 	ld a, [W_ISINBATTLE] ; W_ISINBATTLE
 	and a
 	jr nz, .asm_653e
-	call Func_3e08
+	call ReloadMapSpriteTilePatterns
 .asm_653e
 	call LoadScreenTilesFromBuffer1
 	pop hl
@@ -61,7 +61,7 @@
 	ld [wd07d], a
 	call DisplayNamingScreen
 	call GBPalWhiteOutWithDelay3
-	call Func_3dbe
+	call RestoreScreenTilesAndReloadTilePatterns
 	call LoadGBPal
 	ld a, [wcf4b]
 	cp $50
--- a/engine/menu/pokedex.asm
+++ b/engine/menu/pokedex.asm
@@ -36,8 +36,8 @@
 	ld [wCurrentMenuItem],a
 	ld [wLastMenuItem],a
 	ld [$ffb7],a
-	ld [wcd3a],a
-	ld [wcd3b],a
+	ld [wWastedByteCD3A],a
+	ld [wOverrideSimulatedJoypadStatesMask],a
 	pop af
 	ld [wListScrollOffset],a
 	call GBPalWhiteOutWithDelay3
--- a/engine/menu/start_sub_menus.asm
+++ b/engine/menu/start_sub_menus.asm
@@ -25,7 +25,7 @@
 	jr nc,.chosePokemon
 .exitMenu
 	call GBPalWhiteOutWithDelay3
-	call Func_3dbe
+	call RestoreScreenTilesAndReloadTilePatterns
 	call LoadGBPal
 	jp RedisplayStartMenu
 .chosePokemon
@@ -273,7 +273,7 @@
 	TX_FAR _NotHealthyEnoughText
 	db "@"
 .goBackToMap
-	call Func_3dbe
+	call RestoreScreenTilesAndReloadTilePatterns
 	jp CloseTextDisplay
 .newBadgeRequired
 	ld hl,.newBadgeRequiredText
@@ -413,7 +413,7 @@
 	cp a,$02
 	jp z,.partyMenuNotDisplayed
 	call GBPalWhiteOutWithDelay3
-	call Func_3dbe
+	call RestoreScreenTilesAndReloadTilePatterns
 	pop af
 	ld [wcfcb],a
 	jp StartMenu_Item
@@ -790,7 +790,7 @@
 	ld a, [wCurrentMenuItem] ; wCurrentMenuItem
 	call AddNTimes
 	push hl
-	ld de, wcc97
+	ld de, wSwitchPartyMonTempBuffer
 	ld bc, $2c
 	call CopyData
 	ld hl, wPartyMons
@@ -802,7 +802,7 @@
 	ld bc, $2c
 	call CopyData
 	pop de
-	ld hl, wcc97
+	ld hl, wSwitchPartyMonTempBuffer
 	ld bc, $2c
 	call CopyData
 	ld hl, wPartyMonOT ; wd273
@@ -809,7 +809,7 @@
 	ld a, [wCurrentMenuItem] ; wCurrentMenuItem
 	call SkipFixedLengthTextEntries
 	push hl
-	ld de, wcc97
+	ld de, wSwitchPartyMonTempBuffer
 	ld bc, $b
 	call CopyData
 	ld hl, wPartyMonOT ; wd273
@@ -820,7 +820,7 @@
 	ld bc, $b
 	call CopyData
 	pop de
-	ld hl, wcc97
+	ld hl, wSwitchPartyMonTempBuffer
 	ld bc, $b
 	call CopyData
 	ld hl, wPartyMonNicks ; wPartyMonNicks
@@ -827,7 +827,7 @@
 	ld a, [wCurrentMenuItem] ; wCurrentMenuItem
 	call SkipFixedLengthTextEntries
 	push hl
-	ld de, wcc97
+	ld de, wSwitchPartyMonTempBuffer
 	ld bc, $b
 	call CopyData
 	ld hl, wPartyMonNicks ; wPartyMonNicks
@@ -838,7 +838,7 @@
 	ld bc, $b
 	call CopyData
 	pop de
-	ld hl, wcc97
+	ld hl, wSwitchPartyMonTempBuffer
 	ld bc, $b
 	call CopyData
 	ld a, [wMenuItemToSwap]
--- a/engine/overworld/cut.asm
+++ b/engine/overworld/cut.asm
@@ -36,7 +36,7 @@
 	set 6, [hl]
 	call GBPalWhiteOutWithDelay3
 	call ClearSprites
-	call Func_3dbe
+	call RestoreScreenTilesAndReloadTilePatterns
 	ld a, $90
 	ld [hVBlankWY], a
 	call Delay3
@@ -87,17 +87,17 @@
 	ld hl, vChars1 + $7e0
 	ld bc, (BANK(Overworld_GFX) << 8) + $02
 	call CopyVideoData
-	jr asm_f055
+	jr WriteCutTreeBoulderDustAnimationOAMBlock
 .asm_f020
 	ld hl, vChars1 + $7c0
-	call LoadCutTreeOAM
+	call LoadCutTreeAnimationTilePattern
 	ld hl, vChars1 + $7d0
-	call LoadCutTreeOAM
+	call LoadCutTreeAnimationTilePattern
 	ld hl, vChars1 + $7e0
-	call LoadCutTreeOAM
+	call LoadCutTreeAnimationTilePattern
 	ld hl, vChars1 + $7f0
-	call LoadCutTreeOAM
-	call asm_f055
+	call LoadCutTreeAnimationTilePattern
+	call WriteCutTreeBoulderDustAnimationOAMBlock
 	ld hl, wOAMBuffer + $93
 	ld de, $4
 	ld a, $30
@@ -110,26 +110,27 @@
 	jr nz, .asm_f044
 	ret
 
-LoadCutTreeOAM: ; f04c (3:704c)
+LoadCutTreeAnimationTilePattern: ; f04c (3:704c)
 	ld de, AnimationTileset2 + $60 ; $474e ; tile depicting a leaf
 	ld bc, (BANK(AnimationTileset2) << 8) + $01
 	jp CopyVideoData
-asm_f055: ; f055 (3:7055)
-	call Func_f068
+
+WriteCutTreeBoulderDustAnimationOAMBlock: ; f055 (3:7055)
+	call GetCutTreeBoulderDustAnimationOffsets
 	ld a, $9
-	ld de, CutTreeOAM ; $7060
+	ld de, CutTreeBoulderDustAnimationTilesAndAttributes
 	jp WriteOAMBlock
 
-CutTreeOAM: ; f060 (3:7060)
+CutTreeBoulderDustAnimationTilesAndAttributes: ; f060 (3:7060)
 	db $FC,$10,$FD,$10
 	db $FE,$10,$FF,$10
 
-Func_f068: ; f068 (3:7068)
+GetCutTreeBoulderDustAnimationOffsets: ; f068 (3:7068)
 	ld hl, wSpriteStateData1 + 4
-	ld a, [hli]
+	ld a, [hli] ; player's sprite screen Y position
 	ld b, a
 	inc hl
-	ld a, [hli]
+	ld a, [hli] ; player's sprite screen X position
 	ld c, a ; bc holds ypos/xpos of player's sprite
 	inc hl
 	inc hl
@@ -139,9 +140,9 @@
 	ld d, $0 ; de holds direction (00: down, 02: up, 04: left, 06: right)
 	ld a, [wcd50]
 	and a
-	ld hl, CutTreeAnimationOffsets ; $708f
+	ld hl, CutTreeAnimationOffsets
 	jr z, .asm_f084
-	ld hl, CutTreeAnimationOffsets2 ; $7097
+	ld hl, BoulderDustAnimationOffsets
 .asm_f084
 	add hl, de
 	ld e, [hl]
@@ -162,8 +163,7 @@
 	db -8, 20 ; player is facing left
 	db 24, 20 ; player is facing right
 
-CutTreeAnimationOffsets2: ; f097 (3:7097)
-; Not sure if these ever get used. CutTreeAnimationOffsets only seems to be used.
+BoulderDustAnimationOffsets: ; f097 (3:7097)
 ; Each pair represents the x and y pixels offsets from the player of where the cut tree animation should be drawn
 ; These offsets represent 2 blocks away from the player
 	db  8,  52 ; player is facing down
--- a/engine/overworld/cut2.asm
+++ b/engine/overworld/cut2.asm
@@ -9,12 +9,12 @@
 	ld a, $1
 	ld [wd08a], a
 	ld c, $2
-	call Func_79339
+	call AdjustOAMBlockXPos2
 	ld hl, wOAMBuffer + $99
 	ld a, $ff
 	ld [wd08a], a
 	ld c, $2
-	call Func_79339
+	call AdjustOAMBlockXPos2
 	ld a, [rOBP1] ; $ff49
 	xor $64
 	ld [rOBP1], a ; $ff49
@@ -37,7 +37,7 @@
 	ld a, $2
 	ld [wd08a], a
 	ld c, $4
-	call Func_79352
+	call AdjustOAMBlockYPos2
 	pop bc
 	dec c
 	jr nz, .asm_79eca
@@ -49,22 +49,22 @@
 	ld a, $1
 	ld [wd08a], a
 	ld c, $1
-	call Func_79339
+	call AdjustOAMBlockXPos2
 	ld hl, wOAMBuffer + $95
 	ld a, $2
 	ld [wd08a], a
 	ld c, $1
-	call Func_79339
+	call AdjustOAMBlockXPos2
 	ld hl, wOAMBuffer + $99
 	ld a, $fe
 	ld [wd08a], a
 	ld c, $1
-	call Func_79339
+	call AdjustOAMBlockXPos2
 	ld hl, wOAMBuffer + $9d
 	ld a, $ff
 	ld [wd08a], a
 	ld c, $1
-	call Func_79339
+	call AdjustOAMBlockXPos2
 	ld a, [rOBP1] ; $ff49
 	xor $64
 	ld [rOBP1], a ; $ff49
--- a/engine/overworld/doors.asm
+++ b/engine/overworld/doors.asm
@@ -1,4 +1,5 @@
-HandleDoors: ; 1a609 (6:6609)
+; returns whether the player is standing on a door in carry
+IsPlayerStandingOnDoor: ; 1a609 (6:6609)
 	push de
 	ld hl, DoorTileIDPointers ; $662c
 	ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET
@@ -5,22 +6,22 @@
 	ld de, $3
 	call IsInArray
 	pop de
-	jr nc, .asm_1a62a
+	jr nc, .notStandingOnDoor
 	inc hl
 	ld a, [hli]
 	ld h, [hl]
 	ld l, a
-	aCoord 8, 9
+	aCoord 8, 9 ; a = lower left background tile under player's sprite
 	ld b, a
-.asm_1a621
+.loop
 	ld a, [hli]
 	and a
-	jr z, .asm_1a62a
+	jr z, .notStandingOnDoor
 	cp b
-	jr nz, .asm_1a621
+	jr nz, .loop
 	scf
 	ret
-.asm_1a62a
+.notStandingOnDoor
 	and a
 	ret
 
--- a/engine/overworld/elevator.asm
+++ b/engine/overworld/elevator.asm
@@ -38,7 +38,7 @@
 	cp $b9
 	jr z, .asm_7bf57
 	call UpdateSprites
-	jp Func_2307
+	jp PlayDefaultMusic
 
 Func_7bf64: ; 7bf64 (1e:7f64)
 	ld hl, wd527
--- a/engine/overworld/ledges.asm
+++ b/engine/overworld/ledges.asm
@@ -43,12 +43,12 @@
 	ld [wJoyIgnore], a
 	ld hl, wd736
 	set 6, [hl]
-	call Func_3486
+	call StartSimulatingJoypadStates
 	ld a, e
-	ld [wccd3], a
-	ld [wccd4], a
+	ld [wSimulatedJoypadStatesEnd], a
+	ld [wSimulatedJoypadStatesEnd + 1], a
 	ld a, $2
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesIndex], a
 	call LoadHoppingShadowOAM
 	ld a, (SFX_02_4e - SFX_Headers_02) / 3
 	call PlaySound
--- a/engine/overworld/movement.asm
+++ b/engine/overworld/movement.asm
@@ -168,8 +168,8 @@
 	ld hl, wd730
 	res 0, [hl]
 	xor a
-	ld [wcd38], a
-	ld [wcd3a], a
+	ld [wSimulatedJoypadStatesIndex], a
+	ld [wWastedByteCD3A], a
 	ret
 .asm_4f4b
 	cp $fe
@@ -493,6 +493,8 @@
 	cp b
 	jr c, .spriteInvisible  ; right of screen region
 .skipXVisibilityTest
+; make the sprite invisible if a text box is in front of it
+; $5F is the maximum number for map tiles
 	call getTileSpriteStandsOn
 	ld d, $60
 	ld a, [hli]
@@ -719,8 +721,8 @@
 	bit 7, [hl]
 	set 7, [hl]
 	jp z, Func_52a6
-	ld hl, wcc97
-	ld a, [wcd37]
+	ld hl, wNPCMovementDirections2
+	ld a, [wNPCMovementDirections2Index]
 	add l
 	ld l, a
 	jr nc, .asm_5251
@@ -773,13 +775,13 @@
 	ret nz
 	ld a, $8
 	ld [wcf18], a
-	ld hl, wcd37
+	ld hl, wNPCMovementDirections2Index
 	inc [hl]
 	ret
 
 Func_52a6: ; 52a6 (1:52a6)
 	xor a
-	ld [wcd37], a
+	ld [wNPCMovementDirections2Index], a
 	ld a, $8
 	ld [wcf18], a
 	jp Func_52c3
--- a/engine/overworld/npc_movement.asm
+++ b/engine/overworld/npc_movement.asm
@@ -1,25 +1,25 @@
-Func_1a3e0: ; 1a3e0 (6:63e0)
+PlayerStepOutFromDoor: ; 1a3e0 (6:63e0)
 	ld hl, wd730
 	res 1, [hl]
-	call HandleDoors
-	jr nc, .asm_1a406
+	call IsPlayerStandingOnDoor
+	jr nc, .notStandingOnDoor
 	ld a, $fc
 	ld [wJoyIgnore], a
 	ld hl, wd736
 	set 1, [hl]
 	ld a, $1
-	ld [wcd38], a
-	ld a, $80
-	ld [wccd3], a
+	ld [wSimulatedJoypadStatesIndex], a
+	ld a, D_DOWN
+	ld [wSimulatedJoypadStatesEnd], a
 	xor a
 	ld [wSpriteStateData1 + 2], a
-	call Func_3486
+	call StartSimulatingJoypadStates
 	ret
-.asm_1a406
+.notStandingOnDoor
 	xor a
-	ld [wcd3a], a
-	ld [wcd38], a
-	ld [wccd3], a
+	ld [wWastedByteCD3A], a
+	ld [wSimulatedJoypadStatesIndex], a
+	ld [wSimulatedJoypadStatesEnd], a
 	ld hl, wd736
 	res 0, [hl]
 	res 1, [hl]
@@ -27,7 +27,7 @@
 	res 7, [hl]
 	ret
 
-Func_1a41d: ; 1a41d (6:641d)
+_EndNPCMovementScript: ; 1a41d (6:641d)
 	ld hl, wd730
 	res 7, [hl]
 	ld hl, wd72e
@@ -36,15 +36,15 @@
 	res 0, [hl]
 	res 1, [hl]
 	xor a
-	ld [wcf17], a
-	ld [wcc57], a
-	ld [wcf10], a
-	ld [wcd3a], a
-	ld [wcd38], a
-	ld [wccd3], a
+	ld [wNPCMovementScriptSpriteOffset], a
+	ld [wNPCMovementScriptPointerTableNum], a
+	ld [wNPCMovementScriptFunctionNum], a
+	ld [wWastedByteCD3A], a
+	ld [wSimulatedJoypadStatesIndex], a
+	ld [wSimulatedJoypadStatesEnd], a
 	ret
 
-PointerTable_1a442: ; 1a442 (6:6442)
+ProfOakMovementScriptPointerTable: ; 1a442 (6:6442)
 	dw Func_1a44c
 	dw Func_1a485
 	dw Func_1a4a1
@@ -58,20 +58,20 @@
 	jr z, .asm_1a475
 	ld b, $0
 	ld c, a
-	ld hl, wcc97
+	ld hl, wNPCMovementDirections2
 	ld a, $80
 	call FillMemory
 	ld [hl], $ff
 	ld a, [wcf13]
 	ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
-	ld de, wcc97
+	ld de, wNPCMovementDirections2
 	call MoveSprite
 	ld a, $1
-	ld [wcf10], a
+	ld [wNPCMovementScriptFunctionNum], a
 	jr .asm_1a47a
 .asm_1a475
 	ld a, $3
-	ld [wcf10], a
+	ld [wNPCMovementScriptFunctionNum], a
 .asm_1a47a
 	ld hl, W_FLAGS_D733
 	set 1, [hl]
@@ -84,33 +84,33 @@
 	bit 0, a
 	ret nz
 	ld a, [wcca1]
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesIndex], a
 	ld [$ff95], a
-	predef Func_f9a0
-	call Func_3486
+	predef ConvertNPCMovementDirectionsToJoypadMasks
+	call StartSimulatingJoypadStates
 	ld a, $2
-	ld [wcf10], a
+	ld [wNPCMovementScriptFunctionNum], a
 	ret
 
 Func_1a4a1: ; 1a4a1 (6:64a1)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 
 Func_1a4a6: ; 1a4a6 (6:64a6)
 	xor a
-	ld [wcd3b], a
+	ld [wOverrideSimulatedJoypadStatesMask], a
 	ld a, [wcf13]
 	swap a
-	ld [wcf17], a
+	ld [wNPCMovementScriptSpriteOffset], a
 	xor a
 	ld [wSpriteStateData2 + $06], a
-	ld hl, wccd3
+	ld hl, wSimulatedJoypadStatesEnd
 	ld de, RLEList_1a4e9
 	call DecodeRLEList
 	dec a
-	ld [wcd38], a
-	ld hl, wcc97
+	ld [wSimulatedJoypadStatesIndex], a
+	ld hl, wNPCMovementDirections2
 	ld de, RLEList_1a4dc
 	call DecodeRLEList
 	ld hl, wd72e
@@ -118,7 +118,7 @@
 	ld hl, wd730
 	set 7, [hl]
 	ld a, $4
-	ld [wcf10], a
+	ld [wNPCMovementScriptFunctionNum], a
 	ret
 
 RLEList_1a4dc: ; 1a4dc (6:64dc)
@@ -131,15 +131,15 @@
 	db $FF
 
 RLEList_1a4e9: ; 1a4e9 (6:64e9)
-	db $40, $02
-	db $10, $03
-	db $80, $05
-	db $20, $01
-	db $80, $06
+	db D_UP, $02
+	db D_RIGHT, $03
+	db D_DOWN, $05
+	db D_LEFT, $01
+	db D_DOWN, $06
 	db $FF
 
 Func_1a4f4: ; 1a4f4 (6:64f4)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	ld a, $0
@@ -149,11 +149,11 @@
 	res 7, [hl]
 	ld hl, wd72e
 	res 7, [hl]
-	jp Func_314e
+	jp EndNPCMovementScript
 
-PointerTable_1a510: ; 1a510 (6:6510)
+PewterMuseumGuyMovementScriptPointerTable: ; 1a510 (6:6510)
 	dw Func_1a514
-	dw Func_1a56b
+	dw PewterMovementScriptDone
 
 Func_1a514: ; 1a514 (6:6514)
 	ld a, BANK(Music_MuseumGuy)
@@ -164,30 +164,30 @@
 	call PlaySound
 	ld a, [wcf13]
 	swap a
-	ld [wcf17], a
-	call Func_3486
-	ld hl, wccd3
+	ld [wNPCMovementScriptSpriteOffset], a
+	call StartSimulatingJoypadStates
+	ld hl, wSimulatedJoypadStatesEnd
 	ld de, RLEList_PewterMuseumPlayer
 	call DecodeRLEList
 	dec a
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesIndex], a
 	xor a
 	ld [wd12f], a
 	predef PewterGuys
-	ld hl, wcc97
+	ld hl, wNPCMovementDirections2
 	ld de, RLEList_PewterMuseumGuy
 	call DecodeRLEList
 	ld hl, wd72e
 	res 7, [hl]
 	ld a, $1
-	ld [wcf10], a
+	ld [wNPCMovementScriptFunctionNum], a
 	ret
 
 RLEList_PewterMuseumPlayer: ; 1a559 (6:6559)
-	db $00, $01
-	db $40, $03
-	db $20, $0D
-	db $40, $06
+	db 0, $01
+	db D_UP, $03
+	db D_LEFT, $0D
+	db D_UP, $06
 	db $FF
 
 RLEList_PewterMuseumGuy: ; 1a562 (6:6562)
@@ -197,8 +197,8 @@
 	db $80, $01
 	db $FF
 
-Func_1a56b: ; 1a56b (6:656b)
-	ld a, [wcd38]
+PewterMovementScriptDone: ; 1a56b (6:656b)
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	ld hl, wd730
@@ -205,11 +205,11 @@
 	res 7, [hl]
 	ld hl, wd72e
 	res 7, [hl]
-	jp Func_314e
+	jp EndNPCMovementScript
 
-PointerTable_1a57d: ; 1a57d (6:657d)
+PewterGymGuyMovementScriptPointerTable: ; 1a57d (6:657d)
 	dw Func_1a581
-	dw Func_1a56b
+	dw PewterMovementScriptDone
 
 Func_1a581: ; 1a581 (6:6581)
 	ld a, BANK(Music_MuseumGuy)
@@ -220,18 +220,18 @@
 	call PlaySound
 	ld a, [wcf13]
 	swap a
-	ld [wcf17], a
+	ld [wNPCMovementScriptSpriteOffset], a
 	xor a
 	ld [wSpriteStateData2 + $06], a
-	ld hl, wccd3
+	ld hl, wSimulatedJoypadStatesEnd
 	ld de, RLEList_PewterGymPlayer
 	call DecodeRLEList
 	dec a
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesIndex], a
 	ld a, $1
 	ld [wd12f], a
 	predef PewterGuys
-	ld hl, wcc97
+	ld hl, wNPCMovementDirections2
 	ld de, RLEList_PewterGymGuy
 	call DecodeRLEList
 	ld hl, wd72e
@@ -239,16 +239,16 @@
 	ld hl, wd730
 	set 7, [hl]
 	ld a, $1
-	ld [wcf10], a
+	ld [wNPCMovementScriptFunctionNum], a
 	ret
 
 RLEList_PewterGymPlayer: ; 1a5cd (6:65cd)
-	db $00, $01
-	db $10, $02
-	db $80, $05
-	db $20, $0B
-	db $40, $05
-	db $20, $0F
+	db 0, $01
+	db D_RIGHT, $02
+	db D_DOWN, $05
+	db D_LEFT, $0B
+	db D_UP, $05
+	db D_LEFT, $0F
 	db $FF
 
 RLEList_PewterGymGuy: ; 1a5da (6:65da)
--- a/engine/overworld/pewter_guys.asm
+++ b/engine/overworld/pewter_guys.asm
@@ -1,8 +1,8 @@
 PewterGuys: ; 37ca1 (d:7ca1)
-	ld hl, wccd3
-	ld a, [wcd38]
-	dec a
-	ld [wcd38], a
+	ld hl, wSimulatedJoypadStatesEnd
+	ld a, [wSimulatedJoypadStatesIndex]
+	dec a ; this decrement causes it to overwrite the last byte before $FF in the list
+	ld [wSimulatedJoypadStatesIndex], a
 	ld d, 0
 	ld e, a
 	add hl, de
@@ -37,9 +37,9 @@
 	ret z
 	ld [de], a
 	inc de
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	inc a
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesIndex], a
 	jr .asm_37cd2
 .asm_37ce1
 	inc hl
--- a/engine/overworld/player_animations.asm
+++ b/engine/overworld/player_animations.asm
@@ -34,7 +34,7 @@
 	ld hl, wcd48
 	call Func_70730
 .asm_70558
-	call Func_2307
+	call PlayDefaultMusic
 .asm_7055b
 	jp Func_70772
 .asm_7055e
--- a/engine/overworld/ssanne.asm
+++ b/engine/overworld/ssanne.asm
@@ -1,37 +1,37 @@
-Func_79f54: ; 79f54 (1e:5f54)
+AnimateBoulderDust: ; 79f54 (1e:5f54)
 	ld a, $1
-	ld [wcd50], a
+	ld [wcd50], a ; select the boulder dust offsets
 	ld a, [wcfcb]
 	push af
 	ld a, $ff
 	ld [wcfcb], a
-	ld a, $e4
-	ld [rOBP1], a ; $ff49
+	ld a, %11100100
+	ld [rOBP1], a
 	call LoadSmokeTileFourTimes
-	callba asm_f055
-	ld c, $8
-.asm_79f73
+	callba WriteCutTreeBoulderDustAnimationOAMBlock
+	ld c, 8 ; number of steps in animation
+.loop
 	push bc
-	call Func_79f92
-	ld bc, .asm_79f7e
+	call GetMoveBoulderDustFunctionPointer
+	ld bc, .returnAddress
 	push bc
 	ld c, $4
 	jp [hl]
-.asm_79f7e
-	ld a, [rOBP1] ; $ff49
-	xor $64
-	ld [rOBP1], a ; $ff49
+.returnAddress
+	ld a, [rOBP1]
+	xor %01100100
+	ld [rOBP1], a
 	call Delay3
 	pop bc
 	dec c
-	jr nz, .asm_79f73
+	jr nz, .loop
 	pop af
 	ld [wcfcb], a
 	jp LoadPlayerSpriteGraphics
 
-Func_79f92: ; 79f92 (1e:5f92)
-	ld a, [wSpriteStateData1 + 9]
-	ld hl, PointerTable_79fb0 ; $5fb0
+GetMoveBoulderDustFunctionPointer: ; 79f92 (1e:5f92)
+	ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
+	ld hl, MoveBoulderDustFunctionPointerTable
 	ld c, a
 	ld b, $0
 	add hl, bc
@@ -51,18 +51,22 @@
 	pop hl
 	ret
 
-PointerTable_79fb0: ; 79fb0 (1e:5fb0)
+MoveBoulderDustFunctionPointerTable: ; 79fb0 (1e:5fb0)
+; facing down
 	db $FF,$00
-	dw Func_79350
+	dw AdjustOAMBlockYPos
 
+; facing up
 	db $01,$00
-	dw Func_79350
+	dw AdjustOAMBlockYPos
 
+; facing left
 	db $01,$01
-	dw Func_79337
+	dw AdjustOAMBlockXPos
 
+; facing right
 	db $FF,$01
-	dw Func_79337
+	dw AdjustOAMBlockXPos
 
 LoadSmokeTileFourTimes: ; 79fc0 (1e:5fc0)
 	ld hl, vChars1 + $7c0
--- a/engine/overworld/trainers.asm
+++ b/engine/overworld/trainers.asm
@@ -1,9 +1,9 @@
-Func_567f9: ; 567f9 (15:67f9)
+_GetSpritePosition1: ; 567f9 (15:67f9)
 	ld hl, wSpriteStateData1
 	ld de, $4
 	ld a, [wcf13]
-	ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
-	call Func_56903
+	ld [H_SPRITEINDEX], a
+	call GetSpriteDataPointer
 	ld a, [hli]
 	ld [$ffeb], a
 	inc hl
@@ -17,50 +17,50 @@
 	ld [$ffee], a
 	ret
 
-Func_56819: ; 56819 (15:6819)
+_GetSpritePosition2: ; 56819 (15:6819)
 	ld hl, wSpriteStateData1
-	ld de, $0004
+	ld de, $4
 	ld a, [wcf13]
-	ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
-	call Func_56903
-	ld a, [hli]
+	ld [H_SPRITEINDEX], a
+	call GetSpriteDataPointer
+	ld a, [hli] ; c1x4 (screen Y pos)
 	ld [wd130], a
 	inc hl
-	ld a, [hl]
+	ld a, [hl] ; c1x6 (screen X pos)
 	ld [wd131], a
-	ld de, $00fe
+	ld de, $104 - $6
 	add hl, de
-	ld a, [hli]
+	ld a, [hli] ; c2x4 (map Y pos)
 	ld [wd132], a
-	ld a, [hl]
+	ld a, [hl] ; c2x5 (map X pos)
 	ld [wd133], a
 	ret
 
-Func_5683d: ; 5683d (15:683d)
+_SetSpritePosition1: ; 5683d (15:683d)
 	ld hl, wSpriteStateData1
 	ld de, $4
 	ld a, [wcf13]
-	ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
-	call Func_56903
-	ld a, [$ffeb]
+	ld [H_SPRITEINDEX], a
+	call GetSpriteDataPointer
+	ld a, [$ffeb] ; c1x4 (screen Y pos)
 	ld [hli], a
 	inc hl
-	ld a, [$ffec]
+	ld a, [$ffec] ; c1x6 (screen X pos)
 	ld [hl], a
-	ld de, $fe
+	ld de, $104 - $6
 	add hl, de
-	ld a, [$ffed]
+	ld a, [$ffed] ; c2x4 (map Y pos)
 	ld [hli], a
-	ld a, [$ffee]
+	ld a, [$ffee] ; c2x5 (map X pos)
 	ld [hl], a
 	ret
 
-Func_5685d: ; 5685d (15:685d)
+_SetSpritePosition2: ; 5685d (15:685d)
 	ld hl, wSpriteStateData1
 	ld de, $0004
 	ld a, [wcf13]
-	ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
-	call Func_56903
+	ld [H_SPRITEINDEX], a
+	call GetSpriteDataPointer
 	ld a, [wd130]
 	ld [hli], a
 	inc hl
@@ -139,18 +139,20 @@
 	ld b, $0
 	ld a, $80           ; a = direction to go to
 .writeWalkScript
-	ld hl, wcc97
-	ld de, wcc97
+	ld hl, wNPCMovementDirections2
+	ld de, wNPCMovementDirections2
 	call FillMemory     ; write the necessary steps to reach player
 	ld [hl], $ff        ; write end of list sentinel
 	ld a, [wcf13]
-	ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
+	ld [H_SPRITEINDEX], a
 	jp MoveSprite_
 
-Func_56903: ; 56903 (15:6903)
+; input: de = offset within sprite entry
+; output: de = pointer to sprite data
+GetSpriteDataPointer: ; 56903 (15:6903)
 	push de
 	add hl, de
-	ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c
+	ld a, [H_SPRITEINDEX]
 	swap a
 	ld d, $0
 	ld e, a
--- a/engine/predefs.asm
+++ b/engine/predefs.asm
@@ -84,10 +84,10 @@
 	dbw $03,Func_3eb5 ; for these two, the bank number is actually 0
 	dbw $03,GiveItem
 	add_predef Func_480eb
-	add_predef Func_f8ba
+	add_predef FindPathToPlayer
 	add_predef Func_480ff
-	add_predef Func_f929
-	add_predef Func_f9a0
+	add_predef CalcPositionOfPlayerRelativeToNPC
+	add_predef ConvertNPCMovementDirectionsToJoypadMasks
 	add_predef Func_48125
 	add_predef UpdateHPBar
 	add_predef HPBarLength
--- a/engine/slot_machine.asm
+++ b/engine/slot_machine.asm
@@ -42,7 +42,7 @@
 	ld a, $1
 	ld [wcfcb], a
 	call GoPAL_SET_CF1C
-	call Func_3e08
+	call ReloadMapSpriteTilePatterns
 	call ReloadTilesetTilePatterns
 .skip
 	call LoadScreenTilesFromBuffer2
--- a/engine/turn_sprite.asm
+++ b/engine/turn_sprite.asm
@@ -1,25 +1,25 @@
-Func_13074: ; 13074 (4:7074)
+UpdateSpriteFacingOffsetAndDelayMovement: ; 13074 (4:7074)
 	ld h, $c2
 	ld a, [H_CURRENTSPRITEOFFSET]
 	add $8
 	ld l, a
-	ld a, $7f
-	ld [hl], a
+	ld a, $7f ; maximum movement delay
+	ld [hl], a ; c2x8 (movement delay)
 	dec h
 	ld a, [H_CURRENTSPRITEOFFSET]
 	add $9
 	ld l, a
-	ld a, [hld]
+	ld a, [hld] ; c1x9 (facing direction)
 	ld b, a
 	xor a
 	ld [hld], a
-	ld [hl], a
+	ld [hl], a ; c1x8 (walk animation frame)
 	ld a, [H_CURRENTSPRITEOFFSET]
 	add $2
 	ld l, a
-	ld a, [hl]
-	or b
+	ld a, [hl] ; c1x2 (facing and animation table offset)
+	or b ; or in the facing direction
 	ld [hld], a
-	ld a, $2
-	ld [hl], a
+	ld a, $2 ; delayed movement status
+	ld [hl], a ; c1x1 (movement status)
 	ret
--- a/home.asm
+++ b/home.asm
@@ -256,6 +256,7 @@
 	jp Bankswitch
 
 ; writes c to wd0dc+b
+; XXX unused?
 Func_137a:: ; 137a (0:137a)
 	ld hl, wd0dc
 	ld e, b
@@ -538,6 +539,7 @@
 	ld b,$41 ; no leading zeroes, left-aligned, one byte
 	jp PrintNumber
 
+; XXX unused?
 Func_152e:: ; 152e (0:152e)
 	ld hl,wd0dc
 	ld c,a
@@ -1627,7 +1629,7 @@
 	push hl
 	push de
 	push bc
-	callba Func_13074 ; update the graphics of the sprite the player is talking to (to face the right direction)
+	callba UpdateSpriteFacingOffsetAndDelayMovement ; update the graphics of the sprite the player is talking to (to face the right direction)
 	pop bc
 	pop de
 	ld hl,W_MAPSPRITEDATA ; NPC text entries
@@ -2686,7 +2688,7 @@
 	ret
 
 Func_30fd:: ; 30fd (0:30fd)
-	ld a, [wcc57]
+	ld a, [wNPCMovementScriptPointerTableNum]
 	and a
 	ret nz
 	ld a, [wd736]
@@ -2696,19 +2698,19 @@
 	and $80
 	ret
 
-Func_310e:: ; 310e (0:310e)
+RunNPCMovementScript:: ; 310e (0:310e)
 	ld hl, wd736
 	bit 0, [hl]
 	res 0, [hl]
-	jr nz, .asm_3146
-	ld a, [wcc57]
+	jr nz, .playerStepOutFromDoor
+	ld a, [wNPCMovementScriptPointerTableNum]
 	and a
 	ret z
 	dec a
 	add a
-	ld d, $0
+	ld d, 0
 	ld e, a
-	ld hl, .pointerTable_3140
+	ld hl, .NPCMovementScriptPointerTables
 	add hl, de
 	ld a, [hli]
 	ld h, [hl]
@@ -2715,27 +2717,27 @@
 	ld l, a
 	ld a, [H_LOADEDROMBANK]
 	push af
-	ld a, [wcc58]
+	ld a, [wNPCMovementScriptBank]
 	ld [H_LOADEDROMBANK], a
 	ld [$2000], a
-	ld a, [wcf10]
+	ld a, [wNPCMovementScriptFunctionNum]
 	call CallFunctionInTable
 	pop af
 	ld [H_LOADEDROMBANK], a
 	ld [$2000], a
 	ret
-.pointerTable_3140
-	dw PointerTable_1a442
-	dw PointerTable_1a510
-	dw PointerTable_1a57d
-.asm_3146
-	ld b, BANK(Func_1a3e0)
-	ld hl, Func_1a3e0
+.NPCMovementScriptPointerTables
+	dw ProfOakMovementScriptPointerTable
+	dw PewterMuseumGuyMovementScriptPointerTable
+	dw PewterGymGuyMovementScriptPointerTable
+.playerStepOutFromDoor
+	ld b, BANK(PlayerStepOutFromDoor)
+	ld hl, PlayerStepOutFromDoor
 	jp Bankswitch
 
-Func_314e:: ; 314e (0:314e)
-	ld b, BANK(Func_1a41d)
-	ld hl, Func_1a41d
+EndNPCMovementScript:: ; 314e (0:314e)
+	ld b, BANK(_EndNPCMovementScript)
+	ld hl, _EndNPCMovementScript
 	jp Bankswitch
 
 Func_3156:: ; 3156 (0:3156)
@@ -2978,22 +2980,22 @@
 	ld [W_CURENEMYLVL], a ; W_CURENEMYLVL
 	ret
 
-Func_32ef:: ; 32ef (0:32ef)
-	ld hl, Func_567f9
+GetSpritePosition1:: ; 32ef (0:32ef)
+	ld hl, _GetSpritePosition1
 	jr asm_3301
 
-Func_32f4:: ; 32f4 (0:32f4)
-	ld hl, Func_56819
+GetSpritePosition2:: ; 32f4 (0:32f4)
+	ld hl, _GetSpritePosition2
 	jr asm_3301 ; 0x32f7 $8
 
-Func_32f9:: ; 32f9 (0:32f9)
-	ld hl, Func_5683d
+SetSpritePosition1:: ; 32f9 (0:32f9)
+	ld hl, _SetSpritePosition1
 	jr asm_3301
 
-Func_32fe:: ; 32fe (0:32fe)
-	ld hl, Func_5685d
+SetSpritePosition2:: ; 32fe (0:32fe)
+	ld hl, _SetSpritePosition2
 asm_3301:: ; 3301 (0:3301)
-	ld b, BANK(Func_567f9) ; BANK(Func_56819), BANK(Func_5683d), BANK(Func_5685d)
+	ld b, BANK(_GetSpritePosition1) ; BANK(_GetSpritePosition2), BANK(_SetSpritePosition1), BANK(_SetSpritePosition2)
 	jp Bankswitch ; indirect jump to one of the four functions
 
 CheckForEngagingTrainers:: ; 3306 (0:3306)
@@ -3187,10 +3189,10 @@
 	ld a, [hli]
 	ld d, [hl]
 	ld e, a
-	ld hl, wccd3
+	ld hl, wSimulatedJoypadStatesEnd
 	call DecodeRLEList
 	dec a
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesIndex], a
 	ret
 .asm_345b
 	inc hl
@@ -3225,10 +3227,10 @@
 	ld hl, ActivatePC
 	jr bankswitchAndContinue
 
-Func_3486:: ; 3486 (0:3486)
+StartSimulatingJoypadStates:: ; 3486 (0:3486)
 	xor a
-	ld [wcd3b], a
-	ld [wSpriteStateData2 + $06], a
+	ld [wOverrideSimulatedJoypadStatesMask], a
+	ld [wSpriteStateData2 + $06], a ; player's sprite movement byte 1
 	ld hl, wd730
 	set 7, [hl]
 	ret
@@ -3249,21 +3251,21 @@
 	ld hl, Func_7c18
 	jp Bankswitch
 
-Func_34a6:: ; 34a6 (0:34a6)
-	call Func_34ae
+SetSpriteFacingDirectionAndDelay:: ; 34a6 (0:34a6)
+	call SetSpriteFacingDirection
 	ld c, $6
 	jp DelayFrames
 
-Func_34ae:: ; 34ae (0:34ae)
+SetSpriteFacingDirection:: ; 34ae (0:34ae)
 	ld a, $9
-	ld [H_DOWNARROWBLINKCNT1], a ; $ff8b
-	call Func_34fc
+	ld [H_SPRITEDATAOFFSET], a
+	call GetPointerWithinSpriteStateData1
 	ld a, [$ff8d]
 	ld [hl], a
 	ret
 
-Func_34b9:: ; 34b9 (0:34b9)
-	ld de, $fff9
+SetSpriteImageIndexAfterSettingFacingDirection:: ; 34b9 (0:34b9)
+	ld de, -7
 	add hl, de
 	ld [hl], a
 	ret
@@ -3332,16 +3334,17 @@
 	pop hl
 	jp CheckCoords
 
-Func_34fc:: ; 34fc (0:34fc)
+GetPointerWithinSpriteStateData1:: ; 34fc (0:34fc)
 	ld h, $c1
-	jr asm_3502
+	jr _GetPointerWithinSpriteStateData
 
-Func_3500:: ; 3500 (0:3500)
+GetPointerWithinSpriteStateData2:: ; 3500 (0:3500)
 	ld h, $c2
-asm_3502:: ; 3502 (0:3502)
-	ld a, [H_DOWNARROWBLINKCNT1] ; $ff8b
+
+_GetPointerWithinSpriteStateData:
+	ld a, [H_SPRITEDATAOFFSET]
 	ld b, a
-	ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c
+	ld a, [H_SPRITEINDEX]
 	swap a
 	add b
 	ld l, a
@@ -3402,7 +3405,7 @@
 ; returns the sprite movement byte 1 pointer for sprite [$FF8C] in hl
 GetSpriteMovementByte1Pointer:: ; 354e (0:354e)
 	ld h,$C2
-	ld a,[$FF8C] ; the sprite to move
+	ld a,[H_SPRITEINDEX] ; the sprite to move
 	swap a
 	add a,6
 	ld l,a
@@ -3591,14 +3594,15 @@
 	set 0,[hl]
 	pop hl
 	xor a
-	ld [wcd3b],a
-	ld [wccd3],a
+	ld [wOverrideSimulatedJoypadStatesMask],a
+	ld [wSimulatedJoypadStatesEnd],a
 	dec a
 	ld [wJoyIgnore],a
-	ld [wcd3a],a
+	ld [wWastedByteCD3A],a
 	ret
 
-Func_366b:: ; 366b (0:366b)
+; divides [$ffe5] by [$ffe6] and stores the quotient in [$ffe7]
+DivideBytes:: ; 366b (0:366b)
 	push hl
 	ld hl, $ffe7
 	xor a
@@ -3605,16 +3609,16 @@
 	ld [hld], a
 	ld a, [hld]
 	and a
-	jr z, .asm_367e
+	jr z, .done
 	ld a, [hli]
-.asm_3676
+.loop
 	sub [hl]
-	jr c, .asm_367e
+	jr c, .done
 	inc hl
 	inc [hl]
 	dec hl
-	jr .asm_3676
-.asm_367e
+	jr .loop
+.done
 	pop hl
 	ret
 
@@ -5008,11 +5012,11 @@
 	ret
 
 
-Func_3dbe:: ; 3dbe (0:3dbe)
+RestoreScreenTilesAndReloadTilePatterns:: ; 3dbe (0:3dbe)
 	call ClearSprites
 	ld a, $1
 	ld [wcfcb], a
-	call Func_3e08
+	call ReloadMapSpriteTilePatterns
 	call LoadScreenTilesFromBuffer2
 	call LoadTextBoxTilePatterns
 	call GoPAL_SET_CF1C
@@ -5068,7 +5072,9 @@
 	ld [hl], d
 	ret
 
-Func_3e08:: ; 3e08 (0:3e08)
+; Copy the current map's sprites' tile patterns to VRAM again after they have
+; been overwritten by other tile patterns.
+ReloadMapSpriteTilePatterns:: ; 3e08 (0:3e08)
 	ld hl, wcfc4
 	ld a, [hl]
 	push af
@@ -5075,7 +5081,7 @@
 	res 0, [hl]
 	push hl
 	xor a
-	ld [W_SPRITESETID], a ; W_SPRITESETID
+	ld [W_SPRITESETID], a
 	call DisableLCD
 	callba InitMapSprites
 	call EnableLCD
--- a/home/audio.asm
+++ b/home/audio.asm
@@ -1,4 +1,4 @@
-Func_2307:: ; 2307 (0:2307)
+PlayDefaultMusic:: ; 2307 (0:2307)
 	call WaitForSoundToFinish
 	xor a
 	ld c, a
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -362,7 +362,7 @@
 
 ; function to make bikes twice as fast as walking
 BikeSpeedup:: ; 06a0 (0:06a0)
-	ld a,[wcc57]
+	ld a,[wNPCMovementScriptPointerTableNum]
 	and a
 	ret nz
 	ld a,[W_CURMAP]
@@ -520,7 +520,7 @@
 	ld [wd35d],a
 .done
 	ld hl,wd736
-	set 0,[hl]
+	set 0,[hl] ; have the player's sprite step out from the door (if there is one)
 	call Func_12da
 	jp EnterMap
 
@@ -1203,9 +1203,9 @@
 	bit 6,a ; is the player jumping?
 	jr nz,.noCollision
 ; if not jumping a ledge
-	ld a,[wcd38]
+	ld a,[wSimulatedJoypadStatesIndex]
 	and a
-	jr nz,.noCollision
+	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 d,a
 	ld a,[wSpriteStateData1 + 12] ; the player sprite's collision data (bit field) (set in the sprite movement code)
@@ -1835,10 +1835,10 @@
 	ld a,[W_CURMAP]
 	cp a,ROUTE_17 ; Cycling Road
 	jr nz,.notForcedDownwards
-	ld a,[hJoyHeld] ; current joypad state
-	and a,%11110011 ; bit mask for all directions and A/B
+	ld a,[hJoyHeld]
+	and a,D_DOWN | D_UP | D_LEFT | D_RIGHT | B_BUTTON | A_BUTTON
 	jr nz,.notForcedDownwards
-	ld a,%10000000 ; down pressed
+	ld a,D_DOWN
 	ld [hJoyHeld],a ; on the cycling road, if there isn't a trainer and the player isn't pressing buttons, simulate a down press
 .notForcedDownwards
 	ld a,[wd730]
@@ -1845,18 +1845,17 @@
 	bit 7,a
 	ret z
 ; if simulating button presses
-	ld a,[hJoyHeld] ; current joypad state
+	ld a,[hJoyHeld]
 	ld b,a
-	ld a,[wcd3b] ; bit mask for button presses that override simulated ones
+	ld a,[wOverrideSimulatedJoypadStatesMask] ; bit mask for button presses that override simulated ones
 	and b
 	ret nz ; return if the simulated button presses are overridden
-	ld hl,wcd38 ; index of current simulated button press
+	ld hl,wSimulatedJoypadStatesIndex
 	dec [hl]
 	ld a,[hl]
 	cp a,$ff
 	jr z,.doneSimulating ; if the end of the simulated button presses has been reached
-	ld hl,wccd3 ; base address of simulated button presses
-; add offset to base address
+	ld hl,wSimulatedJoypadStatesEnd
 	add l
 	ld l,a
 	jr nc,.noCarry
@@ -1872,9 +1871,9 @@
 ; if done simulating button presses
 .doneSimulating
 	xor a
-	ld [wcd3a],a
-	ld [wcd38],a
-	ld [wccd3],a
+	ld [wWastedByteCD3A],a
+	ld [wSimulatedJoypadStatesIndex],a
+	ld [wSimulatedJoypadStatesEnd],a
 	ld [wJoyIgnore],a
 	ld [hJoyHeld],a
 	ld hl,wd736
@@ -1944,7 +1943,7 @@
 	xor a
 	ld [wd700],a
 	call LoadPlayerSpriteGraphics
-	call Func_2307
+	call PlayDefaultMusic
 	jr .noCollision
 .checkIfVermilionDockTileset
 	ld a, [W_CURMAPTILESET] ; tileset
@@ -1957,16 +1956,16 @@
 	push hl
 	push de
 	push bc
-	callba Func_f225 ; check if the player is pushing a boulder
+	callba TryPushingBoulder
 	ld a,[wFlags_0xcd60]
-	bit 1,a ; is the player pushing a boulder?
+	bit 1,a ; play boulder dust animation
 	jr z,.afterBoulderEffect
-	callba Func_f2b5 ; displays dust effect when pushing a boulder
+	callba DoBoulderDustAnimation
 .afterBoulderEffect
 	pop bc
 	pop de
 	pop hl
-	call Func_310e
+	call RunNPCMovementScript
 	ld a,[W_CURMAP] ; current map number
 	call SwitchToMapRomBank ; change to the ROM bank the map's data is in
 	ld hl,W_MAPSCRIPTPTR
@@ -2400,4 +2399,4 @@
 	ld b, BANK(RedSprite)
 	ld hl, LoadPlayerSpriteGraphics
 	call Bankswitch
-	jp Func_2307 ; update map/player state?
+	jp PlayDefaultMusic ; update map/player state?
--- a/hram.asm
+++ b/hram.asm
@@ -14,6 +14,9 @@
 H_DOWNARROWBLINKCNT1 EQU $FF8B
 H_DOWNARROWBLINKCNT2 EQU $FF8C
 
+H_SPRITEDATAOFFSET EQU $FF8B
+H_SPRITEINDEX      EQU $FF8C
+
 ; Note: the following multiplication and division addresses are used for multiple purposes
 ; and so they overlap with each other
 
--- a/main.asm
+++ b/main.asm
@@ -26,9 +26,9 @@
 	ld [wd700], a
 	ld [W_ISINBATTLE], a
 	ld [wd35d], a
-	ld [wcf10], a
+	ld [wNPCMovementScriptFunctionNum], a
 	ld [hJoyHeld], a
-	ld [wcc57], a
+	ld [wNPCMovementScriptPointerTableNum], a
 	ld [wFlags_0xcd60], a
 
 	ld [$ff9f], a
@@ -213,7 +213,7 @@
 	dec a
 	swap a
 	ld [$ff93], a  ; $10 * sprite#
-	ld a, [wcf17] ; some sprite offset?
+	ld a, [wNPCMovementScriptSpriteOffset] ; some sprite offset?
 	ld b, a
 	ld a, [H_CURRENTSPRITEOFFSET]
 	cp b
@@ -2247,7 +2247,7 @@
 	push hl
 	push de
 	push bc
-	callba HandleDoors
+	callba IsPlayerStandingOnDoor
 	jr c, .asm_c4c8
 	ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET
 	add a
@@ -3388,23 +3388,23 @@
 	ld c, a
 	ret
 
-Func_f225: ; f225 (3:7225)
+TryPushingBoulder: ; f225 (3:7225)
 	ld a, [wd728]
-	bit 0, a
+	bit 0, a ; using Strength?
 	ret z
 	ld a, [wFlags_0xcd60]
-	bit 1, a
+	bit 1, a ; has boulder dust animation from previous push played yet?
 	ret nz
 	xor a
-	ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
+	ld [$ff8c], a
 	call IsSpriteInFrontOfPlayer
-	ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c
+	ld a, [$ff8c]
 	ld [wd718], a
 	and a
-	jp z, Func_f2dd
+	jp z, ResetBoulderPushFlags
 	ld hl, wSpriteStateData1 + 1
 	ld d, $0
-	ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c
+	ld a, [$ff8c]
 	swap a
 	ld e, a
 	add hl, de
@@ -3411,12 +3411,12 @@
 	res 7, [hl]
 	call GetSpriteMovementByte2Pointer
 	ld a, [hl]
-	cp $10
-	jp nz, Func_f2dd
+	cp BOULDER_MOVEMENT_BYTE_2
+	jp nz, ResetBoulderPushFlags
 	ld hl, wFlags_0xcd60
 	bit 6, [hl]
-	set 6, [hl]
-	ret z
+	set 6, [hl] ; indicate that the player has tried pushing
+	ret z ; the player must try pushing twice before the boulder will move
 	ld a, [hJoyHeld]
 	and $f0
 	ret z
@@ -3423,35 +3423,36 @@
 	predef Func_c60b
 	ld a, [wd71c]
 	and a
-	jp nz, Func_f2dd
+	jp nz, ResetBoulderPushFlags
 	ld a, [hJoyHeld]
 	ld b, a
-	ld a, [wSpriteStateData1 + 9]
-	cp $4
-	jr z, .asm_f289
-	cp $8
-	jr z, .asm_f291
-	cp $c
-	jr z, .asm_f299
+	ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
+	cp SPRITE_FACING_UP
+	jr z, .pushBoulderUp
+	cp SPRITE_FACING_LEFT
+	jr z, .pushBoulderLeft
+	cp SPRITE_FACING_RIGHT
+	jr z, .pushBoulderRight
+.pushBoulderDown
 	bit 7, b
 	ret z
-	ld de, MovementData_f2af
-	jr .asm_f29f
-.asm_f289
+	ld de, PushBoulderDownMovementData
+	jr .done
+.pushBoulderUp
 	bit 6, b
 	ret z
-	ld de, MovementData_f2ad
-	jr .asm_f29f
-.asm_f291
+	ld de, PushBoulderUpMovementData
+	jr .done
+.pushBoulderLeft
 	bit 5, b
 	ret z
-	ld de, MovementData_f2b1
-	jr .asm_f29f
-.asm_f299
+	ld de, PushBoulderLeftMovementData
+	jr .done
+.pushBoulderRight
 	bit 4, b
 	ret z
-	ld de, MovementData_f2b3
-.asm_f29f
+	ld de, PushBoulderRightMovementData
+.done
 	call MoveSprite
 	ld a, (SFX_02_53 - SFX_Headers_02) / 3
 	call PlaySound
@@ -3459,26 +3460,26 @@
 	set 1, [hl]
 	ret
 
-MovementData_f2ad: ; f2ad (3:72ad)
-	db $40,$FF
+PushBoulderUpMovementData: ; f2ad (3:72ad)
+	db NPC_MOVEMENT_UP,$FF
 
-MovementData_f2af: ; f2af (3:72af)
-	db $00,$FF
+PushBoulderDownMovementData: ; f2af (3:72af)
+	db NPC_MOVEMENT_DOWN,$FF
 
-MovementData_f2b1: ; f2b1 (3:72b1)
-	db $80,$FF
+PushBoulderLeftMovementData: ; f2b1 (3:72b1)
+	db NPC_MOVEMENT_LEFT,$FF
 
-MovementData_f2b3: ; f2b3 (3:72b3)
-	db $C0,$FF
+PushBoulderRightMovementData: ; f2b3 (3:72b3)
+	db NPC_MOVEMENT_RIGHT,$FF
 
-Func_f2b5: ; f2b5 (3:72b5)
+DoBoulderDustAnimation: ; f2b5 (3:72b5)
 	ld a, [wd730]
 	bit 0, a
 	ret nz
-	callab Func_79f54
+	callab AnimateBoulderDust
 	call DiscardButtonPresses
 	ld [wJoyIgnore], a
-	call Func_f2dd
+	call ResetBoulderPushFlags
 	set 7, [hl]
 	ld a, [wd718]
 	ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
@@ -3487,7 +3488,7 @@
 	ld a, (SFX_02_56 - SFX_Headers_02) / 3
 	jp PlaySound
 
-Func_f2dd: ; f2dd (3:72dd)
+ResetBoulderPushFlags: ; f2dd (3:72dd)
 	ld hl, wFlags_0xcd60
 	res 1, [hl]
 	res 6, [hl]
@@ -4460,7 +4461,7 @@
 	ld b, $0
 	ret
 
-Func_f8ba: ; f8ba (3:78ba)
+FindPathToPlayer: ; f8ba (3:78ba)
 	xor a
 	ld hl, $ff97
 	ld [hli], a
@@ -4467,13 +4468,12 @@
 	ld [hli], a
 	ld [hli], a
 	ld [hl], a
-	ld hl, wcc97
+	ld hl, wNPCMovementDirections2
 	ld de, $0
-
-Func_f8c8: ; f8c8 (3:78c8)
-	ld a, [H_REMAINDER] ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN)
+.loop
+	ld a, [$ff99]
 	ld b, a
-	ld a, [H_DIVIDEND] ; $ff95 (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT)
+	ld a, [$ff95] ; Y distance in steps
 	call CalcDifference
 	ld d, a
 	and a
@@ -4484,7 +4484,7 @@
 .asm_f8da
 	ld a, [$ff9a]
 	ld b, a
-	ld a, [H_NUMTOPRINT] ; $ff96 (aliases: H_MULTIPLICAND)
+	ld a, [$ff96] ; X distance in steps
 	call CalcDifference
 	ld e, a
 	and a
@@ -4495,7 +4495,7 @@
 .asm_f8ec
 	ld a, [$ff98]
 	cp $3
-	jr z, .asm_f926
+	jr z, .done
 	ld a, e
 	cp d
 	jr c, .asm_f90a
@@ -4502,10 +4502,10 @@
 	ld a, [$ff9d]
 	bit 1, a
 	jr nz, .asm_f900
-	ld d, $c0
+	ld d, NPC_MOVEMENT_RIGHT
 	jr .asm_f902
 .asm_f900
-	ld d, $80
+	ld d, NPC_MOVEMENT_LEFT
 .asm_f902
 	ld a, [$ff9a]
 	add $1
@@ -4515,14 +4515,14 @@
 	ld a, [$ff9d]
 	bit 0, a
 	jr nz, .asm_f914
-	ld d, $0
+	ld d, NPC_MOVEMENT_DOWN
 	jr .asm_f916
 .asm_f914
-	ld d, $40
+	ld d, NPC_MOVEMENT_UP
 .asm_f916
-	ld a, [H_REMAINDER] ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN)
+	ld a, [$ff99]
 	add $1
-	ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN)
+	ld [$ff99], a
 .asm_f91c
 	ld a, d
 	ld [hli], a
@@ -4529,77 +4529,79 @@
 	ld a, [$ff97]
 	inc a
 	ld [$ff97], a
-	jp Func_f8c8
-.asm_f926
+	jp .loop
+.done
 	ld [hl], $ff
 	ret
 
-Func_f929: ; f929 (3:7929)
+CalcPositionOfPlayerRelativeToNPC: ; f929 (3:7929)
 	xor a
 	ld [$ff9d], a
-	ld a, [wSpriteStateData1 + 4]
+	ld a, [wSpriteStateData1 + 4] ; player's sprite screen Y position in pixels
 	ld d, a
-	ld a, [wSpriteStateData1 + 6]
+	ld a, [wSpriteStateData1 + 6] ; player's sprite screen X position in pixels
 	ld e, a
 	ld hl, wSpriteStateData1
-	ld a, [H_DIVIDEND] ; $ff95 (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT)
+	ld a, [$ff95] ; sprite offset
 	add l
 	add $4
 	ld l, a
-	jr nc, .asm_f940
+	jr nc, .noCarry
 	inc h
-.asm_f940
+.noCarry
 	ld a, d
 	ld b, a
-	ld a, [hli]
+	ld a, [hli] ; NPC sprite screen Y position in pixels
 	call CalcDifference
-	jr nc, .asm_f953
+	jr nc, .NPCSouthOfOrAlignedWithPlayer
+.NPCNorthOfPlayer
 	push hl
 	ld hl, $ff9d
 	bit 0, [hl]
 	set 0, [hl]
 	pop hl
-	jr .asm_f95c
-.asm_f953
+	jr .divideYDistance
+.NPCSouthOfOrAlignedWithPlayer
 	push hl
 	ld hl, $ff9d
 	bit 0, [hl]
 	res 0, [hl]
 	pop hl
-.asm_f95c
+.divideYDistance
 	push hl
 	ld hl, $ffe5
 	ld [hli], a
-	ld a, $10
+	ld a, 16
 	ld [hli], a
-	call Func_366b
-	ld a, [hl]
-	ld [H_DIVIDEND], a ; $ff95 (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT)
+	call DivideBytes ; divide Y absolute distance by 16
+	ld a, [hl] ; quotient
+	ld [$ff95], a
 	pop hl
 	inc hl
 	ld b, e
-	ld a, [hl]
+	ld a, [hl] ; NPC sprite screen X position in pixels
 	call CalcDifference
-	jr nc, .asm_f97e
+	jr nc, .NPCEastOfOrAlignedWithPlayer
+.NPCWestOfPlayer
 	push hl
 	ld hl, $ff9d
 	bit 1, [hl]
 	set 1, [hl]
 	pop hl
-	jr .asm_f987
-.asm_f97e
+	jr .divideXDistance
+.NPCEastOfOrAlignedWithPlayer
 	push hl
 	ld hl, $ff9d
 	bit 1, [hl]
 	res 1, [hl]
 	pop hl
-.asm_f987
+.divideXDistance
 	ld [$ffe5], a
-	ld a, $10
+	ld a, 16
 	ld [$ffe6], a
-	call Func_366b
-	ld a, [$ffe7]
-	ld [H_NUMTOPRINT], a ; $ff96 (aliases: H_MULTIPLICAND)
+	call DivideBytes ; divide X absolute distance by 16
+	ld a, [$ffe7] ; quotient
+	ld [$ff96], a
 	ld a, [$ff9b]
 	and a
 	ret z
@@ -4609,47 +4611,51 @@
 	ld [$ff9d], a
 	ret
 
-Func_f9a0: ; f9a0 (3:79a0)
+ConvertNPCMovementDirectionsToJoypadMasks: ; f9a0 (3:79a0)
 	ld a, [$ff95]
-	ld [wcd37], a
+	ld [wNPCMovementDirections2Index], a
 	dec a
-	ld de, wccd3
-	ld hl, wcc97
+	ld de, wSimulatedJoypadStatesEnd
+	ld hl, wNPCMovementDirections2
 	add l
 	ld l, a
-	jr nc, .asm_f9b1
+	jr nc, .loop
 	inc h
-.asm_f9b1
+.loop
 	ld a, [hld]
-	call Func_f9bf
+	call ConvertNPCMovementDirectionToJoypadMask
 	ld [de], a
 	inc de
 	ld a, [$ff95]
 	dec a
 	ld [$ff95], a
-	jr nz, .asm_f9b1
+	jr nz, .loop
 	ret
 
-Func_f9bf: ; f9bf (3:79bf)
+ConvertNPCMovementDirectionToJoypadMask: ; f9bf (3:79bf)
 	push hl
 	ld b, a
-	ld hl, DataTable_f9d2
-.asm_f9c4
+	ld hl, NPCMovementDirectionsToJoypadMasksTable
+.loop
 	ld a, [hli]
 	cp $ff
-	jr z, .asm_f9d0
+	jr z, .done
 	cp b
-	jr z, .asm_f9cf
+	jr z, .loadJoypadMask
 	inc hl
-	jr .asm_f9c4
-.asm_f9cf
+	jr .loop
+.loadJoypadMask
 	ld a, [hl]
-.asm_f9d0
+.done
 	pop hl
 	ret
 
-DataTable_f9d2: ; f9d2 (3:79d2)
-	db $40, $40, $00, $80, $80, $20, $c0, $10, $ff
+NPCMovementDirectionsToJoypadMasksTable: ; f9d2 (3:79d2)
+	db NPC_MOVEMENT_UP, D_UP
+	db NPC_MOVEMENT_DOWN, D_DOWN
+	db NPC_MOVEMENT_LEFT, D_LEFT
+	db NPC_MOVEMENT_RIGHT, D_RIGHT
+	db $ff
 
 Func_f9db: ; f9db (3:79db)
 	ret
--- a/scripts/agatha.asm
+++ b/scripts/agatha.asm
@@ -41,8 +41,8 @@
 AgathaScript4: ; 76473 (1d:6473)
 	ret
 asm_76474: ; 76474 (1d:6474)
-	ld hl, wccd3
-	ld a, $40
+	ld hl, wSimulatedJoypadStatesEnd
+	ld a, D_UP
 	ld [hli], a
 	ld [hli], a
 	ld [hli], a
@@ -50,8 +50,8 @@
 	ld [hli], a
 	ld [hl], a
 	ld a, $6
-	ld [wcd38], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesIndex], a
+	call StartSimulatingJoypadStates
 	ld a, $3
 	ld [W_AGATHACURSCRIPT], a
 	ld [W_CURMAPSCRIPT], a
@@ -64,8 +64,8 @@
 	xor a
 	ld [hJoyPressed], a
 	ld [hJoyHeld], a
-	ld [wccd3], a
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesEnd], a
+	ld [wSimulatedJoypadStatesIndex], a
 	ld a, [wWhichTrade] ; wWhichTrade
 	cp $3
 	jr c, .asm_764b4
@@ -77,11 +77,11 @@
 	ld a, $2
 	ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
 	call DisplayTextID
-	ld a, $40
-	ld [wccd3], a
+	ld a, D_UP
+	ld [wSimulatedJoypadStatesEnd], a
 	ld a, $1
-	ld [wcd38], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesIndex], a
+	call StartSimulatingJoypadStates
 	ld a, $3
 	ld [W_AGATHACURSCRIPT], a
 	ld [W_CURMAPSCRIPT], a
@@ -95,7 +95,7 @@
 	db $FF
 
 AgathaScript3: ; 764da (1d:64da)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	call Delay3
--- a/scripts/battlecenterm.asm
+++ b/scripts/battlecenterm.asm
@@ -9,7 +9,7 @@
 	ld [$ff8d], a
 	ld a, $1
 	ld [$ff8c], a
-	call Func_34ae
+	call SetSpriteFacingDirection
 	ld hl, wd72d
 	bit 0, [hl]
 	set 0, [hl]
--- a/scripts/billshouse.asm
+++ b/scripts/billshouse.asm
@@ -66,7 +66,7 @@
 	ld [$ffed], a
 	ld a, $5
 	ld [$ffee], a
-	call Func_32f9
+	call SetSpritePosition1
 	ld a, $62
 	ld [wcc4d], a
 	predef ShowObject
--- a/scripts/bruno.asm
+++ b/scripts/bruno.asm
@@ -41,8 +41,8 @@
 BrunoScript4: ; 7631c (1d:631c)
 	ret
 asm_7631d: ; 7631d (1d:631d)
-	ld hl, wccd3
-	ld a, $40
+	ld hl, wSimulatedJoypadStatesEnd
+	ld a, D_UP
 	ld [hli], a
 	ld [hli], a
 	ld [hli], a
@@ -50,8 +50,8 @@
 	ld [hli], a
 	ld [hl], a
 	ld a, $6
-	ld [wcd38], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesIndex], a
+	call StartSimulatingJoypadStates
 	ld a, $3
 	ld [W_BRUNOCURSCRIPT], a
 	ld [W_CURMAPSCRIPT], a
@@ -64,8 +64,8 @@
 	xor a
 	ld [hJoyPressed], a
 	ld [hJoyHeld], a
-	ld [wccd3], a
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesEnd], a
+	ld [wSimulatedJoypadStatesIndex], a
 	ld a, [wWhichTrade] ; wWhichTrade
 	cp $3
 	jr c, .asm_7635d
@@ -77,11 +77,11 @@
 	ld a, $2
 	ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
 	call DisplayTextID
-	ld a, $40
-	ld [wccd3], a
+	ld a, D_UP
+	ld [wSimulatedJoypadStatesEnd], a
 	ld a, $1
-	ld [wcd38], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesIndex], a
+	call StartSimulatingJoypadStates
 	ld a, $3
 	ld [W_BRUNOCURSCRIPT], a
 	ld [W_CURMAPSCRIPT], a
@@ -95,7 +95,7 @@
 	db $FF
 
 BrunoScript3: ; 76383 (1d:6383)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	call Delay3
--- a/scripts/ceruleancity.asm
+++ b/scripts/ceruleancity.asm
@@ -85,7 +85,7 @@
 	ld [$ff8c], a
 	ld a, $5
 	ld [$ff8b], a
-	call Func_3500
+	call GetPointerWithinSpriteStateData2
 	ld [hl], $19
 .asm_19535
 	ld a, $5
@@ -117,7 +117,7 @@
 	ld [$ff8c],a
 	xor a
 	ld [$ff8d],a
-	jp Func_34a6 ; face object
+	jp SetSpriteFacingDirectionAndDelay ; face object
 
 CeruleanCityScript1: ; 19567 (6:5567)
 	ld a, [wd730]
@@ -209,7 +209,7 @@
 	predef HideObject
 	xor a
 	ld [wJoyIgnore], a
-	call Func_2307
+	call PlayDefaultMusic
 	ld a, $0
 	ld [W_CERULEANCITYCURSCRIPT], a
 	ret
--- a/scripts/cinnabarisland.asm
+++ b/scripts/cinnabarisland.asm
@@ -32,10 +32,10 @@
 	xor a
 	ld [hJoyHeld], a
 	ld a, $1
-	ld [wcd38], a
-	ld a, $80
-	ld [wccd3], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesIndex], a
+	ld a, D_DOWN
+	ld [wSimulatedJoypadStatesEnd], a
+	call StartSimulatingJoypadStates
 	xor a
 	ld [wSpriteStateData1 + 9], a
 	ld [wJoyIgnore], a
@@ -44,7 +44,7 @@
 	ret
 
 CinnabarIslandScript1: ; 1ca73 (7:4a73)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	call Delay3
--- a/scripts/daycarem.asm
+++ b/scripts/daycarem.asm
@@ -30,7 +30,7 @@
 	call DisplayPartyMenu
 	push af
 	call GBPalWhiteOutWithDelay3
-	call Func_3dbe
+	call RestoreScreenTilesAndReloadTilePatterns
 	call LoadGBPal
 	pop af
 	ld hl, DayCareMText_56437
--- a/scripts/fightingdojo.asm
+++ b/scripts/fightingdojo.asm
@@ -48,7 +48,7 @@
 	ld [$ff8c], a
 	ld a, $8
 	ld [$ff8d], a
-	call Func_34a6
+	call SetSpriteFacingDirectionAndDelay
 	ld a, $1
 	ld [$ff8c], a
 	call DisplayTextID
@@ -67,7 +67,7 @@
 	ld [$ff8c], a
 	ld a, $8
 	ld [$ff8d], a
-	call Func_34a6
+	call SetSpriteFacingDirectionAndDelay
 
 .asm_5cde4
 	ld a, $f0
--- a/scripts/gary.asm
+++ b/scripts/gary.asm
@@ -29,12 +29,12 @@
 GaryScript1: ; 75f48 (1d:5f48)
 	ld a, $ff
 	ld [wJoyIgnore], a
-	ld hl, wccd3
+	ld hl, wSimulatedJoypadStatesEnd
 	ld de, RLEMovement75f63
 	call DecodeRLEList
 	dec a
-	ld [wcd38], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesIndex], a
+	call StartSimulatingJoypadStates
 	ld a, $2
 	ld [W_GARYCURSCRIPT], a
 	ret
@@ -46,7 +46,7 @@
 	db $ff
 
 GaryScript2: ; 75f6a (1d:5f6a)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	call Delay3
@@ -140,12 +140,12 @@
 	ld [$ff8c], a
 	ld a, $8
 	ld [$ff8d], a
-	call Func_34a6
+	call SetSpriteFacingDirectionAndDelay
 	ld a, $2
 	ld [$ff8c], a
 	xor a
 	ld [$ff8d], a
-	call Func_34a6 ; face object
+	call SetSpriteFacingDirectionAndDelay ; face object
 	ld a, $3
 	ld [$ff8c], a
 	call GaryScript_760c8
@@ -158,7 +158,7 @@
 	ld [$ff8c], a
 	ld a, $c
 	ld [$ff8d], a
-	call Func_34a6 ; face object
+	call SetSpriteFacingDirectionAndDelay ; face object
 	ld a, $4
 	ld [$ff8c], a
 	call GaryScript_760c8
@@ -171,7 +171,7 @@
 	ld [$ff8c], a
 	xor a
 	ld [$ff8d], a
-	call Func_34a6 ; face object
+	call SetSpriteFacingDirectionAndDelay ; face object
 	ld a, $5
 	ld [$ff8c], a
 	call GaryScript_760c8
@@ -200,12 +200,12 @@
 GaryScript9: ; 76099 (1d:6099)
 	ld a, $ff
 	ld [wJoyIgnore], a
-	ld hl, wccd3
+	ld hl, wSimulatedJoypadStatesEnd
 	ld de, RLEMovement760b4
 	call DecodeRLEList
 	dec a
-	ld [wcd38], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesIndex], a
+	call StartSimulatingJoypadStates
 	ld a, $a
 	ld [W_GARYCURSCRIPT], a
 	ret
@@ -216,7 +216,7 @@
 	db $ff
 
 GaryScript10: ; 760b9 (1d:60b9)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	xor a
--- a/scripts/halloffameroom.asm
+++ b/scripts/halloffameroom.asm
@@ -62,12 +62,12 @@
 HallofFameRoomScript0: ; 5a50d (16:650d)
 	ld a, $ff
 	ld [wJoyIgnore], a
-	ld hl, wccd3
+	ld hl, wSimulatedJoypadStatesEnd
 	ld de, RLEMovement5a528
 	call DecodeRLEList
 	dec a
-	ld [wcd38], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesIndex], a
+	call StartSimulatingJoypadStates
 	ld a, $1
 	ld [W_HALLOFFAMEROOMCURSCRIPT], a
 	ret
@@ -77,7 +77,7 @@
 	db $ff
 
 HallofFameRoomScript1: ; 5a52b (16:652b)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	ld a, $1
@@ -87,7 +87,7 @@
 	call SetSpriteMovementBytesToFF
 	ld a, $8
 	ld [$ff8d], a
-	call Func_34a6
+	call SetSpriteFacingDirectionAndDelay
 	call Delay3
 	xor a
 	ld [wJoyIgnore], a
--- a/scripts/lance.asm
+++ b/scripts/lance.asm
@@ -99,12 +99,12 @@
 LanceScript_5a35b: ; 5a35b (16:635b)
 	ld a, $ff
 	ld [wJoyIgnore], a
-	ld hl, wccd3
+	ld hl, wSimulatedJoypadStatesEnd
 	ld de, RLEList_5a379
 	call DecodeRLEList
 	dec a
-	ld [wcd38], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesIndex], a
+	call StartSimulatingJoypadStates
 	ld a, $3
 	ld [W_LANCECURSCRIPT], a
 	ld [W_CURMAPSCRIPT], a
@@ -118,7 +118,7 @@
 	db $FF
 
 LanceScript3: ; 5a382 (16:6382)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	call Delay3
--- a/scripts/lorelei.asm
+++ b/scripts/lorelei.asm
@@ -42,8 +42,8 @@
 LoreleiScript4: ; 761c5 (1d:61c5)
 	ret
 asm_761c6: ; 761c6 (1d:61c6)
-	ld hl, wccd3
-	ld a, $40
+	ld hl, wSimulatedJoypadStatesEnd
+	ld a, D_UP
 	ld [hli], a
 	ld [hli], a
 	ld [hli], a
@@ -51,8 +51,8 @@
 	ld [hli], a
 	ld [hl], a
 	ld a, $6
-	ld [wcd38], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesIndex], a
+	call StartSimulatingJoypadStates
 	ld a, $3
 	ld [W_LORELEICURSCRIPT], a
 	ld [W_CURMAPSCRIPT], a
@@ -64,8 +64,8 @@
 	xor a
 	ld [hJoyPressed], a
 	ld [hJoyHeld], a
-	ld [wccd3], a
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesEnd], a
+	ld [wSimulatedJoypadStatesIndex], a
 	ld a, [wWhichTrade] ; wWhichTrade
 	cp $3
 	jr c, .asm_76206
@@ -77,11 +77,11 @@
 	ld a, $2
 	ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
 	call DisplayTextID
-	ld a, $40
-	ld [wccd3], a
+	ld a, D_UP
+	ld [wSimulatedJoypadStatesEnd], a
 	ld a, $1
-	ld [wcd38], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesIndex], a
+	call StartSimulatingJoypadStates
 	ld a, $3
 	ld [W_LORELEICURSCRIPT], a
 	ld [W_CURMAPSCRIPT], a
@@ -95,7 +95,7 @@
 	db $FF
 
 LoreleiScript3: ; 7622c (1d:622c)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	call Delay3
--- a/scripts/museum1f.asm
+++ b/scripts/museum1f.asm
@@ -115,10 +115,10 @@
 	ld hl, Museum1FText_5c21a ; $421a
 	call PrintText
 	ld a, $1
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesIndex], a
 	ld a, $80
-	ld [wccd3], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesEnd], a
+	call StartSimulatingJoypadStates
 	call UpdateSprites
 	jr asm_d1145
 .asm_0b094
--- a/scripts/namerater.asm
+++ b/scripts/namerater.asm
@@ -55,7 +55,7 @@
 	call DisplayPartyMenu
 	push af
 	call GBPalWhiteOutWithDelay3
-	call Func_3dbe
+	call RestoreScreenTilesAndReloadTilePatterns
 	call LoadGBPal
 	pop af
 	jr c, .asm_1daae ; 0x1da80 $2c
--- a/scripts/oakslab.asm
+++ b/scripts/oakslab.asm
@@ -35,7 +35,7 @@
 	ld a, [wd74b]
 	bit 7, a
 	ret z
-	ld a, [wcf10]
+	ld a, [wNPCMovementScriptFunctionNum]
 	and a
 	ret nz
 	ld a, $31
@@ -50,7 +50,7 @@
 
 OaksLabScript1: ; 1cb6e (7:4b6e)
 	ld a, $8
-	ld [$ff8c], a
+	ld [H_SPRITEINDEX], a
 	ld de, OakEntryMovement
 	call MoveSprite
 
@@ -78,22 +78,22 @@
 
 OaksLabScript3: ; 1cba2 (7:4ba2)
 	call Delay3
-	ld hl, wccd3
+	ld hl, wSimulatedJoypadStatesEnd
 	ld de, PlayerEntryMovementRLE
 	call DecodeRLEList
 	dec a
-	ld [wcd38], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesIndex], a
+	call StartSimulatingJoypadStates
 	ld a, $1
-	ld [$ff8c], a
+	ld [H_SPRITEINDEX], a
 	xor a
 	ld [$ff8d], a
-	call Func_34a6 ; face object
+	call SetSpriteFacingDirectionAndDelay
 	ld a, $5
-	ld [$ff8c], a
+	ld [H_SPRITEINDEX], a
 	xor a
 	ld [$ff8d], a
-	call Func_34a6 ; face object
+	call SetSpriteFacingDirectionAndDelay
 
 	ld a, $4
 	ld [W_OAKSLABCURSCRIPT], a
@@ -103,7 +103,7 @@
 	db $40, $8, $ff
 
 OaksLabScript4: ; 1cbd2 (7:4bd2)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	ld hl, wd747
@@ -111,14 +111,14 @@
 	ld hl, wd74b
 	set 0, [hl]
 	ld a, $1
-	ld [$ff8c], a
+	ld [H_SPRITEINDEX], a
 	ld a, $4
 	ld [$ff8d], a
-	call Func_34a6 ; face object
+	call SetSpriteFacingDirectionAndDelay
 	call UpdateSprites
 	ld hl, W_FLAGS_D733
 	res 1, [hl]
-	call Func_2307
+	call PlayDefaultMusic
 
 	ld a, $5
 	ld [W_OAKSLABCURSCRIPT], a
@@ -156,24 +156,24 @@
 	cp $6
 	ret nz
 	ld a, $5
-	ld [$ff8c], a
+	ld [H_SPRITEINDEX], a
 	xor a
 	ld [$ff8d], a
-	call Func_34a6 ; face object
+	call SetSpriteFacingDirectionAndDelay
 	ld a, $1
-	ld [$ff8c], a
+	ld [H_SPRITEINDEX], a
 	xor a
 	ld [$ff8d], a
-	call Func_34a6 ; face object
+	call SetSpriteFacingDirectionAndDelay
 	call UpdateSprites
 	ld a, $c
 	ld [$ff8c], a
 	call DisplayTextID
 	ld a, $1
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesIndex], a
 	ld a, $40
-	ld [wccd3], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesEnd], a
+	call StartSimulatingJoypadStates
 	ld a, $8
 	ld [wd528], a
 
@@ -182,7 +182,7 @@
 	ret
 
 OaksLabScript7: ; 1cc72 (7:4c72)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	call Delay3
@@ -231,10 +231,10 @@
 	jr nz, .asm_1ccf3 ; 0x1cccd $24
 	push hl
 	ld a, $1
-	ld [$ff8c], a
+	ld [H_SPRITEINDEX], a
 	ld a, $4
 	ld [$ff8b], a
-	call Func_34fc
+	call GetPointerWithinSpriteStateData1
 	push hl
 	ld [hl], $4c
 	inc hl
@@ -256,7 +256,7 @@
 
 .asm_1ccf3
 	ld a, $1
-	ld [$ff8c], a
+	ld [H_SPRITEINDEX], a
 	call MoveSprite
 
 	ld a, $9
@@ -270,10 +270,10 @@
 	ld a, $fc
 	ld [wJoyIgnore], a
 	ld a, $1
-	ld [$ff8c], a
+	ld [H_SPRITEINDEX], a
 	ld a, $4
 	ld [$ff8d], a
-	call Func_34a6 ; face object
+	call SetSpriteFacingDirectionAndDelay
 	ld a, $d
 	ld [$ff8c], a
 	call DisplayTextID
@@ -299,10 +299,10 @@
 	ld [wd11e], a
 	call GetMonName
 	ld a, $1
-	ld [$ff8c], a
+	ld [H_SPRITEINDEX], a
 	ld a, $4
 	ld [$ff8d], a
-	call Func_34a6 ; face object
+	call SetSpriteFacingDirectionAndDelay
 	ld a, $e
 	ld [$ff8c], a
 	call DisplayTextID
@@ -320,10 +320,10 @@
 	cp $6
 	ret nz
 	ld a, $1
-	ld [$ff8c], a
+	ld [H_SPRITEINDEX], a
 	xor a
 	ld [$ff8d], a
-	call Func_34a6 ; face object
+	call SetSpriteFacingDirectionAndDelay
 	ld a, $8
 	ld [wd528], a
 	ld c, BANK(Music_MeetRival)
@@ -337,14 +337,14 @@
 	ld a, $1
 	swap a
 	ld [$ff95], a
-	predef Func_f929
+	predef CalcPositionOfPlayerRelativeToNPC
 	ld a, [$ff95]
 	dec a
 	ld [$ff95], a
-	predef Func_f8ba
-	ld de, wcc97
+	predef FindPathToPlayer
+	ld de, wNPCMovementDirections2
 	ld a, $1
-	ld [$ff8c], a
+	ld [H_SPRITEINDEX], a
 	call MoveSprite
 
 	ld a, $b
@@ -375,7 +375,7 @@
 	ld [W_TRAINERNO], a
 	ld a, $1
 	ld [wcf13], a
-	call Func_32ef
+	call GetSpritePosition1
 	ld hl, OaksLabText_1d3be
 	ld de, OaksLabText_1d3c3
 	call PreBattleSaveRegisters
@@ -398,12 +398,12 @@
 	call UpdateSprites
 	ld a, $1
 	ld [wcf13], a
-	call Func_32f9
+	call SetSpritePosition1
 	ld a, $1
-	ld [$ff8c], a
+	ld [H_SPRITEINDEX], a
 	xor a
 	ld [$ff8d], a
-	call Func_34a6 ; face object
+	call SetSpriteFacingDirectionAndDelay
 	predef HealParty
 	ld hl, wd74b
 	set 3, [hl]
@@ -420,7 +420,7 @@
 	call DisplayTextID
 	callba Music_RivalAlternateStart
 	ld a, $1
-	ld [$ff8c], a
+	ld [H_SPRITEINDEX], a
 	ld de, .RivalExitMovement
 	call MoveSprite
 	ld a, [W_XCOORD]
@@ -450,7 +450,7 @@
 	predef HideObject
 	xor a
 	ld [wJoyIgnore], a
-	call Func_2307 ; reset to map music
+	call PlayDefaultMusic ; reset to map music
 	ld a, $12
 	ld [W_OAKSLABCURSCRIPT], a
 	jr .done ; 0x1ce8a $23
@@ -491,17 +491,17 @@
 	ld a, $2a
 	ld [wcc4d], a
 	predef ShowObject
-	ld a, [wcd37]
+	ld a, [wNPCMovementDirections2Index]
 	ld [wd157], a
 	ld b, $0
 	ld c, a
-	ld hl, wcc97
+	ld hl, wNPCMovementDirections2
 	ld a, $40
 	call FillMemory
 	ld [hl], $ff
 	ld a, $1
-	ld [$ff8c], a
-	ld de, wcc97
+	ld [H_SPRITEINDEX], a
+	ld de, wNPCMovementDirections2
 	call MoveSprite
 
 	ld a, $10
@@ -510,15 +510,15 @@
 
 OaksLabScript_1cefd ; 1cefd (7:4efd)
 	ld a, $1
-	ld [$ff8c], a
+	ld [H_SPRITEINDEX], a
 	ld a, $4
 	ld [$ff8d], a
-	call Func_34a6 ; face object
+	call SetSpriteFacingDirectionAndDelay
 	ld a, $8
-	ld [$ff8c], a
+	ld [H_SPRITEINDEX], a
 	xor a
 	ld [$ff8d], a
-	jp Func_34a6 ; face object
+	jp SetSpriteFacingDirectionAndDelay
 
 OaksLabScript16: ; 1cf12 (7:4f12)
 	ld a, [wd730]
@@ -525,7 +525,7 @@
 	bit 0, a
 	ret nz
 	call EnableAutoTextBoxDrawing
-	call Func_2307
+	call PlayDefaultMusic
 	ld a, $fc
 	ld [wJoyIgnore], a
 	call OaksLabScript_1cefd
@@ -558,10 +558,10 @@
 	ld [$ff8c], a
 	call DisplayTextID
 	ld a, $1
-	ld [$ff8c], a
+	ld [H_SPRITEINDEX], a
 	ld a, $c
 	ld [$ff8d], a
-	call Func_34a6 ; face object
+	call SetSpriteFacingDirectionAndDelay
 	call Delay3
 	ld a, $1b
 	ld [$ff8c], a
@@ -579,7 +579,7 @@
 	ld a, [wd157]
 	ld b, $0
 	ld c, a
-	ld hl, wcc97
+	ld hl, wNPCMovementDirections2
 	xor a
 	call FillMemory
 	ld [hl], $ff
@@ -588,8 +588,8 @@
 	call PlaySound
 	callba Music_RivalAlternateStart
 	ld a, $1
-	ld [$ff8c], a
-	ld de, wcc97
+	ld [H_SPRITEINDEX], a
+	ld de, wNPCMovementDirections2
 	call MoveSprite
 
 	ld a, $11
@@ -600,7 +600,7 @@
 	ld a, [wd730]
 	bit 0, a
 	ret nz
-	call Func_2307
+	call PlayDefaultMusic
 	ld a, $2a
 	ld [wcc4d], a
 	predef HideObject
@@ -652,7 +652,7 @@
 	cp $3
 	jr nz, .asm_1d045 ; 0x1d038 $b
 	ld a, $4
-	ld [wcd37], a
+	ld [wNPCMovementDirections2Index], a
 	ld a, $30
 	ld b, $b
 	jr .asm_1d068 ; 0x1d043 $23
@@ -660,13 +660,13 @@
 	cp $1
 	jr nz, .asm_1d054 ; 0x1d047 $b
 	ld a, $2
-	ld [wcd37], a
+	ld [wNPCMovementDirections2Index], a
 	ld a, $30
 	ld b, $9
 	jr .asm_1d068 ; 0x1d052 $14
 .asm_1d054
 	ld a, $3
-	ld [wcd37], a
+	ld [wNPCMovementDirections2Index], a
 	ld b, $a
 	ld a, [W_XCOORD]
 	cp $4
@@ -681,7 +681,7 @@
 	ld [$ffed], a
 	ld a, $1
 	ld [wcf13], a
-	call Func_32f9
+	call SetSpritePosition1
 	ret
 
 OaksLabScript_1d076: ; 1d076 (7:5076)
@@ -817,17 +817,17 @@
 
 OaksLabScript_1d157: ; 1d157 (7:5157)
 	ld a, $5
-	ld [$ff8c], a
+	ld [H_SPRITEINDEX], a
 	ld a, $9
 	ld [$ff8b], a
-	call Func_34fc
+	call GetPointerWithinSpriteStateData1
 	ld [hl], $0
 	; manually fixed some disassembler issues around here
 	ld a, $1
-	ld [$FF8c], a
+	ld [H_SPRITEINDEX], a
 	ld a, $9
 	ld [$ff8b], a
-	call Func_34fc
+	call GetPointerWithinSpriteStateData1
 	ld [hl], $c
 	ld hl, wd730
 	set 6, [hl]
@@ -924,10 +924,10 @@
 
 OaksLabScript_1d22d: ; 1d22d (7:522d)
 	ld a, $5
-	ld [$ff8c], a
+	ld [H_SPRITEINDEX], a
 	ld a, $9
 	ld [$ff8b], a
-	call Func_34fc
+	call GetPointerWithinSpriteStateData1
 	ld [hl], $0
 	ld hl, OaksLabLastMonText
 	call PrintText
--- a/scripts/pallettown.asm
+++ b/scripts/pallettown.asm
@@ -68,7 +68,7 @@
 	ld [$FF8C],a
 	ld a,4
 	ld [$FF8D],a
-	call Func_34a6
+	call SetSpriteFacingDirectionAndDelay
 	call Delay3
 	ld a,1
 	ld [W_YCOORD],a
@@ -77,11 +77,11 @@
 	ld a,1
 	swap a
 	ld [$FF95],a
-	predef Func_f929
+	predef CalcPositionOfPlayerRelativeToNPC
 	ld hl,$FF95
 	dec [hl]
-	predef Func_f8ba ; load Oak’s movement into wcc97
-	ld de,wcc97
+	predef FindPathToPlayer ; load Oak’s movement into wNPCMovementDirections2
+	ld de,wNPCMovementDirections2
 	ld a,1 ; oak
 	ld [$FF8C],a
 	call MoveSprite
@@ -111,11 +111,11 @@
 	ld a,1
 	ld [wcf13],a
 	xor a
-	ld [wcf10],a
+	ld [wNPCMovementScriptFunctionNum],a
 	ld a,1
-	ld [wcc57],a
+	ld [wNPCMovementScriptPointerTableNum],a
 	ld a,[H_LOADEDROMBANK]
-	ld [wcc58],a
+	ld [wNPCMovementScriptBank],a
 
 	; trigger the next script
 	ld a,4
@@ -123,7 +123,7 @@
 	ret
 
 PalletTownScript4: ; 18f4b (6:4f4b)
-	ld a,[wcc57]
+	ld a,[wNPCMovementScriptPointerTableNum]
 	and a
 	ret nz
 
--- a/scripts/pewtercity.asm
+++ b/scripts/pewtercity.asm
@@ -42,18 +42,18 @@
 	db $ff
 
 PewterCityScript1: ; 19280 (6:5280)
-	ld a, [wcc57]
+	ld a, [wNPCMovementScriptPointerTableNum]
 	and a
 	ret nz
 	ld a, $3
-	ld [$ff8c], a
-	ld a, $4
+	ld [H_SPRITEINDEX], a
+	ld a, SPRITE_FACING_UP
 	ld [$ff8d], a
-	call Func_34a6
-	ld a, $34
+	call SetSpriteFacingDirectionAndDelay
+	ld a, ($3 << 4) | SPRITE_FACING_UP
 	ld [$ff8d], a
-	call Func_34b9
-	call Func_2307
+	call SetSpriteImageIndexAfterSettingFacingDirection
+	call PlayDefaultMusic
 	ld hl, wFlags_0xcd60
 	set 4, [hl]
 	ld a, $d
@@ -69,7 +69,7 @@
 	ld [$ffee], a
 	ld a, $3
 	ld [wcf13], a
-	call Func_32f9
+	call SetSpritePosition1
 	ld a, $3
 	ld [$ff8c], a
 	ld de, MovementData_PewterMuseumGuyExit ; $52ce
@@ -95,7 +95,7 @@
 PewterCityScript3: ; 192e9 (6:52e9)
 	ld a, $3
 	ld [wcf13], a
-	call Func_32fe
+	call SetSpritePosition2
 	ld a, $3
 	ld [wcc4d], a
 	predef ShowObject
@@ -106,18 +106,18 @@
 	ret
 
 PewterCityScript4: ; 19305 (6:5305)
-	ld a, [wcc57]
+	ld a, [wNPCMovementScriptPointerTableNum]
 	and a
 	ret nz
 	ld a, $5
 	ld [$ff8c], a
-	ld a, $8
+	ld a, SPRITE_FACING_LEFT
 	ld [$ff8d], a
-	call Func_34a6
-	ld a, $18
+	call SetSpriteFacingDirectionAndDelay
+	ld a, ($1 << 4) | SPRITE_FACING_LEFT
 	ld [$ff8d], a
-	call Func_34b9
-	call Func_2307
+	call SetSpriteImageIndexAfterSettingFacingDirection
+	call PlayDefaultMusic
 	ld hl, wFlags_0xcd60
 	set 4, [hl]
 	ld a, $e
@@ -133,7 +133,7 @@
 	ld [$ffee], a
 	ld a, $5
 	ld [wcf13], a
-	call Func_32f9
+	call SetSpritePosition1
 	ld a, $5
 	ld [$ff8c], a
 	ld de, MovementData_PewterGymGuyExit
@@ -159,7 +159,7 @@
 PewterCityScript6: ; 1936f (6:536f)
 	ld a, $5
 	ld [wcf13], a
-	call Func_32fe
+	call SetSpritePosition2
 	ld a, $4
 	ld [wcc4d], a
 	predef ShowObject
@@ -210,14 +210,14 @@
 	xor a
 	ldh [$b3], a
 	ldh [$b4], a
-	ld [wcf10], a
+	ld [wNPCMovementScriptFunctionNum], a
 	ld a, $2
-	ld [wcc57], a
+	ld [wNPCMovementScriptPointerTableNum], a
 	ldh a, [$b8]
-	ld [wcc58], a
+	ld [wNPCMovementScriptBank], a
 	ld a, $3
 	ld [wcf13], a
-	call Func_32f4
+	call GetSpritePosition2
 	ld a, $1
 	ld [W_PEWTERCITYCURSCRIPT], a
 .asm_ac429 ; 0x193ee
@@ -274,14 +274,14 @@
 	call PrintText
 	xor a
 	ldh [$b4], a
-	ld [wcf10], a
+	ld [wNPCMovementScriptFunctionNum], a
 	ld a, $3
-	ld [wcc57], a
+	ld [wNPCMovementScriptPointerTableNum], a
 	ldh a, [$b8]
-	ld [wcc58], a
+	ld [wNPCMovementScriptBank], a
 	ld a, $5
 	ld [wcf13], a
-	call Func_32f4
+	call GetSpritePosition2
 	ld a, $4
 	ld [W_PEWTERCITYCURSCRIPT], a
 	jp TextScriptEnd
--- a/scripts/pewterpokecenter.asm
+++ b/scripts/pewterpokecenter.asm
@@ -61,7 +61,7 @@
 	jr nz, .asm_5c5d1 ; 0x5c5f6 $d9
 	ld c, $30
 	call DelayFrames
-	call Func_2307
+	call PlayDefaultMusic
 	jp TextScriptEnd
 
 PewterPokecenterText5: ; 5c603 (17:4603)
--- a/scripts/pokemontower2.asm
+++ b/scripts/pokemontower2.asm
@@ -46,7 +46,7 @@
 	ld [$ff8c], a
 	ld a, b
 	ld [$ff8d], a
-	call Func_34a6
+	call SetSpriteFacingDirectionAndDelay
 	ld a, $1
 	ld [$ff8c], a
 	call DisplayTextID
@@ -104,7 +104,7 @@
 	predef HideObject
 	xor a
 	ld [wJoyIgnore], a
-	call Func_2307
+	call PlayDefaultMusic
 	ld a, $0
 	ld [W_POKEMONTOWER2CURSCRIPT], a
 	ld [W_CURMAPSCRIPT], a
--- a/scripts/pokemontower6.asm
+++ b/scripts/pokemontower6.asm
@@ -73,12 +73,12 @@
 	ret
 .asm_60b82
 	ld a, $1
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesIndex], a
 	ld a, $10
-	ld [wccd3], a
+	ld [wSimulatedJoypadStatesEnd], a
 	xor a
 	ld [wSpriteStateData2 + $06], a
-	ld [wcd3b], a
+	ld [wOverrideSimulatedJoypadStatesMask], a
 	ld hl, wd730
 	set 7, [hl]
 	ld a, $3
@@ -87,7 +87,7 @@
 	ret
 
 PokemonTower6Script3: ; 60ba1 (18:4ba1)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	call Delay3
--- a/scripts/rockethideout2.asm
+++ b/scripts/rockethideout2.asm
@@ -24,7 +24,7 @@
 	jp z, CheckFightingMapTrainers
 	ld hl, wd736
 	set 7, [hl]
-	call Func_3486
+	call StartSimulatingJoypadStates
 	ld a, (SFX_02_52 - SFX_Headers_02) / 3
 	call PlaySound
 	ld a, $ff
@@ -306,7 +306,7 @@
 	db $FF
 
 RocketHideout2Script3: ; 44fc2 (11:4fc2)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	jr nz, LoadSpinnerArrowTiles
 	xor a
@@ -333,7 +333,7 @@
 	jr z, .asm_44ff6
 	ld hl, GymSpinnerArrows ; $5053
 .asm_44ff6
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	bit 0, a
 	jr nz, .asm_45001
 	ld de, $18
--- a/scripts/rockethideout3.asm
+++ b/scripts/rockethideout3.asm
@@ -24,7 +24,7 @@
 	jp z, CheckFightingMapTrainers
 	ld hl, wd736
 	set 7, [hl]
-	call Func_3486
+	call StartSimulatingJoypadStates
 	ld a, (SFX_02_52 - SFX_Headers_02) / 3
 	call PlaySound
 	ld a, $ff
@@ -136,7 +136,7 @@
 	db $FF
 
 RocketHideout3Script3 ; 452e4 (11:452e4)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	jp nz, LoadSpinnerArrowTiles
 	xor a
--- a/scripts/route16gate.asm
+++ b/scripts/route16gate.asm
@@ -28,13 +28,13 @@
 	jr z, .asm_4970e ; 0x496f1 $1b
 	ld a, [wWhichTrade]
 	dec a
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesIndex], a
 	ld b, $0
 	ld c, a
 	ld a, $40
-	ld hl, wccd3
+	ld hl, wSimulatedJoypadStatesEnd
 	call FillMemory
-	call Func_3486
+	call StartSimulatingJoypadStates
 	ld a, $1
 	ld [W_ROUTE16GATECURSCRIPT], a
 	ret
@@ -51,7 +51,7 @@
 	db $FF
 
 Route16GateScript1: ; 4971d (12:571d)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	ld a, $f0
@@ -62,16 +62,16 @@
 	ld [H_SPRITEHEIGHT], a
 	call DisplayTextID
 	ld a, $1
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesIndex], a
 	ld a, $10
-	ld [wccd3], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesEnd], a
+	call StartSimulatingJoypadStates
 	ld a, $3
 	ld [W_ROUTE16GATECURSCRIPT], a
 	ret
 
 Route16GateScript3: ; 49741 (12:5741)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	xor a
--- a/scripts/route18gate.asm
+++ b/scripts/route18gate.asm
@@ -28,13 +28,13 @@
 	jr z, .asm_498c6 ; 0x498a9 $1b
 	ld a, [wWhichTrade]
 	dec a
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesIndex], a
 	ld b, $0
 	ld c, a
 	ld a, $40
-	ld hl, wccd3
+	ld hl, wSimulatedJoypadStatesEnd
 	call FillMemory
-	call Func_3486
+	call StartSimulatingJoypadStates
 	ld a, $1
 	ld [W_ROUTE18GATECURSCRIPT], a
 	ret
@@ -51,7 +51,7 @@
 	db $FF
 
 Route18GateScript1: ; 498d5 (12:58d5)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	ld a, $f0
@@ -62,16 +62,16 @@
 	ld [H_SPRITEHEIGHT], a
 	call DisplayTextID
 	ld a, $1
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesIndex], a
 	ld a, $10
-	ld [wccd3], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesEnd], a
+	call StartSimulatingJoypadStates
 	ld a, $3
 	ld [W_ROUTE18GATECURSCRIPT], a
 	ret
 
 Route18GateScript3: ; 498f9 (12:58f9)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	xor a
--- a/scripts/route22.asm
+++ b/scripts/route22.asm
@@ -45,7 +45,7 @@
 	call MoveSprite
 	ld a, $c
 	ld [$ff8d], a
-	jp Func_34a6
+	jp SetSpriteFacingDirectionAndDelay
 
 Route22RivalMovementData: ; 50efb (14:4efb)
 	db $C0,$C0,$C0,$C0,$FF ; move right 4 times
@@ -117,7 +117,7 @@
 	ld [$ff8d], a
 	ld a, $1
 	ld [$ff8c], a
-	call Func_34a6
+	call SetSpriteFacingDirectionAndDelay
 	xor a
 	ld [wJoyIgnore], a
 	ld a, $1
@@ -158,7 +158,7 @@
 	ld [$ff8d], a
 	ld a, $1
 	ld [$ff8c], a
-	call Func_34a6
+	call SetSpriteFacingDirectionAndDelay
 	ld a, $f0
 	ld [wJoyIgnore], a
 	ld hl, wd7eb
@@ -208,7 +208,7 @@
 	ld a, $22
 	ld [wcc4d], a
 	predef HideObject
-	call Func_2307
+	call PlayDefaultMusic
 	ld hl, wd7eb
 	res 0, [hl]
 	res 7, [hl]
@@ -259,7 +259,7 @@
 	ld a, $c
 .asm_510a8
 	ld [$ff8d], a
-	call Func_34a6
+	call SetSpriteFacingDirectionAndDelay
 	xor a
 	ld [wJoyIgnore], a
 	ld a, $2
@@ -303,7 +303,7 @@
 	ld a, $c
 .asm_51102
 	ld [$ff8d], a
-	call Func_34a6
+	call SetSpriteFacingDirectionAndDelay
 	ld a, $f0
 	ld [wJoyIgnore], a
 	ld hl, wd7eb
@@ -353,7 +353,7 @@
 	ld a, $23
 	ld [wcc4d], a
 	predef HideObject
-	call Func_2307
+	call PlayDefaultMusic
 	ld hl, wd7eb
 	res 1, [hl]
 	res 7, [hl]
--- a/scripts/route22gate.asm
+++ b/scripts/route22gate.asm
@@ -34,15 +34,15 @@
 
 Route22GateScript_1e6ba: ; 1e6ba (7:66ba)
 	ld a, $1
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesIndex], a
 	ld a, $80
-	ld [wccd3], a
+	ld [wSimulatedJoypadStatesEnd], a
 	ld [wSpriteStateData1 + 9], a
 	ld [wJoyIgnore], a
-	jp Func_3486
+	jp StartSimulatingJoypadStates
 
 Route22GateScript1: ; 1e6cd (7:66cd)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	xor a
--- a/scripts/route23.asm
+++ b/scripts/route23.asm
@@ -118,16 +118,16 @@
 
 Route23Script_512d8: ; 512d8 (14:52d8)
 	ld a, $1
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesIndex], a
 	ld a, $80
-	ld [wccd3], a
+	ld [wSimulatedJoypadStatesEnd], a
 	xor a
 	ld [wSpriteStateData1 + 9], a
 	ld [wJoyIgnore], a
-	jp Func_3486
+	jp StartSimulatingJoypadStates
 
 Route23Script1: ; 512ec (14:52ec)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 Route23Script2: ; 512f1 (14:52f1)
--- a/scripts/route24.asm
+++ b/scripts/route24.asm
@@ -38,10 +38,10 @@
 	res 1, [hl]
 	ret z
 	ld a, $80
-	ld [wccd3], a
+	ld [wSimulatedJoypadStatesEnd], a
 	ld a, $1
-	ld [wcd38], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesIndex], a
+	call StartSimulatingJoypadStates
 	ld a, $4
 	ld [W_ROUTE24CURSCRIPT], a
 	ld [W_CURMAPSCRIPT], a
@@ -51,7 +51,7 @@
 	db $0F,$0A,$FF
 
 Route24Script4: ; 51411 (14:5411)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	call Delay3
--- a/scripts/route5gate.asm
+++ b/scripts/route5gate.asm
@@ -10,10 +10,10 @@
 
 Route5GateScript_1df43: ; 1df43 (7:5f43)
 	ld a, $40
-	ld [wccd3], a
+	ld [wSimulatedJoypadStatesEnd], a
 	ld a, $1
-	ld [wcd38], a
-	jp Func_3486
+	ld [wSimulatedJoypadStatesIndex], a
+	jp StartSimulatingJoypadStates
 
 Route5GateScript0: ; 1df50 (7:5f50)
 	ld a, [wd728]
@@ -51,7 +51,7 @@
 	db $ff
 
 Route5GateScript1: ; 1df94 (7:5f94)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	call Delay3
--- a/scripts/route6gate.asm
+++ b/scripts/route6gate.asm
@@ -43,7 +43,7 @@
 	db $02,$04,$FF
 
 Route6GateScript1: ; 1e091 (7:6091)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	call Delay3
@@ -56,12 +56,12 @@
 	ld hl, wd730
 	set 7, [hl]
 	ld a, $80
-	ld [wccd3], a
+	ld [wSimulatedJoypadStatesEnd], a
 	ld a, $1
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesIndex], a
 	xor a
 	ld [wSpriteStateData2 + $06], a
-	ld [wcd3b], a
+	ld [wOverrideSimulatedJoypadStatesMask], a
 	ret
 
 Route6GateTextPointers: ; 1e0b8 (7:60b8)
--- a/scripts/route7gate.asm
+++ b/scripts/route7gate.asm
@@ -13,12 +13,12 @@
 	ld hl, wd730
 	set 7, [hl]
 	ld a, $20
-	ld [wccd3], a
+	ld [wSimulatedJoypadStatesEnd], a
 	ld a, $1
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesIndex], a
 	xor a
 	ld [wSpriteStateData2 + $06], a
-	ld [wcd3b], a
+	ld [wOverrideSimulatedJoypadStatesMask], a
 	ret
 
 Route7GateScript0: ; 1e128 (7:6128)
@@ -57,7 +57,7 @@
 	db $ff
 
 Route7GateScript1: ; 1e16c (7:616c)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	call Delay3
--- a/scripts/route8gate.asm
+++ b/scripts/route8gate.asm
@@ -12,12 +12,12 @@
 	ld hl, wd730
 	set 7, [hl]
 	ld a, $10
-	ld [wccd3], a
+	ld [wSimulatedJoypadStatesEnd], a
 	ld a, $1
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesIndex], a
 	xor a
 	ld [wSpriteStateData2 + $06], a
-	ld [wcd3b], a
+	ld [wOverrideSimulatedJoypadStatesMask], a
 	ret
 
 Route8GateScript0: ; 1e1ee (7:61ee)
@@ -55,7 +55,7 @@
 	db $ff
 
 Route8GateScript1: ; 1e231 (7:6231)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	call Delay3
--- a/scripts/safarizoneentrance.asm
+++ b/scripts/safarizoneentrance.asm
@@ -121,14 +121,14 @@
 	push af
 	ld b, $0
 	ld a, c
-	ld [wcd38], a
-	ld hl, wccd3
+	ld [wSimulatedJoypadStatesIndex], a
+	ld hl, wSimulatedJoypadStatesEnd
 	pop af
 	call FillMemory
-	jp Func_3486
+	jp StartSimulatingJoypadStates
 
 SafariZoneEntranceScript_752b4: ; 752b4 (1d:52b4)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret
 
--- a/scripts/seafoamislands4.asm
+++ b/scripts/seafoamislands4.asm
@@ -66,12 +66,12 @@
 	ld a, [W_XCOORD]
 	cp $f
 	ret nz
-	ld hl, wccd3
+	ld hl, wSimulatedJoypadStatesEnd
 	ld de, RLEMovement46632
 	call DecodeRLEList
 	dec a
-	ld [wcd38], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesIndex], a
+	call StartSimulatingJoypadStates
 	ld hl, W_FLAGS_D733
 	set 2, [hl]
 	ld a, $1
@@ -85,7 +85,7 @@
 	db $ff
 
 SeafoamIslands4Script1: ; 46639 (11:6639)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	ld a, $0
@@ -108,10 +108,10 @@
 .asm_4665e
 	ld de, RLEData_46688
 .asm_46661
-	ld hl, wccd3
+	ld hl, wSimulatedJoypadStatesEnd
 	call DecodeRLEList
 	dec a
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesIndex], a
 	xor a
 	ld [wSpriteStateData2 + $06], a
 	ld hl, wd730
@@ -130,7 +130,7 @@
 	db $80,$06,$10,$02,$80,$04,$FF
 
 SeafoamIslands4Script3: ; 4668f (11:668f)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	ld a, $0
--- a/scripts/seafoamislands5.asm
+++ b/scripts/seafoamislands5.asm
@@ -44,10 +44,10 @@
 .asm_467e6
 	ld a, $1
 .asm_467e8
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesIndex], a
 	ld a, $40
-	ld [wccd3], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesEnd], a
+	call StartSimulatingJoypadStates
 	ld hl, W_FLAGS_D733
 	res 2, [hl]
 	ld a, $1
@@ -62,7 +62,7 @@
 	db $FF
 
 SeafoamIslands5Script1: ; 46807 (11:6807)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	xor a
@@ -89,11 +89,11 @@
 .asm_46837
 	ld de, RLEMovementData_46852
 .asm_4683a
-	ld hl, wccd3
+	ld hl, wSimulatedJoypadStatesEnd
 	call DecodeRLEList
 	dec a
-	ld [wcd38], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesIndex], a
+	call StartSimulatingJoypadStates
 	ld a, $3
 .asm_46849
 	ld [W_SEAFOAMISLANDS5CURSCRIPT], a
@@ -117,7 +117,7 @@
 	db $FF
 
 SeafoamIslands5Script3: ; 46860 (11:6860)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	ld b, a
 	cp $1
 	call z, SeaFoamIslands5Script_46872
--- a/scripts/silphco11.asm
+++ b/scripts/silphco11.asm
@@ -160,7 +160,7 @@
 	ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
 	ld a, b
 	ld [$ff8d], a
-	jp Func_34a6
+	jp SetSpriteFacingDirectionAndDelay
 
 SilphCo11Script5: ; 62227 (18:6227)
 	ld a, [W_ISINBATTLE] ; W_ISINBATTLE
--- a/scripts/silphco7.asm
+++ b/scripts/silphco7.asm
@@ -211,7 +211,7 @@
 	ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
 	ld a, $4
 	ld [$ff8d], a
-	call Func_34a6
+	call SetSpriteFacingDirectionAndDelay
 	ld a, $f
 	ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
 	call DisplayTextID
@@ -244,7 +244,7 @@
 	ld a, $a7
 	ld [wcc4d], a
 	predef HideObject
-	call Func_2307
+	call PlayDefaultMusic
 	xor a
 	ld [wJoyIgnore], a
 	jp SilphCo7Text_51c10
@@ -323,7 +323,7 @@
 	ld bc, (LAPRAS << 8) | 15
 	call GivePokemon
 	jr nc, .done
-	ld a, [wccd3]
+	ld a, [wSimulatedJoypadStatesEnd]
 	and a
 	call z, WaitForTextScrollButtonPress
 	call EnableAutoTextBoxDrawing
--- a/scripts/ssanne2.asm
+++ b/scripts/ssanne2.asm
@@ -79,7 +79,7 @@
 	ld [$ff8d], a
 	ld a, $2
 	ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
-	jp Func_34a6
+	jp SetSpriteFacingDirectionAndDelay
 
 SSAnne2Script1: ; 61430 (18:5430)
 	ld a, [wd730]
@@ -163,7 +163,7 @@
 	ld a, $71
 	ld [wcc4d], a
 	predef HideObject
-	call Func_2307
+	call PlayDefaultMusic
 	ld a, $4
 	ld [W_SSANNE2CURSCRIPT], a
 	ret
--- a/scripts/ssanne7.asm
+++ b/scripts/ssanne7.asm
@@ -64,7 +64,7 @@
 	ld a, [wc026]
 	cp MUSIC_PKMN_HEALED
 	jr z, .asm_61910 ; 0x61915 $f9
-	call Func_2307
+	call PlayDefaultMusic
 	ld hl, wd803
 	set 1, [hl]
 	ld hl, wd72d
--- a/scripts/vermilioncity.asm
+++ b/scripts/vermilioncity.asm
@@ -61,10 +61,10 @@
 	ret nz
 .asm_19810
 	ld a, $40
-	ld [wccd3], a
+	ld [wSimulatedJoypadStatesEnd], a
 	ld a, $1
-	ld [wcd38], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesIndex], a
+	call StartSimulatingJoypadStates
 	ld a, $1
 	ld [W_VERMILIONCITYCURSCRIPT], a
 	ret
@@ -85,17 +85,17 @@
 	ld a, $ff
 	ld [wJoyIgnore], a
 	ld a, $40
-	ld [wccd3], a
+	ld [wSimulatedJoypadStatesEnd], a
 	ld [wccd4], a
 	ld a, $2
-	ld [wcd38], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesIndex], a
+	call StartSimulatingJoypadStates
 	ld a, $3
 	ld [W_VERMILIONCITYCURSCRIPT], a
 	ret
 
 VermilionCityScript3: ; 1984e (6:584e)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	xor a
@@ -106,7 +106,7 @@
 	ret
 
 VermilionCityScript1: ; 1985f (6:585f)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	ld c, $a
--- a/scripts/vermiliondock.asm
+++ b/scripts/vermiliondock.asm
@@ -14,16 +14,16 @@
 	call Delay3
 	ld hl, wd730
 	set 7, [hl]
-	ld hl, wccd3
+	ld hl, wSimulatedJoypadStatesEnd
 	ld a, $40
 	ld [hli], a
 	ld [hli], a
 	ld [hl], a
 	ld a, $3
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesIndex], a
 	xor a
 	ld [wSpriteStateData2 + $06], a
-	ld [wcd3b], a
+	ld [wOverrideSimulatedJoypadStatesMask], a
 	dec a
 	ld [wJoyIgnore], a
 	ret
@@ -30,7 +30,7 @@
 .asm_1db8d
 	bit 5, [hl]
 	ret nz
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	ld [wJoyIgnore], a
--- a/scripts/viridiancity.asm
+++ b/scripts/viridiancity.asm
@@ -108,7 +108,7 @@
 	ret
 
 ViridianCityScript3: ; 190c1 (6:50c1)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	call Delay3
@@ -117,11 +117,11 @@
 	ret
 
 ViridianCityScript_190cf: ; 190cf (6:50cf)
-	call Func_3486
+	call StartSimulatingJoypadStates
 	ld a, $1
-	ld [wcd38], a
+	ld [wSimulatedJoypadStatesIndex], a
 	ld a, $80
-	ld [wccd3], a
+	ld [wSimulatedJoypadStatesEnd], a
 	xor a
 	ld [wSpriteStateData1 + 9], a
 	ld [wJoyIgnore], a
--- a/scripts/viridiangym.asm
+++ b/scripts/viridiangym.asm
@@ -38,7 +38,7 @@
 	call Func_3442
 	cp $ff
 	jp z, CheckFightingMapTrainers
-	call Func_3486
+	call StartSimulatingJoypadStates
 	ld hl, wd736
 	set 7, [hl]
 	ld a, (SFX_02_52 - SFX_Headers_02) / 3
@@ -121,7 +121,7 @@
 	db $20,$0C,$FF
 
 ViridianGymScript4: ; 7496b (1d:496b)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	jr nz, .asm_74980
 	xor a
--- a/scripts/viridianmart.asm
+++ b/scripts/viridianmart.asm
@@ -30,12 +30,12 @@
 	ld a, $4
 	ld [$ff8c], a
 	call DisplayTextID
-	ld hl, wccd3
+	ld hl, wSimulatedJoypadStatesEnd
 	ld de, RLEMovement1d4bb
 	call DecodeRLEList
 	dec a
-	ld [wcd38], a
-	call Func_3486
+	ld [wSimulatedJoypadStatesIndex], a
+	call StartSimulatingJoypadStates
 	ld a, $1
 	ld [W_VIRIDIANMARKETCURSCRIPT], a
 	ret
@@ -46,7 +46,7 @@
 	db $ff
 
 ViridianMartScript1: ; 1d4c0 (7:54c0)
-	ld a, [wcd38]
+	ld a, [wSimulatedJoypadStatesIndex]
 	and a
 	ret nz
 	call Delay3
--- a/wram.asm
+++ b/wram.asm
@@ -287,9 +287,17 @@
 
 	ds 1
 
-wcc57:: ds 1
-wcc58:: ds 3
+wNPCMovementScriptPointerTableNum:: ; cc57
+; which NPC movement script pointer is being used
+; 0 if an NPC movement script is not running
+	ds 1
 
+wNPCMovementScriptBank:: ; cc58
+; ROM bank of current NPC movement script
+	ds 1
+
+	ds 2
+
 wHallOfFame:: ; cc5b
 wcc5b:: ds 1
 wcc5c:: ds 1
@@ -298,12 +306,23 @@
 
 wcc6b:: ds 14
 wcc79:: ds 30
-wcc97:: ds 10
+
+wNPCMovementDirections2:: ; cc97
+
+wSwitchPartyMonTempBuffer:: ; cc97
+; temporary buffer when swapping party mon data
+	ds 10
+
 wcca1:: ds 49
 
 wRLEByteCount:: ; ccd2
 	ds 1
 
+wSimulatedJoypadStatesEnd:: ; ccd3
+; this is the end of the joypad states
+; the list starts above this address and extends downwards in memory until here
+; overloaded with below labels
+
 wccd3:: ds 1
 wccd4:: ds 1
 wccd5:: ds 2
@@ -452,12 +471,31 @@
 	ds 1
 
 wcd34:: ds 3
+
+wNPCMovementDirections2Index:: ; cd37
+
 wcd37:: ds 1
-wcd38:: ds 1
-wcd39:: ds 1
-wcd3a:: ds 1
-wcd3b:: ds 2
 
+wSimulatedJoypadStatesIndex:: ; cd38
+; the next simulated joypad state is at wSimulatedJoypadStatesEnd plus this value minus 1
+; 0 if the joypad state is not being simulated
+	ds 1
+
+wWastedByteCD39:: ; cd39
+; written to but nothing ever reads it
+	ds 1
+
+wWastedByteCD3A:: ; cd3a
+; written to but nothing ever reads it
+	ds 1
+
+wOverrideSimulatedJoypadStatesMask:: ; cd3b
+; mask indicating which real button presses can override simulated ones
+; XXX is it ever not 0?
+	ds 1
+
+	ds 1
+
 wWhichTrade:: ; cd3d
 ; which entry from TradeMons to select
 ;	ds 1
@@ -499,6 +537,8 @@
 
 wFlags_0xcd60:: ; cd60
 ; bit 0: is player engaged by trainer (to avoid being engaged by multiple trainers simultaneously)
+; bit 1: boulder dust animation (from using Strength) pending
+; bit 6: tried pushing against boulder once (you need to push twice before it will move)
 	ds 1
 
 	ds 9
@@ -557,7 +597,12 @@
 wcf0d:: ds 1
 wcf0e:: ds 1
 wcf0f:: ds 1
-wcf10:: ds 1
+
+wNPCMovementScriptFunctionNum:: ; cf10
+; which script function within the pointer table indicated by
+; wNPCMovementScriptPointerTableNum
+	ds 1
+
 wcf11:: ds 1
 
 wPredefParentBank:: ; cf12
@@ -571,7 +616,10 @@
 
 	ds 2
 
-wcf17:: ds 1
+wNPCMovementScriptSpriteOffset:: ; cf17
+; sprite offset of sprite being controlled by NPC movement script
+	ds 1
+
 wcf18:: ds 2
 
 wGBC:: ; cf1a
@@ -1657,13 +1705,25 @@
 wd71d:: ds 1
 wd71e:: ds 1
 wd71f:: ds 9
-wd728:: ds 2
+
+wd728::
+; bit 0: using Strength outside of battle
+	ds 1
+
+	ds 1
+
 wd72a:: ds 2
 wd72c:: ds 1
 wd72d:: ds 1
 wd72e:: ds 2
-wd730:: ds 2
-wd732:: ds 1
+
+wd730::
+; bit 7: set if joypad states are being simulated in the overworld
+	ds 1
+
+	ds 1
+
+wd732:: ds 1
 
 W_FLAGS_D733:: ; d733
 ; bit 4: use variable [W_CURMAPSCRIPT] instead of the provided index for next frame's map script (used to start battle when talking to trainers)
@@ -1670,7 +1730,11 @@
 	ds 1
 
 wd734:: ds 2
-wd736:: ds 1
+
+wd736:: ; d736
+; bit 0: check if the player is standing on a door and make him walk down a step if so
+	ds 1
+
 wd737:: ds 4
 wd73b:: ds 1
 wd73c:: ds 3