;
;  SYSLIB Module Name:  SCLINE
;  Author:  Richard Conn
;  SYSLIB Version Number:  2.3
;  Module Version Number:  1.0
;  Module Entry Points:
;	CLINE
;  Module External References:
;	None
;

;
;	CLINE -- Save the command line whose character count is pointed
; to by HL away in an internal buffer as a string.  The line may be up to
; 255 characters long and will be truncated if it is longer.  The string
; will be terminated by a <NULL> as per the SYSLIB concept of strings.
;
;	Input Parameters:  HL = Address of Command Line Buffer
;	Output Parameters:  HL = Address of Command Line String
;			    A = 0 and Zero Flag Set (Z) if Buffer Truncated
;			    A <> 0 and Zero Flag Clear (NZ) if Buffer OK
;	Registers Affected:  HL
;
BSIZE	EQU	255	; SIZE OF BUFFER

CLINE::
	PUSH	D	; SAVE REGS
	PUSH	B
	LXI	D,INBUF	; ADDRESS OF BUFFER
	MVI	C,BSIZE	; BUFFER SIZE
	MOV	B,M	; GET CHAR COUNT IN B
	INX	H	; PT TO FIRST CHAR
CLINE1:
	MOV	A,B	; CHECK FOR DONE
	ORA	A	; 0=DONE
	JZ	CLINE2
	DCR	B	; COUNT DOWN
	MOV	A,M	; GET BYTE
	STAX	D	; PUT BYTE
	INX	H	; PT TO NEXT
	INX	D
	DCR	C	; COUNT DOWN BUFFER LIMIT
	JNZ	CLINE1
CLINE2:
	XRA	A	; A=0
	STAX	D	; PUT ENDING ZERO
	MOV	A,C	; GET REMAINING CHAR COUNT
	POP	B	; RESTORE REGS
	POP	D
	LXI	H,INBUF	; PT TO BUFFER
	ORA	A	; SET FLAGS
	RET
INBUF:
	DS	BSIZE	; SIZE OF BUFFER
	DS	1	; + 1 FOR ENDING ZERO

	END
