| The Hobbit (v1.0) | Routines |
| Prev: 8EA0 | Up: Map | Next: 8F17 |
|
The barrel's FILL handler. The instrument must be something that pours (bit 1 of its flags: water and wine, for example) and the target must not already be full ('the barrel is full'). The work is done by PUT IN (91B9) with target and instrument swapped (9E93), so FILL THE BARREL WITH WATER is really PUT THE WATER IN THE BARREL.
Filling from a river is a special case: if the instrument is object 23 or 24 (the river's water or black water), a fresh object 21 or 22 ('water', 'black water') is used instead, so the river never runs dry.
|
||||
| 8ED3 | LD IX,($B5F8) | IX = the target's own record (the container being filled) | ||
| 8ED7 | LD A,($B5DA) | Is the instrument the fast river's water, or the enchanted river's black water? | ||
| 8EDA | CP $17 | |||
| 8EDC | JR Z,$8EFC | Ordinary river water: go and use a fresh copy of it, below | ||
| 8EDE | CP $18 | |||
| 8EE0 | JR Z,$8F04 | Black water: likewise | ||
| 8EE2 | LD IY,($B5FA) | Anything else: IY = the instrument's own record | ||
| 8EE6 | BIT 1,(IY+$07) | Does it actually pour (is it a liquid)? | ||
| 8EEA | JP Z,$9EBF | No: fail with the usual message | ||
| 8EED | BIT 2,(IX+$07) | Is the container already full? | ||
| 8EF1 | LD A,$82 | A = the state code for FULL | ||
| 8EF3 | JP NZ,$A09C | Yes: say so and stop | ||
| 8EF6 | LD HL,$91B9 | No: do the work as an ordinary PUT IN... | ||
| 8EF9 | JP $9E93 | ...with target and instrument swapped, so "fill X with Y" becomes "put Y in X" | ||
| 8EFC | LD A,$15 | Ordinary river water: A = a FRESH water object | ||
| 8EFE | LD IY,$C343 | IY = its own record | ||
| 8F02 | JR $8F0A | |||
| 8F04 | LD A,$16 | Black water: A = a fresh black-water object instead | ||
| 8F06 | LD IY,$C358 | |||
| 8F0A | LD ($B5DA),A | That fresh object becomes the instrument | ||
| 8F0D | LD ($B5FA),IY | |||
| 8F11 | LD (IY+$01),$FF | It starts out held by nobody... | ||
| 8F15 | JR $8EE2 | ...then join the ordinary FILL code above (so the river itself never runs dry) | ||
| Prev: 8EA0 | Up: Map | Next: 8F17 |