![]() |
Routines |
| Prev: 6058 | Up: Map | Next: 612B |
|
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 | Select the ordinary scripts. The high-priority entry joins here. | |
| 6077 | XOR A | |||
| 6078 | LD ($5B96),A | |||
|
This entry point is used by the routine at RunPriorityScripts.
|
||||
| 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 | |||
| 6084 | CALL MatchCommand | Call MatchCommand to test the verb and noun. | ||
| 6087 | JR RunScripts_Next | The next byte is a condition or an action. | ||
| RunScripts_Failed | 6089 | XOR A | A failed line is abandoned and the next one is tried. | |
| 608A | LD ($5ECA),A | |||
| 608D | CALL SkipLine | |||
| 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) | Shift the condition number so it indexes a word. | |
| 6098 | SLA A | |||
| 609A | LD IX,$67CB | Index the condition table at 67CB. | ||
| 609E | LD C,A | |||
| 609F | LD B,$00 | |||
| 60A1 | ADD IX,BC | |||
| 60A3 | LD A,(IX+$00) | Plant that routine over the call at 60C1. | ||
| 60A6 | LD ($60C2),A | |||
| 60A9 | LD A,(IX+$01) | |||
| 60AC | LD ($60C3),A | |||
| 60AF | PUSH HL | The next bytecode byte is the object number. | ||
| 60B0 | INC HL | |||
| 60B1 | LD A,(HL) | |||
| 60B2 | LD C,A | |||
| 60B3 | LD IX,$5DCA | Point at that object's location in ObjectLocations. | ||
| 60B7 | ADD IX,BC | |||
| 60B9 | LD B,A | The location itself is what the condition compares. | ||
| 60BA | LD A,(IX+$00) | |||
| 60BD | LD C,A | |||
| 60BE | INC HL | The byte after the object is the condition's parameter. | ||
| 60BF | LD A,(HL) | |||
| 60C0 | PUSH DE | |||
| 60C1 | CALL $0006 | The condition routine returns normally when it passes, or sets ConditionFailed when it fails. | ||
| 60C4 | POP DE | |||
| 60C5 | POP HL | |||
| 60C6 | 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 | Remember that a line matched. | |
| 60D5 | LD ($5B79),A | |||
| RunScripts_NextAction | 60D8 | LD A,($5B86) | The word slot is clear, so nothing to forget. | |
| 60DB | OR A | |||
| 60DC | JR Z,RunScripts_Action | |||
| 60DE | XOR A | The first matched line of a command clears WordSlot. | ||
| 60DF | LD ($5B86),A | |||
| RunScripts_Action | 60E2 | BIT 6,(HL) | Bit 6 asks the runner to stop after this action. | |
| 60E4 | JR Z,RunScripts_Do | |||
| 60E6 | LD A,$01 | |||
| 60E8 | LD ($5ECA),A | |||
| RunScripts_Do | 60EB | LD A,(HL) | Keep the action number in the low six bits and double it. | |
| 60EC | AND $3F | |||
| 60EE | SLA A | |||
| 60F0 | LD IX,$6AD5 | Index from the word inside 6AD4. Action 0 is the beeper operand; the routines start at ActionTable. | ||
| 60F4 | LD C,A | |||
| 60F5 | LD B,$00 | |||
| 60F7 | ADD IX,BC | |||
| 60F9 | LD A,(IX+$00) | Plant that routine over the call at 6117. | ||
| 60FC | LD ($6118),A | |||
| 60FF | LD A,(IX+$01) | |||
| 6102 | LD ($6119),A | |||
| 6105 | PUSH HL | The next bytecode byte is the object number. | ||
| 6106 | INC HL | |||
| 6107 | LD A,(HL) | |||
| 6108 | LD IX,$5DCA | Point at that object's location in ObjectLocations. | ||
| 610C | LD C,A | |||
| 610D | ADD IX,BC | |||
| 610F | LD B,A | The location itself is passed to the action. | ||
| 6110 | LD A,(IX+$00) | |||
| 6113 | LD C,A | |||
| 6114 | INC HL | The byte after the object is the action's parameter. | ||
| 6115 | LD A,(HL) | |||
| 6116 | PUSH DE | |||
| 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 to step past the action. | ||
| 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 | |||
| 6128 | JP RunScripts_Failed | Jump to RunScripts_Failed to start the next line. | ||
| Prev: 6058 | Up: Map | Next: 612B |