;***************************************************************************;
;									    ;
;				     GET				    ;
;		  Subroutine to wait for a single character		    ;
;									    ;
;***************************************************************************;
;Copyright (C) 1986 by UltraSoft.  All Rights Reserved.
;
;Written by: David Pallmann
;
;Usage:	XCALL GET, {string_variable}
;
;Notes: this routine waits for a character to be input
;
;Assembly instructions:	.M68 GET       << creates GET.SBR
;
;Edit History:
;1.0 01-Jan-86 created. /DFP
;1.1 03-Jun-86 add error checking just for Brad. /DFP

	VMAJOR=1
	VMINOR=1

	OBJNAM	.SBR

	SEARCH	SYS
	SEARCH	SYSSYM
	SEARCH	TRM

;AlphaBASIC sets up XCALL argument list this way, indexed by A3:

	.OFINI
	.OFDEF	XC.ARG,2		; number of arguments in XCALL
	.OFDEF	XC.TY1,2		; argument #1 - type code
	.OFDEF	XC.AD1,4		; argument #1 - address
	.OFDEF	XC.SZ1,4		; argument #1 - size
	.OFSIZ	XC.SIZ

	XC$STR=2			; type code for string arguments

GET:	PHDR	-1,PV$RSM!PV$WSM,PH$REE!PH$REU	; program header
	CMMW	XC.ARG(A3),#1		; one argument specified in XCALL?
	BNE	ARGERR			;  nope
	CMMW	XC.TY1(A3),#XC$STR	; is argument a string?
	BNE	TYPERR			;  uh-uh
	JOBIDX	A5			; index JCB with A5
	MOV	JOBTRM(A5),A4		; index TCB with A4
	ORW	#T$IMI!T$ECS,T.STS(A4)	; set image mode, no-echo
	KBD				; get a char into D1
	MOV	XC.AD1(A3),A0		; index string var
	MOVB	D1,@A0			; return char
	ANDW	#^C<T$IMI!T$ECS>,T.STS(A4) ; set line mode w/echo
	RTN				; return

ARGERR:	TYPESP	?Argument count
	BR	ERROR

TYPERR:	TYPESP	?Argument type

ERROR:	TYPECR	error in GET.SBR
	EXIT				; exit on error

	END