;*************************** AMUS Program Label ******************************
; Filename: SETTRM.M68                                        Date: 08/30/89
; Category: Change baud rate Hash Code: 234-160-442-335     Version: 2.0(103)
; Initials: AODP/AM       Name: GARY D. CHESSER
; Company: EMERGITECH                              Telephone #: 61488666712
; Related Files:none
; Min. Op. Sys.: 1.3                           Expertise Level: BEG
; Special: Allow you to find out or change baud rate of any trmdef on the
; system. This will work with the AM1213 ports.
; Description: This program will allow you to change any TRMDEF's baud rate.
;
; INPUT: SETTRM TERM1 1200
; 
; RESULT: Will change TERM1's baud rate to 1200.
;
; INPUT: SETTRM TERM1
; 
; RESULT: Will tell you TERM1's baud rate.
;

	SEARCH	SYS
	SEARCH	SYSSYM

VMAJOR=2.
VMINOR=0.
VSUB=0.
VEDIT=103.
VWHO=0.

START:	PHDR	-1,0,PH$REE!PH$REU	
	SSTS	D3			; save psw for lsts
	PUSH	#42			; Need more !
	PUSH				;
	GETMEM	@SP			;
	BEQ	MEMORY			;
	LSTS	D3			; BACK TO USER MODE
	EXIT				;

MEMORY:	POP	A4			; Free memory space in A4
	POP				;

INDEX:	JOBIDX	A5			;
	MOV	70(A5),A5		;

	BYP				; Skip blanks
	LIN				; just a CR?
	JNE	GOOD			; nope
	EXIT

GOOD:	TRM				; Check ours?
	JEQ	PRTBAU			;  Yes, go do it
	NUM				; Is it a baud rate?
	BEQ	GETRAT			;  Yes, change this trmdef

; LOCATE A TERMINAL DEFINITION
; EXIT  A3->TERMINAL DEFINITION BLOCK
;	=0 IF NOT FOUND

GET1:	FILNAM	(A4),XXX		; Save the terminal name
	MOV	(A4),D2			; Save terminal name 
	CALL	TRMSRH			; Locate terminal definition, in A3
	CMP	A5,#0			; If A3=0 then it wasn't found
	BNE	GETRAT			; A5 now indexes the TRMDEF to change
	TYPECR	<That terminal was not found>
	LSTS	D3			; BACK TO USER MODE
	EXIT

TRMSRH:	MOV	TRMDFC,A5		; INDEX THE TERMINAL DEFINITION CHAIN
TMSA:	CMMW    4(A5),(A4)  		; TERMINAL DEFINITION NAME
	BNE	TMSB			; TO FILENAME IN DDBTRM(A5)
	CMMW	6(A5),2(A4)
	BNE	TMSB
	ADD	#10,A5			; ADVANCE TO TERMINAL DEFINITION BASE
	RTN
TMSB:	MOV	@A5,A5			; Next terminal in chain
	CMP	A5,#0
	BNE	TMSA			; Unless end of terminal chain
	RTN

GETRAT:	SUPVR
     	BYP	
	LIN	
	JEQ	PRTBAU
	GTDEC	
	MOVW	4(A0),D2
	LEA	A0,TABLE


BAUD:	CMPW	D1,(A0)+
	BEQ	RATE	
	TSTW	@A0	
	BNE	BAUD	
	TYPESP	<?Baud rate>
	DCVT	0,OT$TRM
	TYPECR	< is not a valid baud rate>
	LSTS	D3		; BACK TO USER MODE
	EXIT

RATE:	SUBW	#2,A0		; Backup to actual baud rate
	LEA	A6,TABLE	; Reindex the beginning of table
	SUB	A6,A0		; Calculate the difference
	MOV	A0,D0		; 
	ASR	D0,#1		; Make it a count offset

CLROIP:	MOVW	@A5,D7		;
	ANDW	#200,D7		; MAKE SURE NOT OIP FLAG
	BNE	CLROIP		; 
	MOVW	D0,120(A5)	; Save new baud rate flag
	MOV	2(A5),A6	; 
	CALL	2(A6)		; Call init routine
	CRLF			; 
	LSTS	D3		; BACK TO USER MODE
	EXIT			; 

PRTBAU:	CLR	D1		; 
	MOVW	120(A5),D1	; Get current baud rate
	ASL	D1,#1		; Shift to word size
	LEA	A1,TABLE	; Index table
	MOVW	0(A1)[D1],D1	; Offset it
	TYPESP	<Current baud rate is>
	DCVT	0,OT$TRM
	CRLF	
	LSTS	D3		;BACK TO USER MODE
	EXIT	

TABLE:	WORD	50.
	WORD	75.
	WORD	110.
	WORD	134.
	WORD	150.
	WORD	200.
	WORD	300.
	WORD	600.
	WORD	1200.
	WORD	1800.
	WORD	2000.
	WORD	2400.
	WORD	3600.
	WORD	4800.
	WORD	7200.
	WORD	9600.
	WORD	19200.
	WORD	38400.
	WORD	56000.
	WORD	0
	END