Sherlock: annotated disassembly

Routines

Prev: B934 Up: Map Next: B98C
B936: Deal with an order or remark addressed to the current actor
Called from CCB3, instead of the actor's script step, when B91F found something for it. A node with +7 = 2 goes to BA20 (Watson's and Lestrade's replies, BA67 and BB67). A node from a plan script's ASK (+1 = $FF) is handled at B98C: its verb and objects become the command, the node is removed, and the caller carries the command out (C4D1). Otherwise the words the player said are parsed for this actor (B191).
How it works:
1. Find the node waiting for this actor (B90E). If its +7 is 2 it is a remark: give Watson's or Lestrade's reply (BA20).
2. If its +1 is $FF it came from a plan script's ASK: turn it into a command (B98C).
3. Otherwise it is words the player said: restore the ALL flag and search position from the node, and parse the current sentence for this actor (B191).
4. If parsing fails, drop the sentences one by one and return Z. Otherwise keep the ALL position, drop the sentence unless it is an ALL, and return with the command to run.
Input
A The actor
Output
F From the order or remark
B936 PUSH IX Save IX on the stack
B938 PUSH IY Save IY on the stack
B93A PUSH HL Save HL on the stack
B93B LD ($B935),A Note the actor
This entry point is used by the routine at B98C.
B93E CALL $B90E IX = its order or remark (B90E)
B941 LD A,(IX+$07) Read byte +7 of the record at IX into A - A remark (+7 = 2): Watson's or Lestrade's reply (BA20)
B944 CP $02 Compare A with $02
B946 JP Z,$BA20 If A equals $02, jump on to the routine "A remark for Watson or Inspector Lestrade: let..." (BA20)
B949 LD A,(IX+$01) Read byte +1 of the record at IX into A - From a plan script's ASK (+1 = $FF)?
B94C CP $FF Compare A with $FF
B94E JR Z,$B98C If A equals $FF, jump on to the routine "Take the command out of an ASK order" (B98C)
B950 LD A,($B935) Read B935 in "The actor an order is for (two copies)" into A - Words the player said: whom they are for
B953 LD ($B934),A Store A in "The actor an order is for (two copies)" (B934)
B956 LD A,(IX+$02) Read byte +2 of the record at IX into A - The ALL flag and the ALL search position, kept in the order
B959 LD ($A01C),A Store A in $A01C in "Game variables"
B95C LD C,(IX+$03) Read byte +3 of the record at IX into C
B95F LD B,(IX+$04) Read byte +4 of the record at IX into B
B962 LD ($B17E),BC Store BC in $B17E in "Parser variables"
B966 CALL $B191 Call the routine "Match the typed command against the verb patterns" (B191) - Parse the order's current sentence for this actor (B191)
B969 JR Z,$B9B4 If the zero flag is set, jump on to B9B4
B96B LD IX,($B866) Read "Speech hand-over variables" (B866) into IX - Parsed: keep the ALL position and flag
B96F LD BC,($B17E) Read $B17E in "Parser variables" into BC
B973 LD (IX+$03),C Store C in byte +3 of the record at IX
B976 LD (IX+$04),B Store B in byte +4 of the record at IX
B979 LD A,($A01C) Read $A01C in "Game variables" into A
B97C LD (IX+$02),A Store A in byte +2 of the record at IX
B97F AND A Test A for zero (this leaves A as it was and clears carry) - Not an ALL: drop the sentence (B9CA)
B980 CALL Z,$B9CA If A is zero, call B9CA (inside "Take the command out of an ASK order")
This entry point is used by the routine at B98C.
B983 LD A,$01 Load A with $01 - NZ: there is a command to carry out
This entry point is used by the routine at B98C.
B985 POP HL Restore HL from the stack
B986 POP IY Restore IY from the stack
B988 POP IX Restore IX from the stack
B98A AND A Clear the carry flag for the caller (A is unchanged)
B98B RET Return to the caller
Prev: B934 Up: Map Next: B98C