Prev: C497 Up: Map Next: C535
C4E6: Block Movement In Y
Used by the routine at BlockMovement.
Brings the speed along 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 along x
L Speed along y
H Speed along z
IX The address of the object
Output
L The new speed along y
Walk the object table.
BlockMovementInY C4E6 LD IY,$5B88 Point IY at PlayerBottomObject.
C4EA LD B,$38 Set a counter of 38 objects.
Skip unless the object is solid and already overlaps along x and z.
BlockMovementInY_Next C4EC CALL TestObjectSolid Jump to BlockMovementInY_Advance if the object is not present or is ignored.
C4EF JR Z,BlockMovementInY_Advance
C4F1 CALL TestOverlapInX Jump to BlockMovementInY_Advance if the objects do not overlap along x.
C4F4 JR NC,BlockMovementInY_Advance
C4F6 CALL TestOverlapInZ Jump to BlockMovementInY_Advance if the objects do not overlap along z.
C4F9 JR NC,BlockMovementInY_Advance
Test whether they overlap along y after the move.
BlockMovementInY_Test C4FB CALL TestOverlapInY Jump to BlockMovementInY_Advance if the objects do not overlap along y after the move.
C4FE JR NC,BlockMovementInY_Advance
Flag the object as blocked along y, then apply the kill flags.
C500 SET 1,(IX+$0C) Flag the object as blocked along y.
C504 LD A,(IX+$0D) Fetch the extra flags and move the bit that it kills what it hits into bit 6.
C507 RRCA
C508 AND %01000000 Keep the bit that flags the other object as killed.
C50A OR (IY+$0D) Set it in the extra flags of the other object, if the object kills what it runs into.
C50D LD (IY+$0D),A
C510 RLCA Move the bit that the other object kills what hits it into bit 6.
C511 AND %01000000 Keep the bit that flags the object as killed.
C513 OR (IX+$0D) Set it in the extra flags of the object, if the other object kills what runs into it.
C516 LD (IX+$0D),A
Pass the speed along y to the other object if it can be moved.
C519 BIT 2,(IY+$07) Jump to BlockMovementInY_Slow if the other object cannot be moved.
C51D JR Z,BlockMovementInY_Slow
C51F LD A,(IX+$0A) Give the speed along y to the other object.
C522 LD (IY+$0A),A
Slow the move along y and test this object again.
BlockMovementInY_Slow C525 LD A,L Fetch the speed along y.
C526 CALL BringSpeedCloserToZero Bring it closer to zero.
C529 LD L,A Store it.
C52A RET Z Return if the speed is now zero.
C52B JR BlockMovementInY_Test Jump to BlockMovementInY_Test.
Move on to the next object.
BlockMovementInY_Advance C52D LD DE,$0020 Point IY at the next object.
C530 ADD IY,DE
C532 DJNZ BlockMovementInY_Next Jump to BlockMovementInY_Next until all of the objects have been tested.
C534 RET Return.
View the equivalent code in;
Prev: C497 Up: Map Next: C535