| The Hobbit (v1.0) | Routines |
| Prev: 84DE | Up: Map | Next: 8554 |
|
Used when a character is deciding what to do (976C): works out, for the action in B5D8 and the objects in $B5D9 and B5DA, whether the action would succeed, without printing anything and without disturbing the player's command. The work area pointer at $833F is saved and restored. Returns with Z set if the action would not work.
|
||||
| 84E6 | PUSH HL | Save every register this uses | ||
| 84E7 | PUSH IY | |||
| 84E9 | PUSH IX | |||
| 84EB | PUSH DE | |||
| 84EC | PUSH BC | |||
| 84ED | LD HL,($833F) | Save where the player's own target search had got to | ||
| 84F0 | PUSH HL | |||
| 84F1 | LD A,($B5D8) | IX = the action table entry for the action being tried | ||
| 84F4 | CALL $70DF | |||
| 84F7 | PUSH HL | |||
| 84F8 | POP IX | |||
| 84FA | CALL $839A | Clear the work area | ||
| 84FD | CALL $70EA | Work out this action's own flag bytes | ||
| 8500 | CALL $8569 | Decode them | ||
| 8503 | LD A,($B5D9) | A = the target the character wants to try | ||
| 8506 | LD B,A | |||
| 8507 | LD A,($B5EF) | Copy its words into the target work area, as if it had been typed | ||
| 850A | LD DE,$8333 | |||
| 850D | CALL $8554 | |||
| 8510 | LD A,($B5DA) | Do the same for the instrument | ||
| 8513 | LD B,A | |||
| 8514 | LD A,($B5F0) | |||
| 8517 | LD DE,$8339 | |||
| 851A | CALL $8554 | |||
| 851D | CALL $8497 | Start the object search fresh, in case a room search is needed instead | ||
| 8520 | XOR A | For now, this is only a trial | ||
| 8521 | LD ($B5EB),A | |||
| 8524 | LD A,($B60D) | Does the action need a target or an instrument at all? | ||
| 8527 | AND $0C | |||
| 8529 | JR NZ,$8534 | It does: check it properly below | ||
| 852B | CALL $946F | It needs neither: just try it directly | ||
| 852E | LD A,($B5EC) | |||
| 8531 | AND A | |||
| 8532 | JR $8543 | |||
| 8534 | LD A,$01 | It does need objects: only accept a single, unambiguous match | ||
| 8536 | LD ($8344),A | |||
| 8539 | CALL $8405 | Search for a workable target and instrument | ||
| 853C | JR Z,$8541 | Found: success | ||
| 853E | XOR A | Not found: failure | ||
| 853F | JR $8543 | |||
| 8541 | OR $01 | |||
| 8543 | LD A,$01 | Whatever the player was doing, it really is happening again now | ||
| 8545 | LD ($B5EB),A | |||
| 8548 | POP HL | Restore the player's own target-search position... | ||
| 8549 | LD ($833F),HL | |||
| 854C | POP BC | ...and every other saved register | ||
| 854D | POP DE | |||
| 854E | POP IX | |||
| 8550 | POP IY | |||
| 8552 | POP HL | |||
| 8553 | RET | |||
| Prev: 84DE | Up: Map | Next: 8554 |