Sherlock: annotated disassembly

Routines

Prev: CD24 Up: Map Next: CD82
CD47: Plan opcode 9, AWAIT: wait for a token from another actor
Looks along the 9FE7 list for a node left by the actor named in the argument for this actor. Fails if there is none (scripts give AWAIT a failure address pointing at itself, so the actor waits); otherwise unlinks the node, frees it and succeeds.
Input
IX The instruction (+1 the actor the token must come from)
Output
The step succeeds if the token was there (and is removed), otherwise it fails
CD47 LD B,(IX+$01) B = who the token must come from
CD4A LD IX,$9FE9 Point IX at sub-script call frames (9FE9) - Walk the token list
CD4E CALL $A0F7 Call the routine "Move IX to the next node of a list" (A0F7)
CD51 JP Z,$CEB8 None left: fail
CD54 LD A,($A036) Read $A036 in "Game variables" into A - Is this token for this actor...
CD57 CP (IX+$01) Compare A with byte +1 of the record at IX
CD5A JR NZ,$CD4E If A differs from byte +1 of the record at IX, go back to CD4E
CD5C LD A,B Copy B into A - ...and from that actor?
CD5D CP (IX+$00) Compare A with the first byte of the record at IX
CD60 JR NZ,$CD4E If A differs from the first byte of the record at IX, go back to CD4E
CD62 PUSH IY Save IY on the stack - Yes: unlink it...
CD64 PUSH IX Save IX on the stack
CD66 POP DE Restore DE from the stack
CD67 LD IY,$9FE7 Point IY at SIGNAL tokens (9FE7)
CD6B CALL $A104 Call the routine "Find the node before node DE in the list at IY" (A104)
CD6E LD L,(IX-$02) Read byte -2 of the record at IX into L
CD71 LD H,(IX-$01) Read byte -1 of the record at IX into H
CD74 LD (IY-$02),L Store L in byte -2 of the record at IY
CD77 LD (IY-$01),H Store H in byte -1 of the record at IY
CD7A CALL $A1C7 Call the routine "Free node IX back to the heap" (A1C7) - ...and free it
CD7D POP IY Restore IY from the stack
CD7F JP $CE8F Succeed
Prev: CD24 Up: Map Next: CD82