| The Hobbit (v1.0) | Routines |
| Prev: 9873 | Up: Map | Next: 98CF |
|
Carries out an action instruction from a character's behaviour program. Normally the three bytes after the instruction byte give the action, the target and the instruction (B5D8-B5DA) and 9921 tries it. If bit 0 of the instruction byte is set, the next two bytes are the address of a special routine, which is called first as a dry run and, if it says it would work, for real.
If the action worked, and the instruction has a jump address (bit 4), the program jumps there. If bit 5 is set the instruction is erased so it will not be done again.
|
||||
| 9883 | CALL $9873 | Move the program pointer past this instruction (and its failure address, if any) | ||
| 9886 | BIT 0,(IX+$00) | Is it a call to a special routine (bit 0)? | ||
| 988A | JR NZ,$98A5 | Yes | ||
| 988C | LD A,(IX+$01) | The action... | ||
| 988F | LD ($B5D8),A | |||
| 9892 | LD A,(IX+$02) | ...the target... | ||
| 9895 | LD ($B5D9),A | |||
| 9898 | LD A,(IX+$03) | ...and the instrument | ||
| 989B | LD ($B5DA),A | |||
| 989E | CALL $9921 | Try it | ||
| 98A1 | JR Z,$9905 | It failed | ||
| 98A3 | JR $98C2 | It worked | ||
| 98A5 | LD L,(IX+$01) | HL = the special routine | ||
| 98A8 | LD H,(IX+$02) | |||
| 98AB | SUB A | Run it first as a dry run: "really do it" off... | ||
| 98AC | LD ($B5EB),A | |||
| 98AF | LD ($B5EC),A | ...and "would work" off | ||
| 98B2 | CALL $9AC7 | |||
| 98B5 | LD A,($B5EC) | Did it say it would work? | ||
| 98B8 | CP $01 | |||
| 98BA | JR NZ,$9905 | No: it failed | ||
| 98BC | LD ($B5EB),A | Yes: run it again for real | ||
| 98BF | CALL $9AC7 | |||
| 98C2 | BIT 5,(IX+$00) | Success. Is this a once-only instruction (bit 5)? | ||
| 98C6 | JP Z,$985C | No: this character's turn is over | ||
| 98C9 | LD (IX+$00),$00 | Yes: wipe out its instruction byte | ||
| 98CD | JR $985C | Turn over | ||
| Prev: 9873 | Up: Map | Next: 98CF |