![]() |
Routines |
Prev: 42438 | Up: Map | Next: 42506 |
Matches phrase patterns with multiple variations against user input tokens.
|
||||||||||||
MatchPhraseTokens | 42459 | EX DE,HL | Switch the phrase token pointer to DE. | |||||||||
42460 | JR MatchPhraseTokens_Start | Jump to MatchPhraseTokens_Start. | ||||||||||
Skip the separator.
|
||||||||||||
MatchPhraseTokens_Loop | 42462 | INC DE | Increment the phrase token pointer by one. | |||||||||
Fetch the second user input token (not the first, as the first token is the verb and the second token onwards gives the context).
For example; "GET" (verb) "KEG OF GUNPOWDER" (direct object).
|
||||||||||||
MatchPhraseTokens_Start | 42463 | LD HL,41276 | HL=UserInput_Token_2. | |||||||||
42466 | JR CompareTokens | Jump to CompareTokens. | ||||||||||
The tokens matched so advance both pointers.
|
||||||||||||
MatchTokens_Loop | 42468 | INC HL | Increment the input token pointer by one. | |||||||||
42469 | INC DE | Increment the pattern token pointer by one. | ||||||||||
Keep looping if the tokens match.
|
||||||||||||
CompareTokens | 42470 | LD A,(DE) | Jump to MatchTokens_Loop if the pattern token and the input token are the same. | |||||||||
42471 | CP (HL) | |||||||||||
42472 | JR Z,MatchTokens_Loop | |||||||||||
The tokens are different, but is it just that we are at the end of the pattern?
|
||||||||||||
42474 | CP 254 | Jump to CheckSeparator unless this is the terminator character (254). | ||||||||||
42476 | JR NZ,CheckSeparator | |||||||||||
Yes! The input tokens all matched against the phrase pattern tokens.
|
||||||||||||
42478 | LD A,(HL) | Return with Z flag result. | ||||||||||
42479 | CP 255 | |||||||||||
42481 | RET | |||||||||||
The tokens are different, but is this a separator character?
|
||||||||||||
CheckSeparator | 42482 | CP 253 | Jump to MatchPhraseTokens_Next if this is not the separator (253). | |||||||||
42484 | JR NZ,MatchPhraseTokens_Next | |||||||||||
42486 | LD A,(HL) | Jump to MatchPhraseTokens_Loop if the input tokens are not complete. | ||||||||||
42487 | CP 255 | |||||||||||
42489 | JR NZ,MatchPhraseTokens_Loop | |||||||||||
42491 | RET | Return. | ||||||||||
The current variant doesn't match, so skip to the next one.
|
||||||||||||
MatchPhraseTokens_Next | 42492 | INC DE | Increment the phrase token pointer by one. | |||||||||
42493 | LD A,(DE) | Jump to MatchPhraseTokens_Return if the terminator has been reached (254). | ||||||||||
42494 | CP 254 | |||||||||||
42496 | JR Z,MatchPhraseTokens_Return | |||||||||||
42498 | CP 253 | Jump to MatchPhraseTokens_Next if this is not the separator (253). | ||||||||||
42500 | JR NZ,MatchPhraseTokens_Next | |||||||||||
42502 | JR MatchPhraseTokens_Loop | Jump to MatchPhraseTokens_Loop. | ||||||||||
The input doesn't match any patterns.
|
||||||||||||
MatchPhraseTokens_Return | 42504 | OR A | Clear the Z flag. | |||||||||
42505 | RET | Return. | ||||||||||
View the equivalent code in;
|
Prev: 42438 | Up: Map | Next: 42506 |