	.title	k11st1	the SET command,overlay one
	.ident	/2.0.05/

	.include	/IN:K11MAC.MAC/
	.include	/IN:K11CDF.MAC/

	.enabl	gbl
	.enabl	lc
	.psect	$code

	$cmglob	=	0

;	Copyright (C) 1984  Change Software, Inc.
;
;	31-Jan-84  15:13:45  Brian Nelson
;
;	Removed SET command code from K11CMD.MAC for space saving via
;	placement into an overlay.



	.psect	$code
	.sbttl	things from k11st0 needed in k11st1
	.enabl	lsb

	

sd$off:	bic	#log$al	,trace		; clear all debug bits now
	bit	#log$op	,trace		; is there a log file open ?
	beq	20$			; no
	calls	close	,<#lun.lo>	; close it
	bic	#log$op	,trace		; say it's closed please
	message	<Debug file closed>,cr
20$:	clr	r0
	return

ttchk:	tstb	ttname			; insure a line is set
	beq	10$			; ok
	clc
	return
10$:	message	<Please use the SET LINE command>,cr
	sec
	return

	.dsabl	lsb

	.sbttl	set block-check-type



set$bl::calls	getcm0	,<#argbuf,#blklst>; find out which option was given
	tst	r0			; did we find one
	bmi	110$			; no
	jsr	pc	,@r1		; dispatch now
	clr	r0			; no errors
110$:	return



	$cmglob	=	0

	command	blklst	,1_CHARACTER_CHECKSUM	,1	,sbl$1
	command	blklst	,2_CHARACTER_CHECKSUM	,1	,sbl$2
	command	blklst	,3_CHARACTER_CRC_CCITT	,1	,sbl$3
	command	blklst	,1-CHARACTER-CHECKSUM	,1	,sbl$1
	command	blklst	,2-CHARACTER-CHECKSUM	,1	,sbl$2
	command	blklst	,3-CHARACTER-CRC-CCITT	,1	,sbl$3
	command	blklst	,ONE_CHARACTER_CHECKSUM	,3	,sbl$1
	command	blklst	,TWO_CHARACTER_CHECKSUM	,3	,sbl$2
	command	blklst	,THREE_CHARACTER_CRC_CCITT,3	,sbl$3
	command	blklst	,ONE-CHARACTER-CHECKSUM	,3	,sbl$1
	command	blklst	,TWO-CHARACTER-CHECKSUM	,3	,sbl$2
	command	blklst	,THREE-CHARACTER-CRC-CCITT,3	,sbl$3
	command	blklst



sbl$1:	movb	#'1	,setrec+p.chkt
	movb	#'1	,setsen+p.chkt
	return


sbl$2:	movb	#'2	,setrec+p.chkt
	movb	#'2	,setsen+p.chkt
	return


sbl$3:	movb	#'3	,setrec+p.chkt
	movb	#'3	,setsen+p.chkt
	return

	global	<argbuf	,conpar	,setrec	,setsen	,senpar>





	.sbttl	set dtr and hangup line


set$dt::call	ttchk			; must have already done a SET LINE
	bcs	100$			; oops
	calls	ttydtr	,<#ttname>	; try to raise DTR on the line
	tst	r0			; did it work ?
	beq	100$			; yes
	direrr	r0			; no, emit a message as to why
100$:	clr	r0			; and exit
	return



c$disc::
c$hang::$name	<HAN>
set$hu::call	ttchk			; must have already done a SET LINE
	bcs	100$			; oops
	calls	ttyhang	,<#ttname>	; try to hang up the line
	tst	r0			; did it work ?
	beq	100$			; yes
	direrr	r0			; no, emit a message as to why
	clr	r0
	return
100$:	message	<KERMIT link >
	print	#ttname
	message	< disconnected>,cr
	return

	global	<ttname>



	.sbttl	set filetype


