Prev: 52445 Up: Map Next: 52531
52488: 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 52488 LD A,(IX+12) Fetch the flags of the object.
52491 AND %11110000 Keep the counter of the object entering the room.
52493 RET NZ Return if the object is entering the room.
52494 BIT 0,(IX+7) Test whether the object is near an arch.
52498 RET NZ Return if it is.
52499 LD A,(23468) Fetch the size of the room in Y and stash it in B from RoomSizeY.
52502 LD B,A
KeepObjectInRoomInY_Test 52503 LD A,(IX+2) Work out where the Y coordinate would be, with the speed added.
52506 ADD A,L
52507 SUB 128
52509 JR NC,KeepObjectInRoomInY_Test_AddDepth Jump to KeepObjectInRoomInY_Test_AddDepth if it is not negative.
52511 NEG Make it positive.
KeepObjectInRoomInY_Test_AddDepth 52513 ADD A,(IX+5) Add the depth of the object.
52516 CP B Compare it with the size of the room.
52517 JR C,KeepObjectInRoomInY_Test_Return Return if it is smaller, as the object stays in the room.
52519 SET 1,(IX+12) Flag the object as blocked in Y.
52523 LD A,L Fetch the speed in Y.
52524 CALL BringSpeedCloserToZero Bring it closer to zero.
52527 LD L,A Store it.
52528 JR NZ,KeepObjectInRoomInY_Test Jump to KeepObjectInRoomInY_Test if it is not zero yet.
KeepObjectInRoomInY_Test_Return 52530 RET Return.
View the equivalent code in;
Prev: 52445 Up: Map Next: 52531