Prev: C041 Up: Map Next: C17D
C058: Handler: User Pressed "ENTER"
Used by the routine at Handler_UserInput.
Handles the user pressing "ENTER".
Input
HL Current position in the command buffer
A Which contains 0D ("ENTER") at this point.
UserInput_Enter C058 LD (HL),A Write 0D to the command buffer pointer for use as a termination character.
Force a newline to be "printed" to the screen.
C059 CALL SwitchNormalScreenOutput Call SwitchNormalScreenOutput.
C05C CALL PrintCharacter Call PrintCharacter.
Clear down the word token buffer which will eventually hold the tokenised input.
C05F LD HL,$BD66 HL=UserInput_Token_1.
C062 LD A,$FF A=FF.
C064 LD B,$0A Set a counter in B for the size of the word token buffer (0A bytes).
Write FF 0A times wiping the word token buffer.
EmptyWordTokenBuffer_Loop C066 LD (HL),A Write A to *HL.
C067 INC HL Increment HL by one.
C068 DJNZ EmptyWordTokenBuffer_Loop Decrease the word token buffer counter by one and loop back to EmptyWordTokenBuffer_Loop until the whole buffer is cleared.
C06A LD HL,$BD34 HL=CommandBuffer.
C06D LD C,$0A C=0A.
Now begin tokenising the user input.
UserInputParser_Loop C06F LD DE,$BD71 DE=BD71.
C072 LD B,$04 B=04.
C074 LD A,$20 Write ASCII "SPACE" (20) to *DE.
UserInput_Enter_0 C076 LD (DE),A
C077 INC DE Increment DE by one.
C078 DJNZ UserInput_Enter_0 Decrease counter by one and loop back to UserInput_Enter_0 until counter is zero.
C07A XOR A A=00.
C07B OR C Set the bits from C.
C07C JP Z,UserInput_Enter_19 Jump to UserInput_Enter_19 if DE is equal to C.
C07F LD A,(HL) Jump to UserInput_Enter_19 if *HL is equal to 0D.
C080 CP $0D
C082 JP Z,UserInput_Enter_19
C085 LD B,$04 B=04.
C087 LD DE,$BD71 DE=BD71.
UserInput_Enter_1 C08A LD A,(HL) A=*HL.
C08B CP $0D Jump to UserInput_Enter_4 if A is equal to 0D.
C08D JR Z,UserInput_Enter_4
C08F CP $20 Jump to UserInput_Enter_3 if A is equal to 20.
C091 JR Z,UserInput_Enter_3
C093 CP $2C Jump to UserInput_Enter_3 if A is equal to 2C.
C095 JR Z,UserInput_Enter_3
C097 LD (DE),A Write A to *DE.
C098 INC HL Increment HL by one.
C099 INC DE Increment DE by one.
C09A DJNZ UserInput_Enter_1 Decrease counter by one and loop back to UserInput_Enter_1 until counter is zero.
UserInput_Enter_2 C09C LD A,(HL) A=*HL.
C09D CP $0D Jump to UserInput_Enter_4 if A is equal to 0D.
C09F JR Z,UserInput_Enter_4
C0A1 CP $20 Jump to UserInput_Enter_3 if A is equal to 20.
C0A3 JR Z,UserInput_Enter_3
C0A5 CP $2C Jump to UserInput_Enter_3 if A is equal to 2C.
C0A7 JR Z,UserInput_Enter_3
C0A9 INC HL Increment HL by one.
C0AA JR UserInput_Enter_2 Jump to UserInput_Enter_2.
UserInput_Enter_3 C0AC INC HL Increment HL by one.
C0AD LD A,(HL) A=*HL.
C0AE CP $20 Jump to UserInput_Enter_3 if A is equal to 20.
C0B0 JR Z,UserInput_Enter_3
C0B2 CP $2C Jump to UserInput_Enter_3 if A is equal to 2C.
C0B4 JR Z,UserInput_Enter_3
UserInput_Enter_4 C0B6 PUSH HL Stash HL, DE and BC on the stack.
C0B7 PUSH DE
C0B8 PUSH BC
C0B9 LD HL,$BD8C HL=Messaging_The.
C0BC LD DE,$BD71 DE=BD71.
C0BF LD B,$04 B=04.
UserInput_Enter_5 C0C1 LD A,(DE) Jump to UserInput_Enter_6 if *DE is not equal to *HL.
C0C2 CP (HL)
C0C3 JR NZ,UserInput_Enter_6
C0C5 INC DE Increment DE by one.
C0C6 INC HL Increment HL by one.
C0C7 DJNZ UserInput_Enter_5 Decrease counter by one and loop back to UserInput_Enter_5 until counter is zero.
UserInput_Enter_6 C0C9 POP BC Restore BC, DE and HL from the stack.
C0CA POP DE
C0CB POP HL
C0CC JR Z,UserInputParser_Loop Jump to UserInputParser_Loop if HL is equal to *HL.
C0CE DEC C Decrease C by one.
C0CF LD ($BD7D),HL Write HL to *TempStore_TablePointer.
C0D2 LD ($BD7F),DE Write DE to *TempStore_TableIndex.
C0D6 LD ($BD81),BC Write BC to *BD81.
C0DA LD HL,($BD0C) HL=*Pointer_Vocabulary.
C0DD LD C,$00 C=00.
UserInput_Enter_7 C0DF LD A,(HL) Jump to UserInput_Enter_12 if *HL is equal to FF.
C0E0 CP $FF
C0E2 JR Z,UserInput_Enter_12
UserInput_Enter_8 C0E4 LD DE,$BD71 DE=BD71.
C0E7 LD B,$04 B=04.
UserInput_Enter_9 C0E9 LD A,(DE) Jump to UserInput_Enter_10 if *DE is not equal to *HL.
C0EA CP (HL)
C0EB JR NZ,UserInput_Enter_10
C0ED INC DE Increment DE by one.
C0EE INC HL Increment HL by one.
C0EF DJNZ UserInput_Enter_9 Decrease counter by one and loop back to UserInput_Enter_9 until counter is zero.
C0F1 LD HL,$BD81 HL=BD81.
C0F4 LD A,$09 A=09.
C0F6 SUB (HL) A-=*HL.
C0F7 LD D,$00 D=00.
C0F9 LD E,A E=A.
C0FA LD HL,$BD66 HL=UserInput_Token_1+DE.
C0FD ADD HL,DE
C0FE LD (HL),C Write C to *HL.
C0FF LD HL,($BD7D) HL=*TempStore_TablePointer.
C102 LD DE,($BD7F) DE=*TempStore_TableIndex.
C106 LD BC,($BD81) BC=*BD81.
C10A JP UserInputParser_Loop Jump to UserInputParser_Loop.
UserInput_Enter_10 C10D LD E,B E=B.
C10E LD D,$00 D=00.
C110 ADD HL,DE HL+=DE.
C111 LD A,(HL) A=*HL.
C112 CP $2C Jump to UserInput_Enter_11 if A is not equal to 2C.
C114 JR NZ,UserInput_Enter_11
C116 INC HL Increment HL by one.
C117 JR UserInput_Enter_8 Jump to UserInput_Enter_8.
UserInput_Enter_11 C119 INC C Increment C by one.
C11A JR UserInput_Enter_7 Jump to UserInput_Enter_7.
UserInput_Enter_12 C11C LD HL,($BD7D) HL=*TempStore_TablePointer.
C11F LD DE,($BD7F) DE=*TempStore_TableIndex.
C123 LD BC,($BD81) BC=*BD81.
C127 LD A,$0A C=0A-C.
C129 SUB C
C12A LD C,A
C12B LD HL,$BD34 HL=CommandBuffer.
UserInput_Enter_13 C12E DEC C Decrease C by one.
C12F JR Z,UserInput_Enter_16 Jump to UserInput_Enter_16 if C is equal to 0A.
UserInput_Enter_14 C131 LD A,(HL) A=*HL.
C132 CP $20 Jump to UserInput_Enter_15 if A is equal to 20.
C134 JR Z,UserInput_Enter_15
C136 CP $2C Jump to UserInput_Enter_15 if A is equal to 2C.
C138 JR Z,UserInput_Enter_15
C13A INC HL Increment HL by one.
C13B JR UserInput_Enter_14 Jump to UserInput_Enter_14.
UserInput_Enter_15 C13D INC HL Increment HL by one.
C13E LD A,(HL) A=*HL.
C13F CP $20 Jump to UserInput_Enter_15 if A is equal to 20.
C141 JR Z,UserInput_Enter_15
C143 CP $2C Jump to UserInput_Enter_15 if A is equal to 2C.
C145 JR Z,UserInput_Enter_15
C147 JR UserInput_Enter_13 Jump to UserInput_Enter_13.
UserInput_Enter_16 C149 PUSH HL Stash HL on the stack.
Print "I don't know the word:-".
C14A LD HL,$BDA5 HL=Messaging_IDontKnowTheWord.
C14D CALL PrintStringAndNewline Call PrintStringAndNewline.
C150 POP HL Restore HL from the stack.
C151 LD A,$22 Print a double quote character: """.
C153 CALL PrintCharacter
UserInput_Enter_17 C156 LD A,(HL) A=*HL.
C157 CP $21 Jump to UserInput_Enter_18 if A is less than 21.
C159 JR C,UserInput_Enter_18
C15B INC HL Increment HL by one.
C15C CALL PrintCharacter Call PrintCharacter.
C15F JR UserInput_Enter_17 Jump to UserInput_Enter_17.
UserInput_Enter_18 C161 LD A,$22 Print a double quote character: """.
C163 CALL PrintCharacter
Print ".".
C166 LD HL,$BF29 HL=Messaging_FullStop.
C169 CALL PrintStringAndNewline Call PrintStringAndNewline.
C16C JR UserInput_Enter_20 Jump to UserInput_Enter_20.
UserInput_Enter_19 C16E LD A,($BD66) Return if *UserInput_Token_1 is not equal to FF.
C171 CP $FF
C173 RET NZ
Print "I don't understand.".
C174 LD HL,$BD91 HL=Messaging_IDontUnderstand.
C177 CALL PrintStringAndNewline Call PrintStringAndNewline.
UserInput_Enter_20 C17A JP Handler_UserInput Jump to Handler_UserInput.
Prev: C041 Up: Map Next: C17D