Prev: 75F6 Up: Map Next: 76EC
75FA: Inglish: Match One Word
Used by the routines at InglishSaveTheMatch and InglishRestoreTheMatch.
Matches one word of the clause against the dictionary. Reached through the jump table at JumpTable, dispatched from 75D0.
InglishMatchOneWord 75FA BIT 1,E Jump to InglishMatchOneWord_MarkTheClauseByte if bit 1 of the grammar flag is clear.
75FC JR Z,InglishMatchOneWord_MarkTheClauseByte
Test the replay path.
75FE LD A,($B706) Jump to InglishMatchOneWord_MarkTheClauseByte if *B706 is not zero.
7601 AND A
7602 JR NZ,InglishMatchOneWord_MarkTheClauseByte
Test the class being matched.
7604 LD A,($B6DE) Jump to InglishMatchOneWord_TestTheConjunction if *B6DE is not C0.
7607 CP $C0
7609 JR NZ,InglishMatchOneWord_TestTheConjunction
760B CP D Jump to InglishCountAConjunction when this letter matches the dictionary.
760C JR Z,InglishCountAConjunction
InglishMatchOneWord_TestTheConjunction 760E CALL Inglish_TestTheConjunctionCount Call Inglish_TestTheConjunctionCount to test the conjunction count.
7611 JP Z,Inglish_AskWhat_1 Jump to Inglish_AskWhat_1 if Inglish_TestTheConjunctionCount found no conjunction left.
This entry point is used by the routine at InglishPrepareTheClause.
InglishMatchOneWord_MarkTheClauseByte 7614 LD A,($B719) Read *B719.
7617 DEC A Jump to InglishMatchOneWord_PointAtReplayPath unless the matcher phase is 01.
7618 JR NZ,InglishMatchOneWord_PointAtReplayPath
761A SET 7,(IY+$01) Mark the clause byte at offset 1 so bit 7 is on.
InglishMatchOneWord_PointAtReplayPath 761E LD HL,$B706 Point HL at B706 and jump to InglishMatchOneWord_CountOneMoreInTheReplayPath unless the matcher phase was 02.
7621 DEC A
7622 LD A,D
7623 JR NZ,InglishMatchOneWord_CountOneMoreInTheReplayPath
7625 CP $A0 Jump to InglishMatchOneWord_ExchangeTheTwoRecords if the class in D is A0.
7627 JR Z,InglishMatchOneWord_ExchangeTheTwoRecords
InglishMatchOneWord_CountOneMoreInTheReplayPath 7629 INC (HL) Count one more in the replay path.
InglishMatchOneWord_ExchangeTheTwoRecords 762A CALL Inglish_ExchangeTheTwoRecords_0 Call Inglish_ExchangeTheTwoRecords_0 to exchange the two records.
762D CP $A0 Jump back to InglishPrepareTheClause_2 if the class is A0.
762F JP Z,InglishPrepareTheClause_2
Test the fresh-game flag.
7632 LD A,($B71A) Jump to InglishMatchOneWord_PointAtTheLocationTable if *B71A is zero.
7635 AND A
7636 JR Z,InglishMatchOneWord_PointAtTheLocationTable
7638 PUSH DE Save DE and keep A in E.
7639 LD E,A
763A LD D,$00 The word-class offset's high byte is zero.
763C LD HL,$B9C8 Index the parser workspace at B9C8.
763F ADD HL,DE
7640 PUSH IY Point IY at the first parser slot.
7642 LD IY,$B9B0
7646 LD A,(IY+$08) Read the name token from IY.
7649 OR (IY+$09) Jump to InglishMatchOneWord_TestTheNameToken if the name token at IY is zero.
764C LD DE,$B9B8
764F JR Z,InglishMatchOneWord_TestTheNameToken
7651 LD A,(IY+$08) Read the name token from IY.
7654 CP (HL) Jump to InglishMatchOneWord_TestTheNameWord if the name token at IY+8 does not match.
7655 JR NZ,InglishMatchOneWord_TestTheNameWord
7657 LD A,(IY+$09) Read the name token's high byte from IY.
765A INC HL Jump to InglishMatchOneWord_TestTheNameToken if the high byte of that word matches too.
765B CP (HL)
765C DEC HL
765D JR Z,InglishMatchOneWord_TestTheNameToken
InglishMatchOneWord_TestTheNameWord 765F LD A,(IY+$12) Read byte +12 from IY.
7662 OR (IY+$13) Test whether the word at offset 12 is zero.
7665 LD DE,$B9C2 Point DE at the third parser slot.
InglishMatchOneWord_TestTheNameToken 7668 POP IY Jump to InglishMatchOneWord_PopTheMatchPointer if the name token just tested is not zero.
766A JR NZ,InglishMatchOneWord_PopTheMatchPointer
766C EX DE,HL Swap the word pointer with the parser slot.
766D LD B,$03 Count 03 passes.
InglishMatchOneWord_Loop 766F LD A,(HL) Jump to InglishMatchOneWord_StepThePairPointers unless this grammar pair is empty.
7670 INC HL
7671 OR (HL)
7672 DEC HL
7673 JR NZ,InglishMatchOneWord_StepThePairPointers
7675 LD A,(DE) Copy the workspace byte into the empty slot pair.
7676 LD (HL),A
InglishMatchOneWord_StepThePairPointers 7677 INC HL Step HL and DE on, and jump to InglishMatchOneWord_StepToTheNextParserByte if the pair was not empty.
7678 INC DE
7679 JR NZ,InglishMatchOneWord_StepToTheNextParserByte
767B LD A,(DE) Copy the second workspace byte into the slot.
767C LD (HL),A
InglishMatchOneWord_StepToTheNextParserByte 767D INC HL Step to the next byte of the parser slot.
767E INC DE Step to the next byte of the parser workspace.
767F DJNZ InglishMatchOneWord_Loop Loop back to InglishMatchOneWord_Loop until 03 runs out.
InglishMatchOneWord_PopTheMatchPointer 7681 POP DE Point at the location table.
InglishMatchOneWord_PointAtTheLocationTable 7682 PUSH IY
7684 LD IY,$B9E0
7688 LD A,($B706) Read *B706.
768B LD B,A Copy the result into B.
768C PUSH BC Call Inglish_ExchangeTheTwoRecords to drop one from the character count and swap the two records.
768D CALL Inglish_ExchangeTheTwoRecords
InglishMatchOneWord_ExchangeForTheReplay 7690 LD A,B Jump to InglishMatchOneWord_SkipToThePreviousParserSlot if the replay path is zero.
7691 AND A
7692 JR Z,InglishMatchOneWord_SkipToThePreviousParserSlot
7694 CALL Inglish_ExchangeTheTwoRecords Call Inglish_ExchangeTheTwoRecords to exchange the two records.
7697 LD A,(IY+$01) Read the clause byte at offset 1.
769A AND $7F Keep bits 0-6 of this clause byte, and call Inglish_CopyTwoBytesFromTheOtherClause if it and the byte at IY are both zero.
769C OR (IY+$00)
769F CALL Z,Inglish_CopyTwoBytesFromTheOtherClause
76A2 JR InglishMatchOneWord_ExchangeForTheReplay Jump back to InglishMatchOneWord_ExchangeForTheReplay to read the next word.
InglishMatchOneWord_SkipToThePreviousParserSlot 76A4 POP BC Call Inglish_StepToThePreviousSlot to drop one from the character count and skip to the previous parser slot.
76A5 POP IY
76A7 PUSH IY
76A9 CALL Inglish_StepToThePreviousSlot
InglishMatchOneWord_TestWhetherTheReplayPathIsZero 76AC LD A,B Jump to InglishMatchOneWord_ReadTheLineReadFlag if the replay path is zero.
76AD AND A
76AE JP Z,InglishMatchOneWord_ReadTheLineReadFlag
76B1 CALL Inglish_StepToThePreviousSlot Call Inglish_StepToThePreviousSlot to step to the previous slot.
76B4 LD A,(IY+$12) Read byte +12 from IY.
76B7 OR (IY+$13) Jump back to InglishMatchOneWord_TestWhetherTheReplayPathIsZero if the name token at offset 12 is not zero.
76BA JR NZ,InglishMatchOneWord_TestWhetherTheReplayPathIsZero
76BC LD A,(IY+$00) Read the clause byte at offset 0.
76BF CP (IX+$00) Jump back to InglishMatchOneWord_TestWhetherTheReplayPathIsZero if the clause byte at offset 0 is not byte 0 of this record.
76C2 JR NZ,InglishMatchOneWord_TestWhetherTheReplayPathIsZero
76C4 LD A,(IY+$01) Read the clause byte at offset 1.
76C7 CP (IX+$01) Jump back to InglishMatchOneWord_TestWhetherTheReplayPathIsZero if the clause byte at offset 1 is not byte 1 of this record.
76CA JR NZ,InglishMatchOneWord_TestWhetherTheReplayPathIsZero
76CC LD A,(IX+$0E) Read clause byte 0E of the other record.
76CF OR (IX+$0F) Jump back to InglishMatchOneWord_TestWhetherTheReplayPathIsZero if bytes 0E and 0F of this record are both zero.
76D2 JR Z,InglishMatchOneWord_TestWhetherTheReplayPathIsZero
76D4 EXX Switch to the saved registers for this phrase.
76D5 LD DE,$000E The copy starts 0E bytes into the record.
76D8 CALL Inglish_CopyTwoBytesFromTheOtherClause_0 Call Inglish_CopyTwoBytesFromTheOtherClause_0 to copy the grammar bytes into the clause.
76DB JP InglishMatchOneWord_TestWhetherTheReplayPathIsZero Jump back to InglishMatchOneWord_TestWhetherTheReplayPathIsZero to read the next word.
InglishMatchOneWord_ReadTheLineReadFlag 76DE POP IY Read *B705.
76E0 LD A,($B705)
76E3 AND A Return if the line-read flag is zero.
76E4 RET Z
76E5 CALL Inglish_TestTheConjunctionCount Call Inglish_TestTheConjunctionCount to test the conjunction count.
76E8 RET Z Return if no conjunction is left.
76E9 JP InglishPrepareTheClause_2 Jump to InglishPrepareTheClause_2 to reset the parser flags and blank the parser slot.
View the equivalent code in;
Prev: 75F6 Up: Map Next: 76EC