Prev: 26848 Up: Map Next: 26927
26880: Parser: Advance To Separator
Input
HL Pointer to phrase token data
Output
F Z flag set when the input matches any wording
Parser_AdvanceToSeparator 26880 EX DE,HL Switch the phrase token pointer to DE.
26881 JR Parser_AdvanceToSeparator_Step1 Jump to Parser_AdvanceToSeparator_Step1.
Skip the separator.
Parser_AdvanceToSeparator_Loop1 26883 INC DE Advance to the next byte of the phrase.
Fetch the second user input token (not the verb).
For example; "TAKE" (verb) "KEY" (direct object).
Parser_AdvanceToSeparator_Step1 26884 LD HL,25234 HL=UserInput_SecondToken.
26887 JR Parser_AdvanceToSeparator_Step2 Jump to Parser_AdvanceToSeparator_Step2.
The tokens matched, so advance both pointers.
Parser_AdvanceToSeparator_Loop2 26889 INC HL Advance the input token pointer.
26890 INC DE Advance the phrase token pointer.
Keep looping while the tokens match.
Parser_AdvanceToSeparator_Step2 26891 LD A,(DE) Read the next byte of the phrase.
26892 CP (HL) Jump to Parser_AdvanceToSeparator_Loop2 while this token agrees with the phrase.
26893 JR Z,Parser_AdvanceToSeparator_Loop2
The tokens differ. Is this the end of the wording (254)?
26895 CP 254 Jump to Parser_AdvanceToSeparator_Step3 unless this is the terminator (254).
26897 JR NZ,Parser_AdvanceToSeparator_Step3
The input matched this wording.
26899 LD A,(HL) Fetch the next input token.
26900 CP 255 Return with the Z flag set when the command has also ended (255).
26902 RET Return.
Is this an alternative separator (253)?
Parser_AdvanceToSeparator_Step3 26903 CP 253 Jump to Parser_AdvanceToSeparator_Loop3 unless this is the separator (253).
26905 JR NZ,Parser_AdvanceToSeparator_Loop3
26907 LD A,(HL) Fetch the next input token.
26908 CP 255 Jump back to Parser_AdvanceToSeparator_Loop1 when more input remains.
26910 JR NZ,Parser_AdvanceToSeparator_Loop1
26912 RET Return.
This wording failed; skip to the next alternative.
Parser_AdvanceToSeparator_Loop3 26913 INC DE Skip ahead to the next separator or terminator.
26914 LD A,(DE)
26915 CP 254
26917 JR Z,Parser_AdvanceToSeparator_Step4
26919 CP 253
26921 JR NZ,Parser_AdvanceToSeparator_Loop3
26923 JR Parser_AdvanceToSeparator_Loop1 Jump back to Parser_AdvanceToSeparator_Loop1 to try the next wording.
No wording matched.
Parser_AdvanceToSeparator_Step4 26925 OR A Clear the Z flag.
26926 RET Return.
Prev: 26848 Up: Map Next: 26927