Prev: AA3C Up: Map Next: AA93
AA4C: Handle Rope
Handler for the object type 17 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 38 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 02 on each call and the counter in byte 06 of the record is set to 03. 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 38.
Handle_Rope AA4C LD HL,($AAA5) Fetch the length of the rope from Rope_Length.
AA4F LD A,L Copy the low byte to A.
AA50 AND $7F Keep only the low seven bits.
AA52 CP $38 Jump to Handle_Rope_Fetch_Displacement if the rope is already full length (the length is 38 or more).
AA54 JR NC,Handle_Rope_Fetch_Displacement
AA56 INC HL Add one to the length, so that the rope grows.
AA57 LD ($AAA5),HL Store the new length of the rope.
AA5A SET 0,(IX+$0F) Set bit 0 of the redraw flags, so that the rope is drawn.
Make the swing die down.
Handle_Rope_Fetch_Displacement AA5E LD A,($AAA4) Fetch the displacement of the end of the rope.
AA61 AND A Jump to Handle_Rope_Store_Displacement if the rope hangs straight down.
AA62 JR Z,Handle_Rope_Store_Displacement
AA64 LD (IX+$06),$03 Set the swing counter to 03.
AA68 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).
AA6B INC A Add two to the displacement, which moves it back towards zero.
AA6C INC A
AA6D JP P,Handle_Rope_Zero_Displacement Jump to Handle_Rope_Zero_Displacement if the displacement has become zero or positive.
Handle_Rope_Store_Displacement AA70 LD ($AAA4),A Store the displacement of the end of the rope.
AA73 LD A,(IX+$06) Fetch the swing counter.
AA76 AND A Jump to Handle_Rope_Position_End if the swing counter is zero.
AA77 JR Z,Handle_Rope_Position_End
AA79 DEC (IX+$06) Decrease the swing counter.
AA7C SET 0,(IX+$0F) Set bit 0 of the redraw flags, so that the rope is drawn.
Handle_Rope_Position_End AA80 CALL Position_Rope_End Work out the position of the end of the rope.
AA83 JP Draw_Rope Jump to Draw_Rope to draw the rope.
Handle_Rope_Zero_Displacement AA86 XOR A Set the displacement to zero, so that the rope hangs straight down.
AA87 LD ($AAA4),A
AA8A JR Handle_Rope_Store_Displacement Jump to Handle_Rope_Store_Displacement.
Handle_Rope_Reduce_Positive AA8C DEC A Subtract two from the displacement, which moves it back towards zero.
AA8D DEC A
AA8E JP M,Handle_Rope_Zero_Displacement Jump to Handle_Rope_Zero_Displacement if the displacement has become negative.
AA91 JR Handle_Rope_Store_Displacement Jump to Handle_Rope_Store_Displacement.
Prev: AA3C Up: Map Next: AA93