| Routines

30575: Deal with Sam when he's on the phone and has been asked 'WHO'S THERE?'

Used by the routine at 30675. Waits for a keypress, and then queues message 40 (''{name}' I SAID ') followed by either message 46 ('I DUNNO NO {name}') or the message Sam is supposed to receive upon giving the correct name.
30575 | CALL 61923 | Check for keypresses or hang up the phone
30578 | RET Z | Return if no key with an ASCII code in the range 48-127 was pressed
30579 | CP 97 | Is the ASCII code of the keypress less than 97 ('a')?
30581 | RET C | Return if so
30582 | CP 104 | Is the ASCII code of the keypress less than 104 ('h')?
30584 | JR C,30591 | Jump if so
30586 | CP 115 | Was 's' pressed?
30588 | RET NZ | Return if not
30589 | SUB 11 | A=104
30591 | ADD A,7 | A=104-111 (message number of a name)
30593 | LD (32720),A | Store this at 32720
30596 | PUSH AF | Save the name message number briefly
30597 | LD A,40 | Message 40: ''{name}' I SAID '
30599 | CALL 30154 | Queue this message urgently
30602 | LD HL,(32663) | Collect from 32663 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 27506 (if the person Sam's calling has no message for him); the final byte of the phone message table is 255, which does not match the message number of any name
30605 | POP AF | Restore the name message number to A
30606 | CP (HL) | Set the zero flag if Sam has used the correct name
30607 | LD A,46 | Message 46: 'I DUNNO NO {name}'
30609 | JR NZ,30617 | Jump unless Sam has used the correct name
This entry point is used by the routine at 30627.
30611 | DEC HL | Point HL at the first byte of the phone entry
30612 | LD (HL),0 | Mark the phone entry inactive
30614 | INC HL | Point HL at the third byte of the phone entry
30615 | INC HL
30616 | LD A,(HL) | A=telephone message number
This entry point is used by the routines at 30627 (with A=43, 44, 45 or 50) and 30675 (with A=47).
30617 | LD HL,512 | Clear 32666 and set bit 1 of the telephone call status flags at 32667 (to disconnect the call)
30620 | LD (32666),HL
30623 | JP 30154 | Queue the telephone message urgently