Prev: C520 Up: Map Next: C579
C556: Handler: Match 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_MatchVerb C556 LD HL,($BD26) Set a pointer to *Pointer_VerbWordTokens in HL.
C559 LD BC,($BD2C) Load *Count_VerbTokens tokens into BC for the search.
C55D LD A,($BD66) Get the *UserInput_Token_1 from the user input.
C560 CPIR Search the verb word tokens table for a matching token.
C562 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.".
C564 LD HL,$BD91 HL=Messaging_IDontUnderstand.
C567 CALL PrintStringAndNewline Call PrintStringAndNewline.
C56A RET Return.
A verb was matched! Calculate its index in the table and jump to its handler routine.
VerbMatched C56B LD A,($BD2C) Calculate the verb index: A=*Count_VerbTokens-C (total tokens minus remaining tokens after match).
C56E SUB C
C56F DEC A Adjust the index (decrease by one, as indices are zero-based).
C570 LD E,A Store the verb index in E for the table lookup.
C571 LD IX,($BD20) Set a pointer to *Pointer_JumpTable_Verbs in IX.
C575 CALL GetTableEntry Call GetTableEntry to get the address of the verb handler routine for this index.
C578 JP (HL) Jump to the verb handler routine to execute the command.
Prev: C520 Up: Map Next: C579