Prev: 36138 Up: Map Next: 36269
36229: 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 36229 LD HL,35100 Set a pointer to Table_VerbSearchList in HL.
36232 LD BC,(25306) Load *Count_VerbTokens tokens into BC for the search.
36236 LD A,(25233) Get the *UserInput_FirstToken from the user input.
36239 CPIR Search the verb word tokens table for a matching token.
36241 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.".
36243 LD HL,25324 HL=Messaging_IDonTUnderstand.
36246 CALL PrintStringAndANewline Call PrintStringAndANewline.
36249 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 36251 LD A,(25306) Calculate the verb index: A=*Count_VerbTokens-C (total tokens minus remaining tokens after match).
36254 SUB C
36255 DEC A Adjust the index (decrease by one, as indices are zero-based).
36256 LD E,A Store the verb index in E for the table lookup.
36257 LD IX,(25304) Set a pointer to *Pointer_JumpTable_Verbs in IX.
36261 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 36264 LD DE,36138 Load GameLoop into DE as the return address.
36267 PUSH DE Stash the game-loop return address on the stack.
36268 JP (HL) Jump to the verb handler routine to execute the command.
Prev: 36138 Up: Map Next: 36269