set$fi::calls	getcm0	,<#argbuf,#setfil>
	tst	r0			; did we find a keyword ?
	bmi	100$			; no
	jsr	pc	,@r1		; yes, dispatch on it please
100$:	return


sf$asc:	mov	#text	,$image		; imagemode := false
	message	<Ascii text mode set>,cr; confirm it
	clr	r0			; no errors
	return				; bye


	.enabl	lsb

sf$bin:	tstb	parity			; can't have parity set for this
	beq	10$			; ok
	cmpb	parity	,#par$no	; has it been set to none ?
	beq	10$			; yes
	message	<The other Kermit must be able to support 8 bit prefixing>,cr
	message	<Without this feature, the high bit will be lost on every>,cr
	message	<character sent>,cr
	message
10$:	mov	#binary	,$image		; imagemode := true
	message	<Binary mode set>,cr	; confirm it
100$:	clr	r0			; no errors
	return				; bye

	.dsabl	lsb


sf$aut:	mov	sp	,doauto		; allow checking of file type and
	clr	r0			; attributes to see if the file should
	return				; be sent as a binary file

sf$noa:	clr	doauto			; never check the file out
	clr	r0			; no errors
	return

	command	setfil	,7_BIT		,1	,sf$asc
	command	setfil	,7-BIT		,1	,sf$asc
	command	setfil	,8_BIT		,1	,sf$bin
	command	setfil	,8-BIT		,1	,sf$bin
	command	setfil	,ASCII		,3	,sf$asc
	command	setfil	,BINARY		,3	,sf$bin
	command	setfil	,EIGHT		,3	,sf$bin
	command	setfil	,SEVEN		,3	,sf$asc
	command	setfil	,EIGHT_BIT	,3	,sf$bin
	command	setfil	,SEVEN_BIT	,3	,sf$asc
	command	setfil	,EIGHT-BIT	,3	,sf$bin
	command	setfil	,SEVEN-BIT	,3	,sf$asc
	command	setfil	,FIXED		,3	,sf$bin
	command	setfil	,IMAGE		,3	,sf$bin
	command	setfil	,AUTO		,3	,sf$aut
	command	setfil	,NOAUTO		,3	,sf$noa
	command	setfil


	global	<argbuf	,$image>




	.sbttl	more set routines

;	SET$DF	set a default filename string for all file opens
;	and creates.



	.enabl	lsb

set$df::copyz	#argbuf	,#defdir,#filsiz; setup a default directory
	calls	fparse	,<#200$,#filnam>; try to parse it to see if
	tst	r0			; if the string is valid
	beq	10$			; ok
	message	<Error from $PARSE - >	;
	direrr	r0			; no, print the error out
	clrb	defdir
	br	100$

10$:	message	<Directory for files set to >
	print	#defdir
	message
100$:	clr	r0
	return

200$:	.asciz	/JUNK.DAT/
	.even

	global	<filsiz>

	.dsabl	lsb


set$ho::clrb	defdir
	message	<Directory set back to none (SY:)>,cr
	clr	r0
	return


;	S E T $ L O
;
;	SET LOGFILE filespec
;
;	set and create the logfile
	


set$lo::call	sd$off			; insure previous file is closed
	calls	create	,<#argbuf,#lun.lo,#text>; handle SET DEBUG FILE filename
	tst	r0			; did the logfile create work ?
	beq	10$			; yes
	direrr	r0			; no,print the error out
	return
10$:	bis	#log$op	,trace		; yes, say it's open please
	copyz	#argbuf	,#logfil,#30	; save the debug filename for show
	message	<Created debug file >	; say we did it
	print	#argbuf			; at last, confirm the logfile name
	message				; crlf
	return				; exit

	global	<argbuf	,defdir>



	.sbttl	set send and set receive


command	setset	,END-OF-LINE,3	,set$eo	,<Octal value of remotes EOL ? >,octnum
command	setset	,PACKET-LENGTH,3,set$pl	,<Packet size ? >,decnum
command	setset	,PAUSE	,3	,set$ps	,<Seconds to delay packets ? >,decnum
command	setset	,TIMEOUT,3	,set$ti	,<Timeout in seconds ? >,decnum
command	setset


	.sbttl	set end-of-line octalvalue, set packetlength and set pause

