| The Hobbit (v1.0) | Routines |
| Prev: A174 | Up: Map | Next: A1E4 |
| A178 | LD A,($B5D9) | Is the TARGET actually the rope (object 18)? | ||
| A17B | CP $12 | |||
| A17D | JR Z,$A1DE | Yes: "TIE THE ROPE TO X" - turn it round into "TIE X TO THE ROPE" (below) | ||
| A17F | LD A,($B5DA) | No: is the INSTRUMENT the rope instead? | ||
| A182 | CP $12 | |||
| A184 | JP NZ,$9EBF | Neither: fail with the usual message - only the rope can be tied | ||
| A187 | LD IX,($B5F8) | IX = the target's own record (the thing being tied) | ||
| A18B | BIT 1,(IX+$07) | Does it pour (is it a liquid)? | ||
| A18F | JP NZ,$9EBF | Yes: cannot tie up a liquid | ||
| A192 | CALL $9CEC | Does it already hold anything visible? | ||
| A195 | CP $00 | |||
| A197 | LD HL,$AF6F | "the X is already tied." | ||
| A19A | JP NZ,$72D4 | Already holding something (i.e. already tied to something): say so and stop | ||
| A19D | BIT 3,(IX+$07) | Is it dead (a corpse)? | ||
| A1A1 | JR NZ,$A1AA | Yes: a dead character may still be tied up | ||
| A1A3 | BIT 6,(IX+$07) | No: is it a LIVING character? | ||
| A1A7 | JP NZ,$9EBF | Yes: cannot tie up someone alive | ||
| A1AA | CALL $9C99 | Dry run? Then stop here: it would work | ||
| A1AD | LD IY,($B5FA) | IY = the rope's own record | ||
| A1B1 | CALL $9BCD | Is the actor already holding the thing being tied? | ||
| A1B4 | LD A,($B5DA) | It becomes held by the rope, either way... | ||
| A1B7 | LD (IX+$01),A | |||
| A1BA | JR C,$A1D2 | If the actor already held it, skip straight to deciding who holds the rope itself | ||
| A1BC | SUB A | Otherwise: try to pick it up first (as an ordinary TAKE), but only as a trial for now | ||
| A1BD | LD ($B5EB),A | |||
| A1C0 | CALL $8CC8 | |||
| A1C3 | LD A,($B5EC) | Did the actor manage to pick it up? | ||
| A1C6 | CP $00 | |||
| A1C8 | LD A,$01 | Either way, this really is happening now | ||
| A1CA | LD ($B5EB),A | |||
| A1CD | LD ($B5EC),A | |||
| A1D0 | JR Z,$A1D9 | Could not pick it up: leave the rope where it is, below | ||
| A1D2 | LD A,($B5DB) | Could pick it up: the rope stays in the actor's own hands | ||
| A1D5 | LD (IY+$01),A | |||
| A1D8 | RET | |||
| A1D9 | LD (IY+$01),$FF | Left lying: the rope is held by nobody, tied to whatever is too heavy to lift | ||
| A1DD | RET | |||
| A1DE | LD HL,$A178 | "TIE THE ROPE TO X": run this same handler again... | ||
| A1E1 | JP $9E93 | ...with target and instrument swapped, so it becomes "TIE X TO THE ROPE" | ||
| Prev: A174 | Up: Map | Next: A1E4 |