Prev: CBE9 Up: Map Next: CC9D
CC38: Block Movement In Z
Used by the routine at BlockMovement.
Brings the speed in Z of an object closer to zero until it does not run into any other object. This works in the same way as BlockMovementInX, except that the object that is hit is flagged as triggered (bit 3 of its flags in byte 0D) as something is standing on it. An object that can be moved takes on the speeds in X and Y of the object that it stands on, if it has none of its own.
Input
C Speed in X
L Speed in Y
H Speed in Z
IX Address of the object
Output
H The new speed in Z
Test each object, then slow the Z speed if they overlap.
BlockMovementInZ CC38 LD IY,$5C08 Point IY at the first object in the table, ObjectsTable.
CC3C LD B,$28 Set the number of objects to 28.
BlockMovementInZ_Next CC3E CALL TestObjectSolid Test whether the object is present and not ignored.
CC41 JR Z,BlockMovementInZ_Advance Jump to BlockMovementInZ_Advance if it is not.
CC43 CALL TestOverlapInX Test whether the objects overlap in X.
CC46 JR NC,BlockMovementInZ_Advance Jump to BlockMovementInZ_Advance if they do not.
CC48 CALL TestOverlapInY Test whether the objects overlap in Y.
CC4B JR NC,BlockMovementInZ_Advance Jump to BlockMovementInZ_Advance if they do not.
BlockMovementInZ_Test CC4D CALL TestOverlapInZ Test whether the objects overlap in Z after the move.
CC50 JR NC,BlockMovementInZ_Advance Jump to BlockMovementInZ_Advance if they do not.
CC52 SET 2,(IX+$0C) Flag the object as blocked in Z.
CC56 LD A,(IX+$0D) Fetch the flags of the object and move the bit that it destroys what it hits into bit 6.
CC59 RRCA
CC5A AND %01000000 Keep the bit that flags the other object as destroyed.
CC5C OR (IY+$0D) Set it in the flags of the other object, if the object destroys what it runs into.
CC5F LD (IY+$0D),A
CC62 RLCA Move the bit that the other object destroys what it hits into bit 6.
CC63 AND %01000000 Keep the bit that flags the object as destroyed.
CC65 OR (IX+$0D) Set it in the flags of the object, if the other object destroys what runs into it.
CC68 LD (IX+$0D),A
CC6B SET 3,(IY+$0D) Flag the other object as triggered.
CC6F BIT 2,(IX+$07) Jump to BlockMovementInZ_Slow if the object cannot be moved.
CC73 JR Z,BlockMovementInZ_Slow
CC75 LD A,(IX+$09) Fetch the speed in X of the object and test it.
CC78 AND A
CC79 JR NZ,BlockMovementInZ_Y Jump to BlockMovementInZ_Y if it has one.
CC7B LD A,(IY+$09) Take the speed in X of the other object.
CC7E LD (IX+$09),A
BlockMovementInZ_Y CC81 LD A,(IX+$0A) Fetch the speed in Y of the object and test it.
CC84 AND A
CC85 JR NZ,BlockMovementInZ_Slow Jump to BlockMovementInZ_Slow if it has one.
CC87 LD A,(IY+$0A) Take the speed in Y of the other object.
CC8A LD (IX+$0A),A
BlockMovementInZ_Slow CC8D LD A,H Fetch the speed in Z.
CC8E CALL BringSpeedCloserToZero Bring it closer to zero.
CC91 LD H,A Store it.
CC92 RET Z Return if it is zero.
CC93 JR BlockMovementInZ_Test Jump to BlockMovementInZ_Test to test it again.
BlockMovementInZ_Advance CC95 LD DE,$0020 Set DE to the size of an object.
CC98 ADD IY,DE Point IY at the next object.
CC9A DJNZ BlockMovementInZ_Next Jump to BlockMovementInZ_Next until all of the objects have been tested.
CC9C RET Return.
View the equivalent code in;
Prev: CBE9 Up: Map Next: CC9D