Sherlock: annotated disassembly

Routines

Prev: CB41 Up: Map Next: CB79
CB43: End of an actor's go: hand the turn back to the player
Reached from $C9A2. Unless DC6C says otherwise, makes the first actor in the table (9860, the player) current again; when $A00B is set, either clears $A00C and narrates (CA76) or - with HL not zero - calls HL with $A027 set (CB40).
How it works:
1. If the actor is the player, Watson or the police cab (actors 0, 1 or $64), do nothing.
2. Otherwise note a failure ($A00B): either call the failure routine given in HL or narrate that the action failed (CA76).
3. Make the player the current actor again.
Input
HL The failure routine to call, or 0
Output
A 0
F Z
$A036 The player again
CB43 PUSH HL Save HL on the stack - Is the current actor 0, 1 or $64 (DC6C: Z if so)? NZ (anyone else): nothing to do
CB44 CALL $DC6C Call DC6C (inside "Action record: default for verb 28 (GO...")
CB47 POP HL Restore HL from the stack
CB48 JR NZ,$CB65 If the zero flag is clear, skip ahead to CB65
CB4A XOR A Clear A to zero (and the carry flag) - No current actor for a moment
CB4B LD ($A036),A Store A in $A036 in "Game variables"
CB4E LD A,($A00B) Read $A00B in "Game variables" into A - A failure ($A00B) to report? If not, skip to the hand-back
CB51 AND A Test A for zero (this leaves A as it was and clears carry)
CB52 JR Z,$CB5F If A is zero, skip ahead to CB5F
CB54 LD A,L Copy L into A - HL = a routine to call: none, so narrate the failure ($A00C = 0, CA76)
CB55 OR H Set in A the bits that are set in H
CB56 JR NZ,$CB67 If the result is not zero, skip ahead to CB67
This entry point is used by the routine at CB7B.
CB58 XOR A Clear A to zero (and the carry flag)
CB59 LD ($A00C),A Store A in $A00C in "Game variables"
CB5C CALL $CA76 Call the routine "Narrate the action, unless the verb is script-only" (CA76)
CB5F LD A,($9860) Read "The actor table: who acts, and where each is in..." (9860) into A - Make the first actor in the table (9860, the player) current again
CB62 LD ($A036),A Store A in $A036 in "Game variables"
CB65 XOR A Set A to zero, which sets the zero flag for the caller
CB66 RET Return to the caller
CB67 LD A,$01 Load A with $01 - A routine to call: with $A027 = 1, call it (CB40), then $A027 = 0
CB69 LD ($A027),A Store A in $A027 in "Game variables"
CB6C PUSH IY Save IY on the stack
CB6E CALL $CB40 Call the routine "Jump to HL" (CB40)
CB71 POP IY Restore IY from the stack
CB73 XOR A Clear A to zero (and the carry flag)
CB74 LD ($A027),A Store A in $A027 in "Game variables"
CB77 JR $CB5F Go back to CB5F
Prev: CB41 Up: Map Next: CB79