Sherlock: annotated disassembly

Routines

Prev: E3A9 Up: Map Next: E3EA
E3B8: Pre-check for getting into a cab
Named in the header of the shared GET INTO action at E3EA. Runs E3F5 first (busy? already there? will you fit?); then, for a moment taking the next number after the cab (its driver) as the actor, asks CFB6, and if that says yes requires the thing at the cab's +3 and the actor to share one of bits 4-6 of +4, refusing (DC15) otherwise.
How it works:
1. Run the checks for sitting on or getting into things (E3F5: not busy, not already in it, will it fit).
2. With the actor temporarily the thing after the cab (its driver), see whether the driver has a step in progress (CFB6).
3. If so, the thing at the cab's +3 and the actor must share one of bits 4 to 6 of +4, or the move is refused.
Input
$A034 The cab
Output
F NZ if the actor may get in; Z or $DC15 if not
E3B8 CALL $E3F5 Call the routine "Pre-check for sitting on or getting into something" (E3F5) - The common checks (E3F5): busy, already there, will it fit?
E3BB RET Z If the zero flag is set, return
E3BC LD A,($A036) Read $A036 in "Game variables" into A - Keep the actor, and take the thing after the cab (its driver) as the actor...
E3BF PUSH AF Save AF on the stack
E3C0 LD A,($A034) Read $A034 in "Game variables" into A
E3C3 INC A Add one to A
E3C4 LD ($A036),A Store A in $A036 in "Game variables"
E3C7 CALL $CFB6 Call CFB6 (inside "Save a sub-script call frame") - ...and ask CFB6 (Z: no)
E3CA EX AF,AF' Swap AF with the shadow copy
E3CB POP AF Restore AF from the stack
E3CC LD ($A036),A Store A in $A036 in "Game variables" - Actor restored
E3CF EX AF,AF' Swap AF with the shadow copy
E3D0 JR Z,$E3E7 No driver step: allowed
E3D2 LD A,(IX+$03) Read byte +3 of the record at IX into A - The thing at the cab's +3 (D237)...
E3D5 CALL $D237 Call the routine "Resolve an id (in A) to its full entity record" (D237)
E3D8 LD IY,($A017) Read $A017 in "Game variables" into IY
E3DC LD A,(IX+$04) Read byte +4 of the record at IX into A - ...must share one of bits 4-6 with the actor's +4 (the AND with $70)
E3DF AND (IY+$04) Keep only the bits of A that are set in byte +4 of the record at IY
E3E2 AND $70 Keep only bits 4, 5, 6 of A (mask $70)
E3E4 JP Z,$DC15 Otherwise refuse (DC15)
E3E7 OR $01 Make A non-zero, which clears the zero flag, and hand that back to the caller - Succeed
E3E9 RET Return to the caller
Prev: E3A9 Up: Map Next: E3EA