Prev: C02E Up: Map Next: C091
C048: Read Key
Reads keys until ENTER. DELETE rubs out, and letters are stored in capitals.
Input
HL Command buffer pointer
Output
HL Pointer after the last stored character
ReadKey C048 CALL $662D Call WaitForKey to read one key.
C04B CP $0C Jump to ReadKey_Delete if the key is DELETE.
C04D JR Z,ReadKey_Delete
C04F CP $0D Jump to ParseLine if the key is ENTER.
C051 JR Z,ParseLine
C053 JR ReadKey_Store Jump to ReadKey_Store to store the key.
Rub the last character out, unless the buffer is already empty.
ReadKey_Delete C055 PUSH AF Stash the key on the stack.
C056 LD A,($5B8E) Jump to ReadKey_Ignore if *InputLength is empty.
C059 OR A
C05A JR Z,ReadKey_Ignore
C05C POP AF Restore the key from the stack.
C05D CALL $6394 Call PrintCharacter to rub the character out.
C060 DEC HL Decrement the buffer pointer and *InputLength.
C061 LD A,($5B8E)
C064 DEC A
C065 LD ($5B8E),A
C068 JR ReadKey Jump to ReadKey.
Throw the key away and read another.
ReadKey_Ignore C06A POP AF Drop the rejected key from the stack.
C06B JR ReadKey Jump to ReadKey.
Store a capital letter if the buffer still has room.
ReadKey_Store C06D PUSH AF Stash the key on the stack.
C06E LD A,($5B8E) Jump to ReadKey_Ignore if *InputLength already holds 5E characters.
C071 CP $5E
C073 JR Z,ReadKey_Ignore
C075 POP AF Restore the key from the stack.
C076 CP $20 Jump to ReadKey if a control or a graphic is rejected.
C078 JR C,ReadKey
C07A CP $61 Fold a lowercase letter to capitals.
C07C JR C,ReadKey_Fold
C07E SUB $20
ReadKey_Fold C080 CP $5B Jump to ReadKey if the character is above "Z".
C082 JR NC,ReadKey
C084 LD (HL),A Store the capital and call PrintCharacter to echo it.
C085 CALL $6394
C088 INC HL Advance the pointer and increment *InputLength.
C089 PUSH HL
C08A LD HL,$5B8E
C08D INC (HL)
C08E POP HL Restore the buffer pointer from the stack.
C08F JR ReadKey Jump to ReadKey.
Prev: C02E Up: Map Next: C091