Sherlock: annotated disassembly

Routines

Prev: D34E Up: Map Next: D39B
D36A: Find the next thing that matches a word slot of the parse
HL = the slot ($B172 or $B178); matches names through A4E0.
How it works:
1. Take the next thing from the index (D206); when there are none left, return $FF.
2. See whether the slot's words name it (A4E0 against its name words at +7); if not, take the next.
3. With $A038 set any match will do; otherwise it must also be visible to the actor (C821).
Input
HL A word slot of the parse
IX The last thing found
Output
A The next matching thing, $FF if none
IX Its list entry
D36A PUSH BC Save BC on the stack
D36B PUSH DE Save DE on the stack
D36C PUSH IY Save IY on the stack
D36E CALL $D206 Call the routine "Step to the next 3-byte entry" (D206) - Next thing (D206: IX its list entry, IY its record); none left: A = $FF
D371 JR Z,$D393 If the zero flag is set, skip ahead to D393
D373 LD BC,$0007 Load BC with $0007 - Do the slot's words name it? (its name words at +7, A4E0)
D376 PUSH IY Save IY on the stack
D378 ADD IY,BC Add BC to IY
D37A CALL $A4E0 Call A4E0 (inside "Do the pattern words at IY name the words...")
D37D POP IY Restore IY from the stack
D37F JR NZ,$D36E If the zero flag is clear, go back to D36E
D381 LD A,($A038) Read $A038 in "Game variables" into A - With $A038 set any match will do;
D384 AND A Test A for zero (this leaves A as it was and clears carry)
D385 JR NZ,$D393 If A is not zero, skip ahead to D393
D387 LD A,(IX+$00) Read the first byte of the record at IX into A - otherwise it must also be here (C821)
D38A PUSH IX Save IX on the stack
D38C CALL $C821 Call the routine "Can the current actor ($A036) see thing A?" (C821)
D38F POP IX Restore IX from the stack
D391 JR Z,$D36E If the zero flag is set, go back to D36E
D393 LD A,(IX+$00) Read the first byte of the record at IX into A - A = the thing
D396 POP IY Restore IY from the stack
D398 POP DE Restore DE from the stack
D399 POP BC Restore BC from the stack
D39A RET Return to the caller
Prev: D34E Up: Map Next: D39B