Prev: 43580 Up: Map Next: 43667
43596: Handle Rope
Handler for the object type 23 which is the rope that hangs from the ceiling of a room (see Set_Up_Rope). It is the handler of record 3 while Sabreman is not holding the rope; when he grabs it the record is cleared and Handle_Sabreman_On_Rope takes over.
Each call lengthens the rope by one (the length is the word at Rope_Length) until its low seven bits reach 56 and sets bit 0 of the redraw flags so that the rope gets drawn.
If the rope is swinging (the displacement in Rope_Displacement_Pixels is not zero) the displacement moves back towards zero by 2 on each call and the counter in byte 6 of the record is set to 3. When the rope hangs straight down, the counter counts down to zero and the redraw flag is set for each count. Finally the position of the end of the rope is worked out (Position_Rope_End) and the rope is drawn (Draw_Rope).
Input
IX Object record of the rope (Rope_Record)
Make the rope longer, up to a length of 56.
Handle_Rope 43596 LD HL,(43685) Fetch the length of the rope from Rope_Length.
43599 LD A,L Copy the low byte to A.
43600 AND 127 Keep only the low seven bits.
43602 CP 56 Jump to Handle_Rope_Fetch_Displacement if the rope is already full length (the length is 56 or more).
43604 JR NC,Handle_Rope_Fetch_Displacement
43606 INC HL Add one to the length, so that the rope grows.
43607 LD (43685),HL Store the new length of the rope.
43610 SET 0,(IX+15) Set bit 0 of the redraw flags, so that the rope is drawn.
Make the swing die down.
Handle_Rope_Fetch_Displacement 43614 LD A,(43684) Fetch the displacement of the end of the rope.
43617 AND A Jump to Handle_Rope_Store_Displacement if the rope hangs straight down.
43618 JR Z,Handle_Rope_Store_Displacement
43620 LD (IX+6),3 Set the swing counter to 3.
43624 JP P,Handle_Rope_Reduce_Positive Jump to Handle_Rope_Reduce_Positive if the end of the rope is displaced to the right (the displacement is positive).
43627 INC A Add two to the displacement, which moves it back towards zero.
43628 INC A
43629 JP P,Handle_Rope_Zero_Displacement Jump to Handle_Rope_Zero_Displacement if the displacement has become zero or positive.
Handle_Rope_Store_Displacement 43632 LD (43684),A Store the displacement of the end of the rope.
43635 LD A,(IX+6) Fetch the swing counter.
43638 AND A Jump to Handle_Rope_Position_End if the swing counter is zero.
43639 JR Z,Handle_Rope_Position_End
43641 DEC (IX+6) Decrease the swing counter.
43644 SET 0,(IX+15) Set bit 0 of the redraw flags, so that the rope is drawn.
Handle_Rope_Position_End 43648 CALL Position_Rope_End Work out the position of the end of the rope.
43651 JP Draw_Rope Jump to Draw_Rope to draw the rope.
Handle_Rope_Zero_Displacement 43654 XOR A Set the displacement to zero, so that the rope hangs straight down.
43655 LD (43684),A
43658 JR Handle_Rope_Store_Displacement Jump to Handle_Rope_Store_Displacement.
Handle_Rope_Reduce_Positive 43660 DEC A Subtract two from the displacement, which moves it back towards zero.
43661 DEC A
43662 JP M,Handle_Rope_Zero_Displacement Jump to Handle_Rope_Zero_Displacement if the displacement has become negative.
43665 JR Handle_Rope_Store_Displacement Jump to Handle_Rope_Store_Displacement.
Prev: 43580 Up: Map Next: 43667