mirror of
https://github.com/pret/pokered.git
synced 2024-10-24 07:25:21 +00:00
52 lines
763 B
NASM
Executable file
52 lines
763 B
NASM
Executable file
HiddenItemNear:
|
|
ld hl, HiddenItemCoords
|
|
ld b, 0
|
|
.loop
|
|
ld de, 3
|
|
ld a, [wCurMap]
|
|
call IsInRestOfArray
|
|
ret nc ; return if current map has no hidden items
|
|
push bc
|
|
push hl
|
|
ld hl, wObtainedHiddenItemsFlags
|
|
ld c, b
|
|
ld b, FLAG_TEST
|
|
predef FlagActionPredef
|
|
ld a, c
|
|
pop hl
|
|
pop bc
|
|
inc b
|
|
and a
|
|
inc hl
|
|
ld d, [hl]
|
|
inc hl
|
|
ld e, [hl]
|
|
inc hl
|
|
jr nz, .loop ; if the item has already been obtained
|
|
; check if the item is within 4-5 tiles (depending on the direction of item)
|
|
ld a, [wYCoord]
|
|
call Sub5ClampTo0
|
|
cp d
|
|
jr nc, .loop
|
|
ld a, [wYCoord]
|
|
add 4
|
|
cp d
|
|
jr c, .loop
|
|
ld a, [wXCoord]
|
|
call Sub5ClampTo0
|
|
cp e
|
|
jr nc, .loop
|
|
ld a, [wXCoord]
|
|
add 5
|
|
cp e
|
|
jr c, .loop
|
|
scf
|
|
ret
|
|
|
|
Sub5ClampTo0:
|
|
; subtract 5 but clamp to 0
|
|
sub 5
|
|
cp $f0
|
|
ret c
|
|
xor a
|
|
ret
|