set$eo::calls	octval	,<#argbuf>	; get the octal value now
	tst	r0			; did it work ?
	bne	100$			; no
	movb	r1	,conpar+p.eol	; yes,stuff it in there please
	movb	r1	,setrec+p.eol	; yes,stuff it in there please
100$:	return				; bye



set$pl::calls	l$val	,<#argbuf>	; set the arguement now
	tst	r0			; did it work ?
	bne	100$			; no
	cmp	r1	,#20.		; minimum of twenty
	blo	110$			; too small
	cmp	r1	,#94.		; max
	bhi	110$			; too large
	movb	r1	,conpar+p.spsiz	; ok, stuff it in
	movb	r1	,setrec+p.spsiz	; ok, stuff it in

	movb	r1	,senpar+p.spsiz	; ok, stuff it in
	movb	r1	,setsen+p.spsiz	; ok, stuff it in

100$:	return

110$:	message	<The packet size must be in the range 20..94>,cr
	return



set$ps::calls	l$val	,<#argbuf>	; get the value
	tst	r0			; well ?
	bne	100$			; no, bad value
	mov	r1	,pauset		; ok
100$:	return

set$dl::calls	l$val	,<#argbuf>	; get the value
	tst	r0			; well ?
	bne	100$			; no, bad value
	mov	r1	,sendly		; ok
100$:	return



	global	<argbuf	,conpar	,conesc	,pauset	,sendly>


	.sbttl	set escape whatever and set retry
	.enabl	lsb


set$es::calls	octval	,<#argbuf>	; get the octal value now
	tst	r0			; did it work ?
	bne	100$			; no
	cmpb	r1	,#40		; must be a control character
	blo	10$			; ok
	message	<The escape character must be a control character>,cr
	br	20$			; exit
10$:	mov	r1	,conesc		; store it
20$:	return



set$re::calls	l$val	,<#argbuf>	; SET RETRY decimal number
	tst	r0			; well ?
	bne	100$			; no, bad value
	cmp	r1	,#3		; a reasonable minimum ?
	bhis	30$			; ok
	message	<RETRY should be between 3 and 30>,cr
	return
30$:	mov	r1	,maxtry		; ok
40$:	return



set$ti::calls	l$val	,<#argbuf>	; SET TIMEOUT decimal number
	tst	r0			; well ?
	bne	100$			; no, bad value
	cmp	r1	,#4		; a reasonable minimum ?
	blo	50$			; ok
	cmp	r1	,#60.		; a reasonable maximum ?
	blos	60$			; yes
50$:	message	<TIMEOUT should be between 4 and 60>,cr
	return
60$:	movb	r1	,conpar+p.time	; alter remotes sinit default
	movb	r1	,setrec+p.time	; show thats it's been set
100$:	return

	global	<argbuf	,conesc	,conpar	,maxtry	,setrec>

	.dsabl	lsb
	.sbttl	set record-format (highly RMS11 dependant)


set$rf::calls	getcm0	,<#argbuf,#rfmlst>; find out which option was given
	tst	r0
	bmi	100$
	jsr	pc	,@r1
	clr	r0
100$:	return


srf$st:	clr	df$rat			; stream ascii please for RSTS?
	movb	#fb$stm	,df$rfm		; say so and exit
	return

srf$va:	movb	#fb$cr	,df$rat		; must have this for RSX?
	movb	#fb$var	,df$rfm		; r.var and fd.cr
	return

	global	<df$rat	,df$rfm	,fb$cr	,fb$stm	,fb$var>

	command	rfmlst	,STREAM	 ,3	,srf$st
	command	rfmlst	,VARIABLE,3	,srf$va
	command	rfmlst


	.sbttl	enable or disable attribute packet transmission


