summaryrefslogtreecommitdiff
path: root/engine/overworld/npc_movement.asm
diff options
context:
space:
mode:
Diffstat (limited to 'engine/overworld/npc_movement.asm')
-rwxr-xr-xengine/overworld/npc_movement.asm156
1 files changed, 81 insertions, 75 deletions
diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm
index 84e39853..98d1b7a7 100755
--- a/engine/overworld/npc_movement.asm
+++ b/engine/overworld/npc_movement.asm
@@ -1,4 +1,4 @@
-PlayerStepOutFromDoor: ; 1a3e0 (6:63e0)
+PlayerStepOutFromDoor:
ld hl, wd730
res 1, [hl]
call IsPlayerStandingOnDoorTile
@@ -27,7 +27,7 @@ PlayerStepOutFromDoor: ; 1a3e0 (6:63e0)
res 7, [hl]
ret
-_EndNPCMovementScript: ; 1a41d (6:641d)
+_EndNPCMovementScript:
ld hl, wd730
res 7, [hl]
ld hl, wd72e
@@ -44,60 +44,66 @@ _EndNPCMovementScript: ; 1a41d (6:641d)
ld [wSimulatedJoypadStatesEnd], a
ret
-ProfOakMovementScriptPointerTable: ; 1a442 (6:6442)
- dw Func_1a44c
- dw Func_1a485
- dw Func_1a4a1
- dw Func_1a4a6
- dw Func_1a4f4
+PalletMovementScriptPointerTable:
+ dw PalletMovementScript_OakMoveLeft
+ dw PalletMovementScript_PlayerMoveLeft
+ dw PalletMovementScript_WaitAndWalkToLab
+ dw PalletMovementScript_WalkToLab
+ dw PalletMovementScript_Done
-Func_1a44c: ; 1a44c (6:644c)
- ld a, [W_XCOORD] ; wd362
+PalletMovementScript_OakMoveLeft:
+ ld a, [wXCoord]
sub $a
- ld [wcca1], a
- jr z, .asm_1a475
- ld b, $0
+ ld [wNumStepsToTake], a
+ jr z, .playerOnLeftTile
+; The player is on the right tile of the northern path out of Pallet Town and
+; Prof. Oak is below.
+; Make Prof. Oak step to the left.
+ ld b, 0
ld c, a
ld hl, wNPCMovementDirections2
- ld a, $80
+ ld a, NPC_MOVEMENT_LEFT
call FillMemory
ld [hl], $ff
ld a, [wSpriteIndex]
- ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
+ ld [H_SPRITEINDEX], a
ld de, wNPCMovementDirections2
call MoveSprite
ld a, $1
ld [wNPCMovementScriptFunctionNum], a
- jr .asm_1a47a
-.asm_1a475
+ jr .done
+; The player is on the left tile of the northern path out of Pallet Town and
+; Prof. Oak is below.
+; Prof. Oak is already where he needs to be.
+.playerOnLeftTile
ld a, $3
ld [wNPCMovementScriptFunctionNum], a
-.asm_1a47a
- ld hl, W_FLAGS_D733
+.done
+ ld hl, wFlags_D733
set 1, [hl]
ld a, $fc
ld [wJoyIgnore], a
ret
-Func_1a485: ; 1a485 (6:6485)
+PalletMovementScript_PlayerMoveLeft:
ld a, [wd730]
- bit 0, a
- ret nz
- ld a, [wcca1]
+ bit 0, a ; is an NPC being moved by a script?
+ ret nz ; return if Oak is still moving
+ ld a, [wNumStepsToTake]
ld [wSimulatedJoypadStatesIndex], a
- ld [$ff95], a
+ ld [hNPCMovementDirections2Index], a
predef ConvertNPCMovementDirectionsToJoypadMasks
call StartSimulatingJoypadStates
ld a, $2
ld [wNPCMovementScriptFunctionNum], a
ret
-Func_1a4a1: ; 1a4a1 (6:64a1)
+PalletMovementScript_WaitAndWalkToLab:
ld a, [wSimulatedJoypadStatesIndex]
- and a
+ and a ; is the player done moving left yet?
ret nz
-Func_1a4a6: ; 1a4a6 (6:64a6)
+PalletMovementScript_WalkToLab:
xor a
ld [wOverrideSimulatedJoypadStatesMask], a
ld a, [wSpriteIndex]
@@ -121,16 +127,16 @@ Func_1a4a6: ; 1a4a6 (6:64a6)
ld [wNPCMovementScriptFunctionNum], a
ret
-RLEList_ProfOakWalkToLab: ; 1a4dc (6:64dc)
- db $00, $05
- db $80, $01
- db $00, $05
- db $C0, $03
- db $40, $01
- db $E0, $01
+RLEList_ProfOakWalkToLab:
+ db NPC_MOVEMENT_DOWN, $05
+ db NPC_MOVEMENT_LEFT, $01
+ db NPC_MOVEMENT_DOWN, $05
+ db NPC_MOVEMENT_RIGHT, $03
+ db NPC_MOVEMENT_UP, $01
+ db $E0, $01 ; stand still
db $FF
-RLEList_PlayerWalkToLab: ; 1a4e9 (6:64e9)
+RLEList_PlayerWalkToLab:
db D_UP, $02
db D_RIGHT, $03
db D_DOWN, $05
@@ -138,12 +144,12 @@ RLEList_PlayerWalkToLab: ; 1a4e9 (6:64e9)
db D_DOWN, $06
db $FF
-Func_1a4f4: ; 1a4f4 (6:64f4)
+PalletMovementScript_Done:
ld a, [wSimulatedJoypadStatesIndex]
and a
ret nz
ld a, $0
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld hl, wd730
res 7, [hl]
@@ -151,16 +157,16 @@ Func_1a4f4: ; 1a4f4 (6:64f4)
res 7, [hl]
jp EndNPCMovementScript
-PewterMuseumGuyMovementScriptPointerTable: ; 1a510 (6:6510)
- dw Func_1a514
- dw PewterMovementScriptDone
+PewterMuseumGuyMovementScriptPointerTable:
+ dw PewterMovementScript_WalkToMuseum
+ dw PewterMovementScript_Done
-Func_1a514: ; 1a514 (6:6514)
+PewterMovementScript_WalkToMuseum:
ld a, BANK(Music_MuseumGuy)
- ld [wc0ef], a
- ld [wc0f0], a
+ ld [wAudioROMBank], a
+ ld [wAudioSavedROMBank], a
ld a, MUSIC_MUSEUM_GUY
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
ld a, [wSpriteIndex]
swap a
@@ -172,7 +178,7 @@ Func_1a514: ; 1a514 (6:6514)
dec a
ld [wSimulatedJoypadStatesIndex], a
xor a
- ld [wd12f], a
+ ld [wWhichPewterGuy], a
predef PewterGuys
ld hl, wNPCMovementDirections2
ld de, RLEList_PewterMuseumGuy
@@ -183,21 +189,21 @@ Func_1a514: ; 1a514 (6:6514)
ld [wNPCMovementScriptFunctionNum], a
ret
-RLEList_PewterMuseumPlayer: ; 1a559 (6:6559)
+RLEList_PewterMuseumPlayer:
db 0, $01
db D_UP, $03
db D_LEFT, $0D
db D_UP, $06
db $FF
-RLEList_PewterMuseumGuy: ; 1a562 (6:6562)
- db $40, $06
- db $80, $0D
- db $40, $03
- db $80, $01
+RLEList_PewterMuseumGuy:
+ db NPC_MOVEMENT_UP, $06
+ db NPC_MOVEMENT_LEFT, $0D
+ db NPC_MOVEMENT_UP, $03
+ db NPC_MOVEMENT_LEFT, $01
db $FF
-PewterMovementScriptDone: ; 1a56b (6:656b)
+PewterMovementScript_Done:
ld a, [wSimulatedJoypadStatesIndex]
and a
ret nz
@@ -207,16 +213,16 @@ PewterMovementScriptDone: ; 1a56b (6:656b)
res 7, [hl]
jp EndNPCMovementScript
-PewterGymGuyMovementScriptPointerTable: ; 1a57d (6:657d)
- dw Func_1a581
- dw PewterMovementScriptDone
+PewterGymGuyMovementScriptPointerTable:
+ dw PewterMovementScript_WalkToGym
+ dw PewterMovementScript_Done
-Func_1a581: ; 1a581 (6:6581)
+PewterMovementScript_WalkToGym:
ld a, BANK(Music_MuseumGuy)
- ld [wc0ef], a
- ld [wc0f0], a
+ ld [wAudioROMBank], a
+ ld [wAudioSavedROMBank], a
ld a, MUSIC_MUSEUM_GUY
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
ld a, [wSpriteIndex]
swap a
@@ -228,8 +234,8 @@ Func_1a581: ; 1a581 (6:6581)
call DecodeRLEList
dec a
ld [wSimulatedJoypadStatesIndex], a
- ld a, $1
- ld [wd12f], a
+ ld a, 1
+ ld [wWhichPewterGuy], a
predef PewterGuys
ld hl, wNPCMovementDirections2
ld de, RLEList_PewterGymGuy
@@ -242,7 +248,7 @@ Func_1a581: ; 1a581 (6:6581)
ld [wNPCMovementScriptFunctionNum], a
ret
-RLEList_PewterGymPlayer: ; 1a5cd (6:65cd)
+RLEList_PewterGymPlayer:
db 0, $01
db D_RIGHT, $02
db D_DOWN, $05
@@ -251,17 +257,17 @@ RLEList_PewterGymPlayer: ; 1a5cd (6:65cd)
db D_LEFT, $0F
db $FF
-RLEList_PewterGymGuy: ; 1a5da (6:65da)
- db $00, $02
- db $80, $0F
- db $40, $05
- db $80, $0B
- db $00, $05
- db $C0, $03
+RLEList_PewterGymGuy:
+ db NPC_MOVEMENT_DOWN, $02
+ db NPC_MOVEMENT_LEFT, $0F
+ db NPC_MOVEMENT_UP, $05
+ db NPC_MOVEMENT_LEFT, $0B
+ db NPC_MOVEMENT_DOWN, $05
+ db NPC_MOVEMENT_RIGHT, $03
db $FF
-FreezeEnemyTrainerSprite: ; 1a5e7 (6:65e7)
- ld a, [W_CURMAP]
+FreezeEnemyTrainerSprite:
+ ld a, [wCurMap]
cp POKEMONTOWER_7
ret z ; the Rockets on Pokemon Tower 7F leave after battling, so don't freeze them
ld hl, RivalIDs
@@ -279,8 +285,8 @@ FreezeEnemyTrainerSprite: ; 1a5e7 (6:65e7)
ld [H_SPRITEINDEX], a
jp SetSpriteMovementBytesToFF
-RivalIDs: ; 1a605 (6:6605)
- db SONY1 + $c8
- db SONY2 + $c8
- db SONY3 + $c8
+RivalIDs:
+ db OPP_SONY1
+ db OPP_SONY2
+ db OPP_SONY3
db $ff