Sherlock: annotated disassembly

Routines

Prev: B4FD Up: Map Next: B549
B517: ALL BUT: is the candidate one of the things after BUT?
Only when $A01C is set (bit 7 of the verb's first word reference, copied from B39C at $B1ED): walks the parse nodes after IY (AEA9) and, in any marked with bit 6 of +1 - the node B029 opens when BUT (or EXCEPT, a synonym) follows ALL - looks for things the words at +8 name (D36A); NZ if the candidate in $A034 is one of them, and B4FD then passes over it.
Input
$A034 The candidate
Output
F NZ if the candidate is one of the BUT things; Z if not
Registers kept
B517 LD A,($A01C) Read $A01C in "Game variables" into A - Only for verbs whose first word has bit 7 ($A01C)
B51A AND A Clear the carry flag for the caller (A is unchanged)
B51B RET Z If A is zero, return
B51C PUSH IY Save IY on the stack
B51E PUSH DE Save DE on the stack
B51F PUSH IX Save IX on the stack
B521 CALL $AEA9 IY = the next parse node - but IY is D36A here, not a node (see the Bugs page)
B524 BIT 6,(IY+$01) Test bit 6 of the holder byte (+1) of the thing record at IY - A BUT node (bit 6 of +1)?
B528 JR Z,$B543 If bit 6 of the holder byte (+1) of the thing record at IY is clear, skip ahead to B543
B52A CALL $D04F Call the routine "IX = just before the start of the thing index (8B6F)" (D04F) - Then each thing its words (+8) name (D36A)...
B52D PUSH IY Save IY on the stack
B52F POP HL Restore HL from the stack
B530 LD DE,$0008 Load DE with $0008, the amount that is added next
B533 ADD HL,DE Add DE to HL
B534 CALL $D36A Call the routine "Find the next thing that matches a word slot of the..." (D36A)
B537 CP $FF Compare A with $FF
B539 JR Z,$B521 If A equals $FF, go back to B521
B53B LD HL,$A034 Point HL at $A034 in "Game variables" - ...is it the candidate?
B53E CP (HL) Compare A with the byte at $A034 in "Game variables"
B53F JR NZ,$B52D If A differs from the byte at $A034 in "Game variables", go back to B52D
B541 OR $01 Set bit 0 of A - NZ: yes, leave it out
B543 POP IX Restore IX from the stack
B545 POP DE Restore DE from the stack
B546 POP IY Restore IY from the stack
B548 RET Return to the caller
Prev: B4FD Up: Map Next: B549