| The Hobbit (v1.0) | Routines |
| Prev: 9D12 | Up: Map | Next: 9D77 |
|
Continues a search of the object index (from IX) for an object whose words match the noun and adjectives at HL (71EA). The object must also match the filter in $B600: 0 for things that are not characters, 1 for characters, 2 for anything. Unless $B5FF says reach does not matter, the object must also be in the same place as the actor (9D86). Returns the object in A, or $FF when there are no more.
|
||||
| 9D2E | PUSH BC | Save the caller's BC, DE and IY | ||
| 9D2F | PUSH DE | |||
| 9D30 | PUSH IY | |||
| 9D32 | LD IY,($B5FC) | IY = the current actor's own record | ||
| 9D36 | LD D,(IY+$10) | D = the actor's room, in case the object must be close by to count | ||
| 9D39 | LD A,($B600) | A = the filter the caller wants: 0 things that are not characters, 1 characters, 2 anything at all | ||
| 9D3C | LD E,A | E = that filter, kept for the tests below | ||
| 9D3D | CALL $9AEE | Look at the next entry of the object index; A = its object number, Z set once we run out | ||
| 9D40 | JR Z,$9D6F | No more objects: give up (A is left holding $FF) | ||
| 9D42 | LD A,$02 | Does the caller want absolutely anything (filter 2)? | ||
| 9D44 | CP E | |||
| 9D45 | JR Z,$9D56 | Yes: skip the character/object test below entirely | ||
| 9D47 | LD A,(IY+$07) | No: A = this object's flags | ||
| 9D4A | AND $48 | Keep only whether it is alive and whether it is dead | ||
| 9D4C | CP $40 | Is it alive and NOT dead, i.e. a proper living character? | ||
| 9D4E | LD A,$00 | Assume it is not a character (0)... | ||
| 9D50 | JR NZ,$9D53 | ...unless it just proved to be alive and undead, in which case... | ||
| 9D52 | INC A | ...it counts as a character (1) | ||
| 9D53 | CP E | Does that match what the caller asked for? | ||
| 9D54 | JR NZ,$9D3D | No: try the next object | ||
| 9D56 | LD BC,$0008 | BC = 8: the offset, from the start of an object's record, to its own four word slots | ||
| 9D59 | PUSH IY | Save IY (the object's record) for a moment | ||
| 9D5B | ADD IY,BC | IY = the object's word slots | ||
| 9D5D | CALL $71EA | Do the noun and adjectives at HL match this object's own words? | ||
| 9D60 | POP IY | Restore IY, the object's record | ||
| 9D62 | JR NZ,$9D3D | No match: try the next object | ||
| 9D64 | LD A,($B5FF) | A match on words. Does this particular action not care whether the object is within reach? | ||
| 9D67 | AND A | |||
| 9D68 | JR NZ,$9D6F | It does not care: accept this object regardless of where it is | ||
| 9D6A | CALL $9D86 | It does care: is the object near the actor? | ||
| 9D6D | JR Z,$9D3D | No: try the next object | ||
| 9D6F | LD A,(IX+$00) | A = the object we settled on (or $FF if we ran right out) | ||
| 9D72 | POP IY | Restore the caller's IY, DE and BC | ||
| 9D74 | POP DE | |||
| 9D75 | POP BC | |||
| 9D76 | RET | |||
| Prev: 9D12 | Up: Map | Next: 9D77 |