Prev: 49217 Up: Map Next: 49533
49240: 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 13 ("ENTER") at this point.
UserInput_Enter 49240 LD (HL),A Write 13 to the command buffer pointer for use as a termination character.
Force a newline to be "printed" to the screen.
49241 CALL SwitchNormalScreenOutput Call SwitchNormalScreenOutput.
49244 CALL PrintCharacter Call PrintCharacter.
Clear down the word token buffer which will eventually hold the tokenised input.
49247 LD HL,48486 HL=UserInput_Token_1.
49250 LD A,255 A=255.
49252 LD B,10 Set a counter in B for the size of the word token buffer (10 bytes).
Write 255 10 times wiping the word token buffer.
EmptyWordTokenBuffer_Loop 49254 LD (HL),A Write A to *HL.
49255 INC HL Increment HL by one.
49256 DJNZ EmptyWordTokenBuffer_Loop Decrease the word token buffer counter by one and loop back to EmptyWordTokenBuffer_Loop until the whole buffer is cleared.
49258 LD HL,48436 HL=CommandBuffer.
49261 LD C,10 C=10.
Now begin tokenising the user input.
UserInputParser_Loop 49263 LD DE,48497 DE=48497.
49266 LD B,4 B=4.
49268 LD A,32 Write ASCII "SPACE" (32) to *DE.
UserInput_Enter_0 49270 LD (DE),A
49271 INC DE Increment DE by one.
49272 DJNZ UserInput_Enter_0 Decrease counter by one and loop back to UserInput_Enter_0 until counter is zero.
49274 XOR A A=0.
49275 OR C Set the bits from C.
49276 JP Z,UserInput_Enter_19 Jump to UserInput_Enter_19 if DE is equal to C.
49279 LD A,(HL) Jump to UserInput_Enter_19 if *HL is equal to 13.
49280 CP 13
49282 JP Z,UserInput_Enter_19
49285 LD B,4 B=4.
49287 LD DE,48497 DE=48497.
UserInput_Enter_1 49290 LD A,(HL) A=*HL.
49291 CP 13 Jump to UserInput_Enter_4 if A is equal to 13.
49293 JR Z,UserInput_Enter_4
49295 CP 32 Jump to UserInput_Enter_3 if A is equal to 32.
49297 JR Z,UserInput_Enter_3
49299 CP 44 Jump to UserInput_Enter_3 if A is equal to 44.
49301 JR Z,UserInput_Enter_3
49303 LD (DE),A Write A to *DE.
49304 INC HL Increment HL by one.
49305 INC DE Increment DE by one.
49306 DJNZ UserInput_Enter_1 Decrease counter by one and loop back to UserInput_Enter_1 until counter is zero.
UserInput_Enter_2 49308 LD A,(HL) A=*HL.
49309 CP 13 Jump to UserInput_Enter_4 if A is equal to 13.
49311 JR Z,UserInput_Enter_4
49313 CP 32 Jump to UserInput_Enter_3 if A is equal to 32.
49315 JR Z,UserInput_Enter_3
49317 CP 44 Jump to UserInput_Enter_3 if A is equal to 44.
49319 JR Z,UserInput_Enter_3
49321 INC HL Increment HL by one.
49322 JR UserInput_Enter_2 Jump to UserInput_Enter_2.
UserInput_Enter_3 49324 INC HL Increment HL by one.
49325 LD A,(HL) A=*HL.
49326 CP 32 Jump to UserInput_Enter_3 if A is equal to 32.
49328 JR Z,UserInput_Enter_3
49330 CP 44 Jump to UserInput_Enter_3 if A is equal to 44.
49332 JR Z,UserInput_Enter_3
UserInput_Enter_4 49334 PUSH HL Stash HL, DE and BC on the stack.
49335 PUSH DE
49336 PUSH BC
49337 LD HL,48524 HL=Messaging_The.
49340 LD DE,48497 DE=48497.
49343 LD B,4 B=4.
UserInput_Enter_5 49345 LD A,(DE) Jump to UserInput_Enter_6 if *DE is not equal to *HL.
49346 CP (HL)
49347 JR NZ,UserInput_Enter_6
49349 INC DE Increment DE by one.
49350 INC HL Increment HL by one.
49351 DJNZ UserInput_Enter_5 Decrease counter by one and loop back to UserInput_Enter_5 until counter is zero.
UserInput_Enter_6 49353 POP BC Restore BC, DE and HL from the stack.
49354 POP DE
49355 POP HL
49356 JR Z,UserInputParser_Loop Jump to UserInputParser_Loop if HL is equal to *HL.
49358 DEC C Decrease C by one.
49359 LD (48509),HL Write HL to *TempStore_TablePointer.
49362 LD (48511),DE Write DE to *TempStore_TableIndex.
49366 LD (48513),BC Write BC to *48513.
49370 LD HL,(48396) HL=*Pointer_Vocabulary.
49373 LD C,0 C=0.
UserInput_Enter_7 49375 LD A,(HL) Jump to UserInput_Enter_12 if *HL is equal to 255.
49376 CP 255
49378 JR Z,UserInput_Enter_12
UserInput_Enter_8 49380 LD DE,48497 DE=48497.
49383 LD B,4 B=4.
UserInput_Enter_9 49385 LD A,(DE) Jump to UserInput_Enter_10 if *DE is not equal to *HL.
49386 CP (HL)
49387 JR NZ,UserInput_Enter_10
49389 INC DE Increment DE by one.
49390 INC HL Increment HL by one.
49391 DJNZ UserInput_Enter_9 Decrease counter by one and loop back to UserInput_Enter_9 until counter is zero.
49393 LD HL,48513 HL=48513.
49396 LD A,9 A=9.
49398 SUB (HL) A-=*HL.
49399 LD D,0 D=0.
49401 LD E,A E=A.
49402 LD HL,48486 HL=UserInput_Token_1+DE.
49405 ADD HL,DE
49406 LD (HL),C Write C to *HL.
49407 LD HL,(48509) HL=*TempStore_TablePointer.
49410 LD DE,(48511) DE=*TempStore_TableIndex.
49414 LD BC,(48513) BC=*48513.
49418 JP UserInputParser_Loop Jump to UserInputParser_Loop.
UserInput_Enter_10 49421 LD E,B E=B.
49422 LD D,0 D=0.
49424 ADD HL,DE HL+=DE.
49425 LD A,(HL) A=*HL.
49426 CP 44 Jump to UserInput_Enter_11 if A is not equal to 44.
49428 JR NZ,UserInput_Enter_11
49430 INC HL Increment HL by one.
49431 JR UserInput_Enter_8 Jump to UserInput_Enter_8.
UserInput_Enter_11 49433 INC C Increment C by one.
49434 JR UserInput_Enter_7 Jump to UserInput_Enter_7.
UserInput_Enter_12 49436 LD HL,(48509) HL=*TempStore_TablePointer.
49439 LD DE,(48511) DE=*TempStore_TableIndex.
49443 LD BC,(48513) BC=*48513.
49447 LD A,10 C=10-C.
49449 SUB C
49450 LD C,A
49451 LD HL,48436 HL=CommandBuffer.
UserInput_Enter_13 49454 DEC C Decrease C by one.
49455 JR Z,UserInput_Enter_16 Jump to UserInput_Enter_16 if C is equal to 10.
UserInput_Enter_14 49457 LD A,(HL) A=*HL.
49458 CP 32 Jump to UserInput_Enter_15 if A is equal to 32.
49460 JR Z,UserInput_Enter_15
49462 CP 44 Jump to UserInput_Enter_15 if A is equal to 44.
49464 JR Z,UserInput_Enter_15
49466 INC HL Increment HL by one.
49467 JR UserInput_Enter_14 Jump to UserInput_Enter_14.
UserInput_Enter_15 49469 INC HL Increment HL by one.
49470 LD A,(HL) A=*HL.
49471 CP 32 Jump to UserInput_Enter_15 if A is equal to 32.
49473 JR Z,UserInput_Enter_15
49475 CP 44 Jump to UserInput_Enter_15 if A is equal to 44.
49477 JR Z,UserInput_Enter_15
49479 JR UserInput_Enter_13 Jump to UserInput_Enter_13.
UserInput_Enter_16 49481 PUSH HL Stash HL on the stack.
Print "I don't know the word:-".
49482 LD HL,48549 HL=Messaging_IDontKnowTheWord.
49485 CALL PrintStringAndNewline Call PrintStringAndNewline.
49488 POP HL Restore HL from the stack.
49489 LD A,34 Print a double quote character: """.
49491 CALL PrintCharacter
UserInput_Enter_17 49494 LD A,(HL) A=*HL.
49495 CP 33 Jump to UserInput_Enter_18 if A is less than 33.
49497 JR C,UserInput_Enter_18
49499 INC HL Increment HL by one.
49500 CALL PrintCharacter Call PrintCharacter.
49503 JR UserInput_Enter_17 Jump to UserInput_Enter_17.
UserInput_Enter_18 49505 LD A,34 Print a double quote character: """.
49507 CALL PrintCharacter
Print ".".
49510 LD HL,48937 HL=Messaging_FullStop.
49513 CALL PrintStringAndNewline Call PrintStringAndNewline.
49516 JR UserInput_Enter_20 Jump to UserInput_Enter_20.
UserInput_Enter_19 49518 LD A,(48486) Return if *UserInput_Token_1 is not equal to 255.
49521 CP 255
49523 RET NZ
Print "I don't understand.".
49524 LD HL,48529 HL=Messaging_IDontUnderstand.
49527 CALL PrintStringAndNewline Call PrintStringAndNewline.
UserInput_Enter_20 49530 JP Handler_UserInput Jump to Handler_UserInput.
Prev: 49217 Up: Map Next: 49533