Prev: CCDD Up: Map Next: CD33
CD08: Keep Object In Room In Y
Used by the routine at BlockMovement.
Brings the speed in 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 in Y
IX Address of the object
Output
L The new speed in Y
Slow the Y speed until the object stays inside the walls.
KeepObjectInRoomInY CD08 LD A,(IX+$0C) Fetch the flags of the object.
CD0B AND %11110000 Keep the counter of the object entering the room.
CD0D RET NZ Return if the object is entering the room.
CD0E BIT 0,(IX+$07) Test whether the object is near an arch.
CD12 RET NZ Return if it is.
CD13 LD A,($5BAC) Fetch the size of the room in Y and stash it in B from RoomSizeY.
CD16 LD B,A
KeepObjectInRoomInY_Test CD17 LD A,(IX+$02) Work out where the Y coordinate would be, with the speed added.
CD1A ADD A,L
CD1B SUB $80
CD1D JR NC,KeepObjectInRoomInY_Test_AddDepth Jump to KeepObjectInRoomInY_Test_AddDepth if it is not negative.
CD1F NEG Make it positive.
KeepObjectInRoomInY_Test_AddDepth CD21 ADD A,(IX+$05) Add the depth of the object.
CD24 CP B Compare it with the size of the room.
CD25 JR C,KeepObjectInRoomInY_Test_Return Return if it is smaller, as the object stays in the room.
CD27 SET 1,(IX+$0C) Flag the object as blocked in Y.
CD2B LD A,L Fetch the speed in Y.
CD2C CALL BringSpeedCloserToZero Bring it closer to zero.
CD2F LD L,A Store it.
CD30 JR NZ,KeepObjectInRoomInY_Test Jump to KeepObjectInRoomInY_Test if it is not zero yet.
KeepObjectInRoomInY_Test_Return CD32 RET Return.
View the equivalent code in;
Prev: CCDD Up: Map Next: CD33