Prev: 77A2 Up: Map Next: 77D3
77A3: Check whether there is a telephone message for Sam
Used by the routine at 77D3. On entry, A holds the identifier of either the telephone that Sam is holding (which was ringing when he picked it up), or the telephone that Sam is calling. If there is a message for Sam, it will be queued unless Sam needs to identify himself first, in which case message 0x25 ('A VOICE SAID 'WHO'S THERE?'') will be queued instead. If there is no message for Sam, the message that is queued will depend on who Sam is calling (Daisy, the police, or someone else).
Input
A Telephone identifier (see 6B00)
HL 6B4B or 6B72
77A3 LD E,A E=telephone identifier
77A4 CALL $76EA Is the telephone ringing, or does the person on the other end have a message for Sam?
77A7 JR C,$77AE Jump if not
77A9 INC HL Point HL at the second byte of the entry in the phone table
77AA LD A,(HL) Pick this up in A
77AB AND A Does Sam need to identify himself in order to receive the message?
77AC JR Z,$7793 Jump if not to queue the message
77AE LD ($7F97),HL Store at 7F97 the address of either the second byte of the relevant phone table entry (if the phone was ringing, or the person Sam's calling has a message for him), or the final byte of the phone message table at 6B72 (if the person Sam's calling has no message for him)
77B1 JP NC,$75F6 Jump if Sam must be asked to identify himself
77B4 LD A,E A=telephone identifier
77B5 CP $5C 0x5C is the identifier of Sam's telephone
77B7 LD A,$32 Message 0x32: 'DAISY SAID 'NO MESSAGES SAM ''
77B9 JR Z,$77D0 Jump if Sam called his office
77BB LD A,E A=telephone identifier
77BC CP $70 0x70 is the identifier of the telephone in the police station
77BE JR NZ,$77C7 Jump unless Sam called the police
77C0 CALL $7A04 Send the police after Sam
77C3 LD A,$33 Message 0x33: 'A VOICE SAID 'OK CRUISE WE'RE COMING''
77C5 JR $77D0 Queue this message
77C7 CALL $F17F Get a random number in A
77CA AND $03 Keep only bits 0 and 1
77CC JR Z,$77B1 Jump if the result is 0 (25% of the time): ask Sam 'WHO'S THERE?'
77CE ADD A,$2A A=0x2B (A VOICE SAID 'THERES NOONE HERE'), 0x2C (A VOICE SAID 'GET LOST - I'M TRYING TO SLEEP') or 0x2D (A VOICE SAID 'BE RIGHT WITH YOU')
77D0 JP $7799 Queue this message
Prev: 77A2 Up: Map Next: 77D3