Prev: 02AD Up: Map Next: 034B
02EB: 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 02EB LD B,$00 Set the running total to 00.
Read letters until a closing parenthesis.
ParseAllophoneGroup_Loop 02ED INC HL Fetch the next character from the speech string.
02EE LD A,(HL)
02EF CP $29 Jump to ParseAllophoneGroup_Close if this is a closing parenthesis.
02F1 JR Z,ParseAllophoneGroup_Close
02F3 PUSH BC Stash the running total on the stack.
02F4 CALL NormaliseCharacter Call NormaliseCharacter.
The letter must appear in the first 18 character keys.
02F7 PUSH HL Stash the string pointer on the stack.
02F8 LD HL,$03AF Search the first 18 entries of CharacterKeys.
02FB LD BC,$0018
02FE CPIR
0300 POP HL Restore the string pointer and the running total from the stack.
0301 POP BC
0302 JR NZ,ParseAllophoneGroup_Carry Jump to ParseAllophoneGroup_Carry if this is not a valid allophone-name character.
0304 ADD A,B Add the letter key to the running total and return if the sum overflowed.
0305 RET C
0306 LD B,A Keep the new total and jump to ParseAllophoneGroup_Loop.
0307 JR ParseAllophoneGroup_Loop
The name has ended; the running total selects the allophone.
ParseAllophoneGroup_Close 0309 LD A,B Use the name sum as the lookup key.
030A CP $64 Jump to ParseAllophoneGroup_Look if the sum is 64.
030C JR Z,ParseAllophoneGroup_Look
030E CP $68 Jump to ParseAllophoneGroup_Look if the sum is 68.
0310 JR Z,ParseAllophoneGroup_Look
0312 CP $5C Jump to ParseAllophoneGroup_Look if the sum is 5C.
0314 JR Z,ParseAllophoneGroup_Look
0316 CP $66 Jump to ParseAllophoneGroup_Look if the sum is 66.
0318 JR Z,ParseAllophoneGroup_Look
031A CP $78 Jump to ParseAllophoneGroup_Prev if the sum is 78.
031C JR Z,ParseAllophoneGroup_Prev
Look the sum up across both character-key tables.
031E LD BC,$0036 Search 36 bytes of the character-key tables.
0321 PUSH HL Stash the string pointer on the stack.
0322 LD HL,$03AF Search CharacterKeys for the name sum.
0325 CPIR
0327 LD BC,$0035 Use the parallel mapped value (35 bytes on).
ParseAllophoneGroup_Offset 032A JR NZ,ParseAllophoneGroup_Fail Jump to ParseAllophoneGroup_Fail if no match was found.
032C ADD HL,BC Fetch the mapped allophone from the parallel table.
032D LD A,(HL)
032E OR A Set the flags from the mapped allophone.
032F POP HL Restore the string pointer from the stack.
0330 RET Return.
Sum 78 uses the character before the ")".
ParseAllophoneGroup_Prev 0331 PUSH HL Stash the string pointer on the stack.
0332 DEC HL Move back to the previous character.
0333 JR ParseAllophoneGroup_Suffix Jump to ParseAllophoneGroup_Suffix.
ParseAllophoneGroup_Look 0335 PUSH HL Stash the string pointer on the stack.
Map the previous character through the suffix tables.
ParseAllophoneGroup_Suffix 0336 DEC HL Fetch the previous character.
0337 LD A,(HL)
0338 CALL NormaliseCharacter Call NormaliseCharacter.
033B LD BC,$0009 Search SuffixKeys for the normalised character.
033E LD HL,$041B
0341 CPIR
0343 LD BC,$0008 Use the parallel suffix value and jump to ParseAllophoneGroup_Offset.
0346 JR ParseAllophoneGroup_Offset
The name sum is not in the key tables; restore the string pointer and fail.
ParseAllophoneGroup_Fail 0348 POP HL Restore the string pointer from the stack.
ParseAllophoneGroup_Carry 0349 SCF Set the carry flag.
034A RET Return.
Prev: 02AD Up: Map Next: 034B