Function Name: CHRIN/BASIN
Purpose: Input from channel
Call address: $FFCF (hex) 65487 (decimal)
Memory: system map
Calls: CHKIN (if necessary)
Registers: .A = character (or error code)
Memory: STATUS, RSSTAT updated
Flags: .C = 1 if error
Description: CHRIN (alias BASIN) reads a character from the current input device (DFLTN
$99) and returns it in .A. Input from devices other than the keyboard (the default
input device) must be OPENed and CHKINed. The character is read from the input
buffer associated with the current input channel:
The path to CHKIN is through an indirect RAM vector at $324. Applications
may therefore provide their own BASIN procedures or supplement the system's by
redirecting this vector to their own routine.
- Cassette data is returned a character at a time from the cassette buffer at $B00,
with additional tape blocks being read when necessary.
- RS-232 data is returned a character at a time from the RS-232 input buffer at $C00,
waiting until a character is received if necessary. If RSSTAT ($A14) is bad from
a prior operation, input is skipped and null input (carriage return) is substituted.
- Serial data is returned a character at a time directly from the serial bus, waiting
until a character is sent if necessary. If STATUS ($90) is bad from a prior
operation, input is skipped and null input (carriage return) is substituted.
- Screen data is read from screen RAM starting at the current cursor position and
ending with a pseudo carriage return at the end of the logical screen line. The
way the BASIN routine is written, the end of line (EOL) is not recog-
nized. Users must therefore count characters themselves or otherwise detect
when the logical EOL has been reached.
- Keyboard data is input by turning on the cursor, reading characters from the
keyboard buffer, and echoing them on the screen until a carriage return is
encountered. Characters are then returned one at a time from the screen until
all characters input have been passed, including the carriage return. Any calls
after the EOL will start the process over again.
LDY #0 ;index
MORE JSR $FFCF ;input a character
STA data,Y ;buffer it
CMP #$0D ;carriage return?