![]() |
Routines |
Prev: C003 | Up: Map | Next: C041 |
Used by the routines at UserInput_Enter and GameLoop.
|
||||||||||||||||||||||
Reset the screen position to defaults.
|
||||||||||||||||||||||
Handler_UserInput | C00A | CALL SetDefaultScreenPosition | Call SetDefaultScreenPosition. | |||||||||||||||||||
Clear down the command buffer which will hold the users input.
|
||||||||||||||||||||||
C00D | LD HL,$BD34 | HL=CommandBuffer. | ||||||||||||||||||||
C010 | LD A,$20 | Store the ASCII code for "SPACE" (" ") into A. | ||||||||||||||||||||
C012 | LD B,$32 | Set a counter in B for the size of the command buffer (32 bytes). | ||||||||||||||||||||
Write "SPACE" 32 times wiping the entire command buffer.
|
||||||||||||||||||||||
EmptyCommandBuffer_Loop | C014 | LD (HL),A | Write A to *HL. | |||||||||||||||||||
C015 | INC HL | Increment HL by one. | ||||||||||||||||||||
C016 | DJNZ EmptyCommandBuffer_Loop | Decrease the command buffer counter by one and loop back to EmptyCommandBuffer_Loop until the whole buffer is cleared. | ||||||||||||||||||||
Now print the prompt icon ">".
|
||||||||||||||||||||||
C018 | CALL PrintInputPrompt | Call PrintInputPrompt. | ||||||||||||||||||||
Initialise the command buffer.
|
||||||||||||||||||||||
C01B | LD HL,$BD34 | HL=CommandBuffer. | ||||||||||||||||||||
This entry point is used by the routine at UserInput_Delete.
Collect the users keypress.
|
||||||||||||||||||||||
UserInput_Loop | C01E | CALL GetUserInput | Call GetUserInput. | |||||||||||||||||||
Check the two valid control keys "DELETE" and "ENTER".
|
||||||||||||||||||||||
C021 | CP $0C | Jump to UserInput_Delete if "DELETE" was pressed. | ||||||||||||||||||||
C023 | JR Z,UserInput_Delete | |||||||||||||||||||||
C025 | CP $0D | Jump to UserInput_Enter if "ENTER" was pressed. | ||||||||||||||||||||
C027 | JR Z,UserInput_Enter | |||||||||||||||||||||
C029 | CP $20 | If the keypress was any other control key (the value being under 20 ASCII "SPACE"), it's not valid input so jump back to UserInput_Loop. | ||||||||||||||||||||
C02B | JR C,UserInput_Loop | |||||||||||||||||||||
Test if the current position in the command buffer is at the end (BD65) of the buffer. For example:
|
||||||||||||||||||||||
C02D | EX DE,HL | Jump back to UserInput_Loop if the input has reached the end of the command buffer (so don't process it). | ||||||||||||||||||||
C02E | LD HL,$BD65 | |||||||||||||||||||||
C031 | AND A | |||||||||||||||||||||
C032 | SBC HL,DE | |||||||||||||||||||||
C034 | EX DE,HL | |||||||||||||||||||||
C035 | JR Z,UserInput_Loop | |||||||||||||||||||||
The keypress is valid, so process it and print it to the screen.
|
||||||||||||||||||||||
C037 | LD (HL),A | Write the keypress into the command buffer at the current position. | ||||||||||||||||||||
C038 | CALL SwitchNormalScreenOutput | Call SwitchNormalScreenOutput. | ||||||||||||||||||||
C03B | CALL PrintCharacter | Call PrintCharacter. | ||||||||||||||||||||
C03E | INC HL | Increment the pointer to the command buffer by one. | ||||||||||||||||||||
C03F | JR UserInput_Loop | Jump back to UserInput_Loop. |
Prev: C003 | Up: Map | Next: C041 |