![]() |
Routines |
| Prev: C442 | Up: Map | Next: C4E6 |
|
Used by the routine at BlockMovement.
Brings the speed along x of an object closer to zero until it does not run into any other object. If the object does run into another, the objects may be killed: bit 7 of the extra flags means that it kills whatever it runs into, and bit 5 means that it kills whatever runs into it. Bit 6 is set to flag an object as killed. An object that is hit and can be moved takes on the speed along x of the object that hit it.
|
||||||||||||||||||
|
Walk the object table.
|
||||||||||||||||||
| BlockMovementInX | C497 | LD IY,$5B88 | Point IY at PlayerBottomObject. | |||||||||||||||
| C49B | LD B,$38 | Set a counter of 38 objects. | ||||||||||||||||
|
Skip unless the object is solid and already overlaps along y and z.
|
||||||||||||||||||
| BlockMovementInX_Next | C49D | CALL TestObjectSolid | Jump to BlockMovementInX_Advance if the object is not present or is ignored. | |||||||||||||||
| C4A0 | JR Z,BlockMovementInX_Advance | |||||||||||||||||
| C4A2 | CALL TestOverlapInY | Jump to BlockMovementInX_Advance if the objects do not overlap along y. | ||||||||||||||||
| C4A5 | JR NC,BlockMovementInX_Advance | |||||||||||||||||
| C4A7 | CALL TestOverlapInZ | Jump to BlockMovementInX_Advance if the objects do not overlap along z. | ||||||||||||||||
| C4AA | JR NC,BlockMovementInX_Advance | |||||||||||||||||
|
Test whether they overlap along x after the move.
|
||||||||||||||||||
| BlockMovementInX_Test | C4AC | CALL TestOverlapInX | Jump to BlockMovementInX_Advance if the objects do not overlap along x after the move. | |||||||||||||||
| C4AF | JR NC,BlockMovementInX_Advance | |||||||||||||||||
|
Flag the object as blocked along x, then apply the kill flags.
|
||||||||||||||||||
| C4B1 | SET 0,(IX+$0C) | Flag the object as blocked along x. | ||||||||||||||||
| C4B5 | LD A,(IX+$0D) | Fetch the extra flags and move the bit that it kills what it hits into bit 6. | ||||||||||||||||
| C4B8 | RRCA | |||||||||||||||||
| C4B9 | AND %01000000 | Keep the bit that flags the other object as killed. | ||||||||||||||||
| C4BB | OR (IY+$0D) | Set it in the extra flags of the other object, if the object kills what it runs into. | ||||||||||||||||
| C4BE | LD (IY+$0D),A | |||||||||||||||||
| C4C1 | RLCA | Move the bit that the other object kills what hits it into bit 6. | ||||||||||||||||
| C4C2 | AND %01000000 | Keep the bit that flags the object as killed. | ||||||||||||||||
| C4C4 | OR (IX+$0D) | Set it in the extra flags of the object, if the other object kills what runs into it. | ||||||||||||||||
| C4C7 | LD (IX+$0D),A | |||||||||||||||||
|
Pass the speed along x to the other object if it can be moved.
|
||||||||||||||||||
| C4CA | BIT 2,(IY+$07) | Jump to BlockMovementInX_Slow if the other object cannot be moved. | ||||||||||||||||
| C4CE | JR Z,BlockMovementInX_Slow | |||||||||||||||||
| C4D0 | LD A,(IX+$09) | Give the speed along x to the other object. | ||||||||||||||||
| C4D3 | LD (IY+$09),A | |||||||||||||||||
|
Slow the move along x and test this object again.
|
||||||||||||||||||
| BlockMovementInX_Slow | C4D6 | LD A,C | Fetch the speed along x. | |||||||||||||||
| C4D7 | CALL BringSpeedCloserToZero | Bring it closer to zero. | ||||||||||||||||
| C4DA | LD C,A | Store it. | ||||||||||||||||
| C4DB | RET Z | Return if the speed is now zero. | ||||||||||||||||
| C4DC | JR BlockMovementInX_Test | Jump to BlockMovementInX_Test. | ||||||||||||||||
|
Move on to the next object.
|
||||||||||||||||||
| BlockMovementInX_Advance | C4DE | LD DE,$0020 | Point IY at the next object. | |||||||||||||||
| C4E1 | ADD IY,DE | |||||||||||||||||
| C4E3 | DJNZ BlockMovementInX_Next | Jump to BlockMovementInX_Next until all of the objects have been tested. | ||||||||||||||||
| C4E5 | RET | Return. | ||||||||||||||||
|
View the equivalent code in;
|
||||||||||||||||||
| Prev: C442 | Up: Map | Next: C4E6 |