Prev: 50643 Up: Map Next: 50707
50665: Keep Object In Room In X
Used by the routine at BlockMovement.
Brings the speed along x of an object closer to zero until the object stays within the walls of the room. Nothing is done while the object is entering the room, or while it is near an arch, as it can then go out through the wall.
Input
C Speed along x
IX The address of the object
Output
C The new speed along x
Return while entering or near an arch.
KeepObjectInRoomInX 50665 LD A,(IX+12) Fetch the collision flags.
50668 AND %11110000 Keep only bits 4-7.
50670 RET NZ Return if the object is entering the room.
50671 BIT 0,(IX+7) Return if the object is near an arch.
50675 RET NZ
50676 LD A,(23307) Fetch RoomSize_X.
50679 LD B,A Copy it to B.
Slow x until the object stays in the room.
KeepObjectInRoomInX_Test 50680 LD A,(IX+1) Fetch the x position of the object.
50683 ADD A,C Add C.
50684 SUB 128 Subtract 128.
50686 JR NC,KeepObjectInRoomInX_Compare Jump to KeepObjectInRoomInX_Compare if carry is not set.
50688 NEG Negate A.
KeepObjectInRoomInX_Compare 50690 ADD A,(IX+4) Add the width of the object.
50693 CP B Return if the object stays in the room.
50694 RET C
50695 SET 0,(IX+12) Set bit 0 of the collision flags.
50699 LD A,C Copy C to A.
50700 CALL BringSpeedCloserToZero Call BringSpeedCloserToZero.
50703 LD C,A Copy it to C.
50704 JR NZ,KeepObjectInRoomInX_Test Jump to KeepObjectInRoomInX_Test if it is not zero.
50706 RET Return.
View the equivalent code in;
Prev: 50643 Up: Map Next: 50707