Prev: CDA0 Up: Map Next: CE31
CDBB: The update routine for the lift
Graphic 84, a block that carries him up. It keeps its state in +17: bit 0 while it is moving, bit 1 while it is on the way down, and bit 7, set by the collision code when he (or the heavy block, HEAVY_BLOCK) lands on it (MARK_STOOD_ON).
At rest, it waits for him: landing on it passes his Z step down to it (ADJ_DZ_FOR_OBJ_INTERSECT), it moves, bumps the floor, and with bit 7 set it starts to rise. Rising, it asks for two units a turn, gives him a Z step of 3 and tells his code he is standing on something (bit 2 of PLAYER_BUMPED); it rises only while it keeps bumping into something above it -- him -- so the moment he steps off it turns round. At a height of 176 it stops, and he is given a Z step of -2. On the way down it sinks one a turn until it bumps into something below, and then it is at rest again.
Measured in the simulator in room 2: he landed on it at Z 128 and it rose one unit a turn with him on top, 12 above it; at 176 he fell, pushing the lift down with him faster and faster, and at the floor it started up again, and so on for as long as he stood there.
Input
IX the object record
LIFT CDBB LD (IX+$09),$00 no sideways step
CDBF LD (IX+$0A),$00
CDC3 CALL DRAW_AT_L16_D8 the drawing nudge
CDC6 CALL CLIP_AND_MOVE move by its Z step, without falling; no sideways step again
CDC9 XOR A
CDCA LD (IX+$09),A
CDCD LD (IX+$0A),A
CDD0 BIT 0,(IX+$17) moving?
CDD4 JR NZ,LIFT_0
CDD6 BIT 2,(IX+$0C) at rest: did something land on it this turn?
CDDA JR Z,STOP_MOVING
CDDC BIT 7,(IX+$17) was it him?
CDE0 JR Z,STOP_MOVING
CDE2 RES 7,(IX+$17) yes: start moving, upwards
CDE6 SET 0,(IX+$17)
CDEA JR LIFT_2
LIFT_0 CDEC BIT 2,(IX+$0C) moving, and nothing above it: go down, one a turn
CDF0 JR NZ,LIFT_1
CDF2 SET 1,(IX+$17)
CDF6 LD (IX+$0B),$FF
CDFA JP SET_WIPE_AND_DRAW_FLAGS
LIFT_1 CDFD BIT 1,(IX+$17) bumped: on the way down, that is the floor or something below
CE01 JR NZ,LIFT_3
CE03 LD A,(IX+$03) on the way up: below 176?
CE06 CP $B0
CE08 JR C,LIFT_2
CE0A LD (IX+$03),$B0 at the top: stay at 176; he is sent down
CE0E LD A,$FE
CE10 LD ($A77A),A
CE13 JP SET_WIPE_AND_DRAW_FLAGS
LIFT_2 CE16 LD (IX+$0B),$02 rise: two units a turn for the lift, three for him, and he stands on it
CE1A LD A,$03
CE1C LD ($A77A),A
CE1F LD A,(PLAYER_BUMPED)
CE22 OR $04
CE24 LD (PLAYER_BUMPED),A
CE27 JP SET_WIPE_AND_DRAW_FLAGS
LIFT_3 CE2A LD (IX+$17),$00 down again: at rest
CE2E JP STOP_MOVING
The Z step it gives him is written into his record whether or not he is the one on top.
Prev: CDA0 Up: Map Next: CE31