;Controller! by Crispin Bivans 3/3/89
;This program allows you to effectively be typing on somebody
;else's keyboard(While they are typing too)
	SEARCH SYS
	SEARCH SYSSYM
	SEARCH TRM

DEFINE	TTAB	X
	PUSH	D1
	MOV	#<-1_8.+X>,D1
	TCRT
	POP	D1
ENDM

	TYPECR	<Controller by Crispin A. Bivans!>
	TRM
	JNE	START
	CRLF
ERROR:	TYPECR	<No jobname?>
	EXIT
START:	           
	CLR	JOBPRG(A0)
	LEA	A1,BUFFER
	PACK	
	PACK
	LEA	A1,BUFFER
	MOV	JOBTBL,A4
JOBSCH:	MOV	(A4)+,D3	
	JMI	ABORT
	JEQ	JOBSCH	
	MOV	D3,A3
	CMM	@A1,JOBNAM(A3)
	JNE	JOBSCH
	MOV	JOBTRM(A3),A5
	INC	A2
	JOBIDX	A0
	TYPECR	<Controlling....Press | to exit.>
KEY:	MOV	JOBTRM(A0),A5
	ORW	#<T$IMI!T$ECS>,@A5
	CLR	D1
	CTRLC	CCC
	TCKI
	BNE	KEY
	KBD	CCC
RET:	CMPB	D1,#13.
	JNE	NORET
	CRLF
	BR	ETI
NORET:	CMPB	D1,#127.
	JNE	EIT
	MOVB	#8.,D1
	TTY
	MOVB	#32.,D1
	TTY
	MOVB	#8.,D1
	TTY
	MOVB	#127.,D1
	BR	ETI
EIT:	CMPB	D1,#'|
	JEQ	ABORT
	TTY
ETI:	MOV	JOBTRM(A3),A5
	TRMICP
	JMP	KEY
CCC:	TYPECR	<^C>
	ANDW	#^C<J.CCC>,JOBSTS(A0)
	CLRW	JOBCMZ(A0)
	ORW	#J.CCA,JOBTYP(A3)
	MOVB	#3.,D1
	MOV	JOBTRM(A3),A5
	TRMICP
	JMP	KEY
ABORT:	TYPECR	<Bye!>
	EXIT	
BUFFER:	BLKB	30.
	BYTE	0
	EVEN
	EXIT
	END