Prev: 50665 Up: Map Next: 50749
50707: Keep Object In Room In Y
Used by the routine at BlockMovement.
Brings the speed along y 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
L Speed along y
IX The address of the object
Output
L The new speed along y
Return while entering or near an arch.
KeepObjectInRoomInY 50707 LD A,(IX+12) Fetch the collision flags.
50710 AND %11110000 Keep only bits 4-7.
50712 RET NZ Return if the object is entering the room.
50713 BIT 0,(IX+7) Return if the object is near an arch.
50717 RET NZ
50718 LD A,(23308) Fetch RoomSize_Y.
50721 LD B,A Copy it to B.
Slow y until the object stays in the room.
KeepObjectInRoomInY_Test 50722 LD A,(IX+2) Fetch the y position of the object.
50725 ADD A,L Add L.
50726 SUB 128 Subtract 128.
50728 JR NC,KeepObjectInRoomInY_Compare Jump to KeepObjectInRoomInY_Compare if carry is not set.
50730 NEG Negate A.
KeepObjectInRoomInY_Compare 50732 ADD A,(IX+5) Add the depth of the object.
50735 CP B Return if the object stays in the room.
50736 RET C
50737 SET 1,(IX+12) Set bit 1 of the collision flags.
50741 LD A,L Copy L to A.
50742 CALL BringSpeedCloserToZero Call BringSpeedCloserToZero.
50745 LD L,A Copy it to L.
50746 JR NZ,KeepObjectInRoomInY_Test Jump to KeepObjectInRoomInY_Test if it is not zero.
50748 RET Return.
View the equivalent code in;
Prev: 50665 Up: Map Next: 50749