Prev: 24664 Up: Map Next: 24875
24692: 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. 127 ends the table.
The ordinary command scripts live at CommandScripts and are marked by a clear script-set flag.
RunScripts 24692 LD HL,39508 Point at the ordinary scripts at CommandScripts.
24695 XOR A Write 0 to ScriptSet.
24696 LD (23446),A
This entry point is used by the routine at RunPriorityScripts.
Walk one script line.
RunScripts_Line 24699 PUSH HL Keep the line pointer in DE while HL walks it.
24700 POP DE
24701 XOR A No line has matched yet, and no condition has failed.
24702 LD (23417),A
24705 LD (24266),A
Test the verb and noun.
24708 CALL MatchCommand Call MatchCommand.
24711 JR RunScripts_Next Jump to RunScripts_Next.
This line failed.
RunScripts_Failed 24713 XOR A Write 0 to ConditionFailed.
24714 LD (24266),A
Skip the rest of this line.
24717 CALL SkipLine Call SkipLine.
Advance to the next line.
RunScripts_Next 24720 LD A,H Return at the 127 end marker.
24721 OR L
24722 RET Z
24723 BIT 7,(HL) Bit 7 on the current byte starts the actions.
24725 JR NZ,RunScripts_Matched
A condition byte, shifted, picks a routine from 26571. The object byte in front of it is looked up in ObjectLocations.
RunScripts_Condition 24727 LD A,(HL) Fetch the condition number.
24728 SLA A Double it so it indexes a word.
24730 LD IX,26571 Point IX at 26571.
24734 LD C,A Index by the condition number.
24735 LD B,0
24737 ADD IX,BC
24739 LD A,(IX+0) Plant that routine over the call at 24770.
24742 LD (24770),A
24745 LD A,(IX+1)
24748 LD (24771),A
24751 PUSH HL Stash the line pointer on the stack.
24752 INC HL Advance to the object number.
24753 LD A,(HL) Fetch it into C.
24754 LD C,A
24755 LD IX,24010 Point IX at ObjectLocations.
24759 ADD IX,BC Add the object number.
24761 LD B,A Keep the object number.
24762 LD A,(IX+0) Fetch that object's location into C.
24765 LD C,A
24766 INC HL Advance to the parameter.
24767 LD A,(HL) Fetch it.
24768 PUSH DE Stash DE on the stack.
24769 CALL 6 Call the planted condition routine.
24772 POP DE Restore DE and HL from the stack.
24773 POP HL
24774 CALL SkipCondition Call SkipCondition.
24777 LD A,(24266) A failure skips the rest of this line.
24780 OR A
24781 JR NZ,RunScripts_Failed
24783 BIT 7,(HL) Otherwise keep testing while bit 7 is clear.
24785 JR Z,RunScripts_Condition
The line matched. Remember that, and perform each action until one asks to stop.
RunScripts_Matched 24787 LD A,1 Write 1 to *ScriptMatched.
24789 LD (23417),A
Perform the next action.
RunScripts_NextAction 24792 LD A,(23430) Jump to RunScripts_Action if *WordSlot is zero.
24795 OR A
24796 JR Z,RunScripts_Action
24798 XOR A The first matched line of a command clears WordSlot.
24799 LD (23430),A
Decode this action.
RunScripts_Action 24802 BIT 6,(HL) Jump to RunScripts_Do if bit 6 is clear.
24804 JR Z,RunScripts_Do
24806 LD A,1 Write 1 to ConditionFailed.
24808 LD (24266),A
Call the action.
RunScripts_Do 24811 LD A,(HL) Fetch the action byte.
24812 AND %00111111 Keep only bits 0-5.
24814 SLA A Double the action number.
24816 LD IX,27349 Point IX at the word inside 27348. Action 0 is the beeper operand, and the routines start at ActionTable.
24820 LD C,A Index by the action number.
24821 LD B,0
24823 ADD IX,BC
24825 LD A,(IX+0) Plant that routine over the call at 24856.
24828 LD (24856),A
24831 LD A,(IX+1)
24834 LD (24857),A
24837 PUSH HL Stash the line pointer on the stack.
24838 INC HL Advance to the object number.
24839 LD A,(HL) Fetch it.
24840 LD IX,24010 Point IX at ObjectLocations.
24844 LD C,A Copy the object number into C.
24845 ADD IX,BC Add it.
24847 LD B,A Keep the object number.
24848 LD A,(IX+0) Fetch that object's location into C.
24851 LD C,A
24852 INC HL Advance to the parameter.
24853 LD A,(HL) Fetch it.
24854 PUSH DE Stash DE on the stack.
24855 CALL 6 Call the patched action.
24858 POP DE Restore the line pointer and the table pointer.
24859 POP HL
24860 CALL SkipAction Call SkipAction.
24863 LD A,(24266) Stop the table when the action raised ConditionFailed.
24866 OR A
24867 RET NZ
24868 BIT 7,(HL) Bit 7 continues this line's next action.
24870 JR NZ,RunScripts_NextAction
Start the next line.
24872 JP RunScripts_Failed Jump to RunScripts_Failed.
Prev: 24664 Up: Map Next: 24875