![]() |
Routines |
| Prev: 46813 | Up: Map | Next: 46914 |
|
Used by the routines at ApplyGravityAndMove and MovePlayer.
Stops an object moving through the walls of the room or through other objects. The speeds along 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 collision flags: bit 0 for x, bit 1 for y and bit 2 for z. For z that means the object is standing on something. An object that is flagged to be ignored is not adjusted.
|
||||||||
|
Ignore the object so that it does not hit itself, and clear the blocked flags.
|
||||||||
| BlockMovement | 46829 | BIT 1,(IX+7) | Return if the object is already being moved. | |||||
| 46833 | RET NZ | |||||||
| 46834 | SET 1,(IX+7) | Flag that the object is being moved. | ||||||
| 46838 | LD A,(IX+12) | Fetch the collision flags. | ||||||
| 46841 | AND %11111000 | Clear the blocked flags of x, y and z. | ||||||
| 46843 | LD (IX+12),A | Store the collision flags. | ||||||
| 46846 | LD L,0 | Start with no speed along y in L and none along x in C. | ||||||
| 46848 | LD C,L | |||||||
|
The new speeds are kept in H for z, C for x and L for y. Test z against the floor, then other objects.
|
||||||||
| 46849 | LD A,(IX+11) | Fetch the speed along z and test whether it is zero. | ||||||
| 46852 | AND A | |||||||
| 46853 | LD H,A | Copy it to H. | ||||||
| 46854 | JR Z,BlockMovement_X | Jump to BlockMovement_X if it is zero. | ||||||
| 46856 | CALL StopObjectAtFloor | Call StopObjectAtFloor to cut the speed down so that the object stays above the floor. | ||||||
| 46859 | LD A,H | Jump to BlockMovement_X if that has left no speed. | ||||||
| 46860 | AND A | |||||||
| 46861 | JR Z,BlockMovement_X | |||||||
| 46863 | CALL BlockMovementInZ | Call BlockMovementInZ to cut the speed down so that the object does not go through another object. | ||||||
|
Test x against the walls of the room, then other objects.
|
||||||||
| BlockMovement_X | 46866 | LD A,(IX+9) | Fetch the speed along x and test whether it is zero. | |||||
| 46869 | AND A | |||||||
| 46870 | LD C,A | Copy it to C. | ||||||
| 46871 | JR Z,BlockMovement_Y | Jump to BlockMovement_Y if it is zero. | ||||||
| 46873 | CALL KeepObjectInRoomInX | Call KeepObjectInRoomInX to cut the speed down so that the object stays inside the walls. | ||||||
| 46876 | LD A,C | Jump to BlockMovement_Y if that has left no speed. | ||||||
| 46877 | AND A | |||||||
| 46878 | JR Z,BlockMovement_Y | |||||||
| 46880 | CALL BlockMovementInX | Call BlockMovementInX to cut the speed down so that the object does not go through another object. | ||||||
|
Test y against the walls of the room, then other objects.
|
||||||||
| BlockMovement_Y | 46883 | LD A,(IX+10) | Fetch the speed along y and test whether it is zero. | |||||
| 46886 | AND A | |||||||
| 46887 | LD L,A | Copy it to L. | ||||||
| 46888 | JR Z,BlockMovement_Store | Jump to BlockMovement_Store if it is zero. | ||||||
| 46890 | CALL KeepObjectInRoomInY | Call KeepObjectInRoomInY to cut the speed down so that the object stays inside the walls. | ||||||
| 46893 | LD A,L | Jump to BlockMovement_Store if that has left no speed. | ||||||
| 46894 | AND A | |||||||
| 46895 | JR Z,BlockMovement_Store | |||||||
| 46897 | CALL BlockMovementInY | Call BlockMovementInY to cut the speed down so that the object does not go through another object. | ||||||
|
Store the new speeds and stop ignoring the object.
|
||||||||
| BlockMovement_Store | 46900 | LD (IX+9),C | Store the new speeds along x, y and z. | |||||
| 46903 | LD (IX+10),L | |||||||
| 46906 | LD (IX+11),H | |||||||
| 46909 | RES 1,(IX+7) | Flag that the object is not being moved. | ||||||
| 46913 | RET | Return. | ||||||
|
View the equivalent code in;
|
||||||||
| Prev: 46813 | Up: Map | Next: 46914 |