Prev: 52009 Up: Map Next: 52122
52037: Block Movement
Used by the routines at ApplyGravityAndMove and MovePlayer.
Stops an object moving through the walls of the room or through other objects. The speeds in X, Y and Z of the object are each brought closer to zero until the object can move without hitting anything. Whichever direction is hit is flagged in the low bits of the flags in byte 12 of the object: bit 0 for X, bit 1 for Y and bit 2 for Z. For the Z direction that means that the object is standing on something. An object that is flagged to be ignored in the 3D calculations is not adjusted.
Input
IX Address of the object
BlockMovement 52037 BIT 1,(IX+7) Test whether the object is flagged to be ignored.
52041 RET NZ Return if it is.
52042 SET 1,(IX+7) Flag the object to be ignored, so that it does not hit itself.
52046 LD A,(IX+12) Fetch the flags.
52049 AND %11111000 Clear the blocked flags of X, Y and Z.
52051 LD (IX+12),A Store the flags.
52054 LD L,0 Set the new speed in Y to zero.
52056 LD C,L Set the new speed in X to zero.
The new speeds are kept in H for Z, C for X and L for Y. The Z direction goes first, and the floor of the room is tried before the objects.
52057 LD A,(IX+11) Fetch the speed in Z.
52060 AND A Test whether it is zero.
52061 LD H,A Stash it in H.
52062 JR Z,BlockMovement_X Jump to BlockMovement_X if it is zero.
52064 CALL StopObjectAtFloor Stop the object going through the floor.
52067 LD A,H Test whether the speed in Z is now zero.
52068 AND A
52069 JR Z,BlockMovement_X Jump to BlockMovement_X if it is.
52071 CALL BlockMovementInZ Stop the object going through other objects.
BlockMovement_X 52074 LD A,(IX+9) Fetch the speed in X and test whether it is zero.
52077 AND A
52078 LD C,A Stash it in C.
52079 JR Z,BlockMovement_Y Jump to BlockMovement_Y if it is zero.
52081 CALL KeepObjectInRoomInX Stop the object going through the walls of the room.
52084 LD A,C Test whether the speed in X is now zero.
52085 AND A
52086 JR Z,BlockMovement_Y Jump to BlockMovement_Y if it is.
52088 CALL BlockMovementInX Stop the object going through other objects.
BlockMovement_Y 52091 LD A,(IX+10) Fetch the speed in Y and test whether it is zero.
52094 AND A
52095 LD L,A Stash it in L.
52096 JR Z,BlockMovement_Store Jump to BlockMovement_Store if it is zero.
52098 CALL KeepObjectInRoomInY Stop the object going through the walls of the room.
52101 LD A,L Test whether the speed in Y is now zero.
52102 AND A
52103 JR Z,BlockMovement_Store Jump to BlockMovement_Store if it is.
52105 CALL BlockMovementInY Stop the object going through other objects.
BlockMovement_Store 52108 LD (IX+9),C Store the new speed in X.
52111 LD (IX+10),L Store the new speed in Y.
52114 LD (IX+11),H Store the new speed in Z.
52117 RES 1,(IX+7) Stop ignoring the object.
52121 RET Return.
View the equivalent code in;
Prev: 52009 Up: Map Next: 52122