set$at::calls	getcm0	,<#argbuf,#attlst>; find out which option was given
	tst	r0			; did we find one
	bmi	110$			; no
	jsr	pc	,@r1		; dispatch now
	mov	r0	,sendat		; save for the show command
100$:	clr	r0			; exit with no error set
110$:	return




	cm$glob	=	0


	command	attlst	,OFF	,3	,sat$of
	command	attlst	,ON	,2	,sat$on
	command	attlst	,NONE	,3	,sat$of
	command	attlst


sat$of:	clr	r0
	return

sat$on:	mov	sp	,r0
	return


	global	<sendat>


set$pr::copyz	#argbuf	,#prompt,#20.
	clr	r0
	return

	global	<prompt	,argbuf>


	.sbttl	error debugging


set$se::calls	l$val	,<#argbuf>	; SET SEED decimal number
	tst	r0			; well ?
	bne	100$			; no, bad value
	mov	r1	,testc		; save it
100$:	return


set$ra::calls	getcm0	,<#argbuf,#ranlst>; find out which option was given
	tst	r0			; did we find one
	bmi	110$			; no
	jsr	pc	,@r1		; dispatch now
	mov	r0	,ranerr		; save for the show command
100$:	clr	r0			; exit with no error set
110$:	return




	cm$glob	=	0


	command	ranlst	,OFF	,3	,sra$of
	command	ranlst	,ON	,2	,sra$on
	command	ranlst	,NONE	,3	,sra$of
	command	ranlst


sra$of:	clr	r0
	return

sra$on:	mov	sp	,r0
	return

	global	<ranerr	,testc>



	.sbttl	disable xon/xoff flow control for RT11

;	SET RTFLOW ON
;	SET RTFLOW OFF
;
;	We need this because some modems (like the VADIC 212) can't
;	handle XON's and XOFF's comming from the connect code. Thus
;	we need a way to disable this. We need flow control for the
;	connect command for RT11 due to the speed limitations of MT
;	service.

set$cf::calls	getcm0	,<#argbuf,#cflst>; find out which option was given
	tst	r0			; did we find one
	bmi	110$			; no
	jsr	pc	,@r1		; dispatch now
	mov	r0	,conflow	; save for the show command
100$:	clr	r0			; exit with no error set
110$:	return


	cm$glob	=	0
	command	cflst	,OFF	,3	,scf$of
	command	cflst	,ON	,2	,scf$on
	command	cflst	,NONE	,3	,scf$of
	command	cflst


scf$of:	clr	r0
	return

scf$on:	mov	sp	,r0
	return
	.sbttl	set repeat on/off or to something (?)



set$rp::calls	getcm0	,<#argbuf,#relst>; find out which option was given
	tst	r0			; did we find one
	bmi	110$			; no
	jsr	pc	,@r1		; dispatch now
	mov	r0	,setrpt		; save for the show command
100$:	clr	r0			; exit with no error set
110$:	return


	cm$glob	=	0
	command	relst	,OFF	,3	,rep$of
	command	relst	,ON	,2	,rep$on
	command	relst


rep$of:	clr	r0
	return

rep$on:	mov	#-1	,r0
	return

	global	<setrpt>


	.sbttl	set local terminal type


set$tt::calls	getcm0	,<#argbuf,#ttlst>; find out which option was given
	tst	r0			; did we find one
	bmi	110$			; no
	jsr	pc	,@r1		; dispatch now
	mov	r0	,vttype		; save for the show command
100$:	clr	r0			; exit with no error set
110$:	return



	cm$glob	=	0
	command	ttlst	,TTY	,3	,svt$tt
	command	ttlst	,VT100	,3	,svt$vt
	command	ttlst	,VT101	,3	,svt$vt
	command	ttlst	,VT102	,3	,svt$vt
	command	ttlst


svt$tt:	clr	r0
	return

svt$vt:	mov	#vt100	,r0
	return


	global	<vttype>

	.end
