Prev: 46829 Up: Map Next: 46993
46914: Block Movement In X
Used by the routine at BlockMovement.
Cuts down the distance that an object moves along x until it does not go through any other object. The speed is reduced by one each time until the object no longer overlaps the other object, or it is zero.
When the object hits another object, the two objects share their hit flags, and if the other object can be pushed, it is given the speed of this object.
Input
C Distance to move along x
IX Object record
Output
C Distance that can be moved
Try the object against each of the objects in turn.
BlockMovementInX 46914 LD IY,42863 Start with the first object record, ObjectsTable.
46918 LD B,54 Set a counter in B of 54 objects.
BlockMovementInX_Next 46920 CALL TestObjectSolid Jump to BlockMovementInX_NextObject if the other object is not in use, or is being moved.
46923 JR Z,BlockMovementInX_NextObject
46925 CALL TestOverlapInY Jump to BlockMovementInX_NextObject if the objects do not overlap along y.
46928 JR NC,BlockMovementInX_NextObject
46930 CALL TestOverlapInZ Jump to BlockMovementInX_NextObject if the objects do not overlap along z.
46933 JR NC,BlockMovementInX_NextObject
BlockMovementInX_Test 46935 CALL TestOverlapInX Jump to BlockMovementInX_NextObject if the objects will not overlap along x when the object has moved.
46938 JR NC,BlockMovementInX_NextObject
The objects hit each other. Flag a hit along x and pass on the hit flags.
46940 SET 0,(IX+12) Flag that the object has been stopped along x.
46944 LD A,(IX+13) Fetch the hit flags of the object.
46947 RRCA Move bit 7 down to bit 6.
46948 AND %01000000 Keep only bit 6.
46950 OR (IY+13) Add the hit flags of the other object.
46953 LD (IY+13),A Write them to the other object.
46956 RLCA Move bit 5 of the hit flags of the other object up to bit 6.
46957 AND %01000000 Keep only bit 6.
46959 OR (IX+13) Add the hit flags of the object.
46962 LD (IX+13),A Write them to the object.
Push the other object, if it can be pushed.
46965 BIT 2,(IY+7) Jump to BlockMovementInX_Reduce if the other object cannot be pushed.
46969 JR Z,BlockMovementInX_Reduce
46971 LD A,(IX+9) Give the other object the speed along x of the object.
46974 LD (IY+9),A
Step the distance closer to zero while the objects still overlap.
BlockMovementInX_Reduce 46977 LD A,C Fetch the distance along x.
46978 CALL BringSpeedCloserToZero Call BringSpeedCloserToZero to step it one closer to zero.
46981 LD C,A Set the distance.
46982 RET Z Return if the distance is zero.
46983 JR BlockMovementInX_Test Jump to BlockMovementInX_Test to test again.
BlockMovementInX_NextObject 46985 LD DE,32 Move IY on to the next object record.
46988 ADD IY,DE
46990 DJNZ BlockMovementInX_Next Decrease the counter and loop until all the objects have been tried.
46992 RET Return.
View the equivalent code in;
Prev: 46829 Up: Map Next: 46993