Prev: 00461 Up: Map Next: 00685
00543: Parse Speech String
Used by the routine at HandleInterrupt.
Expand the contents of s$ into the allophone buffer. A leading "*" or "?" means the string has already been spoken.
Input
HL Pointer to s$
Read the length of s$ and ignore an empty string.
ParseSpeechString 00543 INC HL Fetch the low length byte of s$.
00544 LD E,(HL)
00545 XOR A Test whether the low length byte is zero.
00546 CP (HL)
00547 INC HL Fetch the high length byte of s$.
00548 LD D,(HL)
00549 JR NZ,ParseSpeechString_Body Jump to ParseSpeechString_Body if the low length byte is non-zero.
00551 CP (HL) Return if s$ is empty.
00552 RET Z
Leave strings that have already been spoken.
ParseSpeechString_Body 00553 INC HL Move to the first character.
00554 LD A,42 Return if s$ starts with "*".
00556 CP (HL)
00557 RET Z
00558 LD A,63 Return if s$ starts with "?".
00560 CP (HL)
00561 RET Z
00562 DEC HL Move back to the length.
00563 PUSH HL Stash the start of s$ on the stack.
00564 ADD HL,DE Point DE at the end of s$.
00565 EX DE,HL
00566 POP HL Restore the start of s$ from the stack.
00567 CALL ReadBufferPointer Call ReadBufferPointer.
Convert the next character of s$ into allophones.
ParseSpeechString_Next 00570 PUSH BC Stash the buffer pointer on the stack.
00571 INC HL Fetch the next character from s$.
00572 LD A,(HL)
00573 CALL NormaliseCharacter Call NormaliseCharacter.
00576 CP 14 Jump to ParseSpeechString_TestGroup if this is not a full stop.
00578 JR NZ,ParseSpeechString_TestGroup
00580 LD A,4 Queue a short pause.
00582 POP BC Restore the buffer pointer from the stack.
00583 LD (BC),A Write the pause to the speech buffer.
00584 DEC BC
00585 CALL CheckMemory Call CheckMemory and return if the buffer is full.
00588 RET C
00589 PUSH BC Stash the buffer pointer on the stack.
00590 JR ParseSpeechString_Store Jump to ParseSpeechString_Store.
A "(" starts a parenthesised allophone name.
ParseSpeechString_TestGroup 00592 CP 8 Jump to ParseSpeechString_Map if this is not "(".
00594 JR NZ,ParseSpeechString_Map
00596 CALL ParseAllophoneGroup Call ParseAllophoneGroup and jump to ParseSpeechString_Store if the name was valid.
00599 JR NC,ParseSpeechString_Store
00601 POP BC Restore the buffer pointer from the stack.
00602 JR ParseSpeechString_Mark Jump to ParseSpeechString_Mark.
Map the character through CharacterKeys.
ParseSpeechString_Map 00604 PUSH HL Stash the string pointer on the stack.
00605 LD HL,943 Search CharacterKeys and jump to ParseSpeechString_Mapped if this letter is known.
00608 LD BC,27
00611 CPIR
00613 JR Z,ParseSpeechString_Mapped
00615 POP HL Restore the string pointer and the buffer pointer from the stack.
00616 POP BC
This character is not in the key tables; mark s$ with "?".
ParseSpeechString_Mark 00617 INC DE Step past this character.
00618 INC HL
ParseSpeechString_Bound 00619 PUSH HL Test whether the string pointer has reached the end of s$.
00620 OR A
00621 SBC HL,DE
00623 POP HL
00624 JR C,ParseSpeechString_Query Jump to ParseSpeechString_Query if it has.
00626 DEC HL Move back one character.
00627 JR ParseSpeechString_Bound Jump to ParseSpeechString_Bound.
ParseSpeechString_Query 00629 LD C,63 Mark s$ with "?" and jump to ParseSpeechString_Term.
00631 LD (HL),C
00632 JR ParseSpeechString_Term
ParseSpeechString_Mapped 00634 LD BC,53 Fetch the mapped allophone from MappedCharacters.
00637 ADD HL,BC
00638 LD A,(HL)
00639 POP HL Restore the string pointer from the stack.
Apply intonation and queue the allophone.
ParseSpeechString_Store 00640 LD B,A Keep the allophone in B.
00641 XOR A Set the flags-byte index.
00642 PUSH HL Stash the string pointer on the stack.
00643 CALL ReadWorkspace Call ReadWorkspace.
00646 POP HL Restore the string pointer from the stack.
00647 AND %01000000 Keep only bit 6 (intonation).
00649 ADD A,B Apply the intonation bit to the allophone.
00650 POP BC Restore the buffer pointer from the stack.
00651 LD (BC),A Queue the allophone in the speech buffer.
00652 DEC BC
00653 CALL CheckMemory Call CheckMemory and return if the buffer is full.
00656 RET C
00657 PUSH HL Jump to ParseSpeechString_Next if there are still characters left in s$.
00658 SBC HL,DE
00660 POP HL
00661 JR C,ParseSpeechString_Next
00663 XOR A Write a terminator to the speech buffer.
00664 LD (BC),A
00665 DEC BC
00666 CALL CheckMemory Call CheckMemory and return if the buffer is full.
00669 RET C
00670 CALL WriteBufferPointer Call WriteBufferPointer.
00673 LD C,42 Use "*" as the "already spoken" marker.
Overwrite the first character of s$ so it will not be spoken again.
ParseSpeechString_Term 00675 LD A,83 Call FindVariable for "s$".
00677 CALL FindVariable
00680 INC HL Move to the first character of s$.
00681 INC HL
00682 INC HL
00683 LD (HL),C Mark s$ as already spoken.
00684 RET Return.
Prev: 00461 Up: Map Next: 00685