| The Hobbit (v1.0) | Routines |
| Prev: 9EF8 | Up: Map | Next: 9F89 |
|
Prints each visible object held by A (A=$FF for loose objects) that is in room B, one per line, each followed by a full stop. After each one, its contents are listed by a recursive call, indented two more characters (D, stored at $7692 for 7694), with a heading from 9F89 such as 'gandalf is carrying' or 'in the chest there is'. The actor's own possessions are not listed when looking round the room. C counts the objects printed.
|
||||
| 9F10 | PUSH HL | Save the caller's HL | ||
| 9F11 | LD L,A | L = the holder we are listing the contents of (or $FF for "lying loose") | ||
| 9F12 | LD A,($7692) | A = whatever indent is currently in use, from an earlier, outer call to this same routine | ||
| 9F15 | LD H,A | H = that old indent, kept alongside the holder in L for a moment | ||
| 9F16 | LD A,D | A = the new indent this call should use | ||
| 9F17 | LD ($7692),A | Set it as the printer's current indent | ||
| 9F1A | LD A,L | A = the holder again | ||
| 9F1B | EX (SP),HL | Swap: put (old indent, holder) safely on the stack, and get the real, original HL back | ||
| 9F1C | PUSH IX | Save the caller's IX | ||
| 9F1E | LD IX,$BF50 | IX = just before the start of the object index, so the search below starts at its very first entry | ||
| 9F22 | CALL $9B04 | Look at the next object; IY = its own record | ||
| 9F25 | JR Z,$9F7F | Have we run out of objects? | ||
| 9F27 | CP (IY+$01) | No: is this object held by the one we are listing the contents of? | ||
| 9F2A | JR NZ,$9F22 | It is not: try the next object | ||
| 9F2C | PUSH AF | It is: save this object's number for a moment | ||
| 9F2D | LD A,$01 | Does it occupy only a single place (not a door or the like)? | ||
| 9F2F | CP (IY+$00) | |||
| 9F32 | JR NZ,$9F76 | No: doors and similar things are never listed as "contents" | ||
| 9F34 | LD A,(IY+$10) | A = this object's own room | ||
| 9F37 | CP B | Is it really in the room we are listing (rather than, say, tucked inside something else there)? | ||
| 9F38 | JR NZ,$9F76 | No: skip it | ||
| 9F3A | LD A,($B5DB) | Is the current actor the very object whose contents we are printing... | ||
| 9F3D | CP (IX+$00) | |||
| 9F40 | JR NZ,$9F47 | ...(if not, always list it - this next check is only about the actor's own belongings) | ||
| 9F42 | LD A,$04 | ...and is this the outermost call, not one nested inside a container? | ||
| 9F44 | CP D | |||
| 9F45 | JR Z,$9F76 | Both true: this is the actor's own possession, and the room listing should not repeat it - skip it | ||
| 9F47 | CALL $9D86 | Otherwise: can the actor actually see this object (is it close enough)? | ||
| 9F4A | JR Z,$9F76 | No: skip it | ||
| 9F4C | INC C | Yes: count it | ||
| 9F4D | SUB A | No forced capital letter for this printing... | ||
| 9F4E | LD ($B5F5),A | |||
| 9F51 | LD ($B5F4),A | ...and no article added before the whole name | ||
| 9F54 | CALL $9E10 | Print the object's name | ||
| 9F57 | LD A,($B5DB) | Are we listing what the CURRENT ACTOR is carrying (rather than something else)? | ||
| 9F5A | CP (IX+$00) | |||
| 9F5D | JR Z,$9F7A | If so, no full stop is wanted here - the actor's own heading handles that separately | ||
| 9F5F | LD A,$2E | Otherwise print a full stop... | ||
| 9F61 | CALL $7580 | |||
| 9F64 | LD A,(IX+$00) | A = the object just printed | ||
| 9F67 | CALL $9F89 | Print the heading for whatever IT holds ("X is carrying", "in the Y there is") - and find out whether it has anything worth listing | ||
| 9F6A | JR C,$9F76 | Nothing to list inside it (or it is closed): do not recurse | ||
| 9F6C | LD A,(IX+$00) | A = the object again | ||
| 9F6F | PUSH DE | Save the indent (D) for a moment | ||
| 9F70 | INC D | Indent two spaces further in, for its own contents... | ||
| 9F71 | INC D | |||
| 9F72 | CALL $9F10 | ...and list them, calling this same routine again | ||
| 9F75 | POP DE | Restore the indent | ||
| 9F76 | POP AF | Restore the object's number | ||
| 9F77 | JP $9F22 | Try the next object in the index | ||
| 9F7A | CALL $7578 | (Top-level listing: just a new line, with no full stop) | ||
| 9F7D | JR $9F76 | |||
| 9F7F | POP IX | Out of objects: restore the caller's IX | ||
| 9F81 | EX (SP),HL | Recover the (old indent, holder) pair saved earlier, putting the real HL safely back on the stack | ||
| 9F82 | LD A,H | Restore the caller's own indent... | ||
| 9F83 | LD ($7692),A | |||
| 9F86 | LD A,L | ...(A is left holding the holder, though nothing further uses it) | ||
| 9F87 | POP HL | Restore the caller's real HL | ||
| 9F88 | RET | |||
| Prev: 9EF8 | Up: Map | Next: 9F89 |