Sherlock: annotated disassembly

Routines

Prev: E2C7 Up: Map Next: E31C
E2EE: Start actor A on the script at DE, with objects B and C
$A034 = B and $A035 = C; with A as the current actor (CC0E) the script is pushed as its plan (CF80, B = 2) and its script position (+1/+2 of its actor-table entry) set to DE. The HAIL action (E2C7) uses it with DE = F2B6 to set the cab and cabbie off.
Input
A The actor
DE The script
B, C The two objects
Output
F NZ; the actor's old script is kept as a sub-script and the new one started
E2EE PUSH DE Save DE on the stack - A = the actor, DE = the script, B and C = the objects
E2EF LD D,A Copy A into D
E2F0 LD A,B Copy B into A
E2F1 LD ($A034),A Store A in $A034 in "Game variables" - Direct and indirect objects ($A034, $A035)
E2F4 LD A,C Copy C into A
E2F5 LD ($A035),A Store A in $A035 in "Game variables"
E2F8 LD A,($A036) Read $A036 in "Game variables" into A - Keep the current actor and make A the actor
E2FB PUSH AF Save AF on the stack
E2FC LD A,D Copy D into A
E2FD LD ($A036),A Store A in $A036 in "Game variables"
E300 CALL $CC0E Find its record (CC0E, IY)
E303 LD L,(IY+$01) Read byte +1 of the record at IY into L - HL = its current script address (+1/+2)
E306 LD H,(IY+$02) Read byte +2 of the record at IY into H
E309 LD B,$02 Load B with $02 - Push it as a sub-script call frame (CF80), so the actor returns to it afterwards
E30B CALL $CF80 Call the routine "Save a sub-script call frame" (CF80)
E30E POP AF Restore AF from the stack - Actor back as it was
E30F LD ($A036),A Store A in $A036 in "Game variables"
E312 POP DE Restore DE from the stack
E313 LD (IY+$01),E Store E in byte +1 of the record at IY - Point the actor's record at DE: its new script
E316 LD (IY+$02),D Store D in byte +2 of the record at IY
E319 OR $01 Make A non-zero, which clears the zero flag, and hand that back to the caller - Succeed
E31B RET Return to the caller
Prev: E2C7 Up: Map Next: E31C