Prev: CD0D Up: Map Next: CD70
CD16: The update routine for a collectable
Graphics 144 to 148: the five things that must be brought to the pentagram. Anywhere but room 82, or before the pentagram is showing (PENTAGRAM_ON), a collectable is an ordinary thing that falls and can be pushed (it goes on at FALL, in PUSHABLE); the player can pick it up and carry it (TAKE_OR_LEAVE).
In room 82 with the pentagram showing, it glides without falling towards its own place on the pentagram, one unit a turn in U and in V: the place comes from TARGETS by the low three bits of the graphic, and HEAD_FOR_TARGET steers. When it is there its graphic goes up by 8, in its object record and in its quest record (CHANGE_GRAPHIC), so it is no longer a collectable (152 to 156 are a still thing's), and PLACED counts it. The fifth ends the game: a jump to WON.
Input
IX the collectable's object record
COLLECTABLE CD16 CALL DRAW_AT_L16_D8 the drawing nudge
CD19 LD A,(PLAYER_ROOM) not in room 82, or no pentagram yet: just fall and stop
CD1C CP $52
CD1E JP NZ,FALL
CD21 LD A,(PENTAGRAM_ON)
CD24 AND A
CD25 JP Z,FALL
CD28 LD A,(IX+$00) +15 and +16 = its place on the pentagram, from TARGETS by graphic AND 7
CD2B AND $07
CD2D ADD A,A
CD2E LD L,A
CD2F LD H,$00
CD31 LD DE,TARGETS
CD34 ADD HL,DE
CD35 LD A,(HL)
CD36 LD (IX+$15),A
CD39 INC HL
CD3A LD A,(HL)
CD3B LD (IX+$16),A
CD3E CALL HEAD_FOR_TARGET step towards it, and move without falling
CD41 CALL CLIP_AND_MOVE
CD44 LD A,(IX+$01) not there yet: stop, and redraw
CD47 SUB (IX+$15)
CD4A LD C,A
CD4B LD A,(IX+$02)
CD4E SUB (IX+$16)
CD51 OR C
CD52 JP NZ,STOP_MOVING
CD55 LD A,(IX+$00) there: graphic + 8, here and in its quest record
CD58 ADD A,$08
CD5A LD C,A
CD5B LD A,(IX+$00)
CD5E CALL CHANGE_GRAPHIC
CD61 LD A,(PLACED) one more placed; the fifth wins the game
CD64 INC A
CD65 LD (PLACED),A
CD68 CP $05
CD6A JP NC,WON
CD6D JP STOP_MOVING stop, and redraw
Prev: CD0D Up: Map Next: CD70