Prev: 6058 Up: Map Next: 612B
6074: Run Script Table
Used by the routine at ObeyCommand.
Walks a bytecode table. A line whose verb and noun match is executed; a failed condition or a bit-6 action stops the line. 7F ends the table.
The ordinary command scripts live at CommandScripts and are marked by a clear script-set flag.
RunScripts 6074 LD HL,$9A54 Point at the ordinary scripts at CommandScripts.
6077 XOR A Write 00 to ScriptSet.
6078 LD ($5B96),A
This entry point is used by the routine at RunPriorityScripts.
Walk one script line.
RunScripts_Line 607B PUSH HL Keep the line pointer in DE while HL walks it.
607C POP DE
607D XOR A No line has matched yet, and no condition has failed.
607E LD ($5B79),A
6081 LD ($5ECA),A
Test the verb and noun.
6084 CALL MatchCommand Call MatchCommand.
6087 JR RunScripts_Next Jump to RunScripts_Next.
This line failed.
RunScripts_Failed 6089 XOR A Write 00 to ConditionFailed.
608A LD ($5ECA),A
Skip the rest of this line.
608D CALL SkipLine Call SkipLine.
Advance to the next line.
RunScripts_Next 6090 LD A,H Return at the 7F end marker.
6091 OR L
6092 RET Z
6093 BIT 7,(HL) Bit 7 on the current byte starts the actions.
6095 JR NZ,RunScripts_Matched
A condition byte, shifted, picks a routine from 67CB. The object byte in front of it is looked up in ObjectLocations.
RunScripts_Condition 6097 LD A,(HL) Fetch the condition number.
6098 SLA A Double it so it indexes a word.
609A LD IX,$67CB Point IX at 67CB.
609E LD C,A Index by the condition number.
609F LD B,$00
60A1 ADD IX,BC
60A3 LD A,(IX+$00) Plant that routine over the call at 60C2.
60A6 LD ($60C2),A
60A9 LD A,(IX+$01)
60AC LD ($60C3),A
60AF PUSH HL Stash the line pointer on the stack.
60B0 INC HL Advance to the object number.
60B1 LD A,(HL) Fetch it into C.
60B2 LD C,A
60B3 LD IX,$5DCA Point IX at ObjectLocations.
60B7 ADD IX,BC Add the object number.
60B9 LD B,A Keep the object number.
60BA LD A,(IX+$00) Fetch that object's location into C.
60BD LD C,A
60BE INC HL Advance to the parameter.
60BF LD A,(HL) Fetch it.
60C0 PUSH DE Stash DE on the stack.
60C1 CALL $0006 Call the planted condition routine.
60C4 POP DE Restore DE and HL from the stack.
60C5 POP HL
60C6 CALL SkipCondition Call SkipCondition.
60C9 LD A,($5ECA) A failure skips the rest of this line.
60CC OR A
60CD JR NZ,RunScripts_Failed
60CF BIT 7,(HL) Otherwise keep testing while bit 7 is clear.
60D1 JR Z,RunScripts_Condition
The line matched. Remember that, and perform each action until one asks to stop.
RunScripts_Matched 60D3 LD A,$01 Write 01 to *ScriptMatched.
60D5 LD ($5B79),A
Perform the next action.
RunScripts_NextAction 60D8 LD A,($5B86) Jump to RunScripts_Action if *WordSlot is zero.
60DB OR A
60DC JR Z,RunScripts_Action
60DE XOR A The first matched line of a command clears WordSlot.
60DF LD ($5B86),A
Decode this action.
RunScripts_Action 60E2 BIT 6,(HL) Jump to RunScripts_Do if bit 6 is clear.
60E4 JR Z,RunScripts_Do
60E6 LD A,$01 Write 01 to ConditionFailed.
60E8 LD ($5ECA),A
Call the action.
RunScripts_Do 60EB LD A,(HL) Fetch the action byte.
60EC AND %00111111 Keep only bits 0-5.
60EE SLA A Double the action number.
60F0 LD IX,$6AD5 Point IX at the word inside 6AD4. Action 0 is the beeper operand, and the routines start at ActionTable.
60F4 LD C,A Index by the action number.
60F5 LD B,$00
60F7 ADD IX,BC
60F9 LD A,(IX+$00) Plant that routine over the call at 6118.
60FC LD ($6118),A
60FF LD A,(IX+$01)
6102 LD ($6119),A
6105 PUSH HL Stash the line pointer on the stack.
6106 INC HL Advance to the object number.
6107 LD A,(HL) Fetch it.
6108 LD IX,$5DCA Point IX at ObjectLocations.
610C LD C,A Copy the object number into C.
610D ADD IX,BC Add it.
610F LD B,A Keep the object number.
6110 LD A,(IX+$00) Fetch that object's location into C.
6113 LD C,A
6114 INC HL Advance to the parameter.
6115 LD A,(HL) Fetch it.
6116 PUSH DE Stash DE on the stack.
6117 CALL $0006 Call the patched action.
611A POP DE Restore the line pointer and the table pointer.
611B POP HL
611C CALL SkipAction Call SkipAction.
611F LD A,($5ECA) Stop the table when the action raised ConditionFailed.
6122 OR A
6123 RET NZ
6124 BIT 7,(HL) Bit 7 continues this line's next action.
6126 JR NZ,RunScripts_NextAction
Start the next line.
6128 JP RunScripts_Failed Jump to RunScripts_Failed.
Prev: 6058 Up: Map Next: 612B