![]() |
Routines |
| Prev: 24664 | Up: Map | Next: 24875 |
|
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 | Select the ordinary scripts. The high-priority entry joins here. | |
| 24695 | XOR A | |||
| 24696 | LD (23446),A | |||
|
This entry point is used by the routine at RunPriorityScripts.
|
||||
| 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 | |||
| 24708 | CALL MatchCommand | Call MatchCommand to test the verb and noun. | ||
| 24711 | JR RunScripts_Next | The next byte is a condition or an action. | ||
| RunScripts_Failed | 24713 | XOR A | A failed line is abandoned and the next one is tried. | |
| 24714 | LD (24266),A | |||
| 24717 | CALL SkipLine | |||
| 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) | Shift the condition number so it indexes a word. | |
| 24728 | SLA A | |||
| 24730 | LD IX,26571 | Index the condition table at 26571. | ||
| 24734 | LD C,A | |||
| 24735 | LD B,0 | |||
| 24737 | ADD IX,BC | |||
| 24739 | LD A,(IX+0) | Plant that routine over the call at 24769. | ||
| 24742 | LD (24770),A | |||
| 24745 | LD A,(IX+1) | |||
| 24748 | LD (24771),A | |||
| 24751 | PUSH HL | The next bytecode byte is the object number. | ||
| 24752 | INC HL | |||
| 24753 | LD A,(HL) | |||
| 24754 | LD C,A | |||
| 24755 | LD IX,24010 | Point at that object's location in ObjectLocations. | ||
| 24759 | ADD IX,BC | |||
| 24761 | LD B,A | The location itself is what the condition compares. | ||
| 24762 | LD A,(IX+0) | |||
| 24765 | LD C,A | |||
| 24766 | INC HL | The byte after the object is the condition's parameter. | ||
| 24767 | LD A,(HL) | |||
| 24768 | PUSH DE | |||
| 24769 | CALL 6 | The condition routine returns normally when it passes, or sets ConditionFailed when it fails. | ||
| 24772 | POP DE | |||
| 24773 | POP HL | |||
| 24774 | 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 | Remember that a line matched. | |
| 24789 | LD (23417),A | |||
| RunScripts_NextAction | 24792 | LD A,(23430) | The word slot is clear, so nothing to forget. | |
| 24795 | OR A | |||
| 24796 | JR Z,RunScripts_Action | |||
| 24798 | XOR A | The first matched line of a command clears WordSlot. | ||
| 24799 | LD (23430),A | |||
| RunScripts_Action | 24802 | BIT 6,(HL) | Bit 6 asks the runner to stop after this action. | |
| 24804 | JR Z,RunScripts_Do | |||
| 24806 | LD A,1 | |||
| 24808 | LD (24266),A | |||
| RunScripts_Do | 24811 | LD A,(HL) | Keep the action number in the low six bits and double it. | |
| 24812 | AND 63 | |||
| 24814 | SLA A | |||
| 24816 | LD IX,27349 | Index from the word inside 27348. Action 0 is the beeper operand; the routines start at ActionTable. | ||
| 24820 | LD C,A | |||
| 24821 | LD B,0 | |||
| 24823 | ADD IX,BC | |||
| 24825 | LD A,(IX+0) | Plant that routine over the call at 24855. | ||
| 24828 | LD (24856),A | |||
| 24831 | LD A,(IX+1) | |||
| 24834 | LD (24857),A | |||
| 24837 | PUSH HL | The next bytecode byte is the object number. | ||
| 24838 | INC HL | |||
| 24839 | LD A,(HL) | |||
| 24840 | LD IX,24010 | Point at that object's location in ObjectLocations. | ||
| 24844 | LD C,A | |||
| 24845 | ADD IX,BC | |||
| 24847 | LD B,A | The location itself is passed to the action. | ||
| 24848 | LD A,(IX+0) | |||
| 24851 | LD C,A | |||
| 24852 | INC HL | The byte after the object is the action's parameter. | ||
| 24853 | LD A,(HL) | |||
| 24854 | PUSH DE | |||
| 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 to step past the action. | ||
| 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 | |||
| 24872 | JP RunScripts_Failed | Jump to RunScripts_Failed to start the next line. | ||
| Prev: 24664 | Up: Map | Next: 24875 |