Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/items/itemfinder.asm
1271 views
1
HiddenItemNear:
2
ld hl, HiddenItemCoords
3
ld b, 0
4
.loop
5
ld de, 3
6
ld a, [wCurMap]
7
call IsInRestOfArray
8
ret nc ; return if current map has no hidden items
9
push bc
10
push hl
11
ld hl, wObtainedHiddenItemsFlags
12
ld c, b
13
ld b, FLAG_TEST
14
predef FlagActionPredef
15
ld a, c
16
pop hl
17
pop bc
18
inc b
19
and a
20
inc hl
21
ld d, [hl]
22
inc hl
23
ld e, [hl]
24
inc hl
25
jr nz, .loop ; if the item has already been obtained
26
; check if the item is within 4-5 tiles (depending on the direction of item)
27
ld a, [wYCoord]
28
call Sub5ClampTo0
29
cp d
30
jr nc, .loop
31
ld a, [wYCoord]
32
add 4
33
cp d
34
jr c, .loop
35
ld a, [wXCoord]
36
call Sub5ClampTo0
37
cp e
38
jr nc, .loop
39
ld a, [wXCoord]
40
add 5
41
cp e
42
jr c, .loop
43
scf
44
ret
45
46
Sub5ClampTo0:
47
; subtract 5 but clamp to 0
48
sub 5
49
cp $f0
50
ret c
51
xor a
52
ret
53
54