Index

Function Name: CHRIN/BASIN

Purpose: Input from channel
Call address: $FFCF (hex) 65487 (decimal)
Preparation:

	Registers:	none
	Memory:		system map
	Flags:		none
	Calls:		CHKIN (if necessary)
Results:
	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:

  1. Cassette data is returned a character at a time from the cassette buffer at $B00, with additional tape blocks being read when necessary.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
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.

EXAMPLE:

	LDY	#0	;index
MORE	JSR	$FFCF	;input a character
	STA	data,Y	;buffer it
	INY
	CMP	#$0D	;carriage return?
	BNE	MORE