pokered/engine/items/itemfinder.asm

53 lines
763 B
NASM
Raw Normal View History

2016-06-12 00:24:04 +00:00
HiddenItemNear:
2014-05-22 22:13:20 +00:00
ld hl, HiddenItemCoords
2015-07-19 03:49:52 +00:00
ld b, 0
.loop
ld de, 3
2015-08-31 02:38:41 +00:00
ld a, [wCurMap]
call IsInRestOfArray
2014-05-22 22:13:20 +00:00
ret nc ; return if current map has no hidden items
push bc
push hl
2015-07-19 03:49:52 +00:00
ld hl, wObtainedHiddenItemsFlags
2014-05-22 22:13:20 +00:00
ld c, b
2015-07-20 03:45:34 +00:00
ld b, FLAG_TEST
predef FlagActionPredef
2014-05-22 22:13:20 +00:00
ld a, c
pop hl
pop bc
inc b
and a
inc hl
ld d, [hl]
inc hl
ld e, [hl]
inc hl
2015-07-19 03:49:52 +00:00
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)
2015-08-31 02:38:41 +00:00
ld a, [wYCoord]
2015-07-19 03:49:52 +00:00
call Sub5ClampTo0
2014-05-22 22:13:20 +00:00
cp d
2015-07-19 03:49:52 +00:00
jr nc, .loop
2015-08-31 02:38:41 +00:00
ld a, [wYCoord]
2015-07-19 03:49:52 +00:00
add 4
2014-05-22 22:13:20 +00:00
cp d
2015-07-19 03:49:52 +00:00
jr c, .loop
2015-08-31 02:38:41 +00:00
ld a, [wXCoord]
2015-07-19 03:49:52 +00:00
call Sub5ClampTo0
2014-05-22 22:13:20 +00:00
cp e
2015-07-19 03:49:52 +00:00
jr nc, .loop
2015-08-31 02:38:41 +00:00
ld a, [wXCoord]
2015-07-19 03:49:52 +00:00
add 5
2014-05-22 22:13:20 +00:00
cp e
2015-07-19 03:49:52 +00:00
jr c, .loop
2014-05-22 22:13:20 +00:00
scf
ret
2016-06-12 00:24:04 +00:00
Sub5ClampTo0:
2015-07-19 03:49:52 +00:00
; subtract 5 but clamp to 0
sub 5
2014-05-22 22:13:20 +00:00
cp $f0
ret c
xor a
ret