![]()  | 
Routines | 
| Prev: 44651 | Up: Map | Next: 44719 | 
| 
 
Used by the routine at ActionRouting.
 
Matches phrase patterns with multiple variations against user input tokens.
 
 
  | 
||||||||||||
| MatchPhraseTokens | 44672 | EX DE,HL | Switch the phrase token pointer to DE. | |||||||||
| 44673 | JR MatchPhraseTokens_Start | Jump to MatchPhraseTokens_Start. | ||||||||||
| 
 
Skip the separator.
 
 | 
||||||||||||
| MatchPhraseTokens_Loop | 44675 | 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 | 44676 | LD HL,43045 | HL=UserInput_Token_2. | |||||||||
| 44679 | JR CompareTokens | Jump to CompareTokens. | ||||||||||
| 
 
The tokens matched so advance both pointers.
 
 | 
||||||||||||
| MatchTokens_Loop | 44681 | INC HL | Increment the input token pointer by one. | |||||||||
| 44682 | INC DE | Increment the pattern token pointer by one. | ||||||||||
| 
 
Keep looping if the tokens match.
 
 | 
||||||||||||
| CompareTokens | 44683 | LD A,(DE) | Jump to MatchTokens_Loop if the pattern token and the input token are the same. | |||||||||
| 44684 | CP (HL) | |||||||||||
| 44685 | JR Z,MatchTokens_Loop | |||||||||||
| 
 
The tokens are different, but is it just that we are at the end of the pattern?
 
 | 
||||||||||||
| 44687 | CP 254 | Jump to CheckSeparator unless this is the terminator character (254). | ||||||||||
| 44689 | JR NZ,CheckSeparator | |||||||||||
| 
 
Yes! The input tokens all matched against the phrase pattern tokens.
 
 | 
||||||||||||
| 44691 | LD A,(HL) | Return with Z flag result. | ||||||||||
| 44692 | CP 255 | |||||||||||
| 44694 | RET | |||||||||||
| 
 
The tokens are different, but is this a separator character?
 
 | 
||||||||||||
| CheckSeparator | 44695 | CP 253 | Jump to MatchPhraseTokens_Next if this is not the separator (253). | |||||||||
| 44697 | JR NZ,MatchPhraseTokens_Next | |||||||||||
| 44699 | LD A,(HL) | Jump to MatchPhraseTokens_Loop if the input tokens are not complete. | ||||||||||
| 44700 | CP 255 | |||||||||||
| 44702 | JR NZ,MatchPhraseTokens_Loop | |||||||||||
| 44704 | RET | Return. | ||||||||||
| 
 
The current variant doesn't match, so skip to the next one.
 
 | 
||||||||||||
| MatchPhraseTokens_Next | 44705 | INC DE | Increment the phrase token pointer by one. | |||||||||
| 44706 | LD A,(DE) | Jump to MatchPhraseTokens_Return if the terminator has been reached (254). | ||||||||||
| 44707 | CP 254 | |||||||||||
| 44709 | JR Z,MatchPhraseTokens_Return | |||||||||||
| 44711 | CP 253 | Jump to MatchPhraseTokens_Next if this is not the separator (253). | ||||||||||
| 44713 | JR NZ,MatchPhraseTokens_Next | |||||||||||
| 44715 | JR MatchPhraseTokens_Loop | Jump to MatchPhraseTokens_Loop. | ||||||||||
| 
 
The input doesn't match any patterns.
 
 | 
||||||||||||
| MatchPhraseTokens_Return | 44717 | OR A | Clear the Z flag. | |||||||||
| 44718 | RET | Return. | ||||||||||
| 
 
View the equivalent code in The Jewels Of Babylon.
 
 | 
||||||||||||
| Prev: 44651 | Up: Map | Next: 44719 |