Prev: C4E6 Up: Map Next: C5A9
C535: Shorten dZ against the other objects
Used by the routine at ADJ_FOR_OUT_OF_BOUNDS.
ADJ_DU_FOR_OBJ_INTERSECT for Z, done before U and V so it tests the object where it stands: an object has to overlap in U and in V to be above or below it. Stopping sets bit 2 of +$0C, whether the move was up or down, and harm passes as in U.
A mover with bit 2 of its flags -- the robot's legs have it -- is carried: it gives its intended dZ to the obstacle and, wherever its own dU or dV is zero, takes on the obstacle's, so standing on something that moves carries it along. When that mover is one of graphics 16 to 47, which takes in the robot's legs, the obstacle also gets bit 3 of its +$0D: the robot has stood on it, or come up against it from below. The update routines of graphics 44, 45 and 47 (DROPPING_BLOCK, COLLAPSING_BLOCK, LIFT) read and clear that bit.
Knight Lore sets the obstacle's bit 3 for any mover and passes no dZ; Pentagram passes the dZ and sets bit 3 for any mover too, with more of its own (the conveyors, the marks its lift reads). Here the bit is kept for the robot.
Input
IX the moving object
H dZ
C dU, zero here
L dV, zero here
Output
H dZ, shortened
ADJ_DZ_FOR_OBJ_INTERSECT C535 LD IY,OBJECTS IY = the first record; 56 of them
C539 LD B,$38
ADJ_DZ_FOR_OBJ_INTERSECT_0 C53B CALL IS_OBJECT_NOT_IGNORED Empty, or out of the collision tests
C53E JR Z,DZ_OBJ_NEXT
C540 CALL DO_OBJS_INTERSECT_ON_U Not overlapping in U, or not in V
C543 JR NC,DZ_OBJ_NEXT
C545 CALL DO_OBJS_INTERSECT_ON_V
C548 JR NC,DZ_OBJ_NEXT
DZ_OBJ_HIT_TEST C54A CALL DO_OBJS_INTERSECT_ON_Z No overlap in Z after the move: the next object
C54D JR NC,DZ_OBJ_NEXT
C54F SET 2,(IX+$0C) Stopped in Z
C553 LD A,(IX+$0D) Harm passes both ways, as in U
C556 RRCA
C557 AND $40
C559 OR (IY+$0D)
C55C LD (IY+$0D),A
C55F RLCA
C560 AND $40
C562 OR (IX+$0D)
C565 LD (IX+$0D),A
C568 BIT 2,(IX+$07) Not a mover that is carried
C56C JR Z,ADJ_DZ_FOR_OBJ_INTERSECT_3
C56E LD A,(IX+$00) Not graphics 16-47
C571 SUB $10
C573 CP $20
C575 JR NC,ADJ_DZ_FOR_OBJ_INTERSECT_1
C577 SET 3,(IY+$0D) The mover (flags bit 2 and graphics 16-47: the robot, the pushable blocks, the bobbing block and the lift) has met the obstacle in Z
ADJ_DZ_FOR_OBJ_INTERSECT_1 C57B LD A,(IX+$0B) The obstacle takes our dZ
C57E LD (IY+$0B),A
C581 LD A,(IX+$09) No dU of our own: ride with the obstacle's
C584 AND A
C585 JR NZ,ADJ_DZ_FOR_OBJ_INTERSECT_2
C587 LD A,(IY+$09)
C58A LD (IX+$09),A
ADJ_DZ_FOR_OBJ_INTERSECT_2 C58D LD A,(IX+$0A) No dV of our own: ride with the obstacle's
C590 AND A
C591 JR NZ,ADJ_DZ_FOR_OBJ_INTERSECT_3
C593 LD A,(IY+$0A)
C596 LD (IX+$0A),A
ADJ_DZ_FOR_OBJ_INTERSECT_3 C599 LD A,H A unit shorter; none left, done; else the same object again
C59A CALL SHORTEN_DELTA
C59D LD H,A
C59E RET Z
C59F JR DZ_OBJ_HIT_TEST
DZ_OBJ_NEXT C5A1 LD DE,$0020 The next of 56
C5A4 ADD IY,DE
C5A6 DJNZ ADJ_DZ_FOR_OBJ_INTERSECT_0
C5A8 RET
Prev: C4E6 Up: Map Next: C5A9