Prev: 76FA Up: Map Next: 776E
772F: Check whether a character can answer the telephone that Sam is calling
Used by the routine at 77D3. Returns with the carry flag set if the telephone that Sam is calling is both off-screen and not his own, or if there is a character close enough to the telephone to pick it up.
772F LD HL,$7F9A 7F9A holds the identifier of the telephone that Sam is calling
7732 LD A,(HL) Pick this up in A
7733 AND $1F E=x-coordinate of the leftmost column of the 8-tile-wide segment of the play area that contains the telephone (0, 8, 16,...248)
7735 ADD A,A
7736 ADD A,A
7737 ADD A,A
7738 LD E,A
7739 LD A,(HL) A=telephone identifier
773A CP $5C Is Sam calling his office?
773C JR Z,$774A Jump if so
773E LD A,E A=telephone's x-coordinate (0, 8, 16,...248)
773F LD L,$FE HL=7FFE, which holds the leftmost column of the play area on screen
7741 CP (HL) Is the telephone that Sam is calling off screen to the left?
7742 RET C Return with the carry flag set if so
7743 SUB $20 Does the telephone that Sam is calling have an x-coordinate that is less than 32?
7745 JR C,$774A Jump if so (it's on screen)
7747 CP (HL) Is the telephone that Sam is calling off screen to the right?
7748 CCF Return with the carry flag set if so
7749 RET C
Sam has called his office, or a telephone that is on screen. In this case, Sam will get an answer only if another character is close to the telephone.
774A LD L,$9A Collect the telephone identifier from 7F9A
774C LD A,(HL)
774D AND $E0 D=y-coordinate of the telephone (7, 13, 19, 25 or 31)
774F RRCA
7750 RRCA
7751 RRCA
7752 LD D,A
7753 RRCA
7754 ADD A,D
7755 ADD A,$07
7757 LD D,A
7758 LD HL,$D702 Point HL at byte 0x02 of character buffer 0xD7
775B LD B,$0F We will check the locations of characters 0xD7-0xE5
775D LD A,(HL) A=character's y-coordinate
775E CP D Does it match that of the telephone?
775F JR NZ,$7769 Jump to consider the next character if not
7761 DEC L L=0x01
7762 LD A,(HL) A=character's x-coordinate
7763 INC L L=0x02
7764 AND $F8 Set the zero flag if the character is in the same 8-tile-wide segment of the play area as the telephone
7766 CP E
7767 SCF Set the carry flag
7768 RET Z Return with the carry flag set if the character is close to the telephone
7769 INC H Next character
776A DJNZ $775D Jump back until every character has been checked
776C AND A Reset the carry flag (there is no one close to the telephone)
776D RET
Prev: 76FA Up: Map Next: 776E