Sherlock: annotated disassembly

Routines

Prev: D26C Up: Map Next: D29D
D275: Is thing A carried by the actor, perhaps inside something? (carry = yes)
Follows thing A's container (+1) upwards (D288, through D237) until it reaches the actor in $A036 (carry set) or something not held by anything ($FF: carry clear). A = $FF or $FE (no thing, a number) also gives carry.
Input
A the thing
Output
F carry if the actor has it
D275 LD HL,$A036 HL points at the actor
This entry point is used by the routines at D4EF, DC8D and E40A.
D278 CP $FF Compare A with $FF - No thing ($FF) or a number ($FE): carry
D27A SCF Set the carry flag for the caller
D27B RET Z If the zero flag is set, return
D27C CP $FE Compare A with $FE
D27E SCF Set the carry flag for the caller
D27F RET Z If the zero flag is set, return
D280 PUSH IX Save IX on the stack
D282 CALL $D288 Call D288 (inside "Is thing A carried by the actor, perhaps...")
D285 POP IX Restore IX from the stack
D287 RET Return to the caller
D288 CALL $D237 Call the routine "Resolve an id (in A) to its full entity record" (D237) - Find thing A's record
D28B PUSH AF Save AF on the stack
D28C LD A,(IX+$01) Read the holder byte (+1) of the thing record at IX into A - Its container; $FF = held by nothing: not carried (NC)
D28F CP $FF Compare A with $FF
D291 JR Z,$D29A If A equals $FF, skip ahead to D29A
D293 POP IX Restore IX from the stack - Is the container the actor? If not, go up a level
D295 CP (HL) Compare A with the byte HL points at
D296 JR NZ,$D288 If A differs from the byte HL points at, go back to D288
D298 SCF Set the carry flag for the caller - Carry: the actor has it
D299 RET Return to the caller
D29A POP AF Restore AF from the stack
D29B AND A Clear the carry flag for the caller (A is unchanged)
D29C RET Return to the caller
Prev: D26C Up: Map Next: D29D