/	WPTRNS - DOCUMENT TRANSFER
/
/	045	EMcD	14-Sep-85	Add Nordic translations 
/					(conditionalised)
/	044	RCME	08-Jul-85	Allow multiple option characters
/					in AX/DX menu.
/	043	EMcD	28-Feb-85	Add DECDEV switch
/
/ --------------- All below refer to V2.0 and earlier ------------------
/
/	042	HLP	15-NOV-84	Search & Replace:
/					USOCHR=TTYOU
/					HTICHR=HS2IN
/					HTOCHR=HS2OU
/	041	TCW	28-NOV-84	Terminate text packet before a QUIT
/	040	TCW	24-OCT-84	Write all rec. packets before quiting
/	039	TCW	12-OCT-84	Add flag cks & sets before IOA calls
/	038	TCW	02-AUG-84	Add (CLA) before menu call
/	037	GDH	31-JUL-84	Bug fix for losing packets.
/					Fix EZLINK BYE packet detection.
/	036	JFS	18-JUN-84	DM-III mods
/	035	WCE	11-MAY-84	Remove all occurances of USERNO
/	034	TCW	02-MAR-84	Ring bell for invalid character
/	033	TCW	21-FEB-84	Add ck for local init. of recrtn
/	032	TCW	27-JAN-84	Limit menu input to 64 chars.
/	031	TCW	29-DEC-83	a) Send back a "NO" packet when unable
/					to create document.
/					b) Close document when unable to create
/					c) Put any text in "NO" packet on
/					Problem: line.
/					d) Add special cases of "NO" packet;
/						1) Response to "RCV" packet.
/						2) Response to "SOD" packet.
/					e) Move "Problem:" to line 4.
/					f) Reset Status:, Problem: & Message:
/					lines on S & R options.
/	030	FJL	17-NOV-83	Change to fix comm. bug, erroneous msg
/	029	GDH	28-JUL-83	Changed default filename generator
/					 to not generate "1." if drive 1.
/	028	GDH	21-JUL-83	Eliminated bad "AC7773" reference.
/	027	GDH	 6-JUN-83	General Cleanup & Rewrite of terminal
/					I/O
/	026	DFB	01-JUN-83	Fix to close DX doc
/	025	GDH	26-MAY-83	Rearranged GTLINE char checks per WPF1
/	024	GDH	18-MAY-83	Moved LARGE BUFFER to field 6.
/	023	GDH	18-APR-83	Eliminated unneeded label DLYINT.
/					Eliminated unreferenced pool DOCLSA.
/					Free list buffer linkage now done at
/					 assembly time instead of run-time.
/					Eliminated redundant initialization
/					 of CMADSX.
/				 	Eliminated DXSTLS initializations.
/					AX/DX is reloaded each time it's
/					 invoked.
/					Implemented EZ-LINK chain back to CX.
/	022	EH	08-OCT-82	Limit input chars for ID/PASSWORD to 64
/	021	SBB	25-AUG-82	Changed vt278 message to
/					DM-II(IFDEF'ed)
/	020	SBB	15-JUL-82	Made timeout delays variable from menu.
/	019	GDH	15-FEB-82	Fixed AX-DX to not clobber loc 53 in
/					 header when copying print settings
/					 to recieve document.
/	018	GDH	30-NOV-81	Changed TIMOUT to TIMEOU due to WPF1
/					 definition of TIMOUT.
/	017	EH	28-OCT-81	Merged differences from 78,1 into here
/	016	GDH	21-OCT-81	Deleted phoney CIF/CDF mapping stuff.
/	015	EH	16-OCT-81	Made dx clear error count prior to
/					 each transmition.
/	014	GDH	14-OCT-81	De-implemented LOCK/UNLOCK.
/	013	GDH	26-AUG-81	WPFILS calling seq changes.
/	012	TT	07-JUL-81	Removed superfluous conditionals
/	011	JM	01-APR-81	Text change for CANADA
/	010	DIM	27-MAR-81	FIXED PAGE ERROR FOR DUTCH
/	009	DAO	 1-JAN-81	PUT IN FIX TO DX BUG IN 278 WHICH
/					RESULTED IN TOO MANY PACKET ERRORS
/					WHEN 278 RECEIVED AT BAUD RATES GREATER
/					THAN 600. STILL HAS A PROBLEM AT
/					19200 BAUD.
/	008	DRH	 4-DEC-80	CONNECTED TO "VT278" IN AX/DX ADDED
/	007	GR,DAO	17-OCT-80	CONDITIONALIZED ESCAPE SEQUENCES
/	006    DM,JM    15-SEPT-80      Merged Scandi and Europe/English
/	005	DSS	09-JUL-80	MODIFIED FOR ENGLISH/FRENCH-CANADIAN
/	004	CMW	 6-MAY-80	ENTERED CANADA TRANSLATIONS
/	003	DSS	17-APR-80	ENTERED DUTCH FIXES
/	002	GLT	 2-APR-80	Change WS201, WS202 messages to WS81,
/					WS82
/	001	CMW GLT	10-JAN-80	Added French, German and Dutch
/					conditionals
/	French diacritical substitutions:
/	"["=L.A.E, "]"=L.G.E; "&" does not UPPERCASE
/	German diacritical substitutions:
/	"["=L.U.A, "\"=L.U.O, "]"=L.U.U; "&" usable
/	3.0	MB	31-JUL-78 PUT IN NULLS AFTER CR IN A PACKET OPTION
/	QA3.3 	MB	13-APR-78 FIX RESPONSE PACKET TO T,B OPTION IN AX-DX
/	2.6+	MB	NEW PROTOCOL
/	2.5-1	MB	FIX THE CREATE PROBLEMS IN THE WT78 10/15/77
/	2.P-4	KEE	ADD CODE TO UNLOCK 102 FILES
/	2.G-2	MB	PUT IN CHANGE FOR MOVED MENU AREA 8/10/77
/	2.G-1	MB	GET FROM THE 78 PACK

/
/	THIS PAGE WRITES OUT WPTRNS
/
	*200
	JMP I	.+3
	JMP I	.+1
	7600
	RXLOAD
	*RXLDLS
	RXEWT=4
	RXEWT
	0
	RXQBLK=11
	RXQBLK
	.
	DLODWC 			/ ++++
	100 			/ ++++
	IFNDEF DECDEV <
	CDF 10 			/ ++++
	>
	IFDEF DECDEV <
	CDF 30 			/ ++++
	>

	-DSODWC

	DLODW2 			/ ++++
	7400 			/ ++++
	IFNDEF DECDEV <
	CDF 20 			/ ++++
	>
	IFDEF DECDEV <
	CDF 40
	>
	-DSODW2

	0

/
/	HERE ARE THE CONSTANTS USED BY WPTRNS
/
/	THESE ARE THE CONSTANTS THAT HANDLE I/O FOR A CHAR
/
/
/	SET UP CONSTANTS FOR THE PROGRAM
/
	BUFCNT=5 		/ THE NUMBER OF BUFFERS IN THE POOL
	BUFSIZ=100 		/ THE STANDARD BUFFER SIZE
	NAKLM=-41 		/ THE IS THE NUMBER OF RETRNANSMITS IT WILL DO
	TOLIM=-5 	/ THE NUMBER OF TIMES YOU RESEND AFTER A TIME OUT
/
	BELL=7
	CR=15 	/ SENT AS AN END OF LINE DESIGNATOR FOR A TIME SHARING SYSTEM
	LF=12 			/ LINE FEED
	SPACE=40 		/ BLANK
	BKSPAC=10
	RUBOUT=177 		/ THE RUBOUT CHARACTER
	SPECHR=140 / USED TO TELL THE DIFFERENCE FROM A PACKET AND A COMMAND
	RESET=175
/
VERSIO=40 / THE VERSION OF THE PROTOCOL SHOULD BE INCREMENTED WITH EVERY
	/ CHANGE TO THE PROTOCOL THAT WOULDNOT ALLOW THE NEW
				/ TO TALK TO THE OLD
/
	TYPE=40 		/ THE TYPE OF THE PROTOCOL
/
ZERNUL=137 / NUMBER OF NULLS REQUESTED FROM THE OTHER SYSTEM AFTER A PACKET
		/ 40 = ZERO.  IT IS SENT IN THE INIT AND INIT-ACK PACKETS
/
/	THE VALUES FOR SYSTY1.  THEY TELL THE OTHER SYSTEM SOFTWARE
/				 WHAT IS RUNNING
/	ON THIS SYSTEM AX OR DX
/
	AXSYS=41
	DXSYS=40
/
/	THE TIME OUT CONSTANTS
/
	/D020	SEC1=-2
	/D020	SEC3=-4
	/D020	SEC30=-37
	/D020	SEC15=-11		/ 9 SEC				/A017
	/D020	SEC5=-6
/
/	VALUES FOR THE OPTIONS
/
	OPTNUL=40 		/ NOTHING
	OPTBYE=41 		/ JUST BYE MESSAGE
	OPTBM=42 		/ BYE AND NORMAL MESSAGE
	OPTBMS=43 		/ BYE, NORMAL, AND SEND
	OPTALL=44 		/ EVERYTHING
/
/	CONSTANTS FOR THE COMMAND COMPARE
/
/d044	IFDEF ENGLSH <
/d044	SEND="S&177
/d044	RECEIV="R&177
/d044	MESSAG="M&177
/d044	BYE="B&177
/d044	>
/d044	IFDEF ITALIAN <
/d044	SEND="I&177
/d044	RECEIV="R&177
/d044	DOCMNT="D&177
/d044	MESSAG="M&177
/d044	BYE="T&177
/d044	>
/
/	THE FLAG CHARACTERS FOR THE PACKET TYPE AND THE COMMANDS FOR
/	THE LOW LEVEL
/	IF THE VALUES CHANGE TELL HSTTBL BECAUSE USE THEN AS OFFSETS
/	THEY ALL HAVE THE SAME PACKET FORMAT
/
	TYPYES=140 		/ THE OK PACKET TYPE
	TYPMOD=141 		/ DOCUMENT OPTIONS PACKET RESPOND WITH A PROMPT
				/ ANSWER PACKET
	TYPMES=142 		/ THE NORMAL MESSAGE
	TYPBYE=143 		/ BYE MESSAGE PACKET, WILL TERMINATE A TRANSFER
	TYPSOD=144 		/ FIRST PACKET OF A DOCUMENT CONTAINING SIZE
				/ AND PRINTER SETTINGS
	TYPDTA=145 		/ NORMAL TEXT PACKET OF A DOCUMENT
	TYPEOF=146 		/ LAST PACKET OF A DOCUMENT. CONTAINS THE LAST
				/ 64 BYTES OR LESS
	TYPHIT=147 		/ HIGH LEVEL INITALIZE PACKET THAT HAS THE
				/ TERMINAL MESSAGE IN IT
	TYPHAK=150 		/ THE HIGH LEVEL ACK
	TYPSND=151 		/ WANT TO SEND A DOCUMENT
	TYPRCV=152 		/ WANT TO RECEIVE A DOCUMENT
	TYPOPT=153 		/ THE OPTION PACKET
	TYPDOC=154 		/ USED WHEN SENDING A LIST IT IS A PROMPT FOR
				/ THE DX USER TO ANSWER
	TYPNO=164 		/ ANO RESPONSE TO A PACKET
	TYPPAN=172 		/ ANSWER TO PROMPT CONTAINS WHAT THE USER TYPED
	TYPPMT=175 		/ PROMPT PACKET
	TYPPNE=176 		/ PROMPT WITH NO ECHO
/
/	THE LOW LEVEL PACKET TYPES.  HTE FORMATS ARE DIFFERENT THAN ABOVE'S.
/
	NAK=160
	ACK=170
	QUIT=171 		/ TELLS THE SYSTEM THAT THE OTHER SYSTEM GOLD
				/ MENUED
	INIACK=173
	INIT=174
/
/	CONSTANTS FOR THE GET THE BLOCK SIZE
/
	ISGBK1=INMBLK
	ISGBK2=ISGBK1+1
/
/	THE CONSTANTS USED IN THE PRINTER SETTINGS
/
RDFILB=7400 		/ START OF THE BUFFER THAT THE HEADER BLOCK IS
/			  READ INTO
/
SETSAV=ISGBK2+1 	/ THE START OF THE PRINTER SETTING IN THE INCOMING
SETSND=RDFILB+23 	/ START OF THE PRINTER SETTINGS IN THE RXHAN BUFFER
SETSIZ=-30		/ SIZE OF THE PRINTER SETTINGS IN WORDS	/M019
PRTOFF=21 		/ THE OFFSET FOR THE FIRST WORD OF THE PRINTER SETTINGS
SCHDR=6000 		/ OFFSET USED TO FIND THE SCROLL BUFFER WITH THE
/			  SETTINGS
/
/	CONSTANTS FOR THE OTHER FIELD
/	THESE ARE THE ADDRESS IN THE BUFFER FIELD THAT CONTAIN THESE ROUTINE'S
/	ADDRESS.
/
	AXDIS=200
	AXEC=AXDIS+1
	AXDON=AXEC+1
	ADRCRT=AXDON+1
	AXLRT=ADRCRT+1 		/ RETURN THE LOG FILE
	AXSR=AXLRT+1 		/ AX SEND AND RECEIVE ROUTINE
	REDSIX=AXSR+1 		/ READ FROM RDFILL A 6-BIT CHARACTER AND TRANSLATE TO 7-BIT
	WRISIX=REDSIX+1 	/ TAKE A 7-BIT CHARACTER AND TURN INTO 6 AND WRITE TO DISK
	CLASIX=WRISIX+1 	/ INITALIZE THE REDSIX AND WRISIX ROUTINES

	IFNDEF DECDEV <
	FIELD 1
	>
	IFDEF DECDEV <
	FIELD 3
	>
	*100 			/ THE FIRST 100 LOCATIONS ARE USED FOR THE SYSTEM
/
/	THE USER FIELD CONSTANTS
/
	CDFMYF=CDFEDT		/					/M016

/
/	HERE ARE SOME OF THE MORE COMMONLY USED FLAGS
/
AXFLG,	0 			/ SET IF IN AX MODE
SENDFL,	0 			/ THE STATUS FLAG:
				/ -5 = TRANSFER ABORTED
				/ -4 = ERROR AND WAITING
				/ -3 = TRANSFER DONE " "
				/ -2 = NOT CONNECTED YET " "
				/ -1 = CONNECTED " "
				/ 0= RECEIVE
				/ 1= SEND
INIFLG,	0 			/ IF 1 = TRANSFER IN PROGRESS
DOCNCT,	0 			/ IN AX THE NUMBER OF DOCUMENTS TRANSFERRED
AXREC,	0 			/ AX SETS THIS FLAG IF WANT TO RECEIVE
SNDAD,	0 			/ AX SETS IF WANTS TO SEND
RSTFLG,	0 	/ DXIPRG SETS IT TO POSITIVE IF INIT DETECTED AND MINUS
		/ IF OTHER SYSTEM HAS WRONG VERSION
OPTFLG,	0 	/ OPTIONS AVAILABLE TO THIS SYTEM'S USER
TMPRST,	0 	/ CONTAINS THE VALUE THAT TELLS THE OTHER SYSTEM
		/ THE OPTIONS IT HAS AVAILABLE AT CONNECT TIME
CNGSCF,	0 	/ CAN BE SET BY ANYONE IF + MAINJOB WILL DISPLAY ONLY THE PART
		/ THAT HAS BEEN SAID TO BY OTHER FLAGS, IF - REPAINT THE SCREEN
INIFL3,	0 	/ THE FLAG IS SET TO NON ZERO IF HIGH LEVEL INIT HAS TAKEN
		/ PLACE
MGWTFG,	0
ERRFLG,	0 	/ SET BY ANYONE.  IF - THE ERROR ALL OPTIONS EXCEPT  GM
		/ ARE NOT ALLOWED.  IF + THEN JUST DISPLAY THE ERROR
HSTRAD,	0 	/ THE ADDRESS OF THE PACKET THAT THE HOST SYSTEM RECEIVED
DXGTPT,	0 	/ A POINTER FOR THE PACKET STARTING WORD
MSGAST,	0 	/ THIS IS THE FLAG TO TELL THE MAINLP THAT A MESSAGE IS BEING
		/ TRANSFERRED AND THE STATUS WORD'S ADDRESS IS ITS VALUE

AXPMT,	0 			/ 1= ACT LIKE A SPECIAL PROMPT FOR AX
OSYSAX,	0 			/ 1= OTHER USER IS IN AX
TEMP,	0 			/ TEMP USED BY ANYONE
GTBFPT,	INBUFA 			/ BUFFER AREA FOR THE INPUT FROM KEYBOARD

/The following variables are modified during start up of
/WPTRNS. They are on this page because there is room here.
/They can be moved if you can find room.
DLY1X,	-6								/A020
DLY3X,	-12								/A020
DLY6X,	-37								/A020
DLY180,	-264								/A020
/
/ THE FOLLOWING 9 WORDS MOVED HERE FOR ROOM AT (022)
SENT2,	0
EOF,	0
SENT3,	0
SENTMP,	0
SENT4,	0
DXNONK,	0
DTARTM,	0
BYSETF,	0
NOFLAG,	0			/ SPECIAL CASES OF "NO" PACKET		/A031
PRBSFG,	0			/ TEXT IN "NO" PACKET			/A031
GTSTA3,	INBUFA
/
NODSBL,	0			/ Set to 0 for UPDATE; 1 for no update
/
/The following 9 locations must start with CLASXA and must terminate with 0
/
CLASXA,	CLASIX			/ Init REDSIX/WRISIX routines.
REDSXA,	REDSIX			/ Read SIX bit.
WRISXA,	WRISIX			/ Write SIX bit.
ADRCRA,	ADRCRT			/ Create a document.
AXECA,	AXEC			/ Ask DX user for info needed at connect time.
AXDISA,	AXDIS			/ Set up AX.
AXSRA,	AXSR			/ AX SEND/RECEIVE routine.
AXDONA,	AXDON			/ Log transaction to AX LOG file.
	0
/
	*173
/
/	THESE FLAGS HAVE TO BE IN THESE LOCATIONS FOR AX TO WORK
/
SPFLAG,	0 	/ IF NEGATIVE TELLS THE OTHER JOBS TO EXIT, IF POSITIVE
				/ TELLS THE HOST JOB TO WAIT
/
FREEPT,	BUFBL1 	/ POINTER TO THE FIRST FREE BUFFER (START OF THE FREE LIST)
RECPT,	0 			/ START OF THE BUFFERS RECEIVED LIST
SENDPT,	0 			/ START OF THE SEND LIST
/
NULCNT,	-2 	/ THIS IS THE NEGATIVE NUMBER OF NULLS TO SEND AT THE
		/ END OF EVERY PACKET AFTER THE CR.  IT IS SET BY THE
				/ RECEIVED INIT PACKET.
				/ SET TO -2 TO WORK CORRECTLY WITH RSX-11M
/
	PAGE

/
/	THE PROGRAM STARTS HERE
/
DWXTRT,	XX
	CLA
	RDF
	TAD	CIDF0
	DCA	RTNCER 		/ SAVE THE CALLERS FIELD
	CDFMYF 			/ CDF FOR THIS FIELD
	TAD	(OPTALL) 	/ SET THE OPTIONS TO ALL UNTIL LATER
	DCA	TMPRST
	JMS	SETSIX 		/ SET THE CROSS FIELD CALLS
	JMS	XDELAY		/INITIALIZE TIME OUT DELAYS		/A020
/
/D023;	TAD	(DXSTLS-1) 	/ Get the list of stuff to initialize	/M023
/D023;	JMS	DXIOCL		/ at start-up				/M023
/D023;
/D023;				/ HAS TO BE DONE ONCE
/D023;				/ THIS IS CHAINING THE BUFFERS TOGETHER TO
/D023;				/ CREATE THE INITIAL FREE LIST
/D023;	TAD	(BUFBL1)
/D023;	DCA	FREEPT
/D023;	TAD	(BUFBL2)
/D023;	DCA	BUFBL1
/D023;	TAD	(BUFBL3)
/D023;	DCA	BUFBL2
/D023;	TAD	(BUFBL4)
/D023;	DCA	BUFBL3
/D023;	TAD	(BUFBL5)
/D023;	DCA	BUFBL4
/
	JMS	DXICLA 	/ CLEAR THE FLAGS NEEDED FOR THE IO PROGRAMS TO START
/D023;	JMP	CHKROT 		/ CHECK FOR THE ROUTINE THAT WAS CALLED
/D023;				/ CHKROT RETURNS TO TRNCN5
CHKROT,				/					/A023

/
/	CHKROT - SEES WHICH ROUTINE WAS CALLED FROM THE MENU
/	1 AUTO TRANSMIT
/	2 DOCUMENT TRANSFER
/
CHKROT,
	CDFMNU
	TAD I	(MUBUF+MNTMP1) 	/ SEE WHAT PACKAGE WAS CALLED
	CDFMYF
	DCA	T3
