Prev: B714 Up: Map Next: B776
B753: Handler: Dispatch Verb
Used by the routine at GameLoop.
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 B753 LD HL,($AEEA) Set a pointer to *Pointer_VerbWordTokens in HL.
B756 LD BC,($AEF4) Load *Count_VerbTokens tokens into BC for the search.
B75A LD A,($AF2E) Get the *UserInput_FirstToken from the user input.
B75D CPIR Search the verb word tokens table for a matching token.
B75F 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.".
B761 LD HL,$AF59 HL=Messaging_IDontUnderstand.
B764 CALL PrintStringAndNewline Call PrintStringAndNewline.
B767 RET Return.
A verb was matched! Calculate its index in the table and jump to its handler routine.
VerbMatched B768 LD A,($AEF4) Calculate the verb index: A=*Count_VerbTokens-C (total tokens minus remaining tokens after match).
B76B SUB C
B76C DEC A Adjust the index (decrease by one, as indices are zero-based).
B76D LD E,A Store the verb index in E for the table lookup.
B76E LD IX,($AEE4) Set a pointer to *Pointer_JumpTable_Verbs in IX.
B772 CALL GetTableEntry Call GetTableEntry to get the address of the verb handler routine for this index.
B775 JP (HL) Jump to the verb handler routine to execute the command.
Prev: B714 Up: Map Next: B776