Prev: 7B9A Up: Map Next: 7BE1
7BB6: Control the hook while it's flying
The address of this uninterruptible subcommand routine is placed into bytes 0x12 and 0x13 of the hook's buffer by the routine at 7BE1. 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 0xE5 (hook)
7BB6 CALL $E9C8 Update the SRB for the hook's current animatory state and location
7BB9 LD L,$14 Byte 0x14 of the hook's buffer holds the distance remaining in the hook's flight
7BBB DEC (HL) Decrease this by 1
7BBC JR Z,$7BC8 Jump if the hook's flight has ended
7BBE RLCA Set the carry flag if the hook is flying rightwards
7BBF RRCA
7BC0 DEC E Decrement the hook's x-coordinate
7BC1 JR NC,$7BC5 Jump if the hook is flying leftwards
7BC3 INC E Otherwise increment the hook's x-coordinate
7BC4 INC E
7BC5 JP NZ,$E9D5 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.
7BC8 DEC L L=0x13
7BC9 XOR A Remove the address of this routine from bytes 0x12 and 0x13 of the hook's buffer
7BCA LD (HL),A
7BCB LD L,$03 Clear all flags in byte 0x03 of the hook's buffer
7BCD LD (HL),A
7BCE DEC L Set the hook's y-coordinate to 50 (out of sight)
7BCF LD (HL),$32
7BD1 LD A,D A=hook's y-coordinate while it was flying
7BD2 CP $09 Was it greater than 9?
7BD4 JR NC,$7BDC Jump if so
7BD6 LD A,E A=x-coordinate of the hook at the end of its flight
7BD7 CP $DF Did the hook reach the roof of no. 17?
7BD9 JP NC,$FC25 Jump if so
7BDC LD HL,$7D1C Reactivate the entry for the hook in the object table at 7D1C
7BDF DEC (HL)
7BE0 RET
Prev: 7B9A Up: Map Next: 7BE1