.PrintInputBuffer SEC \ Set bit 7 of textDropShadow so the following text is ROR textDropShadow \ printed without a drop shadow \ We now print the contents of the input buffer \ \ Key presses are stored in the input buffer using an \ ascending stack, with new input being pushed into \ inputBuffer, so to print the contents of the buffer, \ we need to print it backwards, from the oldest input \ at index T - 1 down to the most recent input at \ index 0 LDX T \ Set X = T - 1 so we can use X as an index into the DEX \ buffer, starting from the oldest input .pinb1 LDA inputBuffer,X \ Set A to the X-th entry in the input buffer JSR PrintDigit \ Print the numerical digit in A DEX \ Decrement the buffer index BPL pinb1 \ Loop back until we have printed the whole buffer \ We now want to backspace by the number of characters \ we just printed, to leave the cursor at the start of \ the printed number LDX T \ Set X to the size of the input buffer, which we can \ use as a character counter in the following loop to \ ensure we backspace by the correct number of \ characters to reach the start of printed number LDA #8 \ Set A = 8 to perform a series of VDU 8 commands, each \ of which will backspace the cursor by one character .pinb2 JSR PrintDigit \ Print the character in A, which performs a VDU 8 to \ backspace the cursor by one character DEX \ Decrement the character counter BNE pinb2 \ Loop back until we have backspaced to the start of the \ buffer contents that we just printed LSR textDropShadow \ Clear bit 7 of textDropShadow so text tokens are once \ again printed with drop shadows RTS \ Return from the subroutineName: PrintInputBuffer [Show more] Type: Subroutine Category: Text Summary: Print the contents of the keyboard input bufferContext: See this subroutine in context in the source code References: This subroutine is called as follows: * ReadNumber calls PrintInputBuffer
Arguments: T The size of the input buffer
[X]
Subroutine PrintDigit (category: Text)
Print a numerical digit, printing zero as a capital "O"
[X]
Variable inputBuffer in workspace Main variable workspace
The eight-byte keyboard input buffer
[X]
Label pinb1 is local to this routine
[X]
Label pinb2 is local to this routine
[X]
Variable textDropShadow in workspace Main variable workspace
Controls whether text in text tokens is printed with a drop shadow