Prev: 00685 Up: Map Next: 00843
00747: Parse Allophone Group
Used by the routine at ParseSpeechString.
Read a parenthesised allophone name from the speech string (for example "(AA)" or "(SH)"). Letters are normalised, checked against CharacterKeys, and summed; the sum selects an allophone from the parallel tables.
Input
HL Current string pointer
Output
A Mapped allophone
F Carry set if the group is invalid
Clear the running total that will identify the name.
ParseAllophoneGroup 00747 LD B,0 Set the running total to 0.
Read letters until a closing parenthesis.
ParseAllophoneGroup_Loop 00749 INC HL Fetch the next character from the speech string.
00750 LD A,(HL)
00751 CP 41 Jump to ParseAllophoneGroup_Close if this is a closing parenthesis.
00753 JR Z,ParseAllophoneGroup_Close
00755 PUSH BC Stash the running total on the stack.
00756 CALL NormaliseCharacter Call NormaliseCharacter.
The letter must appear in the first 24 character keys.
00759 PUSH HL Stash the string pointer on the stack.
00760 LD HL,943 Search the first 24 entries of CharacterKeys.
00763 LD BC,24
00766 CPIR
00768 POP HL Restore the string pointer and the running total from the stack.
00769 POP BC
00770 JR NZ,ParseAllophoneGroup_Carry Jump to ParseAllophoneGroup_Carry if this is not a valid allophone-name character.
00772 ADD A,B Add the letter key to the running total and return if the sum overflowed.
00773 RET C
00774 LD B,A Keep the new total and jump to ParseAllophoneGroup_Loop.
00775 JR ParseAllophoneGroup_Loop
The name has ended; the running total selects the allophone.
ParseAllophoneGroup_Close 00777 LD A,B Use the name sum as the lookup key.
00778 CP 100 Jump to ParseAllophoneGroup_Look if the sum is 100.
00780 JR Z,ParseAllophoneGroup_Look
00782 CP 104 Jump to ParseAllophoneGroup_Look if the sum is 104.
00784 JR Z,ParseAllophoneGroup_Look
00786 CP 92 Jump to ParseAllophoneGroup_Look if the sum is 92.
00788 JR Z,ParseAllophoneGroup_Look
00790 CP 102 Jump to ParseAllophoneGroup_Look if the sum is 102.
00792 JR Z,ParseAllophoneGroup_Look
00794 CP 120 Jump to ParseAllophoneGroup_Prev if the sum is 120.
00796 JR Z,ParseAllophoneGroup_Prev
Look the sum up across both character-key tables.
00798 LD BC,54 Search 54 bytes of the character-key tables.
00801 PUSH HL Stash the string pointer on the stack.
00802 LD HL,943 Search CharacterKeys for the name sum.
00805 CPIR
00807 LD BC,53 Use the parallel mapped value (53 bytes on).
ParseAllophoneGroup_Offset 00810 JR NZ,ParseAllophoneGroup_Fail Jump to ParseAllophoneGroup_Fail if no match was found.
00812 ADD HL,BC Fetch the mapped allophone from the parallel table.
00813 LD A,(HL)
00814 OR A Set the flags from the mapped allophone.
00815 POP HL Restore the string pointer from the stack.
00816 RET Return.
Sum 120 uses the character before the ")".
ParseAllophoneGroup_Prev 00817 PUSH HL Stash the string pointer on the stack.
00818 DEC HL Move back to the previous character.
00819 JR ParseAllophoneGroup_Suffix Jump to ParseAllophoneGroup_Suffix.
ParseAllophoneGroup_Look 00821 PUSH HL Stash the string pointer on the stack.
Map the previous character through the suffix tables.
ParseAllophoneGroup_Suffix 00822 DEC HL Fetch the previous character.
00823 LD A,(HL)
00824 CALL NormaliseCharacter Call NormaliseCharacter.
00827 LD BC,9 Search SuffixKeys for the normalised character.
00830 LD HL,1051
00833 CPIR
00835 LD BC,8 Use the parallel suffix value and jump to ParseAllophoneGroup_Offset.
00838 JR ParseAllophoneGroup_Offset
The name sum is not in the key tables; restore the string pointer and fail.
ParseAllophoneGroup_Fail 00840 POP HL Restore the string pointer from the stack.
ParseAllophoneGroup_Carry 00841 SCF Set the carry flag.
00842 RET Return.
Prev: 00685 Up: Map Next: 00843