Sherlock: annotated disassembly

Routines

Prev: 9D95 Up: Map Next: 9DD8
9DC6: Lestrade greets you: 'WELL, HOLMES FANCY SEEING YOU HERE.' the first time
Once the greeting countdown allows (9CF2), says 71ED the first time (the flag at HL becomes 1) and an ordinary greeting (9CEC, 6929: '... SAYS TO ... "GOOD MORNING"') after that. Called by Lestrade's after-turn routine 9D95. "' and 'Inspector Lestrade says to you " Good afternoon "').
Input
HL The greeting flag of Lestrade ($9D91; its countdown is the next byte)
C The person to greet
Output
F From $A59F
9DC6 INC HL Step HL on to the next byte - Greeting countdown allows it (9CF2)?
9DC7 CALL $9CF2 Call 9CF2 (inside "Say good morning to C, if just met")
9DCA DEC HL Step HL back one byte
9DCB LD A,(HL) Read the byte HL points at into A - Already greeted once (9DCC non-zero): ordinary greeting (9CEC)
9DCC AND A Test A for zero (this leaves A as it was and clears carry)
9DCD JP NZ,$9CEC If A is not zero, go back to 9CEC
9DD0 INC A Add one to A - First time: mark it greeted...
9DD1 LD (HL),A Store A at the address HL points to
9DD2 LD HL,$71ED Point HL at the message "YOU WITH A SURPRISED LOOK ON HIS FACE, SAYS"... (71ED) - ...and say 71ED
9DD5 JP $A59F Jump on to the routine "Print the message at HL" (A59F)
Prev: 9D95 Up: Map Next: 9DD8