Skip to navigation

Keyboard: ReadCharacter

Name: ReadCharacter [Show more] Type: Subroutine Category: Keyboard Summary: Read a character from the currently selected input stream
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * ReadNumber calls ReadCharacter

Returns: A The character read from the input stream, in ASCII
.ReadCharacter JSR OSRDCH \ Read a character from the currently selected input \ stream into A BCC read1 \ If the C flag is clear then the call to OSRDCH read a \ valid character, so jump to read1 to return from the \ subroutine CMP #27 \ If the character read is not ESCAPE, jump to read1 to BNE read1 \ return from the subroutine \ If we get here then we have an ESCAPE condition, so we \ need to acknowledge it and try again TYA \ Store Y on the stack to we can preserve it through the PHA \ call to OSBYTE LDA #126 \ Call OSBYTE with A = 126 to acknowledge the ESCAPE JSR OSBYTE \ condition PLA \ Retrieve Y from the stack TAY JMP ReadCharacter \ Loop back to read another character .read1 RTS \ Return from the subroutine