Prev: C5E9 Up: Map Next: C63D
C613: 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 C613 LD A,(IX+$0C) Fetch the collision flags.
C616 AND %11110000 Keep only bits 4-7.
C618 RET NZ Return if the object is entering the room.
C619 BIT 0,(IX+$07) Return if the object is near an arch.
C61D RET NZ
C61E LD A,($5B0C) Fetch RoomSize_Y.
C621 LD B,A Copy it to B.
Slow y until the object stays in the room.
KeepObjectInRoomInY_Test C622 LD A,(IX+$02) Fetch the y position of the object.
C625 ADD A,L Add L.
C626 SUB $80 Subtract 80.
C628 JR NC,KeepObjectInRoomInY_Compare Jump to KeepObjectInRoomInY_Compare if carry is not set.
C62A NEG Negate A.
KeepObjectInRoomInY_Compare C62C ADD A,(IX+$05) Add the depth of the object.
C62F CP B Return if the object stays in the room.
C630 RET C
C631 SET 1,(IX+$0C) Set bit 1 of the collision flags.
C635 LD A,L Copy L to A.
C636 CALL BringSpeedCloserToZero Call BringSpeedCloserToZero.
C639 LD L,A Copy it to L.
C63A JR NZ,KeepObjectInRoomInY_Test Jump to KeepObjectInRoomInY_Test if it is not zero.
C63C RET Return.
View the equivalent code in;
Prev: C5E9 Up: Map Next: C63D