Prev: B560 Up: Map Next: B5A4
B575: Match Phrase Tokens
Match Phrase Tokens.
Input
HL A pointer to phrase token data
Output
F The Z flag is set if the input matches any pattern
MatchPhraseTokens B575 EX DE,HL Move the phrase token pointer into DE.
B576 JR MatchPhraseTokens_Next Start the match at the first pattern byte, MatchPhraseTokens_Next.
Match_PhraseTokens_Loop B578 INC DE Advance DE to the next byte.
MatchPhraseTokens_Next B579 LD HL,$AF2F Point HL at the second word token.
B57C JR Match_PhraseTokens_Compare Compare the command from its first word at Match_PhraseTokens_Compare.
MatchPhraseTokens_Loop B57E INC HL Advance HL to the next byte.
B57F INC DE Advance DE to the next byte.
Match_PhraseTokens_Compare B580 LD A,(DE) Read the next vocabulary byte into A.
B581 CP (HL) Branch to MatchPhraseTokens_Loop when the byte at HL means the values match.
B582 JR Z,MatchPhraseTokens_Loop
B584 CP $FE Branch to Match_PhraseTokens_Alternative when FE means the values differ.
B586 JR NZ,Match_PhraseTokens_Alternative
B588 LD A,(HL) Accept the phrase when the command has ended.
B589 CP $FF
B58B RET
Match_PhraseTokens_Alternative B58C CP $FD Branch to Match_PhraseTokens_Skip when FD means the values differ.
B58E JR NZ,Match_PhraseTokens_Skip
B590 LD A,(HL) Match this alternative when the command has ended, and try the next one when the player typed another word.
B591 CP $FF
B593 JR NZ,Match_PhraseTokens_Loop
B595 RET
Match_PhraseTokens_Skip B596 INC DE Advance DE to the next byte.
B597 LD A,(DE) Read the next vocabulary byte into A.
B598 CP $FE Branch to Match_PhraseTokens_Done when FE means the values match.
B59A JR Z,Match_PhraseTokens_Done
B59C CP $FD Branch to Match_PhraseTokens_Skip when FD means the values differ.
B59E JR NZ,Match_PhraseTokens_Skip
B5A0 JR Match_PhraseTokens_Loop Try the next phrase alternative at Match_PhraseTokens_Loop.
Match_PhraseTokens_Done B5A2 OR A Test A so the following branch can see whether it is zero.
B5A3 RET Return.
Prev: B560 Up: Map Next: B5A4