| Routines

7A17: Check whether Sam has dialled a valid telephone number

Used by the routine at 77D3. Returns with the zero flag set if Sam has dialled a valid telephone number, and with the telephone identifier in A.
7A17 | LD HL,$6B4A | Point HL at the end of the phone number and location table at 6B00
7A1A | LD C,$0F | There are 15 entries to check
7A1C | LD DE,$7F95 | Point DE at the last digit of the phone number dialled by Sam (stored at 7F92)
7A1F | LD B,$04 | There are 4 digits in a phone number
7A21 | LD A,(DE) | A=digit of the phone number dialled by Sam
7A22 | CP (HL) | Compare it with that of a phone number in the table
7A23 | DEC HL | Point HL at the previous digit of the phone number
7A24 | DEC DE | Point DE at the previous digit dialled by Sam
7A25 | JR NZ,$7A2C | Jump if there's no match
7A27 | DJNZ $7A21 | Jump back until all 4 digits have been compared
7A29 | LD A,(HL) | A=identifier of the matching telephone
7A2A | RET | Return with the zero flag set
7A2B | DEC HL | Point HL at the first byte of the phone number entry (the telephone identifier)
7A2C | DJNZ $7A2B
7A2E | DEC HL | Point HL at the last digit of the previous phone number in the table
7A2F | DEC C | Are there any more phone numbers to check?
7A30 | JR NZ,$7A1C | Jump back if so
7A32 | AND A | Reset the zero flag
7A33 | RET |