Prev: 46914 Up: Map Next: 47072
46993: Block Movement In Y
Used by the routine at BlockMovement.
Cuts down the distance that an object moves along y until it does not go through any other object, in the same way as BlockMovementInX does for x.
Input
L Distance to move along y
IX Object record
Output
L Distance that can be moved
Try the object against each of the objects in turn.
BlockMovementInY 46993 LD IY,42863 Start with the first object record, ObjectsTable.
46997 LD B,54 Set a counter in B of 54 objects.
BlockMovementInY_Next 46999 CALL TestObjectSolid Jump to BlockMovementInY_NextObject if the other object is not in use, or is being moved.
47002 JR Z,BlockMovementInY_NextObject
47004 CALL TestOverlapInX Jump to BlockMovementInY_NextObject if the objects do not overlap along x.
47007 JR NC,BlockMovementInY_NextObject
47009 CALL TestOverlapInZ Jump to BlockMovementInY_NextObject if the objects do not overlap along z.
47012 JR NC,BlockMovementInY_NextObject
BlockMovementInY_Test 47014 CALL TestOverlapInY Jump to BlockMovementInY_NextObject if the objects will not overlap along y when the object has moved.
47017 JR NC,BlockMovementInY_NextObject
The objects hit each other. Flag a hit along y and pass on the hit flags.
47019 SET 1,(IX+12) Flag that the object has been stopped along y.
47023 LD A,(IX+13) Fetch the hit flags of the object.
47026 RRCA Move bit 7 down to bit 6.
47027 AND %01000000 Keep only bit 6.
47029 OR (IY+13) Add the hit flags of the other object.
47032 LD (IY+13),A Write them to the other object.
47035 RLCA Move bit 5 of the hit flags of the other object up to bit 6.
47036 AND %01000000 Keep only bit 6.
47038 OR (IX+13) Add the hit flags of the object.
47041 LD (IX+13),A Write them to the object.
Push the other object, if it can be pushed.
47044 BIT 2,(IY+7) Jump to BlockMovementInY_Reduce if the other object cannot be pushed.
47048 JR Z,BlockMovementInY_Reduce
47050 LD A,(IX+10) Give the other object the speed along y of the object.
47053 LD (IY+10),A
Step the distance closer to zero while the objects still overlap.
BlockMovementInY_Reduce 47056 LD A,L Fetch the distance along y.
47057 CALL BringSpeedCloserToZero Call BringSpeedCloserToZero to step it one closer to zero.
47060 LD L,A Set the distance.
47061 RET Z Return if the distance is zero.
47062 JR BlockMovementInY_Test Jump to BlockMovementInY_Test to test again.
BlockMovementInY_NextObject 47064 LD DE,32 Move IY on to the next object record.
47067 ADD IY,DE
47069 DJNZ BlockMovementInY_Next Decrease the counter and loop until all the objects have been tried.
47071 RET Return.
View the equivalent code in;
Prev: 46914 Up: Map Next: 47072