Prev: 26652 Up: Map Next: 26798
26726: Lookup Word
Used by the routines at START_TURN and NOUN_CHECK.
Lookup word in vocabulary
Input
HL points to entered characters
Output
A id of the matching word
LOOKUP_WORD 26726 LD A,223 A=space (stored XOR 255)
26728 LD DE,27351 Word entry buffer
26731 LD B,4 Word buffer has 4 characters
LOOKUP_WORD_0 26733 DEC DE
26734 LD (DE),A Fill buffer with spaces
26735 DJNZ LOOKUP_WORD_0 Loop until buffer is full
26737 LD B,4 B=each word has 4 characters
LOOKUP_WORD_1 26739 LD A,(HL) Read next character
26740 CP 32 Is it a space?
26742 JR Z,LOOKUP_WORD_2 If so, skip forward to process word
26744 CP 13 Is it a newline?
26746 JR Z,LOOKUP_WORD_2 If so, skip forward to process word
26748 CPL Encode character by XORing with 255
26749 LD (DE),A Store character in buffer
26750 INC DE Move buffer pointer up by one
26751 INC HL Move entered characters pointer up by one
26752 DJNZ LOOKUP_WORD_1 Loop to read next character until we have 4
LOOKUP_WORD_2 26754 LD BC,(27557) BC=address of vocabulary table
26758 PUSH HL
This entry point is used by the routine at LOOKUP_WORD_7.
LOOKUP_WORD_3 26759 LD HL,27347 HL=start of word entered buffer
26762 RES 5,(IY+8) Reset 'non-matching character' flag
26766 LD D,4 4 characters in each word to look at
This entry point is used by the routine at LOOKUP_WORD_5.
LOOKUP_WORD_4 26768 LD A,(BC) Read character from vocab table
26769 OR A Have we reached the end of the vocab table?
This entry point is used by the routine at ACTION_ROUTINES.
26770 JR NZ,LOOKUP_WORD_5 If not, process vocab entry
26772 POP HL
26773 RET If we have, then return with A=0
LOOKUP_WORD_5 26774 CP (HL) Does character in word match character entered?
26775 JR Z,LOOKUP_WORD_6 If so, skip setting flag
26777 SET 5,(IY+8) Set flag to indicate that character does not match
LOOKUP_WORD_6 26781 INC BC Onto next character in vocab table
26782 INC HL Onto next character in word entered buffer
26783 DEC D Decrement character counter
26784 JR NZ,LOOKUP_WORD_4 If not yet zero, check next character
26786 BIT 5,(IY+8) Do all characters match?
26790 JR NZ,LOOKUP_WORD_7 If not, try next word
26792 LD A,(BC) If so, set A to the ID of the word found
26793 POP HL
26794 RET Return with A containing ID of matching word
LOOKUP_WORD_7 26795 INC BC Move on to next vocab word
26796 JR LOOKUP_WORD_3 Try matching this word against entered
Prev: 26652 Up: Map Next: 26798