Sherlock: annotated disassembly

Routines

Prev: CC29 Up: Map Next: CC78
CC37: Start an actor's turn
On failure to resolve the id, clears $A01F and returns early instead.
How it works:
1. Clear the failure count (CC0B). Find the actor's record (CC0E); if there is none, make the action take 1 minute and stop.
2. Keep the record address (9FDB) and the actor ($A036), and note whether an order or remark is waiting (B91F).
3. Set up the actor (CC29) and note the player's room (D045).
4. Switch output on only when the player can see the actor (C821). Clear $A01F.
Input
A The actor number
Output
$A01F 0 (or 1 if the actor is not in the table)
IY The actor's record
$A036 The actor
$5C3C Output on only when the actor is seen by the player
CC37 PUSH AF Save AF on the stack - Clear the failure count (CC0B)
CC38 XOR A Clear A to zero (and the carry flag)
CC39 LD ($CC0B),A Store A in "Bytes for the actor's turn (CC37)" (CC0B)
CC3C POP AF Restore AF from the stack
CC3D CALL $CC0E Find the actor's record (CC0E)
CC40 CP $FF Compare A with $FF - Not found: $A01F = 1 and return
CC42 LD HL,$0001 Load HL with $0001
CC45 JP Z,$CC74 If A equals $FF, jump on to CC74
CC48 LD ($9FDB),IY Store IY in the current actor's (9FDB) - Save the record address and the actor's id
CC4C LD ($A036),A Store A in $A036 in "Game variables"
CC4F CALL $B91F Call the routine "Is an order or a remark waiting for the current actor?" (B91F) - $CC0D = 1 if an order or remark is waiting for it (B91F), 0 if not
CC52 LD A,$00 Load A with $00
CC54 JR NZ,$CC57 If the zero flag is clear, skip ahead to CC57
CC56 INC A Add one to A
CC57 LD ($CC0D),A Store A in $CC0D in "Bytes for the actor's turn (CC37)"
This entry point is used by the routine at CC78.
CC5A CALL $CC29 Call the routine "Set up the current actor: its record and room" (CC29) - Set the actor up as the subject (CC29, D045)
CC5D CALL $D045 Call the routine "Note the room the player is in ($A009)" (D045)
CC60 SUB A Clear A to zero - Output off ($5C3C = 0)...
CC61 LD ($5C3C),A Store A in the output-switch byte (TV_FLAG) ($5C3C)
CC64 LD A,($9860) Read "The actor table: who acts, and where each is in..." (9860) into A - ...unless the actor is where the player is (C821)
CC67 CALL $C821 Call the routine "Can the current actor ($A036) see thing A?" (C821)
CC6A JR Z,$CC71 If the zero flag is set, skip ahead to CC71
CC6C LD A,$01 Load A with $01
CC6E LD ($5C3C),A Store A in the output-switch byte (TV_FLAG) ($5C3C)
CC71 LD HL,$0000 Load HL with $0000 - $A01F = 0
CC74 LD ($A01F),HL Store HL in $A01F in "Game variables"
CC77 RET Return to the caller
Prev: CC29 Up: Map Next: CC78