Prev: 9257 Up: Map Next: 9344
9308: GIVE TO
The actor must be carrying the target (9BCD; otherwise 'you are not carrying it'). The receiver must be able to carry it: the target's weight plus what the receiver already carries (9C42) must not exceed the receiver's capacity, or 'X is carrying too much'. Then the receiver becomes the target's holder, the target moves to the receiver's room, and 9B38 tells anyone who sees it.
9308 LD IY,($B5FA) IY = the instrument's (the receiver's) own record
930C CALL $9BCD Is the actor actually holding the target?
930F LD HL,$ACE4 "you are not carrying it."
9312 JP NC,$72D4 If not, say so and stop
9315 LD A,($B5DA) A = the receiver
9318 CALL $9C42 A = how much the receiver is already carrying
931B LD IX,($B5F8) IX = the target's own record
931F ADD A,(IX+$03) Add the target's own weight to that
9322 PUSH AF Keep the combined total for a moment
9323 POP BC
9324 LD A,(IY+$03) A = the receiver's own carrying capacity
9327 SUB B Subtract the combined total: would that go below zero?
9328 LD HL,$ACFF "X is carrying too much."
932B JP C,$72D4 Too much for them to take: say so and stop
932E CALL $9C99 Dry run? Then stop here: it would work
9331 LD A,($B5DA) The receiver becomes the target's new holder...
9334 LD (IX+$01),A
9337 LD A,(IY+$10) ...in the receiver's own room
933A LD (IX+$10),A
933D LD B,A B = that room
933E LD A,($B5D9) Move the target there, telling Bilbo about it if he can see it
9341 JP $9B38
Prev: 9257 Up: Map Next: 9344