/
			/ INITALIZE THE SYSTEM MESSAGE SENT AT INIT TIME
	IFDEF ENGLSH <
	TAD	("D-200) 	/ INITALIZE TO DX
	>
	IFDEF ITALIAN <
	TAD	("D-200) 	/ INITALIZE TO DX
	>
	IFDEF V30NOR <
	TAD	("D-200) 	/ INITALIZE TO DX
	>
	IFDEF V30SWE <
	TAD	("D-200)
	>
	DCA	SYSTY2 		/ Save the "DX" name
	TAD	(DXSYS) 	/ TELL THE OTHER SYSTEM THAT THIS SIDE IS IN DX
	DCA	SYSTY1
/
/ The following was deleted in edit 023 because CMADSX is initialized	/A023
/ in WPCU3.PA when communications is 1st loaded.			/A023
/D023;	IFDEF WS102 <
/D023;	TAD	T3 		/ SET THE FLAG IS WS102 TO WHAT IS SELECTED
/D023;/
/D023;	CDFSYS 			/ ++++
/D023;	DCA I	(CMADSX) 	/ ++++
/D023;	CDFMYF
/D023;	>			/ END IFDEF WS102
	AC7777 			/ CHECK FOR "AX"
	TAD	T3
	SZA CLA 		/ ++++
	 JMP	TRNCN5 		/ IF NOT "AX" THEN RETURN
	CIFBUF			/ Call routine to start AX.
	JMS I	AXDISA		/  ...
	 JMP	RTNSY 		/ GOLD MENU RETURN
	ISZ	AXFLG
/ SET THE TOP MESSAGE TO "AX"
	IFDEF ENGLSH <
	TAD	("A-200) 	/ INITALIZE TO AX
	>
	IFDEF ITALIAN <
	TAD	("A-200) 	/ INITALIZE TO AX
	>
	IFDEF V30NOR <
	TAD	("A-200) 	/ INITALIZE TO AX
	>
	IFDEF V30SWE <
	TAD	("A-200)
	>
	DCA	SYSTY2 		/ Save the "AX" name
	TAD	(AXSYS)
	DCA	SYSTY1
	AC0002 			/ THE AX OPTIONS CAN NEVER CHANGE FROM 2
	DCA	OPTREC
	JMP	TRNCN5

TRNCN2,	JMS	CLAMSL 		/ CLEAR THE MESSAGE LINE OF ANY MESSAGES
				/ OR ERRORS
TRNCN5,	AC7776 			/ ++++
	DCA	SENDFL 		/ SET THE STATUS TO NOT CONNECTED
	DCA	ERRFLG 		/ CLEAR THE ERROR FLAG ON REINITALIZING
	DCA	OSYSAX 		/ CLEAR THE FLAG THAT TELLS THE USER THAT THE
				/ OTHER
				/ SYSTEM IS IN AX
	DCA	INIFL3 		/ FOR THE HIGH LEVEL
	TAD	OPTREC 		/ RESET THE OPTIONS
	DCA	OPTFLG
	JMS	SETFLG 		/ SET THE FLAGS
	DCA	PMTTMP 		/ CLEAR ALL PENDING PROMPTS
	DCA	INIFL2 		/ CLEAR THE LOW LEVEL FLAG FOR INITALIZATION
	DCA	INIFL1 		/ CLEAR THE FLAG FOR THE LOW LEVEL SAYING TO
				/ SEND INIT
	DCA	SPFLAG 		/ CLEAR THE STOP THE HOST FLAG
	JMS	STRJBS 		/ START THE PROGRAMS
	JMP	TRNCN6		/ DISP SCREEN FIRST			/A039
/D039	JMP	MAINL3 		/ WAIT FOR THE LINE TO INITALIZE
/
/	*******************************
/
RTNSY,	JMS	DOCTRN 		/ KILLS THE JOBS RUNNING AND CLOSES FILE
/	IFDEF WS102 <
/	JMS	RTN102 		/ UNLOCK THE LOG DOCUMENT
/	>			/ END IFDEF WS102
/D023;	CLA

	CDFMNU			/ Map MENU field.			/A023
	TAD I	(MUBUF+MNTMP6)	/ Get EZ-LINK indicator.		/A023
	CDFMYF			/ Back to our field.			/A023
	SZA CLA			/ Skip if normal exit.			/A023
	 JMP	RTNCX		/ Jmp to chain back to CX.		/A023
	CIF	60		/ Map Alternate buffer field.		/A024
	JMS I	(COMXIT)	/ Undo field-6 buffers.			/A024

/	JMS	RTCLCM 		/ CLEAR THE FLAG FOR OTHER USER
	CDFSYS								/A017
	DCA I	(CMADSX)						/A017
	CDFMYF								/A017
/
RTNCER,	XX
	JMP I	DWXTRT


RTNCX,	CDFMNU			/ Map MENU field.			/A023
	TAD	(MUBUF+MNONUM-1)/ Set up to modify MENU Overlay info.	/A023
	DCA	IX1		/  ...					/A023
	TAD	(3)		/ Set up menu code to re-load CX.	/A023
	DCA I	IX1		/ Overlay #3 is CX.			/A023
	TAD	(200)		/ CX entry point is at 200.		/A023
	DCA I	IX1		/  ...					/A023
	TAD	(CIF 20)	/ field to load CX into.		/A023
	DCA I	IX1		/  ...					/A023
	CDFMYF			/ back to our field.			/A023
	ISZ	DWXTRT		/ Set to CHAIN to CX			/A023
	JMP	RTNCER		/ go to it!!!				/A023

/D023;
/D023;/
/D023;/	THE LIST OF LOCATIONS THAT ON ENTERING THEY HAVE TO BE ZERO
/D023;/
/D023;DXSTLS,
/D023;	DOCNCT 			/ THE DOCUMENT COUNTER FOR AX
/D023;	AXFLG 			/ THE ALL IMPORTANT AX FLAG IS SET SAYS THE PROGRAM IS AN AX
/D023;	INBUFA 			/ CLEAR THE KEYBOARD BUFFER
/D023;	SENDPT 			/ THE POINTER TO THE BUFFERS SENT LIST
/D023;	RECPT 			/ THE POINTER TO THE RECEIVED LIST
/D023;	DSKBA1 			/ CLEAR THE BUFFER FOR DOCUMENT TRANSFER
/D023;	DSKBA3 			/ CLEAR THE SECOND BUFFER
/D023;	DXIHFP 			/ RELEASE THE BUFFER THAT THE INPUT TASK USES
/D023;	BUFBL5 			/ THE ZERO IS INSERTED IN THE END OF THE FREE LIST
/D023;	PUTPRC 			/ CLEAR THE COUNTER OF THE BUFFERS WAITING TO BE ACKED
/D023;	PTRHED 			/ AND CLEAR THE FIRST ENTRY
/D023;	PTRHED-1 		/ AND THE TEMP LOCATION
/D023;	STRTJB 			/ CLEAR THE FLAG THAT SAYS THE JOBS ARE RUNNING
/D023;	OPTREC 			/ CLEAR THE OPTIONS OF THE OTHER SYSTEM
/D023;	HSFLAG 			/ HOST FLAG
/D023;	TRNERC 			/ CLEAR THE ERROR COUNTER
/D023;	RDFILF 			/ FLAG SET IF OPEN DOCUMENT FOR READ
/D023;	0
/D023;/


GETCHR,	XX			/ Routine to display date & time and get a
				/ character
	CIFPRT			/ Call FLABUZ in printer field.
	JMS I	(FLABUZ)	/  ... (display printer error if appropriate)
	CIFMNU			/ Now display updated time.
	JMS I	TIMCAL		/  ...
	 JMP	GETCH1		/ no time change. don't update display.
	JMS	CPYTIM		/ Copy new time values.
	CIFMNU			/ Now to update the screen.
	JMS I	IOACAL		/  ...
		0		/ output directly to the terminal.
		TIMSTR		/  ...
		0072		/ Line 1, col 59.
		DATSTR		/ Time/Date string.
	JMS	DISBL		/ update bottom line.
GETCH1,	CIFSYS			/ Now wait for RETURN or GOLD MENU.
	XLTIN			/  ...
	 ISZ	GETCHR		/ Take 2nd return for buffer full.
	JMP I	GETCHR		/ Return to caller.
/
/	FILMBF - FILLS THE MESSAGE BUFFER INMBLK
/
FILMBF,	XX
	TAD	(INMBLK)
	JMS	FILIBF
	JMP I	FILMBF

/------------
	PAGE

/
/	SETFLT - CLEAR THE FLAGS FOR THE DX INIT
/
SETFLT,	XX
	CLA
	DECIMAL
	TAD	(-1000) 	/ SET THE INITAL COMPARISON COUNTER FOR BLOCK
				/ COUNT
	OCTAL
	DCA	BLKTMP
	TAD	DSKBA1 		/ SEE IF THE FIRST OF 2 BUFFERS ARE IN USE
	SNA 			/ ++++
	 JMP	SETFL2
	JMS	PUTBUF 		/ ++++
		FREEPT
SETFL2,	TAD	DSKBA3 		/ CHECK FOR THE OTHER
	SNA 			/ ++++
	 JMP	SETFL3
	JMS	PUTBUF 		/ ++++
		FREEPT
SETFL3,	TAD	(SETFLL-1)
	JMS	DXIOCL
	CIFBUF
	JMS I	CLASXA 		/ INITALIZE THE RED AND WRI SIX ROUTINES
	JMS	CLDOC 		/ CLOSE ANY DOCUMENTS LEFT OPEN BEFORE OPENING ANOTHER
	JMP I	SETFLT

/
/	SETFLL - THE LIST OF FLAGS THAT ARE CLEARED FOR THE DX
/
SETFLL,	INIFLG 			/ CLEAR THE PROGRAM STARTED TO SEND A DOC FLAG
	SNDAD 			/ USED FOR THE SEND PART OF AX
	AXREC 			/ AND USED BY AX RECEIVE
	INMSFG 			/ FLAG SAYING THAT THERE IS A MESSAGE TO PUT UP
	BYSETF 			/ BYE COMMAND IS BEING SENT FLAG
	BLKNUM 			/ THE NUMBER OF BLOCKS SENT CORRECTLY
	EOF 			/ END OF DOCUMENT FLAG
	DOCSIZ 			/ SIZE OF THE SENDING DOCUMENT IN BLOCKS
	RESBFS 			/ CLEAR THE FLAG FOR THE BUFFERS HAVE BEEN CHOSEN
	DSKBA1 			/ THE ADDRESS OF THE FIRST BUFFER USED FOR THE TRANSFER
	DSKBA3 			/ THE SECOND BUFFER
	DSKBA4 			/ THE DISK BUFFER WRITE FLAG
	DSKBA2 			/ THE OTHER DISK BUFFER WRITE FLAG
	BLKOVR
	PMTFLG 			/ CLEAR THE PROMT FLAG
	ERRFLG 			/ CLEAR THE ERROR FLAG
	NOFLAG			/ SPECIAL CASES OF "NO" PACKET		/A031
/D023;	DOCLSA 			/ CLEAR THE FIRST ENTRY INTO THE LIST EVERY TIME A
/D023;				/ TRANSFER IS TO START
	RSTFLG 			/ CLEAR THE RESTART FLAG
	0

/
/	DXICLA - CLEARS THE MAJORITY OF THE FLAGS THAT ARE NEEDED FOR THE LOW
/	LEVEL INIT
/
DXICLA,	XX
	TAD	(TOCLST-1)
	JMS	DXIOCL
	JMS	HOSTIN 		/ CLEAR THE INPUT BUFFER
	SKP CLA
	 JMP	.-2
	JMP I	DXICLA

/
/	DXIOCL - CLEARS THE LIST SPECIFIED BY THE AC
/
DXIOCL,	XX
	DCA	IX1 		/ THE AC CONTAINS THE LIST ADDRESS MINUS 1
DXICLL,	TAD I	IX1
	SNA 			/ ++++
	 JMP I	DXIOCL
	DCA	T2
	DCA I	T2 		/ CLEAR THE FLAG
	JMP	DXICLL

/
/	START THE OTHER JOBS
/
STRJBS,	XX
	CLA
	TAD	STRTJB
	SZA CLA 		/ ++++
	 JMP I	STRJBS
	AC0001 			/ ++++
	DCA	STRTJB
/D035	TAD	USERNO
/D035	SZA CLA 		/ ++++
/D035	 TAD	(JSBSZ^4)
	TAD	(JSBX0) 	/ ++++
	DCA	X0
	TAD	(JLIST-1) 	/ ++++
	DCA	IX1
	JMP	B

A,	MQL
	TAD	X0 		/ ++++
	DCA	T1
	CDFSYS
	RIF
	CLL RAL
	DCA I	X0
	DCA I	X0
	MQA 			/ ++++
	DCA I	X0
	DCA I	X0
	ISZ	X0
	CDFMYF 			/ CDF FOR THIS FIELD (MY FIELD)
	TAD	T1
	CIFSYS 			/ ++++
	JSTRT
B,	TAD I	IX1
	SZA 			/ ++++
	 JMP	A
	JMP I	STRJBS

JLIST,	HSTPRG 			/ ++++
	DXIHJB 			/ ++++
	DXOHJB
	0

STRTJB,	0

/	UNABLE TO CREATE DOCUMENT ERROR PATH				/A031

RCVCR3,	DCA	PMTTMP		/ CLEAR FLAGS				/A031
	DCA	AXPMT		/					/A031
	TAD	(-4)		/ SIGNAL - "***ERROR***"		/A031
	DCA	SENDFL		/					/A031
	AC7777			/ SIGNAL - CHANGE SCREEN		/A031
	DCA	CNGSCF		/					/A031
	JMP	MAINLW		/ RETURN TO MAIN LOOP			/A031

/	RECEIVED A "NO" PACKET - OTHER SYS UNABLE TO CREATE		/A031

RECNO1,	AC0003			/ SIGNAL - "COULD NOT CREATE DOC."	/A031
	DCA	ERRFLG		/					/A031
	DCA	PMTTMP		/ CLEAR FLAGS				/A031
	DCA	AXPMT		/					/A031
	TAD	HSTRAD		/ RELEASE BUFFER			/A031
	JMS	PUTBUF		/					/A031
		FREEPT		/					/A031
	JMP	HSTRST		/ RESTART HOST				/A031

GTLERD,	XX			/ RING BELL HERE			/C034
	CIFMNU
	JMS I	IOACAL		/					/C034
	0
	BELSTR			/ CONTROL STRING			/C034
	BELTXT			/ BELL CODE				/C034
	JMP I	GTLERD		/ Return to caller.

/-------------
	PAGE

/
/	TRNAGN - WAITS FOR THE HOST JOB TO RESPOND TO THE SPFLAG
/
TRNAGN,	AC0001 			/ SET THE FLAG INCASE IT WASNT SET
	JMS	HSTSET 		/ SET THE FLAG AND WAIT FOR THE HOST TO GET IT
	 JMP	RTNSY 		/ GO BACK TO MAIN MENU
	JMS	CLDOC 		/ CLOSE THE DOCUMENT
	JMP	TRNCN2

/
/	HSTSET -  SETS SPFLAG TO TELL THE HOST SOMETHING  AND WAITS
/	FOR HOST TO SAY IT RECEIVED IT
/
HSTSET,	XX
	DCA	SPFLAG
HSTSE2,	JMS	HLTEST 		/ ++++
	 JMP I	HSTSET
	TAD	HSFLAG 		/ SEE IF THE HOST STOPPED
	SNA CLA 		/ ++++
	 JMP	HSTSE2
	ISZ	HSTSET
	JMP I	HSTSET

/
/	RSTPRG - THE HIGH LEVEL INIT ROUTINE
/	IT WILL SEND AN INITALIZE MESSAGE EVERY
/	5 SECONDS AND WAIT FOR A INITALIZE ACK
/
RSTPRG,	TAD	(INITYP-1)
	JMS	INIBFS
	 JMP	HSTWAT 		/ SPFLAG IS SET SO WAIT
	 JMP	TIMEOU 		/ TIMED OUT
	ISZ	INIFL3 		/ SET IT SO ONLY ONE INIT IS SENT
	JMP	HSTJWT 		/ WAIT FOR OTHERS TO SEE WHAT IS DONE

/
/	CPYITM - COPY FROM THE COMMUNICATIONS KEYBOARD BUFFER TO MENU'S
/
CPYITM,	XX
	DCA	TOKOFT 		/ GET THE STARTING ADDRESS
	JMS	DXCOPY
		CDFMYF
TOKOFT,		XX
		CDFMNU
CPYDST,		MUBUF+MNIBUF
	TAD	CPYDST	 	/ SET THE POINTER TO THE MENU BUFFER
	CDFMNU
	DCA I	(MUBUF+MNPOS)
	CDFMYF
	JMP I	CPYITM

/
/	CPYMTB -GET THE DOCUMENT NAME THAT WAS TYPED
/
CPYMTB,	XX
	DCA	CPYMT2
	JMS	DXCOPY
		CDFMYF
CPYMT2,		XX
		CDFMYF
		DOCNBF
	DCA	INBUFA 		/ CLEAR THE KEYBOARD BUFFER SINCE DONE WITH IT
	JMP I	CPYMTB

/
/	GTDCNO - GETS THE DOCUMENT NUMBER FROM THE MENU
/
GTDCNO,	XX
	CDFMNU
	TAD I	(MUBUF+MNFNO) 	/ ALSO SET THE DOCUMENT NUMBER
	CDFMYF
	DCA	DOCNO
	JMP I	GTDCNO

/
/	HITRTN - HOST ROUTINE THAT WILL TAKE CARE OF A HIGH LEVEL INIT PACKET
/
HITRTN,	TAD	AXFLG 		/ KNOW WHAT THE OTHER SYSTEM IS RUNNING BUT DO
	SNA CLA 		/ ++++
	 JMP	HITRT2 		/ NEED MORE INFORMATION IF WE ARE AX?
	CIFBUF
	JMS I	AXECA
	 JMP	HSTWAT 		/ SPFLAG IS SET
	 JMP	TIMEOU 		/ TIMED OUT
	DCA	TMPRST 		/ SAVE OPTIONS THAT THE OTHER SYSTEM CAN USE
HITRT2,	AC0004 			/ GET THE FIRST WORD THE ONE THAT HAS OTHER SYSTEMS
	TAD	HSTRAD 		/ TYPE IN IT IT CAN BE EITHER DX OR AX
	DCA	T1
	TAD I	T1
	TAD	(-40) 		/ IF 40 = DX 41=AX
	DCA	OSYSAX
	TAD	OSYSAX
	SZA CLA 		/ ++++
	 JMP	HITRT4 		/ IF AX THERE IS NO NEED TO SEND THE OPTIONS
	TAD	TMPRST 		/ RESPOND WITH THE OPTION PACKET
	DCA	OPTSTR+1
	TAD	(OPTSTR-1)
	JMS	INIBFS
	 JMP	HSTWAT
	 JMP	TIMEOU
HITRT4,	AC7777 			/ ++++
	DCA	SENDFL 		/ SET STATUS TO WAITING AND INITALIZED
	TAD	HSTRAD 		/ ++++
	DCA	LN2FG 		/ TELL THE MAINJOB THE ADDRESS OF THE BUFFER TO
				/ DISPLAY AND RELEASE WHEN DONE.
	AC7777 			/ ++++
	DCA	CNGSCF 		/ REPAINT THE SCREEN
	JMP	HSTJWT 		/ WAIT BUT FIRST CLEAR THE INTFLG

LN2FG,	0
OPTSTR,	TYPOPT
	XX
	0

/
/	DISBL - DISPLAYS THE BOTTOM LINE AND POSITIONS THE CURSER
/
DISBL,	XX
	TAD	NODSBL 		/ IF 1 THEN DONT DISPLAY THE BOTTOM LINE
	SZA CLA 		/ ++++
	 JMP I	DISBL
	CIFMNU
	JMS I	IOACAL
		0
		CLALIN
		2700
	CIFMNU
	JMS I	IOACAL 		/ DISPLAY THE BOTTOM LINE
		KBOUTC
		BTLINE
		INBUFA
	JMP I	DISBL
/
/	THIS WILL CLEAR THE MESSAGE LINE ON THE SCREEN
/
CLAMSL,	XX
	CIFMNU
	JMS I	IOACAL
		0
		CLALIN
		500
				/ PROBLEM LINE IS NOW ON 4, CLEAR IT TO	/A031
	CIFMNU								/A031
	JMS I	IOACAL							/A031
		0							/A031
		CLALIN							/A031
		400			/ PROBLEM LINE			/A031
	JMP I	CLAMSL
/------------
	PAGE

/
/	DXICKV - CHECK THE VERSION OF THE CONNECTING PROTOCOL TO SEE IF SAME
/
DXICKV,	XX
	AC0002
	TAD	DXGTPT
	DCA	X5
	TAD I	X5 		/ GET WHAT IS SENT
	TAD	(-VERSIO)
	SZA CLA 		/ ++++
	 JMP	DXICKE 		/ ERROR
	TAD I	X5 		/ ++++
	SZA 			/ ++++
	 JMS	SBOFST 		/ ++++
	CIA 			/ ++++
	DCA	NULCNT 		/ STORE THE NUMBER OF NULLS THE
				/ HOST NEEDS AFTER THE CR
	DCA	ERRFLG		/ CLEAR ERROR STATUS			/A017
				/ (FOR RECONNECT REASONS)		/A017
/
/	*** NOTE ***
/	THE SZA IN THE ABOVE SEQUENCE IS THERE TO ALLOW PRE-VER3.1
/	SOFWARE NAMELY 3.0 TO TALK TO EACH OTHER.  3.1 IS THE FIRST TO HAVE THE NULL
/	COUNT ADDED TO IT.  SO IT ASSUMES ZERO IF TALKING TO 3.0
/
	ISZ	DXICKV
	JMP I	DXICKV
DXICKE,	TAD	(7) 		/ ++++
	DCA	ERRFLG 		/ SET FOR THE CORRECT MESSAGE
	JMP I	DXICKV

/
/	INIBFS - SENDS A BUFFER BY PLACING IT IN THE SEND CHAIN
/	THE AC UPON ENTERING CONTAINS THE ADDRESS IF THE TEXT TO SEND IN THE
/	PACKET INCLUDING THE TYP.  THE ADDRESS IS = TO
/	THE STRING ADDRESS -1 TO USE IN AN AUTO INDEX REGISTER.
/	CALL:	JMS	INIBFS
/	RETURN TO MAIN MENU
/	TIMED OUT
/	SENT OK
/
INIBFS,	XX
	DCA	INITM2 		/ SAVE THE CHARACTER TO SEND
	JMS	GETFRE 		/ GET A FREE BUFFER AND RETURN THE ADDRESS IN THE AC
	 JMP I	INIBFS 		/ ERROR RETURN
	DCA	IBFAX 		/ SAVE THE ADDRES TO THE BUFFER
	TAD	IBFAX
	DCA	IX1
	DCA I	IX1 		/ CLEAR THE STATUS FLAG
	DCA I	IX1 		/ CLEAR THE SEQUENCE WORD
	TAD	INITM2
	DCA	IX0
INIGF4,	TAD I	IX0
	SNA 			/ ++++
	 JMP	INIGF3
	DCA I	IX1
	JMP	INIGF4

INIGF3,	DCA I	IX1 		/ INSERT A ZERO TRAILER
	TAD	IBFAX 		/ SEND THE BUFFER
	JMS	PUTBUF 		/ ++++
		SENDPT		/ SEND THE PACKET
	JMP	INIBW3

INIBWT,	JMS	INIWAT 		/ WAIT AND CHECK THE STOP FLAGS
	 JMP	INIBER 		/ ONES SET
INIBW3,	AC0001
	TAD	IBFAX
	DCA	T1
	TAD I	T1
	SNA 			/ ++++
	 JMP	INIBWT
	DCA	INITM2
	TAD	IBFAX 		/ FREE IT
	JMS	PUTBUF 		/ ++++
		FREEPT
	TAD	INITM2
	SMA CLA 		/ ++++
	 ISZ	INIBFS 		/ ERROR DONT INCREMENT
	ISZ	INIBFS
	JMP I	INIBFS

INIBER,	TAD	IBFAX
	JMS	PUTBUF 		/ ++++
		FREEPT		/ EVEN IF ERROR RELEASE BUFFER
	JMP I	INIBFS


INITM2,	0
IBFAX,	0

/
/	THIS WILL STOP THE JOBS THAT ARE RUNNING AND
/	CLOSE THE FILE THAT YOU ARE WRITING TO SINCE IT IS A COMPLETE
/	COPY I DONT ALLOW MULTIPLE DOCUMENTS STORED IN A SINGLE ONE
/
DOCTRN,	XX
	CLA
	TAD	STRTJB 		/ DONT STOP IF NOTHING STARTED
	SNA CLA 		/ ++++
	 JMP I	DOCTRN 		/ IF NOTHING STARTED DONT BOTHER CLOSING
	AC7777 			/ ++++
	DCA	SPFLAG 		/ TELL THE OTHER PROGRAMS TO STOP
	JMP	EXTJMP 		/ GO AND CHECK THE PROGRAMS FOR TERMINATION

EXTWAT,	CIFSYS 			/ ++++
	JSWAP 			/ GET DONE AS SOON A IT CAN
EXTJMP,	TAD	DXIFLG 		/ ASSUME THAT THEY WILL BE - ONLY IF EXITED
	SMA CLA 		/ ++++
	 JMP	EXTWAT
	TAD	DXOFLG
	SMA CLA 		/ ++++
	 JMP	EXTWAT
	TAD	HSFLAG
	SMA CLA 		/ ++++
	 JMP	EXTWAT
	JMS	CLDOC 		/ CLOSE THE DOCUMENT
	JMP I	DOCTRN

/
/	CLDOC - CLOSES THE DOCUMENT THAT IS OPENED
/
CLDOC,	XX
	CLA
	TAD	RDFILF 		/ IF FLAG IS SET THEN THE DOCUMENT WAS OPENED FOR READ
	SZA CLA 		/ ++++
	 JMP	CLDO2
	JMS	CLSCRL 		/ CLOSE SCROLL
	JMP	CLDO3

CLDO2,	DCA	RDFILF
CLDO3,	DCA	DOCNO 		/ CLEAR THE DOCUMENT NUMBER
	JMP I	CLDOC

/
/	HSTOU - USED TO SEND CHARACTERS TO THE HOST.  SHOULD BE USED FOR ONLY SENDING
/	NULLS SINCE THE REGULAR ROUTINE TO SEND A CHARACTER IS HOSTOU.  THE REASON
/	FOR HAVING THIS ROUTINE IS THAT IT IS CALLED BY HOSTOU THROUGH HOSTO2.  THE
/	REASON FOR NOT DOING IT A CLEANER WAY IS ROOM.
/
HSTOU,	XX
	JMP	HSTO2

HSTO3,	TAD	SPFLAG 		/ IF SET TO -1 THEN RETURN SINCE SYSTEM ABORTED
	SPA CLA 		/ ++++
	 JMP I	HSTOU
	CIFSYS 			/ ++++
	JWAIT
HSTO2,	CIFSYS 			/ ++++
	HS2OU
	 JMP	HSTO3
	JMP I	HSTOU
/
/	DXIQIT - ROUTINE USED BY INPUT JOB TO ACT ON A RECEIVED QUIT PACKET
/
DXIQIT,	AC7777 			/ ++++
	DCA	CNGSCF 		/ MAKE SURE SCREEN IS UPDATED
	TAD	(-11) 		/ ++++
	DCA	ERRFLG 		/ SET THE ERROR MESSAGE
	DCA	INIFLG 		/ STOP ANY TRANSFERRING
	JMP	DXIHJB

/------------
	PAGE

/
/	RTCLCM - SETS THE COMMUNICATIONS FLAG TO NOT IN USE.
/	THE FLAG WAS SET BY CU3COM IN WPCU3.PA BEFORE THIS OVERLAY WAS LOADED
/
/RTCLCM,XX
/	CDFSYS
/	DCA I	(CMADSX)
/	CDFMYF
/	JMP I	RTCLCM

/
/	THIS IS THE MAIN KEYBOARD LOOP
/	THE LOGIC OF THIS JOB IS TO TAKE CARE OF THE SCREEN AND ALSO THE USER.
/	IT DISPLAYS MOST OF THE MESSAGES THAT ARE TO APPEAR ON THE SCREEN AND ALSO
/	PREFORM ANY REQUESTS FROM THE USER
/
MAINL3,	DCA	DISTMP		/ CLEAR DISPLAY LOCK FLAG		/C039
MAINLP,	JMS	GTLINE 		/ SEE IF ANYTHING IS BEING TYPED IN
	 JMP	MAINL3 		/ ERRO SO REDISPLAY
	 JMP	RTNSY 		/ GOLD MENU RETURN
	 SKP 			/ OK NOW CHECK FLAGS WHILE WAITING FOR SOMETHING
	JMP	KBDL1 		/ EOL

	JMS	CHKMSG		/ Check Msg - See if one is outstanding./A037
	 NOP			/ Yes. ignore it.			/A037
	TAD	CNGSCF 		/ DISPLAY THE NEW SETTINGS
	SZA CLA			/ ++++					/C039
	  JMS	CKDISF		/ CK FLAG FIRST AND THEN DISPLAY	/C039
	TAD	RSTFLG 		/ SEE IF HAVE TO RESTART
	SMA SZA 		/ ++++
	 JMP	TRNAGN 		/ MEANS LOW LEVEL INITED IF +
	SZA CLA 		/ ++++
	 JMP	MAINLW 		/ THE VERSION OF THE OTHER SYSTEM DOESNT MATCH

	TAD	PMTFLG 		/ SEE IF PROMT FLAG IS SET
	SZA 			/ ++++
	 JMP	PMTANS

	TAD	SNDAD 		/ SEE OF SENDING TO AX
	SZA CLA 		/ ++++
	 JMP	SNTOA1

	TAD	AXREC 		/ SEE IF AX RECEIVE
	SZA CLA 		/ ++++
	 JMP	RCVRT6

MAINLW,	CIFSYS 			/ ++++
	JWAIT 			/ NOTHING SEEMS TO BE DONE SO WAIT
	JMP	MAINLP

/
/	MORE OF THE KEYBOARD ROUTINE
/
CHKMSG,	XX			/ Routine to see if outstanding unanswered msg./A037
	TAD	MSGAST 		/ IF NOT ZERO THEN A MESSAGE WAS SENT
	SNA CLA			/ Skip if there is an outstanding msg.	/A037
	 JMP	MSGOK		/ Jmp if no outstanding msg.		/A037
	TAD I	MSGAST 		/ IF NZ THE ADDRESS OF THE STATUS FOR THE PACKET
	SPA 			/ ++++
	 JMP	MESTO		/ TIMED OUT IF NEG.			/C034
	SNA CLA			/ If positive then sent ok.		/M037
	 JMP	MSGPND		/ If 0 then msg still pending.		/M037
	AC7776 			/ SEE IF JUST SENT A PROMPT ANSWER
	TAD	PMTTMP
	SPA CLA 		/ ++++
	 JMP	MESSN2

	TAD	INIFLG 		/ SEE IF ALREADY SET
	SNA			/ Skip if already set.
	 AC7777			/ ++++
	DCA	INIFLG
MESSN2,	DCA	PMTTMP 		/ CLEAR THE PROMPT FLAG
	ISZ	MGWTFG
	TAD	CNGSCF 		/ IF SET DONT TOUCH
	SNA CLA 		/ ++++
	 ISZ	CNGSCF
	DCA	MSGAST 		/ CLEAR FLAG
	TAD	MSGAX
	JMS	PUTBUF 		/ ++++
		FREEPT
MSGOK,	ISZ	CHKMSG		/ Return w/ no message pending.		/A037
MSGPND,	JMP I	CHKMSG		/ Return w/ message pending.		/A037

/
/	THIS IS THE CHECK FOR VALID COMMAND LOGIC
/
KBDL1,	JMS	INITKF		/ Set TOKOFF to start of input INBUFA string.
	CIFMNU			/ Parse 1st token from input string.
	JMS I	NXACAL		/ This is done primarily for error msgs below.
		TOKOFF		/ ptr to input string.
		TOKBUF		/ buffer to contain parsed token.
	 JMP	MAINLW		/ No args, so forget it.
KBDL3,	IFDEF ENGLSH <
	TAD	TOKBUF+2 	/ SEE IF THE ARG IS TOO BIG
	>
	IFDEF ITALIAN <
	TAD	TOKBUF+3
	>
	IFDEF V30NOR <
	TAD	TOKBUF+2 	/ SEE IF THE ARG IS TOO BIG
	>
	IFDEF V30SWE <
	TAD	TOKBUF+2 	/ SEE IF THE ARG IS TOO BIG
	>
	SZA CLA 		/ ++++
	JMP	KBERRO
	DCA I	GTBFPT 		/ CLEAR THE BUFFER
	TAD	TOKBUF+1 	/ GET THE ARG

/ This code changed to accept up to two characters per option (mainly	/a044
/ due to italian prompting.						/a044

	TAD	(-140)		/ Convert to six bit packed		/a044
	SPA			/					/a044
	TAD	(40)		/					/a044
	AND	P77		/					/a044
	BSW			/ Move into top half of word		/a044
	DCA	T1		/ and save				/a044
	TAD	TOKBUF+2	/ Get the second letter (or zero)	/a044
	TAD	(-140)		/ Convert it to six bit			/a044
	SPA			/ 					/a044
	TAD	(40)		/					/a044
	AND	P77		/					/a044
	TAD	T1		/ Combine it with the other character	/a044
	CIA			/ Compement them for the compare	/a044
	DCA	T1		/ And save them both together		/a044
	TAD	(KBTBL-1)	/ Get the address of the valid ans. table/a044
	DCA	X1		/ Save in an auto-index pointer		/a044

KBDSRL,	TAD I	X1		/ Get the valid word to compare with	/a044
	SNA			/ Is it the end of the table?		/a044
	JMP	KBDEXT		/ Yes, error.				/a044
	TAD	T1		/ Compare it with what the user typed.	/a044
	SNA CLA			/ Are they the same?			/a044
	JMP	KBDEXT		/ Yes, execute the associated routine	/a044
	ISZ	X1		/ No, move to cosider the next entry	/a044
	JMP	KBDSRL		/ Test the next one.			/a044

KBDEXT,	TAD I	X1		/ Get the address to jump to		/a044
	DCA	T1		/ Save it				/a044
	JMP I	T1		/ Jump to it				/a044

KBERRO,	JMS	DISBER 		/ DISPLAY THE ERROR ON THE BOTTOM LINE
	ISZ	NODSBL 		/ SET THE FLAG USED BY RESETS TO TELL IF IT SHOULD UPDDATE
				/ THE BOTTOM LINE AFTER UPDATING THE SCREEN
				/ 0= UPDATE IT 1 = NO
				/ IT IS CLEARED EVERYTIME SOMEONE TYPES A CHARACTER IN GTLINE
	JMP	MAINLW

KBTBL,	IFDEF ENGLSH <
	2200;	RECRTN		/ "R;0	/ RECEIVE
	2300;	SENRTN		/ "S;0	/ SEND
	1500;	RMESRT		/ "M;0	/ MESSAGE
	0200;	RBYERT		/ "B;0	/ BYE
	0000;	KBERRO		/ 0	/ END OF TABLE, ERROR
	>
	IFDEF ITALIAN <
	2204;	RECRTN		/ "R;"D	/ RECEIVE
	1104;	SENRTN		/ "I;"D	/ SEND
	1115;	RMESRT		/ "I;"M	/ MESSAGE
	1124;	RBYERT		/ "I;"T	/ BYE
	0000;	KBERRO		/ 0	/ END OF TABLE, ERROR
	>
	IFDEF V30NOR <
	2200;	RECRTN		/ "R;0	/ RECEIVE
	2300;	SENRTN		/ "S;0	/ SEND
	1500;	RMESRT		/ "M;0	/ MESSAGE
	0200;	RBYERT		/ "B;0	/ BYE
	0000;	KBERRO		/ 0	/ END OF TABLE, ERROR
	>
	IFDEF V30SWE <
	2200;	RECRTN		/ "R;0	/ RECEIVE
	2300;	SENRTN		/ "S;0	/ SEND
	1500;	RMESRT		/ "M;0	/ MESSAGE
	0200;	RBYERT		/ "B;0	/ BYE
	0000;	KBERRO		/ 0	/ END OF TABLE, ERROR
	>

/-----------
	PAGE

/
/	GTLINE - WILL READ IN A CHARACTER FROM THE KEY BOARD AND
/	INTERPERATE IT FOR ANY SPECIAL MEANING.
/
/	CALL:
/	JMS	GTLINE
/	NOTHING
/	RETURN IF THE CHAR. IS A GOLD MENU
/	OK CHAR THAT HAS BEEN PUT IN THE BUFFER
/	EOL
/
GTLINE,	XX
	JMS	GETCHR		/ Get character & display DATE&TIME.
	 SKP			/ CHAR in AC return.
	JMP	GTLNOK 		/ NOTHING
	DCA	GTLTEM 		/ SAVE THE CHARACTER TYPED
	DCA	NODSBL 		/ CLEAR THE FLAG SO RESETS WILL UPDATE BOTTOM LINE
	TAD	(-INBUFA) 	/ SEE IF IT WAS THE FIRST CHARACTER IN THE BUFFER
	TAD	GTBFPT 		/ IF SO CLEAR THE SCREEN
	SZA CLA 		/ ++++
	 JMP	GTLIN1
	DCA I	GTBFPT 		/ FIRST MAKE SURE THE BUFFER IS CLEARED
	JMS	DISBL
GTLIN1,	TAD	GTLTEM
	TAD	(-EDMENU) 	/ CHECK FOR GOLD MENU
	SNA 			/ ++++
	 JMP	GTLNGM
	TAD	(EDMENU-EDRBCH) / CHECK FOR A RUB CHARACTER
	SNA 			/ ++++
	 JMP	GTRBCR
	TAD	(EDRBCH-EDRBWD) / NOW CHECK FOR RUB WORD
	SNA 			/ ++++
	 JMP	GTRBWD
	TAD	(EDRBWD-EDNWLN) / CHECK FOR A RETURN
	SNA 			/ ++++
	 JMP	GTSTPR
	TAD	(EDNWLN)
	SPA 			/ ++++
	 JMP	GTERED 		/ SEE IF IT IS A NON VALID EDIT CHAR.
	AND	P177 		/ IF EVERYTHING PASSES THEN STORE THE CHAR
	TAD	(-40) 		/ GET RID OF CONTROL CHARACTERS
	SPA 			/ ++++
	 JMP	GTLNOK
	TAD	(40)
	DCA I	GTBFPT
	TAD I	GTBFPT 		/ DISPLAY THE CHAR
	JMS	KBOUTC
	TAD	(-INBUFA-INBUFM)/ CHECK FOR MAX
	TAD	GTBFPT
/D034	 SZA CLA 		/ ++++
	 SNA CLA		/ ++++					/C034
	JMP	GTERED		/ MAX - RUB CHAR & RING BELL		/A034
	ISZ	GTBFPT		/ NOT YET - BUMP POINTER		/A034
	DCA I	GTBFPT		/ INSERT DELIMITER			/A034
	JMP	GTLNOK 		/ BRANCH TO OK EXIT			/A034

GTRBCR,	JMS	GTRBCH 		/ CALL RUB CHAR
	 JMP	GTLNOK 		/ BEGINING OF BUFFER
	JMP	GTLNOK 		/ WORKED OK

/
/	GTRBWR - RUBOUT A WORD
/
GTRBWD,	AC7777 			/ SEE THE NEXT CHAR WHAT IS IT
	TAD	GTBFPT
	DCA	T1
	TAD I	T1
	TAD	(-40)
	SMA SZA CLA		/ Skip if space or less (ie not a character).
	 JMP	GTRBW2		/ found a char (start of word).
	JMS	GTRBCH		/ Rub out leading spaces (tabs, etc.)
	 JMP	GTLNOK		/ line empty return.
	JMP	GTRBWD		/ do rest of leading spaces, tabs, etc.
GTRBW2,	AC7777
	TAD	GTBFPT 		/ SEE WHAT THE NEXT CHAR IS
	DCA	T1
	TAD I	T1
	TAD	(-40)
	SMA SZA CLA		/ Skip if not a word character.
	 JMS	GTRBCH		/ Rub out character of word.
	  JMP	GTLNOK		/ line empty so done.
	JMP	GTRBW2		/ check out next (preceding) character.

GTERED,	ISZ	GTBFPT		/ ADJUST FOR RUB CHAR			/A034
	JMS	GTRBCH		/ RUB CHAR				/A034
	  JMP GTLNOK		/ NO CHAR RETURN			/A034
	JMS	GTLERD		/ RING BELL				/A034
	JMP	GTLNOK		/ TAKE THE NOTHING RETURN		/A034
GTSTPR,	TAD	(INBUFA)	/ SET THE BEGINNING OF THE BUFFER
	DCA	GTBFPT
	ISZ	GTLINE
GTLNOK,	ISZ	GTLINE
GTLNGM,	ISZ	GTLINE
GTERRT,	JMP I	GTLINE

GTLTEM,	0


/
/	GTRBCH - RUB A CHARACTER IF THERE ARE NO CHARS IT WILL DO A NON SKIP RETURN
/	IF DID RUB OUT SOMETHING THEN A NORMAL RETURN
/
GTRBCH,	XX
	CLA
	TAD	(-INBUFA) 	/ CHECK FOR THE POINTER IF IT HAS MOVED
	TAD	GTBFPT
	SNA CLA 		/ ++++
	 JMP I	GTRBCH 		/ RETURN
	ISZ	GTRBCH
	AC7777 			/ DECREMENT THE POINTER
	TAD	GTBFPT
	DCA	GTBFPT
	DCA I	GTBFPT 		/ ERASE THE CHAR FROM THE BUFFER
	JMS	KBOUT		/ Erase from the screen
		BKSPAC+4000	/ BS
		SPACE+4000	/ SP
		BKSPAC		/ BS
	JMP I	GTRBCH


			/ ERROR WHILE CREATING THE RECEIVE FILE		/A031
RCVCR1,			/ ENTRY FOR THE RECEIVER OF THE "REC" PACKET	/A031
			/ SENDS THE "NO" PACKET BACK			/A031
	DCA	INIFLG		/ CLEAR INIT FLAG			/A031
	TAD	(TYPNO)		/ "NO" PACKET				/A031
	DCA	ANSBUF		/ TEMP STORAGE				/A031
	TAD	(ANSBUF-1)	/ THE POINTER				/A031
	JMS	INIBFS		/ SEND THE PACKET			/A031
	JMP	HSTPRG		/ RETURN TO MAIN MENU			/A031
	JMP	TIMEOU		/ TIMED OUT				/A031
RCVCR2,				/ OK RETURN - PACKET WAS SENT		/A031
	/ ENTRY POINT FROM NORTN - RECEIVER OF A "NO" PACKET		/A031

	AC0003			/ "UNABLE TO CREATE"			/A031
	DCA	ERRFLG		/					/A031
	JMP	RCVCR3		/					/A031

BELSTR,	TEXT '^A'		/ CONTROL STRING FOR KB ERROR ROUTINE	/A034
BELTXT,	207;0			/ 					/A034

/------------
	PAGE

/
/	THIS ROUTINE WILL INITALIZE THE PROGRAM FOR SENDING A FILE
/

SENRTN,	JMS	CLASTA		/ CLEAR THE STATUS LINE	AND FLAGS	/A031
	TAD	PMTTMP		/ is the SEND invoked by this user?
	SNA CLA			/ Skip if no.
	 JMS	INITFN		/ Set up default filename string.
SNDDM1,	JMS	DOMENU		/ Prompt for a file name for doc to be sent.
		DLMA17		/  ...
	 JMP	KBDL5 		/ GOLD MENU RETURN
	TAD	TOKOFF 		/ COPY THE LAST INPUT AREA NOT FROM MENU
	JMS	CPYMTB 		/ GET THE FILE NAME
	TAD	AXPMT 		/ SEE IF THE SECOND MENU FOR AX (AN AX PROMPT)
	SNA CLA 		/ ++++
	JMP	SNDDM5
	DCA	AXPMT
SNDDM2,	AC7776			/ TELL NORTN TO USE CANNED MESSAGE	/A031
	DCA	NOFLAG		/ "UNABLE TO CREATE DOCUMENT" IF NO	/A031
	AC0002 			/ SEND THE SEND PAKCET
	JMP	SNDPPK

SNDDM5,	JMS	GTDCNO 		/ GET THE DOCUMENT NUMBER
	AC0002 			/ ++++
	DCA	OPTFLG 		/ SET THE OPTIONS TO SEND A MESSAGE ONLY
SNTOA1,	DCA	SNDAD 		/ CLEAR THE FLAG FOR AX SEND
	TAD	DOCNO
	CIFFIO 			/ ++++					/M013
	FILEIO 			/ ++++					/M013
	XRDFIN 			/ OPEN THE FILE FOR READING
	ISZ	RDFILF 		/ SET THE REDFIL FLAG SO TO CLOSE IT
/
	AC0001 			/ ++++
	DCA	SENDFL 		/ SET FOR THE SYSTEM TO KNOW THAT IS SEND
	TAD	OSYSAX 		/ IF THE OTHER SYSTEM IS IN AX THEN DISPLAY
	SNA CLA			/  the other prompt to tell us what to do.
	 JMP	SNDDM2		/ JMP if other system not in AX.
	ISZ	AXPMT 		/ SET FLAG FOR PROMT DISPLAY
	JMS	INITKF 		/ INITALIZE THE TOKEN OFFSET TOKOFF TO STARTING OF BUFFER
	DCA	INBUFA 		/ CLEAR BUFFER SO THE SECOND PROMPT ACT LIKE A PROMPT
	JMP	RCVRT0


RCVGLD,	JMS	CLDOC		/ CLOSE RECIEVE FILE			/A017
KBDL5,	AC7777			/ THE GOLD MENU RETURN FROM ANY OPTION IN THE KEYBOARD PROGRAM
	DCA	CNGSCF 		/ REDISPLAY THE SCREEN
	TAD	AXFLG 		/ IF SET FOR AX ACT IF NO PROMPT FLAG SET
	SZA CLA 		/ ++++
	JMP	KBDL6
	TAD	PMTTMP 		/ IF IT IS A PROMPT GOLD MENU MEANS GO TO MAIN
	SZA CLA 		/ ++++
	JMP	RTNSY
KBDL6,	TAD	INIFLG 		/ IF IN THE MIDDLE OF TRANSFERING THEN JUST CONTINUE
	SZA CLA 		/ ++++
	JMP	KBDL7
	AC7777 			/ ++++
	DCA	SENDFL 		/ SET FOR CONNECTION MADE STATUS
	TAD	OPTREC 		/ ++++
	DCA	OPTFLG 		/ SET THE OPTIONS BACK TO WHAT THEY WERE
KBDL7,	DCA	AXPMT 		/ CLEAR THE PROMPT STATUS TO AX
	JMP	MAINLW

RDFILF,	0

/
/	ASSEMBLES THE INIT MESSAGE FOR THE OTHER USER
/
SETUPW,	XX
	JMS	GETFRE 		/ GET A FREE BUFFER AND RETURN THE ADRESS IN THE AC
	 JMP	HSTWAT 		/ ERROR RETURN
	DCA	SETUPA 		/ STORE THE STARTING ADDRESS
	CDFFIO 			/ GET THE DOCUMENT SIZE			/M013
	TAD I	(RDFSIZ)
	CDFMYF 			/ A CDF FOR THIS FIELD (MY FIELD)
	DCA	DOCSIZ
	TAD	SETUPA
	DCA	X1
	DCA I	X1 		/ CLEAR THE STATUS
	DCA I	X1 		/ CLEAR THE SEQUENCE
	TAD	(TYPSOD) 	/ INSERT THE FLAG CHARACTER
	DCA I	X1
	TAD	DOCSIZ 		/ INSERT IT INTO THE INITAL MESSAGE
	BSW
	AND	P77
	JMS	ADOFST
	DCA I	X1
	TAD	DOCSIZ
	AND	P77
	JMS	ADOFST
	DCA I	X1
	TAD	X1
	JMS	GETPRC 		/ INSERT THE PRINTER SETTINGS
	TAD	SETUPA 		/ PUT THE PACKET INTO THE SEND LIST
	JMS	PUTBUF 		/ ++++
		SENDPT
	JMP	SNDFS2

SNDFS1,	JMS	INIWAT 		/ WAIT
	 JMP	HSTWAT 		/ SPFLAG SET

SNDFS2,	AC0001 			/ CHECK THE STATUS
	TAD	SETUPA
	DCA	T1
	TAD I	T1
	SNA 			/ ++++
	 JMP	SNDFS1 		/ NOT DONE
	DCA	TEMP 		/ SAVE STATUS
	TAD	SETUPA 		/ OK
	JMS	PUTBUF 		/ ++++
		FREEPT		/ SO GET RID OF IT
	TAD	TEMP
	SPA CLA 		/ ++++
	 JMP	TIMEOU 		/ IF - THEN TIMED OUT
	JMP I	SETUPW

SETUPA,	0
/--------------
	PAGE

/
/	THE ROUTINE TO HANDLE THE RECEIVE COMMAND
/

RECRTN,	JMS	CLASTA		/ CLEAR STATUS LINE AND FLAGS		/A031
	TAD	PMTTMP		/ who's initing this?
	SNA CLA			/ Skip if HOST initing the receive.
	 DCA	DOCNBF		/ For user initiated prompt, clear default.
RCVRT0,	JMS	DOMENU		/ Put up the RECEIVE menu.
		DLMA16		/  ...
	 JMP	KBDL5 		/ GOLD MENU RETURN
	TAD	TOKOFF
	JMS	CPYMTB 		/ GET THE DOCUMENT NAME
	CDFMNU			/ Get MNTMP3 return value.
	TAD I	(MUBUF+MNTMP3)	/  ...
	CDFMYF			/   3 = ok return; 4 = have to create return.
	TAD	(-4)		/ check for "have to create" return.
	SNA CLA			/ Skip if file already exists.
	 JMP	RCVCRT
	TAD	AXPMT 		/ WHATS IT USED FOR A SPECIAL PROMPT TO AX
	SNA CLA 		/ ++++
	 JMP	RCVMOD 		/ NO
	DCA	AXPMT
RCVRT3,	AC0003 			/ SET THE PROMPT RESPONSE TO = RECEIVE
	JMP	SNDPPK

RCVMOD,				/ ASKMOD Gets MNTMP3 value from AC.
	JMS	ASKMOD		/ Display Top, Bottom, Overwrite & get option.
		DLMA15		/  ...
	 JMP	RCVGLD		/ GOLD MENU RETURN			/A017
	TAD	(-2) 		/ GET BACK TO THE VALUE THAT WAS IN MNTMP1
	DCA	DOCMOD 		/ STORE THE OPTION
	JMP	RCVRT5

RCVCRT,	CIFBUF
	JMS I	ADRCRA		/ Call CREATE routine.
	 JMP	RCVCKP		/ CREATE ERROR FOR THE PUT ROUTINE	/C033
	CDFMNU			/ SET "REMEMBERED" FILE NUMBER.
	DCA I	(MUBUF+MNFNO)	/  ...
	TAD I	(MUBUF+MNFNO)	/ GET DOC NUMBER.
	AND	P377		/  ...
	DCA I	(MUBUF+MNDOCN)	/ STORE IT TOO.
/	the below is not needed as GTDCNO does CDF for us & i need 1 more word.
/	CDFMYF			/ Back to our field.
RCVRT5,	JMS	GTDCNO		/ Copy doc # from menu to DOCNO.
RCVRT6,	DCA	AXREC 		/ CLEAR THE AX RECEIVE FLAG
	TAD	DOCNO
	MQL
	TAD	DOCMOD 		/ GET THE WAY THE FILE IS TO BE OPENED
	CIFFIO 			/ ++++					/M013
	FILEIO 			/ ++++					/M013
	XDSKIN 			/ INITALIZE THE FILE
	AC0002 			/ ++++
	DCA	OPTFLG 		/ SET TO ONLY SEND A MESSAGE AND BYE
	DCA	SENDFL 		/ SET TO RECEIVE
	TAD	OSYSAX 		/ IF THE OTHER SIDE IS AX THEN ANOTHER PROMPT
	SNA CLA			/  IS NEEDED
	 JMP	RCVRT3		/ Jmp if other side NOT in AX.
	JMS	INITKF 		/ INITALIZE THE TOKEN OFFSET TOKOFF TH BEGINING OF BUFFER
	DCA	INBUFA 		/ CLEAR SO OTHER DISPLAY ACTS LIKE A PROMPT
	ISZ	AXPMT
	JMP	SNDDM1

DOCNO,	0
DOCMOD,	0

RCVCKP,	CLA			/ CK FOR LOCAL INIT. OF REC		/A033
	TAD	PMTTMP		/					/A033
	SNA CLA			/ SKIP IF HOST				/A033
	JMP	RCVCR2		/ LOCAL ERROR ONLY			/A033
	JMP	RCVCR1		/ HOST REQUIRES A "NO" PACKET		/A033

/
/	IT WILL SEND A MESSAGE TO THE OTHER SYSTEM
/
RMESRT,	JMS	WTMARG 		/ WAIT FOR SOMETHING TO BE TYPED
	TAD	(TYPMES) 	/ INSERT THE TYP CODE
MSGSET,	DCA	T3 		/ STORE THE FLAG CHARACTER
				/ THIS IS A TEMP ON PAGE ZERO BUT I USE IT SINCE
				/ GETBUF ONLY USES 1 AND 2 BUT WATCH OUT IF CHANGED
	JMP	MSGST1

MSGST2,	JMS	HLTEST 		/ ++++
	 JMP	RTNSY 		/ SEE IF A GOLD HALT WAS PRESSED
MSGST1,	JMS	CHKMSG		/ See if there is a msg pending an ACK.	/A037
	 JMP	MSGST2		/ Jmp if yes. Wait for it to be 'ack'ed	/A037
	JMS	GETBUF 		/ ++++
		FREEPT
	 JMP	MSGST2
	DCA	MSGAX 		/ SAVE THE ADDRESS OF THE BUFFER FOR LATER
	TAD	MSGAX
	DCA	X3
	DCA I	X3 		/ CLEAR THE STATUS FLAG
	TAD	X3
	DCA	MSGAST 		/ STORE THE ADDRESS OF THE CONDITION CODE
	DCA I	X3 		/ CLEAR THE SEQUENCE POSITION
	TAD	T3 		/ INSERT THE FLAG CHARACTER
	DCA I	X3
	JMS	MSGFIL 		/ FILL THE REMAINING OF THE PACKET
	TAD	MSGAX 		/ PUT IN SEND LIST
	JMS	PUTBUF 		/ ++++
		SENDPT		/ BUT INTO THE SEND BUFFER
	JMS	CLAINF
	ISZ	MESSNF 		/ PUT UP MESSAGE SENT
	JMP	MAINLW 		/ GO AND WAIT FOR THE MESSAGE TO BE SENT

MESSNF,	0
MSGAX,	0
MESTO,	AC7776
	DCA	ERRFLG		/ SET ERROR MESSAGE			/A034
	DCA	MSGAST		/ MESSAGE SENT FLAG			/A034
	JMP	RCVCR3		/ CONTINUE ERROR PATH AT OLD MAINER	/A034
/-----------
	PAGE

/
/	SEND A GOOD-BYE TO THE OTHER TERMINAL
/
RBYERT,	JMS	WTMARG 		/ WAIT FOR SOMETHING TYPED THAT CAN BE SENT
	JMS	STPTRN 		/ STOP A TRANSFER IN PROGRESS IF ANY
	TAD	(TYPBYE) 	/ SET THE TYP OF THE BUFFER
	JMP	MSGSET

/
/	PMTANS - WILL DISPLAY THE PROMPT AND WAIT FOR A RESPONSE
/
PMTANS,	DCA	PMTTMP 		/ CLEAR THE REAL PROMPT FLAG FOR OTHERS TO BE ALLOWED
	DCA	PMTFLG 		/ WHILE THIS ONE IS BEING ANSWERED
	DCA	INBUFA 		/ CLEAR THE BUFFER FOR THE PROMT TO WORK CORRECTLY
	JMS	INITKF 		/ INITALIZE THE TOKEN POINTER TO BEGINING OF BUFFER
	TAD	PMTTMP 		/ SEE IF IT IS A DOCUMENT MOD PROMPT (4)
	SPA 			/ ++++
	 JMP	PMTAN3 		/ IF NEGATIVE TREAT SPECIAL
	TAD	(-4)
	SNA 			/ ++++
	 JMP	MDRTN
	TAD	(2)		/ NOW CHECK FOR A SEND/RECEIVE PROMPT (2 AND 3)
	SPA 			/ ++++
	 JMP	PMTAN3
	CIA
	TAD	SENDFL 		/ SEE IF ALREADY IN THE SAME MODE
	SNA CLA 		/ ++++
	 JMP	PMTERR 		/ YES

	TAD	SENDFL 		/ IF POSITIVE THEN ALREADY IN THE STATUS DESIRED SO DO NOTHING
	SMA CLA 		/ ++++
	 JMP	MAINLW

	AC7776			/ IF A SEND PACKET RECEIVED GO TO THE SEND ROUTINE
	TAD	PMTTMP		/ AND RECEIVE FOR A SEND PACKET RECEIVED
	SNA CLA 		/ ++++
	 JMP	RECRTN
	JMP	SENRTN

PMTAN3,	CLA			/ CLEAR BEFORE MENU CALL		/A038
	CIFMNU
	JMS I	MNUCAL
		DLMAD5
	CIFMNU
	JMS I	IOACAL 		/ DISPLAY THE other half of the PROMPT
		0		/ that the MN2 starts
		PMTMES		/ IOA string for printing buffers
	IFDEF ENGLSH < 2212 > 	/ cursor position to start at for "TYPE PASSWORD/ID"
	IFDEF ITALIAN < 2212 >
	IFDEF V30NOR < 2212 > 	/ cursor position to start at for "TYPE PASSWORD/ID"
	IFDEF V30SWE < 2212 > 	/ cursor position to start at for "TYPE PASSWORD/ID"
		DOCNBF		/ buffer address
		2700		/ where to position cursor after
PMTANW,	CIFSYS 			/ ++++
	JWAIT
	JMS	GTLINE 		/ READ IN THE TEXT FOR THE PROMT ANSWER
	 JMP	PMTAN3 		/ RE-DISPLAY THE PROMPT			/M022
	 JMP	RTNSY 		/ GM
/D034	 JMP	PMTAN0		/ CHECK OF # OF CHARS WITHIN LIMITS	/A022
	 JMP	PMTANW		/ CHAR OK OR NOTHING			/A034
	CLA			/ CLEAR THE FLAG BECAUSE IF SET WHEN THE PACKET IS
	DCA	PMTTMP		/ TRANSFERRED THEN INIFLG IS ACTIVATED.
	AC0001 			/ SEND THE NORMAL RESPONSE TO THE PROMPT
	JMP	SNDPP2


/ THIS ROUTINE CHECKS TO MAKE SURE THAT THE USER PUTS IN
/  64 CHARACTERS OR LESS WHEN ENTERING AN ID OR PASSWORD.
/   THE REASON BEING, IS THAT THE BUFFERS FOR ID/PASS ARE
/    ONLY 64 LOC LONG

/PMTAN0,	TAD	GTBFPT		/ POINTER TO INPUT BUFFER	/A022
/	TAD	(-INBUFA-101)	/ REACHED MAX INPUT?		/A022
/	SZA CLA			/ SKIP IF: MAX INPUT REACHED		/A022
/	 JMP	PMTANW		/ WITHIN LIMIT, WAIT FOR MORE		/A022
/	JMS	GTLERD		/ Display appropriate error msg.	/M027
/	JMP	PMTAN3		/ Re-display prompt.			/M027

PMTERR,	AC7777 			/ ++++
	DCA	CNGSCF 		/ SET FLAG SO THE ENTIRE SCREEN IS CHANGED
	TAD	(10)		/ ++++
	DCA	ERRFLG
	JMP	MAINLW

PMTTMP,	0

/
/	THE ROUTINE WILL WAIT FOR A YES OR NO SENT FROM THE HOST
/	IN RESPONSE OF A INITALIZE MESSAGE
/
WTFRYN,	XX
	CLA
WTFRLP,	TAD	DLY6X 		/ SET THE TIME LIMIT			/M020
	JMS	WAITDT 		/ WAIT FOR 30 SECONDS FOR A RESPONSE
	 JMP	TIMEOU 		/ TIMED OUT
	DCA	WTFRT2
	TAD	HSTRAD 		/ RELEASE IT
	JMS	PUTBUF 		/ ++++
		FREEPT
	TAD	WTFRT2 		/ GET THE CHAR BACK
	TAD	(-TYPNO) 	/ CHECK FOR NO
	SNA 			/ ++++
	 JMP	CKCSN 		/ NO FOUND NOW VALIDATE
	TAD	(TYPNO-TYPYES)
	SNA CLA 		/ ++++
	 JMP	CKCSY 		/ CHECK FOR A REAL YES
	JMP	WTFRLP 		/ WAIT AGAIN

CKCSY,	ISZ	WTFRYN
CKCSN,	JMP I	WTFRYN

WTFRTP,	0
WTFRT2,	0

/
/	FILLS THE BUFFER WITH THE CHARACTERS TYPED IN FROM THE
/	MESSAGE TYPED IN AFTER THE COMMAND OR THE ENTIRE INPUT BUFFER IF A PROMPT
/
MSGFIL,	XX
	AC7777 			/ WANT THE SCREEN COMPLETELY DISPLAYED
	DCA	CNGSCF
	TAD	TOKOFF
	DCA	MSGAG1
	AC0001 			/ GET THE STARTING ADDRESS OF THE BUFFER FOR THE PACKET
	TAD	X3
	DCA	MSGAG2
	JMS	DXCOPY 		/ GET THE TEXT PART OF THE PACKET
		CDFMYF
MSGAG1,		XX
		CDFMYF
MSGAG2,		XX
MSGFL3,	DCA	INBUFA 		/ CLEAR THE INPUT BUFFER
	JMP I	MSGFIL

CKDISF,	XX			/ 					/A039
	TAD	DISTMP		/ CK FLAG BEFORE CALL			/A039
	SZA CLA			/					/A039
	  JMP	MAINLW		/ HOST IS ACTIVE - RET AND WAIT		/A039
	TAD	CNGSCF		/ PICK UP VALUE				/A039
	JMS	DISSCR		/ CALL DISPLAY ROUTINE			/A039
	JMP I	CKDISF		/ RETURN				/A039

/------------
	PAGE

/
/	DISSCR - CLEARS THE RESETC FLAG AND CALLS THE CORRECT DISPLAY ROUTINE
/
DISSCR,	XX
	DCA	DISTMP
	DCA	CNGSCF
	TAD	DISTMP
	SMA SZA 		/ ++++
	 JMS	RESTS
	SZA CLA 		/ ++++
	 JMS	RESETS
	DCA	DISTMP 		/ CLEAR FLAG FOR HOST PROGRAM
	JMP I	DISSCR
/
/	French needed one location on this page. It appears that
/	INITKF is not called while DISTMP is in use so for french the
/	return address location of INITKF is used for temporary storage
/
	IFNDEF FRENCH <
DISTMP,
	0
	>
	IFDEF FRENCH <
	DISTMP=INITKF
	>


/
/	THIS IS RESTS - WHICH HANDLES MOEST OF THE SEPERATE LINES ON THE SCREEN
/	THAT ARE CHANGED THE MOST
/
RESTS,
	XX
	AC0002 			/ DONT DISPLAY IF NOT CONNECTED YET
	TAD	SENDFL
	SNA CLA 		/ ++++
	JMP	RESTA
/
	CIFMNU
	JMS I	IOACAL 		/ THE NUMBER OF TRANSMIT ERRORS
	0
	NUMDIS
	IFDEF ENGLSH < 1060 >
	IFDEF ITALIAN < 1076 >
	IFDEF DUTCH < 1065 >
	IFDEF V30NOR < 1060 >
	IFDEF V30SWE < 1060 >
	TRNERC
/
RESTA,
	TAD	LN2FG 		/ CHECK FOR THE SECOND LINE FLAG
	SNA 			/ ++++
	JMP	RESTC
	TAD	(5)
	DCA	LN2F2
	CIFMNU
	JMS I	IOACAL
	0
	OUTLN
	205
LN2F2,	XX
/
	TAD	LN2FG 		/ RELEASE THE BUFFER
	JMS	PUTBUF 		/ ++++
	FREEPT
	DCA	LN2FG 		/ CLEAR FLAG
RESTC,
	TAD	INIFLG 		/ DISPLAY IF TRANSFER IN PROGRESS
	SZA SMA CLA 		/ ++++
	JMP	RESTC2
	AC0003 			/ ++++
	TAD	SENDFL 		/ IF IN TRANSFER COMPLETE MODE STILL DISPLAY NO.
	SNA CLA
RESTC2,
	JMS	BLKNMD 		/ UPDATE THE BLOCK COUNT ON THE SCREEN
/
	TAD	INMSFG 		/ CHECK FOR A MESSAGE FOR THE SCREEN
	SNA CLA 		/ ++++
	JMP	RESTI 		/ NO
	DCA	INMSFG 		/ CLEAR THE MESSAGE FLAG
/
	CIFMNU
	JMS I	IOACAL
	0
	MESSTM 			/ YES , PUT IT UP
	505
	INMBLK
/
RESTI,
	TAD	BYSETF 		/ SEE IF A BYE MESSAGE WAS RECEIVED
	SNA CLA 		/ ++++
	JMP	RESTM
	DCA	BYSETF 		/ CLEAR THE BYE MESSAGE FLAG
/
	CIFMNU
	JMS I	IOACAL
	0
	BYESTM
	505
	INMBLK
/
RESTM,
	TAD	MGWTFG 		/ SEE IF A MESSAGE HAS BEEN SENT
	SNA CLA 		/ ++++
	JMP	RESTN
	DCA	MGWTFG 		/ CLEAR THE FLAG SO IT IS ONLY SHOWN ONCE
/
	CIFMNU
	JMS I	IOACAL 		/ Print " - Recieved"
	0 			/ default output routine
	OKSTMT 			/ string address
	IFDEF ENGLSH < 621 	/ cursor position for "sent - received"
	>
	IFDEF ITALIAN < 626 >	/ cursor position for "inviato - ricevuto"
	IFDEF V30NOR < 626 >	/ cursor position for "inviato - ricevuto"
	IFDEF V30SWE < 626 >	/ cursor position for "inviato - ricevuto"

RESTN,
	TAD	MESSNF 		/ IF SET PUT UP THE MESSAGE FOR A MESSAGE BEING SENT
	SNA CLA 		/ ++++
	JMP	RESTO
	DCA	MESSNF
/
	CIFMNU
	JMS I	IOACAL 		/ Print "Message sent"
	0 			/ Default output routine
	MSGPRG 			/ string address
	605 			/ cursor position
/
RESTO,
	TAD	ERRFL2 		/ IF THE ERROR FLAG IS SET THEN DISPLAY IT
	SNA 			/ ++++
	 JMP	RESTP		/					/C031
	CDFMNU			/ Map menu field.			/A037
	TAD	(-11)		/ see if 'other user returned to Main'	/A037
	SNA CLA			/ Skip if no.				/A037
	 TAD I	(MUBUF+MNTMP6)	/ Are we in EZLINK (i.e. from CX)?	/A037
	CDFMYF			/ Back to my field.			/A037
	SZA CLA			/ Jmp if time to return to CX.		/A037
	 JMP	RTNSY		/ Return to CX.				/A037
	TAD	ERRFL2		/ Get error code.			/A037
	CDFMNU
	DCA I	(MUBUF+MNTMP1) 	/ SET THE ERROR
	CDFMYF
	CIFMNU
	JMS I	MNUCAL
		DLMA12
RESTP,	TAD	PRBSFG		/ CK FOR TEXT IN "NO" PACKET		/A031
	SNA	CLA		/ SKIP IF PRESENT			/A031
	JMP	RESTQ		/ NO - CONTINUE				/A031
	DCA	PRBSFG		/ RESET FLAG				/A031
	CIFMNU			/ MENU					/A031
	JMS I	IOACAL		/ UP ON SCREEN				/A031
	0			/					/A031
	PRBSTM			/ TEXT "PROBLEM:"			/A031
	0405			/ SCREEN ADDRESS			/A031
	INMBLK			/ ADDRESS OF TEXT			/A031
RESTQ,
/
	/JMS	DISBL 		/ RESET THE BOTTOM LINE			/D017
	JMS	DISBLF		/ RESET THE BOTTOM LINE AND CLEAR EVENT FLAG/A017
/
	JMP I	RESTS
/------------
 	PAGE

/
/	RESETS WILL RESET THE VALUES ON THE SCREEN THAT ARE PRESENT
/	MOST OF THE TIME
/
RESETS,	XX
	CLA			/ THIS WILL UPDATE THE SCREEN WITH THE INFO NEEDED
	TAD	ERRFLG 		/ ++++
	DCA	ERRFL2 		/ SET THE FLAG THAT IS USED TO DISPLAY AN ERROR
	TAD	ERRFLG 		/ SEE IF THE OPTIONS WILL CHANGE
	SPA 			/ ++++
	 JMP	RESETW
	SZA CLA 		/ ++++
	 JMS	STPTRN
	JMP	RESETA		/ STOP ANY TRANSFER AND RESET THE OPTIONS

RESETW,	CIA 			/ FIRST MAKE POSITIVE
	DCA	ERRFL2
	DCA	INIFLG 		/ CLEAR THE INIT FLAG
	TAD	AXFLG 		/ IF AX DISPLAY THE MESSAGE BUT DONT CHANGE OPTIONS
	SNA CLA 		/ ++++
	 DCA	OPTFLG 		/ CLEAR THE OPTIONS
RESETA,	TAD	INIFLG
	SPA SNA CLA 		/ ++++
	 JMP	CHKST3
	TAD	(7)
	JMP	CHKST4

CHKST3,	TAD	(5)
	TAD	SENDFL
CHKST4,	CDFMNU
	DCA I	(MUBUF+MNTMP1) 	/ SET TEMP 1 TO STATE
	CDFMYF
	TAD	OPTFLG 		/ SET OPTIONS INTO TEMP 2
	TAD	(OPTTBL) 	/ GET THE POSITION FOR THE OPTION LINE ON SCREEN
	DCA	T1
	TAD I	T1
	CDFMNU
	DCA I	(MUBUF+MNTMP2)
	TAD	DOCSIZ 		/ LET THE MENU DISPLAY THE APROXIMATE VALUE
	DCA I	(MUBUF+MNTMP3)
	TAD	DOCTMP 		/ GIVE IT THE VALUE TO DISPLAY
	DCA I	(MUBUF+MNTMP4)
	TAD	DOCNCT 		/ DISPLAY THE NUMBER OF DOCUMENTS TRANSFERRED IN AX
	DCA I	(MUBUF+MNTMP5)
	CDFMYF
	CIFMNU
	JMS I	MNUCAL
		DLMA10
RESETY,	JMS	RESTS 		/ PUT UP THE MESSAGES THAT ARE SPECIAL
	JMP I	RESETS 		/ GO TO WHERE IT WAS CALLED FROM

/ The following 2 variables (DOCSIZ, DOCTMP) MUST BE ON THIS PAGE
DOCSIZ,	0
DOCTMP,	0
ERRFL2,	0
/
OPTTBL,	0
	2100
	1700
	1500
	1300

/
/  WTMARG - WAIT FOR AN AGRUMENT TO BE TYPED FOR THE MESSAGE ROUTINE TO SEND IT.
/
WTMARG,	XX
	CDFMNU			/ Map menu field.
	DCA I	(MUBUF+MNTMP4)	/ save switch. set to 0 for MESSAGE/BYE
				/ Set to 1 for "has no meaning" error msg.
	CDFMYF			/ Back to our field.
	JMS	DOMENU		/ Display the menu prompting for a MESSAGE.
		DLMA14		/  ...
	 JMP	KBDL5 		/ GOLD MENU
	JMP I	WTMARG 		/ GOT SOMETHING THAT IT LIKES

/
/	THE TIME OUT ROUTINE
/
TIMEOU,	AC0002			/ Set error flag to -2.
/
/	THIS IS THE ERROR RECOVERY IF THERE IS AN ERROR ENCOUNTERED IN
/	READ DOCUMENT ROUTINE
/
DSKERR,	TAD	(-4)		/ Set error flag to -4 for disk error.
	DCA	ERRFLG		/ Set to -2 for TIME-OUT, -4 for DISK ERROR.
/
/	TELLS THE MAIN PROGRAM TO DISPLAY THE SCREEN AND ALSO THAT THE STATUS IS
/	NOW ERROR FOUND AND WAITING
/
HSTRST,	TAD	(-4)
	DCA	SENDFL
	AC7777 			/ ++++
	DCA	CNGSCF 		/ RESET THE ENTIRE SCREEN
	JMP	HSTJWT

SNDPPK,	MQL
	TAD	(DOCNBF) 	/ SET THE INPUT COMING FROM THIS BUFFER INSTEAD
	DCA	TOKOFF 		/ THE USUAL INPUT BUFFER INBUFA
	MQA
SNDPP2,	TAD	(PMTTBL-1)
	DCA	T1
	TAD I	T1
	JMP	MSGSET

PMTTBL,	TYPPAN
	TYPRCV
	TYPSND

/
/	HLTEST - USED TO CHECK THE HALT FLAG TO BE SET DOES A NON-SKIP RETURN IF NOT
/
HLTEST,	XX 			/ TAKES NON-SKIP RETURN IF HALT FLAG SET
	CLA
	CIFSYS 			/ ++++
	JWAIT
	CDFSYS 			/ ++++
	TAD I	HLTFLG 		/ ++++
	CDFMYF
	SNA CLA 		/ ++++
	 ISZ	HLTEST
	JMP I	HLTEST

/
/	GETNXT - GETS THE NEXT PACKET TO SEND IN A RETRANSMIT
/
GETNXT,	XX
	TAD I	GTNXPT
	SNA 			/ ++++
	 JMP	GETNXD
	ISZ	GTNXPT
	ISZ	GETNXT
GETNXD,	JMP I	GETNXT

GTNXPT,	0

CPYTIM,	XX			/ Routine to copy the DATE & TIME string
	CDFMNU			/ Get address of DATE&TIME string in menu field.
	TAD I	(DATESP)	/  ...
	CDFMYF			/ Back to our field.
	DCA	CPYTM1		/ Save for DXCOPY.
	JMS	DXCOPY		/ Copy ASCIZ string
		CDFMNU		/  from menu field
CPYTM1,		XX		/   from here,
		CDFMYF		/    to our field
		DATSTR		/     to here.
	JMP I	CPYTIM		/ Return to caller when done.
/----------
PAGE

/
/	THE HOST PROGRAM , THIS WILL HANDLE THE DATA FLOW FROM THE
/	HOST TO THE BUFFER AND FROM THE BUFFER TO THE HOST
/
HSFLAG,	0 			/ HSTPRG USES IT TO TELL THE MAINJOB THAT IT
				/ RECEIVED THE SPFLAG CHANGE
HSTEXT,	CIFSYS 			/ ++++
	JEXIT
HSTJWT,	JMS	CLAINF 		/ WAIT BUT FIRST CLEAR THE INTFLG WHICH
				/ LETS THE OTHER PROGRAM SEE WHAT HAS CHANGED
				/ AND RETURNS BACK
HSTWAT,	CIFSYS 			/ ++++
	JWAIT
HSTPRG,	CLA
	TAD	SPFLAG 		/ SEE IF ANYTHING IS TO BE DONE
				/ IF SPFLAG IS NOT ZERO DO NOTHING
	DCA	HSFLAG 		/ SET THE HOST FLAG TO THE SPFLAG
				/ TO SHOW THE MAIN PROGRAM THATWE SAW IT
	TAD	HSFLAG
	SPA 			/ ++++
	 JMP	HSTEXT
	SZA CLA 		/ ++++
	 JMP	HSTWAT 		/ IF NOT ZERO THEN WAIT
	TAD	INIFL2 		/ SEE IF THE LOW LEVEL HAS INITED
	SPA SNA CLA 		/ ++++
	 JMP	HSTWAT 		/ NO
	TAD	INIFL3 		/ NOW SEE OF THE HIGH LEVEL HAS
	SNA CLA 		/ ++++
	 JMP	RSTPRG
	TAD	INIFLG 		/ IF TRANSFER NOT IN PROGRESS SEE IF ANY TO REC
	SPA 			/ ++++
	 JMP	HSTPR2
	SNA CLA 		/ ++++
	 JMP	HSTCKL
	TAD	SENDFL 		/ CHECK MODE
	SMA SZA 		/ ++++
	 JMP	SENDMD 		/ IN SEND MODE
	SZA
HSTCKL,	 AC0001 			/ IN SOME SORT OF A WAIT STATE
	SNA 			/ ++++
	 TAD	DLY6X 	 	/ IN RECEIVE				/M020
HSTRC2,	JMS	WAITDT 		/ WAIT FOR SOMETHING TO BE SENT
	JMP	CWTAGN

HOSREC,	TAD	(HSTTBL-140) 	/ USE THE TYPE FOR AN INDEX
	DCA	T1 		/ TO GET THE ROUTINE TO JUMP TO
	TAD I	T1
	DCA	T1
	JMP I	T1

HOSRBF,	TAD	HSTRAD 		/ RELEASE THE PACKET BUFFER ITS NOT NEEDED
	JMS	PUTBUF 		/ ++++
		FREEPT
	JMP	HSTPRG

HSTPR2,	CLA
	TAD	SENDFL 		/ IF SEND MODE AND INIFLG IS NEGATIVE SEND FIRST PACKET
	SNA SPA CLA 		/ ++++
	 JMP	HSTPR3
	JMS	SETUPW 		/ SET UP THE FIRST PACKET OF THE DOCUMENT
	AC7777			/ TELL NORTN TO USE CANNED MESSAGE	/A031
	DCA	NOFLAG		/ "NOT ENOUGH ROOM ON DISKETTE"		/A031
	JMS	WTFRYN 		/ WAIT FOR A RESPONSE
	 JMP	NORTN		/ RECEIVED THE "NO" PACKET		/A031
/D031	 JMP	SNDNO2 		/ NO
	JMP	SNDYE2

HSTPR3,	AC0001 			/ ++++
	DCA	INIFLG
	JMP	HSTJWT
/
/	THIS HANDLES THE NO PACKET IT IS JUST LIKE A NORMAL MESSAGE ONLY A
/	FEW DIFFERENCES THAT IS WHY IT IS HERE THE CODE FALLS TO THE MESSAGE ROTUINE
/
NORTN,
	JMS	CLDOC 		/ CLOSE THE DOCUMENT
/
	AC7777 			/ ++++
	DCA	CNGSCF 		/ SET SCREEN FLAG TO CHANGE EVERYTHING
	DCA	INIFLG 		/ CLEAR THE INIT FLAG TO DKILL A TRNAFER IS STARTRD
/
	TAD	OPTREC 		/ RESET THE OPTIONS
	DCA	OPTFLG
/				/ CK FOR TEXT IN THE "NO" PACKET AND DISPLAY
				/ IF PRESENT				/A031
	JMS	FILMBF		/ FILL MESSAGE BUFFER			/A031
	TAD	INMBLK		/ LOOK FOR A CHARACTER			/A031
	SZA			/ SKIP IF EMPTY				/A031
	JMP	PROBMS		/ A MESSAGE IS PRESENT - DISPLAY	/A031
	AC0001			/ CK FOR SPECIAL CASES OF "NO" PACKET	/A031
	TAD	NOFLAG		/ a) RESPONSE TO "SENT" PACKET		/A031
	SNA			/ b) RESPONSE TO "SOD" PACKET		/A031
	JMP	SNDNO2		/ DISKETTE FULL MESSAGE			/A031
	SPA			/					/A031
	JMP	RECNO1		/ UNABLE TO CREATE MESSAGE		/A031
	JMP	MESRTN		/ CONTINUE TO MESSAGE ROUTINE		/A031

/	TEXT IN THE "NO" PACKET						/A031

PROBMS,	DCA	PRBSFG		/ SIGNAL - TEXT IN THE "NO" PACKET	/A031
	JMP	HSTJWT


/
/	HSTTBL- THE TABLE OF THE ROUTINES THAT ARE CALLED DEPENDING ON THE
/	PACKET TYPE.  THE VALUE OF THE PACKET TYPE BYTE IS USED AS AN INDEX TO THE TABLE
/
	RESERV=HOSRBF 	/ IF NOT WANTED OR UNDEFINED

HSTTBL,	YESRTN			/ 140 - TYPYES
	MODRTN			/ 141 - TYPMOD
	MESRTN			/ 142 - TYPMES
	BYERTN			/ 143 - TYPBYE
	SODRTN			/ 144 - TYPSOD
	DTARTN			/ 145 - TYPDTA
	EOFRTN			/ 146 - TYPEOF
	HITRTN			/ 147 - TYPHIT
	RESERV 			/ 150
	SNDRTN			/ 151 - TYPSND
	RCVRTN			/ 152 - TYPRCV
	OPTRTN			/ 153 - TYPOPT
	RESERV 			/ 154
	RESERV 			/ 155
	RESERV 			/ 156
	RESERV 			/ 157
	RESERV 			/ 160
	RESERV 			/ 161
	RESERV 			/ 162
	RESERV 			/ 163
	NORTN			/ 164 - TYPNO
	RESERV 			/ 165
	RESERV 			/ 166
	RESERV 			/ 167
	RESERV 			/ 170
	RESERV 			/ 171
	RESERV 			/ 172
	RESERV 			/ 173
	RESERV 			/ 174
	PMTRTN			/ 175 - TYPPMT
	PNERTN			/ 176 - TYPPNE
/-----------
	PAGE

/
/	CHKSM1 - DOES A TOTALING JOB FOR CHKSUM
/
CHKSM1,	XX
	DCA	T1
	DCA	T2 		/ CLEAR THE TOTALER
CHKSUJ,	TAD I	T1
	SNA 			/ ++++
	JMP I	CHKSM1 		/ 0= DONE
	TAD	T2
	DCA	T2
	ISZ	T1
	JMP	CHKSUJ

/
/	SENDMD - ROUTINE THAT WILL TAKE CARE OF SENDING A TEXT PACKET
/
SENDMD,	JMS	GETBUF 		/ ++++
		RECPT		/ SEE IF THE BUFFER IS EMPTY
	 JMP	SENDCB 		/ YES
	JMS	STOBUF 		/ STORE THE VALUES
	JMP	HOSREC

SENDCR,	TAD	EOF 		/ SEE IF THE LAST PACKET HAS BEEN QUEUED
	SNA CLA 		/ ++++
	 JMP	SENDCT
	TAD	DSKBA2 		/ CHECK FOR EVERYTHING SENT
	TAD	DSKBA4
	SZA CLA 		/ ++++
	 JMP	HSTWAT 		/ IF NOT WAIT
	JMP	DSKTL2 		/ IF SO THEN QUIT

SENDCT,	TAD	(-BUFSIZ) 	/ SET THE CHARACTER COUNTER
	DCA	SENTMP
	JMS	DSKBUF 		/ SEE IF THERE IS AN AVAILABLE BUFFER
	 JMP	HSTWAT 		/ NO
	DCA	SENT2
	TAD	SENT2 		/ STORE IN X1
	DCA	X1
	DCA I	X1 		/ CLEAR THE STATUS WORD
	AC0003
	TAD	X1 		/ SET UP FOR THE INSERT CHARACTERS
	DCA	SENT3
	AC7777
	TAD	SENT3 		/ SAVE THE ADDRESS OF THE FLAG CHARACTER
	DCA	SENT4
SENDJ1,	TAD	INIFLG 		/ IF DOCUMENT ABORTED STOP SENDING
	SNA CLA 		/ ++++
	 JMP	HSTPRG
	CIFBUF 			/ ++++
	JMS I	REDSXA 		/ GET NEXT 7-BIT CHARACTER
	SPA SNA			/ Skip if valid char returned.
	 JMP	ENDDOC		/  ...
	DCA I	SENT3
	ISZ	SENT3 		/ UPDATE THE COUNTER
	ISZ	SENTMP 		/ INCREMENT THE CHARACTER COUNTER
	 JMP	SENDJ1
	DCA I	SENT3
	TAD	(TYPDTA)
	JMP	SENDJ3 		/ CONTINUE

ENDDOC,	SZA CLA			/ Skip if END-OF-FILE detected.
	 JMP	DSKERR		/ Report DISK ERROR.
	DCA I	SENT3
	ISZ	EOF 		/ SET LAST PACKET FLAG
	TAD	(TYPEOF)
SENDJ3,	DCA I	SENT4
	TAD	SENT2
	JMS	PUTBUF 		/ ++++
		SENDPT
	JMP	HSTPRG

/
/	SNDNAK - SENDS A NAK TO THE OTHER SYSTEM
/
SNDNAK,	TAD	DXNONK 		/ SEE IF A NAK CAN BE SENT
	SZA CLA 		/ ++++
	 JMP	DXIHJB
	JMS	UPDTER 		/ UPDATE THE ERROR COUNTER
	TAD	(NAK)
	ISZ	DXNONK 		/ SET FLAG SO CANNOT SEND ANOTHER NAK
/	THIS WILL SEND THE CONTENTS IN THE AC AS A COMMAND		/A017
DXIBDY,	DCA	CMDFLG							/A017
	JMS	CLAINF		/ CLEAR THE EVENT FLAG			/A017
	JMP	DXIHJB		/ DONE CONTINUE				/A017

/
/	DXOCPK - CREATE THE COMMAND PACKET TO SEND
/
DXOCPK,	XX
	DCA	CMDBUF 		/ PUT THE TYPE ON THE PACKET
	DCA	CMDFLG 		/ CLEAR THE FLAG
	TAD	(CMDBUF) 	/ SET THE BUFFER ADDRESS TO FILL
	DCA	X1
	TAD	ISEQNO 		/ PUT THE SEQUENCE NUMBER IN
	AND	P77
	JMS	ADOFST
	DCA I	X1
/
/ IF THE PACKET IS AN INIT OR INIT-ACK THEN THE BODY OF THE PACKET IS
/
/ TYPE VERSION NULCNT
/
/ TYPE TELLS THE TYPE OF PROTOCOL.  THIS IS FOR FUTURE USE. RIGHT
/ NOW IT IS ALWAYS 40.  COULD BE USED TO TELL THE HOST THE
/ DIFFERENCE BETWEEN A WS78 AND A WT78 ON THE SAME LINE.
/
/ VERSION IS THE VERSION OF THE PROTOCOL SO THE TWO SYSTEMS ARE
/ ABLE TO ALLOW FOR THE DIFFERENCES OR JUST TELL THE USER THAT
/ THEY CANNOT EVER CONNECT BECAUSE OF THE DIFFERENT VERSIONS.
/
/ NULCNT IS THE NUMBER OF NULLS THE OTHER SYSTEM WANTS SENT TO IT
/ AFTER THE CR THAT TERMINATES ALL PACKETS.  THE FORMAT IS 40 OCTAL
/ PLUS THE NUMBER DESIRED.
/
	TAD	CMDBUF 		/ SEE IF THE COMMAND IS A INIT OF SOME KIND
	TAD	(-INIT) 	/ IF SO SEND THE TYPE AND VERSION OF THE PROTOCOL
	SZA 			/ ++++
	TAD	(INIT-INIACK) 	/ ELSE JUST ADD THE ZERO TERMINATOR
	SZA CLA 		/ ++++
	JMP	DXOSTR
	TAD	(TYPE)
	DCA I	X1
	TAD	(VERSIO)
	DCA I	X1
	TAD	(ZERNUL) 	/ THIS SOFTWARE DOESNT REALLY NEED NULLS
	DCA I	X1
DXOSTR,	DCA I	X1
	TAD	(CMDBUF) 	/ SET THE CHECK SUM
	JMS	CHKSUM
	JMP I	DXOCPK

TRNCN6,	AC7777			/ SET FLAG TO LOCK OUT HOST JOB		/A039
	DCA	DISTMP		/					/A039
	JMP	TRNCN7		/ CONTINUE				/A039

/----------
	PAGE

/
/	DSKBUF - GETS THE NEXT BUFFER FREE FOR TEXT
/	IF NONE ARE FREE IT GET TWO
/
DSKBUF,	XX
	CLA
	TAD	RESBFS 		/ SEE IF 2 HAVE BEEN ALOCATED
	SZA CLA 		/ ++++
	 JMP	DSKBU2
	JMS	GETFRE 		/ GET A FREE BUFFER
	 JMP	HSTWAT 		/ ERROR RETURN SPFLAG SET
	DCA	DSKBA1
	DCA	DSKBA2 		/ CLEAR THE WRITE FLAG
	JMS	GETFRE
	 JMP	HSTWAT 		/ ERROR RETURN SPFLAG SET
	DCA	DSKBA3 		/ STORE ADDRESS
	DCA	DSKBA4 		/ CLEAR THE FULL FLAG
	ISZ	RESBFS
DSKBU2,	TAD	DSKBA2
	SZA CLA 		/ ++++
	 JMP	DSKBU3 		/ NOT BEING SENT
	AC0001 			/ ++++
	DCA	DSKBA2
	TAD	DSKBA1
	ISZ	DSKBUF
	JMP I	DSKBUF

DSKBU3,	TAD	DSKBA4
	SZA CLA 		/ ++++
	 JMP I	DSKBUF
	AC0001 			/ ++++
	DCA	DSKBA4
	ISZ	DSKBUF
	TAD	DSKBA3
	JMP I	DSKBUF

RESBFS,	0
/
/	ORDER DEPENDENT
/
DSKBA1,	0
DSKBA2,	0
DSKBA3,	0
DSKBA4,	0

/
/	GETFRE - GET A FREE BUFFER
/	WILL WAIT CHECKING FOR SPFLAG SET AND RETURN IF SO.
/	ON ENTRY THE AC VALUE DOESNT MATTER ON RETURN IT IS THE ADDRESS OF
/	THE BUFFER.
/
/	CALL
/	JMS	GETFRE
/	ERROR RETURN
/	OK
/
GETFRE,	XX
	JMP	GETFR1 		/ JUMP TO TRY TO GET A BUFFER

GETFR2,	JMS	INIWAT 		/ CHECK SPFLAG
	 JMP I	GETFRE 		/ ITS SET RETURN
GETFR1,	JMS	GETBUF 		/ ++++
		FREEPT
	 JMP	GETFR2
	ISZ	GETFRE 		/ GOT A BUFFER RETURN
	JMP I	GETFRE

/
/	SENDCB - FREES THE PACKETS THAT ARE SENT CORRECTLY AND ARE DATA
/
SENDCB,	TAD	DSKBA2 		/ SEE IF THE FIRST IS TO SEND
	SNA CLA 		/ ++++
	 JMP	SENDC2
	TAD	DSKBA1
	IAC
	DCA	T1 		/ SEE IFTHE BUFFER IS BEING SENT
	TAD I	T1
	SPA 			/ ++++
	 JMP	TIMEOU 		/ SEE IF -1 THEN COULDNT SEND
	SNA CLA 		/ ++++
	 JMP	SENDC2
	DCA	DSKBA2
	JMS	BLKNM 		/ UPDATE THE PACKET COUNTER
SENDC2,	TAD	DSKBA4
	SNA CLA 		/ ++++
	 JMP	SENDCR
	TAD	DSKBA3 		/ SEE IF THE OTHER IS FULL
	IAC
	DCA	T1
	TAD I	T1
	SPA 			/ ++++
	 JMP	TIMEOU
	SNA CLA 		/ ++++
	 JMP	SENDCR
	DCA	DSKBA4
	JMS	BLKNM 		/ UPDATE THE PACKET COUNTER
	JMP	SENDCR

/
/	DTARTN - WILL RECEIVE A PACKET OF TEXT
/
EOFRTN,	ISZ	EOF 		/ THE ONLY DIFFERENCE BETWEEN ANY OF THE TEXT AND THE LAST
				/ IS SETTING THE LAST PACKET FLAG
DTARTN,	AC0003 			/ GET THE STARTING ADDRESS
	TAD	HSTRAD
	DCA	DTARTM 		/ SAVE IN TEMP
	JMS	BLKNM 		/ INCREMENT THE BLOCK COUNT
	CLA
DXRCLP,
/D040	TAD	INIFLG 		/ CALLED FROM DTARTN WHICH RECEIVES A DOCUMENT
/D040	SNA CLA 		/ ++++
/D040	 JMP	HOSRBF 		/ IF TRANSFER TERMINATED THEN THROW AWAY PACKET
	ISZ	DTARTM
	TAD I	DTARTM 		/ STORE THE CHARACTER FIRST GET IT
	SNA 			/ ++++
	 JMP	DTARTJ 		/ RELEASE THE BUFFER
	CIFBUF 			/ ++++
	JMS I	WRISXA 		/ WRITE CHARACTER
	JMP	DXRCLP

DTARTJ,	TAD	HSTRAD 		/ RELEASE THE BUFFER
	JMS	PUTBUF 		/ ++++
		FREEPT
	JMP	DSKTLB 		/ SEE IF IT IS THE LAST

/
/	BYERTN HANDLES THE BYE MESSAGE THAT CAN BE SENT FROM THE OTHER
/	SYSTEM TO TERMINATE THE TRANSFER.IT ACTS LIKE A TIME OUT
/
BYERTN,	JMS	FILMBF 		/ FILL THE MESSAGE BUFFER WITH THE TEXT SENT
	AC7777 			/ ++++
	DCA	CNGSCF
	AC0001 			/ ++++
	DCA	BYSETF 		/ SET THE STOP EVERYTHING FLAG
	JMS	STPTRN 		/ STOP ANY TRANSFER AND RESET OPTIONS
	JMP	HSTJWT 		/ SIMILAR TO A JWAIT INSTEAD OF A WAIT

/
/	STPRTN - STOP A TRANSFER IF ANY AND SET THE OPTIONS BACK TO THOSE RECEIVED
/
STPTRN,	XX
	CLA
	JMS	SETOPT							/A017
	TAD	INIFLG 		/ IF TRANSFER IN PROGRESS PUT INTO ABORT STATE
	SNA CLA 		/ ++++
	JMP I	STPTRN
	TAD	(-5) 		/ ++++
	DCA	SENDFL
	DCA	INIFLG
	JMP I	STPTRN


SETOPT,	XX								/A017
	TAD	OPTREC							/A017
	DCA	OPTFLG							/A017
	JMP I	SETOPT							/A017

OPTREC,	0000			/					/M023

SNDQT1,	AC7777		/  CLEAR OUTPUT BUFFER				/A041
	JMS	HOSTOU	/						/A041
	CLA		/ BUFFER FULL RETURN				/A041
	AC0003		/ GET READY FOR TEST				/A041
	JMP	SNDQT2	/ CONTINUE 					/A041

/-----------
	PAGE


/
/	OPTRTN - HANDLES THE OPTION PACKET THAT IS SENT FROM THE OTHER SYSTEM
/	GIVING THE SYSTEM ITS OPTIONS
/
OPTRTN,
	TAD	AXFLG 		/ IF IN AX DONT LET THE OPTIONS CHANGE
	SZA CLA 		/ ++++
	JMP	HOSRBF
	AC0004 			/ GET THE ONE CHARACTER THAT WILL BE THE OPTION
	TAD	HSTRAD
	DCA	T1
	TAD I	T1
/
	TAD	(-40) 		/ SET THE INTERNAL FLAG
	DCA	OPTREC
/
/	TAD	OPTREC 							/D017
/	DCA	OPTFLG 							/D017
	JMS	SETOPT							/A017
/
	AC7777 			/ ++++
	DCA	CNGSCF 		/ RESETTHE SCREEN
	JMS	CLAINF
	JMP	HOSRBF 		/ RELEASE THE BUFFER


/
/	THIS HANDLES THE INCOMING MESSAGES FOR BOTH THE SENDER AND THE
/
				/ THE RECEIVER
/
MESRTN,
	JMS	FILMBF 		/ FILL THE INPUT MESSAGE BUFFER WITH THE
				/ MESSAGE SENT . NO FLAGS ARE SET BECAUSE
				/ NOTHING AT THIS POINT SHOULD BE GOING ON
				/ THAT WOULD AFFECT THE ACTION
/
	AC0001 			/ ++++
	DCA	INMSFG 		/ SET THE MESSAGE FLAG SO WHEN
				/ THE SRCEEN IS UPDATED THE MESSAGE WILL
				/ APPEAR
	TAD	CNGSCF 		/ SET THE FLAG TO DISPLAY THE SCREEN MESSAGE
	SNA CLA 		/ ++++
	ISZ	CNGSCF 		/ IF NOT ALREADY SET
/
	JMP	HSTJWT
/
INMSFG,
	0

RCVRTN,	TAD	AXFLG 		/ IS IN AX THEN HAVE TO TREAT SPECIAL
	SZA CLA 		/ ++++
	JMP	AXRRTN
	TAD	SENDFL 		/ IF SET TO NOT WAIT THEN JUST INIT DONT SET PROMPT
	SMA CLA 		/ ++++
	JMP	PMTOK
	JMP	PMT002

SNDRTN,	TAD	AXFLG
	SZA CLA 		/ ++++
	JMP	AXSRTN
	TAD	SENDFL 		/ IF SET DONT SET FOR PROMPT
	SMA CLA 		/ ++++
	JMP	PMTOK
	JMP	PMT003

PNERTN,	TAD	(-5)		/ Set PMTFLG to -1 for PROMPT NO ECHO.	/M028
MODRTN,	IAC			/ Set PMTFLG to 4 for MODIFY prompt.
PMT003,	IAC			/ Set PMTFLG to 3 for SEND.
PMT002,	IAC			/ Set PMTFLG to 2 for RECEIVE.
PMTRTN,	IAC			/ set PMTFLG to 1 for PROMPT.
PMTRT2,	DCA	PMTFLG
	JMS	FIL2BF 		/ FILL THE BUFFER
PMTRT3,	JMP	HSTJWT 		/ CLEAR THE EVENT FLAG AND WAIT THIS ALOWS QUICK RESPONSE
PMTOK,	AC7777 			/ ++++
	DCA	INIFLG 		/ SAY START SENDING DOCUMENT
	JMP	HOSRBF 		/ RELEASE THE BUFFER

PMTFLG,	0

/
/	FIL2BF - FILLS THE SECOND MESSAGE BUFFER
/
FIL2BF,	XX
	TAD	(DOCNBF)
	JMS	FILIBF
	JMP I	FIL2BF


/
/	FILLS THE MESSAGE BUFFER WHOSE ADDRESS IS IN THE AC
/
FILIBF,	XX
	DCA	FILIB2 		/ STORE THE ADDRESS TO COPY INTO
	AC0004 			/ GET THE STARTING ADDRESS OF THE STRING TO COPY
	TAD	HSTRAD
	DCA	FILIB1
	JMS	DXCOPY
		CDFMYF
FILIB1,		XX
		CDFMYF
FILIB2,		XX
	TAD	HSTRAD
	JMS	PUTBUF 		/ ++++
		FREEPT		/ FREE IT
	JMP I	FILIBF

/
/	THE ROUTINES USED FOR THE COPY TO GET THE HOST SPECIFIED
/
/	OUTPUT
/
HOSTOU,	XX
	DCA	HOSTOT 		/ ++++
	TAD	HOSTOT 		/ SAVE THE CARACTER FOR HOSTO2
	CIFSYS 			/ ++++
	HS2OU
	 JMP I	HOSTOU
	ISZ	HOSTOU
	JMS	HOSTO2 		/ CHECK FOR A CR AND IF SO SEND NULLS (PAD)
	JMP I	HOSTOU

HOSTOT,	0

/
/	THE INPUT ROUTINE
/
HOSTIN,	XX
HOSTIL,	CIFSYS 			/ ++++
	HS2IN
	 JMP I	HOSTIN
	AND	P177 		/ GET THE 7 -BITS
	SNA 			/ ++++
	 JMP	HOSTIL 		/ SKIP A NULL
	TAD	(-RUBOUT) 	/ NOT ALLOW A RUBOUT
	SNA 			/ ++++
	 JMP	HOSTIL
	TAD	(RUBOUT-40) 	/ CHECK FOR A CONTROL CHARACTER
	SMA 			/ ++++
	 JMP	HOSTI2 		/ IF A CONTROL CHARACTER THEN CHECK FOR A CR
	TAD	(40-CR)
	SZA 			/ ++++
	 JMP	HOSTIL 		/ SKIP ALL BUT A CR
	TAD	(CR-40)
HOSTI2,	TAD	(40) 		/ RETURN THE CHARACTER FOUND
	ISZ	HOSTIN
	JMP I	HOSTIN

/
/	CLAINF - CLEAR THE EVENT FLAG IN THE SYSTEM. BY CLEARING THE FLAG
/	YOU TELL THE SYSTEM AN EVENT HAS HAPPENED.
/
CLAINF,	XX
	CLA
	CDFSYS 			/ ++++
	DCA I	(INTFLG) 	/ ++++
	CDFMYF
	JMP I	CLAINF
/
/	THIS ROUTINE IS USED THROUGHOUT THE MAIN JOB.  THE ROUTINE IS
/	USED TO SET THE TOKEN POINTER THAT IS THE POINTER TO THE INPUT BUFFER
/	TO THE BEGINNING
/
INITKF,	XX
	CLA
	TAD	(INBUFA) 	/ INITALIZE THE POINTER
	DCA	TOKOFF
	JMP I	INITKF
/------------
	PAGE

/
/	DISBER - DISPLAYS THE ERROR MESSAGE THAT THE INPUT WAS BAD
/
DISBER,	XX
	TAD	(TOKBUF+1)	/ Set token pointer to token buffer
	DCA	TOKOFF		/  (where the bad input is stored).
	AC0001			/ now call menu A14 to report the bad input.
	JMS	WTMARG		/  ...
	JMP I	DISBER		/ return to caller.

/
/	SETFLG - SETS ALL THE FLAGS NEEDED FOR EACH TRANSFER AND ALSO CLEARS THE
/	MESSAGE LINE.  THIS LINE IS CLEARED INCASE AN ERROR IS DISPLAYED
/
SETFLG,	XX
	JMS	SETFLT 		/ CLEAR FLAGS
	DCA	TRNERC		/ CLEAR THE ERROR COUNTER.		/A015
	JMS	CLAMSL 		/ CLEAR MESSAGE LINE
	JMP I	SETFLG


/
/	RECEIVES THE INITAL MESSAGE
/
SODRTN,
	TAD	SENDFL 		/ SEE IF A START OF DOCUMENT CAN BE ACCEPTED
	SZA CLA 		/ ++++
	JMP	HOSRBF
/
	JMS	FILMBF 		/ THIS WILL FILL THE INPUT MESSAGE BUFFER
				/ AND CHECK THE CHECK SUMS FOR IT
	CLA
	DCA	INMSFG 		/ CLEAR THE MESSAGE FLAG SO THE CONTENTS WILL NOT
				/ APPEAR ON THE SCREEN
/
	TAD	ISGBK1 		/ GET THE BLOCK COUNT
	JMS	SBOFST
	BSW
	DCA	T1 		/ SAVE THE FIRST HALF
	TAD	ISGBK2 		/ GET SECOND HALF
	JMS	SBOFST
	TAD	T1 		/ ADD IT TI THE OTHER HALF
	DCA	DOCSIZ
/
	TAD	DOCSIZ
	CIA 			/ AVAILABLE
/
	MQL 			/ SEE IF OVERWRITE OPTION IF SO ADD THE DOC SIZE
	TAD	DOCMOD 		/ IF -1 = OVERWRITE
	CLL RAL
	CLA MQA
	SNL 			/ ++++
	JMP	INIREJ
/
	CDFBUF 			/ SEE IF THERE IS ROOM ON THE DISKETTE FOR THE FILE
	TAD I	(SCHDR+5) 	/ SUBTRACT THE FILE SIZE BECAUSE OVERWRITE
INIREJ,
	CDFFIO	 		/					/M013
	TAD I	(SCFSPC) 	/ SUBTRACT THE AMOUNT LEFT ON THE DISK
/
	CDFMYF 			/ ACDF FOR THIS FIELD (MY FIELD)
/
	TAD	(-10) 		/ MAKE SURE THAT I WILL NOT OVERFLOW
/
	SPA SNA CLA 		/ ++++
	JMP	SENNO
/
/	THE YES ANSWER
/
	TAD	(TYPYES) 	/ SEND A YES
	DCA	ANSBUF
	TAD	(ANSBUF-1)
/
	JMS	INIBFS
	JMP	HSTPRG
	JMP	TIMEOU 		/ IF NEGATIVE RESTART
/
	JMS	STRPRT 		/ STORE THE RULER SETTINGS
SNDYE2,
	AC0001 			/ ++++
	DCA	INIFLG 		/ SET THE FLAG SO THE INITAL MESSAGE WILL
				/ SENT WHEN IT CAN IF IN SEND
/
	JMS	DISAPX 		/ CALCULATE THE  APPOXIMATE NO OF PACKETS
SNDYE4,				/ CALLED BY AXRRTN AND AXSRTN
	AC7777 			/ ++++
	DCA	CNGSCF 		/ REPAINT THE SCREEN
SNDYE3,
	JMP	HSTJWT 		/ CLEAR THE EVENT FLAG SO PROGRAM IS RETURNED TO QUICKER
/
/	THE YES ROUTINE USE FOR THE YES RESPONSE FROM AX ON A COMMAND PACKET
/
YESRTN,
	AC7777 			/ ++++
	DCA	INIFLG 		/ START THE ITRANSFER OF A DOCUMENT PROCESS
	JMP	SNDYE3
/
/	THE NO RESPONSE
/
SENNO,
	DCA	INIFLG 		/ CLEAR THE INIT FLAG
	TAD	(TYPNO)
	DCA	ANSBUF
/
	TAD	(ANSBUF-1)
	JMS	INIBFS 		/ SEND THE RESPONSE
	JMP	HSTPRG 		/ GOLD HALT
	JMP	TIMEOU 		/ IF NEGATIVE THEN RESTART
/
SNDNO2,
	AC0001 			/ ++++
	DCA	ERRFLG
	DCA	INIFLG
	JMP	SNDNO3		/ CLOSE DOCUMENT FIRST			/C031
ANSBUF,
	ZBLOCK 2

/
/	THIS WILL PUT THE ESTIMATE ON THE SCREEN
/
DISAPX,	XX
	CLA
	TAD	DOCSIZ 		/ TO SEE IF THE NUMBER OF BLOCKS EXCEED 200
	TAD	(-201)
	SMA CLA 		/ ++++
	 JMP	DISJMP 		/ IF SO JUMP
	TAD	DOCSIZ 		/ FIRST MULTIPLY BY 8
	JMP	DISAP2

DISJMP,	DCA	T1 		/ CLEAR THE COUNTER FOR THE DIVIDE BY 10
	TAD	DOCSIZ
	TAD	(5) 		/ ROUND BY ADDING 5 TO TOTAL BEFORE DEVIDING
DISLUP,	TAD	(-12) 		/ DEVIDE BY 10
	ISZ	T1 		/ INCREMENT THE COUNTER FOR EACH DEVIDE
	SMA 			/ ++++
	 JMP	DISLUP 		/ NOTE :THIS PROCESS ROUNDS UP
	AC7777 			/ THIS WILL GET THE RIGHT NUMBER FOR THE DIVIDE
	TAD	T1 		/ NOW MULTIPLY BY 8
DISAP2,	CLL RAL 		/ ++++
	CLL RAL 		/ ++++
	CLL RAL
	DCA	DOCTMP
	JMP I	DISAPX

/
/	THE UPDATING OF THE ERRORS ON THE SCREEN
/
UPDTER,	XX
	ISZ	TRNERC 		/ INCREMENT THE COUNTER
	TAD	CNGSCF 		/ IF NOT SET SET IT
	SNA CLA 		/ ++++
	 ISZ	CNGSCF
	JMP I	UPDTER

TRNERC,	0
/----------
	PAGE

/
/	WAITING FOR SOMETHING TO BE SENT (RECEIVER)
/
WAITDT,	XX
	DCA	DLYLIM
	JMP	WAITLP

WAITWT,	TAD	DLYLIM 		/ IF POSITIVE THEN RETURN DONT JWAIT
	SMA CLA 		/ ++++
	 JMP I	WAITDT
	CIFSYS 			/ ++++
	JWAIT
	JMS	GETTM
	SNA CLA 		/ ++++
	 JMP	WAITLP
	ISZ	DLYLIM
	 JMP	WAITLP
	JMP I	WAITDT

WAITLP,	TAD	SPFLAG 		/ SEE IF THE JOB SHOULD STOP
	SZA CLA 		/ ++++
	 JMP	HSTWAT
	JMS	GETBUF 		/ ++++
		RECPT
	 JMP	WAITWT
	JMS	STOBUF 		/ STORE THE ADDRESS IN HSTRAD
	ISZ	WAITDT
	JMP I	WAITDT

DLYLIM,	0

/
/	STOBUF - WILL STORE THE ADDRESS OF THE RECEIVED BUFFER IN HSTRAD
/
STOBUF,	XX
	DCA	HSTRAD
	AC0003
	TAD	HSTRAD
	DCA	T1
	TAD I	T1
	JMP I	STOBUF


/
/	UPDATE THE BLOCK COUNTER AND SET THE DISPLAY FLAG
/
BLKNM,
	XX
	CLA
	ISZ	BLKTMP 		/ THIS IS THE BLOCK COUNTER FOR THE -1000 TO 0 RANGE
	JMP	BLKN1 		/ IF THERE IS NO OVERFLOW THEN PROCEED
/
	DECIMAL
	TAD	(-1000) 	/ SET THE COUNTER ON OVERFLOW
	OCTAL
/
	DCA	BLKTMP
	ISZ	BLKOVR 		/ INCREMENT THE THOUSAND COUNTER
BLKN3,
	TAD	BLKTMP 		/ SET THE TEMP TO A DISPLAYABLE NUMBER FOR IOA
/
	DECIMAL
	TAD	(2000) 		/ 1000 FOR POSITIVE AND 1000 FOR THE ZEROS
	OCTAL
/
	JMP	BLKN4
BLKN1,
	TAD	BLKOVR 		/ SEE IF THE BLOCK COUNTER IS OVER 1000
	SZA CLA 		/ ++++
	JMP	BLKN3 		/ IF SO GO TO BLKN3
/
	DECIMAL
	TAD	(1000) 		/ GET THE REAL NUMBER TO DISPLAY
	OCTAL
/
	TAD	BLKTMP
BLKN4,
	DCA	BLKNUM
/
	TAD	CNGSCF 		/ SEE IF ALREADY SET IF NOT SET IT
	SNA CLA 		/ ++++
	ISZ	CNGSCF
/
	JMS	CLAINF
	JMP I	BLKNM 		/ RETURN
/
BLKNUM,
	0
BLKTMP,
	0
BLKOVR,
	0


/
/	UPDATE THE SCREEN FOR THE BLOCK COUNT
/
BLKNMD,
	XX
	CIFMNU
	JMS I	IOACAL
	0
	NUMDIS
	IFDEF ENGLSH < 1260 >
	IFDEF ITALIAN < 1276 >
	IFDEF DUTCH < 1265 > 	/ Keep messages from being clobbered by blk counts
	IFDEF V30NOR < 1260 >	/ cursor position for "inviato - ricevuto"
	IFDEF V30SWE < 1260 >	/ cursor position for "inviato - ricevuto"

	BLKNUM
/
	TAD	BLKOVR 		/ SEE IF THE BLOCK COUNT IS OVER 1000
	SNA CLA 		/ ++++
	JMP I	BLKNMD 		/ IF SO IOA WILL NOT HANDLE IT SO A NOTHER CALL
				/ HAS TO BE MADE TO WRITE OUT THE 1000 DIGIT
/
	CIFMNU
	JMS I	IOACAL
	0
	BLKDS2
	IFDEF ENGLSH < 1260 >
	IFDEF ITALIAN < 1276 >
	IFDEF DUTCH < 1265 > 	/ Keep messages from being clobbered by blk counts
	IFDEF V30NOR < 1260 >
	IFDEF V30SWE < 1260 >
	BLKOVR
/
	JMP I	BLKNMD

/
/	GET THE TIME CHANGE USING THE SYSTEMS CLOCK
/	IT RETURNS A 1 IF A SECOND WENT BY AND A 0 IF NO CHANGE
/
GETTM,	XX
	JMS	GETCLK 		/ SEE IF THE TIME CHANGED
	TAD	TMPTME 		/ COMPARE TO SEE IF THE CLOCK CHANGED
	SNA 			/ ++++
	 JMP I	GETTM 		/ NO CHANGE
	CIA 			/ ++++
	TAD	TMPTME 		/ IF CHANGE STORE THE NEW ONE
	DCA	TMPTME
	AC0001
	JMP I	GETTM

TMPTME,	0
/
/	THE TIME ROUTINE FOR THE LINE
/
GETTM2,	XX
	JMS	GETCLK
	TAD	TMPTM2 		/ CHECK FOR A CHANGE IN THE TEMP
	SNA 			/ ++++
	 JMP I	GETTM2
	CIA 			/ ++++
	TAD	TMPTM2 		/ STORE THE DIFFERENT VALUE IF THERE IS ANY
	DCA	TMPTM2
	AC0001
	JMP I	GETTM2

TMPTM2,	0

GETCLK,	XX
	CLA
	CDFSYS
	TAD I	(CLOCK+2) 	/ ++++
	CIA
	CDFMYF 			/ ACDF FOR THIS FIELD (MY FIELD)
	JMP I	GETCLK

SNDNO3,	JMS	CLDOC		/ CLOSE DOCUMENT			/A031
	JMP	HSTRST		/ NOW RESTART				/A031

/
/	KBOUT - OUTPUT A CHARACTER TO THE SCREEN
/
KBOUT,	XX
	JMP	KBOUL

KBOUW,	CIF 0 			/ ++++
	JWAIT
KBOUL,	CLA
	TAD I	KBOUT		/ Get character to output.
	AND	P177		/ Isolate the character bits.
	CIFSYS 			/ ++++
	TTYOU
	 JMP	KBOUW
	TAD I	KBOUT		/ Get character just output.
	ISZ	KBOUT		/ Bump to return/next character.
	SPA CLA			/ Skip if we're done.
	 JMP	KBOUL		/ Jmp if there's another one.
	JMP I	KBOUT		/ Return to caller.
/------------
	PAGE


CWTAGN,
	CLA
	TAD	INIFLG 		/ IF A TRANSFER IS IN PROGRESS
	SPA SNA CLA 		/ ++++
	JMP	HSTWAT
	TAD	SENDFL 		/ AND IN RECEIVE MODE THEN AN ERROR
	SZA CLA 		/ ++++
	JMP	HSTWAT
	JMP	TIMEOU

/
/	THIS CHECKS FOR END OF FILE ENCOUNTERED. IT BELONGS ON THE LAST
/	PAGE WITH DSKPRG BUT DOESNT FIT
/
DSKTLB,	CLA
	TAD	EOF 		/ SEE IF LAST PACKET
	SNA CLA 		/ ++++
	 JMP	HSTPRG
	JMS	CLDOC 		/ CLOSE THE DOCUMENT IF ANY OPEN	/M026
	TAD	AXFLG 		/ SEE IF AX MODE
	SNA CLA 		/ ++++
	 JMP	DSKTL2
	CIFBUF
	JMS I	AXDONA
DSKTL2,	AC7775 			/ ++++
	DCA	SENDFL 		/ SET TO DONE
	JMS	SETOPT		/ Reset the options to what they were before.
	AC7777 			/ ++++
	DCA	CNGSCF 		/ SET THE RESET SCREEN FLAG
	TAD	AXFLG 		/ IF IN AX MODE INCREMENT THE COUNTER FOR NUMBER
				/ OF DOCUMENTS PROCESSED.
	SZA CLA 		/ ++++
	 ISZ	DOCNCT
	DCA	INIFLG 		/ CLEAR THE TRANSFER FLAG
	JMP	HSTJWT 		/ WAIT FOR RESTART


/
/	DXOHJB - THE OUTPUT ROUTINE TO THE HOST
/
DXOHEX,
/D041	JMS	SNDQIT 		/ BEFORE DYING SEND A QUIT TO TELL THE OTHER SIDE
/D041				/ WHATS GOING ON HAS NO EFFECT IF AX
	JMP	SNDQT1		/ SEND QUIT PACKET			/A041
DXOSQR,				/ RETURNS HERE				/A041
	AC7777 			/ ++++
	DCA	DXOFLG 		/ SET TO NEGATIVE A SIGN THAT EXITED
	CIFSYS 			/ ++++
	JEXIT
DXOHWT,
	CIFSYS 			/ ++++
	JWAIT
DXOHJB,
	CLA
	TAD	SPFLAG 		/ SEE IF IT IS TIME TO STOP
	SPA CLA 		/ ++++
	JMP	DXOHEX
	TAD	CMDFLG 		/ SEE IF THERE IS A COMMAND TO OUTPUT
	SNA 			/ ++++
	JMP	DXOHJ1
/
	JMS	DXOCPK 		/ SET UP THE COMMAND PACKET AC = 0 WHEN CALL DXOCPK
/
	TAD	(CMDBUF)
	JMS	SNDPCK
	JMP	DXOHTO 		/ ERROR IN TRANSFER
/
	TAD	CMDBUF 		/ SEE IF INIT ACK SENT IF SO SET FLAG
	TAD	(-INIACK)
	SZA CLA 		/ ++++
	JMP	DXOHJB
	AC0001 			/ ++++
	DCA	INIFL2
	JMP	DXOHJB
DXOHJ1,
	TAD	NAKFL2
	TAD	TOFL2
	SNA CLA 		/ ++++
	JMP	DXOHJ2
	TAD	PUTPRC
	SNA CLA 		/ ++++
	JMP	DXOHJ4
/
	TAD	(PTRHED) 	/ SET THE POINTERS FOR THE RESENDING
	DCA	GTNXPT
/
DXOHJ5,
	JMS	GETNXT 		/ GET THE NEXT PACKET TO SEND
	JMP	DXOHJ4
/
	TAD	(2) 		/ GET THE ADDRES FOR THE DATA
/
	JMS	SNDPCK 		/ SEND IT
	JMP	DXOHTO
	JMP	DXOHJ5
DXOHJ4,
	CLA
	DCA	TOFL2 		/ CLEAR THE ERROR FLAGS
	DCA	NAKFL2
DXOHJ2,
	TAD	INIFL2 		/ SEE IF THE LINE HAS BEEN INITALIZED YET
	SNA CLA 		/ ++++
	JMP	DXOHWT
	JMS	GETBUF 		/ ++++
	SENDPT 			/ SEE IF THERE IS A PACKET TO SENT
	JMP	DXOHWT 		/ NOTHING TO DO SO WAIT
/
	JMS	DXSNBF 		/ SEND IT
	JMP	DXOHTO 		/ ERROR IN SENDING IT
	JMP	DXOHJB
DXOHTO,
	CLA
	TAD	TOFL2 		/ SEE WHY
	SNA CLA 		/ ++++
	JMP	DXOHT2
DXOHT3,
	AC7777
	JMS	HOSTOU 		/ CLEAR THE BUFFERS
	NOP
DXOHT2,
	TAD	(RESET) 	/ SEND A RESET CAHRACTER TO TERMINAT THE PACKET
	JMS	SNDCHR
	JMP	DXOHT3
	TAD	(CR) 		/ TERMINATOR
	JMS	SNDCHR
	JMP	DXOHT3
/
	JMP	DXOHJB
DXOFLG,
	0
TOTM2,
	0
INIFL2,
	0
TOFL2,
	0
/
/
/	DISBLF - DISPLAY THE BOTTOM LINE AND CLEAR EVENT FLAG INTFLG	/A017
/
DISBLF,	XX								/A017
	JMS	DISBL							/A017
	JMS	CLAINF							/A017
	JMP I	DISBLF							/A017

	PAGE


/
/	DXSNBF - SEND THE PACKET AND PUT IT INTO THE SENT BUFFER
/
DXSNBF,
	XX
	DCA	DXSNBA 		/ SAVE THE STARTING ADDRESS
	AC0002 			/ GET THE START OF TEXT
	TAD	DXSNBA
	DCA	SEQPSN
/
	ISZ	OSEQNO 		/ INCREMENT THE SEQ NUMBER
	CLA
	TAD	OSEQNO 		/ INSERT THE SEQ
	AND	P77
	JMS	ADOFST
	DCA I	SEQPSN
/
	TAD	SEQPSN
	JMS	CHKSUM
/
	TAD	DXSNBA 		/ PUT THE PACKET IN THE SEND LIST
	JMS	PUTPTR
/
	TAD	SEQPSN
	JMS	SNDPCK 		/ SEND THE PACKET
	JMP I	DXSNBF
/
	ISZ	DXSNBF
	JMP I	DXSNBF
DXSNBA,
	0
SEQPSN,
	0
OSEQNO,
	0


/
/	ADOFST - ADDS THE OFFSET TO THE AC
/
ADOFST,
	XX
	SNA 			/ ++++
	TAD	(100) 		/ IF ZERO ADD 137 ELSE ADD 37
	TAD	(37)
	JMP I	ADOFST


/
/	SBOFST - TAKE OFF THE OFFSET FROM THE CONTENTS OF THE AC
/
SBOFST,
	XX
	TAD	(-137) 		/ IF ZERO SUBTRACT A 137 ELSE A 37
	SZA 			/ ++++
	TAD	(100)
	JMP I	SBOFST



/
/	CHKSUM - COMPUTES THE CHECK SUM OF THE PACKET WHOSE ADDRESS IS
/	IN THE AC.IT THEN INSERTS ATHE CHECK SUM AT THE END OF THE PACKET AND
/	ENDS IT WITH A ZERO.
/
CHKSUM,
	XX
	JMS	CHKSM1 		/ GET THE SUM OF THE BUFFER
	TAD	T2
	BSW 			/ PUT IN THE FIRST HALF
	AND	P77
	JMS	ADOFST
	DCA I	T1
	ISZ	T1
	TAD	T2 		/ NOW THE SECOND HALF
	AND	P77
	JMS	ADOFST
	DCA I	T1
/
	ISZ	T1
	DCA I	T1 		/ INSERT THE TRAILER
	JMP I	CHKSUM


/
/	SNDCHR - SEND CHARACTER ROUTINE
/
SNDCHR,
	XX
	DCA	SNDCHT
	AC0002 			/ ++++
	DCA	SNDTMO 		/ SET TIME OUT FOR EACH CHARACTER
	JMP	SNDCHJ
SNDCHW,
	CLA
	CIFSYS 			/ ++++
	JWAIT
	TAD	SPFLAG 		/ IF NOT TIMED OUT CHECK TO SEE IF THE OTHER
	SPA CLA 		/ ++++
	JMP	DXOHEX 		/ PROGRAMS ARE RUNNING
	TAD	SNDTMO 		/ ++++
	SZA CLA 		/ ++++
	JMP	SNDCHJ
	TAD	TOFL2 		/ OR THAT THE INPUT ROUTINE TIMED OUT
	TAD	NAKFL2 		/ OR THAT IT RECEIVED A NAK
	SZA CLA 		/ ++++
	JMP	SNDCHE
SNDCHJ,
	TAD	SNDCHT
	JMS	HOSTOU
	JMP	SNDCHW
	ISZ	SNDCHR
SNDCHE,
	JMP I	SNDCHR
SNDCHT,
	0
SNDTMO,
	0


/
/	DXIHJB - HOST INPUT ROUTINE
/
DXIHEX,
	AC7777 			/ ++++
	DCA	DXIFLG 		/ SET TO SAY I HAVE EXITED.
	CIFSYS 			/ ++++
	JEXIT
DXIHWT,
	CIFSYS 			/ ++++
	JWAIT
DXIHJB,
	CLA
	TAD	SPFLAG 		/ SEE IF THE OHTER JOBS ARE DONE IF SO STOP
	SPA CLA 		/ ++++
	JMP	DXIHEX
	TAD	RSTFLG 		/ IF SET WAIT
	SZA CLA 		/ ++++
	JMP	DXIHWT
	TAD	INIFL1 		/ SEE IF THE LINE IS INITIATED
	SNA CLA 		/ ++++
	JMP	DXIHIN
	JMS	GETTM2
	SZA CLA 		/ ++++
	ISZ	DLYLM2
	SKP CLA 		/ ++++
	JMP	DXIHTO 		/ TIME OUT PROCESS
DXIHJ1,
	JMP	DXIHGP 		/ GET A PACKET
DXIHJ2,
	TAD I	DXGTPT 		/ SEE WHAT IT IS
	TAD	(-SPECHR)
	SMA CLA 		/ ++++
	JMP	DXICMD 		/ ACOMMAND TO LOW LEVEL DW
	AC0002			/ DID WE TIMEOUT?			/A017
	TAD	ERRFLG		/ (IS ERROR STATUS TIMEOUT?)		/A017
	SZA CLA			/ IF YES THEN DON'T ACK			/A017
	TAD	INIFL2 		/ IF NOT SET DONT ACCEPT THE PACKET
	SNA CLA 		/ ++++
	JMP	DXIHWT 		/ WAIT UNTIL SET
	JMP	DXIPKT
DXIFLG,
	0
DLYLM2,
	0
/
	PAGE


/
/	THIS IS THE TIME OUT CHECK
/
DXIHTO,
	TAD	INIFL2
	SNA CLA 		/ ++++
	JMP	DXIHIN 		/ IF NOT INITALIZED THEN RESET THE INIT
	TAD	PUTPRC 		/ SEE IF IT IS OK TO TIME OUT
	SNA CLA 		/ ++++
	JMP	DXIHWT
	JMS	CLAINF 		/ CLEAR THE EVENT FLAG SO OHTER JOBS WILL NOTICE
	ISZ	TOFL2
	AC7777 			/ ++++
	TAD	SNDTMO 		/ UPDATE THE TIME OUT COUNTER FOR A CHARACTER
	SMA 			/ ++++
	DCA	SNDTMO
	CLA
	TAD	DLY3X    		/ ++++				/M020
	DCA	DLYLM2
	JMS	UPDTER 		/ INCREMENT THE ERROR COUNTER
	ISZ	TOTM2
	JMP	DXIHWT
	JMS	DXIHKP 		/ KILL THE SEND PACKETS IF THE TRANSFER FAILED
	AC7777 			/ ++++
	JMS	HOSTOU 		/ CLEAR THE OUTPUT BUFFER
	CLA
	JMP	DXIHWT


/
/	DXIHKP - KILLS ALL PACKETS TO BE SENT AND WAITING
/
DXIHKP,
	XX
	AC7777 			/ ++++
	JMS	HOSTOU 		/ CLEAR THE OUTPUT BUFFER AND MAKE SURE ITS XONED
	CLA
	JMS	DXICLA 		/ CLEAR THE START THE LOW INIT FLAGS
/
DXIHK2,
	JMS	GETBUF 		/ ++++
	SENDPT 			/ CHECK THE SEND LIST
	JMP	DXIHKJ
/
	JMS	DXIHKR 		/ SET THE CONDITION FLAG
	JMP	DXIHK2 		/ CONTINUE UNTIL EMPTY
DXIHKJ,
	JMS	GETPTR 		/ GET THE ONES IN THE WAIT LIST
	JMP I	DXIHKP
/
	JMS	DXIHKR
	JMP	DXIHKJ
DXIHKR,
	XX
	IAC
	DCA	T1
	AC7777
	DCA I	T1
	JMP I	DXIHKR


/
/	DXIHIN - SENDS THE LINE INIT
/
DXIHIN,
	AC0001 			/ ++++
	DCA	INIFL1
	JMS	DXIHKP 		/ CLEAR EVERYTHING
	TAD	AXFLG 		/ CHECK FOR AX
	SZA CLA 		/ ++++
	JMP	DXIHJ1
	TAD	DLY1X 		/ ++++					/M020
	DCA	DLYLM2
	TAD	(INIT)
	JMP	DXIBDY
INIFL1,
	0


/
/	DXIPKT - RETRUN A PACKET
/
DXIPKT,
	TAD I	DXGTPT 		/ GET THE SEQUENCE NUMBER
	JMS	SBOFST
	CIA
	DCA	T1
	AC0001
	TAD	ISEQNO
	AND	P77
	TAD	T1
	SZA CLA 		/ ++++
	JMP	DXIPK2
/
	TAD	DXGTPA 		/ GET THE STARTING ADDRESS
	JMS	PUTBUF 		/ ++++
	RECPT
/
	CLA
	DCA	DXIHFP 		/ KEEP PACKET
	DCA	DXNONK 		/ CLEAR THE DONT SEND A NAK FLAG
/
	ISZ	ISEQNO 		/ ++++
	NOP 			/ UPDATE THE PACKET INPUT SEQUENCE NUMBER
DXIPK2,
	TAD	(ACK) 		/ SEND A ACK
	JMP	DXIBDY							/A017
/


/
/	THIS WILL SEND THE CONTENTS IN THE AC AS A COMMAND
/
/DXIBDY,
/	DCA	CMDFLG
/
/	JMS	CLAINF 		/ CLEAR THE EVENT FLAG
/	JMP	DXIHJB 		/ DONE CONTINUE
ISEQNO,
	0
CMDFLG,
	0

/
/	DXICMD - HANDLES THE INCOMING COMMAND
/
DXICMD,	TAD I	DXGTPT
	TAD	(-ACK) 		/ CHECK FOR AN ACK
	SNA 			/ ++++
	 JMP	DXICKS
	TAD	(ACK-NAK) 	/ NOW A NAK
	SNA 			/ ++++
	 JMP	DXINAK
	TAD	(NAK-INIT) 	/ AND INIT
	SNA 			/ ++++
	 JMP	DXINIT
	TAD	(INIT-INIACK)
	SNA 			/ ++++
	 JMP	DXIACI
	TAD	(INIACK-QUIT) 	/ IF A QUIT LOW LEVEL COMMAND AND IN DX LEAVE
	SNA CLA 		/ ++++
	 JMP	DXIQIT
	JMP	DXIHJB

/
/	DXINAK - CHECK FOR A VALID NAK
/
DXINAK,	ISZ	NAKFL2
	JMS	UPDTER 		/ UPDATE THE ERROR COUNTER
	JMP	DXICKS

NAKFL2,	0
/------------
	PAGE


/
/	*********************************************************
/
/	THE NEXT TWO LOCATIONS ARE IMPORTANT TO AX SO IF MOVED TELL AX
/	SHOULD BE LOCATIONS 5200 AND 5201
/
/	*********************************************************
/
	IFNZRO .-5200 <ERROR !!!>
/
	GETBUF
	PUTBUF
/
/	*********************************************************
/


/
/	DXICKS - CHECK FOR A VALID COMMAND
/
DXICKS,
	AC0001
	TAD	DXGTPT 		/ GET ADDRESS OF THE SEQUENCE
	DCA	T1
	TAD I	T1 		/ GET THE SEQUENCE
	JMS	SBOFST
/
	CIA 			/ GET THE NEGATIVE SEQUENCE NUMBER SENT
	TAD	OSEQNO 		/ COMPARE TO THE OUTPUT SEQUENCE NUMBER
	AND	P77 		/ AND IT TO KEEP IT POSITIVE
	CIA 			/ MAKE NEGATINE TO SEE IF THE NUMBER IS IN RANGE
	TAD	PUTPRC 		/ COMPARE TO THE NUMBER OF PACKETS IN THE WAIT LIST
	CIA
	DCA	DXIAKT 		/ IF NEGATIVE IT IS THE NUMBER OF PACKETS ACKED
	TAD	DXIAKT 		/ ++++
	SMA CLA 		/ ++++
	JMP	DXIHJB 		/ FORGET IF NOT NEGATIVE
/
DXIAK3,
	JMS	GETPTR 		/ GET THE BUFFERS OUT OF THE LIST
	JMP	DXIAKD 		/ RETURN
/
	IAC
	DCA	DXIAK2 		/ SET THE STATUS TO DONE
	IAC 			/ DONE IS 1
	DCA I	DXIAK2
/
	ISZ	DXIAKT
	JMP	DXIAK3
DXIAKD,
	TAD	DLY3X							/M020
	DCA	DLYLM2
	JMP	DXIHJB
DXIAKT,
	0
DXIAK2,
	0


/
/	DXIHGP - GETS A PACKET IF ONE IS COMMING
/
DXIHGP,
	TAD	DXIHFP 		/ SEE IF A BUFFER IS ALOCATED TO INPUT
	SZA CLA 		/ ++++
	JMP	DXIHGJ 		/ IF SO FILL IT
	JMS	GETBUF 		/ ++++
	FREEPT
	JMP	DXIHWT
	DCA	DXGTPA 		/ SAVE THE BUFFER ADDRESS
	ISZ	DXIHFP
/
DXIHG1,
	JMS	DXIHGX 		/ SET THE POINTERS TO THE BEGINING
DXIHGJ,
				/ SHOULD HAVE A GETCHR ROUTINE SO TO GET FRAMING
	JMS	HOSTIN 		/ GET A CHARACTER
	JMP	DXIHWT
/
	TAD	(-CR) 		/ SEE IF END OF PACKET
	SNA 			/ ++++
	JMP	DXIHG2
	TAD	(CR)
DXIHGZ,
	DCA I	DXGTPS
	ISZ	DXGTPS
	ISZ	DXGTPC
	JMP	DXIHGJ
	JMP	DXIHG1 		/ TOO BIG
DXIHG2,
	DCA I	DXGTPS 		/ INSERT A ZERO FOR THE END OF A PACKET
/
	AC7776
	TAD	DXGTPS 		/ GET THE ADDRESS OF THE CHECK SUM
	CIA
	TAD	DXGTPT 		/ GET DATA CNT
	SMA 			/ ++++
	JMP	DXIHG1 		/ IGNORE IF TOO SMALL
	DCA	T2
/
	AC7777 			/ SEE IF THE RESET CHARACTER IS PART OF THE
	TAD	DXGTPS
	DCA	T1
	TAD I	T1
	TAD	(-SPECHR)
	SMA CLA 		/ ++++
	JMP	DXIHG1
/
	TAD	DXGTPT
	DCA	T1
DXIHG3,
	TAD I	T1 		/ GET THE CONTENTS
	ISZ	T1
	ISZ	T2 		/ ++++
	JMP	DXIHG3
	DCA	T3 		/ SAVE CHECK SUM
	TAD I	T1 		/ GET THE SENT CHECK SUM
	JMS	SBOFST 		/ GET RID OF THE OFFSET
	BSW
	DCA	T2
/
	DCA I	T1 		/ CLEAR THE TERMINATOR
/
	ISZ	T1
	TAD I	T1
	JMS	SBOFST 		/ STRIP THE OFFSET
	TAD	T2
	CIA 			/ ++++
	TAD	T3
	SNA CLA 		/ ++++
	JMP	DXIHG4 		/ SEE WHAT WAS FOUND
	TAD I	DXGTPT 		/ CHECK THE SEQUENCES
	JMS	SBOFST
	CIA 			/ ++++
	IAC
	TAD	ISEQNO
	AND	P77
	SZA CLA 		/ ++++
	JMP	DXIHG1 		/ FORGET TI TF THE SEQUENCES DONT MATCH
	JMS	DXIHGX 		/ RESET THE POINTERS
	JMP	SNDNAK
DXIHG4,
	JMS	DXIHGX 		/ RESET THE POINTERS
	JMP	DXIHJ2
/
DXIHGX,
	XX
	AC0002
	TAD	DXGTPA
	DCA	DXGTPS 		/ STORE ADDRESS OF START OF TEXT
	TAD	DXGTPS
	DCA	DXGTPT
/
	TAD	(-BUFSIZ-5) 	/ COUNTER MINUS THE CR
	DCA	DXGTPC
	JMP I	DXIHGX
DXIHFP,
	0
DXGTPA,
	0
DXGTPS,
	0
DXGTPC,
	0
/
	PAGE


/
/	DXINIT - FOR THE INITAL MESSAGE
/
DXINIT,
	JMS	DXICKV 		/ CHECK FOR A VALID VERSION OF THE PROTOCOL
	JMP	DXIER1
/
	TAD	INIFL3 		/ SEE IF ALREADY CONNECTED
	SNA CLA 		/ ++++
	JMP	DXINI2
/
	JMS	DXIHKP 		/ CLEAR EVERYTHING
/
	AC0001
DXIER2,
	DCA	RSTFLG 		/ IF - THEN CANNOT CONNECT IF + RESTARTED
/
	JMP	DXIHWT
DXINI2,
	TAD	(INIACK) 	/ ++++
	DCA	CMDFLG 		/ SET THE COMMAND FLAG
DXIACI,
	JMS	DXICKV 		/ CHECK FOR VALIN VERSION
	JMP	DXIER1
/
	AC0001
	DCA	INIFL2 		/ SET THE LINE IS INITALIZED FLAG
DXIAC3,
	JMS	CLAINF
	JMP	DXIHJB
DXIER1,
	AC7777 			/ ++++
	DCA	CNGSCF 		/ SET TO REPAINT THE SCREEN
	AC7777
	JMP	DXIER2


/
/	HOSTO2 - WILL SEND THE DESIRED NUMBER OF NULLS THAT THE HOST SYSTEM REQUESTED
/	TO BE SEND AS PAD CHARACTERS AFTER A CR.
/
HOSTO2,
	XX
	TAD	HOSTOT 		/ ++++
	TAD	(-CR) 		/ SEE IF A CR WAS THE LAST CHARACTER SENT
	SZA CLA 		/ ++++
	JMP I	HOSTO2 		/ IF NOT RETURN
	TAD	NULCNT 		/ IF YES THEN SEE IF THE NULL COUNTER IS NON ZERO
	SNA 			/ ++++
	JMP I	HOSTO2 		/ IF ZERO THEN RETURN ALSO
	DCA	HOSTM1
HOSTJ1,
	JMS	HSTOU 		/ OUTPUT NULLS
	ISZ	HOSTM1
	JMP	HOSTJ1
	JMP I	HOSTO2
HOSTM1,	0
/


/
/	PUTPTR - INSERTS THE ADDRESS IN THE AC INTO THE SEND LIST OF PACKETS
/	AND STARTS THE TIMERS
/
PUTPTR,
	XX
	DCA	T1 		/ STORE THE ADDRESS OF THE BUFFER
	TAD	(PTRHED-1) 	/ GET THE START OF THE LIST
	TAD	PUTPRC 		/ USE COUNTER FOR THE OFFSET
	DCA	IX0
	TAD	T1 		/ TACK THIS ONE TO THE END OF THE LIST
	DCA I	IX0
	DCA I	IX0
/
	TAD	(TOLIM) 	/ ++++
	DCA	TOTM2
	TAD	DLY3X							/M020
	DCA	DLYLM2 		/ SET THE TIMERS
/
	ISZ	PUTPRC 		/ INCREMENT THE COUNTER
	JMP I	PUTPTR
PUTPRC,
	0
PUTPRQ,
	0

/
/	GETPTR - GETS THE MOST RECENT PACKET OUT OF THE BUFFER OF
/	MESSAGES SENT BUT UNANSWERED
/
GETPTR,	XX
	CLA
	TAD	PUTPRC 		/ SEE IF STACK EMPTY
	SNA 			/ ++++
	 JMP I	GETPTR
	CIA
	DCA	T2
	TAD	(PTRHED-2)
	DCA	IX1
	TAD	(PTRHED-1)
	DCA	IX0
GETPTL,	TAD I	IX0 		/ GET THE NEXT ENTRY
	DCA I	IX1
	ISZ	T2
	 JMP	GETPTL
	DCA I	IX1
	ISZ	GETPTR
	AC7777
	TAD	PUTPRC 		/ DECREMENT THE COUNTER
	DCA	PUTPRC
	TAD	PTRHED-1 	/ GET THE NEXT ADDRESS
	JMP I	GETPTR

/
/	GETBUF - GETS THE NEXT BUFFER ADDRES IF THERE IS ON IN THE REQUESTED CHAIN
/	CALL
/	JMS GETBUF
/	THE CHAIN STARTING ADDRESS (FREEPT,RECPT,SENDPT)
/	EMPTY RETURN
/	NORMAL RETURN
/
GETBUF,	XX
	CLA
	RDF 			/ READ THE DATA FIELD TO SEE WHERE IT CAME FROM
	TAD	CIDF0 		/ MAKE THE RETURN INSTRUCTION
	DCA	GETBUX
	TAD I	GETBUF 		/ GET THE ADDRESS
	CDFMYF
	ISZ	GETBUF
	DCA	T1
	TAD I	T1 		/ GET THE NEXT BUFFER IN THE CHAIN
	SNA 			/ ++++
	 JMP	GETBUX 		/ RETURN ZERO IN BUFFER
	DCA	T2
	TAD I	T2 		/ CHANGE THE POINTERS BECAUSE THIS ONE IS NOW IN USE T1
	DCA I	T1 		/ CUT FROM CHAIN
	TAD	T2 		/ RETRUN THE BUFFER ADDRESS
	ISZ	GETBUF
GETBUX,	XX
	JMP I	GETBUF

/
/	PUTBUF - ADD THE SPECIFIED BUFFER WHOSE ADDRESS ISIN THE AC IN THE LIST
/	DESIRED BY THE NEXT LOCATION
/
PUTBUF,	XX
	DCA	T2 		/ SAVE THE BUFFER
	RDF 			/ READ THE DATA FIELD FOR THE RETURN
	TAD	CIDF0
	DCA	PUTBUX
	TAD I	PUTBUF 		/ GET THE CHAIN STARTER
	ISZ	PUTBUF
	DCA	T1
	CDFMYF
PUTBUJ,	TAD I	T1 		/ GO TO THE END
	SNA 			/ ++++
	 JMP	PUTJ2
	DCA	T1
	JMP	PUTBUJ
PUTJ2,	TAD	T2
	DCA I	T1
	DCA I	T2
PUTBUX,	XX
	JMP I	PUTBUF
/------------
	PAGE

/
/	SNDPCK - SENDS A PACKET
/	THE ADDRESS OF THE TEXT PART OF THE BUFFER IS IN THE AC
/
SNDPCK,	XX
	DCA	SNDTP2 		/ SAVE THE STARTING ADDRESS
SNDCMJ,	TAD I	SNDTP2 		/ GET THE FIRST CHARACTER
	SNA 			/ ++++
	 JMP	SNDCMD
	JMS	SNDCHR
	 JMP	SNDCME
	ISZ	SNDTP2
	JMP	SNDCMJ

SNDCMD,	TAD	(CR) 		/ SEND THE TRAILER
	JMS	SNDCHR
	 JMP	SNDCME
	ISZ	SNDPCK
SNDCME,	JMP I	SNDPCK

SNDTP2,	0

/
/	CLSCRL - CLOSES THE FILE IF HAS BEEN OPENED FOR SCROLL
/
CLSCRL,	XX
	TAD	DOCNO 		/ SEE IF IT IS OPEN
	SNA CLA 		/ ++++
	 JMP I	CLSCRL
	CIFBUF			/ Call the SIX BIT routine so as to	/A017
	JMS I	WRISXA		/ TERMINATE THE FILE PROPERLY		/A017
	CIFFIO 			/ ++++					/M013
	FILEIO 			/ ++++					/M013
	XDSKCL
	JMP I	CLSCRL

/
/	GETPRC - GETS THE PRINTER SETTING OUT OF THE BUFFER READ IN BY RDFIL INIT
/
GETPRC,	XX
	DCA	INISTT 		/ SAVE THE ADDRESS FOR THE INSERT PRINTER CONTROLS
	DCA	BYTCNT 		/ INITALIZE THE BYTE COUNT
	TAD	INISTT
	DCA	X1
	TAD	(SETSIZ) 	/ INITALIZE THE WORD COUNTER
	DCA	SETCNT
	TAD	(SETSND-1) 	/ GET THE INITAL ADDRESS OF STRE THE SETTING
	DCA	SETTMP 		/ STORE THE INITAL ADDRES OF THE SETTINGS
GETRLL,	JMS	GETPRB 		/ GET A BYTE OF THE SETTINGS
	JMS	ADOFST 		/ ADD THE OFFSET
	DCA I	X1 		/ STORE IN MESSAGE BUFFER
	JMS	GETPRB
	JMS	ADOFST 		/ ADD THE OFFSET OFR THE LINE
	DCA I	X1
	ISZ	SETCNT
	 JMP	GETRLL
	DCA I	X1
	JMP I	GETPRC

SETCNT,	0
INISTT,	0

/
/	GETRLB - GETS THE NEXT BYTE OF THE PRINTER SETTINGS
/
GETPRB,	XX
	JMS	GETBYT 		/ FIND OUT WHICH HALF OF THE WORD TO RETURN
	 JMP	NOISZ 		/ TOP HALF
	ISZ	SETTMP 		/ NEXT WORD TOP BYTE
	CDFBUF
	TAD I	SETTMP
	BSW
	JMP	GETCNT

NOISZ,	CDFBUF
	TAD I	SETTMP
GETCNT,	CDFMYF
	AND	P77
	JMP I	GETPRB

SETTMP,	0

/
/	GETBYT - IF BYTCNT = 0 SET TO 1 AND SKIP RETURN
/	IF 1 THEN SET TO ZERO AND RETURN
/
GETBYT,	XX
	CLA
	TAD	BYTCNT
	SZA CLA
	 JMP	CLABYT
	AC0001
	ISZ	GETBYT
CLABYT,	DCA	BYTCNT
	JMP I	GETBYT

BYTCNT,	0

/
/	STRPRT - STORES THE PRINTER SETTINGS INTO THE FILE HEADER THAT IS
/	RECEIVING THE DOCUMENT
/
STRPRT,	XX
	CLA
	TAD	(PRTOFF) 	/ SEE IF THERE EXISTS ANY PRINTER SETTINGS
	CIFFIO 			/ ++++					/M013
	FILEIO 			/ ++++					/M013
	XHDRGT
	SZA CLA 		/ ++++
	 JMP I	STRPRT 		/ THERE EXISTS PRINTER SETTINGS
	TAD	(SETSIZ) 	/ INITALIZE THE COUNTER FOR THE PRINTER SETTINGS
	DCA	SETCNT
	TAD	(SETSAV-1) 	/ GET THE STARTING ADDRESS
	DCA	X5
	TAD	(PRTOFF) 	/ INITLAIZE THE OFFSET FOR SAVING THE VALUES
	DCA	SETTM2
STRRLL,	TAD I	X5
	JMS	SBOFST 		/ TAKE OFF THE OFFSET
	BSW
	MQL 			/ STORE IT
	TAD I	X5
	JMS	SBOFST
	MQA
	MQL 			/ ++++
	TAD	SETTM2
	CIFFIO 			/ ++++					/M013
	FILEIO 			/ ++++					/M013
	XHDRPT
	ISZ	SETTM2
	ISZ	SETCNT
	JMP	STRRLL

	JMP I	STRPRT
SETTM2,	0

/	CLEAR STATUS LINE AND RESET FLAGS				/A031

CLASTA,	XX			/ CLEAR STATUS LINE			/A031
	JMS	SETFLG		/ FIRST RESET FLAGS			/A031
	CIFMNU			/ MENU					/A031
	JMS I	IOACAL		/ GO DISPLAY				/A031
	  0			/					/A031
	  CONSTM		/ "CONNECTION ESTABLISHED"		/A031
	  0315			/ SCREEN POSITION			/A031
	JMP I	CLASTA		/ RETURN				/A031
/
/	INIWAT - JWAITS AND CHECKS THE SPFLAG
/	IT DOES A SKIP RETURN IF NOTHING IS SET.
/
INIWAT,
	XX
	CIFSYS 			/ ++++
	JWAIT
/
	CLA
	TAD	SPFLAG
	SNA CLA 		/ ++++
	ISZ	INIWAT
/
	JMP I	INIWAT
/
/-------------
	PAGE

/
/	DXCOPY - SIMILAR TO CUCOPY BUT THIS COPY MAKES ASCIIZ STRINGS OUT OF THE
/	RECEIVING STRING AND NEEDS AN ASCIIZ STRING FOR THE BEGINNING STRING.  THAT IS
/	WHY IT HAS TO COUNT
/
/	CALL:
/	JMS	DXCOPY
/	CDF TO FIELD OF START STRING
/	ADDRESS OF THAT STRING
/	CDF TO RECEIVING STRING
/	ADDRESS OF STRING
/
DXCOPY,	XX
	CLA
	TAD	DXBSIZ 		/ SET A LIMIT FOR PROTECTION
	DCA	T1
	TAD I	DXCOPY
	DCA	DXCOP1
	ISZ	DXCOPY
	AC7777
	TAD I	DXCOPY
	DCA	X1
	ISZ	DXCOPY
	TAD I	DXCOPY
	DCA	DXCOP2
	ISZ	DXCOPY
	AC7777
	TAD I	DXCOPY
	DCA	X2
	ISZ	DXCOPY
DXCOP1,	XX
	TAD I	X1
DXCOP2,	XX
	SNA 			/ ++++
	 JMP	DXCOPX
	DCA I	X2
	ISZ	T1
	 JMP	DXCOP1
DXCOPX,	DCA I	X2
	CDFMYF
	JMP I	DXCOPY

DXBSIZ,	-BUFSIZ

/
/	KBOUTC - CROSS FIELD ROUTINE THAT WILL OUTPUT A CHARACTER IF ECHO IS TURNED
/	ON ELSE OUTPUT A BOX TO THE SCREEN
/
KBOUTC,	XX
	DCA	OUTCHR 		/ CHARACTER IS IN THE AC TO BE PRINTED WHEN CALLED
	RDF
	TAD	CIDF0
	DCA	KBOUTX 		/ SET THE RETURN FIELD
	CDFMYF
	TAD	OUTCHR
	SNA CLA 		/ ++++
	 JMP	KBOUTX
	TAD I	LPMTFL 		/ IF NEGATIVE ECHO IS TURNED OFF
	SMA CLA 		/ ++++
	 JMP	KBOUTL
	JMS I	LKBOUT
		ESC+4000	/ ESC					/M007
		"(+4000		/ (					/A007
		060+4000	/ '0' put in special graphics mode	/M017
		141+4000	/ a (outputs a square box)		/M007
		ESC+4000	/ ESC					/M007
		"(+4000							/A007
		102		/ 'B' put back in ascii character set	/M017
	 JMP	KBOUTX 		/ RETURN WHEN THE STRING IS SENT

KBOUTL,	JMS I	LKBOUT
OUTCHR,		0		/ Character to be output.
KBOUTX,	XX
	JMP I	KBOUTC

LPMTFL,	PMTTMP
LKBOUT,	KBOUT

/
/	THIS IS THE LIST OF FLAGS TO CLEAR AT THE STARTOF THE LOW LEVEL ROUTINES
/	TOCLST
/
TOCLST,	DXOFLG 			/ CLEAR THE FLAG FOR THE OUTPUT JOB
	TOTM2 			/ CLEAR THE TIME OUT FLAG
	TOFL2 			/ CLEAR THE TIME OUT COUNTER
	OSEQNO 			/ CLEAR THE OUTPUT SEQUENCE NUMBER
	SNDTMO 			/ CLEAR THE FLAG FOR THE SEND CHARACTER ROUTINE FOR TIME
	DXIFLG 			/ CLEAR THE INPUT FLAG
	ISEQNO 			/ CLEAR THE INPUT SEQUENCE NUMBER
	NAKFL2 			/ CLEAR THE NAK FLAG
	DXNONK 			/ CLEAR THE DONT SEND A NAK ONE HAS BEEN SENT ALREADY FLAG
	0 			/ TERMINATOR


/
/	THE BUFFERS
/
CMDBUF,
	ZBLOCK 10 		/ THE COMMAND BUFFER
PTRHE1,
	0 			/ THE NEXT ADDRESS THAT WILL BE RETURNED BY GETPTR
PTRHED,
	ZBLOCK BUFCNT+1 	/ THE LIST OF PACKETS SENT AND WAITING FOR AN ACK
INMBLK,
	ZBLOCK BUFSIZ+1 	/ MINUS THE CHECK SUM
DOCNBF,
	ZBLOCK BUFSIZ+2 	/ SECOND MESSAGE BUFFER USED FOR FILE NAME
				/ AND COMMUNICATIONS BETWEEN THE HOST AND MAIN
/

/
/	THIS IS THE BUFFER POOL.  BUFBL1 - 5
/
/	FORMAT:
/	ADDRESS	+0	LINK TO NEXT ENTRY IN LIST
/	+1	STATUS: 0 = NOTHING, 1 = SENT, -1 = TIMED OUT
/	+2 - 64	TEXT OF PACKET ASCIIZ FORMAT
/
/	THE USE OF THE POINTER IS TO LINK TOGETHER THE THREE LIST: FREE, SEND
/	AND RECEIVE.  THE LISTS ARE TERMINATED BY A ZERO POINTER.  THE STARTING
/	ADDRESS OF THE LISTS ARE FOUND IN FREEPT, SENDPT, AND RECPT.  TO GET A BUFFER
/	FROM ANY LIST OR TO ADD TO THE LIST THER ARE ROUTINES FOR THIS CALLED
/	PUTBUF AND GETBUF.
/
/	CALL:
/	JMS PUTBUF/GETBUF
/	ADDRESS OF POINTER TO LIST
/
/	ON CALLING PUTBUF THE AC CONTAINS THE STARTING ADDRESS OF THE BUFFER.
/
/	WHEN RETURNING FROM GETBUF THE STARTING ADDRESS OF THE NEXT BUFFER IS  IN
/	THE AC.  IF THERE  ARE NO BUFFERS GETBUF DOES A NON-SKIP RETURN, ELSE A
/	SKIP RETURN.
/
BUFBL1,	BUFBL2			/ LINK BUFF 1 TO BUFF 2.		/A023
	ZBLOCK BUFSIZ+6 						/M023
BUFBL2,	BUFBL3			/ LINK BUFF TO TO BUFF 3.		/A023
	ZBLOCK BUFSIZ+6 						/M023
*BUFBL2+2	/LEAVE A COUPLE OF ZERO WORDS AT BEG OF BUFFER		/A020
DLYBAS,	-1	/BASE CONSTANT FOR DEVLOPING VARIABLE DELAYS		/A020
XDLYCT,	-1	/DEFAULT MULTIPLIER					/A020
XDELAY,	XX								/A020
	CDFMNU	/NEED TO ACCESS MENU AREA FOR DELAY ENTRY		/A020
	TAD I	IMNXDL		/GET DELAY MULTIPLIER			/A020
	CDFMYF								/A020
	CIA			/CONVERT TO NEG COUNT			/A020
	DCA	XDLYCT		/SET COUNTER				/A020
	TAD	DLYBAS		/GET BASE DELAY CONSTANT		/A020
	ISZ	XDLYCT		/SKIP WHEN DELAY IS BIG ENOUGH		/A020
	JMP	.-2		/LOOP TILL DELAY MULTIPLIED X TIMES	/A020
	DCA I	IDLY1X		/SET NEW BASE DELAY (TIMES X)		/A020
	TAD I	IDLY1X		/GET BASE DELAY			/A020
	TAD I	IDLY1X		/DEVELOP 3X DELAY			/A020
	TAD I	IDLY1X							/A020
	DCA I	IDLY3X		/SET 3X DELAY				/A020
	TAD I	IDLY3X		/GET PACKET SEND/RECV TIMEOUT DELAY	/A020
	TAD I	IDLY3X		/DOUBLE IT				/A020
	DCA I	IDLY6X		/SET 6X DELAY (HOST ACK TIME OUT	/A020
	TAD I	IDLY6X		/USE 6X DELAY TO DEVELOP 36X (180)DELAY	/A020
	TAD I	IDLY6X		/USE 6X DELAY TO DEVELOP 36X (180)DELAY	/A020
	TAD I	IDLY6X		/USE 6X DELAY TO DEVELOP 36X (180)DELAY	/A020
	TAD I	IDLY6X		/USE 6X DELAY TO DEVELOP 36X (180)DELAY	/A020
	TAD I	IDLY6X		/USE 6X DELAY TO DEVELOP 36X (180)DELAY	/A020
	TAD I	IDLY6X		/USE 6X DELAY TO DEVELOP 36X (180)DELAY	/A020
	DCA I	IDLY18		/SET USER RESPONSE TIME DELAY		/A020
	AC7777			/MAKE SURE 1ST SECOND IS A WHOLE ONE	/A020
	TAD I	IDLY1X		/GET SHORT DELAY			/A020
	DCA I	IDLY1X		/PUT BACK ADJUSTED DELAY COUNT		/A020
	AC7777			/SAME PROCEDURE FOR 6X DELAY		/A020
	TAD I	IDLY6X		/GET IT					/A020
	DCA I	IDLY6X		/DON'T ADJUST 3X DELAY			/A020
/D023;	CLA								/A020
/D023;	TAD	.-1		/GET A NOP INSTRUCTION			/A020
/D023;	DCA I	ILYINT		/OVERLAY JMS TO THIS ONCE ONLY ROUTINE	/A020
XDLYEX,	JMP I	XDELAY		/RETURN				/A020

IMNXDL,	MNXDLY+MUBUF	/ADDRESS OF VARIABLE IN MENU AREA		/A020
/D023;ILYINT,	DLYINT		/ADDRESS OF ENTRY JMS TO X DELAY		/A020
IDLY1X,	DLY1X			/ADDRESS OF TIMES ONE CONSTANT		/A020
IDLY3X,	DLY3X			/ADDRESS OF TIMES 3 CONSTANT		/A020
IDLY6X,	DLY6X			/ADDRESS OF 6 etc.			/A020
IDLY18,	DLY180			/ESTIMATED AT  3 MIN.			/A020

*BUFBL2+BUFSIZ+7		/CONTINUE WITH BUFFER DEFINITIONS	/A020
BUFBL3,	BUFBL4			/ LINK BUFF 3 TO BUFF 4.		/A023
	ZBLOCK BUFSIZ+6							/M023
BUFBL4,	BUFBL5			/ LINK BUFF 4 TO BUFF 5.		/A023
	ZBLOCK BUFSIZ+6 						/M023
BUFBL5,	0			/ BUFF 5 IS GROUNDED BECAUSE IT'S LAST.	/A023
	ZBLOCK BUFSIZ+6

/
/	USED FOR THE INPUT ROUTINES FOR CHECKING FOR A VALID ENTRY
/
TOKOFF,	0
TOKBUF,	-7
	ZBLOCK 10

/D023;/
/D023;/	THIS IS THE BUFFER USED BY THE DOCUMENT LIST ROUTINE.  DX IS ALOWED TO
/D023;/	RECEIVE UP TO 8 DOCUMENTS FROM A AX SYSTEM ON REQUEST. THE LIST IS STORED
/D023;/	HERE IN THE FORMAT:
/D023;/
/D023;/	OPEN CODE -1 = OVERWRITE; 0 = TOP; 1 = BOTTOM
/D023;/
/D023;DOCLSA,
/D023;	ZBLOCK LSTSIZ+1


/
/	MESSAGES
/
/THERE IS NO APPARENT REASON TO DO AN ERASE TO END OF LINE SO WE
/CAN MAKE THESE TWO COMMAND STRINGS TO IOA THE SAME. ALSO, THIS LITTLE
/CHANGE FIXES THE PROBLEM OF PACKET ERRORS WHEN THE 278 IS RECEIVING
/A DOCUMENT AT GREATER THAN 600 BAUD. THERE IS STILL A PROBLEM AT 19200
/BAUD. SOMEONE SHOULD LOOK AT IOA TO SEE HOW IT IS DOING THE ERASE TO
/END OF LINE AS IT IS THE CULPRIT. WE APPARENTLY LOOSE INPUT CHARACTERS
/FROM THE HOST WHEN DOING THE ERASE TO END OF LINE IN A 278	/A009

NUMDIS,/TEXT '^P!L!D'						/D009
BLKDS2,	TEXT '^P!D'
DRVSTR,	TEXT	/!D/
DATSTR,	ZBLOCK	27		/ filled in w/ the DATE & TIME string.
OKSTMT,	IFDEF ENGLSH < TEXT '^P - RECEIVED' >
	IFDEF ITALIAN < TEXT '^P - RICEVUTO' >
	IFDEF V30NOR <TEXT  '^P - MOTTATT'>
	IFDEF V30SWE <TEXT  '^P - MOTTAGEN'>
/
MESSTM,	IFDEF ENGLSH < TEXT '^P!L&MESSAGE: ^A' >
	IFDEF ITALIAN < TEXT '^P!L&MESSAGGIO: ^A' >
	IFDEF V30NOR < TEXT '^P!L&MELDING: ^A' >
	IFDEF V30SWE < TEXT '^P!L&MEDDELANDE: ^A' >
/

CONSTM,	IFDEF ENGLSH < TEXT '^P!L&CONNECTION ESTABLISHED'>		/A031
	IFDEF ITALIAN < TEXT '^P!L&CONNESSIONE IN CORSO' >
	IFDEF V30NOR < TEXT '^P!L&FORBINDELSE OPPRETTET'>
	IFDEF V30SWE < TEXT '^P!L&UPPKOPPLINGEN \DR KLAR'>

PRBSTM,	IFDEF ENGLSH < TEXT '^P!L&PROBLEM: ^A'>				/A031
	IFDEF ITALIAN < TEXT '^P!L&PROBLEMA: ^A' >
	IFDEF V30NOR <TEXT '^P!L&PROBLEM: ^A'>
	IFDEF V30SWE <TEXT '^P!L&PROBLEM: ^A'>


BYESTM,	IFDEF ENGLSH < TEXT '^P!L&BYE: ^A' >
	IFDEF ITALIAN < TEXT '^P!L&BYE: ^A' >
	IFDEF V30NOR <TEXT '^P!L&ADJ\X: ^A'>
	IFDEF V30SWE <TEXT '^P!L&STANNA: ^A'>
/
MSGPRG,	IFDEF ENGLSH < TEXT '^P!L&MESSAGE SENT' >
	IFDEF ITALIAN < TEXT '^P!L&MESSAGGIO INVIATO' >
	IFDEF V30NOR < TEXT '^P!L&MELDING SENDT'>
	IFDEF V30SWE < TEXT '^P!L&ETT MEDDELANDE \DR S\DNT'>
/
PMTMES,	TEXT '^P^A^P'
/
CLALIN,	TEXT '^P!L'
BTLINE,	TEXT '^A'
TIMSTR,/TEXT	/^P^A!L/
OUTLN,	TEXT '^P!L^A'
INITYP,	TYPHIT 			/ HAS TO BE JUST BEFORE THE SYSTYP
SYSTY1,	0

	IFDEF ENGLSH <
	"Y-200 			/ Y
	"o-200 			/ o
	"u-200 			/ u
	" -200 			/
	"a-200 			/ a
	"r-200 			/ r
	"e-200 			/ e
	" -200 			/
	"c-200 			/ c
	"o-200 			/ o
	"n-200 			/ n
	"n-200 			/ n
	"e-200 			/ e
	"c-200 			/ c
	"t-200 			/ t
	"e-200 			/ e
	"d-200 			/ d
	" -200 			/
	"t-200 			/ t
	"o-200 			/ o
	" -200 			/
	"a-200 			/ a
	" -200 			/
	> 			/ End IFNDEF ENGLSH

	IFDEF ITALIAN <
	"C-200
	"o-200
	"n-200
	"n-200
	"e-200
	"s-200
	"s-200
	"i-200
	"o-200
	"n-200
	"e-200
	" -200
	>			/ End IFDEF ITALIAN

	IFDEF V30SWE <
	"K-200 			/ k
	"o-200 			/ o
	"p-200 			/ p
	"l-200 			/ l
	"e-200 			/ e
	"t-200 			/ t
	" -200 			/
	"t-200 			/ t
	"i-200 			/ i
	"l-200 			/ l
	" -200 			/
	"e-200 			/ e
	"t-200 			/ t
	" -200 			/
	> 			/ End IFDEF V30SWE

	IFDEF	CONDOR	<						/A021
	"D-200			/ D	CONNECTED TO		/A036/M021/A008
	"M-200			/ M	DECMATE			/A036/M021/A008
	>			/END IFDEF CONDOR			/A021
	IFNDEF	CONDOR	<						/A021
	"V-200			/ V	SET UP MESSAGE		/M021/A008
	"T-200			/ T	SAYING THAT CONNECTED	/M021/A008
	"2-200			/ 2	TO A "VT278" IN		/A008
	"7-200			/ 7	AX OR DX MODE		/M021/A008
	"8-200			/ 8				/M021/A008
	>			/END CONDOR NDEF			/A021
	" -200 			/ Space
	IFDEF ENGLSH <
	151 			/ i
	156 			/ n
	>
	IFDEF ITALIAN <
	"p-200
	"e-200
	"r-200
	>
	IFDEF V30NOR <
	" -200
	"i-200 			/ i
	" -200
	>
	IFDEF V30SWE <
	" -200
	"i-200 			/ i
	" -200
	>
/
	" -200 			/ Space
/
	IFDEF ENGLSH <
SYSTY2,	"D-200
SYSTY3,	"X-200
	>
	IFDEF ITALIAN <
SYSTY3,	"T-200
SYSTY2,	"D-200
	" -200
	"a-200
	"t-200
	"t-200
	"i-200
	"v-200
	"a-200
	>

	IFDEF V30NOR <
SYSTY2,	"D-200
SYSTY3,	"X-200
	>
	IFDEF V30SWE <
SYSTY2,	"D-200
SYSTY3,	"X-200
	>
	0
/
ENDFD1=.
	0			/ 1st word of KB: input buffer (INBUFA)	/A023

/
/	USE OF THE AREA PAST ENDFD1
/
	INBUFA=ENDFD1 		/ THE END OF THE FIRST FIELD AT ASSEMBLY TIME (ENDFD1)
				/ INPUT FROM THE KEYBOARD (INBUFA)
	INBUFM=100 		/ BUFFER MAX
	ENDINB=INBUFA+INBUFM 	/ THE VALUE OF THE LAST WORD USED FOR THE INPUT BUFFER
	EXTSPC=ENDINB+1 	/ THE UNUSED AREA IN THE LAST BLOCK 7400 - 7777
/
/	THIS IS THE PART OF WPTRNS THAT IS IN THE AREA ENDFD1 TO 7777.  THE REASON THAT
/	IT IS A SEPERATE AREA IS FOR ASSEMBLY REASONS. THIS AREA IS OCUPIED BY
/	OS-8 SO CANNOT USE WHEN LOADING OUT.  FOR THIS REASON IT IS ASSEMBLED OUT
/	IN FIELD 2 BUT IS LOADED AT THE SAME TIME WPTRNS IS.
/
	IFNDEF DECDEV <
	FIELD 2
	>
	IFDEF DECDEV <
	FIELD 4
	>

	*EXTSPC 		/ VALUE FOR THE END OF THIS AREA USED BY BUFFERS
/

/
/	DOMENU - Displays the MENU following the point of call. If the menu is
/	being displayed because of a packet received then the prompt version of
/	the MENU is displayed.
/
/
/CALL:	JMS	DOMENU
/		MENU block # to call.
/	 GOLD MENU return
/	Normal return
/
DOMENU,	XX
	CLA			/ Inititialize.
	TAD I	DOMENU		/ Get MENU to call.
	DCA	DOMEN2		/  ...
	ISZ	DOMENU		/ Bump to return address.
	TAD	PMTTMP 		/ TELL THE MENU IF CALLED BY A PROMPT
	CDFMNU
	DCA I	(MUBUF+MNTMP1)
	TAD	AXPMT 		/ THIS SETS FOR A SPECIAL TYPE OF PROMPT NEEDED FOR AX
	DCA I	(MUBUF+MNTMP2)
	DCA I	(MUBUF+MNTMP3)	/ Initializing call.
	CDFMYF
	TAD	TOKOFF		/ First time, use any prior input.
DOMEN1,	JMS	CPYITM		/  ...
	JMS	BUFSET		/ CHANGE BUFFER LENGTH TO 64 CHARS.	/A032
	CIFMNU
	JMS I	MNUCAL
DOMEN2,		XX
	JMS	BUFRST		/ RESTORE BUFFER LENGTH			/A032
	AC7776			/ First we check for Gold:MENU return (2).
	CDFMNU			/ Map menu field.
	TAD I	(MUBUF+MNTMP3)	/ Get return value.
	CDFMYF			/ Map our field.
	SNA			/ Skip if NOT GOLD:MENU.
	 JMP	DOMEN4		/ JMP to take the GOLD:MENU return.
	SMA CLA			/ Skip if have to call menu again.
	 JMP	DOMEN3		/ Jmp to do final return.
	TAD	(DOCNBF)	/ 2nd time (& thereafter) use default filename.
	JMP	DOMEN1		/ Go process it.

DOMEN3,	JMS	INITKF		/ init TOKBUF to start of INBUFA area.
	JMS	DXCOPY		/ copy input
		CDFMNU		/  from menu
		MUBUF+MNIBUF	/   input area,
		CDFMYF		/  to our
		INBUFA		/   input area.
	ISZ	DOMENU		/ Take normal return.
DOMEN4,
	JMP I	DOMENU		/ Return to caller.

INITFN,	XX			/ Entry point.
	TAD	AXPMT		/ See if we're supposed to use 'remembered fnam''
	TAD	PMTTMP		/ If both 0 then yes.
	SZA CLA			/ Skip if both 0 (ie yes).
	 JMP	INIFN2		/ Jmp to use current DOCNBF.
	TAD	(DOCNBF)	/ Create ptr to where to put default filename.
	DCA	SENXXX		/ Save in an temp.
	CDFMNU			/ We're supposed to use 'remembered filename'
	TAD I	(MUBUF+MNDRV)	/ Get drive of remembered doc.
	DCA	T1		/ Save in temp.
	TAD I	(MUBUF+MNFNAM)	/ Get menu pointer to file name.
	DCA	INIFN0		/ save for later.
	TAD I	(MUBUF+MNFNO)	/ Now see if there is one available.
	CDFMYF			/  ...
	SNA CLA			/ Skip if yes.
	 JMP	INIFN1		/ Jmp if no. Set 'NO DEFAULT'.
	AC7777			/ See if drive is drive 1.		/A029
	TAD	T1		/  ...					/A029
	SNA CLA			/ Skip if no. We must convert & output it/A029
	 JMP	INIFN3		/ Don't output default drive 1.		/A029
	CIFMNU			/ Convert to ascii.
	JMS I	IOACAL		/  ...
		MYROUT		/
		DRVSTR		/ text string to convert drive number to ascii.
		T1		/ pointer to where it is.
INIFN3,	JMS	DXCOPY		/ Copy filename string
		CDFMNU		/  from menu area,
INIFN0,		MUBUF+MNFNAM	/   ...
		CDFMYF		/  to our input string area.
SENXXX,		XX		/ Address of where to copy filename to.
	AC7777			/ Now to remove terminating space.
	TAD	X2		/ X2 was pointing to terminating null.
	DCA	SENXXX		/ So now SENXXX points to previous character.
	TAD I	SENXXX		/ See if that prior character is a blank space.
	TAD	(-40)		/  ...
	SNA CLA			/ Skip if no. If yes, then zap it.
INIFN1,	DCA I	SENXXX		/ Zap Default filename pointer.
INIFN2,	JMP I	INITFN


MYROUT,	XX			/ XFLD callable from MENU IOA call.
	DCA	T2		/ Save char in our temp.
	RDF			/ Get calling field.
	TAD	CIDF0		/ Make into a return CDI instruction.
	DCA	MYEXIT		/ save for exit.
	CDFMYF			/ Map our field.
	TAD	T2		/ Get character being output.
	SNA			/ Skip if not terminator.
	 TAD	(".&177)	/ Convert terminator to a period.
	DCA I	SENXXX		/ Stuff in buffer.
	ISZ	SENXXX		/ Bump pointer.
MYEXIT,	CDIMNU			/ Return to IOACAL processor.
	JMP I	MYROUT		/  ...

/
/
/	SETSIX - sets the XFIELD call vector in page 0 to their appropriate
/	values. At startup, the list entries contain the address of the
/	address (in the BUF field) of the routine. The list starts with
/	location CLASXA & is terminated with a zero entry.
/
SETSIX,	XX
	TAD	(CLASXA)	/ get address of list.
	DCA	T1		/ Save in a temp.
SETSX1,	TAD I	T1		/ Get address of address.
	SNA			/ Skip if not done.
	 JMP I	SETSIX		/ Return when done.
	DCA	T2		/ Save.
	CDFBUF
	TAD I	T2		/ Get address of routine.
	CDFMYF
	DCA I	T1		/ Save address in vector table.
	ISZ	T1		/ Bump to next entry.
	JMP	SETSX1		/ Go process it.

TRNCN7,	JMS	RESETS		/ DISPLAY FIRST SCREEN			/A039
	JMP	MAINL3		/ NOW GO TO KB LOOP			/A039

/------------
	PAGE

/
/	IF SET FOR 102 THEN THE LOG DOCUMENT HAS TO BE UNLOCKED IF USED
/
/RTN102,XX
/
/	CLA 								/D017
/	CDFBUF
/	TAD I	(AXLRT) 	/ GET THE ADDRESS OF THE ROUTINE THAT WILL UNLOCK
/	CDFMYF
/
/	DCA	T1
/
/	CIFBUF 			/ UNLOCK LOG FILE
/	JMS I	T1
/
/	JMP I	RTN102
/

/
/	THE SEND AND RECEIVE PART OF AX
/
AXRRTN,	AC0001
AXSRTN,	DCA	TEMP 		/ ZERO =RECEIVE AND 1 = SEND
	JMS	FIL2BF 		/ FILL THE DOCNBF BUFFER AND RELEASE THIS ONE
	JMP	AXRT3 		/ SEE IF THE KEYBOARD ROUTINE IS USEING THE MENU
AXRT4,	JMS	INIWAT 		/ DO A JWAIT AND THEN CHECK SPFLAG
				/ HAVE TO CHECK SPFLAG TO AVOID AN INFINITE LOOP
	JMP	HSTWAT 		/ RETURN AND WAIT AT MAIN LOOP

AXRT3,	TAD	DISTMP
	SZA CLA 		/ ++++
	 JMP	AXRT4
	AC7777			/ SET FLAG BEFORE ENTERING THIS SECTION	/A039
	DCA	DISTMP		/					/A039
	JMS	CLASTA		/ CLEAR THE FLAGS FOR A TRANSFER	/C031
	TAD	TEMP 		/ TELL THE OTHER FIELD WHICH MODE TO GO TO
	CIFBUF
	JMS I	AXSRA
		DOCNBF			/ THE ADDRESS OF THE POINTER TO THE BUFFER RECEIVED
/D039	 JMP	HSTWAT 		/ NO RETURN
	 JMP	AXRTNO		/ NO RETURN				/A039
	DCA	DOCNO 		/ SAVE THE DOCUMENT NUMBER
	MQA
	DCA	DOCMOD 		/ AND THE MODIFICATION VALUE
	AC0002
	TAD	TEMP 		/ SET THE PROMPT FLAG SO WHEN THE ANSWER PAKCET IS
				/ SENT THE TRANSFER WILL BE ACTIVATED
				/ SINCE IT WILL NOW ACT LIKE THE ANSWER TO A
				/ SEND OR RECEIVE PROMPT
	DCA	PMTTMP
	TAD	TEMP 		/ IF SET FOR RECEIVE OR SEND SET THE CORRECT FLAG
	SNA CLA 		/ ++++
	JMP	AXRT2
	ISZ	SNDAD 		/ SET AX SEND FLAG
/D039	JMP	HSTWAT
	JMP	AXRTNO		/					/A039
AXRT2,	ISZ	AXREC 		/ SET AX RECEIVE FLAG
AXRTNO,	CLA			/ 					/A039
	DCA	DISTMP		/ CLEAR DISTMP BEFORE LEAVING		/A039
	JMP	HSTWAT 		/ RELEASE BUFFER


/
/	MDRTN - THE ROUTINE WILL ASK THE DX USER HOW TO MODIFY THE DOCUMENT
/	ON THE AX SIDE.  THE TYPMOD PACKET WILL ONLY BE SENT TO THE DX USER IF THE
/	DX USER IS SENDING A DOCUMENT TO AX AND THAT DOCUMENT ALREADY EXITS
/	ON THE AX SIDE.
/
/	THE VALUE OF THE FIRST BYTE OF THE PACKET IS USED TO TELL WHICH
/	OPTIONS CAN BE CHOSEN.  SINCE THE ONLY TWO THAT
/	MEAN ANYTHING RIGHT NOW IN THE PROGRAM IS TOB AND BOTTOM OR TOB BOTTOM AND
/	OVERWRITE, THESE TWO CHOICES ARE LOOKED FOR.
/
/	ALL VALUES THAT COULD EXIST IN THE FIRST BYTE
/
/	40	NONE
/	41	TOP
/	42	BOTTOM
/	43	TOP AND BOTTOM
/	47	ALL
/
/	THE VALUES RETURNED IN THE PROMPT ANSWER PACKET IS ALSO THE
/	FIRST CHARACTER USED. THE VALUES ARE:
/
/	40	GOLD MENU TYPED
/	41	OVERWRITE
/	42	TOP
/	43	BOTTOM
/
MDRTN,	TAD	(-43) 		/ IF NOT TOP AND BOTTOM (43) ASSUME ALL FOR NOW
	TAD	DOCNBF
	SNA CLA 		/ ++++
	AC0001 			/ 1= TOP AND BOTTOM 0 = ALL
	JMS	ASKMOD 		/ DISPLAY THE OPTIONS
		DLMA15		/  and get the choice.
	JMS	SETOPT		/ RE-SET OPTIONS & CLA. GOLD MENU IS 40 /A017
	TAD	(40) 		/ SEND THE RESPONSE PLUS 40 TO MAKE IT A VALID CHARACTER
				/ TO SEND DOWN THE COM LINE.
	DCA	INBUFA
	DCA	INBUFA+1
	DCA	DOCNBF		/ Clear out DEFAULT filename.
	DCA	PMTTMP 		/ CLEAR THE FLAG DONT WANT TO ACT LIKE A NORMAL PROMPT
	AC0001 			/ SET VALUE FOR RETURN PACKET TYPE
	JMP	SNDPP2 		/ GO AND SEND RESPONSE

/
/	SNDQIT - WILL SEND A QUIT MESSAGE TO THE OTHER SYSTEM NOT CARING IF THE OTHER
/	SYSTEM GETS IT OR NOT .  IT TELLS THE OTHER SYSTEM THAT THIS USER IS GOING TO
/	THE MAIN MENU.
/
/D041SNDQIT,	XX
/D041	AC7777 			/ ++++
/D041	JMS	HOSTOU 		/ CLEAR THE OUTPUT BUFFER IF THERE IS ANYTHING
/D041	CLA 			/ FOR THE SKIP RETURN

SNDQT2,				/ TEST FOR TRANSFER COMPLETE		/A041
	TAD	SENDFL		/					/A041
	SNA CLA			/ 0 = TRANSFER COMPLETE			/A041
	JMP	SNDQT3		/					/A041
	TAD	(CR)		/ PACKET TERMINATOR			/A041
	JMS	HOSTOU		/ SEND IT				/A041
	CLA			/ FOR THE SKIP RETURN			/A041
SNDQT3,	TAD	(QUIT)
	JMS	DXOCPK 		/ GENERATE A COMMAND
	TAD	(CMDBUF-1) 	/ SEND IT
	DCA	X1
SNDQIL,	TAD I	X1
	SNA 			/ ++++
	JMP	SNDQI2 		/ SEND THE CR
	JMS	HOSTOU
	JMP	DXOSQR		/ BUFFER FULL RETURN			/M041
	JMP	SNDQIL
SNDQI2,	TAD	(CR)
	JMS	HOSTOU
	NOP
	JMP	DXOSQR		/ RETURN TO DX OUTPUT ROUTINE		/M041

/
/	ASKMOD - DISPLAY THE MENU FOR THE OPTIONS TO A DOCUMENT THAT ALREADY
/	EXISTS. IF MNTMP3 IS SET TO ZERO ALL OPTIONS ARE GIVEN, IF SET TO 1
/	THEN ALL BUT OVERWRITE. THIS CAN BE EXPANDED TO DISPLAY ANY COMBINATION
/	DESIRED, BUT THE ONLY TWO THAT ARE USED ARE THESE. THE MENU IS ONLY SET
/	FOR THESE TWO OPTIONS BUT THE PROTOCOL CAN HANDLE ANY.
/	IT CAN BE ALSO CALLED FOR ANY OTHER MENU BESIDES DLMA15. THE MENU IS
/	FOLLOWS THE CALL AND THE AC CONTAINS THE VALUE TO SET MNTMP3.
/	THIS IS USEFUL WHEN CALLING DLMA15 BUT CAN BE USED BY ANYONE.
/
ASKMOD,	XX
	CDFMNU
	DCA I	(MUBUF+MNTMP3)
	CDFMYF
	TAD I	ASKMOD		/ Get MENU to call.
	ISZ	ASKMOD		/ Bump past argument.
	DCA	ASKMO4 		/ STORE THE MENU TO CALL
	JMS	BUFSET		/ LIMIT INPUT BUFFER TO 64 CHARS	/A032
	CIFMNU
	JMS I	MNUCAL		/ Get option (Top, Bottom, Overwrite)
ASKMO4,		XX
	JMS	BUFRST		/ RESTORE BUFFER LENGTH			/A032
	CDFMNU			/ Get MNTMP1 response.
	TAD I	(MUBUF+MNTMP1)	/  ...
	CDFMYF			/ Back to our field.
	SZA			/ Skip if GOLD:MENU. Return the value.
	ISZ	ASKMOD 		/ OK RETURN
	JMP I	ASKMOD		/ Return to caller.
/
/
/
/	THIS ROUTINE WILL CHANGE THE MENU INPUT BUFFER LENGTH TO 64 CHARS.
/	THIS WORD AT (MNILEN) MUST BE RESTORED UPON RETURN FROM THE MENU CALL
/
BUFSET,	XX			/					/A032
	CLA			/					/A032
	CDFMNU			/					/A032
	TAD I	(MUBUF+MNILEN)	/ FETCH PRESENT LENGTH			/A032
	CDFMYF			/					/A032
	DCA	BUFLEN		/ SAVE HERE				/A032
	TAD	(-BUFSIZ-1)	/ A NEG 64				/A032
	CDFMNU			/					/A032
	DCA I	(MUBUF+MNILEN)	/ INSTALL VALUE				/A032
	CDFMYF			/					/A032
	JMP I	BUFSET		/					/A032
/
/
/
/	THIS ROUTINE WILL RESTORE THE MENU BUFFER LENGTH THAT WAS
/
/	CHANGED BY BUFSET
/
/
BUFRST,	XX			/					/A032
	CLA
	TAD	BUFLEN		/ FETCH OLD VALUE			/A032
	CDFMNU			/					/A032
	DCA I	(MUBUF+MNILEN)	/ BACK INTO MENU FIELD			/A032
	CDFMYF			/					/A032
	JMP I	BUFRST		/					/A032
BUFLEN,	0			/ STORAGE FOR BUFFER LENGTH		/A032


/-------------
	PAGE


