Prev: 52122 Up: Map Next: 52280
52201: Block Movement In Y
Used by the routine at BlockMovement.
Brings the speed in Y of an object closer to zero until it does not run into any other object. This works in the same way as BlockMovementInX.
Input
C Speed in X
L Speed in Y
H Speed in Z
IX Address of the object
Output
L The new speed in Y
Test each object, then slow the Y speed if they overlap.
BlockMovementInY 52201 LD IY,23560 Point IY at the first object in the table, ObjectsTable.
52205 LD B,40 Set the number of objects to 40.
BlockMovementInY_Next 52207 CALL TestObjectSolid Test whether the object is present and not ignored.
52210 JR Z,BlockMovementInY_Advance Jump to BlockMovementInY_Advance if it is not.
52212 CALL TestOverlapInX Test whether the objects overlap in X.
52215 JR NC,BlockMovementInY_Advance Jump to BlockMovementInY_Advance if they do not.
52217 CALL TestOverlapInZ Test whether the objects overlap in Z.
52220 JR NC,BlockMovementInY_Advance Jump to BlockMovementInY_Advance if they do not.
BlockMovementInY_Test 52222 CALL TestOverlapInY Test whether the objects overlap in Y after the move.
52225 JR NC,BlockMovementInY_Advance Jump to BlockMovementInY_Advance if they do not.
52227 SET 1,(IX+12) Flag the object as blocked in Y.
52231 LD A,(IX+13) Fetch the flags of the object and move the bit that it destroys what it hits into bit 6.
52234 RRCA
52235 AND %01000000 Keep the bit that flags the other object as destroyed.
52237 OR (IY+13) Set it in the flags of the other object, if the object destroys what it runs into.
52240 LD (IY+13),A
52243 RLCA Move the bit that the other object destroys what it hits into bit 6.
52244 AND %01000000 Keep the bit that flags the object as destroyed.
52246 OR (IX+13) Set it in the flags of the object, if the other object destroys what runs into it.
52249 LD (IX+13),A
52252 BIT 2,(IY+7) Jump to BlockMovementInY_Slow if the other object cannot be moved.
52256 JR Z,BlockMovementInY_Slow
52258 LD A,(IX+10) Fetch the speed in Y of the object.
52261 LD (IY+10),A Give it to the other object.
BlockMovementInY_Slow 52264 LD A,L Fetch the speed in Y.
52265 CALL BringSpeedCloserToZero Bring it closer to zero.
52268 LD L,A Store it.
52269 RET Z Return if it is zero.
52270 JR BlockMovementInY_Test Jump to BlockMovementInY_Test to test it again.
BlockMovementInY_Advance 52272 LD DE,32 Set DE to the size of an object.
52275 ADD IY,DE Point IY at the next object.
52277 DJNZ BlockMovementInY_Next Jump to BlockMovementInY_Next until all of the objects have been tested.
52279 RET Return.
View the equivalent code in;
Prev: 52122 Up: Map Next: 52280