Prev: 49001 Up: Map Next: 49066
49011: Handler: User Input
Used by the routines at Handler_UnknownWord and GameLoop.
Read a line of text, then turn it into vocabulary tokens.
Reset the cursor to the top of the text window.
Handler_UserInput 49011 CALL SetDefaultScreenPosition Call SetDefaultScreenPosition to park the cursor at the top of the text.
Clear the command buffer.
49014 LD HL,47876 Start at the command buffer (CommandBuffer).
49017 LD A,32 Prepare a space (32) and a counter of 50 bytes.
49019 LD B,50
EmptyCommandBuffer_Loop 49021 LD (HL),A Write spaces through the whole command buffer.
49022 INC HL
49023 DJNZ EmptyCommandBuffer_Loop
Print the ">" prompt.
49025 CALL PrintInputPrompt Call PrintInputPrompt.
Collect keypresses.
49028 LD HL,47876 Start again at the beginning of the command.
This entry point is used by the routine at UserInput_Delete.
Wait for the next key.
UserInput_Loop 49031 CALL GetUserInput Call GetUserInput.
DELETE rubs out a character. ENTER finishes the line. Any other control key is ignored.
49034 CP 12 Jump to UserInput_Delete if DELETE was pressed.
49036 JR Z,UserInput_Delete
49038 CP 13 Jump to UserInput_Enter if ENTER was pressed.
49040 JR Z,UserInput_Enter
49042 CP 32 Jump back to UserInput_Loop when the key is below SPACE.
49044 JR C,UserInput_Loop
Is the command buffer full?
49046 EX DE,HL Jump back to UserInput_Loop once the pointer has reached the sentinel at 47925.
49047 LD HL,47925
49050 AND A
49051 SBC HL,DE
49053 EX DE,HL
49054 JR Z,UserInput_Loop
The key is valid, so store it and print it.
49056 LD (HL),A Write the key into the command buffer.
49057 CALL SwitchNormalScreenOutput Call SwitchNormalScreenOutput to select the screen channel.
49060 CALL PrintCharacter Call PrintCharacter to echo the key.
49063 INC HL Advance to the next space in the buffer.
49064 JR UserInput_Loop Jump back to UserInput_Loop for the next key.
Prev: 49001 Up: Map Next: 49066