Prev: 50406 Up: Map Next: 50601
50485: Block Movement In Z
Used by the routine at BlockMovement.
Brings the speed along z of an object closer to zero until it does not run into any other object. This works in the same way as BlockMovementInX, except that the object that is hit is flagged as touched (bit 3 of its extra flags) if the player is the object that hit it. An object which can be moved gives its speed along z to the other object, and takes on the speeds along x and y of the other object if it has none of its own.
Input
C Speed along x
L Speed along y
H Speed along z
IX The address of the object
Output
H The new speed along z
Walk the object table.
BlockMovementInZ 50485 LD IY,23432 Point IY at PlayerBottomObject.
50489 LD B,56 Set a counter of 56 objects.
Skip unless the object is solid and already overlaps along x and y.
BlockMovementInZ_Next 50491 CALL TestObjectSolid Jump to BlockMovementInZ_Advance if the object is not present or is ignored.
50494 JR Z,BlockMovementInZ_Advance
50496 CALL TestOverlapInX Jump to BlockMovementInZ_Advance if the objects do not overlap along x.
50499 JR NC,BlockMovementInZ_Advance
50501 CALL TestOverlapInY Jump to BlockMovementInZ_Advance if the objects do not overlap along y.
50504 JR NC,BlockMovementInZ_Advance
Test whether they overlap along z after the move.
BlockMovementInZ_Test 50506 CALL TestOverlapInZ Jump to BlockMovementInZ_Advance if the objects do not overlap along z after the move.
50509 JR NC,BlockMovementInZ_Advance
Flag the object as blocked along z, then apply the kill flags.
50511 SET 2,(IX+12) Flag the object as blocked along z.
50515 LD A,(IX+13) Fetch the extra flags and move the bit that it kills what it hits into bit 6.
50518 RRCA
50519 AND %01000000 Keep the bit that flags the other object as killed.
50521 OR (IY+13) Set it in the extra flags of the other object, if the object kills what it runs into.
50524 LD (IY+13),A
50527 RLCA Move the bit that the other object kills what hits it into bit 6.
50528 AND %01000000 Keep the bit that flags the object as killed.
50530 OR (IX+13) Set it in the extra flags of the object, if the other object kills what runs into it.
50533 LD (IX+13),A
Pass speeds if this object can be moved. Flag the other object as touched if the player is standing on it.
50536 BIT 2,(IX+7) Jump to BlockMovementInZ_Slow if the object cannot be moved.
50540 JR Z,BlockMovementInZ_Slow
50542 LD A,(IX+0) Fetch the sprite number and subtract 16.
50545 SUB 16
50547 CP 32 Jump to BlockMovementInZ_Carry if it is not the player.
50549 JR NC,BlockMovementInZ_Carry
50551 SET 3,(IY+13) Flag the other object as touched.
Give the speed along z to the other object, and take its speeds along x and y if this object has none.
BlockMovementInZ_Carry 50555 LD A,(IX+11) Give the speed along z to the other object.
50558 LD (IY+11),A
50561 LD A,(IX+9) Fetch the speed along x and test it.
50564 AND A
50565 JR NZ,BlockMovementInZ_Y Jump to BlockMovementInZ_Y if it has one.
50567 LD A,(IY+9) Take the speed along x of the other object.
50570 LD (IX+9),A
BlockMovementInZ_Y 50573 LD A,(IX+10) Fetch the speed along y and test it.
50576 AND A
50577 JR NZ,BlockMovementInZ_Slow Jump to BlockMovementInZ_Slow if it has one.
50579 LD A,(IY+10) Take the speed along y of the other object.
50582 LD (IX+10),A
Slow the move along z and test this object again.
BlockMovementInZ_Slow 50585 LD A,H Fetch the speed along z.
50586 CALL BringSpeedCloserToZero Bring it closer to zero.
50589 LD H,A Store it.
50590 RET Z Return if the speed is now zero.
50591 JR BlockMovementInZ_Test Jump to BlockMovementInZ_Test.
Move on to the next object.
BlockMovementInZ_Advance 50593 LD DE,32 Point IY at the next object.
50596 ADD IY,DE
50598 DJNZ BlockMovementInZ_Next Jump to BlockMovementInZ_Next until all of the objects have been tested.
50600 RET Return.
View the equivalent code in;
Prev: 50406 Up: Map Next: 50601