Prev: 31670 Up: Map Next: 31807
31713: 'C' pressed - use hook
The address of this routine is found in the table of keypress handling routines at 60672. It is called from the main loop at 61483 when 'C' is pressed.
31713 LD A,(32745) Collect the object inventory flags from 32745
31716 BIT 6,A Has Sam got the hook?
31718 RET Z Return if not
31719 LD A,(58884) A=Sam's z-coordinate
31722 LD HL,(58881) Collect Sam's x- and y-coordinates in L and H
31725 RRCA Is Sam's z-coordinate 1 (indoors)?
31726 JR NC,31755 Jump if not
31728 LD A,L A=x (Sam's x-coordinate)
31729 CP 222 Is Sam in no. 17 or no. 15 (x>=222)?
31731 RET NC Return if so
31732 CP 207 Is Sam in no. 19 (207<=x<222)?
31734 JR NC,31751 Jump if so
31736 CP 122 Is Sam in the police station, no. 27, or the apartments next to no. 19 (122<=x<207)?
31738 JR NC,31747 Jump if so
31740 CP 103 Is Sam in no. 31 (103<=x<122)?
31742 JR NC,31751 Jump if so
31744 CP 25 Is Sam in no. 74 or the hotel (25<=x<103)?
31746 RET NC Return if so
31747 LD A,7 7 is the y-coordinate of the roof of the police station, no. 27, and the apartment building next to no. 19
31749 JR 31753
31751 LD A,13 13 is the y-coordinate of the roofs of no. 19 and no. 31
31753 CP H Is Sam on the roof of a building?
31754 RET C Return if not
Sam is in a location that is amenable to hook-throwing.
31755 INC H H=1+Sam's y-coordinate
31756 LD A,(58880) A=Sam's animatory state
31759 AND 128 Keep only the direction bit (bit 7)
31761 JR Z,31764 Jump if Sam is facing left
31763 INC L L=1+Sam's x-coordinate
31764 ADD A,121 A=121/249 (hook)
31766 EX DE,HL DE=hook's initial coordinates
31767 LD HL,58643 Point HL at byte 19 of character buffer 229
31770 INC (HL) Is the current owner of character buffer 229 (the hook or a banknote) under the control of an uninterruptible subcommand routine?
31771 DEC (HL)
31772 RET NZ Return if so (the hook must currently be in flight, which is unlikely)
The hook will be thrown. Prepare it for launch now.
31773 INC L Initialise the distance remaining for the hook to fly (stored in byte 20 of the hook's buffer)
31774 LD (HL),20
31776 DEC L Place the address of the uninterruptible subcommand routine at 31670 into bytes 18 and 19 of the hook's buffer
31777 LD (HL),123
31779 DEC L
31780 LD (HL),182
31782 LD L,4 Set the hook's z-coordinate to 4
31784 LD (HL),L
31785 DEC L Set bit 7 of byte 3 of the hook's buffer, thus making the hook fly as fast as possible
31786 LD (HL),128
31788 DEC L Initialise the hook's x- and y-coordinates
31789 LD (HL),D
31790 DEC L
31791 LD (HL),E
31792 DEC L Initialise the hook's animatory state
31793 LD (HL),A
31794 CALL 59861 Update the hook's animatory state and location and update the SRB
31797 LD HL,32745 The object inventory flags are stored at 32745
31800 RES 6,(HL) Clear bit 6, thus removing the hook from Sam's possession
31802 LD H,230 230=Sam
31804 JP 62212 Raise Sam's arm and make a sound effect
Prev: 31670 Up: Map Next: 31807