Prev: 6E8B Up: Map Next: 6F30
6E97: Input: Take The Next Word
Used by the routine at TurnReadAndTokeniseTheCommand.
Skips spaces, stores the start of the next word, and classifies it.
Input_TakeTheNextWord 6E97 PUSH DE Jump back to Input_TakeTheNextWord_SkipSpaces if the line being typed is a space.
Input_TakeTheNextWord_SkipSpaces 6E98 LD A,(HL)
6E99 INC HL
6E9A CP $20
6E9C JR Z,Input_TakeTheNextWord_SkipSpaces
6E9E DEC HL Step back one byte through 6FF9.
6E9F LD ($B6DA),HL Update *B6DA.
6EA2 CP $0D Jump to Input_TakeTheNextWord_MarkTheEndOfTheCommand if the line being typed is ENTER.
6EA4 JR Z,Input_TakeTheNextWord_MarkTheEndOfTheCommand
6EA6 CALL Input_ClassifyPunctuation Call Input_ClassifyPunctuation to classify punctuation.
6EA9 JR Z,Input_TakeTheNextWord_ReturnTheClass Jump to Input_TakeTheNextWord_ReturnTheClass if Input_ClassifyPunctuation classified this character as punctuation.
6EAB CALL Input_CopyADictionaryWord Call Input_CopyADictionaryWord to copy a dictionary word.
6EAE JR NZ,Input_TakeTheNextWord_MarkThisTokenAsAnUnknownWord Jump to Input_TakeTheNextWord_MarkThisTokenAsAnUnknownWord if Input_CopyADictionaryWord found no dictionary word starting with the typed word's first letter.
6EB0 PUSH HL
Input_TakeTheNextWord_CompareTheDictionaryWord 6EB1 CALL Input_CompareTheDictionaryWord Call Input_CompareTheDictionaryWord to compare the dictionary word.
6EB4 JR Z,Input_TakeTheNextWord_CompareTheWordLengths Jump to Input_TakeTheNextWord_CompareTheWordLengths if Input_CompareTheDictionaryWord found the words match.
Input_TakeTheNextWord_CopyADictionaryWord 6EB6 CALL Input_CopyADictionaryWord_0 Call Input_CopyADictionaryWord_0 to copy a dictionary word.
6EB9 JR Z,Input_TakeTheNextWord_CompareTheDictionaryWord Jump back to Input_TakeTheNextWord_CompareTheDictionaryWord while Input_CopyADictionaryWord_0 finds another dictionary word with the same first letter.
6EBB POP HL
Input_TakeTheNextWord_MarkThisTokenAsAnUnknownWord 6EBC LD A,$D0 Mark this token as an unknown word.
6EBE JR Input_TakeTheNextWord_FinishTheUnknownWord Jump to Input_TakeTheNextWord_FinishTheUnknownWord to finish this unknown-word token.
Input_TakeTheNextWord_CompareTheWordLengths 6EC0 LD A,($708A) Read *708A.
6EC3 LD B,A Copy the result into B.
6EC4 LD A,($709B) Read *709B.
6EC7 CP B Jump to Input_TakeTheNextWord_LoadTheDictionaryPointer if the length of the dictionary word is not below the length of the typed word.
6EC8 JR NC,Input_TakeTheNextWord_LoadTheDictionaryPointer
6ECA CP $04 Jump back to Input_TakeTheNextWord_CopyADictionaryWord if the length of the dictionary word is below 04.
6ECC JR C,Input_TakeTheNextWord_CopyADictionaryWord
6ECE PUSH IX Call Input_CopyADictionaryWord_1 to unpack the dictionary word when its length matches the typed word.
6ED0 CALL Input_CopyADictionaryWord_1
6ED3 JR NZ,Input_TakeTheNextWord_PopTheSavedPointer Jump to Input_TakeTheNextWord_PopTheSavedPointer if Input_CopyADictionaryWord_1 found a mismatch.
6ED5 CALL Input_CompareTheDictionaryWord Call Input_CompareTheDictionaryWord to compare the dictionary word.
6ED8 JR NZ,Input_TakeTheNextWord_PopTheSavedPointer Jump to Input_TakeTheNextWord_PopTheSavedPointer if Input_CompareTheDictionaryWord found the words differ.
6EDA POP IX Jump back to Input_TakeTheNextWord_CopyADictionaryWord to read the input line.
6EDC JR Input_TakeTheNextWord_CopyADictionaryWord
Input_TakeTheNextWord_MarkTheEndOfTheCommand 6EDE LD A,$C0 Mark this token as the end of a command.
Input_TakeTheNextWord_FinishTheUnknownWord 6EE0 LD BC,$0000 Start from a clear pointer.
Input_TakeTheNextWord_ReturnTheClass 6EE3 POP DE Keep the low byte of the saved pointer and put the class in D.
6EE4 LD D,A
6EE5 ADD A,B Add the length of the typed word to the class in A.
6EE6 LD B,A Copy the result into B.
6EE7 LD A,D Restore the end-of-command class C0.
6EE8 RET Return.
Input_TakeTheNextWord_PopTheSavedPointer 6EE9 POP IX Read *B717.
Input_TakeTheNextWord_LoadTheDictionaryPointer 6EEB LD IX,($B717)
6EEF PUSH IX Save the dictionary pointer and start the length at zero.
6EF1 XOR A
Input_TakeTheNextWord_StepThroughTheDictionaryWord 6EF2 INC IX Step to the next dictionary byte and loop back to Input_TakeTheNextWord_StepThroughTheDictionaryWord while bit 7 of that byte is clear.
6EF4 INC A
6EF5 BIT 7,(IX-$01)
6EF9 JR Z,Input_TakeTheNextWord_StepThroughTheDictionaryWord
6EFB CP $02 Jump back to Input_TakeTheNextWord_StepThroughTheDictionaryWord if the dictionary byte count is 02.
6EFD JR Z,Input_TakeTheNextWord_StepThroughTheDictionaryWord
6EFF CP $03 Jump to Input_TakeTheNextWord_TestForAnOffset unless the byte is 03.
6F01 JR NZ,Input_TakeTheNextWord_TestForAnOffset
6F03 BIT 7,(IX-$02) Jump back to Input_TakeTheNextWord_StepThroughTheDictionaryWord if bit 7 of the earlier dictionary byte is set.
6F07 JR NZ,Input_TakeTheNextWord_StepThroughTheDictionaryWord
Input_TakeTheNextWord_TestForAnOffset 6F09 BIT 6,(IX-$01) Jump to Input_TakeTheNextWord_PackTheClassBits if bit 6 of this dictionary byte is clear.
6F0D JR Z,Input_TakeTheNextWord_PackTheClassBits
6F0F LD L,(IX+$00) Read the low byte of this dictionary offset.
6F12 LD H,(IX+$01) Read the high byte of this dictionary offset.
6F15 LD DE,$6000 Add the dictionary base at WordIndex.
6F18 ADD HL,DE
6F19 EX (SP),HL Exchange the dictionary address with the pointer saved on the stack.
Input_TakeTheNextWord_PackTheClassBits 6F1A POP HL Pack the top two bits of this letter into the class.
6F1B LD A,(HL)
6F1C RLCA
6F1D AND $C0
6F1F LD B,A
6F20 INC HL Step to the next byte of the input buffer.
6F21 LD A,(HL) Pack the next two bits of the following letter into the class.
6F22 RRCA
6F23 AND $30
6F25 ADD A,B Combine the two pairs of class bits.
6F26 DEC HL Step back one byte through 6FF9.
6F27 LD DE,$A000 Add the A000 token base onto the token pointer.
6F2A ADD HL,DE Add the token base to 6FF9.
6F2B PUSH HL Keep the token address in BC and jump to Input_TakeTheNextWord_ReturnTheClass to return the class.
6F2C POP BC
6F2D POP HL
6F2E JR Input_TakeTheNextWord_ReturnTheClass
Prev: 6E8B Up: Map Next: 6F30