Prev: 45087 Up: Map Next: 45185
45150: Handler: Dispatch Verb
Used by the routines at GameLoop and Parser_ShiftSecondTokenToVerb.
Matches the first word token from the user's command against the verb word tokens table. If a match is found, it calculates the verb index and jumps to the corresponding verb handler routine. If no match is found, it displays "I Don't Understand" and returns.
Set up to search the verb word tokens table for the first word token.
Handler_DispatchVerb 45150 LD HL,(42976) Set a pointer to *Pointer_VerbWordTokens in HL.
45153 LD BC,(42986) Load *Count_VerbTokens tokens into BC for the search.
45157 LD A,(43044) Get the *UserInput_FirstToken from the user input.
45160 CPIR Search the verb word tokens table for a matching token.
45162 JR Z,VerbMatched Jump to VerbMatched if a match was found (Z flag is set).
The token doesn't match any verb. Display an error message: "I don't understand.".
45164 LD HL,43087 HL=Messaging_IDontUnderstand.
45167 CALL PrintStringAndNewline Call PrintStringAndNewline.
45170 RET Return.
A verb was matched! Calculate its index in the table and jump to its handler routine.
VerbMatched 45171 LD A,(42986) Calculate the verb index: A=*Count_VerbTokens-C (total tokens minus remaining tokens after match).
45174 SUB C
45175 DEC A Adjust the index (decrease by one, as indices are zero-based).
45176 LD E,A Store the verb index in E for the table lookup.
45177 LD IX,(42970) Set a pointer to *Pointer_JumpTable_Verbs in IX.
45181 CALL GetTableEntry Call GetTableEntry to get the address of the verb handler routine for this index.
45184 JP (HL) Jump to the verb handler routine to execute the command.
Prev: 45087 Up: Map Next: 45185