Prev: D085 Up: Map Next: D13A
D0AC: The update routine for the bucket
Graphic 90. Bit 0 of +14 says whether it has a quest item to go to. Until it has, it falls one unit a turn, and looks for a quest item not yet done (graphics 112 to 115) among the room's records each turn; the well's rooms have none, so it falls to the ground there and waits to be carried (TAKE_OR_LEAVE). Put down where a quest item is, it finds it, takes its U and V as the target, and from then on rises one unit a turn to a height of 176 while it steers towards the item (HEAD_FOR_TARGET), without falling.
When it can move no more -- above the item at the top of its rise, or stopped by something in every direction -- it finds the quest item in the room again and sets bit 0 of its +16, which QUEST_ITEM acts on. Then the bucket's work is done: BUCKET_OUT is cleared so the well can give another, the quest-item tune plays, the bucket's quest record is emptied, and the bucket turns into a puff (START_PUFF).
Input
IX the bucket's object record
BUCKET D0AC CALL DRAW_AT_L16_D8 the drawing nudge
D0AF BIT 0,(IX+$14) not yet going to a quest item
D0B3 JR Z,BUCKET_5
D0B5 CALL HEAD_FOR_TARGET going: steer to it, and rise while below 176
D0B8 LD A,(IX+$03)
D0BB CP $B0
D0BD JR NC,BUCKET_0
D0BF LD (IX+$0B),$01
BUCKET_0 D0C3 CALL CLIP_AND_MOVE move without falling; moved: stop, and redraw
D0C6 LD A,(IX+$0A)
D0C9 OR (IX+$09)
D0CC OR (IX+$0B)
D0CF JP NZ,STOP_MOVING
D0D2 CALL ROOM_OBJECT_LOOP stuck: find the quest item not yet done in this room; none: stop
D0D5 LD C,$70
BUCKET_1 D0D7 LD A,(IY+$00)
D0DA AND $FC
D0DC CP C
D0DD JR Z,BUCKET_2
D0DF ADD IY,DE
D0E1 DJNZ BUCKET_1
D0E3 JP STOP_MOVING
BUCKET_2 D0E6 SET 0,(IY+$16) tell it the bucket has reached it
D0EA XOR A the well may give another bucket; the quest-item tune
D0EB LD (BUCKET_OUT),A
D0EE LD DE,TUNE_QUEST
D0F1 CALL PLAY_TUNE
D0F4 CALL QUEST_RECORD_LOOP empty the bucket's quest record...
D0F7 LD A,$5A
BUCKET_3 D0F9 CP (IY+$00)
D0FC JR Z,BUCKET_4
D0FE ADD IY,DE
D100 DJNZ BUCKET_3
D102 JP START_PUFF
BUCKET_4 D105 LD (IY+$00),$00 ...and the bucket becomes a puff
D109 JP START_PUFF
BUCKET_5 D10C LD (IX+$0B),$FF not going anywhere: fall one unit
D110 CALL CLIP_AND_MOVE
D113 CALL ROOM_OBJECT_LOOP a quest item not yet done in this room? None: stop
D116 LD C,$70
BUCKET_6 D118 LD A,(IY+$00)
D11B AND $FC
D11D CP C
D11E JR Z,BUCKET_7
D120 ADD IY,DE
D122 DJNZ BUCKET_6
D124 JP STOP_MOVING
BUCKET_7 D127 LD A,(IY+$01) there is: its U and V are the target, and the bucket is on its way
D12A LD (IX+$15),A
D12D LD A,(IY+$02)
D130 LD (IX+$16),A
D133 SET 0,(IX+$14)
D137 JP STOP_MOVING
Prev: D085 Up: Map Next: D13A