![]() |
Routines |
| Prev: CB29 | Up: Map | Next: CB9A |
|
Used by the routines at ApplyGravityAndMove and MovePlayer.
Stops an object moving through the walls of the room or through other objects. The speeds in X, Y and Z of the object are each brought closer to zero until the object can move without hitting anything. Whichever direction is hit is flagged in the low bits of the flags in byte 0C of the object: bit 0 for X, bit 1 for Y and bit 2 for Z. For the Z direction that means that the object is standing on something. An object that is flagged to be ignored in the 3D calculations is not adjusted.
|
||||||||
| BlockMovement | CB45 | BIT 1,(IX+$07) | Test whether the object is flagged to be ignored. | |||||
| CB49 | RET NZ | Return if it is. | ||||||
| CB4A | SET 1,(IX+$07) | Flag the object to be ignored, so that it does not hit itself. | ||||||
| CB4E | LD A,(IX+$0C) | Fetch the flags. | ||||||
| CB51 | AND %11111000 | Clear the blocked flags of X, Y and Z. | ||||||
| CB53 | LD (IX+$0C),A | Store the flags. | ||||||
| CB56 | LD L,$00 | Set the new speed in Y to zero. | ||||||
| CB58 | LD C,L | Set the new speed in X to zero. | ||||||
|
The new speeds are kept in H for Z, C for X and L for Y. The Z direction goes first, and the floor of the room is tried before the objects.
|
||||||||
| CB59 | LD A,(IX+$0B) | Fetch the speed in Z. | ||||||
| CB5C | AND A | Test whether it is zero. | ||||||
| CB5D | LD H,A | Stash it in H. | ||||||
| CB5E | JR Z,BlockMovement_X | Jump to BlockMovement_X if it is zero. | ||||||
| CB60 | CALL StopObjectAtFloor | Stop the object going through the floor. | ||||||
| CB63 | LD A,H | Test whether the speed in Z is now zero. | ||||||
| CB64 | AND A | |||||||
| CB65 | JR Z,BlockMovement_X | Jump to BlockMovement_X if it is. | ||||||
| CB67 | CALL BlockMovementInZ | Stop the object going through other objects. | ||||||
| BlockMovement_X | CB6A | LD A,(IX+$09) | Fetch the speed in X and test whether it is zero. | |||||
| CB6D | AND A | |||||||
| CB6E | LD C,A | Stash it in C. | ||||||
| CB6F | JR Z,BlockMovement_Y | Jump to BlockMovement_Y if it is zero. | ||||||
| CB71 | CALL KeepObjectInRoomInX | Stop the object going through the walls of the room. | ||||||
| CB74 | LD A,C | Test whether the speed in X is now zero. | ||||||
| CB75 | AND A | |||||||
| CB76 | JR Z,BlockMovement_Y | Jump to BlockMovement_Y if it is. | ||||||
| CB78 | CALL BlockMovementInX | Stop the object going through other objects. | ||||||
| BlockMovement_Y | CB7B | LD A,(IX+$0A) | Fetch the speed in Y and test whether it is zero. | |||||
| CB7E | AND A | |||||||
| CB7F | LD L,A | Stash it in L. | ||||||
| CB80 | JR Z,BlockMovement_Store | Jump to BlockMovement_Store if it is zero. | ||||||
| CB82 | CALL KeepObjectInRoomInY | Stop the object going through the walls of the room. | ||||||
| CB85 | LD A,L | Test whether the speed in Y is now zero. | ||||||
| CB86 | AND A | |||||||
| CB87 | JR Z,BlockMovement_Store | Jump to BlockMovement_Store if it is. | ||||||
| CB89 | CALL BlockMovementInY | Stop the object going through other objects. | ||||||
| BlockMovement_Store | CB8C | LD (IX+$09),C | Store the new speed in X. | |||||
| CB8F | LD (IX+$0A),L | Store the new speed in Y. | ||||||
| CB92 | LD (IX+$0B),H | Store the new speed in Z. | ||||||
| CB95 | RES 1,(IX+$07) | Stop ignoring the object. | ||||||
| CB99 | RET | Return. | ||||||
| Prev: CB29 | Up: Map | Next: CB9A |