Prev: CCAB Up: Map Next: CCFB
CCCD: Is item discoverable?
This searches through item_structs for items dropped nearby. If items are found then hostiles are made to pursue the hero, but the green key and food items are ignored.
Used by the routine at automatics.
is_item_discoverable CCCD LD A,($68A0) Get the global current room index
CCD0 AND A Is it room_0_OUTDOORS?
CCD1 JR Z,is_item_discoverable_0 Jump if so
Interior.
CCD3 CALL is_item_discoverable_interior Is the item discoverable indoors?
CCD6 RET NZ Return if not found
Item was found.
CCD7 CALL hostiles_pursue Hostiles pursue prisoners
CCDA RET Return
Exterior.
is_item_discoverable_0 CCDB LD HL,$76C9 Point HL at item_structs[0].room
CCDE LD DE,$0007 Prepare the itemstruct stride
CCE1 LD B,$10 Set B for 16 iterations -- number of itemstructs
Start loop
is_item_discoverable_1 CCE3 BIT 7,(HL) Is itemstruct.item_and_flags itemstruct_ROOM_FLAG_NEARBY_7 flag set?
CCE5 JR NZ,iid_nearby Jump if so
iid_next CCE7 ADD HL,DE Advance to the next itemstruct
CCE8 DJNZ is_item_discoverable_1 ..loop
CCEA RET Return
Suspected bug: HL is decremented, but not re-incremented before 'goto next'. So it must be reading a byte early when iteration is resumed. Consequences? I think it'll screw up when multiple items are in range.
iid_nearby CCEB DEC HL
CCEC LD A,(HL) A = *HL & itemstruct_ITEM_MASK; // sampled HL=$772A (&item_structs[item_PURSE].item)
CCED AND $0F
The green key and food items are ignored.
CCEF CP $0B Is it item_GREEN_KEY?
CCF1 JR Z,iid_next Jump to next iteration if so
CCF3 CP $07 Is it item_FOOD?
CCF5 JR Z,iid_next Jump to next iteration if so
CCF7 CALL hostiles_pursue Otherwise, hostiles pursue prisoners
CCFA RET Return
Prev: CCAB Up: Map Next: CCFB