![]() |
Routines |
Prev: C35F | Up: Map | Next: C3AE |
Used by the routines at Action_Examine, Action_Take, Action_Get, Action_DropThrow, Action_LayPlacePut, Action_???, Action_Kill, Action_Shooting, Action_Climb, Action_Eat, Action_Drink, Action_Open, Action_CloseShut, Action_Shout, Action_Insert, Action_Pull, Action_Wear, Action_LightStrike, Action_Enter, Action_Move, Action_Unlock and Action_Row.
Matches phrase patterns with multiple variations against user input tokens.
|
||||||||||||
MatchPhraseTokens | C37F | EX DE,HL | Switch the phrase token pointer to DE. | |||||||||
C380 | JR MatchPhraseTokens_Start | Jump to MatchPhraseTokens_Start. | ||||||||||
Skip the separator.
|
||||||||||||
MatchPhraseTokens_Loop | C382 | 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 | C383 | LD HL,$BD67 | HL=UserInput_Token_2. | |||||||||
C386 | JR CompareTokens | Jump to CompareTokens. | ||||||||||
The tokens matched so advance both pointers.
|
||||||||||||
MatchTokens_Loop | C388 | INC HL | Increment the input token pointer by one. | |||||||||
C389 | INC DE | Increment the pattern token pointer by one. | ||||||||||
Keep looping if the tokens match.
|
||||||||||||
CompareTokens | C38A | LD A,(DE) | Jump to MatchTokens_Loop if the pattern token and the input token are the same. | |||||||||
C38B | CP (HL) | |||||||||||
C38C | JR Z,MatchTokens_Loop | |||||||||||
The tokens are different, but is it just that we are at the end of the pattern?
|
||||||||||||
C38E | CP $FE | Jump to CheckSeparator unless this is the terminator character (FE). | ||||||||||
C390 | JR NZ,CheckSeparator | |||||||||||
Yes! The input tokens all matched against the phrase pattern tokens.
|
||||||||||||
C392 | LD A,(HL) | Return with Z flag result. | ||||||||||
C393 | CP $FF | |||||||||||
C395 | RET | |||||||||||
The tokens are different, but is this a separator character?
|
||||||||||||
CheckSeparator | C396 | CP $FD | Jump to MatchPhraseTokens_Next if this is not the separator (FD). | |||||||||
C398 | JR NZ,MatchPhraseTokens_Next | |||||||||||
C39A | LD A,(HL) | Jump to MatchPhraseTokens_Loop if the input tokens are not complete. | ||||||||||
C39B | CP $FF | |||||||||||
C39D | JR NZ,MatchPhraseTokens_Loop | |||||||||||
C39F | RET | Return. | ||||||||||
The current variant doesn't match, so skip to the next one.
|
||||||||||||
MatchPhraseTokens_Next | C3A0 | INC DE | Increment the phrase token pointer by one. | |||||||||
C3A1 | LD A,(DE) | Jump to MatchPhraseTokens_Return if the terminator has been reached (FE). | ||||||||||
C3A2 | CP $FE | |||||||||||
C3A4 | JR Z,MatchPhraseTokens_Return | |||||||||||
C3A6 | CP $FD | Jump to MatchPhraseTokens_Next if this is not the separator (FD). | ||||||||||
C3A8 | JR NZ,MatchPhraseTokens_Next | |||||||||||
C3AA | JR MatchPhraseTokens_Loop | Jump to MatchPhraseTokens_Loop. | ||||||||||
The input doesn't match any patterns.
|
||||||||||||
MatchPhraseTokens_Return | C3AC | OR A | Clear the Z flag. | |||||||||
C3AD | RET | Return. |
Prev: C35F | Up: Map | Next: C3AE |