![]() |
Routines |
| Prev: 46993 | Up: Map | Next: 47206 |
|
Used by the routine at BlockMovement.
Cuts down the distance that an object moves along z until it does not go through any other object. A hit along z means that the object has landed on the other one (or has bumped its head on it), so the routine also deals with the things that are done to an object that is stood on.
When an object is stopped, the two objects share their hit flags, the one underneath is marked as being stood on, and an object that can be pushed is carried along: it takes the speeds of the object it is on.
|
||||||||||||||
|
Try the object against each of the objects in turn.
|
||||||||||||||
| BlockMovementInZ | 47072 | LD IY,42863 | Start with the first object record, ObjectsTable. | |||||||||||
| 47076 | LD B,54 | Set a counter in B of 54 objects. | ||||||||||||
| BlockMovementInZ_Next | 47078 | CALL TestObjectSolid | Jump to BlockMovementInZ_NextObject if the other object is not in use, or is being moved. | |||||||||||
| 47081 | JR Z,BlockMovementInZ_NextObject | |||||||||||||
| 47083 | CALL TestOverlapInX | Jump to BlockMovementInZ_NextObject if the objects do not overlap along x. | ||||||||||||
| 47086 | JR NC,BlockMovementInZ_NextObject | |||||||||||||
| 47088 | CALL TestOverlapInY | Jump to BlockMovementInZ_NextObject if the objects do not overlap along y. | ||||||||||||
| 47091 | JR NC,BlockMovementInZ_NextObject | |||||||||||||
| BlockMovementInZ_Test | 47093 | CALL TestOverlapInZ | Jump to BlockMovementInZ_NextObject if the objects will not overlap along z when the object has moved. | |||||||||||
| 47096 | JR NC,BlockMovementInZ_NextObject | |||||||||||||
|
The objects hit each other. Flag a hit along z, which also means the object is on the ground.
|
||||||||||||||
| 47098 | SET 2,(IX+12) | Flag that the object has been stopped along z. | ||||||||||||
| 47102 | CALL MarkObjectBelow | Call MarkObjectBelow to flag the other object if the object is a part of the player or a block of type 91. | ||||||||||||
|
Flag the object if it is standing on the player.
|
||||||||||||||
| 47105 | LD A,(IY+0) | Fetch the type of the other object. | ||||||||||||
| 47108 | CP 32 | Jump to BlockMovementInZ_Block if it is below 32, the first part of the player. | ||||||||||||
| 47110 | JR C,BlockMovementInZ_Block | |||||||||||||
| 47112 | CP 40 | Jump to BlockMovementInZ_Block if it is 40 or more, which is not a part of the player. | ||||||||||||
| 47114 | JR NC,BlockMovementInZ_Block | |||||||||||||
| 47116 | SET 7,(IX+23) | Flag that the object is on the player. | ||||||||||||
|
An object that stands on a moving block is pushed by it.
|
||||||||||||||
| BlockMovementInZ_Block | 47120 | CP 140 | Jump to BlockMovementInZ_HitFlags if the other object is below 140, the first of the moving blocks. | |||||||||||
| 47122 | JR C,BlockMovementInZ_HitFlags | |||||||||||||
| 47124 | CP 144 | Call PushObjectOnBlock to push the object if the other object is a moving block, which is when it is below 144. | ||||||||||||
| 47126 | CALL C,PushObjectOnBlock | |||||||||||||
|
Pass on the hit flags, and flag that the other object has something on it.
|
||||||||||||||
| BlockMovementInZ_HitFlags | 47129 | LD A,(IX+13) | Fetch the hit flags of the object. | |||||||||||
| 47132 | RRCA | Move bit 7 down to bit 6. | ||||||||||||
| 47133 | AND %01000000 | Keep only bit 6. | ||||||||||||
| 47135 | OR (IY+13) | Add the hit flags of the other object. | ||||||||||||
| 47138 | LD (IY+13),A | Write them to the other object. | ||||||||||||
| 47141 | RLCA | Move bit 5 of the hit flags of the other object up to bit 6. | ||||||||||||
| 47142 | AND %01000000 | Keep only bit 6. | ||||||||||||
| 47144 | OR (IX+13) | Add the hit flags of the object. | ||||||||||||
| 47147 | LD (IX+13),A | Write them to the object. | ||||||||||||
| 47150 | SET 3,(IY+13) | Flag that the other object has something on it. | ||||||||||||
|
Carry an object that can be pushed. It takes the speed along z of the object, and the speeds along x and y if it has none.
|
||||||||||||||
| 47154 | BIT 2,(IX+7) | Jump to BlockMovementInZ_Reduce if the object cannot be pushed. | ||||||||||||
| 47158 | JR Z,BlockMovementInZ_Reduce | |||||||||||||
| 47160 | LD A,(IX+11) | Give the other object the speed along z of the object. | ||||||||||||
| 47163 | LD (IY+11),A | |||||||||||||
| 47166 | LD A,(IX+9) | Jump to BlockMovementInZ_CarryY if the object is moving along x. | ||||||||||||
| 47169 | AND A | |||||||||||||
| 47170 | JR NZ,BlockMovementInZ_CarryY | |||||||||||||
| 47172 | LD A,(IY+9) | Give the object the speed along x of the other object. | ||||||||||||
| 47175 | LD (IX+9),A | |||||||||||||
| BlockMovementInZ_CarryY | 47178 | LD A,(IX+10) | Jump to BlockMovementInZ_Reduce if the object is moving along y. | |||||||||||
| 47181 | AND A | |||||||||||||
| 47182 | JR NZ,BlockMovementInZ_Reduce | |||||||||||||
| 47184 | LD A,(IY+10) | Give the object the speed along y of the other object. | ||||||||||||
| 47187 | LD (IX+10),A | |||||||||||||
|
Step the distance closer to zero while the objects still overlap.
|
||||||||||||||
| BlockMovementInZ_Reduce | 47190 | LD A,H | Fetch the distance along z. | |||||||||||
| 47191 | CALL BringSpeedCloserToZero | Call BringSpeedCloserToZero to step it one closer to zero. | ||||||||||||
| 47194 | LD H,A | Set the distance. | ||||||||||||
| 47195 | RET Z | Return if the distance is zero. | ||||||||||||
| 47196 | JR BlockMovementInZ_Test | Jump to BlockMovementInZ_Test to test again. | ||||||||||||
| BlockMovementInZ_NextObject | 47198 | LD DE,32 | Move IY on to the next object record. | |||||||||||
| 47201 | ADD IY,DE | |||||||||||||
| 47203 | DJNZ BlockMovementInZ_Next | Decrease the counter and loop until all the objects have been tried. | ||||||||||||
| 47205 | RET | Return. | ||||||||||||
| Prev: 46993 | Up: Map | Next: 47206 |