Sherlock: annotated disassembly

Routines

Prev: C989 Up: Map Next: C9BF
C996: Run a numbered action record; a script record becomes the actor's plan
Runs it through C9BF; with carry (a script) the record is started as the actor's plan (CF80, the actor's entry at 9FDB).
Input
HL An action record
Output
F Carry set if a script was started as the actor's plan; Z if refused; NZ if done
C996 PUSH IY Save IY on the stack - Try the action record in HL (C9BF)
C998 PUSH BC Save BC on the stack
C999 CALL $C9BF Call the routine "Run an action record (HL = the record)" (C9BF)
C99C POP BC Restore BC from the stack
C99D POP IY Restore IY from the stack
C99F JR C,$C9A7 Carry: it is a script record
C9A1 JP Z,$CB43 Z: failed - end the actor's go (CB43)
C9A4 OR $01 Make A non-zero, which clears the zero flag, and hand that back to the caller - NZ: done
C9A6 RET Return to the caller
C9A7 PUSH HL Save HL on the stack - Script record: save the actor's current script as a sub-script frame (CF80)...
C9A8 PUSH BC Save BC on the stack
C9A9 LD HL,($9FD9) Read the plan instruction (9FD9) into HL
C9AC LD B,$01 Load B with $01
C9AE CALL $CF80 Call the routine "Save a sub-script call frame" (CF80)
C9B1 POP BC Restore BC from the stack
C9B2 POP HL Restore HL from the stack
C9B3 LD IX,($9FDB) Read the current actor's (9FDB) into IX - ...and set the actor's script to the new one (HL, in +1/+2 of its record)
C9B7 LD (IX+$01),L Store L in byte +1 of the record at IX
C9BA LD (IX+$02),H Store H in byte +2 of the record at IX
C9BD SCF Set the carry flag for the caller - Carry: a script was started
C9BE RET Return to the caller
Prev: C989 Up: Map Next: C9BF