Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/home/pathfinding.asm
1270 views
1
; calculates the difference |a-b|, setting carry flag if a<b
2
CalcDifference::
3
sub b
4
ret nc
5
cpl
6
add $1
7
scf
8
ret
9
10
MoveSprite::
11
; move the sprite [hSpriteIndex] with the movement pointed to by de
12
; actually only copies the movement data to wNPCMovementDirections for later
13
call SetSpriteMovementBytesToFF
14
MoveSprite_::
15
push hl
16
push bc
17
call GetSpriteMovementByte1Pointer
18
xor a
19
ld [hl], a
20
ld hl, wNPCMovementDirections
21
ld c, 0
22
23
.loop
24
ld a, [de]
25
ld [hli], a
26
inc de
27
inc c
28
cp -1 ; have we reached the end of the movement data?
29
jr nz, .loop
30
31
ld a, c
32
ld [wNPCNumScriptedSteps], a ; number of steps taken
33
34
pop bc
35
ld hl, wStatusFlags5
36
set BIT_SCRIPTED_NPC_MOVEMENT, [hl]
37
pop hl
38
xor a
39
ld [wOverrideSimulatedJoypadStatesMask], a
40
ld [wSimulatedJoypadStatesEnd], a
41
dec a
42
ld [wJoyIgnore], a
43
ld [wUnusedOverrideSimulatedJoypadStatesIndex], a
44
ret
45
46
; divides [hDividend2] by [hDivisor2] and stores the quotient in [hQuotient2]
47
DivideBytes::
48
push hl
49
ld hl, hQuotient2
50
xor a
51
ld [hld], a
52
ld a, [hld]
53
and a
54
jr z, .done
55
ld a, [hli]
56
.loop
57
sub [hl]
58
jr c, .done
59
inc hl
60
inc [hl]
61
dec hl
62
jr .loop
63
.done
64
pop hl
65
ret
66
67