;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;									    ;
;				    ECHO				    ;
;			    Keyboard Echo Utility			    ;
;									    ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Copyright (C) 1987 UltraSoft Corp.  All Rights Reserved.
;
;Written by: David Pallmann
;
;Edit History:
;1.0  06-Jun-87  created. /DFP

	VMAJOR=2
	VMINOR=0

	JCB=A4
	TCB=A5
	ROW=D4
	EXTCHR=D5

	SEARCH	SYS
	SEARCH	SYSSYM
	SEARCH	TRM
	SEARCH	TCRT

START:	PHDR	-1,,PH$REE!PH$REU

	CLS
	TYPECR	Echo keyboard characters and show equivalent values
	TYPECR	Copyright (C) 1987 UltraSoft Corporation.
	CRLF

SETUP:	MOV	JOBCUR,JCB
	PUSHW	JOBTYP(JCB)
	MOV	JOBTRM(JCB),A5
	ORW	#T$DAT!T$ECS,T.STS(TCB)

QUERY1:	TYPESP	Translate function keys?
10$:	KBD
	UCS
	CMPB	D1,#'Y
	BEQ	20$
	CMPB	D1,#'N
	BEQ	30$
	TTYI
	BYTE	7,0
	EVEN
	BR	10$
20$:	TYPECR	Yes
	ORW	#T$XLT,T.STS(TCB)
	BR	40$
30$:	TYPECR	No
	ORW	#T$NFK,T.STS(TCB)
40$:

QUERY2:	TYPESP	Exit character:
	KBD
	MOVB	D1,EXTCHR
	CALL	IMAGE
	CRLF

HEADER:	CRLF
	TYPECR	<Char    Octal   Decimal Hex     Binary>
	CRLF
	MOV	#9.,ROW

LOOP:	KBD
	CMPB	D1,EXTCHR
	JEQ	EXIT

DUMP:	AND	#377,D1
	CALL	CHAR
	CALL	OCTAL
	CALL	DECIMAL
	CALL	HEX
	CALL	BINARY
	CRLF
	INCB	ROW
	CMPB	ROW,#23.
	BLOS	LOOP
	CURSOR	#9.,#1
	DELLIN
	CURSOR	#23.,#1
	BR	LOOP

EXIT:	CURSOR	#24.,#1
	POPW	JOBTYP(JCB)
	EXIT

CHAR:	CALL	IMAGE
	TYPE	<     >
	RTN

OCTAL:	ANDW	#^C<J.HEX>,JOBTYP(JCB)
	OCVT	3,OT$TRM
	TYPE	<     >
	RTN

DECIMAL:
	DCVT	3,OT$TRM!OT$ZER
	TYPE	<.    >
	RTN

HEX:	ORW	#J.HEX,JOBTYP(JCB)
	TYPE	$
	OCVT	2,OT$TRM
	TYPE	<     >
	RTN

BINARY:	MOVB	D1,D0
	MOV	#8.,D2
10$:	ROLB	D0
	BCC	20$
	TYPE	1
	BR	30$
20$:	TYPE	0
30$:	SOB	D2,10$
	RTN

IMAGE:	SAVE	D1
	CMPB	D1,#40
	BLO	IM.CTL
	CMPB	D1,#177
	BEQ	IM.DEL
	BHI	IM.NUM
IM.CHR:	TTY
	TYPE	<  >
	BR	IM.RTN
IM.DEL:	TYPE	DEL
	BR	IM.RTN
IM.NUM:	DCVT	3,OT$TRM
	BR	IM.RTN
IM.CTL:	ADDB	#'@,D1
	TYPE	^
	TTY
	TYPESP
IM.RTN:	REST	D1
	RTN

	END