Sherlock: annotated disassembly

Routines

Prev: A2BD Up: Map Next: A35D
A2E4: Narrate a command as a sentence ('You take the oil lamp.')
Saves the verb and objects (A35D-A35F), then - unless it is too dark and the player is the one acting, when it prints 'SORRY IT IS TOO DARK.' (68D1) - prints the actor (A724), the verb's words from its pattern (A2B1/A2BD) and the objects, ending the line (A2A2). This is the sentence every successful action shows, for the player and for characters in sight ('Inspector Lestrade hails the hansom cab.').
What $A00C means (the B of this routine) was not established, so the two narration paths are described by the branch, not by who is acting.
How it works:
1. Set A2AA to 1 while narrating, and keep the verb and both objects at A35D to A35F.
2. Work out whether the text is printed as quoted ($A027 is 1 when $A00C is 0).
3. If it is too dark to see (D078) and the actor is the player, print 'SORRY IT IS TOO DARK.' and finish.
4. Find the verb's record and gather its flags (A2BD). If bit 4 of $A01D is set the verb is never narrated.
5. Start a fresh line if the actor is a character other than the player, Watson or Lestrade's usual set (DC6C), and print the actor's name (A724).
6. If the actor was the player print the word YOU and narrate the command (A360); otherwise narrate it as it stands (A37D). End the line, clear A2AA and $A027.
Input
$A033 The verb
A034 The first object, A035 the second
$A036 The actor
Output
All registers kept
A2E4 LD A,$01 Load A with $01 - A2AA = 1 while narrating
A2E6 LD ($A2AA),A Store A in "Use THE: a flag for the article printer (A7F2)" (A2AA)
A2E9 PUSH IY Save IY on the stack - Save the registers
A2EB PUSH BC Save BC on the stack
A2EC PUSH IX Save IX on the stack
A2EE PUSH HL Save HL on the stack
A2EF PUSH DE Save DE on the stack
A2F0 LD A,($A033) Read $A033 in "Game variables" into A - Save the verb and the two objects at A35D-A35F
A2F3 LD ($A35D),A Store A in "A remembered command: verb, direct object,..." (A35D)
A2F6 LD HL,($A034) Read $A034 in "Game variables" into HL
A2F9 LD ($A35E),HL Store HL in A35E in "A remembered command: verb, direct object,..."
A2FC LD A,($A00C) Read $A00C in "Game variables" into A - B = $A00C (what it means was not established; CB43 clears it before narrating)
A2FF LD B,A Copy A into B
A300 AND A Test A for zero (this leaves A as it was and clears carry)
A301 LD A,$01 Load A with $01 - $A027 (quoted printing) = 1 if B is zero, else 0 (so the text is quoted when B is zero)
A303 JR Z,$A306 If A is zero, skip ahead to A306
A305 XOR A Clear A to zero (and the carry flag)
A306 LD ($A027),A Store A in $A027 in "Game variables"
A309 CALL $D078 Is it too dark to see (D078)?
A30C JR NC,$A31A No: carry on
A30E LD A,B Copy B into A - Dark, but B non-zero: carry on regardless
A30F AND A Test A for zero (this leaves A as it was and clears carry)
A310 JR NZ,$A31A If A is not zero, skip ahead to A31A
A312 LD HL,$68D1 Point HL at the message "SORRY IT IS TOO DARK." (68D1) - Dark: 'SORRY IT IS TOO DARK.' (68D1)
A315 CALL $A59F Call the routine "Print the message at HL" (A59F)
A318 JR $A34E Jump on to A34E
A31A LD A,($A35D) Read "A remembered command: verb, direct object,..." (A35D) into A - The verb's pattern record (A2B1) into IX
A31D CALL $A2B1 Call the routine "HL = verb A's record in the verb table" (A2B1)
A320 PUSH HL Save HL on the stack
A321 POP IX Restore IX from the stack
A323 CALL $A2BD Set the verb flags $A01D/$A01E (A2BD)
A326 LD A,($A01D) Read $A01D in "Game variables" into A - Verb flag bit 4: no narration
A329 AND $10 Isolate bit 4 of A (mask $10)
A32B JR NZ,$A34E Set: skip to the end
A32D CP B Compare A with B - B zero?
A32E JR Z,$A336 If A equals B, skip ahead to A336
A330 CALL $DC6C An actor other than 0, 1 or 100?
A333 CALL Z,$A2A2 Then start a fresh line (A2A2)
A336 CALL $A724 Print the actor's name (A724)
A339 LD DE,$017F Load DE with $017F - DE = $017F
A33C XOR A Clear A to zero (and the carry flag)
A33D CP B Compare A with B - B zero: print the word at DE ($017F) (A887), then narrate with the actor set to 0 = YOU (A360)
A33E JR NZ,$A348 If A differs from B, skip ahead to A348
A340 CALL $A887 Call A887 (inside "Print the dictionary word that HL refers to")
A343 CALL $A360 Call the routine "Code $18: narrate the remembered command" (A360)
A346 JR $A34B Skip ahead to A34B
A348 CALL $A37D B non-zero: narrate as it stands (A37D)
A34B CALL $A2A2 End the line (A2A2)
A34E XOR A Clear A to zero (and the carry flag) - Clear A2AA and $A027
A34F LD ($A2AA),A Store A in "Use THE: a flag for the article printer (A7F2)" (A2AA)
A352 LD ($A027),A Store A in $A027 in "Game variables"
A355 POP DE Restore DE from the stack - Restore the registers and return
A356 POP HL Restore HL from the stack
A357 POP IX Restore IX from the stack
A359 POP BC Restore BC from the stack
A35A POP IY Restore IY from the stack
A35C RET Return to the caller
Prev: A2BD Up: Map Next: A35D