Prev: CFB2 Up: Map Next: D071
CFD2: The update routine for the well
Graphic 120. Shot at enough, it puts out the bucket. It counts in +14 the turns on which one of his bolts touches it (BOLT_TOUCHING), and on the 32nd, with no bucket already out (BUCKET_OUT) and none in the room, and a free record for one, it makes the bucket: a copy of its own record with graphic 90, at the well's U, 8 further in V, at a height of 141, rising one unit (so it hangs there for a turn and then falls), pushable, and linked to the quest's bucket record (QUEST_BUCKET, in QUEST_RECORDS), which gets the graphic and the room.
The count is kept in the well's own record, which is rebuilt from the room's data every time the room is entered, so the 32 must come in one visit.
Input
IX the well's object record
WELL CFD2 CALL DRAW_AT_L16_D8 the drawing nudge; move without falling
CFD5 CALL CLIP_AND_MOVE
CFD8 LD A,(BUCKET_OUT) a bucket out already: nothing more
CFDB AND A
CFDC RET NZ
CFDD CALL BOLT_TOUCHING no bolt touching: nothing
CFE0 RET NZ
CFE1 INC (IX+$14) the 32nd turn a bolt has touched it?
CFE4 LD A,(IX+$14)
CFE7 CP $20
CFE9 RET C
CFEA LD (IX+$14),$00 start the count again; a bucket in the room already: nothing
CFEE CALL ROOM_OBJECT_LOOP
CFF1 LD A,$5A
WELL_0 CFF3 CP (IY+$00)
CFF6 RET Z
CFF7 ADD IY,DE
CFF9 DJNZ WELL_0
CFFB CALL ROOM_OBJECT_LOOP find a free record; none: nothing
CFFE XOR A
WELL_1 CFFF CP (IY+$00)
D002 JR Z,WELL_2
D004 ADD IY,DE
D006 DJNZ WELL_1
D008 RET
WELL_2 D009 PUSH IX copy the well's record into it
D00B POP HL
D00C PUSH IY
D00E POP DE
D00F LD BC,$0020
D012 LDIR
D014 LD (IY+$00),$5A graphic 90, height 141, half-sizes 8, 8, 12, flags $14, rising one unit
D018 LD (IY+$03),$8D
D01C LD A,$08
D01E LD (IY+$04),A
D021 LD (IY+$05),A
D024 LD (IY+$06),$0C
D028 LD (IY+$07),$14
D02C LD (IY+$0B),$01
D030 LD DE,QUEST_BUCKET linked to the quest's bucket record
D033 LD (IY+$10),E
D036 LD (IY+$11),D
D039 LD A,(IX+$01) at the well's U, 8 further in V
D03C LD (IY+$01),A
D03F LD A,(IX+$02)
D042 ADD A,$08
D044 LD (IY+$02),A
D047 LD A,$01 the bucket is out
D049 LD (BUCKET_OUT),A
D04C PUSH IX the new record: its nudge, its place on screen, a move, and drawn
D04E PUSH IY
D050 POP IX
D052 CALL DRAW_AT_L16_D8
D055 CALL CALC_PIXEL_XY
D058 CALL DEC_DZ_AND_UPDATE_UVZ
D05B CALL SET_WIPE_AND_DRAW_FLAGS
D05E POP IX
D060 LD IY,QUEST_BUCKET the quest's bucket record gets the graphic and the room; redraw the well
D064 LD (IY+$00),$5A
D068 LD A,(IX+$08)
D06B LD (IY+$08),A
D06E JP SET_WIPE_AND_DRAW_FLAGS
Prev: CFB2 Up: Map Next: D071