Prev: 8D2A Up: Map Next: 8DAD
8D85: Handler: Dispatch Verb
Used by the routines at GameLoop and HandlerResolveSynonym.
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 to the game loop.
Set up to search the verb word tokens table for the first word token.
Handler_DispatchVerb 8D85 LD HL,$891C Set a pointer to Table_VerbSearchList in HL.
8D88 LD BC,($62DA) Load *Count_VerbTokens tokens into BC for the search.
8D8C LD A,($6291) Get the *UserInput_FirstToken from the user input.
8D8F CPIR Search the verb word tokens table for a matching token.
8D91 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.".
8D93 LD HL,$62EC HL=Messaging_IDonTUnderstand.
8D96 CALL PrintStringAndANewline Call PrintStringAndANewline.
8D99 JR GameLoop Jump to GameLoop to read the next command.
A verb was matched! Calculate its index in the table and jump to its handler routine.
VerbMatched 8D9B LD A,($62DA) Calculate the verb index: A=*Count_VerbTokens-C (total tokens minus remaining tokens after match).
8D9E SUB C
8D9F DEC A Adjust the index (decrease by one, as indices are zero-based).
8DA0 LD E,A Store the verb index in E for the table lookup.
8DA1 LD IX,($62D8) Set a pointer to *Pointer_JumpTable_Verbs in IX.
8DA5 CALL GetTableEntry Call GetTableEntry to get the address of the verb handler routine for this index.
This entry point is used by the routine at GameLoop.
Run the matched verb handler, then return to the game loop.
VerbMatched_Run 8DA8 LD DE,$8D2A Load GameLoop into DE as the return address.
8DAB PUSH DE Stash the game-loop return address on the stack.
8DAC JP (HL) Jump to the verb handler routine to execute the command.
Prev: 8D2A Up: Map Next: 8DAD