Prev: 6CCD Up: Map Next: 6DCC
6CEC: Turn: Read And Tokenise The Command
Reads the player's command or replays a stored one, tokenises the words and hands them to the Inglish matcher.
TurnReadAndTokeniseTheCommand 6CEC LD A,$11 Write 11 to B716.
6CEE LD ($B716),A
6CF1 LD A,($B706) Read the replay path.
6CF4 INC A Count on from the replay path.
6CF5 JR NZ,TurnReadAndTokeniseTheCommand_SetTheLineReadFlag If A is not zero then jump to TurnReadAndTokeniseTheCommand_SetTheLineReadFlag.
6CF7 CALL Turn_ResetToThePlayer Call Turn_ResetToThePlayer to reset the turn to the player.
6CFA LD HL,$6FF2 Point at the input buffer.
TurnReadAndTokeniseTheCommand_Loop 6CFD LD A,(HL) Read the next byte of the input buffer.
Echo this character of the stored line.
6CFE CALL Print_Character_0 Call Print_Character_0 to print one character.
6D01 INC HL Jump back to TurnReadAndTokeniseTheCommand_Loop if the front of the line is not 0D.
6D02 CP $0D
6D04 JR NZ,TurnReadAndTokeniseTheCommand_Loop
6D06 LD HL,$6FF4 Copies 05 bytes from 6FF4 to 6FF9.
6D09 LD DE,$6FF9
6D0C LD BC,$0005
6D0F LDIR
6D11 JR TurnReadAndTokeniseTheCommand_ClearTheTokenBuffer Jump to TurnReadAndTokeniseTheCommand_ClearTheTokenBuffer to clear the token buffer.
TurnReadAndTokeniseTheCommand_SetTheLineReadFlag 6D13 LD A,$01 Write 01 to B705.
6D15 LD ($B705),A
6D18 LD A,$09 Write 09 to B716.
6D1A LD ($B716),A
6D1D CALL ReadTheInputLine Call ReadTheInputLine to read the input line.
6D20 JR Z,TurnReadAndTokeniseTheCommand_PointAtTheTokens Jump to TurnReadAndTokeniseTheCommand_PointAtTheTokens if ReadTheInputLine returned with the zero flag set.
TurnReadAndTokeniseTheCommand_ClearTheTokenBuffer 6D22 LD HL,$709C Write 00 to 40 bytes, starting from 709C with Blanker.
6D25 LD B,$40
6D27 CALL Blanker
6D2A LD HL,$6FF9 Point at the input buffer.
6D2D LD IY,$709C Point IY at the token buffer.
TurnReadAndTokeniseTheCommand_TakeTheNextWord 6D31 CALL Input_TakeTheNextWord Call Input_TakeTheNextWord to take the next word.
6D34 CP $D0 Jump to TurnReadAndTokeniseTheCommand_ShowTheUnknownWord if the byte from Input_TakeTheNextWord is D0.
6D36 JR Z,TurnReadAndTokeniseTheCommand_ShowTheUnknownWord
6D38 CP $90 Jump to TurnReadAndTokeniseTheCommand_StoreTheToken if that byte is not 90.
6D3A JR NZ,TurnReadAndTokeniseTheCommand_StoreTheToken
6D3C LD A,B Jump to TurnReadAndTokeniseTheCommand_StoreTheToken if the low nibble of B or any bit of C is set.
6D3D AND $0F
6D3F OR C
6D40 JR NZ,TurnReadAndTokeniseTheCommand_StoreTheToken
Test the conjunction count.
6D42 LD A,($B71B) Jump to TurnReadAndTokeniseTheCommand_CountConjunctions if *B71B is not zero.
6D45 AND A
6D46 JR NZ,TurnReadAndTokeniseTheCommand_CountConjunctions
6D48 INC A Count on from the conjunction count.
6D49 LD ($B71B),A Update *B71B.
6D4C JR TurnReadAndTokeniseTheCommand_StoreTheToken Jump to TurnReadAndTokeniseTheCommand_StoreTheToken to skip updating the conjunction count.
TurnReadAndTokeniseTheCommand_CountConjunctions 6D4E DEC A Step the conjunction count down by one.
6D4F LD ($B71B),A Update *B71B.
6D52 LD A,(IY-$02) Read the previous token byte from IY.
6D55 AND $F0 Jump to TurnReadAndTokeniseTheCommand_StoreTheToken if the high nibble of the clause byte at offset -2 is B0.
6D57 CP $B0
6D59 JR Z,TurnReadAndTokeniseTheCommand_StoreTheToken
6D5B CP $A0 Jump to TurnReadAndTokeniseTheCommand_StoreTheToken if the high nibble of the clause byte at offset -2 is A0.
6D5D JR Z,TurnReadAndTokeniseTheCommand_StoreTheToken
6D5F LD A,$B0 Mark this token as a full stop.
6D61 LD (IY+$00),A Store the token byte in the buffer at IY.
6D64 XOR A Take zero for the next token byte.
6D65 LD (IY+$01),A Store that zero in the token buffer at IY.
6D68 INC IY Step to the next byte of the token buffer.
6D6A INC IY
TurnReadAndTokeniseTheCommand_StoreTheToken 6D6C LD (IY+$00),B Store the token byte in the buffer at IY.
6D6F LD (IY+$01),C Store the token's second byte in the buffer at IY.
6D72 INC IY Jump back to TurnReadAndTokeniseTheCommand_TakeTheNextWord unless the class in D is C0.
6D74 INC IY
6D76 LD A,D
6D77 CP $C0
6D79 JR NZ,TurnReadAndTokeniseTheCommand_TakeTheNextWord
Test the conjunction count.
6D7B LD A,($B71B) Jump to TurnReadAndTokeniseTheCommand_PointAtTheTokens if *B71B is zero.
6D7E AND A
6D7F JR Z,TurnReadAndTokeniseTheCommand_PointAtTheTokens
6D81 XOR A Clear *B71B.
6D82 LD ($B71B),A
Deal with the conjunction before the next line.
6D85 CALL Inglish_AskWhat_1 Call Inglish_AskWhat_1 to ask "what ?" and set the action countdown.
6D88 JR TurnReadAndTokeniseTheCommand_SetTheLineReadFlag Jump back to TurnReadAndTokeniseTheCommand_SetTheLineReadFlag to update the line-read flag.
TurnReadAndTokeniseTheCommand_PointAtTheTokens 6D8A LD HL,$709C Point *B6DC at 709C.
6D8D LD ($B6DC),HL
Match the tokens against the grammar.
TurnReadAndTokeniseTheCommand_PrepareTheClause 6D90 CALL InglishPrepareTheClause_0 Call InglishPrepareTheClause_0 to prepare the clause.
6D93 JP NZ,TurnReadAndTokeniseTheCommand_SetTheLineReadFlag Jump back to TurnReadAndTokeniseTheCommand_SetTheLineReadFlag if InglishPrepareTheClause_0 returned with the zero flag clear.
Carry out the matched command.
6D96 CALL InglishApplyAMatch Call InglishApplyAMatch to apply A match.
Test the line-read flag.
6D99 LD A,($B705) Jump to TurnReadAndTokeniseTheCommand_PrepareTheClause if *B705 is not zero.
6D9C AND A
6D9D JR NZ,TurnReadAndTokeniseTheCommand_PrepareTheClause
6D9F JP TurnReadAndTokeniseTheCommand_SetTheLineReadFlag Jump back to TurnReadAndTokeniseTheCommand_SetTheLineReadFlag to update the line-read flag.
TurnReadAndTokeniseTheCommand_ShowTheUnknownWord 6DA2 LD HL,$AD93 Point at the message "i do not know the word " (AD93).
6DA5 LD A,$01 Write 01 to WaitCountdown.
6DA7 LD ($B701),A
6DAA CALL PrintMessage Call PrintMessage to print message.
6DAD LD HL,($B6DA) Read *B6DA.
TurnReadAndTokeniseTheCommand_TestForEnter 6DB0 LD A,(HL) Jump to TurnReadAndTokeniseTheCommand_PrintAQuote if the unknown word is 0D.
6DB1 CP $0D
6DB3 JR Z,TurnReadAndTokeniseTheCommand_PrintAQuote
6DB5 CP $22 Jump to TurnReadAndTokeniseTheCommand_PrintAQuote if the unknown word is 22.
6DB7 JR Z,TurnReadAndTokeniseTheCommand_PrintAQuote
Print the character in A.
6DB9 CALL Print_Character Call Print_Character to print one character.
6DBC INC HL Jump back to TurnReadAndTokeniseTheCommand_TestForEnter if the unknown word is not 20.
6DBD CP $20
6DBF JR NZ,TurnReadAndTokeniseTheCommand_TestForEnter
Print a quote.
TurnReadAndTokeniseTheCommand_PrintAQuote 6DC1 LD A,$22 Print a quote.
6DC3 CALL Print_Character
Print a newline.
6DC6 CALL Print_LineBreak Call Print_LineBreak to print a newline.
6DC9 JP TurnReadAndTokeniseTheCommand_SetTheLineReadFlag Jump back to TurnReadAndTokeniseTheCommand_SetTheLineReadFlag to update the line-read flag.
Prev: 6CCD Up: Map Next: 6DCC