Sherlock: annotated disassembly

Routines

Prev: 9CCE Up: Map Next: 9D10
9CE9: Say good morning to C, if just met
Used by after-turn routines: 9CF2 checks whether C is here and seen and whether the greeting countdown at HL has run out; if so the countdown is set to 30 to 45 minutes (30 plus a random number from 0 to 15) and 6929 is printed: '<actor> SAYS TO <C> "GOOD MORNING".' While C stays away the countdown runs down by one a turn, so characters greet each other again only after a while apart.
Input
HL The greeting countdown
C The thing to greet
Output
F From $A59F when the greeting is printed
9CE9 CALL $9CF2 9CF2 sets up who is being spoken to; if it returns, print message 6929
This entry point is used by the routine at 9DC6.
9CEC LD HL,$6929 Point HL at the message "YOU SAY TO THE OIL LAMP" GOOD MORNING "." (6929) - "... SAYS TO ... GOOD MORNING"
9CEF JP $A59F Jump on to the routine "Print the message at HL" (A59F)
This entry point is used by the routines at 9D48, 9DC6 and 9DD8.
9CF2 LD A,C Copy C into A - The thing to talk to (C) becomes the direct object ($A034)
9CF3 LD ($A034),A Store A in $A034 in "Game variables"
9CF6 CALL $9CCE Is it in the actor's room and visible to the player (9CCE)?
9CF9 JR Z,$9D02 Yes
9CFB DEC (HL) Subtract one from the byte HL points at - Not so: one less on its countdown (not below zero)
9CFC JP P,$9D00 If the last result was positive (sign flag clear), skip ahead to 9D00
9CFF INC (HL) Add one to the byte HL points at
9D00 POP DE Restore DE from the stack - ...and skip the caller's print (the stack is dropped)
9D01 RET Return to the caller
9D02 LD A,(HL) Read the byte HL points at into A - Visible: only when the countdown is 0...
9D03 AND A Test A for zero (this leaves A as it was and clears carry)
9D04 JR NZ,$9D00 If A is not zero, go back to 9D00
9D06 LD A,$0F Load A with $0F - ...then reset it to a random 30 to 44 (D2A4 with range 15, plus 30)
9D08 CALL $D2A4 Call the routine "A random number from 0 to A" (D2A4)
9D0B ADD A,$1E Add $1E to A
9D0D LD (HL),A Store A at the address HL points to
9D0E XOR A Set A to zero, which sets the zero flag for the caller - Greet
9D0F RET Return to the caller
Prev: 9CCE Up: Map Next: 9D10