summaryrefslogtreecommitdiff
path: root/home/npc_movement.asm
diff options
context:
space:
mode:
authordannye <33dannye@gmail.com>2020-11-04 00:06:44 -0600
committerdannye <33dannye@gmail.com>2020-11-04 00:06:44 -0600
commit5647ca687b92954dcf37a6ea6bfbc9a341c32de4 (patch)
treedde1937a1bfdb3a835f4155e1c2eb8f1aaf86f63 /home/npc_movement.asm
parent53fcd05aa24693093d8af1dc8ec4fedd3957decc (diff)
Sync with pokered
Diffstat (limited to 'home/npc_movement.asm')
-rw-r--r--home/npc_movement.asm52
1 files changed, 52 insertions, 0 deletions
diff --git a/home/npc_movement.asm b/home/npc_movement.asm
new file mode 100644
index 00000000..200d3983
--- /dev/null
+++ b/home/npc_movement.asm
@@ -0,0 +1,52 @@
+; not zero if an NPC movement script is running, the player character is
+; automatically stepping down from a door, or joypad states are being simulated
+IsPlayerCharacterBeingControlledByGame::
+ ld a, [wNPCMovementScriptPointerTableNum]
+ and a
+ ret nz
+ ld a, [wd736]
+ bit 1, a ; currently stepping down from door bit
+ ret nz
+ ld a, [wd730]
+ and $80
+ ret
+
+RunNPCMovementScript::
+ ld hl, wd736
+ bit 0, [hl]
+ res 0, [hl]
+ jr nz, .playerStepOutFromDoor
+ ld a, [wNPCMovementScriptPointerTableNum]
+ and a
+ ret z
+ dec a
+ add a
+ ld d, 0
+ ld e, a
+ ld hl, .NPCMovementScriptPointerTables
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ldh a, [hLoadedROMBank]
+ push af
+ ld a, [wNPCMovementScriptBank]
+ call BankswitchCommon
+ ld a, [wNPCMovementScriptFunctionNum]
+ call CallFunctionInTable
+ pop af
+ call BankswitchCommon
+ ret
+
+.NPCMovementScriptPointerTables
+ dw PalletMovementScriptPointerTable
+ dw PewterMuseumGuyMovementScriptPointerTable
+ dw PewterGymGuyMovementScriptPointerTable
+.playerStepOutFromDoor
+ farjp PlayerStepOutFromDoor
+
+EndNPCMovementScript::
+ farjp _EndNPCMovementScript
+
+DebugPressedOrHeldB::
+ ret