2014-05-22 22:13:20 +00:00
|
|
|
HiddenItemNear: ; 7481f (1d:481f)
|
|
|
|
ld hl, HiddenItemCoords
|
2015-07-19 03:49:52 +00:00
|
|
|
ld b, 0
|
|
|
|
.loop
|
|
|
|
ld de, 3
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [W_CURMAP]
|
2014-05-23 22:11:09 +00:00
|
|
|
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
|
2014-06-16 20:57:26 +00:00
|
|
|
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)
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [W_YCOORD]
|
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
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [W_YCOORD]
|
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
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [W_XCOORD]
|
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
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [W_XCOORD]
|
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
|
|
|
|
|
2015-07-19 03:49:52 +00:00
|
|
|
Sub5ClampTo0: ; 7486b (1d:486b)
|
|
|
|
; subtract 5 but clamp to 0
|
|
|
|
sub 5
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $f0
|
|
|
|
ret c
|
|
|
|
xor a
|
|
|
|
ret
|