Prev: 31642 Up: Map Next: 31713
31670: Control the hook while it's flying
The address of this uninterruptible subcommand routine is placed into bytes 18 and 19 of the hook's buffer by the routine at 31713. It controls the hook until the end of its flight, at which point it places a rope above the roof of no. 19 if necessary, or else restores the hook to its original location on the top floor of no. 74.
Input
H 229 (hook)
31670 CALL 59848 Update the SRB for the hook's current animatory state and location
31673 LD L,20 Byte 20 of the hook's buffer holds the distance remaining in the hook's flight
31675 DEC (HL) Decrease this by 1
31676 JR Z,31688 Jump if the hook's flight has ended
31678 RLCA Set the carry flag if the hook is flying rightwards
31679 RRCA
31680 DEC E Decrement the hook's x-coordinate
31681 JR NC,31685 Jump if the hook is flying leftwards
31683 INC E Otherwise increment the hook's x-coordinate
31684 INC E
31685 JP NZ,59861 Update the hook's animatory state and location and update the SRB (unless the hook has flown off the edge of the play area)
The hook's flight has ended (either naturally or by escaping the play area). Check whether it reached the roof of no. 17.
31688 DEC L L=19
31689 XOR A Remove the address of this routine from bytes 18 and 19 of the hook's buffer
31690 LD (HL),A
31691 LD L,3 Clear all flags in byte 3 of the hook's buffer
31693 LD (HL),A
31694 DEC L Set the hook's y-coordinate to 50 (out of sight)
31695 LD (HL),50
31697 LD A,D A=hook's y-coordinate while it was flying
31698 CP 9 Was it greater than 9?
31700 JR NC,31708 Jump if so
31702 LD A,E A=x-coordinate of the hook at the end of its flight
31703 CP 223 Did the hook reach the roof of no. 17?
31705 JP NC,64549 Jump if so
31708 LD HL,32028 Reactivate the entry for the hook in the object table at 32028
31711 DEC (HL)
31712 RET
Prev: 31642 Up: Map Next: 31713