Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/home/npc_movement.asm
1270 views
1
; not zero if an NPC movement script is running, the player character is
2
; automatically stepping down from a door, or joypad states are being simulated
3
IsPlayerCharacterBeingControlledByGame::
4
ld a, [wNPCMovementScriptPointerTableNum]
5
and a
6
ret nz
7
ld a, [wMovementFlags]
8
bit BIT_EXITING_DOOR, a
9
ret nz
10
ld a, [wStatusFlags5]
11
and 1 << BIT_SCRIPTED_MOVEMENT_STATE
12
ret
13
14
RunNPCMovementScript::
15
ld hl, wMovementFlags
16
bit BIT_STANDING_ON_DOOR, [hl]
17
res BIT_STANDING_ON_DOOR, [hl]
18
jr nz, .playerStepOutFromDoor
19
ld a, [wNPCMovementScriptPointerTableNum]
20
and a
21
ret z
22
dec a
23
add a
24
ld d, 0
25
ld e, a
26
ld hl, .NPCMovementScriptPointerTables
27
add hl, de
28
ld a, [hli]
29
ld h, [hl]
30
ld l, a
31
ldh a, [hLoadedROMBank]
32
push af
33
ld a, [wNPCMovementScriptBank]
34
ldh [hLoadedROMBank], a
35
ld [rROMB], a
36
ld a, [wNPCMovementScriptFunctionNum]
37
call CallFunctionInTable
38
pop af
39
ldh [hLoadedROMBank], a
40
ld [rROMB], a
41
ret
42
43
.NPCMovementScriptPointerTables
44
dw PalletMovementScriptPointerTable
45
dw PewterMuseumGuyMovementScriptPointerTable
46
dw PewterGymGuyMovementScriptPointerTable
47
.playerStepOutFromDoor
48
farjp PlayerStepOutFromDoor
49
50
EndNPCMovementScript::
51
farjp _EndNPCMovementScript
52
53
DebugPressedOrHeldB:: ; dummy except in _DEBUG
54
; This is used to skip Trainer battles, the
55
; Safari Game step counter, and some NPC scripts.
56
IF DEF(_DEBUG)
57
ld a, [wStatusFlags6]
58
bit BIT_DEBUG_MODE, a
59
ret z
60
ldh a, [hJoyHeld]
61
bit B_PAD_B, a
62
ret nz
63
ldh a, [hJoyPressed]
64
bit B_PAD_B, a
65
ENDC
66
ret
67
68