Prev: 30198 Up: Map Next: 30444
30202: 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 30160.
InglishMatchOneWord 30202 BIT 1,E Jump to InglishMatchOneWord_MarkTheClauseByte if bit 1 of the grammar flag is clear.
30204 JR Z,InglishMatchOneWord_MarkTheClauseByte
Test the replay path.
30206 LD A,(46854) Jump to InglishMatchOneWord_MarkTheClauseByte if *46854 is not zero.
30209 AND A
30210 JR NZ,InglishMatchOneWord_MarkTheClauseByte
Test the class being matched.
30212 LD A,(46814) Jump to InglishMatchOneWord_TestTheConjunction if *46814 is not 192.
30215 CP 192
30217 JR NZ,InglishMatchOneWord_TestTheConjunction
30219 CP D Jump to InglishCountAConjunction when this letter matches the dictionary.
30220 JR Z,InglishCountAConjunction
InglishMatchOneWord_TestTheConjunction 30222 CALL Inglish_TestTheConjunctionCount Call Inglish_TestTheConjunctionCount to test the conjunction count.
30225 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 30228 LD A,(46873) Read *46873.
30231 DEC A Jump to InglishMatchOneWord_PointAtReplayPath unless the matcher phase is 1.
30232 JR NZ,InglishMatchOneWord_PointAtReplayPath
30234 SET 7,(IY+1) Mark the clause byte at offset 1 so bit 7 is on.
InglishMatchOneWord_PointAtReplayPath 30238 LD HL,46854 Point HL at 46854 and jump to InglishMatchOneWord_CountOneMoreInTheReplayPath unless the matcher phase was 2.
30241 DEC A
30242 LD A,D
30243 JR NZ,InglishMatchOneWord_CountOneMoreInTheReplayPath
30245 CP 160 Jump to InglishMatchOneWord_ExchangeTheTwoRecords if the class in D is 160.
30247 JR Z,InglishMatchOneWord_ExchangeTheTwoRecords
InglishMatchOneWord_CountOneMoreInTheReplayPath 30249 INC (HL) Count one more in the replay path.
InglishMatchOneWord_ExchangeTheTwoRecords 30250 CALL Inglish_ExchangeTheTwoRecords_0 Call Inglish_ExchangeTheTwoRecords_0 to exchange the two records.
30253 CP 160 Jump back to InglishPrepareTheClause_2 if the class is 160.
30255 JP Z,InglishPrepareTheClause_2
Test the fresh-game flag.
30258 LD A,(46874) Jump to InglishMatchOneWord_PointAtTheLocationTable if *46874 is zero.
30261 AND A
30262 JR Z,InglishMatchOneWord_PointAtTheLocationTable
30264 PUSH DE Save DE and keep A in E.
30265 LD E,A
30266 LD D,0 The word-class offset's high byte is zero.
30268 LD HL,47560 Index the parser workspace at 47560.
30271 ADD HL,DE
30272 PUSH IY Point IY at the first parser slot.
30274 LD IY,47536
30278 LD A,(IY+8) Read the name token from IY.
30281 OR (IY+9) Jump to InglishMatchOneWord_TestTheNameToken if the name token at IY is zero.
30284 LD DE,47544
30287 JR Z,InglishMatchOneWord_TestTheNameToken
30289 LD A,(IY+8) Read the name token from IY.
30292 CP (HL) Jump to InglishMatchOneWord_TestTheNameWord if the name token at IY+8 does not match.
30293 JR NZ,InglishMatchOneWord_TestTheNameWord
30295 LD A,(IY+9) Read the name token's high byte from IY.
30298 INC HL Jump to InglishMatchOneWord_TestTheNameToken if the high byte of that word matches too.
30299 CP (HL)
30300 DEC HL
30301 JR Z,InglishMatchOneWord_TestTheNameToken
InglishMatchOneWord_TestTheNameWord 30303 LD A,(IY+18) Read byte +18 from IY.
30306 OR (IY+19) Test whether the word at offset 18 is zero.
30309 LD DE,47554 Point DE at the third parser slot.
InglishMatchOneWord_TestTheNameToken 30312 POP IY Jump to InglishMatchOneWord_PopTheMatchPointer if the name token just tested is not zero.
30314 JR NZ,InglishMatchOneWord_PopTheMatchPointer
30316 EX DE,HL Swap the word pointer with the parser slot.
30317 LD B,3 Count 3 passes.
InglishMatchOneWord_Loop 30319 LD A,(HL) Jump to InglishMatchOneWord_StepThePairPointers unless this grammar pair is empty.
30320 INC HL
30321 OR (HL)
30322 DEC HL
30323 JR NZ,InglishMatchOneWord_StepThePairPointers
30325 LD A,(DE) Copy the workspace byte into the empty slot pair.
30326 LD (HL),A
InglishMatchOneWord_StepThePairPointers 30327 INC HL Step HL and DE on, and jump to InglishMatchOneWord_StepToTheNextParserByte if the pair was not empty.
30328 INC DE
30329 JR NZ,InglishMatchOneWord_StepToTheNextParserByte
30331 LD A,(DE) Copy the second workspace byte into the slot.
30332 LD (HL),A
InglishMatchOneWord_StepToTheNextParserByte 30333 INC HL Step to the next byte of the parser slot.
30334 INC DE Step to the next byte of the parser workspace.
30335 DJNZ InglishMatchOneWord_Loop Loop back to InglishMatchOneWord_Loop until 3 runs out.
InglishMatchOneWord_PopTheMatchPointer 30337 POP DE Point at the location table.
InglishMatchOneWord_PointAtTheLocationTable 30338 PUSH IY
30340 LD IY,47584
30344 LD A,(46854) Read *46854.
30347 LD B,A Copy the result into B.
30348 PUSH BC Call Inglish_ExchangeTheTwoRecords to drop one from the character count and swap the two records.
30349 CALL Inglish_ExchangeTheTwoRecords
InglishMatchOneWord_ExchangeForTheReplay 30352 LD A,B Jump to InglishMatchOneWord_SkipToThePreviousParserSlot if the replay path is zero.
30353 AND A
30354 JR Z,InglishMatchOneWord_SkipToThePreviousParserSlot
30356 CALL Inglish_ExchangeTheTwoRecords Call Inglish_ExchangeTheTwoRecords to exchange the two records.
30359 LD A,(IY+1) Read the clause byte at offset 1.
30362 AND 127 Keep bits 0-6 of this clause byte, and call Inglish_CopyTwoBytesFromTheOtherClause if it and the byte at IY are both zero.
30364 OR (IY+0)
30367 CALL Z,Inglish_CopyTwoBytesFromTheOtherClause
30370 JR InglishMatchOneWord_ExchangeForTheReplay Jump back to InglishMatchOneWord_ExchangeForTheReplay to read the next word.
InglishMatchOneWord_SkipToThePreviousParserSlot 30372 POP BC Call Inglish_StepToThePreviousSlot to drop one from the character count and skip to the previous parser slot.
30373 POP IY
30375 PUSH IY
30377 CALL Inglish_StepToThePreviousSlot
InglishMatchOneWord_TestWhetherTheReplayPathIsZero 30380 LD A,B Jump to InglishMatchOneWord_ReadTheLineReadFlag if the replay path is zero.
30381 AND A
30382 JP Z,InglishMatchOneWord_ReadTheLineReadFlag
30385 CALL Inglish_StepToThePreviousSlot Call Inglish_StepToThePreviousSlot to step to the previous slot.
30388 LD A,(IY+18) Read byte +18 from IY.
30391 OR (IY+19) Jump back to InglishMatchOneWord_TestWhetherTheReplayPathIsZero if the name token at offset 18 is not zero.
30394 JR NZ,InglishMatchOneWord_TestWhetherTheReplayPathIsZero
30396 LD A,(IY+0) Read the clause byte at offset 0.
30399 CP (IX+0) Jump back to InglishMatchOneWord_TestWhetherTheReplayPathIsZero if the clause byte at offset 0 is not byte 0 of this record.
30402 JR NZ,InglishMatchOneWord_TestWhetherTheReplayPathIsZero
30404 LD A,(IY+1) Read the clause byte at offset 1.
30407 CP (IX+1) Jump back to InglishMatchOneWord_TestWhetherTheReplayPathIsZero if the clause byte at offset 1 is not byte 1 of this record.
30410 JR NZ,InglishMatchOneWord_TestWhetherTheReplayPathIsZero
30412 LD A,(IX+14) Read clause byte 14 of the other record.
30415 OR (IX+15) Jump back to InglishMatchOneWord_TestWhetherTheReplayPathIsZero if bytes 14 and 15 of this record are both zero.
30418 JR Z,InglishMatchOneWord_TestWhetherTheReplayPathIsZero
30420 EXX Switch to the saved registers for this phrase.
30421 LD DE,14 The copy starts 14 bytes into the record.
30424 CALL Inglish_CopyTwoBytesFromTheOtherClause_0 Call Inglish_CopyTwoBytesFromTheOtherClause_0 to copy the grammar bytes into the clause.
30427 JP InglishMatchOneWord_TestWhetherTheReplayPathIsZero Jump back to InglishMatchOneWord_TestWhetherTheReplayPathIsZero to read the next word.
InglishMatchOneWord_ReadTheLineReadFlag 30430 POP IY Read *46853.
30432 LD A,(46853)
30435 AND A Return if the line-read flag is zero.
30436 RET Z
30437 CALL Inglish_TestTheConjunctionCount Call Inglish_TestTheConjunctionCount to test the conjunction count.
30440 RET Z Return if no conjunction is left.
30441 JP InglishPrepareTheClause_2 Jump to InglishPrepareTheClause_2 to reset the parser flags and blank the parser slot.
View the equivalent code in;
Prev: 30198 Up: Map Next: 30444