Prev: 35456 Up: Map Next: 35583
35547: Find Item In Room
Used by the routine at HandlerHunchback.
Searches the eight records that start at ItemEntity_Wine for one that is in use and is in the same room as an entity. The records have eight bytes each, laid out in the same way as an entity.
Input
IX The entity
Output
C 1 if a record was found, otherwise 0
DE The position of the record that was found (X in E and Y in D)
HL The address of the Y position of the record that was found
FindItemInRoom 35547 LD HL,60184 Point HL at the first of the item records at ItemEntity_Wine.
35550 LD DE,8 DE=0008 (the size of each record).
35553 LD B,8 B=8 (the number of records to look at).
FindItemInRoom_Loop 35555 PUSH HL Stash the address of the record on the stack.
35556 LD A,(HL) Fetch the sprite ID of the record.
35557 AND A Test whether the record is in use.
35558 JR Z,FindItemInRoom_Next Jump to FindItemInRoom_Next if it is not.
35560 INC HL Move HL on to the room of the record.
35561 LD A,(HL) Fetch the room of the record.
35562 CP (IX+1) Compare it with the room of the entity.
35565 JR NZ,FindItemInRoom_Next Jump to FindItemInRoom_Next if they are different.
35567 POP DE Restore the address of the record into DE.
35568 INC HL Move HL on to the X position of the record.
35569 INC HL
35570 LD E,(HL) Fetch the X position of the record.
35571 INC HL Move HL on to the Y position of the record.
35572 LD D,(HL) Fetch the Y position of the record.
35573 LD C,1 Set the result in C to 1 (found).
35575 RET Return.
FindItemInRoom_Next 35576 POP HL Restore the address of the record from the stack.
35577 ADD HL,DE Move HL on to the next record.
35578 DJNZ FindItemInRoom_Loop Decrease the record counter by one and loop back to FindItemInRoom_Loop until all eight records have been checked.
35580 LD C,0 Set the result in C to 0 (not found).
35582 RET Return.
Prev: 35456 Up: Map Next: 35583