Sherlock: annotated disassembly

Routines

Prev: BB5C Up: Map Next: BC46
BB67: Lestrade's reply to something the player says
Parses the remark into a statement the same way as Watson's reply (BA67) and checks it against the case table: a statement whose evidence is complete is proven (BCC9) and Lestrade says so; otherwise it is marked as waiting and he says he does not believe the player has the evidence (72A6, 72BD).
A plain HELLO does not come here at all: Lestrade answers 'Good afternoon' through 9A80.
the player put in Lestrade's room, then remarks typed): BASIL KILLED - a statement that stops after the verb - goes to BBBE and Lestrade says 'What' (7243). After MAJOR FFOULKES IS INNOCENT is left waiting the same remark proves it and Lestrade says 'Very good Holmes, I shall return to Leather head tomorrow...', through BBE5.
BBFB-BC17, which names a statement with flags bit 4 that is still waiting. Only the four flags-$B4 statements (Tricia Fender or Phipps killed Mrs Brown or Mrs Jones) have that bit, and each has a child record that asks only that thing 0, the player, has been seen.
Input
IY The remark's sentence node
A 0
Output
A reply printed
BB67 LD ($BA1D),A Store A in $BA1D in "Variables used by the code at BA20-BF58" - A = 0 on entry: clear $BA1D and $BA1C (the count of statements matched)
BB6A LD ($BA1C),A Store A in $BA1C in "Variables used by the code at BA20-BF58"
BB6D CALL $BD7E Parse the next statement out of the remark (BD7E)
BB70 JP C,$BBBE Carry: no sense, reply 7243 (BBBE)
BB73 CALL $BC21 Call BC21 (inside "Lestrade's reply to something the player...") - Look it up and try to prove it (BC21)
BB76 JR Z,$BB7C If the zero flag is set, skip ahead to BB7C
BB78 LD HL,$BA1C Point HL at $BA1C in "Variables used by the code at BA20-BF58" - Count one more in $BA1C
BB7B INC (HL) Add one to the byte at $BA1C in "Variables used by the code at BA20-BF58"
BB7C CALL $AEA9 Call the routine "IY = the next node in the list (Z at the end)" (AEA9) - Next part of the remark (AEA9); more: loop
BB7F JR NZ,$BB6D If the zero flag is clear, go back to BB6D
BB81 LD A,($BA1C) Read $BA1C in "Variables used by the code at BA20-BF58" into A - Matched nothing at all?
BB84 AND A Test A for zero (this leaves A as it was and clears carry)
BB85 JR NZ,$BB8E If A is not zero, skip ahead to BB8E
BB87 LD HL,$725F Point HL at the message "YOU SAY" THAT MAY WELL BE, HOLMES, I WILL THINK... (725F) - Then the stock reply 725F
BB8A CALL $A59F Call the routine "Print the message at HL" (A59F)
BB8D RET Return to the caller
BB8E LD A,($BA1D) Read $BA1D in "Variables used by the code at BA20-BF58" into A - $BA1D zero: go to the summary at BBC9
BB91 AND A Test A for zero (this leaves A as it was and clears carry)
BB92 JR Z,$BBC9 If A is zero, jump on to BBC9
BB94 LD IX,($BA1E) Read $BA1E in "Variables used by the code at BA20-BF58" into IX - Otherwise IX = the last record found ($BA1E)
BB98 PUSH IX Save IX on the stack
BB9A CALL $BE5A Step over it (BE5A)...
BB9D LD A,(IX+$03) Read byte +3 of the record at IX into A - ...and look at what follows for records with flags bits 7-6 = 10 or bit 3 set; otherwise skip a group (BE72)
BBA0 AND $C0 Keep only bits 6, 7 of A (mask $C0)
BBA2 CP $80 Compare A with $80
BBA4 JR Z,$BBB1 If A equals $80, skip ahead to BBB1
BBA6 BIT 3,(IX+$03) Test bit 3 of byte +3 of the record at IX
BBAA JR NZ,$BBB1 If bit 3 of byte +3 of the record at IX is set, skip ahead to BBB1
BBAC CALL $BE72 Call the routine "Step IX over a whole group of case records" (BE72)
BBAF JR $BB9D Go back to BB9D
BBB1 POP IX Restore IX from the stack - Restore IX; NZ: the 'do not believe you have the evidence' reply 72A6 (BBC4)
BBB3 JR NZ,$BBC4 If the zero flag is clear, skip ahead to BBC4
BBB5 LD HL,$7295 Z: reply 7295
BBB8 PUSH IX Save IX on the stack - Print the reply with IX as the subject
BBBA CALL $A59F Call the routine "Print the message at HL" (A59F)
BBBD RET Return to the caller
This entry point is used by the routine at BA67.
BBBE LD HL,$7243 Point HL at the message "YOU SAY" WHAT"." (7243) - Reply 7243
BBC1 JP $A59F Go back to the routine "Print the message at HL" (A59F)
BBC4 LD HL,$72A6 (72A6)
BBC7 JR $BBB8 Go back to BBB8
BBC9 CALL $BC46 Summary: try to prove every waiting statement (BC46)
BBCC CALL $BC9C Call the routine "Find the first waiting statement that cannot be..." (BC9C) - Find the first still unprovable one (BC9C): B = how many
BBCF LD A,B Copy B into A
BBD0 AND A Test A for zero (this leaves A as it was and clears carry)
BBD1 JR NZ,$BBE5 Some: BBE5
BBD3 CALL $BC74 Call the routine "Count the waiting statements that can now be proven" (BC74) - None: count those that can now be proven (BC74)
BBD6 AND A Test A for zero (this leaves A as it was and clears carry)
BBD7 JR Z,$BBDE If A is zero, skip ahead to BBDE
BBD9 LD HL,$72BD (72BD) - Some: reply 72BD
BBDC JR $BBB8 Go back to BBB8
BBDE LD HL,$727E Point HL at the message "YOU SAY" THATS FINE HOLMES BUT WHAT DOES IT... (727E) - None: reply 727E
BBE1 CALL $A59F Call the routine "Print the message at HL" (A59F)
BBE4 RET Return to the caller
This entry point is used by the routine at 9DD8.
BBE5 PUSH AF Print 67FF, then 72D6 unless exactly one...
BBE6 LD HL,$67FF Point HL at the message "YOU SAY"" (67FF)
BBE9 CALL $A59F Call the routine "Print the message at HL" (A59F)
BBEC POP AF Restore AF from the stack
BBED CP $01 Compare A with $01
BBEF LD HL,$72D6 Point HL at the message "ONE THING AT A TIME HOLMES" (72D6)
BBF2 CALL NZ,$A59F If A differs from $01, call the routine "Print the message at HL" (A59F)
BBF5 BIT 4,(IX+$03) Test bit 4 of byte +3 of the record at IX - Statement flags bit 4 clear: jump to the address at +4/+5 (BC1A). Bit 4 set: take back the proven bit (1), print 72E1, then the message at +4/+5 (or a Save the statement record
BBF9 JR Z,$BC1A If bit 4 of byte +3 of the record at IX is clear, skip ahead to BC1A
BBFB RES 1,(IX+$03) Clear bit 1 of byte +3 of the record at IX
BBFF PUSH IX Save IX on the stack
BC01 LD HL,$72E1 Point HL at the message "I CANNOT ACCEPT THAT YOU AND YOU." (72E1) - Print 72E1
BC04 CALL $A59F Call the routine "Print the message at HL" (A59F)
BC07 LD L,(IX+$04) Read byte +4 of the record at IX into L - HL = the word at +4/+5
BC0A LD H,(IX+$05) Read byte +5 of the record at IX into H
BC0D LD A,L Copy L into A
BC0E OR H Set in A the bits that are set in H
BC0F JP NZ,$A59F Non-zero: print the message it points to and finish (A59F)
BC12 LD A,$22 Load A with $22 - Zero: print a quote mark (A = $22) (A9B7)
BC14 CALL $A9B7 Call the routine "Print character A, a word at a time (word wrap)" (A9B7)
BC17 JP $A414 ...and end the line (A414)
BC1A LD L,(IX+$04) Read byte +4 of the record at IX into L - Bit 4 clear: jump to the routine at +4/+5
BC1D LD H,(IX+$05) Read byte +5 of the record at IX into H
BC20 JP (HL) Jump to the address in HL
BC21 CALL $BD51 Look the statement up in the case table (BD51)
BC24 JR NZ,$BC2F Not there: return 0
BC26 LD A,(IX+$03) Read byte +3 of the record at IX into A - Only if its flags bits 7-6 are 10
BC29 AND $C0 Keep only bits 6, 7 of A (mask $C0)
BC2B CP $80 Compare A with $80
BC2D JR Z,$BC31 If A equals $80, skip ahead to BC31
BC2F XOR A Set A to zero, which sets the zero flag for the caller
BC30 RET Return to the caller
BC31 LD ($BA1E),IX Remember the record in $BA1E
BC35 CALL $BCC9 Try to prove it (BCC9)
BC38 JR Z,$BC43 Proven: return NZ
BC3A LD A,$01 Load A with $01 - Not proven: $BA1D = 1...
BC3C LD ($BA1D),A Store A in $BA1D in "Variables used by the code at BA20-BF58"
BC3F SET 0,(IX+$03) ...and mark it waiting (bit 0)
BC43 OR $01 Make A non-zero, which clears the zero flag, and hand that back to the caller - Return NZ
BC45 RET Return to the caller
Prev: BB5C Up: Map Next: BC46