/ WPEDOV - EDITOR OVERLAYS
/
/
/===============================================================
/
/
/		*******  EDIT HISTORY  *******

/ 240	KMD	23-Sep-85	Add Spanish Xlations and page size checks
/ 239	KMD	17-Sep-85	Add V30 Sveeedish translation IFDEFs
/ 238	KMD	16-Sep-85	Add V30 NORWAY IFDEFS
/ 237	KMD	15-Sep-85	Move TEC8VAL routine to blaster
/ 236	KMD	13-Sep-85	Add Spanish technical changes
/ 235	EMcD	26-Aug-85	Add Insert-Overstrike Mode
/ 234 	MART	16-AUG-85	ADD DUTCH
/ 233	RCME	12-Jul-85	Add new table and code to allow keys
/				returning 8 bit characters on mcs
/				keyboards to generate technical chars.
/ 232	RCME	01-Jul-85	Add new table for allowable 8-bit chars in
/				ruler definitions
/ 231	EMcD	15-May-85	Allow (and show) Breaking Hyphen on Gold 
/				View for MCS chars
/ 230	EMcD	14-May-85	Upper/Lower casing of 8 bit chars
/ 229	EMcD	07-May-85	Allow Swap on Dead key chars
/ 228	EMcD	01-May-85	Allow Search on 8bit chars
/ 227	EMcD	01-May-85	Fix Bug with Swap on Bold char
/ 226	EMcD	30-Apr-85	Change UNDEADing to UNDEAD extended
/				tech and MCS deads.
/ 225	EMcD	26-Apr-85	Moved Gold Swap and allow allow 8 bit in
/				Abbrev doc.
/ 224	rcme	23-Apr-85	Add code and hole to merge overlay to deal
/				with extended field names from MATH module
/				containing multinational and tech characters
/ 223	EMcD	19-Mar-85	Allow line Drawing set for tech chars
/
/-------------------- All mods below refer to V2.0 and earlier --------------
/
/ 222	IHZ	11-JAN-84	Fix HELP MENU display for DECmate I
/ 221	WCE	11-JAN-84	Fix COLUMN CUT ending on spaced line
/ 220	WCE	17-DEC-84	Fix GOLD SEARCH not checking line length
/ 219	WCE	13-DEC-84	Fix GOLD VIEW problem with multiple screens
/ 218	WCE	10-DEC-84	Fix COLUMN STRIP RIGHT of single column
/ 217	WCE	01-NOV-84	Fix GOLD RULER when backing up across screens
/ 216	DFB	31-OCT-84	Fix COLUMN PASTE to paste on correct line
/ 215	WCE	30-OCT-84	Fix COLUMN PASTE pasting extra TAB characters
/ 214	WCE	22-OCT-84	Fix premature GOLD-HALT problem with go-to-page
/ 213	DFB	19-OCT-84	Fix to column strip left when at left margin
/ 212 	EJL	16-OCT-84	Change help column values
/ 211	EJL	26-SEP-84	Fix to uparrow code for ruler problem
/ 210	WCE	24-SEP-84	Search for technical characters
/				Rewrote Search, GSR, Tech Character overlays
/ 209	WCE	20-SEP-84	Fix to List Processing for Caller Routine Call
/ 208	WCE	19-SEP-84	Fix to COLUMN PASTE not pasting CUT text
/ 207	EJL	18-SEP-84	Prevent case change on dead key sequences
/ 206	WCE	13-SEP-84	Fix Go-To-Page zapping search buffer text
/ 205	WCE	11-SEP-84	Move cursor to CUT buffer overflow point
/ 204	WCE	07-SEP-84	Fix for GOLD CUT not bringing rulers like CUT
/ 203	DFB	05-SEP-84	Fixes for Column Cut Paste BUG
/ 202	EJL	04-SEP-84	More fixes for arrow keys and math
/ 201	DFB	29-AUG-84	Fixes for Column Cut Paste
/ 200	GDH	29-AUG-84	Fix for Go-To-Ruler not found within buffer.
/ 199	WCE	28-AUG-84	Fix for Go-To-Ruler not found within buffer
/ 198	WCE	25-AUG-84	Fix for Global Search finding Centered Lines
/ 197	EJL	23-AUG-84	Fix reset of ruler during window change
/ 196	WCE	21-AUG-84	Fix for no error at 50 characters in GSR
/ 195	WCE	20-AUG-84	Fix for GSR not completting replace operation
/ 194	EJL	14-AUG-84	Process math on down arrow
/ 193	EJL	07-AUG-84	Increase speed of column paste
/				Fix ruler status line in ruler edit mode
/ 192	BC	26-JUL-84	Delete SPLTFL, use WIDNAR flag for 80/132
/ 191	WCE	23-JUL-84	Fix for List Processing HALT problem
/ 190	WCE	16-JUL-84	Changes for BRITISH pound sign
/ 189	MP	16-JUL-84	Fix problem with GOLD Menu from G.S. menu
/ 186	BC	16-JUL-84	Add manual screen width choice
/ 185	WCE	10-JUL-84	Fix for HELP key crashing system
/ 184	EJL	09-JUL-84	Fix for storing rulers
/ 183	JAC	08-JUL-84	Changed size of buffer for 100 UDK'S
/ 182	WCE	28-JUN-84	Various bug fixes for the EDITOR
/				Problem redisplaying centered lines after paste
/				Problem with GOLD PAGE and STATUS LINE
/ 181	WCE	27-JUN-84	Rewrote EDITOR MENU page to fix SO-CD problem
/ 180	EJL	26-JUN-84	Extend ruler from 158 to 238
/ 179	GDC	22-JUN-84	Column cut, paste, and strip inserted.
/ 178	MP	17-JUN-84	XXFIND will search for CR, TABS.
/ 177	DKR	01-JUN-84	Added Calls to OVRLOF (turn ruler display
/				 on/off) in OVINIT and OVMENU.  And, Erase
/				  Line if Rulers-Off .AND. Gold:Tab makes a
/				   new ruler
/ 176	DKR	29-MAY-84	Gold:Tab Code (Indent Tabs)
/ 175	EJL	29-MAY-84	Update Technical Character Mapping Table
/ 174	GDC	14-MAY-84	Changes to support second overlay area.
/ 173	WCE	11-MAY-84	Remove all occurances of USERNO
/ 172	EJL	08-MAY-84	Install Technical Character overlay
/				Fixed deadkey and required space
/ 171	WCE	02-MAY-84	Moved Resident Overlay from WPEDOV to WPEDIT
/ 170	WCE	26-APR-84	Fixed problem with LP and SWAP AREA
/ 169	AH	22-MAR-84	Added code for Column Cut
/ 168	WCE	13-MAR-84	Changed reset point from EIFXT2 to EIFIX
/				for SEARCH and CONTINUE SEARCH overlay
/				Changed startup point from EIFIX to EINEXA to
/				correct problem with blocks used display
/ 167	WJY	24-FEB-84	Hang up modem on finish on DMI also
/ 166	WJY	08-FEB-84	DECmate I compatability
/ 165	WCE	19-JAN-84	Made swap area smaller by two blocks
/ 164	EH	18-JAN-84	Removed fix #162
/ 163	EH	09-JAN-84	Do Not destroy UDK's if no next ruler found
/ 162	EH	21-DEC-83	Fix PASTE to insert prior to centered mark
/ 161	GDH	14-DEC-83	Fixed View code to update status line.
/ 160	GDH	14-DEC-83	Changed DSPRUL calling seq. OVRULR effected.
/ 159	EH	08-DEC-83	Fix G-Ruler, G-Menu System Halt
/ 158	DMB	30-NOV-83	Misc bug fixes: (1) GTP no longer winds up
/				on wrong page if it passes empty pages or
/				if the destination new-page-marker is too
/				close to the start of the block;
/				(2) GOLD:BOT and GTP no longer set "MA NO".
/ 157	DMB	12-NOV-83	REWRITE SUBSTANTIAL PORTION OF GOTO-RULER
/				TO FIX SOME PARTICULARLY TRICKY BUGS.
/				EDIT HISTORY ONLY UPDATED FOR ROUTINES
/				NOT EXCLUSIVELY USED BY GOTO-RULER.
/ 156	WCE	17-NOV-83	FIX FOR L.P TO PRINTER NOT SCROLLING AND
/				DUPLICATE WARNINGS FOR LACK OF SPACE
/ 155	DMB	03-NOV-83	FIX VARIOUS GOTO-RULER BUGS
/ 154   WJD     31-OCT-83	MAKE GOLD_BOTTOM ACT LIKE GTP
/				and remove GOLD_HALT process from GTP & GOLD_BOTTOM
/ 153	WCE	27-OCT-83	REMOVED ALL PREVIOUS EDIT HISTORIES FOR
/				NEW VERSION 1.5 SOURCE FILES

/ WRITE OUT CODE FOR THE EDITOR OVERLAYS

	FIELD 0			/ FIELD WHERE RXHAN IS LOCATED
	*200			/ START ADDRESS USED BY OS8 "GO" COMMAND
	JMP I	.+3		/ LOCATION USED TO START UP RXHAN
	JMP I	.+1		/ LOCATION USED TO RETURN TO OS8 MONITOR
	7605			/ ADDRESS OF OS8 MONITOR RETURN POINT
	RXLOAD			/ ADDRESS OF START LOCATION FOR RXHAN

	*RXLDLS			/ ADDRESS WITHIN RXHAN TO OVERLAY
	RXEWT			/ WRITE FUNCTION CODE
	0
	RXQBLK			/ ADDRESS OF QUEUE BLOCK TO USE
	.			/ ADDRESS OF TABLE OF DISK COMMANDS

	DLOEDO   ;0;CDF 30;-17	/ FIELD ONE EDITOR OVERLAYS
	DLOEDO+17;0;CDF 40;-20	/ FIELD TWO EDITOR OVERLAYS
	DLOEDO+37;0;CDF 50;-17	/ FIELD THREE EDITOR OVERLAYS
	0


/
/ MISC GLOBAL SYMBOL DEFINITIONS FOR EDITOR OVERLAYS
/

	CDFMYF=	CDFEDT		/ EDITOR OVERLAY CODE EXECUTES IN EDITOR FIELD
IFZERO	OVLAYM	<OVLAYM=400>	/ INITIALIZE MERGE OVERLAY ADDRESS
	OVRNUM=	0		/ INITIALIZE OVERLAY NUMBER COUNTER ONE
IFZERO	OVLAY1	<OVLAY1=7400>	/ INITIALIZE OVERLAY NUMBER ONE ADDRESS
	OV2NUM=	0		/ INITIALIZE OVERLAY NUMBER COUNTER TWO
IFZERO	OVLAY2	<OVLAY2=7000>	/ INITIALIZE OVERLAY NUMBER TWO ADDRESS

/ RPPGDS (GOTO-PAGE) DESCRIPTOR WORD BIT DEFINITIONS -
/ BIT VALUE:			/ IF SET MEANS:

RPRULR=	4000			/ RULER PRESENT IN THIS BLOCK
RPMTHB= 100			/ MATH BEGINS IN THIS BLOCK
RPMTHO= 100			/ PAGE IS WITHIN A MATH AREA
RPMTHE= 100			/ MATH ENDS IN THIS BLOCK


DH1BL=	55			/ OFFSET INTO HEADER BLOCK # 1
				/ FOR FIRST BLOCK IN DOCUMENT

	FIELD 3

	*0

/***************************************************************************
/****			   START OF OVERLAY				****
/***************************************************************************

	OVRNUM=OVRNUM+200
	OVRBLK=OVRNUM%200+DLOEDO-1 / DISK BLOCK WHERE OVERLAY IS LOADED

	RELOC

	RELOC OVLAY1
	OVRNUM

	OVSTLD=	.-OVLAY1+OVRNUM	/LOAD THIS OVERLAY FOR STRIP
	JMP	OVJRTN

	OVSTPX=	.-OVLAY1+OVRNUM
	JMP	ESSTPX		/SECOND HALF OF STRIP

	OVMRG4=	.-OVLAY1+OVRNUM	/ DISK FULL EXIT POINT FOR MERGE
	IAC
	OVMRG3=	.-OVLAY1+OVRNUM	/ FINAL MERGE OVERLAY
	JMP	XVMRG3

	OVINI1=	.-OVLAY1+OVRNUM 	/ NORMAL EDIT INITIALIZE


	TAD	(-DLSTAT)	/ PICK UP ADDRESS OF STATUS CODE
	CIFMNU			/ CHANGE TO MENU FIELD
	PGSWAP			/ AC=DLSTAT SO JUST READ IN STATUS CODE

/D170 / INITIALIAZE THE SWAP AREA ON THE DISK BY STORING HALT INSTRUCTIONS IN
/D170 / UNUSED LOCATIONS.  ENTER WITH THE DATA FIELD POINTING TO THIS FIELD

/D170	TAD	(SWPEND)	/ POINTER TO FIRST MEMORY LOCATION
/D170	DCA	T1		/ STORE IN TEMPORARY COUNTER
/D170	TAD	(DSSTAT^400+SWPBEG-SWPEND) / NUMBER OF WORDS TO CLEAR
/D170	CIA			/ MAKE COUNT NEGATIVE
/D170	DCA	T2		/ STORE NEGATIVE COUNT OF WORDS TO CLEAR
/D170	CDFMNU			/ CHANGE TO MENU FIELD

/D170 CLRLOP,	TAD	(7402)		/ PICK UP HALT INSTRUCTION
/D170	DCA I	T1		/ STORE IN MENU FIELD
/D170	ISZ	T1		/ BUMP COUNTER TO NEXT ADDRESS
/D170	ISZ	T2		/ INCREMENT COUNTER - SKIP IF DONE
/D170	JMP	CLRLOP		/ NOT DONE, GO DO IT AGAIN

	CDFMYF			/ CHANGE DATA FIELD BACK TO THIS FIELD
	CIFMNU			/ CHANGE INSTRUCTION FIELD TO MENU FIELD
	PGSWAP			/ AC=0, SAVE SWAP AREA & RELOAD MENU CODE

	JMS	MNUGET
	MNFNO
	DCA	FILENO
	DCA	FORMNO 		/ CLEAR FORM NUMBER (USED AS FLAG TO INDICATE
				/    NOT IN LIST PROCESSING
	DCA	FILOPT


/******************** EDITOR MATH INIT CALL ****************************
/ THE FOLLOWING CALL IS MADE TO THE MATH FIELD TO INITIALIZE THE MATH
/ MODULE CODE AND SET "MTHTYP" TO 1 IN THE MATH FIELD IN PREPARATION
/ FOR USING EDITOR MATH. A 1 IS PLACED IN THE AC BEFORE THE CALL TO TELL
/"RTRN4" THAT IT IS TO INIT FOR EDITOR MATH NOT LIST PROCESSING MATH
/ NOTE THAT THIS SAME INIT CALL TAKES PLACE IN "OVEXIT" AND HERE IN
/"OVINI1".

	AC0001			/ SET THE AC = 1
	CIFMTH			/ CHANGE PROGRAM CONTROL TO MATH FIELD
	JMS	RTRN4		/ GO SET "MTHTYP" = 1; AND INIT MATH MODULE

/******************   END MATH INIT CALL   *****************************

	CIFMNU			/ CALL ROUTINE IN FIELD TWO TO LOAD
	JMS I	OLAYCL		/ IN THE EDITOR MATH OVERLAY
		10		/ NUMBER OF THE EDITOR MATH OVERLAY
	DCA	BUFBEG
	TAD	(BUFEND)
	DCA	BUFSIZ

/D171	JMS	CPYBUF
/D171		-200
/D171		CDFMYF
/D171		MGOVLY-1
/D171		CDFMYF
/D171		OVLAYM-1

	TAD	(XGETET)
	DCA	MGPTC1
	TAD	(ESGETX&177+4600)
	DCA	MGPTC2
	TAD	MGPTC2
	DCA	MGPTC3
	TAD	MGPTC3
	DCA	MGPTC4
	CDFSYS
	TAD I	(CLOCK+3)
	MQL 			/ SAVE MINUTES AND HOURS AT
	TAD I	(CLOCK+4) 	/ START OF EDIT
	CDFMYF
	DCA	OLDHR
	MQA
	DCA	OLDMIN
	TAD	(WIDTH-COLM81)	/ SET TO NARROW SCREEN AT STARTUP	/A186
	DCA	WIDNAR		/ 					/A186
	JMP	OVJRTN


XVMRG3,	DCA	MRGDNC 		/ SET EXIT CONDITION CODE
	CURMOV
	NOP 			/ FINISH WITH STYLE
	JMS	CLR132		/ REVERT TO 80-COLUMN MODE

	PUTESC			/ CLEAR SCREEN
	"[&177+4000
	"2&177+4000
	"J-200

	JMS	PROMPT
	MSGF 			/ SHOW WE'RE ALMOST DONE
	AC7777
	CHKPTR
	SMA CLA
	JMP	.-3 		/ GET TO STX
MRGDNA,	AC0001
	CHKPTR
	SNA
	JMP	.-3 		/ IGNORE NULLS
	SPA CLA
	JMP	MRGDNB 		/ JUMP IF ETX
	TAD I	CURPTR
	PUTSTX 			/ PUT OUT REAL CHAR
	JMP	MRGDNA 		/ AND LOOP FOR ALL

MRGDNB,	TAD	FILENO
	SZA CLA
	JMP	MRGDNF 		/ JUMP IF MERGE TO FILE
				/ ELSE CLOSE PRINTER
	AC7777
	PUTSTX 			/ SET EOF FLAG (AND WAIT FOR PRINTER)
	JMP	MRGDNX 		/ THEN EXIT

MRGDNF,	JMS	DSKCAL
	XDSKCL 			/ CLOSE EDIT FILE

MRGDNX,	CLA
	CDFMYF			/ CHANGE DATA FIELD TO THIS FIELD	  /A170
	CIFMNU			/ CHANGE INSTRUCTION FIELD TO MENU FIELD  /A170
	PGSWAP			/ AC=0, SAVE SWAP AREA & RELOAD MENU CODE /A170

	TAD	MRGDNC 		/ LOAD CONDITION CODE
	JMP	EDEXI3 		/ THEN EXIT

MRGDNC,	.-.

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

	/ MGOVLY MOVED TO WPEDIT RESIDENT AREA BY EDIT 171

/	STRP13	SEARCH FOR NEXT LINE
/
/

ESSTPX,	CDFBUF
	TAD I	CURPTR			/FETCH FIRST CHAR
	JMP	STRP14
STRP13,	ADVSPC
	JMP	STPEX1
STRP14,	AND	P177
	ZZCASE
	STPTB3-1

/	ECNWLN;	STRP15		/NEWLINE COULD BE GOOD
/	ECNWPG;	STPEX2		/NEWPAGE HERE IS NONO
/	ECSTRL;	STPEX2		/SAME WITH RULER	
/	ECMDFL;	STRP16		/MODIFIED FLAG SKIP INC CURSOR
/	0

	ISZ	CURSOR
STRP16,	JMP	STRP13		/GO BACK AND CHECK NEXT CHARACTER	/C218

/D218	STRP16,	CURMOV
/D218	JMP	STPEX1		/EOF IS ACTUALLY CATASTROPHIC FAILURE
/D218	JMP	STRP13		/GO BACK AND CHECK NEXT CHARACTER

STRP15,	TAD I	CURPTR		/WHAT TYPE OF NEWLINE?
	TAD	(-ECSLPT)	/SELECT POINT?
	SNA
	JMP	STRP17		/YES FINISH OUT
	TAD	(ECSLPT-ECNWLN)	/HARD RETURN?
	SZA CLA
	JMP	STPEX1		/NOPE BAD DATA
STRP22,	AC0001
	CURMOV
	JMP	STPEX1		/CATO. ERROR
	TAD I	CURPTR
	AND	P177
	TAD	(-ECNWPG)
	SNA CLA
	JMP	STRP20
	TAD	CURPTR
	DCA	IX1
	TAD	LINE23
	DCA	CURPTR
	BKPPTR
	HLT
	AND	P177
	TAD	(-ECNDRL)
	SNA CLA
	JMP	STRP18
STRP23,	TAD	IX1
	DCA	CURPTR
	JMS	OV2JMP
	OVSTRP

/	STRP18	RULER ABORT
/
/

STRP18,	TAD	IX1
	DCA	CURPTR
	JMP	STPEX1

/	STRP20	CHECK CURRENT PAGE MARK
/
/

STRP20,	TAD I	CURPTR
	TAD	(-ECPCT1)
	SNA
	JMP	STRP25
	TAD	(ECPCT1-ECPCT2)
	SNA CLA
	JMP	STPEX1
	JMP	STRP22
STRP25,	AC0001
	CURMOV
	JMP	STPEX1
	TAD I	CURPTR
	TAD	(-ECSLPT)
	SNA
	JMP	STRP17
	TAD	(ECSLPT-ECPCT2)
	SZA CLA
	JMP	STRP25
	JMP	STRP22


/	STPXE1	EXIT VIA STPNFG
/
/

STPEX1,	JMS	OV2JMP
	OVSNFG

/	STPEX2	EXIT VIA STPEXB
/
/

STPEX2,	JMS	OV2JMP
	OVSEXB

STPTB3,	ECNWLN;	STRP15		/NEWLINE COULD BE GOOD
	ECNWPG;	STPEX2		/NEWPAGE HERE IS NONO
	ECSTRL;	STPEX2		/SAME WITH RULER	
	ECMDFL;	STRP16		/MODIFIED FLAG SKIP INC CURSOR
	0

STPTB4,	ECNWLN;	STRP28
	ECNWPG;	STRP28
	ECTAB;	STRP28
	0

STPTB5,	ECNWLN;	STRP12			/NO COLUMN TO STRIP
	ECNWPG;	STPNFG			/BAD DATA FORMAT
	ECTAB;	STRP28
	0

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

/***************************************************************************
/****			   START OF OVERLAY				****
/***************************************************************************

	OVRNUM=OVRNUM+200 	/ OVERLAY NUMBER
	OVRBLK=OVRNUM%200+DLOEDO-1 / DISK BLOCK WHERE OVERLAY IS LOADED

	RELOC

	RELOC OVLAY1
	OVRNUM 			/ CURRENT OVERLAY CONTENTS

	IFDEF	FORIN	<
	ACCENT=	.-OVLAY1+OVRNUM
	JMP	XCCENT
			>	/ END IFDEF FORIN

	OVSPCE=	.-OVLAY1+OVRNUM
	TAD	FORMNO
	SNA CLA
	JMP	EISPCE
	OVLJMP
	OVMRG4 			/ QUIT NOW IF MERGING

	OVSPC2=	.-OVLAY1+OVRNUM
	ISZ	BLKALM		/ FORCE HARD LIMIT
	JMP	EISPCE


	OVINIT=	.-OVLAY1+OVRNUM / CURRENT OVERLAY

	TAD	RPBIN1		/ EXCLUSIVE GOTO PAGE FLAG
	SMA CLA			/ DONT' CLEAR SCREEN IF GOTO PAGE

	JMS	CLR132		/ REVERT TO 80 COLUMNS
	CDFFIO
	DCA I	(SCFSPC)	/ CLEAR SPACE LEFT INDICATOR
	CDFMYF
	TAD	FILENO 		/ GET THE OUTPUT FILE NUMBER
	SNA			/ CHECK FOR LIST PROCESSING TO A PRINTER
	JMP	INIX00		/ YES, SKIP AROUND DOCUMENT RELATED ITEMS
	MQL
	TAD	FILOPT 		/ SAVE FILE #, SET NORMAL OPTION
	JMS	DSKCAL
	XDSKIN 			/ INIT FILE
	SZA
	JMP	EDEXI3 		/ QUIT IF OPEN FAILED

	JMS	HDRGET
	HDRPSZ 			/ CHECK PAGE SIZE
	SZA CLA
	JMP	.+5 		/ IF ZERO,
	JMS	MNUGET
	MNPGSZ 			/ GET DEFAULT PAGE SIZE
	JMS	HDRPUT
	HDRPSZ 			/ AND PUT TO HEADER

	JMS	HDRGET 		/ GET FILE SIZE FROM DOCUMENT HEADER
	HDRFSZ 			/ POINTER TO FILE SIZE
	JMS	MNUPUT 		/ STORE FILE SIZE FOR STATUS LINE
	LINUSD-MUBUF		/ LOCATION FOR BLOCKS USED IN DOCUMENT

	JMS	MNUPUT 		/ CLEAR BLOCKS FREE FOR STATUS LINE
	LINFRE-MUBUF		/ LOCATION FOR BLOCKS FREE IN DOCUMENT

	JMS	MNUPUT 		/ CLEAR HIGH ORDER PAGE NUMBER
	LINPGH-MUBUF		/ HIGH ORDER PAGE NUMBER IN DOCUMENT

	AC0001			/ SET TO A COUNT OF ONE
	JMS	MNUPUT 		/ STORE PAGE NUMBER FOR STATUS LINE
	LINPGL-MUBUF		/ LOW ORDER PAGE NUMBER IN DOCUMENT

	AC0001			/ SET TO A COUNT OF ONE
	JMS	MNUPUT 		/ STORE LINE NUMBER FOR STATUS LINE
	LINNUM-MUBUF		/ LOCATION FOR LINE NUMBER IN DOCUMENT

/D157	TAD	(3777)		/ CLEAR DON'T-DISPLAY-MSG FLAG
/D157	AND	RPBIN1		/ FROM UNIQUE GOTO PAGE WORD
/D157	DCA	RPBIN1

/D156	TAD	FORMNO		/ GET THE FORM NUMBER
/D156	SZA CLA			/ ARE WE MERGING (LIST PROCESSING)
/D156	JMP	INIX01		/ YES, PICK UP MAXIMUM NUMBER OF LINES
/D156	JMS	MNUGET		/ NO, THEN SET UP FOR SCROLLING AREA
/D156	MNSTAT			/ PICK UP NUMBER OF STATUS LINES
/D156	CIA			/ MAKE NEGATIVE FOR SUBTRACT
/D156	INIX01,	TAD	(NPTRS)	/ PICK UP MAXIMUM NUMBER OF LINES
/D156	DCA	SCRNLN		/ SAVE FOR USE BY EDITOR ROUTINES

	TAD	(-24) 		/ USE 20 AS CUTOFF AT ALL TIMES
INIX00,	DCA	SPCCHK		/ FOR L.P. TO A PRINTER, USE A VALUE OF ZERO
	DCA	BLKALM		/ CLEAR SPACE ALARM FLAG
/D156	DCA	BLWTCH		/ CLEAR FREE BLOCK WATCH WORD

	TAD	FORMNO		/ GET THE FORM NUMBER			/A156
	SZA CLA			/ ARE WE MERGING (LIST PROCESSING)	/A156
	JMP	INIX01		/ YES, PICK UP MAXIMUM NUMBER OF LINES	/A156
	JMS	MNUGET		/ NO, THEN SET UP FOR SCROLLING AREA	/A156
	MNSTAT			/ PICK UP NUMBER OF STATUS LINES	/A156
	CIA			/ MAKE NEGATIVE FOR SUBTRACT		/A156

INIX01,	TAD	(NPTRS)		/ PICK UP MAXIMUM NUMBER OF LINES	/A156
	DCA	SCRNLN		/ SAVE FOR USE BY EDITOR ROUTINES	/A156

/ +++	Modify RULOFF Case-Table to turn Display-Rulers ON or OFF.	/a177
/									/a177
/	MNSTAT = 0 or 1 ... Ruler Display ON				/a177
/	MNSTAT = 2 or 3 ... Ruler Display OFF				/a177
/									/a177
	JMS	OV2JMP		/ LOAD OVERLAY 2			/a177
	OVRLOF			/ Adjust Case-Table and Continue	/a177


/ INITIALIZE EDIT PAGE 0 CONTROL WORDS
	JMS	CLRMEM		/ CLEAR MEMORY
		SINZRO-1	/ FROM
		-NINZRO		/ - NUMBER OF LOCATIONS
		CDFEDT		/ CDF INSTRUCTION

/ INITIALIZE EDIT MATH PAGE 0 CONTROL WORDS
	JMS	CLRMEM		/ CLEAR MEMORY
		MF5P0ET-1	/ FROM
		-LMF5P0ET	/ - NUMBER OF LOCATIONS
		CDFLP		/ CDF INSTRUCTION

/	INITIALIZE EDIT BUFFER

	AC7777 			/ SET POINTER TO BUFFER_BEGIN - 1
	TAD	BUFBEG
	DCA	X0
	CDFBUF
	TAD	(ECBFBG) 	/ GET BUFFER BEGIN CODE
	DCA I	X0 		/ INSTALL AT TOP OF BUFFER
	TAD	(ECSTX) 	/ GET START OF TEXT CODE
	DCA I	X0 		/ INSTALL IN NEXT BUFFER LOCATION
	TAD	(ECETX) 	/ GET END OF TEXT CODE
	DCA I	X0 		/ INSTALL IN NEXT BUFFER LOCATION
	TAD	X0 		/ SET CURPTR TO POINT AT ETX CHAR. THAT
				/  WAS JUST INSTALLED
	DCA	CURPTR

/ CLEAR THE REST OF THE BUFFER
	TAD	BUFSIZ 		/ SET COUNTER FOR NO. OF WORDS TO CLEAR
	CIA
	TAD	(4)
	DCA	X1
	DCA I	X0 		/ CLEAR ONE LOCATION
	ISZ	X1 		/ SKIP IF: FINISHED
	JMP	.-2 		/ NOT FINISHED! DO THE NEXT LOCATION!

	TAD	(ECBFND) 	/ INSTALL BUFFER_END CHARACTER
	DCA I	X0

/	INITIALIZE SCREEN
/	***

/ INITIALIZE EDITOR'S PTRBLK (POINTER_BLOCK) TABLE
	CDFMYF
	JMS	CLRMEM		/ CLEAR MEMORY
		PTRBLK-1	/ FROM
INIXLN,		-NPTRS+1	/ - NUMBER OF LOCATIONS
		CDFEDT		/ CDF INSTRUCTION
	TAD	CURPTR 		/ SET LAST LOC. IN PTRBLK = CURPTR
	DCA I	X0

	TAD	CURPTR 		/ INITIALIZE LINE 23 POINTER		/A157
	DCA	LINE23							/A157
	DCA	CURSOR 		/ CLEAR CURSOR				/A157
	DCA	LOWLIM		/ CLEAR LOLIM				/A157

	AC7777			/ A180
	CIFMNU
	PGSWAP

/ CLEAR CURRENT RULER IF NOT DOING GOTO-PAGE, GOLD:BOT, OR GOTO-RULER;	/A157
/ CLEAR "GOTO-PAGE, GOLD:BOTTOM, OR GOTO-RULER" FLAG.			/A157
	CLA CLL CML RAR		/ L,AC = 04000				/A157
	TAD	RPBIN1		/ LINK=RPBIN1 BIT 0,AC0=-RPBIN1 BIT 0	/A157
	SMA								/A157
	 DCA	RPBIN1		/ CLEAR RPBIN1 BIT 0			/A157
				/ (CLEAR "GTP, GOLD:BOT, OR GTR" FLAG,	/A157
				/  BUT FLAG LIVES ON IN LINK)		/A157

	JMP	INIX04		/ CONTINUE ON NEXT PAGE


	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

/D157 INIX04,	TAD	CURPTR 		/ INITIALIZE LINE 23 POINTER
/D157 	DCA	LINE23
/D157 	DCA	CURSOR 		/ CLEAR CURSOR
/D157 	DCA	LOWLIM		/ CLEAR LOLIM
	/ INHIBIT CLEARING OF CURRENT RULER FOR GOTO-RULER		/A157
INIX04,	SZL CLA			/ G-T-PAGE, GOLD:BOT OR G-T-RULER?	/A157
	 JMP	INIX05		/ YES: PRESERVE CURRENT RULER		/A157
	JMS	CLRULR 		/ NO: CLEAR RULERS
	JMS	COPRUL
INIX05,	TAD	FORMNO							/M157
	SNA
	JMP	.+3
	JMS	DSKCAL
	XRDFIN 			/ INIT FORM FILE IF MERGING
	JMS	LODCHR 		/ GET FIRST CHARACTER
	JMP	INIX03		/ THERE WAS NONE, GO INSERT A RULER
	TAD	(-ECSTRL)	/ IS IT THE START OF A RULER
	SNA CLA 		/ SKIP IF: NOT
	JMP	INIX02		/ RULER FOUND, NO CHANGE NEEDED

/ NO RULER! INSERT ONE!

INIX03,	CDFMYF
	JMS	RLGETS
	JMS	INSRUL 		/ ELSE INSERT RULER 0
	TAD	(ECRMFL)
	JMS	INSRL1 		/ AND RLRMOD CODE
	TAD	LINE23
	DCA	CURPTR 		/ RESET TO START OF MEM

INIX02,	PUTESC 			/ SET APPLICATION KEYPAD MODE
	"=-200
	JMS	SETCUR 		/ GET TO BOTTOM LINE
	AC0003
	DCA	SCRLCT 		/ INIT TO TOP
	TAD	FORMNO 		/ AND START UP RIGHT PROCESS
	SNA CLA
	JMP	TOOVJRTN	/ CHECK AMOUNT OF ROOM ON DISK BEFORE
				/ RESUME OF EDIT OR GTP

/	AC7777			/ SET AC = -1				 /A170
/	CIFMNU			/ CHANGE INSTRUCTION FIELD TO MENU FIELD /A170
/	PGSWAP			/ AC=-1 SO JUST LOAD IN THE SAVE AREA	 /A170

	OVLJMP
	OVMRG2 			/ ... OR MERGE


EISPCE,	
	JMS	CLR132		/ MAKE SURE THE SCREEN IS IN NARROW MODE
	AC0003			/ SET UP TO RESET SCROLL REGION
	CIFMNU			/ CHANGE INSTRUCTION FIELD TO MENU FIELD
	JMS I	(CALLN1)	/ RESET SCROLL REGION SET ABSOLUTE MODE
/	CIFMNU			/ CHANGE INSTRUCTION FIELD TO MENU FIELD
/	PGSWAP			/ AC=0, SAVE SWAP AREA & RELOAD MENU CODE

	TAD	BLKALM		/ CHECK FOR HARD LIMIT
	SZA CLA			/ IF NOT SET, THEN TAKE SOFT APPROCH	/A156

/D156	SNA CLA
/D156	JMP	EISPC3		/ NOT HARD, TAKE SOFT APPROACH
/D156	TAD	BLWTCH		/ SEE IF THIS IS THE FIRST WARNING
/D156	SZA CLA

EISPC2,	AC0002			/ SET-UP MENU TO FORCE EXIT

EISPC3,	IAC			/ TAKE SOFT WARNING APPROACH

	JMS	MNUPUT
	MNTMP1

	CDFFIO
	TAD I	(SCFSPC)
	JMS	MNUPUT
	MNTMP2

	CIFMNU
	PGSWAP

	CIFMNU
	JMS I	MNUCAL
	DLMEM1

/D156	TAD	BLKALM		/ IS THIS A FORCE EXIT?
/D156	SNA CLA
/D156	JMP	EISPC4		/ NO, RETURN TO EDITOR
/D156	TAD	BLWTCH		/ COULD BE, CHECK BLWTCH
/D156	SZA CLA			/ FIRST WARNING! DON'T FORCE FILE

	TAD	BLKALM		/ IS THIS A FORCE EXIT?			/A156
	SZA CLA								/A156
	JMP	EIFILE		/ YES! FILE THE DOCUMENT!

EISPC4,	AC7777			/ SET AC = -1
	CIFMNU			/ CHANGE INSTRUCTION FIELD TO MENU FIELD
	PGSWAP			/ AC=-1 SO JUST LOAD IN THE SAVE AREA

	TAD	WIDNAR		/ ARE WE FORCED WIDE?			/M192
	SNA CLA			/ SKIP IF NOT				/M192
	JMS	SET132		/ YES

	JMS	CLSSET		/ USE CLSCRN IN FXSCRL TO DISPLAY STATUS

	TAD	OPNFLG		/ CHECK VALUE OF OPEN FLAG
	SNA CLA			/ SKIP IF: OPENING A DOCUMENT
	JMP	EINEXT

	JMP	OVJRTN		/ RESUME NORMAL EDIT OR GTP

/++
/			CLRMEM

/ FUNTIONAL DESCRIPTION:	CLEAR_MEMORY

/	THIS ROUTINE WILL CLEAR ANY SECTION OF MEMORY AS PER PARAMETERS
/	SPECIFIED AT CALLER+1, 2, AND 3.

/ CALLING SEQUENCE:	JMS	CLRMEM
/			 ADDRESS - 1 TO START CLR
/			 -NUMBER OF LOCATIONS TO CLR
/			 CDF INSTRUCTION

/ INPUT PARAMETERS:	AC = 0

/ IMPLICIT INPUT:	X0, T1

/ OUTPUT PARAMETERS:	AC = 0

/ IMPLICIT OUTPUT:	X0, T1, CLRME1

/ COMPLETION CODE:	NONE
/ SIDE EFFECTS:		NONE

/--

CLRMEM,	XX			/ CLEAR_MEMORY
	TAD I	CLRMEM		/ GET ADDRESS-1 OF MEM. TO BE CLEARED
	DCA	X0		/ SAVE IT
	ISZ	CLRMEM		/ BUMP RETURN POINTER
	TAD I	CLRMEM		/ GET -NUMBER OF LOCATIONS TO BE CLEARED
	DCA	T1		/ SAVE IT
	ISZ	CLRMEM		/ BUMP RETURN POINTER
	TAD I	CLRMEM		/ GET CDF INSTRUCTION FOR MEM. TO BE CLEARED
	DCA	CLRME1		/ SAVE IT
	ISZ	CLRMEM		/ BUMP RETURN POINTER
CLRME1,	.-.			/ HOLDS CDF INSTRUCTION
	DCA I	X0		/ BUMP POINTER THEN CLEAR LOCATION
	ISZ	T1		/ FINISHED? SKIP IF: SO
	JMP	.-2		/ CLEAR THE NEXT LOCATION
	CDFMYF			/ RESTORE DATA FIELD
	JMP I	CLRMEM		/ RETURN




/ THIS ROUTINE CHECKS TO SEE HOW MUCH ROOM IS LEFT ON THE DISKETTE AT
/  OPEN TIME.  IF THE NUMBER OF BLOCKS LEFT IS GREATER THAN THE CUTOFF
/   POINT (SPCCHK) RESUME.  ELSE, IF THE NUMBER OF BLOCKS IS GREATER
/    THAN 6, THEN WARN THE USER ABOUT DISK SPACE AND RESUME.  ELSE
/     THE NUMBER OF BLOCKS LEFT IS LESS THAN 6, DO NOT ALLOW THE USER
/      TO EDIT THE DOCUMENT.
/ THIS ENTIRE ROUTINE IS EDIT #132
TOOVJRTN,
	AC0001			/
	DCA	OPNFLG		/ SIGNIFIES OPENING DOCUMNET
	CDFFIO			/
	TAD I	(SCFSPC)	/ GET THE # OF AVAILABLE BLOCKS
	CDFMYF			/

	DCA	BLWTCH		/ AND SAVE NUMBER OF FREE BLOCKS	/M156
	TAD	BLWTCH		/ RESTORE FREE BLOCK COUNT		/M156
	TAD	SPCCHK		/ COMPARE TO CUTOFF POINT
	SMA CLA			/ SKIP IF: BELOW CUTOFF POINT

	JMP	EISPC4		/ ENOUGH BLOCKS LEFT, GO PAGE SWAP AREA

	TAD	BLWTCH		/ RESTORE FREE BLOCK COUNT		/M156
	TAD	(-7)		/ COMPARE TO HARD LIMIT
	SMA CLA			/ SKIP IF: LESS THAN HARD LIMIT
	JMP	EISPC3		/ SOFT LIMIT, WARN USER

/D156	ISZ	BLWTCH
	ISZ	BLKALM		/ SETTING THIS WORD TELLS EISPC2 THAT USER
	JMP	EISPC2		/ HAS REACHED HARD LIMIT, FILE THE DOCUMENT

OPNFLG,	0			/ IF = 1: OPEN


	IFDEF	FORIN	<

/	HERE TO TEST FOR ACCENTED CHARACRTERS ON INPUT

XCCENT,	TAD	CHAR1 		/ GET CHARACTER BACK
	SPA 			/ INPUT COMMAND?
	JMP	EINEXC 		/ YES, PROCESS COMAND
	CLA
	TAD	(TABLE1-1)
	JMS	SEARCH 		/ LOOK FOR CHARACTER IN TABLE
	JMP	ACENT1 		/ NOT FOUND
	TAD	(ECSTOV)	/ FOUND
	INSCHR 			/ INSET DEAD KEY START
	TAD	CHAR1
	INSCHR 			/ INSERT CHARACTER
ACENT0,	GETINP 			/ GET NEXT CHARACTER
	SMA 			/ SPECIAL?
	JMP	ACENT2 		/ NO
	JMS	BEEPER 		/ DCA	CHAR1		/YES, SAVE CHARACTER
	JMP	ACENT0 		/ ADVPTR			/ ADVANCE POINTER
	NOP 			/ JMP	EIBAD		/?
	NOP 			/ TAD	(ECNDOV)
	NOP 			/ JMS	INSRL1		/ STORE END OF DEAD KEY SEQUENCE
	NOP 			/ TAD	CHAR1
	NOP 			/ JMP	EINEXC		/ NOW EXECUTE SPECIAL CHARACTER
ACENT2,	INSCHR 			/ INSERT 2ND CHARACTER
	TAD	(ECNDOV)
	SKP 			/ INSERT DEAD KEY SEQ. END
ACENT1,	TAD	CHAR1 		/ CHAR NOT FOUND IN TABLE
	JMP	EINSRT 		/ INSERT INTO TEXT NORMALLY
			>	/ END IFDEF FORIN

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

/***************************************************************************
/****			   START OF OVERLAY				****
/***************************************************************************

	OVRNUM=OVRNUM+200
	OVRBLK=OVRNUM%200+DLOEDO-1 / DISK BLOCK WHERE OVERLAY IS LOADED

	RELOC

	RELOC OVLAY1
	OVRNUM

	OVMRG1=	.-OVLAY1+OVRNUM / "MERGE" OVERLAY # 1

	JMS	CPYBUF		/ SAVE CONTENTS OF FIRST SWAP AREA BLOCK /A170
	-200			/ NUMBER OF WORDS TO SAVE		 /A170
	CDFMNU			/ SOURCE FIELD				 /A170
	SWPBEG-1		/ SOURCE ADDRESS			 /A170
	CDFMYF			/ DESTINATION FIELD			 /A170
	OVLAYM-1		/ DESTINATION ADDRESS			 /A170

	TAD	(-DLSTAT)	/ PICK UP ADDRESS OF STATUS CODE	 /A170
	CIFMNU			/ CHANGE TO MENU FIELD			 /A170
	PGSWAP			/ AC=DLSTAT SO JUST READ IN STATUS CODE	 /A170

	JMS	CPYBUF		/ RESTORE CONTENTS OF SWAP AREA BLOCK	 /A170
	-200			/ NUMBER OF WORDS TO SAVE		 /A170
	CDFMYF			/ SOURCE FIELD				 /A170
	OVLAYM-1		/ SOURCE ADDRESS			 /A170
	CDFMNU			/ DESTINATION FIELD			 /A170
	SWPBEG-1		/ DESTINATION ADDRESS			 /A170

	TAD	(7400)		/ PICK UP SPECIAL VALUE OF NO-OP CODE	/A209
	JMS	MNUPUT		/ STORE FOR SWAP AREA LOADED CHECK	/A209
	CALLN1+2-MUBUF		/ FLAG LOCATION USED BY CALLER ROUTINE	/A209


	CIFMNU			/ CHANGE INSTRUCTION FIELD TO MENU FIELD /A170
	PGSWAP			/ AC=0, SAVE SWAP AREA & RELOAD MENU CODE /A170

	TAD	(5000)
	DCA	BUFBEG 		/ SET UP EDIT BUF PTRS

	TAD	(BUFEND-5000)
	DCA	BUFSIZ

	TAD	EDMERG
	DCA	EDITOR 		/ COPY RETURN ADDR

	TAD	(CDILP)							/A191
	DCA	EDEXI3		/ SET UP RETURN FIELD INSTRUCTION	/A191

	JMS	MNUPUT		/ CLEAR EDITOR LOCK WORD SO THAT THE	/A191
	OLL110-MUBUF		/ EDITOR CODE IN MEMORY IS REFRESHED	/A191

	JMS	CPYBUF
	-200
	CDFMYF
	MGOVLY-1
	CDFMYF
	OVLAYM-1
	TAD	(XRDFNC)
	DCA	MGPTC1 		/ DO PATCHES
	TAD	(SKP CLA)
	DCA	MGPTC2
	TAD	(SKP CLA)
	DCA	MGPTC3
	TAD	(ESGETX&177+4600)
	DCA	MGPTC4

	CDFBUF 			/ GET ARGS
	AC7777
	DCA	X0
	TAD I	X0
	DCA	FORMNO
	TAD I	X0
	DCA	FILENO
	TAD I	X0
	DCA	FILOPT
	TAD	FILENO
	SZA CLA
	JMP	MRGINB 		/ INIT PRINT IF NEC.
	TAD	(PRTBUF-1) 	/ GET THE STARTING LOC. OF THE
	DCA	X0 		/ MERGE-TO-PRINT BUFFER
	TAD	(-PRTSIZ+1) 	/ AND ITS SIZE
	DCA	T1
	DCA I	X0 		/ SO THAT
	ISZ	T1 		/ WE CAN
	JMP	.-2 		/ CLEAR THE BUFFER
	TAD	(PRTBUF-1)
	DCA I	X0 		/ AND SET END MARKER
	CDFMYF
	TAD	(ESPUTX&177+5600)
	DCA	MGPTC4 		/ RE-PATCH FOR PRINTER
	AC7777			/ Set "printer not halted yet" flag.
	DCA	MRGHFG		/ Reset "printer halted" flag.
	CDFPRT
	RIF
	TAD	(CIF) 		/ GET CIF TO MY FIELD
	DCA I	(PRIRFD) 	/ SET CALL TO OUR ROUTINE
	TAD	(GETPRT)
	DCA I	(PRIRAD)

MRGINB,	OVLJMP;OVINIT 			/ NOW INIT REST OF WORLD


	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE


/ THIS ROUTINE RETURNS A NON-ZERO CHARACTER, UNLESS THE END OF THE FILE IS
/ REACHED.  WHEN THE END OF THE FILE IS REACHED, THE ROUTINE CONTINUES TO
/ RETURN A ZERO EACH TIME IT IS INVOKED.  HOWEVER, THE END OF FILE MARK IS
/ NEVER REMOVED, SO THE ROUTINE MUST BE "CLOSED" IF LIST PROCESSING IS TO
/ TERMINATE.  TO DO THIS, SIMPLY CALL GETPRT WITH A NON-ZERO AC.

MGOVLY,	RELOC OVLAYM		/ DEFINE THE MERGE OVERLAY

GETPRT,	XX 			/ CALLED FROM PRINTER FOR MERGE OUTPUT
	CDFBUF			/ map buffer field for final call.
	SZA CLA
	JMP	GETPRZ 		/ YES--CLOSE THINGS OFF

GETPRY,	CDFBUF
	TAD I	PRGETP 		/ GET NEXT CHAR
	SNA SPA
	JMP	GETPRV 		/ JUMP IF WRAP OR EOF
GETPRZ,	MQL 			/ SAVE CHAR
	DCA I	PRGETP 		/ SHOW WE GOT IT
	CDFSYS
	DCA I	(INTFLG) 	/ LET EVERYBODY WAKE UP
	ISZ	PRGETP 		/ WHILE WE FIX PTR
	CLA MQA 		/ RETRIEVE CHAR
GETPRX,	CIF CDFPRT		/ RETURN CIF
	JMP I	GETPRT

GETPRV,	SNA
	JMP	GETPRW 		/ JUMP IF NO CHARACTERS TO BE HAD
	IAC
	SNA
	JMP	GETPRX 		/ RETURN IMMEDIATELY IF END OF FILE
	DCA	PRGETP 		/ ELSE RESET FOR WRAPPED BUFFER
	JMP	GETPRY 		/ AND RETRY

GETPRW,	CDFMYF
	CIFSYS
	JWAIT 			/ WAIT FOR OUTPUT
	JMP	GETPRY 		/ THEN TRY AGAIN

PRGETP,	PRTBUF 			/ PRINT BUFFER READ PTR

PUTST2,	HLTTST			/ See if GOLD:HALT has been pressed.
	SKP			/ this return if yes. Process GOLD:HALT
	JMP	PUTST4		/ This return if no. continue waiting.
	AC7777			/ check printer status.
	CDFPRT			/ get printer status word.
	TAD I	(PRSTTS)	/  ...
	SNA CLA			/ Skip if FR<> 1 (stop/ error status).
	JMP	PUTST4		/ JMP to ignore the HALT. continue WAIT
	TAD	MRGHFG		/ have we halted thee spooler yet?
	SNA			/ skip if no. Do it this time.
	JMP	PUTXIT		/ Ignore character.
	DCA I	(PABORT)	/ set printer abort flag. unhang spooler
	AC0001
	DCA I	(PRSTOP)	/ set printer stop flag.
	AC0002
	DCA I	(PRACTN)	/ set stop action to cancel.
				/ set flag saying that we already
	DCA	MRGHFG		/  halted the spooler.
PUTXIT,	CDFBUF			/ return to calling routine.
	JMP	ESPUTY		/  ...

PUTST4,	CDFMYF
	CIFSYS
	JWAIT
PUTST1,	JMS	KBDCHK 		/ CHECK FOR PRINTER COMAND
	CDFSYS
	DCA I	(INTFLG) 	/ WAKE PEOPLE UP
	CDFBUF
	TAD I	PRPUTP 		/ CHECK FOR WRAP/ FULL
	SMA
	JMP	.+6 		/ JUMP IF NOT WRAP
	IAC
	SNA
	JMP	PUTST2 		/ JUMP IF ALL DONE
	DCA	PRPUTP
	JMP	.-7 		/ ELSE RESET AND RETRY
	SZA CLA
	JMP	PUTST2 		/ JUMP IF FULL
	TAD	T1
	DCA I	PRPUTP 		/ STORE GOOD CHAR IN BUFFER
	TAD	T1
	SPA CLA
	JMP	PUTST3 		/ JUMP IF ALL DONE
	ISZ	PRPUTP 		/ BUMP BUFFER PTR
	JMP	ESPUTY 		/ RETURN

PUTST3,	DCA	T1 		/ SAVE CHAR
	JMP	PUTST1 		/ JOIN OUTPUT LOOP

PRPUTP,	PRTBUF 			/ OUTPUT PTR TO PRINT BUFFER
MRGHFG,	0			/ 0 until printer is told to cancel.

KBDCHK,	XX 			/ CHECK KEYBOARD FOR PRINTER COMMAND
KBDCH1,	CDFMYF
	CIFSYS
	TTYIN			/ Get char from KB: (not UDK).
	JMP I	KBDCHK 		/ RETURN IF NONE
	SPA
	JMP	KBDCH4 		/ COMPLAIN IF SPECIAL
	AND	P177
	XLTUPR
	TAD	(-"R+200)
	SNA
	JMP	KBDCH5 		/ RESUME?
	TAD	("R-"N)
	SNA
	JMP	KBDCH6 		/ NEW PAGE?
	TAD	("N&177)	/ restore origional character.
	TAD I	HLTLST		/ see if part of GOLD:HALT string.
	ISZ	HLTLST		/ bump string pointer.
	SZA CLA
	JMP	KBDCH4		/ JMP if not part of GOLD:HALT.
	TAD I	HLTSTR		/ are we at the end of GOLD:HALT?
	SZA CLA
	JMP	KBDCH1		/ Jmp if NO. Get next input character.
	JMP	KBDCH7		/ Hit the end. reset pointer but no beep

KBDCH4,	JMS	BEEPER
KBDCH7,	TAD	(HLTSTR)	/ reset GOLD:HALT string pointer.
	DCA	HLTLST		/  ...
	JMP	KBDCH1 		/ COMPLAIN AND IGNORE IF ILLEGAL

KBDCH5,	AC0006
	SKP 			/ RESUME,
KBDCH6,	AC0001 			/ OR NEW PAGE
	CDFPRT
	DCA I	(PRACTN)
	JMP	KBDCH1 		/ AND CONTINUE

HLTLST,	HLTSTR			/ pointer into GOLD:HALT string.
HLTSTR,	-33;-117;-120;-140;0	/ GOLD:HALT sequencee.

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

/***************************************************************************
/****			   START OF OVERLAY				****
/***************************************************************************

	OVRNUM=OVRNUM+200
	OVRBLK=OVRNUM%200+DLOEDO-1 / DISK BLOCK WHERE OVERLAY IS LOADED

	RELOC

	RELOC OVLAY1
	OVRNUM 			/ UTILITY OVERLAY

	OVDLTE=	.-OVLAY1+OVRNUM
	JMP	XVDLTE

/
/	OVSWAP=	.-OVLAY1+OVRNUM / SWAP ENTRY
/
/	OVSWAP which used to be here has been moved to OVHELP to allow	/M225
/	it more room to handle MCS and give Hyphenation space to also 	/M225
/	handle MCS.							/M225
/

/
/	OVTIME overlay has now also been moved to OVHELP to allow	/M231
/	Hyphenation more space for 8 bit support			/M231
/




	OVHYPS=	.-OVLAY1+OVRNUM / HYPHEN PUSH

XVHYPS,	DCA	SCRLFL 		/ CLEAR SCROLL FLAG
XVHYPB,	AC7777
	CURMOV
	JMP	EIBAD 		/ BACK UP TO PREVIOUS LINE
	TAD	SCRLFL
	SZA CLA			/ Skip if no.
	JMP	XVHYPC		/ Jmp if yes. see where we are.
	AC2000			/ see if there is an invisible-hyphen.
	AND I	CURPTR		/  ...
	SNA CLA			/ skip if yes.
	JMP	XVHYPV		/ no. go to next prev posn.		/M231
XVHYB1,	TAD	CURSOR		/ save earliest hyphen posn.		/A231
	IAC			/ make bais by 1 (not 0).
	DCA	HYPSAV		/  ...
	JMP	XVHYPB		/ go to next prev posn.
XVHYPC,	TAD I	CURPTR		/ Get current character.
	JMS	CHKALP
	JMP	EIHYPT 		/ SKIP IF NOT ALPHA			/M231
	AND	(5777)
	DCA I	CURPTR 		/ CLEAR BREAK FLAG
EIHYPY,	CLA
	SLNMOD
	DCA	SCRLFL 		/ CLEAR SCROLL FLAG AGAIN
EIHYPW,	AC0001
	CURMOV
	JMP	EIHYPX 		/ SET FLAG ON NEXT
	TAD	SCRLFL
	SZA CLA
	JMP	EIHYPX 		/ UNLESS LINE TOO LONG
	TAD	CURSOR 		/ OR AT RIGHT MARGIN ALREADY
	CIA
	TAD	RGTMAR
	SPA SNA CLA
	JMP	EIHYPZ
	TAD	HYPSAV		/ Did we see an invisible hyphen?
	SNA			/ Skip if YES. See if it's within ruler.
	JMP	XVHYPD		/ No. Force normal hyphenization.
	TAD	CURSOR		/ Compute cursor address of seen hyphen.
	CIA
	TAD	RGTMAR
	SMA CLA
	JMP	EIHYPZ		/ JMP if within ruler setting.
XVHYPD,	TAD I	CURPTR
	JMS	CHKALP
	JMP	XVHYPR 		/ OR CHAR NOT ALPHA			/M231
	AC2000
	MQA
	DCA I	CURPTR
EIHYPZ,	AC0001
	CURMOV
	JMP	EIHYPX 		/ THEN ADVANCE LINE
	TAD	SCRLFL
	SNA CLA
	JMP	EIHYPZ 		/ TO SHOW NEW HYPHENATION
EIHYPX,	JMP	EIFIX		/ AND GO LISTEN				/C168

EIHYPT,	JMS	HYPLMX		/ Is it 8 bit				/A231
	 JMP	EIHYPY		/ No .. go away				/A231
	JMP	EIHYPY		/ Yes .. but we are already finished	/A231

XVHYPR,	JMS	BHOOK		/ Check for 8 bit			/A231
	MCSTHY			/ 8 bit char ?				/A231
	 JMP	EIHYPZ		/ No 					/A231
	TAD	(2000)		/ Put on breaking bit			/A231
	DCA I	CURPTR		/ Put char away again			/A231
	JMS	HYBKUP		/ Now backup				/A231
	JMP	EIHYPZ
XVHYPV,	JMS	BHOOK		/ Check for 8 bit			/A231
	MCSTHY			/					/A231
	  JMP	XVHYPB		/ No 					/A231
	CLA 			/					/A231
	TAD I	CURPTR		/ Get full char back			/A231
	DCA 	XVTEMP		/ Save char				/A231
	JMS	HYBKUP		/ move back				/A231
	CLA			/ Clear out Start dead			/A231
	TAD	XVTEMP		/ get char back				/A231
	AND	(2000)		/ is breaking bit set ?			/A231
	SNA CLA			/					/A231
	JMP	XVHYPB		/ No get out				/A231
	JMP	XVHYB1		/ Yes , set HYPSAV			/A231

	OVHYPL=	.-OVLAY1+OVRNUM / HYPHEN PULL

XVHYPL,	DCA	SCRLFL 		/ CLEAR SCROLL FLAG
	DCA	HYPSAV		/ init previous HYPHEN posn.
	AC7777
	CURMOV
	JMP	EIBAD 		/ BACK UP TO PREVIOUS LINE
	TAD	SCRLFL
	SNA CLA
	JMP	.-5
	TAD I	CURPTR
	JMS	CHKALP
	JMP	HYPLMC		/ Test for Pull on MCS			/M231
	AND	(5777)
	DCA I	CURPTR 		/ CLEAR BREAK FLAG
HYPLFN,	SLNMOD
	AC7776
	CURMOV
	JMP	EIBAD 		/ TWO MORE, SO WE CAN ADVANCE
	JMP	EIHYPY 		/ IN COMMON CODE

HYPSAV,	0			/ posn (0 bais) of next invisible hyphen.

HYPLMC,	JMS	HYPLMX		/ Is it 8 bit				/A231
	 JMP	EIHYPZ		/ No .. go away				/A231
	JMP	HYPLFN		/ Yes .. we are already finished	/A231


HYPLMX,	XX
	JMS	BHOOK		/ Is this an MCS char			/A231
	MCSTHY			/ 8 bit char in Hyphenation		/A231
	 JMP I	HYPLMX		/ No , ignore				/A231
	DCA I	CURPTR		/ Put char back				/A231
	ISZ	HYPLMX		/ Bump return for 8 bit			/A231
	JMS	HYBKUP		/ Now backup to start of dead		/A231
	JMP I	HYPLMX		/ And rejoin Mainline			/A231

HYBKUP,	XX			/ Backup cursor				/A231
	BKPPTR			/ Backup				/A231
	NOP			/ Shouldn't happen ..			/A231
	BKPPTR			/ And again				/A231
	NOP			/ Shouldn't happen ..			/A231
	BKPPTR			/ Last one				/A231
	NOP			/ 					/A231
	JMP I	HYBKUP		/ Get out				/A231

XVTEMP,	0			/ Temp for char 			/A231
	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE


XVDLTE,	TAD	(BASKET-1)
	DCA	X5 		/ SET UP PTRS
	DCA	BASKCT 		/ AND COUNT FOR WASTEBASKET FILLING
	DCA	PSTBLK 		/ SHOW NO INCORE PASTE
	TAD	CURPTR
	DCA	DELUN1 		/ SAVE CURPTR
	JMS	SETUNT		/ SET PROPER UNIT TYPE
	JMS	RLEQTE		/ MAKE NWRUL=CURUL
	JMS	LODCHR	
	JMP	DELUNZ		/ QUIT IF EOF
	JMS	CHKUNT		/ CHECK FOR END OF UNIT
DELNXT,	XX
	SPA CLA
	JMP	DELUNX 		/ QUIT IF ALL DONE
	TAD I	CURPTR		/ Get character to delete.
	AND	P177		/ isolate character bits.
	TAD	(-LF)		/ compare against line terminator.
	SNA CLA			/ skip if not terminator.
	JMS	RSTRLN		/ set to repaint entire line.
	TAD I	CURPTR
	TAD	(-ECSLPT) 	/ CLEAR SELECT IF WE CROSS
	SNA
	JMP	DELUNS
	TAD	(ECSLPT-ECRMFL)
	SNA
	JMP	DELUNM
	TAD	(ECRMFL-ECSTRL)
	SNA
	JMP	DELUNR
DELUNE,	TAD	(ECSTRL-ECSTOV)
	SNA CLA
	JMP	DELUNO
	TAD I	CURPTR
	JMS	ESJCHK
	SNA CLA
	JMP	DELUNA
DELUNP,	JMS	DELPUT 		/ OTPUT TO WASTEBASKET
DELUNA,	DCA I	CURPTR 		/ DELETE CHAR
	AC0001
	CHKPTR
	SNA
	JMP	.-3 		/ GET NEXT CHAR
	SMA CLA
	JMP	DELUNB 		/ JUMP IF OK
	TAD I	CURPTR
	DCA I	DELUN1 		/ COPY ETX CODE
	TAD	DELUN1
	DCA	CURPTR 		/ RESET CURPTR
DELUNC,	ADVPTR
	JMP	DELUNX 		/ JUMP IF EOF
	JMP I	DELNXT 		/ ELSE TEST AGAIN
DELUNB,	TAD I	CURPTR
	JMP I	DELNXT
DELUND,	DCA I	CURPTR 		/ DELETE LAST CHAR
DELUNX,	TAD	DELUN1
	DCA	CURPTR 		/ RESET CURPTR
	SLNMOD
	TAD	LINMOD
	JMS	INSERT 		/ SET MOD FLAG
DELUNW,	JMS	CMPRUL
	JMP	DELUNY 		/ CHECK FOR RULER CHANGE
	JMS	INSRUL
DELUNY,	TAD	DELUN1
	DCA	CURPTR 		/ RESET CURPTR (AGAIN)
	SLNMOD 			/ SHOW MODS HAPPENED
DELUNZ,	JMP	EIFIX 		/ AND RETURN

DELPUT,	XX
	TAD	BASKCT 		/ PUT TO WASTEBASKET, IF NOT FULL
	TAD	(-BASKSZ)
	SNA CLA
	JMP I	DELPUT
	TAD I	CURPTR
	DCA I	X5
	ISZ	BASKCT
	JMP I	DELPUT

DELUNO,	JMS	DELPUT 		/ OUTPUT TO WASTEBASKET
	DCA I	CURPTR 		/ DELETE
	ADVPTR
	JMP	DELUNX
	TAD	(-ECNDOV) 	/ CHECK FOR END
	SZA CLA
	JMP	DELUNO 		/ LOOP IF NOT
	JMP	DELUNP 		/ ELSE OUTPUT AND RETURN

DELUNM,	TAD I	CURPTR
	DCA	RLRMOD 		/ SAVE MOD FLAG
	JMP	DELUNA

DELUNS,	DCA	EDMODE 		/ DELETE SELECT POINT
	JMP	DELUNA

DELUNR,	TAD	DELUN1
	DCA	CURPTR 		/ RESET CURPTR
	JMS	ESNWRL 		/ GET NEW RULER
	TAD	DELUN1
	DCA	CURPTR
	JMS	DLTRLR 		/ DELETE RULER
	JMP	DELUNC

DELUN1,	0

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

/***************************************************************************
/****			   START OF OVERLAY				****
/***************************************************************************

	OVRNUM=OVRNUM+200
	OVRBLK=OVRNUM%200+DLOEDO-1 / DISK BLOCK WHERE OVERLAY IS LOADED

	RELOC

	RELOC OVLAY1
	OVRNUM 			/ CURRENT OVERLAY CONTENTS


	CURSAV=RPGETUNT		/ LOCATION ONLY USED BY GO-TO-PAGE


	OVCLKY=	.-OVLAY1+OVRNUM	/ COLUMN CUT				/A169
	JMP	COLKEY							/A169


	OVXRL1=	.-OVLAY1+OVRNUM	/ CONTINUATION ENTRY POINT FOR GOLD: RULER
	DCA	RLDIRN		/ SET RULER MOVEMENT DIRECTION TO FORWARD /A217

RULSVE,	JMS	PCUR 		/ SET TO BOTTOM LINE

	IFDEF	PERDEC	<
	TAD	(4056)
	DCA	OKSTR 		/ USE BLANKS FOR NULLS
			> 	/ END IFDEF PERDEC

	IFDEF	COLDEC	<
	TAD	(4072)
	DCA	OKSTR 		/ USE BLANKS FOR NULLS
			> 	/ END IFDEF COLDEC

	IFDEF	COMDEC	<
	TAD	(4054)
	DCA	OKSTR 		/ USE BLANKS FOR NULLS
			> 	/ END IFDEF COMDEC

	/ DISPLAY SCALE FOR RULER
	JMS	NWLN
	JMS	NWLN
	DCA	RLIT1
RULSV2,	ISZ	RLIT1	/ Display 10 - 80
	TAD	RLIT1
	TAD	(-10)
	SMA SZA CLA
	JMP	RULSV3
	JMS	TWODEC
	JMP	RULSV2

RULSV3,
/D192	TAD	SPLTFL		/ IN SPLIT SCREEN MODE?
/D192	SZA CLA
	JMS	RLDBLD		/ YES, PAINT REST OF RULER
				/ Output ...:...: text
	TAD	(-10)
	DCA	RLIT1
	JMS	NWLN
	JMS	PCUR
RULV3A,	JMS	PUTMSA
	  RLSTR2
	ISZ	RLIT1
	JMP	RULV3A
	JMS	NWLN
	TAD	(-4)
	DCA	SCRLCT 		/ SET UP FOR SCROLL RECOVERY
	OVLJMP			/ GO SET RLPOSN AND DISPLAY RULER
	OVDRUL			/ JUMP TO NEXT OVERLAY


	OVRULX=	.-OVLAY1+OVRNUM / HERE TO "GO DOUBLE"

	AC7777
	DCA	SPLTFL
				/ Swaped next 2 locations		/M193
	JMS	FXMEUP		/ RE-PAINT THE SCREEN NOW
	JMS	SET132		/ SET 132 COL IF WIDNAR FLAG IS WIDE	/M192
	JMP	RULSVE

RLDBLD,	XX
	JMS	TWODEC
	TAD	RLIT1
	TAD	(-30)
	ISZ	RLIT1
	SZA CLA
	JMP	RLDBLD+1
	TAD	(-21)		/ SO WE GET UP TO 242 ON WIDE RULERS	/M186
	JMP I	RLDBLD

RLIT1,	.-.
RLIT2,	.-.

TWODEC,	0		/ Two digit decimal print routine
	JMS	PUTMSA	/ Print 7 spaces
	  RLSTR4
	DCA	NUMDGT
	TAD	RLIT1
NUM01,	TAD	(7766)	/ -10 decimal
	SPA
	JMP	NUM02
	ISZ	NUMDGT
	JMP	NUM01

NUM02,	TAD	(12)	/ decimal 10
	DCA	NUMB
	TAD	NUMDGT	/ get hundreds digit and display
	SNA
	TAD	(-20)	/ If zero convert to a space
	JMS	NUMOUT
	TAD	NUMB	/ get tens digit and display
	JMS	NUMOUT
	JMS	NUMOUT	/ units digit always 0
	JMP I	TWODEC

NUMOUT,	0
	TAD	(60)
	JMS	PUTSCH
	JMP I	NUMOUT

NUMB,	0
NUMDGT,	0


PUTMSA,	XX
	DCA	RLIT2
	TAD I	PUTMSA
	DCA	PUTMA2
	ISZ	PUTMSA
PUTMA1,	ISZ	RLIT2
	TAD	RLIT2
	JMS	GETBYT
PUTMA2,	0
	SNA
	JMP I	PUTMSA

	BSW			/ THIS LITTLE TRICK CONVERTS SIXBIT TO ASCII
	SMA
	IAC
	BSW

	JMS	PUTSCH
	JMP	PUTMA1

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE


FXMEUP,	XX

	JMS	CLSSET		/ INITIALIZE SCROLL VALUES FOR STATUS

				/ USE HYPHENS FOR NULLS
	IFDEF	PERDEC	<
	TAD	(5556)
	DCA	OKSTR
			> 	/ END IFDEF PERDEC

	IFDEF	COLDEC	<
	TAD	(5572)
	DCA	OKSTR
			> 	/ END IFDEF COLDEC

	IFDEF	COMDEC	<
	TAD	(5554)
	DCA	OKSTR
			> 	/ END IFDEF COMDEC

	ISZ	NORUPD		/ KEEP RULER FROM REVERTING
	JMS	FXSCRL		/ AND RE-PAINT THE SCREEN
	DCA	NORUPD		/ 					/A197
	JMP I	FXMEUP

/************* FROM HERE THRU NEXT LINE OF ASTERISKS IS ALL*********	/A169

COLKEY,
/D201	GETINP			/ GET A KEYSTROKE AND DECODE

COLCH1,	CIFSYS								/A201
	JWAIT								/A201

	HLTTST			/HAS GOLD HALT BEEN SET			/A201
	JMP	EINEXT		/YES					/A201
	CIFPRT								/A201
	JMS I	(FLABUZ)	/ SOUND BUZZER AND TOGGLE LED'S		/A201
				/ IF THEIR IS A PRINTER ERROR
	CIFSYS								/A201
	XLTIN								/A201
	JMP	COLCH1							/A201

				/ MUST BE PASTE, CUT, GOLD:CUT, DELCHR, RUBCHR
	ZZCASE			/ TEST KEYSTROKE AGAINST TABLE
	COLTAB-1		/ TABLE FOR CASE
	JMS BEEPER		/ NO MATCH, FOR NOW BEEP TWICE
	JMP EIBAD		/ BAD EXIT

COLTAB,	EDPSTE			/ PASTE
	OVCLPX			/ ADDRESS FOR PASTE

	EDSCUT			/ CUT
	OVCLCX

	EDGCUT			/ GOLD:CUT
	OVCGCX

	EDDLTC			/ DELCHR
	OVCLRX

	EDRBCH			/ RUBCHR
	OVCLLX

/	EDLINE			/ LINE SOLIDIFY TEXT
/	OVCLSD

/	EDPARA			/ PARA SOFTEN TEXT
/	OVCLSF
	0			/ END OF CASE CHECK INDICATOR

				/ COLUMN OPERATIONS			/A169
OVCLPX, OVLJMP;OVCLPS		/ COLUMN PASTE				/A169
OVCLCX,	OVLJMP;OVCLCT		/ COLUMN CUT				/A169
OVCGCX,	OVLJMP;OVCGCT		/ COLUMN GOLD:CUT			/A169
OVCLRX,	JMS	OV2JMP		/ COLUMN DELCHR				/A169
	OVCLRS								/A169
OVCLLX,	JMS	OV2JMP		/ COLUMN RUBCHR				/A169
	OVCLLS								/A169
OVCLSD,	JMS	OV2JMP		/ LINE SOLIDIFY TEXT			/A169
	OVSLID								/A169
OVCLSF,	JMS	OV2JMP		/ PARA SOFTEN TEXT			/A169
	OVSOFT								/A169

/***************** END ADDITIONS FOR COLUMN **********************	A169

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE


/***************************************************************************
/****			   START OF OVERLAY				****
/***************************************************************************

	OVRNUM=OVRNUM+200
	OVRBLK=OVRNUM%200+DLOEDO-1 / DISK BLOCK WHERE OVERLAY IS LOADED

	RELOC

	RELOC OVLAY1
	OVRNUM

	OVRBAD=	.-OVLAY1+OVRNUM

	JMP	XVRBAD

	OVERUL=	.-OVLAY1+OVRNUM

RLERUL,	JMS	RLEQTE 		/ SET NEW=OLD (CANCEL MODS)

	OVDRUL=	.-OVLAY1+OVRNUM

	AC0001
	TAD	CURSOR
	DCA	RLPOSN 		/ POSN=CURSOR

	OVPRUL=	.-OVLAY1+OVRNUM

RLPRUL,	JMS	DSPRUL 		/ DISPLAY RULER
		NWRUL		/ display new ruler.			/A160
RLGETI,	JMS	TSTLIM		/ TEST FOR SCREEN ZONE CHANGE
	TAD	SCRNFL
	TAD	(-2000)		/ DID ZONE CHANGE?
	SZA CLA
	JMP	RLGET0		/ NO

/D192	JMS	CLSCRN 		/ CLEAR SCREEN ON ZONE CHANGE

	DCA	SCRNFL		/ YES, CLEAR SCRNFL
	OVLJMP			/ THEN REDISPLAY SCREEN
	OVRULX								/M192

RLGET0,	AC7777
	TAD	RLPOSN
	TAD	LOWLIM		/ NORMALIZE TO LEFT OF SCREEN
	JMS	PCUR 		/ REPOSITION CURSOR

	CIFMNU			/ CHANGE TO MENU FIELD			/A217
	JMS I	(CALLN5)	/ CHECK FOR STATUS LINE CHANGES		/A217
	GETINP 			/ GET NEXT INPUT CHARACTER
	SPA 			/ SKIP IF: NOT A SPECIAL CHARACTER
	JMP	RLSPCI 		/ JUMP IF SPECIAL

	DCA	RLCHAR		/ Save the character while		/a232
	TAD	RLCHAR		/ a check is made for an eight bit	/a232
	AND	(200)		/ character.				/a232
	SZA CLA			/ Is the character eight bit?		/a232
	TAD	(EIGHTC		/ Yes, determine from eight bit table	/a232
	SNA			/ and skip the next instruction. If not	/a232
	TAD	(OKSTR		/ then use ordinary table		/a232
	DCA	SRHTBL		/ Save the table address to be used	/a232

	IFDEF	ENGLSH	<
	TAD	RLCHAR		/ RESTORE FOR COMPARE
	TAD	(-140)		/ IS THE CHAR A "@"?
	SZA			/ SKIP IF: CHAR IS "@"
	TAD	(-36)		/ IS THE CHAR A "~"?
	SNA CLA			/ SKIP WITH VALID CHAR
	JMP	RLBADI		/ CHAR WAS A "@" OR A "~"
	TAD	RLCHAR		/ RESTORE CHAR FOR FURTHER COMPARE
	TAD	(-140) 		/ CONVERT CHARACTER TO 6-BIT CODE
	SPA
	TAD	(40)
	SNA 			/ SKIP IF: CHARACTER WAS NOT AN '@'
	TAD	(""&77) 	/  SUBSTITUTE A '"' IN PLACE OF '@'
			> 	/ END IFDEF ENGLSH

/ THE SPANISH TRAP CHARACTERS ARE A COPY OF THE ENGLSH.
	IFDEF	SPANISH	<						/A236
	TAD	RLCHAR		/ RESTORE FOR COMPARE
	TAD	(-140)		/ IS THE CHAR A "@"?
	SZA			/ SKIP IF: CHAR IS "@"
	TAD	(-36)		/ IS THE CHAR A "~"?
	SNA CLA			/ SKIP WITH VALID CHAR
	JMP	RLBADI		/ CHAR WAS A "@" OR A "~"
	TAD	RLCHAR		/ RESTORE CHAR FOR FURTHER COMPARE
	TAD	(-140) 		/ CONVERT CHARACTER TO 6-BIT CODE
	SPA
	TAD	(40)
	SNA 			/ SKIP IF: CHARACTER WAS NOT AN '@'
	TAD	(""&77) 	/  SUBSTITUTE A '"' IN PLACE OF '@'
			> 	/ END IFDEF SPANISH			/A236

/ THE NORWAY TRAP CHARACTERS ARE A COPY OF THE ENGLSH.
	IFDEF	V30NOR	<						/A238
	TAD	RLCHAR		/ RESTORE FOR COMPARE
	TAD	(-140)		/ IS THE CHAR A "@"?
	SZA			/ SKIP IF: CHAR IS "@"
	TAD	(-36)		/ IS THE CHAR A "~"?
	SNA CLA			/ SKIP WITH VALID CHAR
	JMP	RLBADI		/ CHAR WAS A "@" OR A "~"
	TAD	RLCHAR		/ RESTORE CHAR FOR FURTHER COMPARE
	TAD	(-140) 		/ CONVERT CHARACTER TO 6-BIT CODE
	SPA
	TAD	(40)
	SNA 			/ SKIP IF: CHARACTER WAS NOT AN '@'
	TAD	(""&77) 	/  SUBSTITUTE A '"' IN PLACE OF '@'
			> 	/ END IFDEF V30NOR			/A238

/ THE SWEDISH TRAP CHARACTERS ARE A COPY OF THE ENGLSH.
	IFDEF	V30SWE	<						/A239
	TAD	RLCHAR		/ RESTORE FOR COMPARE
	TAD	(-140)		/ IS THE CHAR A "@"?
	SZA			/ SKIP IF: CHAR IS "@"
	TAD	(-36)		/ IS THE CHAR A "~"?
	SNA CLA			/ SKIP WITH VALID CHAR
	JMP	RLBADI		/ CHAR WAS A "@" OR A "~"
	TAD	RLCHAR		/ RESTORE CHAR FOR FURTHER COMPARE
	TAD	(-140) 		/ CONVERT CHARACTER TO 6-BIT CODE
	SPA
	TAD	(40)
	SNA 			/ SKIP IF: CHARACTER WAS NOT AN '@'
	TAD	(""&77) 	/  SUBSTITUTE A '"' IN PLACE OF '@'
			> 	/ END IFDEF V30SWE			/A239

	IFDEF ITALIAN	<
	TAD	RLCHAR
	TAD	(-134)		/ Have we a \?
	SNA			/ Well?
	JMP	RLBADI		/ Yes, well we don't want it here!
	TAD	(134-140)	/ Convert to six bit
	SPA
	TAD	(40)
	SNA			/ Have we an @ or an a-grave?
	TAD	(34)		/ Yes, make it into a \ as six bit
				/ can't represent @
			>

	IFDEF	DUTCH	<
	TAD	RLCHAR		/ RESTORE FOR COMPARE
	TAD	(-140)		/ IS THE CHAR A "@"?
	SZA			/ SKIP IF: CHAR IS "@"
	TAD	(-36)		/ IS THE CHAR A "~"?
	SNA CLA			/ SKIP WITH VALID CHAR
	JMP	RLBADI		/ CHAR WAS A "@" OR A "~"
	TAD	RLCHAR		/ RESTORE CHAR FOR FURTHER COMPARE
	TAD	(-140) 		/ CONVERT CHARACTER TO 6-BIT CODE
	SPA
	TAD	(40)
	SNA 			/ SKIP IF: CHARACTER WAS NOT AN '@'
	TAD	(""&77) 	/  SUBSTITUTE A '"' IN PLACE OF '@'
			> 	/ END IFDEF DUTCH

	IFDEF	FRENCH	<
	TAD	(-175)
	SNA
	TAD	(77-175)
	TAD	(175-140)
	SPA
	TAD	(40)
	SNA
	TAD	("#&77)
			> 	/ END IFDEF FRENCH

	IFDEF	GERMAN	<
	TAD	(-140)
	SPA
	TAD	(40)
	SNA
	TAD	("#&77)
			> 	/ END IFDEF GERMAN

	IFDEF	CANADA	<
	TAD	(-140)
	SPA
	TAD	(40)
	SNA
	TAD	(""&77)
			> 	/ END IFDEF CANADA

	IFDEF	SCANDI	<
	TAD	(-140)
	SPA
	TAD	(40)
			> 	/ END IFDEF SCANDI

	AND	P77 		/ MASK UPPER BYTE
	CIA 			/ GET -CHARACTER VALUE
	DCA	T2		/ SAVE VALUE
	DCA	T3		/ ZERO INDEX COUNT

/ SEE IF INPUT CHARACTER IS LEGAL BY CHECKING FOR A MATCH FOR IT IN
/  OKSTR TABLE.
INDEXA,	ISZ	T3		/ BUMP INDEX COUNT
	TAD	T3		/ GET INDEX COUNT
	JMS	GETBYT 		/ GET CORRESPONDING CHARACTER IN
				/  OKSTR TABLE
SRHTBL,	OKSTR								/m232
	SNA 			/ SKIP IF: NOT AT END OF TABLE
	JMP	RLBADI 		/ ERROR IF NOT FOUND
	TAD	T2		/ ADD -CHAR. VALUE TO VALUE RETURNED
				/  FROM OKSTR TABLE.
	SZA CLA 		/ SKIP IF: CHARACTER MATCHED
	JMP	INDEXA 		/ LOOP IF NOT EQUAL
	TAD	T3		/ RETURN INDEX

	TAD	(-17) 		/ ADD (NUMBER OF RULER SETTING CHARACTERS IN
				/  OKSTR TABLE - 1)
	SMA 			/ SKIP IF: INPUT CHARCTER WAS A RULER SETTING
				/  CHARACTER ( 'L', 'R', 'D', '.' ...ETC.)
	JMP	GETSRL 		/ INPUT CHARACTER WAS EITHER A STORE_RULER
				/  ('!', '@', '#' ...ETC.) OR ACCESS_STORED_
				/   RULER CHARACTER ('1', '2', '3' ...ETC.).
				/    JUMP TO HANDLER.
	TAD	(17) 		/ RESTORE INDEX NUMBER IN AC
	JMS	UPDRUL 		/ UPDATE RULER
	JMP	RLPRUL 		/ AND DISPLAY

GETSRL,	SNA 			/ SKIP IF: TABLE MATCH DID NOT OCCUR ON 17TH
				/  BYTE OF OKSTR TABLE (CHARACTER IN 17TH
				/   BYTE IS AN '=')
	JMP	RLERUL 		/ INPUT CHARACTER WAS AN '='.  SO GOTO
				/  ROUTINE THAT WILL RESET THE NEW RULER
				/   EQUAL TO THE OLD.
	TAD	(-13) 		/ IS CHARACTER AN ACCESS_STORED_RULER CHAR.?
	SPA 			/ SKIP IF: SO
	JMP	GETSRX 		/ JUMP TO GET RULER SPECIFIED BY INPUT CHAR.
	DCA	T3 		/ STORE THIS RULER AS PER STORE_RULER CHAR.
				/  SPECIFIED BY INPUT CHARACTER.
	OVLJMP;	OVGSRL		/ GO STORE THE RULER			/M184

GETSRX,	TAD	(12)
	JMS	RLGETS
	CDFMNU
	TAD	NWRMAR
	TAD	(-COLM81)
	CDFMYF
	SPA SNA CLA
	JMP	RLPRUL
	TAD	SPLTFL
	SZA CLA
	JMP	RLPRUL
	OVLJMP
	OVRULX


/
/ ADVANCE TO NEXT RULER (AFTER ENTERING RULER BEING EDITED)
/
RLGOAD,	AC0001			/ INDICATE ADVANCE TO RULER
	JMP	RLNWL

/
/ BACKUP TO PREVIOUS RULER (AFTER ENTERING RULER BEING EDITED)
/
RLGOBK,	AC7777			/ INDICATE BACKUP TO RULER
	JMP	RLNWL

/
/ CANCEL ALL MODS TO RULER AND EXIT
/
RLQUIT,	JMS	RLEQTE 		/ SET NWRUL := CURUL
/
/ ENTER RULER BEING EDITED, AND EXIT GOLD:RULER COMMAND
/
RLNWL,	DCA	RRDIR		/ SET GOTO-RULER FLAG (0=NO GOTO-RULER)
	OVLJMP
	OVXRUL

/ RLSPCI	moved to next page to make room this edit		/a232

TLITAA,	SPCLST-1

RLCHAR,	0			/ TEMP HOLD FOR CURRENT INPUT CHAR

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE


SPCLST,	RLQUIT 			/ CANCEL MODS AND QUIT
	-EDRULR
	RLNWL 			/ EXIT WITH MODS
	-EDNWLN
	RLBKP 			/ BACK-UP CURSOR
	-EDBKUP
	RLADV 			/ ADVANCE CURSOR
	-EDADVN
	RLMNU 			/ CALL UP EDITOR MENU
	-EDMENU
	RLWRD 			/ MOVE CURSOR TO NEXT RULER MARK
	-EDWORD
	RLINE 			/ MOVE CURSOR TO COLUMN 80
	-EDLINE
	RLOJDL			/ DELETE RULER
	-EDDLTW			/   (DELETE WORD)
	RLERUL			/ UNDELETE RULER
	-EDUDLT			/   (GOLD DELETE WORD)
	RLGOAD			/ ADVANCE TO NEXT RULER
	-EDGADV			/   (GOLD:ADVANCE)
	RLGOBK			/ BACKUP TO PREVIOUS RULER
	-EDGBKP			/   (GOLD:BACKUP)
	0 			/ END OF SPCLST


RLSPCI,	DCA	T1 		/ SAVE CODE
	TAD	TLITAA
	DCA	X0
	TAD I	X0
	SNA
	JMP	RLBADI 		/ ERROR IF NOT FOUND
	DCA	T2
	TAD I	X0
	TAD	T1
	SZA CLA
	JMP	.-7
	JMP I	T2 		/ JUMP TO ROUTINE

RLBKP,	AC7777
RLADV,	DCA	RLDIRN 		/ SET DIRECTION FOR FUTURE MOVES
	JMS	RLMOV 		/ DO MOVE OF ONE
	JMP	RLINE2		/ AND LISTEN FOR MORE

RLMOV,	XX
	TAD	RLDIRN
	SMA CLA
	JMP	RLADV1 		/ MOVE ONE IN RIGHT DIRECTION
	AC7777 			/ ELSE BACK UP
	TAD	RLPOSN
	SNA
	JMP	RLBADI
	DCA	RLPOSN
	JMP I	RLMOV

RLADV1,	TAD	(-COLLIM+2) 		/ ADVANCE CURSOR
	TAD	RLPOSN
	SMA CLA
	JMP	RLBADI
/D192	TAD	RLPOSN
/D192	TAD	(-COLM81)
	ISZ	RLPOSN
/D192	SPA CLA
	JMP I	RLMOV
/D192	TAD	SPLTFL		/ SPLIT SCREEN MODE?
/D192	SZA CLA
/D192	JMP I	RLMOV		/ RETURN IF YES!

/D192	AC7777
/D192	TAD	RLPOSN		/ ELSE SET CURSOR TO 1 LESS THAN RULER
/D192	DCA	CURSOR
/D192	OVLJMP
/D192		OVRULX

/D217	RLDIRN,	0		/ GOLD: RULER DIRECTION (0 FORWARD, -1 REVERSE)

RLWRD,	JMS	RLMOV 		/ GO ONE POSITION
	TAD	RLPOSN
	JMS	GETBYT
	NWRUL 			/ CHECK FOR SOMETHING
	TAD	(-1)
	SNA CLA
	JMP	RLWRD 		/ LOOP TIL WE GET IT
	JMP	RLINE2		/ THEN GO LISTEN FOR MORE

RLINE,	TAD	RLDIRN
	SMA CLA
	JMP	RLINE1
	IAC 			/ GO TO END OF LINE
	DCA	RLPOSN
	JMP	RLINE2		/ AND RETURN FOR MORE

RLINE1,	TAD	RLPOSN
	TAD	(-COLM81) 	/ SECOND LINE?
	SMA CLA								/M192
	TAD	(COLLIM-COLM81-2) / ADD OFFSET IF SO
	TAD	(COLM81)
	DCA	RLPOSN

RLINE2,	AC7777
	TAD	RLPOSN		/ SET CURSOR TO 1 LESS THAN RULER POS'N
	DCA	CURSOR
	JMP	RLGETI

XVRBAD,
RLBADI,	JMS	BEEPER
	JMP	RLINE2

RLMNU,	JMS	RLEQTE 		/ CANCEL ANY MODS

	IFDEF	PERDEC	<
	TAD	(5556)
	DCA	OKSTR 		/ RESTORE RULER DISPLAY CODES
			>	/ END IFDEF PERDEC

	IFDEF	COLDEC	<
	TAD	(5572)
	DCA	OKSTR 		/ RESTORE RULER DISPLAY CODES
			> 	/ END IFDEF COLDEC

	IFDEF	COMDEC	<
	TAD	(5554)
	DCA	OKSTR 		/ RESTORE RULER DISPLAY CODES
			> 	/ END IFDEF COMDEC

	DCA	CURSOR
	TAD	LINE23
	DCA	CURPTR

/D159;	CIFMNU			/ CHANGE INSTRUCTION FIELD TO MENU FIELD
/D159;	PGSWAP			/ AC=0, SAVE SWAP AREA & RELOAD MENU CODE

	OVLJMP
	OVMENU			/ GO TO EDITOR MENU

/
/ TRANSFER TO "DELETE RULER" ROUTINE IN ANOTHER OVERLAY
/
RLOJDL,	OVLJMP
	OVRLDL

/ This next string has the same purpose as OKSTR, in that it defines
/ acceptable characters for ruler definitions.  However, whereas OKSTR
/ only has the definitions for correct 7 bit characters, this string
/ only has the definitions for correct 8 bit characters.

                      /1........1.........1.........1.........1.........1/
EIGHTC,	IFDEF ENGLSH <
	IFNDEF V30FAO <
	TEXT \                                   \
	>
	IFDEF V30FAO <
	TEXT \                            C       \
	>
	>

	IFDEF V30NOR <
	TEXT \                                   \
	>

	IFDEF V30SWE <
	TEXT \                                   \
	>

	IFDEF SPANISH <
	TEXT \                            C       \
	>

	IFDEF ITALIAN <
	TEXT "                         \#I    H G" >
	IFDEF DUTCH	<
	TEXT \                                   \
	>
	
	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

/***************************************************************************
/****			   START OF OVERLAY				****
/***************************************************************************

	OVRNUM=OVRNUM+200
	OVRBLK=OVRNUM%200+DLOEDO-1 / DISK BLOCK WHERE OVERLAY IS LOADED

	RELOC

	RELOC OVLAY1
	OVRNUM 			/ CURRENT OVERLAY NUMBER

	OVABRV=	.-OVLAY1+OVRNUM	/ GOLD ABBREVIATION ENTRY POINT
	JMP	XVABRV

	OVGETC=	.-OVLAY1+OVRNUM	/ GOLD LIBRARY ENTRY POINT
	JMP	XVGETC

	OVDCM2=	.-OVLAY1+OVRNUM
	JMP	XVDCM2


/ ERROR HANDLING FOR THE GET COPY, ABBREVIATION, AND LIBRARY CODE
EIGETY,	JMS	PROMPT 		/ PROMPT ERROR MESSAGE EIGER2
	EIGER2 			/ "NOT FOUND" ERROR MESSAGE

/ GET COPY, ABREVIATION, AND LIBRARY CODE
EIGETA,	TAD	(-EIGESL)
	DCA I	.+2 		/ SET BUFFER LENGTH (OVER BRACKET)
	JMS	GETLIN
	EIGES3 			/ GET PARA NAME
	TAD	GETLEN
	SNA
	JMP	EIGETD 		/ NOP IF NO NAME
	TAD	(EIGES3)
	DCA	X2 		/ FIX END OF STRING
	JMS	MNUGET
	MNLBRY 			/ GET LIBRARY FILE NUM
	JMS	EIGOPN
	JMP	EIGETD 		/ OPEN FOR READING
	JMS	EIGETK
	JMP	EIGETY

EIGETB,	JMS	RDNXNJ
	JMP	EIGETD 		/ GET NEXT CHAR FROM GRAF
	DCA	EIGTM1
	DCA	EIGTM2 		/ SAVE IT
	HLTTST
	JMP	EIGETD 		/ QUIT IF HALTED
	TAD	EIGTM1
	AND	P177
	TAD	(-"<+200)
	SZA CLA
	JMP	EIGETF 		/ CHECK FOR END
	JMS	RDNXNJ
	JMP	EIGETE
	DCA	EIGTM2
	TAD	EIGTM2
	AND	P177
	TAD	(-"<+200)
	SNA CLA
	JMP	EIGETD 		/ JUMP IF AT END
EIGETF,	TAD	EIGTM1
	JMS	EIGETG 		/ ELSE INSERT
	TAD	EIGTM2
	SZA
	JMS	EIGETG
	JMP	EIGETB 		/ AND LOOP FOR MORE

EIGETG,	XX
	JMS	CHKRPC
	JMP	EIGETH 		/ JUMP IF RULER
	JMS	CHKSPC		/ HELPS PRREVENT DISKETTE OVERFILL
	SZA
	INSCHR 			/ INSERT IF OK
EIGETX,	JMP I	EIGETG

EIGETH,	JMS	RDNXNJ
	JMP I	EIGETG
	TAD	(-ECMDRL)
	SZA CLA
	JMP	EIGETH 		/ GET TO MIDDLE
	JMS	SETRUL
	EIGETJ 			/ SET NWRUL
	JMS	CMPRUL
	JMP I	EIGETG 		/ JUMP IF =OLD
	TAD	CURPTR
	DCA	EIGTM1 		/ SAVE PTR
	JMS I	TLITBA 		/ INSERT NEW RULER
	TAD	(ECRMFL)
	JMS	INSERT 		/ SET MOD FLAG
	SLNMOD
	TAD	EIGTM1
	DCA	CURPTR 		/ RESTORE PTR
	CURMOV
	NOP 			/ FIX UP
	TAD	LINE23
	DCA	CURPTR 		/ RESTORE CURPTR
	DCA	CURSOR
	JMP I	EIGETG 		/ AND LOOP FOR NEXT INPUT

EIGETE,	TAD	EIGTM1
	INSCHR 			/ STRANGE END #1

EIGETD,	JMP I	TLITBC

EIGTM1,	0 			/ TEMPS
EIGTM2,	0

TLITBA,	INSRUL 			/ ****LITERALS TO BYPASS PAL8 LIMITS***
TLITBC,	EIFIX								/C168


	EIGESL=21 		/ MAX PARA NAME LENGTH

EIGES2,	"<-200
	"<-200
	ZBLOCK EIGESL+2 	/ BUFFER
	EIGES3=EIGES2+1 	/ BUFFER START FOR GETLIN



	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

EIGETJ,	XX
	JMS	RDNXNJ
	JMP	EIGETX
	CDFMYF
	JMP I	EIGETJ

EIGETK,	XX 			/ SET UP FOR RDFIND
	CDFMYF
	TAD	("<-200)
	DCA I	(EIGES3)
	TAD	(">-200)
	DCA I	X2
	TAD	(">-200)
	DCA I	X2
	DCA I	X2
	DCA	PSTBLK
	DCA	BASKCT
	JMS	RDFIND
	EIGES2
	JMP I	EIGETK
	ISZ	EIGETK 		/ BUMP FOR SUCCESSFUL RETURN
	JMP I	EIGETK

RDFIND,	XX
	CDFMYF 			/ FIND STRING IN SYSFIL
RDFLP1,	TAD I	RDFIND
	DCA	RDFPTR 		/ GET STRING PTR
RDFLP2,	JMS	RDNXNJ
	JMP	RDFXI1 		/ GET NEXT CHAR
	MQL
	HLTTST
	JMP	RDFXI1 		/ QUIT IF HALTED
	CDFMYF
	TAD I	RDFPTR 		/ COMPARE WITH STRING
	SWP
	JMS	USCMPR
	JMP	RDFLP1 		/ REINIT IF NO MATCH HERE
	ISZ	RDFPTR 		/ BUMP STRING PTR
	TAD I	RDFPTR 		/ END YET?
	SZA CLA
	JMP	RDFLP2 		/ CONTINUE MATCH IF NOT
	ISZ	RDFIND 		/ ELSE BUMP TO OK RETURN
RDFXI1,	ISZ	RDFIND
	JMP I	RDFIND 		/ RETURN TO CALLER

RDFPTR,	0 			/ TMP

XVABRV,	JMS	MNUGET 		/ CODE FOR ABRV OVERLAY
	MNABRV 			/ GET ABBREV FILE NUM
	JMS	EIGOPN
	JMP	EIFIX		/ INIT ABBREV FILE			/C168
	JMS	RDNXNJ
	JMP	EIABRA
	CLA 			/ CHECK IT
	TAD	(EIGES3)
	DCA	X2 		/ INIT STRING PTR
	GETINP
	SPA
	JMP	EIABRA 		/ GET 1ST CHAR
	JMS	XVABIN		/ Insert it (7 or 8 bit)		/A225
	GETINP			/ Get 2nd char					
	SPA			/ 					
	JMP	EIABRA		/ And process as for 1st		
	JMS	XVABIN		/ Insert it				/A225
	JMS	EIGETK
	JMP	EIABRA 		/ GO FIND IT
	JMP	EIGETB 		/ GO COPY IF FOUND

EIABRA,	JMP	EIBAD

XVGETC,	JMS	FXSCRL 		/ UPDATE SCREEN
	JMS	PROMPT
	EIGES1 			/ ASK FOR NAME
	JMP	EIGETA		/ GO TO CONTINUATION ROUTINE

XVDCM2,	TAD	CPYFNO 		/ SECOND OVERLAY
	JMS	EIGOPN
	JMP	EIFIX		/ INIT DOCUMENT FILE			/C168

EIDCMD,	JMS	RDNXNJ
	JMP	EIGETD 		/ GET A CHARACTER, EXIT IF DONE
	JMS	EIGETG 		/ INSERT CHARACTER
	HLTTST 			/ TEST IF HALT FLAG SET
	JMP	EIGETD 		/ YES, DONE
	JMP	EIDCMD 		/ NO, GO AROUND AGAIN

EIGOPN,	XX 			/ CHECK FILE, THEN OPEN FOR READING
	DCA	CPYFNO 		/ SAVE FILE NO
	TAD	CPYFNO
	CIA 			/ COMPARE AGAINST EDIT FILE
	TAD	FILENO
	SZA CLA
	JMP	.+3
	JMS	BEEPER 		/ COMPLAIN IF SAME
	JMP I	EIGOPN 		/ TAKE NON-SKIP RETURN

	TAD	CPYFNO
	JMS	DSKCAL
	XRDFIN 			/ ELSE INIT IT
	ISZ	EIGOPN
	JMP I	EIGOPN 		/ AND TAKE SKIP RETURN


/
/	Routine (blasted) to insert 7 or 8 bit (dead key) char into	/A225
/	 EIGESL buffer							/A225
/


XVABIN,	XX			
	DCA	XABRVC		/ Store 1st char			/A225
	TAD	XABRVC		/ Get it back				/A225
	AND	(200)		/ Is it 8 bit ?				/A225
	SZA CLA			/					/A225
	JMP	XABXPC		/ Yes, expand char			/A225
	TAD	XABRVC		/ Get char back				/A225
	DCA I	X2		/ And save it				/A225
	JMP I	XVABIN		/ Now exit				/A225
XABXPC,	TAD	XABRVC		/ get char				/A225
	JMS	BHOOK		/ Call Blaster				/A225
	AB8INS			/ 					/A225
	JMP I	XVABIN		/ return				/A225

XABRVC,	0			/ Temp for input char			/A225





	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

/***************************************************************************
/****			   START OF OVERLAY				****
/***************************************************************************

	OVRNUM=OVRNUM+200 	/ NEW OVERLAY
	OVRBLK=OVRNUM%200+DLOEDO-1 / DISK BLOCK WHERE OVERLAY IS LOADED

	RELOC

	RELOC OVLAY1
	OVRNUM 			/ CURRENT OVERLAY NUMBER


/D185	BEGIN HELP OVERLAY........CALL CLEAR SCREEN AND SAVE MENU DATA
/D185	OVHELP=	.-OVLAY1+OVRNUM
/D185	TAD	BASKCT		/ GET WASTEBASKET COUNT
/D185	DCA	T3		/ SAVE FOR HELP UNDELETE
/D185	JMS	EIDCMB		/ SAVE MENU DATA
/D185	OVLJMP;OVHLP1		/ START OF HELP OVERLAY
/D185	END HELP OVERLAY..........RESTORE MENU DATA AND POINTERS
/D185	OVHLPE=	.-OVLAY1+OVRNUM
/D185	JMS	EIDCMC		/ RESET PTRS
/D185	JMS	EIPSWP		/ GO RESTORE THE SWAP AREA		/A181
/D185	TAD	T2		/ FINISH  - GET RETURN CODE
/D185	SNA			/ IS CODE OR NULL(RET TO EDITOR)
/D185	JMP	EINEXT		/ RETURN TO NORMAL EDITOR FUNCTIONS	/C168
/D185	JMP	EINEXB		/ RETURN TO EDITOR ...WITH NEG CODE IN AC


	OVDCMT=	.-OVLAY1+OVRNUM / GET DOCUMENT

	JMS	EIDCMB 		/ SAVE MENU STUFF
	JMS	MNUPUT
	MNTMP1 			/ NO SPECIAL OPTIONS
	CIFMNU
	JMS I	MNUCAL
	DLMEM1 			/ CALL MENU
	JMS	EIDCMC 		/ RESTORE MENU STUFF
	JMS	EIPSWP		/ GO RESTORE THE SWAP AREA		/A181
	JMS	MNUGET
	MNTMP3 			/ GET FILE NUM FROM MENU
	SNA
	JMP	EIFIX		/ QUIT IF NULL				/C168
	DCA	CPYFNO 		/ ELSE SAVE FOR CHECKING
	OVLJMP;OVDCM2 		/ AND JUMP TO NEXT OVERLAY

	OVMENU=	.-OVLAY1+OVRNUM	/ EDITOR MENU

XVMENU,	JMS	EIDCMB 		/ SAVE MENU STUFF
	JMS	HDRGET
	HDRPSZ 			/ GIVE HIM OUR PAGE SIZE
	JMS	MNUPUT
	MNTMP3
/D186	CDFMYF
	TAD	WIDNAR		/ GET WIDE/NARROW FLAG			/A186
	SZA CLA			/ CONVERT TO 1/0 FLAG			/A186
	 AC0001			/ NARROW (52 DEC) = 1			/A186
	JMS	MNUPUT		/ STORE WHERE MENU CAN FIND IT		/A186
	 MNTMP8								/A186

	CIFMNU
	JMS I	MNUCAL
	DLMEM2 			/ CALL MENU

	DCA	LOWLIM		/ CLEAR SO THAT TESTLIM CAN SET IT OK	/A186
	JMS	MNUGET							/A186
	MNTMP8			/ GET WIDE/NARROW SCREEN FLAG		/A186
	CLL RAR			/ CONVERT TO FORM EDITOR CAN USE	/A186
	SZL CLA			/ SKIP IF WIDE MODE JUST SPECIFIED	/A186
	 TAD	(WIDTH-COLM81)	/ NARROW = 52 DECIMAL FOR EDITOR USE	/A186
	DCA	WIDNAR		/ STORE IT AWAY				/A186
	SNL CLA			/ WHAT IS IT?				/A186
	 CMA			/ WIDE, SET AC=-1, PRESERVE LINK!!	/A186
	DCA	WIDEFL		/ SET 'NEED TO GO TO 132 COL.' FLAG	/A192
	SNL			/ SKIP IF NARROW			/A192
	 JMS	SET132		/ WIDE, GO TO 132 COLUMN MODE		/A186
	JMS	EIDCMC 		/ RESTORE MENU STUFF
	JMS	MNUGET
	MNTMP3 			/ GET PAGE SIZE BACK AGAIN
	JMS	HDRPUT
	HDRPSZ 			/ PUT BACK IN HEADER
	JMS	MNUGET
	MNTMP5 			/ WRITE SYSTEM OPTIONS PAGE IF MODIFIED
	SZA CLA
	JMS	EIMSVU

/ +++	Modify RULOFF Case-Table to turn Display-Rulers ON or OFF.	/a177
/									/a177
/	MNSTAT = 0 or 1 ... Ruler Display ON				/a177
/	MNSTAT = 2 or 3 ... Ruler Display OFF				/a177
/									/a177
	JMS	OV2JMP		/ LOAD OVERLAY 2			/a177
	OVRLOF			/ Adjust Case-Table and Continue	/a177

	JMS	MNUGET
	MNTMP4 			/ GET MNU OPTION RETURN
	TAD	(JMP I EIMNUA) 	/ USE TO JUMP THRU TABLE
	DCA	.+1
	JMP I	EIMNUA 		/ TAKE OPTION JUMP
EIMNUA,	EIMNU0 			/ RETURN
	EIMNU1 			/ DK
	EIMNU2 			/ NULL VALUE
	EIMNU3 			/ CONTINUE PRINTER
	EIMNU4	 		/ FINISH DOCUMENT
	EIMNU5			/ GLOBAL SEARCH AND REPLACE
	EIMNU6			/ AUTO-PAGINATION

EIMNU0,	JMS	EIPSWP		/ GO RESTORE THE SWAP AREA		/A181
	JMP	EIFIX		/ RETURN TO EDITOR			/C168

EIMNU4,	JMS	EIPSWP		/ GO RESTORE THE SWAP AREA		/A181
	JMP	EIFILE		/ GO FILE THE DOCUMENT

EIMNU2,				/ NULL VALUE
EIMNU5,	DCA	PSTBLK		/ RESET PASTE BLOCK POINTER TO CAUSE
				/ PASTE BLOCK TO BE RE-INITITED IN CORE
	OVLJMP;OVGSRP		/ GO TO GSR OVERLAY			/C210


/D181	EIDCMA,	XX
/D181		CDFMNU
/D181		AC7777
/D181		TAD I	(FNAMSP)
/D181		DCA	X1
/D181		TAD	(SMULOC-1)
/D181		DCA	X2
/D181		JMP I	EIDCMA


EIDCMB,	XX
	CDFMNU			/ CHANGE TO MENU FIELD			/A181
	AC7777			/ SET UP FOR A DECREMENT		/A181
	TAD I	(FNAMSP)	/ PICK UP ADDRESS OF FILE NAME BUFFER	/A181
	DCA	EDICMX		/ STORE SOURCE ADDRESS			/A181

	JMS	CPYBUF		/ CALL SYSTEM ROUTINE TO MOVE BUFFER	/A181
	-STRLEN			/ NUMBER OF WORDS TO MOVE		/A181
	CDFMNU			/ SOURCE FIELD				/A181
EDICMX,	0			/ SOURCE ADDRESS			/A181
	CDFMYF			/ DESTINATION FIELD			/A181
	SMULOC-1		/ DESTINATION ADDRESS			/A181

	DCA	PSTBLK
	DCA	BASKCT 		/ CLEAR PASTE BUF FLAGS

	JMS	CLR132		/ MAKE SURE THE SCREEN IS IN NARROW MODE
	AC0003			/ SET UP TO RESET SCROLL REGION
	CIFMNU			/ CHANGE INSTRUCTION FIELD TO MENU FIELD
	JMS I	(CALLN1)	/ RESET SCROLL REGION SET ABSOLUTE MODE
	CIFMNU			/ CHANGE INSTRUCTION FIELD TO MENU FIELD
	PGSWAP			/ AC=0, SAVE SWAP AREA & RELOAD MENU CODE

	JMP I	EIDCMB

EIDCMC,	XX
	TAD	EDICMX		/ PICK UP ADDRESS OF FILE NAME BUFFER	/A181
	DCA	EDICMY		/ STORE SOURCE ADDRESS			/A181

	JMS	CPYBUF		/ CALL SYSTEM ROUTINE TO MOVE BUFFER	/A181
	-STRLEN			/ NUMBER OF WORDS TO MOVE		/A181
	CDFMYF			/ SOURCE FIELD				/A181
	SMULOC-1		/ SOURCE ADDRESS			/A181
	CDFMNU			/ DESTINATION FIELD			/A181
EDICMY,	0			/ DESTINATION ADDRESS			/A181

/D192	TAD	SPLTFL		/ CHECK FOR WIDE SCREEN
/D192	SZA CLA			/ SKIP IF NARROW
	JMS	SET132		/ CONVERT TO 132 COLUMN MODE (IF WIDE!)
	JMS	CLSSET		/ INITIALIZE SCROLL VALUES FOR STATUS
	JMP I	EIDCMC

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

EIMNU3,	AC0006 			/ LOAD 'CONTINUE' ACTION CODE
	CDFPRT 			/ GET TO PRINTER FIELD
	DCA I	(PRACTN) 	/ SET ACTION CODE
/D173	TAD I	(PRSTOP) 	/ STOP PRINTER,
/D173	SZA CLA
/D173	JMP	.+4 		/ IF NOT ALREADY STOPPED
	AC0001
/D173	TAD	USERNO 		/ BY SETTING OUR NUMBER
	DCA I	(PRSTOP) 	/ IN PRINTER STOP FLAG
	CDFMYF 			/ BACK TO OUR FIELD
	JMP	EIMNU0		/ GO RETURN TO EDITOR			/A173

EIMNU1,	JMS	CLR132		/ DON'T NEED WIDE SCREEN HERE
	OVLJMP;OVUDKS		/ GO TRANSFER TO UDK OVERLAY

EIMNU6,	JMS	EIPSWP		/ GO RESTORE THE SWAP AREA		/A181
	JMS	TSTLIM		/ GO SET UP THE LIMITS OF DISPLAY	/A186
	JMS	FXSCRL		/ GO REPAINT THE SCREEN			/A186
	OVLJMP;OVAPAG		/ JUMP TO AUTO GOLD PAGE OVERLAY


EIMSVU,	XX 			/ SAVE SYSTEM OPTIONS PAGE
	TAD	(DLSVAL)	/ DISK BLOCK TO READ			/A181
	CDFMYF			/ FIELD TO READ IT INTO			/A181
	JMS	SYSIO		/ SYSTEM ROUTINE TO READ A DISK BLOCK	/A181
	RXERD			/ READ COMMAND CODE			/A181
	OVLAY2			/ BUFFER TO READ IT INTO		/A181

	JMS	CPYBUF		/ CALL SYSTEM ROUTINE TO MOVE BUFFER	/A181
	-MUSYSL			/ NUMBER OF WORDS TO MOVE		/A181
	CDFMNU			/ SOURCE FIELD				/A181
	MUSYSV-1		/ SOURCE ADDRESS			/A181
	CDFMYF			/ DESTINATION FIELD			/A181
	OVLAY2-1		/ DESTINATION ADDRESS			/A181

	TAD	(DLSVAL)	/ DISK BLOCK TO WRITE			/M181
	CDFMYF			/ FIELD TO WRITE FROM			/M181
	JMS	SYSIO		/ SYSTEM ROUTINE TO WRITE A DISK BLOCK	/M181
	RXEWT			/ WRITE COMMAND CODE			/M181
EIMLAY,	OVLAY2			/ BUFFER TO WRITE FROM			/M181

	DCA I	EIMLAY		/ ZAP POINTER TO SECOND OVERLAY NUMBER	/M181
	JMP I	EIMSVU		/ RETURN TO CALLER			/M181

SMULOC,	ZBLOCK STRLEN		/ LOCATION TO SAVE THE FILE NAME BUFFER
/D181	SMOOT,	0		/ SHOWS LENGTH OF SMULOC BLOCK

EIPSWP,	XX			/ RESTORE THE SWAP AREA ROUTINE		/A181
	AC7777			/ SET AC = -1				/A181
	CIFMNU			/ CHANGE INSTRUCTION FIELD TO MENU FIELD/A181
	PGSWAP			/ AC=-1 SO JUST LOAD IN THE SAVE AREA	/A181
	JMP I	EIPSWP		/ RETURN TO CALLER			/A181

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE


/***************************************************************************
/****			   START OF OVERLAY				****
/***************************************************************************

	OVRNUM=OVRNUM+200 	/ NEW OVERLAY
	OVRBLK=OVRNUM%200+DLOEDO-1 / DISK BLOCK WHERE OVERLAY IS LOADED

	RELOC

	RELOC OVLAY1
	OVRNUM 			/ CURRENT OVERLAY NUMBER

	OVSCUT=	.-OVLAY1+OVRNUM	/ ENTRY POINT FOR STANDARD CUT OVERLAY
	JMP	XVSCUT

	OVCLPB=	.-OVLAY1+OVRNUM	/ ENTRY POINT FOR CLEAR CUT/ PASTE BUFFER
	JMP	XVCLPB

	OVGCUT=	.-OVLAY1+OVRNUM	/ ENTRY POINT FOR GOLD CUT OVERLAY
	JMP	XVGCUT

	OVREPL=	.-OVLAY1+OVRNUM	/ ENTRY POINT FOR GOLD REPLACE OVERLAY

	TSTSLT 			/ CHECK FOR SELECT REGION		/C204
	JMP	CLRGSR		/ ERROR IF NOT IN SELECT
	TAD	(SLCTMD)	/ PICK UP CODE FOR SELECT COMMAND
	DCA	GRAMUN 		/ SET "FLAG" UNIT TYPE
	TAD	(ESNOPC)	/ PICK UP NULL OUTPUT ROUTINE ADDRESS
	JMS	CUTSUB 		/ DELETE TO NOWHERE
	OVLJMP			/ JUMP TO DO PASTE
	OVPSTE

CLRGSR,	DCA	GSRF		/ CLEAR GSR FLAG			/C204
	JMP	EIBAD		/ ERROR IF NO SELECT


/ ENTRY POINT FOR GOLD CUT OVERLAY

XVGCUT,	TAD	(ESCUTX)	/ PICK UP OUTPUT ROUTINE ADDRESS	/A204
	DCA	CUTOUT 		/ SAVE OUTPUT ROUTINE POINTER		/A204

	JMS	ESCUTY 		/ GO INITIALIZE POINTERS
	JMS	SETUNT		/ SETUP FOR CHKUNT

	JMS	RLEQTE 		/ SET UP FOR RULER CHANGE CHECKING	/A204
	JMS	CUTRUL 		/ SAVE CURRENT RULER			/A204
	JMP	XVGCU1 		/ PASTE BUFFER OVERFLOW ERROR		/A204

	CDFMYF			/ RESET BACK TO OUR FIELD
	DCA	JCLGCT		/ SET FLAG TO NOT DELETE PAGE MARKER
	DCA	SETRUL		/ CLEAR FLAG INDICATING RULER CROSSED	/A204

	JMS	GETUNT 		/ CO-ROUTINE, GET CHARACTER UNTIL SELECT
GCUTNX,	XX			/ RESTART CO-ROUTINE ENTRY POINT
	SNA CLA			/ RETURN FROM CO-ROUTINE WITH CHAR OR NULL/C204
	JMP	XVGCU1		/ JUMP IF ALL DONE

	CDFMYF			/ RESET BACK TO OUR FIELD		/A204
	TAD	SETRUL		/ GET THE RULER CROSSING FLAG		/A204
	SNA CLA			/ DID WE CROSS A RULER ?		/A204
	JMP	XVGCU0		/ NO, GO PUT CHARACTER INTO PASTE BUFFER/A204

	JMS	CUTRUL		/ YES, PUT NEW RULER INTO PASTE BUFFER	/A204
	JMP	XVGCU1 		/ PASTE BUFFER OVERFLOW ERROR		/A204

	CDFMYF			/ RESET BACK TO OUR FIELD		/A204
	DCA	SETRUL		/ CLEAR THE FLAG FOR NEXT TIME		/A204

XVGCU0,	CDFBUF			/ SET TO BUFFER FIELD			/A204
	TAD I	CURPTR		/ PICK UP THE CURRENT CHARACTER		/A204
	JMS	ESCUTX		/ STUFF IT INTO THE PASTE BUFFER
	JMP I	GCUTNX		/ GO GET ANOTHER CHARACTER
	ISZ	CURPTR		/ OVERFLOW, SKIP OVER CURRENT CHARACTER	/A205

XVGCU1,	CDFMYF			/ BACK TO OUR FIELD
	TAD	GCLIT1		/ RESTORE JCLEAN LITERAL
	DCA	JCLGCT
	JMP	ESCUT3 		/ PUT ONE MORE IN PSTE BUFFER

GCLIT1,	JTSTOF-ECPMRK		/ LITERAL FOR JCLEAN TO DELETE PG MRK'S

/ ENTRY POINT FOR STANDARD CUT OVERLAY

XVSCUT,	JMS	ESCUTY 		/ GO INITIALIZE POINTERS
	TAD	(ESCUTX)	/ PICK UP OUTPUT ROUTINE ADDRESS
	JMS	CUTSUB 		/ DELETE SELECT RANGE TO PASTE BUFFER

ESCUT3,	ISZ	ESCUT1		/ CHECK FOR OVERFLOW
	JMP	ESCUT4 		/ JUMP IF NORMAL TERMINATE

	JMS	BEEPER 		/ ELSE COMPLAIN
	JMP	CUTMOV		/ KILL SELECT & BACK UP TO OVERFLOW POINT/A205
/D205	JMP	UNSLCT 		/ SCROLL TO SELECT POINT

ESCUT4,	CDFBUF
	DCA I	PSTPTR 		/ SET PASTE STOPPER
	TAD	(RXEWT+2000)
	JMS	PSTIO 		/ OUTPUT LAST BUFFER
	JMP	EINEXT 		/ AND GO LISTEN

ESCUT1,	0			/ LOCATION USED FOR OVERFLOW FLAG

ESCUTX,	XX 			/ ROUTINE TO PUT A CHARACTER TO PASTE BUFFER
	CDFBUF			/ SET TO BUFFER FIELD
	DCA I	PSTPTR		/ STORE CHARACTER FOR OUTPUT
	ISZ	PSTPTR		/ BUMP THE POINTER INTO THE PASTE BUFFER
	JMP I	ESCUTX 		/ RETURN IF NOT FULL

	TAD	(RXEWT+2000)	/ PICK UP THE CODE FOR A DISK BLOCK WRITE
	JMS	PSTIO		/ GO OUTPUT THE PASTE BUFFER BLOCK
	ISZ	PSTBLK 		/ BUMP THE BLOCK NUMBER
	TAD	PSTBLK		/ PICK UP THE BLOCK NUMBER
	TAD	(-PSTEND)	/ COMBINE WITH THE LIMIT OF BLOCKS
	SZA CLA			/ DID WE DO THE LAST PASTE BUFFER BLOCK
	JMP I	ESCUTX 		/ RETURN IF NOT

	AC7777			/ SET AC TO A MINUS 1
	DCA	ESCUT1 		/ SET OVERFLOW FLAG
	ISZ	ESCUTX 		/ BUMP TO ABNORMAL RETURN
	JMP I	ESCUTX 		/ AND TAKE IT

ESCUTY,	XX			/ ROUTINE TO INITIALIZE POINTERS
	TSTSLT			/ CHECK FOR SELECT REGION
	JMP	EIBAD 		/ ERROR IF NOT IN SELECT
	TAD	(PSTEBG)	/ PICK UP START BLOCK OF PASTE BUFFER
	DCA	PSTBLK 		/ SET TO BEGINNING BLOCK OF FILE
	JMS	SETPST 		/ SET BUFFER PTR AND COUNT
	DCA	ESCUT1 		/ CLEAR OVERFLOW FLAG
	TAD	(SLCTMD)	/ PICK UP CODE FOR SELECT COMMAND
	DCA	GRAMUN 		/ SET SELECT UNIT TYPE
	JMP I	ESCUTY		/ RETURN TO CALLER


/ ENTRY POINT FOR "CLEAR CUT/ PASTE BUFFER" OVERLAY
/ WHEN READING FROM THE CUT/ PASTE BUFFER, THE PROCESS STOPS
/ AS SOON AS A ZERO IS READ, HENCE PUT A ZERO IN THE FIRST
/ WORD OF THE BUFFER, AND THE BUFFER APPEARS EMPTY

XVCLPB,	CLA

/ IF the entry into "OVJUMP" is from "F" (FINISHED using the system)
/ THEN "Hang-up" the modem

	TAD	OVJUMP
	AND	(7600)
	TAD	(-200)
	SZA CLA
	JMP	.+5
	TAD	(7402)
	CIFSYS
	HS2OU
	CLA

	TAD	(PSTEBG)
	DCA	PSTBLK		/ SET TO BEGINNING BLOCK OF FILE
	TAD	(PSTEBF)
	DCA	PSTPTR		/ RESET POINTERS
	CDFBUF
	DCA I	PSTPTR		/ CLEAR THE FIRST WORD OF THE BUFFER
	TAD	(RXEWT+2000)
	JMS	PSTIO		/ PUT OUT BUFFER
	JMP	OVJRTN		/ AND RETURN


	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

CUTMOV,	TAD	(ECTMRK)	/ PICK UP POSITION MARKER		/A205
	JMS	INSERT		/ INSERT MARK INTO TEXT BUFFER		/A205

	MODSET;	EDTMOD		/ SET ADVANCE CHARACTER MODE		/A205
	JMS	LODCHR		/ PICK UP CURRENT OR NEXT CHARACTER	/A205
	JMP	EIFIX		/ ERROR, SHOULD NOT BE AT END OF FILE	/A205

	JMS	GETUNT		/ CO-ROUTINE TO GET NEXT UNIT		/A205
CUTXXX,	.-.			/ RETURN POINT BACK TO CO-ROUTINE	/A205
	SZA CLA			/ DID WE FIND THE SELECT MARK		/A205
	JMP I	CUTXXX		/ NO, GO CHECK NEXT CHARACTER		/A205

CUTOVR,	AC7777			/ SET UP FOR A BACKWARD MOVE		/A205
	CURMOV			/ MOVE BACK ONE CHARACTER		/A205
	NOP			/ EOF RETURN, IMPOSSIBLE AT THIS TIME	/A205

	TAD I	CURPTR		/ PICK UP THE CURRENT CHARACTER		/A205
	CIA			/ MAKE IT NEGATIVE			/A205
	TAD	(ECTMRK)	/ CHECK FOR PLACEMENT MARK		/A205
	SZA CLA			/ IS THIS THE MARK WE JUST PUT IN ?	/A205
	JMP	CUTOVR		/ NO, GO CHECK AGAIN			/A205

	DCA I	CURPTR		/ CLEAR THE MARK FROM THE BUFFER	/A205
	JMP	EIFIX		/ GO HANDLE NEXT COMMAND FROM USER	/A205

	CUTUN1=	CUTXXX		/ USE FOR STORAGE LOCATION		/A205


ESNOPC,	XX			/ NULL OUTPUT ROUTINE FOR GOLD REPLACE
	CLA			/ CLEAR ARGUMENT
	JMP I	ESNOPC		/ RETURN TO CALLER


CUTSUB,	XX 			/ DELETE SELECTED TEXT THRU ARG-ROUTINE
	DCA	CUTOUT 		/ SAVE OUTPUT ROUTINE POINTER
	TAD	CURPTR		/ GET CURSOR POINTER ADDRESS IN BUFFER
	DCA	CUTUN1 		/ SAVE CURRENT POINTER

	JMS	SETUNT 		/ SET UP FOR CHKUNT
	JMS	RLEQTE 		/ SET UP FOR RULER CHANGE CHECKING
	JMS	CUTRUL 		/ SAVE CURRENT RULER
	JMP	CUTUNX		/ PASTE BUFFER OVERFLOW ERROR		/A204

	JMS	LODCHR		/ GET CURRENT OR NEXT CHARACTER
	JMP I	CUTSUB 		/ QUIT AT EOF, RETURN TO CALLER		/C204

	JMS	CHKUNT 		/ CO-ROUTINE CHECK FOR DONE
CUTNXT,	.-.
	SPA CLA			/ RETURNS -1 WHEN DONE
	JMP	CUTUNX 		/ QUIT IF DONE

	TAD I	CURPTR 		/ GET THE CURRENT CHARACTER BACK
	TAD	(-ECSTRL)	/ COMBINE WITH THE START OF RULER CODE
	SZA			/ IS THIS THE START OF A RULER		/C204
	JMP	CUTUNR 		/ JUMP IF NO RULER

	TAD	CUTUN1		/ PICK UP SAVED BUFFER POINTER		/C204
	DCA	CURPTR		/ RESTORE VALUE TO CURPTR
	JMS	ESNWRL 		/ COLLECT NEW RULER
	JMS	CUTRUL 		/ OUTPUT TO "CUTOUT"
	JMP	CUTUNX		/ PASTE BUFFER OVERFLOW ERROR		/A204

	TAD	CUTUN1		/ PICK UP SAVED BUFFER POINTER
	DCA	CURPTR		/ RESTORE VALUE TO CURPTR
	JMS	DLTRLR 		/ DELETE RULER
	JMP	CUTUNC 		/ CONTINUE

CUTUNR,	TAD	(ECSTRL-ECRMFL)	/ COMBINE WITH RULER MODIFIED CODE	/C204
	SZA CLA			/ IS THIS RULER MODIFIED FLAG CODE	/C204
	JMP	CUTUNM 		/ JUMP IF NOT RULER MODIFIED FLAG

	TAD I	CURPTR		/ PICK UP THE CURRENT CHARACTER		/C204
	DCA	RLRMOD		/ SAVE RULER MODIFIED FLAG
	JMP	CUTUNA		/ JUMP TO DELETE IT

CUTUNM,	TAD I	CURPTR		/ PICK UP THE CURENT CHARACTER		/C204
	JMS	ESJCHK		/ GO CHECK FOR JUSTIFIED CODES
	SNA CLA			/ IS THIS A JUSTIFIED CHARACTER CODE
	JMP	CUTUNA 		/ JUMP IF J-CODES

	TAD I	CURPTR		/ PICK UP THE CURENT CHARACTER
	JMS	CUTCHR 		/ OUTPUT CHARACTER TO PASTE BUFFER

CUTUNA,	DCA I	CURPTR 		/ DELETE CHARACTER

CUTUND,	AC0001			/ SET UP FOR A FORWARD MOVE		/C204
	CHKPTR			/ MOVE FORWARD AND CHECK NEXT CHARACTER
	SNA			/ IS IT A NULL CHARACTER
	JMP	CUTUND 		/ YES, GO GET NEXT CHARACTER		/C204

	SPA CLA			/ IS IT A BUFFER TERMINATOR CODE	/C204
	JMP	CUTUNB 		/ YES, GO RESET BUFFER WRAP POINTERS
	TAD I	CURPTR 		/ NO, PICK UP THE CURRENT CHARACTER
	JMP I	CUTNXT 		/ GO CHECK FOR DONE

CUTUNB,	TAD I	CURPTR		/ PICK UP THE CURRENT CHARACTER		/C204
	DCA I	CUTUN1 		/ COPY ETX POINTER
	TAD	CUTUN1
	DCA	CURPTR 		/ RESTORE CURPTR

CUTUNC,	ADVPTR			/ ADVANCE TO NEXT CHARACTER
	JMP	CUTUNX 		/ QUIT IF EOF
	JMP I	CUTNXT 		/ ELSE GO CHECK FOR DONE

CUTCHR,	XX 			/ OUTPUT CHAR TO "CUTOUT" ROUTINE
	JMS I	CUTOUT
	JMP I	CUTCHR 		/ JUST RETURN IF OK
	DCA I	CURPTR 		/ DELETE LAST CHAR AND QUIT IF OVERFLOW

CUTUNX,	TAD	CUTUN1
	DCA	CURPTR 		/ RESTORE PTR

	SLNMOD			/ SET LINE MODIFIED FLAG
	TAD	LINMOD
	JMS	INSERT 		/ SAVE MOD FLAG

	JMS	CMPRUL
	JMP	CUTUNY 		/ JUMP IF NO RULER CHANGE
	JMS	INSRUL 		/ ELSE INSERT LAST RULER

CUTUNY,	TAD	CUTUN1
	DCA	CURPTR 		/ RESTORE CURPTR AGAIN
	SLNMOD			/ SET LINE MODIFIED FLAG
	JMP I	CUTSUB 		/ RETURN TO CALLER

CUTRUL,	XX 			/ OUTPUT RULER
	TAD	(ECSTRL)	/ PICK UP START OF RULER CODE
	JMS	CUTCHX		/ OUTPUT IT TO PASTE BUFFER
	JMS	MAKRUL		/ MAKE A RULER IN THE PASTE BUFFER
	NWRUL			/ RULER TO USE FOR A PATTERN
	CUTCHX			/ OUTPUT ROUTINE TO USE TO MAKE A RULER
	TAD	(ECNDRL)	/ PICK UP END OF RULER CODE
	JMS	CUTCHX		/ OUTPUT IT TO PASTE BUFFER
	ISZ	CUTRUL		/ BUMP TO "OK" RETURN			/A204
	JMP I	CUTRUL		/ RETURN TO CALLER

CUTCHX,	XX 			/ OUTPUT RULER CHARACTER TO "CUTOUT"
	JMS I	CUTOUT
	JMP I	CUTCHX 		/ JUST RETURN IF OK
	JMP I	CUTRUL 		/ ELSE QUIT				/C204

CUTOUT,	.-.			/ LOCATION TO USE FOR CUT OPERATION
/D205	CUTUN1,	.-.		/ PLACE TO SAVE THE VALUE OF CURPTR

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

/***************************************************************************
/****			   START OF OVERLAY				****
/***************************************************************************

	OVRNUM=OVRNUM+200
	OVRBLK=OVRNUM%200+DLOEDO-1 / DISK BLOCK WHERE OVERLAY IS LOADED

	RELOC
	RELOC	OVLAY1
	OVRNUM

	OVGBKP=	.-OVLAY1+OVRNUM
	JMP	GLDBKP		/ TRANSFER TO GOLD BACKUP ROUTINE

	OVGADV=	.-OVLAY1+OVRNUM
	JMP	GLDADV		/ TRANSFER TO GOLD ADVANCE ROUTINE


/ OVNWLN  --  check for permature termination of a centered line.

	OVNWLN=	.-OVLAY1+OVRNUM
	JMP	XVNWLN

	OVGPST=	.-OVLAY1+OVRNUM / EXACT PASTE OVERLAY
	AC7777 			/ SET EXACT PASTE FLAG
				/ AND FALL THRU TO PASTE
	OVPSTE=	.-OVLAY1+OVRNUM / "PASTE" OVERLAY
PSTE4,	DCA	GLDPSF 		/ SET (OR CLEAR) EXACT PASTE FLAG
	DCA	GETPSF 		/ CLEAR EOF FLAG
	TAD	GLDPSF
	SZA CLA
	JMS I	TLITCJ 		/ SAVE RULER IF EXACT PASTE
	JMS	SETPST 		/ SET UP BUFFER PTRS
	TAD	PSTBLK
	TAD	TLITCB 		/ NEED TO READ FIRST?
	SNA CLA
	JMP	PSTE1 		/ JUMP IF NOT
	TAD	(PSTEBG)
	DCA	PSTBLK 		/ ELSE SET IT UP
PSTE3,	TAD	TLITCC
	JMS	PSTIO 		/ AND READ IT IN
PSTE1,	TAD I	PSTPTR
PSTE9,	SNA
	JMP	PSTXIT 		/ JUMP IF DONE
	JMS	GSRTST		/ IF NOT IN GSR THEN TEST FOR GOLD+HALT	/M195
	JMP	PSTXIT		/ STOP IF ONE FOUND
	JMS	CHKSPC		/ Check for enough space on diskette
	JMS I	TLITCD
	JMP I	TLITCE 		/ JUMP IF RULER
	SZA 			/ SKIP IF REDUNDANT
/D164;	 JMS	DOINSR		/ ELSE INSERT CHAR IN FILE		/A162
	INSCHR 			/ ELSE INSERT CHAR IN FILE		/M164
PSTE8,	JMS I	TLITCF
	JMP	PSTE9 		/ LOOP FOR ALL CHARS

TLITCA,	EIFIX								/C168
TLITCB,	-PSTEBG
TLITCC,	RXERD
TLITCD,	CHKRPC
TLITCE,	PSTRUL
TLITCF,	GETPST
TLITCG,	12
TLITCH,	RLGETS
TLITCI,	PSTRLX
TLITCJ,	SAVCRL

PSTXIT,	TAD	GSRF		/ IS THE GLOBAL SEARCH FLAG SET?
	SNA CLA
	JMP	PSTEXT		/ -NO- DO NORMAL REPLACE EXIT.
	OVLJMP			/ -YES- CALL BACK THE SEARCH AND
	OVCONT			/ SELECT OVERLAY TO CONTINUE G.S.R

PSTEXT,	TAD	GLDPSF 		/ EXACT PASTE?
	SNA CLA
	JMP I	TLITCA 		/ RETURN IF NOT
	TAD	TLITCG
	JMS I	TLITCH 		/ ELSE RESTORE RULER
	JMS I	TLITCI
	JMP I	TLITCA 		/ AND THEN RETURN

PSTRUL,	CLA
	JMS	SETRUL
	GETPST 			/ GET NEW RULER FROM PASTE BUFFER
	TAD	GETPSF
	SZA CLA
	JMP	PSTXIT 		/ JUMP IF ABNORMAL TERMINATION
	TAD	GLDPSF
	SZA CLA
	JMS	PSTRLX 		/ INSERT RULER IF EXACT PASTE IN EFFECT
	JMP	PSTE8 		/ THEN GO GET MORE

PSTRLX,	XX 			/ PASTE RULER
	JMS	CMPRUL
	JMP I	PSTRLX 		/ JUST RETURN IF NOT NECESSARY
	TAD	CURPTR
	DCA	PSTRL2
	JMS	INSRUL 		/ ELSE INSERT NEW RULER
	TAD	(207)
	JMS	INSERT 		/ AND RULER MOD FLAG
	TAD	PSTRL2
	DCA	CURPTR 		/ RESTORE CURPTR
	SLNMOD
	CURMOV
	NOP 			/ ADVANCE OVER RULER
	JMP I	PSTRLX 		/ AND RETURN
PSTRL2,	.-.

SAVCRL,	XX			/ SAVE CURRENT RULER (AS RLR 10.)
	JMS	CPYBUF
	-RULSIZ
	CDFMYF
	CURUL-1
	CDFBUF
	PSTEBF
	TAD	(DLRLRE+5)
	DCA	PSTBLK
	TAD	(RXEWT+2000)
	JMS	PSTIO
	JMP I	SAVCRL

	OVUDLT=	.-OVLAY1+OVRNUM / UNDELETE ENTRY
	TAD	BASKCT 		/ GET WASTEBASKET COUNT
	SNA
	JMP	EIFIX		/ IGNORE IF NULL			/C168
	CIA
	DCA	UDLTM1
	TAD	(BASKET-1)
	DCA	UDLTX0 		/ INIT BASKET PTR

UDLTLP,	CDFBUF 			/ GET TO WASTEBASKET FIELD
	TAD I	UDLTX0 		/ GET NEXT CHAR
	JMS	CHKRPC
	CLA 			/ CHECK FOR REDUNDANT PRINT CONTROL
	SZA 			/ SKIP IF REDUNDANT
	JMS	DOINSR		/ INSERT CHAR (unless redundant)
	ISZ	UDLTM1
	JMP	UDLTLP 		/ LOOP FOR ALL
	JMP	EIFIX		/ RESET MODE AND GET NEXT		/C168

	UDLTX0=X5
UDLTM1,	0 			/ TEMP

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

/ ROUTINE TO CHECK FOR GOLD HALT IF NOT IN GLOBAL SEARCH AND REPLACE	/A195

GSRTST,	XX			/ DO HLTTST IF NOT DOING GSR		/A195
	DCA	GSRTS2		/ SAVE THE ACCUMULATOR			/A195
	TAD	GSRF		/ GET THE GSR IN PROGRESS FLAG		/A195
	SZA CLA			/ ARE WE DOING A GSR OPERATION ?	/A195
	JMP	GSRTS1		/ YES, TAKE NORMAL EXIT			/A195
	HLTTST			/ CHECK THE GOLD HALT FLAG		/A195
	SKP			/ ONE FOUND, TAKE ABORT EXIT		/A195
GSRTS1,	ISZ	GSRTST		/ BUMP RETURN POINTER FOR NORMAL RETURN	/A195
	TAD	GSRTS2		/ RETREIVE THE CONTENTS OF THE AC	/A195
	JMP I	GSRTST		/ RETURN TO CALLER			/A195

GSRTS2,	0			/ LOCATION TO SAVE THE AC		/A195

XVNWLN,	TAD	CURPTR		/ SAVE CURRENT TEXT POINTER.
	DCA	JNWLNP		/  ...
	TAD	T2		/ SAVE T2 (FOR EINWLN).
	DCA	NWLNT2		/  ...
	TAD	RGTMAR		/ COMPUTE A LOOP COUNTER.
	TAD	(-COLM80)
	SMA CLA
	TAD	(-COLLIM+COLM81)
	TAD	(-COLM81)		/  ...
	DCA	NWLNCT		/ SET MAX LOOP COUNTER.
	JMS	LODCHR		/ GET 1ST CHAR.
	JMP	NWLND		/ JMP IF NO MORE TEXT.
	JMP	NWLNB		/ MERGE BELOW.
NWLNA,	ADVSPC			/ BUMP TO NEXT POSN.
	JMP	NWLND
NWLNB,	AND	P177		/ ISOLATE LO BITS.
	TAD	(-ECNWLN)	/ CHECK FOR LINE TERMINATOR.
	SZA CLA			/ SKIP IF LINE TERMINATOR.
	JMP	NWLNC		/ NOT A TERMINATOR. CHECK FOR DONE.
	TAD I	CURPTR		/ GET CHARACTER BACK.
	TAD	(-ECENLN)	/ IS IT A "CENTER"ED MARK?

	SNA CLA			/ SKIP IF NOT				/A182
	JMS	RSTRLN		/ WE MUST RE-PAINT THE LINE		/A182
	JMP	NWLND		/ EXIT BELOW.				/A182

/D182	SZA CLA			/ SKIP IF YES. WE MUST RE-PAINT THE LINE.
/D182	JMP	NWLND		/ NOPE. CONTINUE AS IS.
/D182	TAD	CURSOR		/ SAVE CURSOR.
/D182	DCA	NWLNCT		/  ...
/D182	DCA	CURSOR		/ RESET TO BEGINING OF LINE.
/D182	SLNMOD			/ SET LINE TO BE REPAINTED FROM START.
/D182	TAD	NWLNCT		/ RESTORE CURSOR.
/D182	DCA	CURSOR		/  ...
/D182	JMP	NWLND		/ EXIT BELOW.

NWLNC,	ISZ	NWLNCT		/ 1 MORE POSN CHECKED OUT.
	JMP	NWLNA		/ CONTINUE TESTING.
NWLND,	TAD	JNWLNP		/ RESTORE CURSOR POINTER.
	DCA	CURPTR		/  ...
	TAD	NWLNT2		/ RESTORE T2 (FOR EINWLN, ETC.)
	DCA	T2		/  ...
	JMP	OVJRTN		/ return to caller.

NWLNT2,	0			/ TEMP HOLDING PLACE FOR "T2".
JNWLNP,	0			/ SAVE LOCATION FOR "CURPTR".
NWLNCT,	0			/ TEMP COUNTER.


GETPST,	XX			/ GET NEXT CHAR FROM PST BUFFER
	ISZ	PSTPTR		/ BUMP PTR
	JMP	GETPS1		/ JUMP IF OK
	ISZ	PSTBLK		/ ELSE BUMP BLK
	TAD	PSTBLK
	TAD	(-PSTEND)	/ AND CHECK FOR END
	SNA CLA
	JMP	GETPS2		/ JUMP IF END
	TAD	(RXERD)
	JMS	PSTIO		/ ELSE READ NEXT BLOCK

GETPS1,	CDFBUF
	TAD I	PSTPTR		/ GET NEXT CHAR
	SZA
	JMP I	GETPST		/ RETURN IF NOT EOF
GETPS2,	AC7777
	DCA	GETPSF		/ ELSE SET EOF FLAG
	JMP I	GETPST		/ AND RETURN

DOINSR,	XX			/ ROUTINE TO CHECK INSERTION CHAR FOR <CR>
				/ & <PARA>
	DCA	T2		/ SAVE CHAR.
	TAD	T2		/ GET IT BACK.
/D164;	AND	P177		/ MASK TO 7-BIT				/A162
	TAD	(-ECNWLN)	/ SEE IF <CR>
	SZA			/ SKIP IF YES.
/D164;	TAD	(ECNWLN-ECNWPG)	/ SEE IF <PAGE MARKER>			/M162
	TAD	(ECNWLN-ECPGRF)	/ SEE IF <PARA MARKER>			/M164
	SZA CLA			/ SKIP IF <CR> OR <PARA>
	JMP	DOINSA		/ PROCESS CHAR BELOW.
	OVLJMP;OVNWLN		/ CKECK FOR TERMINATION OF CENTERED TEXT

/D164;	TAD	T2		/ RESTORE CHAR				/A162
/D164;	AND	P177		/ MASK TO 7-BIT				/A162
/D164;	TAD	(-ECNWPG)	/ SEE IF <PAGE MARKER>			/A162
/D164;	SZA CLA			/ SKIP IF <PAGE>			/A162
/D164;	 JMP	DOINSA		/  PROCESS CHAR BELOW			/A162
/D164;	DCA	CURSOR		/ RESET CURSOR				/A162
/D164;	TAD	LINE23		/ AND					/A162
/D164;	DCA	CURPTR		/ CURPTR				/A162
DOINSA,	TAD	T2		/ GET CHARACTER TO INSERT BACK.
	INSCHR			/ ELSE INSERT CHAR IN FILE
	JMP I	DOINSR		/ RETURN TO CALLER.


GLDBKP,	AC7777			/ SET UP FOR A BACKWARD MOVEMENT
	JMS	GLDMOV		/ GO MOVE BACKWARD THROUGH DOCUMENT
	JMP	EIBAD		/ ERROR, CAN'T BACK UP PAST TOP OF FILE
	JMP	EIFIX		/ FIX UP SCREEN AND GET NEXT CHARACTER

GLDADV,	AC0001			/ SET UP FOR A FORWARD MOVEMENT
	JMS	GLDMOV		/ GO MOVE FORWARD THROUGH DOCUMENT
	JMP	EIBAD		/ ERROR, CAN'T ADVANCE PAST BOTTOM
	JMP	EIFIX		/ FIX UP SCREEN AND GET NEXT CHARACTER

GLDMOV,	XX			/ ROUTINE TO ADVANCE OR BACKUP IN FILE
	DCA	GLDDIR		/ SAVE DIRECTION INDICATOR FOR MOVE
	AC0001 			/ SET UP TO KEEP THE SCREEN UPDATED
	DCA	ECHFLG 		/ TURN ON THE "ALWAYS ECHO" FLAG
	JMS	FXSCRL 		/ UPDATE THE SCREEN

	TAD	GLDDIR		/ PICK UP MOVEMENT DIRECTION INDICATOR
	SPA CLA			/ SKIP IF DIRECTION IS FORWARD
	AC0001			/ INDICATE A BACKUP CONDITION
	DCA	MOVMOD+1	/ SET OR CLEAR EDMODE - NEEDED FOR
	MODSET			/   PROPER EXECUTION OF EDITOR MATH
	MOVMOD

	TAD	GLDDIR		/ PICK UP MOVEMENT DIRECTION INDICATOR
	CURMOV 			/ TRY TO MOVE AT LEAST ONE POSITION
	JMP I	GLDMOV		/ COULDN'T DO IT, GO REPORT THE ERROR

	ISZ	GLDMOV		/ BUMP RETURN PAST ERROR RETURN
GLDMV1,	TAD	GLDDIR		/ PICK UP MOVEMENT DIRECTION INDICATOR
	CURMOV 			/ MOVE THE CURSOR ONE CHARACTER POSITION
	JMP I	GLDMOV		/ HIT END OF DOCUMENT, ALL DONE

	TAD	SCRLCT 		/ PICK UP THE SCREEN LAG COUNT
	SPA CLA 		/ SKIP IF SCREEN IS OK
	JMS	FXSCRL 		/ DON'T LET SCREEN GET BEHIND
	HLTTST 			/ CHECK IF USER WANTS TO STOP
	JMP	EIFIX		/ YES, THEN WE ARE ALL DONE
	JMP	GLDMV1		/ LOOP TILL STOPPED

GLDDIR,	0			/ LOCATION TO HOLD DIRECTION INDICATOR

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

/***************************************************************************
/****			   START OF OVERLAY				****
/***************************************************************************

	OVRNUM=OVRNUM+200
	OVRBLK=OVRNUM%200+DLOEDO-1 / DISK BLOCK WHERE OVERLAY IS LOADED

	RELOC
	RELOC OVLAY1
	OVRNUM

	OVCONT=	.-OVLAY1+OVRNUM / THE USER TYPED "GOLD:SEARCH & SELECT"

OVCON1,	TSTSLT			/ CHECK TO SEE IF WE ARE ALREADY IN SELECT
	JMP	OVCON2		/ NOT IN SELECT, GO DO THE SEARCH

	CLA			/ IF IN 'SELECTED' POSITION AND
	TAD	GSRF		/ THE USER REQUESTS 'GLOBAL SEARCH AND
	SNA CLA			/ REPLACE', LET OPERATION CONTINUE
	JMP	EISRCL		/ OTHERWISE, DO UNSELECT AND SEARCH

	OVLJMP			/ CALL IN THE 'REPLACE' OVERLAY
	OVREPL			/ TO CONTINUE G.S.R. FUNCTION

/ FIX TO ALLOW CONT SEARCH AND SEL TO DELETE SEL MARK THEN SEARCH NEXT ARG

EISRCL,	DCA	EDMODE		/ CLEAR CURRENT EDIT MODE
	JMP	EISRCN		/ GO LOAD CHAR

EISRCM,	ADVPTR			/ ADVANCE POINTER
	JMP	SLXMOD		/ ETX

EISRCN,	JMS	LODCHR		/ GET THE NEXT CHARACTER
	JMP	SLXMOD		/ ETX

	JMS	ESLCTD		/ IF SELECT MARK DELETE IT
	JMP	EISRCM		/ NOT A SELECT MARK GET NEXT CHARACTER
/\	JMP	OVCON2		/ GO DO SEARCH - FALL THROUGH

OVCON2,	DCA	SRCDIR 		/ SET FOR SEARCHING FORWARD
	AC0001
	DCA	ECHFLG 		/ SET FLAG TO LET SCREEN SCROLL WITH US
	ISZ	NOMOVE		/ KEEP CURSOR FROM PRE-INCREMENTING
	AC0001 			/ AND SET S/ S FLAG
/\	JMP	EISRCG		/ FALL THROUGH INTO CONTINUE SEARCH


	OVSRCH=	.-OVLAY1+OVRNUM / USER TYPED "GOLD:CONTINUE SEARCH"
				/ ENTER HERE FROM REGULAR SEARCH

EISRCG,	DCA	SRCSLT 		/ RESET S/ S FLAG
	CDFMYF			/ GO-TO-PAGE USES SRCDIR AS A FLAG WORD	/A206
				/ MAKE SURE DIRECTION VALUE IS VALID	/A206
	AC0002			/ SET UP AC WITH VALUE OF TWO		/A206
	TAD	SRCDIR		/ COMBINE WITH VALUE IN DIRECTION FLAG	/A206
	SZA CLA			/ SKIP IF BACKWARD DIRECTION SET	/A206
	DCA	SRCDIR		/ SET FORWARD DIRECTION			/A206

	TAD I	(EIGES4+1)	/ PICK UP FIRST CHARACTER IN SEARCH BUFFER
	SNA CLA			/ CHECK FOR ANYTHING TO SEARCH FOR
	JMP	EIFIX		/ DON'T BOTHER, IF NULL			/C168
	JMP	EISRCB		/ SKIP OVER BUFFER POINTER RESTORATION

EISRCA,	TAD	EIFND4		/ PICK UP SAVED BUFFER POSITION
	DCA	CURPTR 		/ RESTORE CURPTR

EISRCB,	HLTTST			/ GO CHECK IF USER PRESSED THE HALT KEY
	JMP	EISRCJ 		/ QUIT ON HALT

	TAD	NOMOVE		/ DO WE MOVE CURSOR OR NOT?
	SZA CLA
	JMP	EISRCQ		/ NO, WE DON'T

	AC0001			/ SET UP FOR A FORWARD MOVEMENT
	TAD	SRCDIR		/ COMBINE WITH REAL DIRECTION
	CURMOV			/ MOVE TO NEXT CHARACTER
	JMP	EISRCK 		/ STX/ETX, QUIT AT END OF BUFFER

EISRCQ,	CDFMYF			/ RESET BACK TO THIS FIELD
	DCA	NOMOVE		/ CLEAR THE MOVEMENT FLAG

	TAD	CURPTR		/ PICK UP THE CURRENT BUFFER POSITION
	DCA	EIFND4 		/ SAVE CURPTR

	TAD	(EIGES4+1)	/ PICK UP POINTER TO SEARCH STRING
	DCA	EIFND6 		/ SET UP POINTER REGISTER

	CDFBUF			/ SET TO BUFFER FIELD
	TAD I	CURPTR 		/ GET CURRENT CHARACTER
	JMP	EISRCD		/ SKIP OVER BUFFER MOVEMENT ROUTINE

EISRCC,	ADVPTR			/ MOVE POINTER ONE BUFFER POSITION	/C209
/D209	ADVSPC			/ MOVE POINTER ONE SCREEN POSITION
	JMP	EISRCA 		/ ETX, QUIT AT END OF BUFFER

EISRCD,	JMS	ESJCHK		/ CHECK FOR LINE OR RULER MODIFIED FLAG
	SNA			/ AC = 0 OR AC = VALID CHARACTER - JCHKOF
	JMP	EISRCC 		/ NO JUST CODES
	TAD	(JCHKOF)	/ RESTORE TO ORIGINAL CHARACTER

	CDFMYF			/ RESET TO THIS FIELD
	TAD	(-ECSTOV)	/ START OF DEAD-KEY SEQUENCE?
	SZA			/ SKIP IF YES.
	JMP	EISRCX		/
	TAD I	EIFND6		/ GET CHARACTER FROM STRING
	JMP	EISRDK		/ GO HANDLE DEAD KEY SEQUENCE

EISRCX,	TAD	(ECSTOV) 	/ NO, RESTORE TO ORIG. CHAR
	MQL			/ PUT CHARACTER IN THE MQ
	TAD I	EIFND6 		/ GET CHARACTER FROM STRING		/A198
	TAD	(-ECNWLN)	/ COMPARE WITH NEW LINE CHARACTER	/A198
	SZA CLA			/ IS THIS A CARRIAGE RETURN ?		/A198
	JMP	EISNNL		/ NO, THIS IS NOT A NEW LINE		/A198

	MQA			/ GET BACK THE BUFFER CHARACTER		/A198
	TAD	(-ECNWLN)	/ COMPARE WITH NEW LINE CHARACTER	/A198
	SZA CLA			/ IS BUFFER CHARACTER A NEW LINE ?	/A198
	JMP	EISRCA		/ NO, NO MATCH, GO RESTART THE SEARCH	/A198

EISNNL,	TAD I	EIFND6 		/ PICK UP CHARACTER FROM SEARCH STRING
	SWP			/ SWAP PLACES WITH BUFFER CHARACTER
	JMS	USCMPR		/ COMPARE WITH STRING BYTE
	JMP	EISRCA 		/ JUMP IF NO MATCH

EISRCY,	ISZ	EIFND6		/ THEY MATCH, BUMP THE STRING POINTER
	TAD I	EIFND6		/ GET THE NEXT CHARACTER
	SZA CLA			/ CHECK FOR NULL CHARACTER
	JMP	EISRCC 		/ NOT NULL, LOOP TILL END OF STRING

	TAD	SRCSLT		/ DONE, GET THE SEARCH AND SELECT FLAG
	SNA CLA			/ IS IT SET ?
	JMP	EISRCE 		/ NO, SKIP AROUND

	ADVPTR			/ IF SET, PASS FINAL CHARACTER
	NOP			/ ETX RETRUN, SHOULD NOT HAPPEN
	CLA 			/ THROW AWAY ANY CHARACTER CODE RETURNED

	TAD	(ECTMRK)	/ PICK UP POSITION MARK
	JMS	INSERT 		/ MARK OUR PLACE FOR SELECT

	TAD	EIFND4		/ PICK UP SAVED BUFFER POSITION
	DCA	CURPTR 		/ RESTORE TO START OF STRING
	JMP	DOSLCT 		/ JUMP TO SELECT STRING

EISRCE,	TAD	EIFND4
	DCA	CURPTR 		/ RESTORE CURPTR
EISRCF,	JMP	EIFIX							/C168


SRCSLT,	0 			/ SEARCH AND SELECT FLAG
EIFND4,	0
EIFND6,	0

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

EISRCK,	CDFMYF
	CLA
	DCA	GSRPRV		/ CLEAR PREVIOUS GLOBAL SEARCH FLAG
	DCA	NOMOVE
/\	JMP	EISRCJ		/ FALL THROUGH

				/ HERE AFTER HALT TEST - FIELD = EDITOR
EISRCJ,	TAD	XLTINI		/ RESTORE GSKILN AFTER FINISHING
	DCA	GSKILN		/ A G.S.R. OPERATION

	JMS	BUZZER		/ DO NOT CLEAR UDK STACK(BEEPER DOES)

	TAD	SRCDIR		/ PICK UP THE SEARCH DIRECTION
	SNA CLA			/ SKIP IF NOT GOING FORWARD
	AC7776 			/ REVERSE DIRECTION
	DCA	SRCDIR 		/ FOR NEXT TIME
	DCA	GSRF		/ CLEAR GLOBAL SEARCH FLAG
	JMP	EIFIX		/ GO BACK FOR NEXT EDITOR COMMAND	/C168

XLTINI,	CIFSYS			/ INST TO PATCH UP EDITOR

/ DEAD KEY SEQUENCE WAS FOUND IN TEXT BUFFER.  CHECK FOR TECH CHARACTER
/ AND REQUIRED SPACE.  IF NOT, THEN RESTART THE SEARCH

EISRDK,	SPA			/ CHECK FOR A SPECIAL CHARACTER ?
	CMA			/ YES, INVERT THE CHARACTER FOR CHECK
	DCA	EISRT1		/ SAVE THE CURRENT BUFFER CHARACTER

	ADVPTR			/ MOVE TO THE NEXT CHARACTER OF SEQUENCE
	JMP	EISRCA		/ ETX, GO RESTART THE SEARCH
	AND 	P177		/ Strip off attributes			/A228
	TAD	(-ECSPC)	/ SUBTRACT OFF THE VALUE OF A SPACE
	SZA CLA			/ WAS THIS CHARACTER A SPACE ?
	JMP	EISRCA		/ NO, MUST BE A NORMAL DEAD KEY, RESTART

	ADVPTR			/ MOVE TO THE NEXT CHARACTER OF SEQUENCE
	JMP	EISRCA		/ ETX, GO RESTART THE SEARCH
	DCA	EISRT2		/ SAVE THE CHARACTER JUST OBTAINED
	TAD	EISRT2		/ GET THE CHARACTER BACK AGAIN
	TAD	(-ECSPC)	/ SUBTRACT OFF THE VALUE OF A SPACE
	SZA CLA			/ WAS THIS CHARACTER A SPACE ?
	JMP	EISRTC		/ NO, IT MUST BE A TECHNICAL CHARACTER

	TAD	EISRT1		/ GET THE SAVED BUFFER CHARACTER
	SNA			/ CHECK FOR REQUIRED SPACE CODE
	JMP	EISROK		/ YES, IT'S A MATCH
	TAD	(-ECSPC)	/ CHECK FOR A NORMAL SPACE
	SZA CLA			/ CHECK FOR A MATCH
	JMP	EISRCA		/ NO MATCH, GO RESTART THE SEARCH
	JMP	EISROK		/ IT'S A MATCH, GO GET END OF DEAD KEY

EISRTC,	TAD	EISRT2		/ GET THE CHARACTER BACK AGAIN
	AND	(174)		/ DROP OUT LOW ORDER BITS		/M228
	TAD	(-60)		/ SUBTRACT OFF CHARACTER SET VALUE
	SZA CLA			/ IS THIS A TECH CHARACTER ?
	JMP	EISRCA		/ NO, GO RESTART THE SEARCH

	TAD	EISRT2		/ GET THE CHARACTER BACK AGAIN
	AND	(3)		/ ISOLATE THE LOW ORDER BITS
	DCA	EISRT3		/ SAVE FOR COMPARISON
	TAD	EISRT1		/ GET THE BUFFER CHARACTER
	R3L			/ POSITION CHARACTER SET BITS
	AND	(3)		/ ISOLATE THE LOW ORDER BITS
	CIA			/ MAKE VALUE NEGATIVE
	TAD	EISRT3		/ COMBINE WITH SAVED BITS
	SZA CLA			/ IS THERE A MATCH ?
	JMP	EISRCA		/ NO, GO RESTART THE SEARCH

	TAD	EISRT1		/ YES, GET THE SAVED BUFFER CHARACTER
	AND	P177		/ ISOLATE THE LOW ORDER BITS
	DCA	EISRT3		/ SAVE FOR COMPARISON
	ADVPTR			/ MOVE TO THE NEXT CHARACTER OF SEQUENCE
	JMP	EISRCA		/ ETX, GO RESTART THE SEARCH
	AND	P177		/ Strip off attributes			/A228
	CIA			/ NEGATE THE CHARACTER
	TAD	EISRT3		/ COMBINE WITH SAVED ASCII CHARACTER
	SZA CLA			/ CHECK FOR A MATCH
	JMP	EISRCA		/ NO MATCH, GO RESTART THE SEARCH

EISROK,	ADVPTR			/ MOVE TO THE NEXT CHARACTER OF SEQUENCE
	JMP	EISRCA		/ ETX, GO RESTART THE SEARCH
	TAD	(-ECNDOV)	/ SUBTRACT OFF VALUE OF END DEAD CHARACTER
	SZA CLA			/ IS THIS THE END OF THE DEAD KEY ?
	JMP	EISROK		/ NO, GO CHECK AGAIN
	CDFMYF			/ RESET BACK TO THIS FIELD FOR NEXT CHECK
	JMP	EISRCY		/ DONE, GO CHECK NEXT CHARACTER

EISRT1,	.-.			/ TEMPORARY REGISTER ONE - BUFFER CHARACTER
EISRT2,	.-.			/ TEMPORARY REGISTER TWO - TEXT CHARACTER
EISRT3,	.-.			/ TEMPORARY REGISTER THREE - MATCH VALUE

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE

/---------------------
	PAGE

/***************************************************************************
/****			   START OF OVERLAY				****
/***************************************************************************

	OVRNUM=OVRNUM+200
	OVRBLK=OVRNUM%200+DLOEDO-1 / DISK BLOCK WHERE OVERLAY IS LOADED

	RELOC

	RELOC	OVLAY1
	OVRNUM


	IFDEF	LFTRGT  <
	OVRARO=	.-OVLAY1+OVRNUM
	JMP	XVRARO		/ RIGHT ARROW

	OVLARO=	.-OVLAY1+OVRNUM
	JMP	XVLARO		/ LEFT ARROW
	>

	OVUPAR=	.-OVLAY1+OVRNUM
	JMP	XVUPAR		/ UP ARROW

	OVDNAR=	.-OVLAY1+OVRNUM
	JMP	XVDNAR		/ DOWN ARROW

	OVGRAR=	.-OVLAY1+OVRNUM
	JMP	XVGRAR		/ GOLD RIGHT ARROW

	OVGLAR=	.-OVLAY1+OVRNUM
	JMP	XVGLAR		/ GOLD LEFT ARROW

	OVSUPS=	.-OVLAY1+OVRNUM
	JMP	XVSUPS

	OVHYP2=	.-OVLAY1+OVRNUM
	JMP	XVHYP2



/	LCMAP defines the end of the alphabet that is to be considered for
/	UPPER/ lower casing commands. 133 includes "A"-"Z", and 136
/	includes "A"-"Z" and the national standard characters "[","\" and "]"

	IFDEF SCANDI <LCMAP=136>/ Scandinavian: include extra characters
	IFNDEF SCANDI <LCMAP=133>/ American: use only ASCII set
	OVCASE=	.-OVLAY1+OVRNUM / SET UPPER-LOWER CASE

	JMS	SCRNMD 		/ SHOW SCREEN (TO BE) MODIFIED
	JMS	GETUNT
CASNXT,	XX
	SNA
	JMP	EINEXT
	JMS	BHOOK		/ Call Blaster				/A230
	MNCUCS			/ Case any valid char			/A230
	  JMP	GETUNY		/ Finished with invalid or dead 	/A230
	JMP I	CASNXT		/ Exit					/A230

/d230	TAD	(-ECSTOV)	/ Is it a dead key sequence		/A207
/d230	SNA			/ No					/A207
/d230	JMP	GETUNY		/ Yes, curmov over it			/A207
/d230	TAD	(ECSTOV)	/ Restore character to original value	/A207
/d230	JMS	CHKALP
/d230	JMP I	CASNXT
/d230	AND	(137) 		/ SET UPPER CASE
/d230	TAD	(-133) 		/ CHECK FOR PROPER RANGE
/d230	SMA
/d230	JMP	CASUN1
/d230	TAD	(133-101)
/d230	SPA
/d230	JMP	CASUN1
/d230	CLA MQA
/d230	AND	(7737)
/d230	TAD	CASBIT
/d230	MQL
/d230CASUN1,	CLA MQA
/d230	JMP I	CASNXT


	OVBOLD=	.-OVLAY1+OVRNUM

XVBOLD,	JMS	SCRNMD 		/ SET BOLD - SHOW SCREEN (TO BE) MODIFIED
	JMS	GETUNT
BLDNXT,	XX
	SNA
	JMP	EINEXT
	JMS	CHKALP
	JMP	BLDUN2
BLDUN3,	AND	(7577) 		/ CLEAR THE BIT
	TAD	BLDBIT 		/ SO WE CAN (SET) IT
BLDUN1,	JMP I	BLDNXT

BLDUN2,	AND	(2177)
	TAD	(-40)
	SZA
	TAD	(40-ECTAB)	/ ALLOW TABS TO BE BOLDED
	SZA CLA
	JMP	BLDUN1
	CLA MQA
	JMP	BLDUN3


	OVUNDL=	.-OVLAY1+OVRNUM

XVUNDL,	JMS	SCRNMD 		/ UNDERLINING - SHOW SCREEN (TO BE) MODIFIED
	JMS	GETUNT
UDLNXT,	XX
	SNA
	JMP	EINEXT
	JMS	CHKALP
	JMP	UDLUN2
	RTL
	SPA CLA
	JMP	UDLUN1 		/ IGNORE IF SUPERSCRPTED
UDLUN3,	CLA MQA 		/ RESTORE CHAR
	AND	(7377) 		/ CLEAR THE BIT
	TAD	UDLBIT 		/ SO WE CAN (SET) IT
UDLUN1,	JMP I	UDLNXT

UDLUN2,	AND	(3177)
	TAD	(-40)
	SZA
	TAD	(40-ECTAB)
	SZA CLA
	JMP	UDLUN1
	JMP	UDLUN3

XVSUPS,	TSTSLT			/ SUPER-SUBSCRPT
	SKP CLA
	TAD	(SLCTMD)
	DCA	GRAMUN
	JMS	SETUNT
	JMS	GETUNT
SUPNXT,	XX
	SNA
	JMP	EIFIX							/C168
	JMS	CHKALP
	JMP I	SUPNXT
	AND	(2377)
	SWP
	RTL
	RAL
	SNL
	CLA 			/ CLEAR IF NOT SUP-SUB
	SPA CLA
	CMA CLL 		/ -1 IF SUB
	SZL
	IAC 			/ +1 IF SUP
	TAD	CASBIT 		/ ADJUST FOR MODE IN EFFECT
	TAD (TAD EISUP1)	/ THIS INSURES A CURRENT PAGE REFERENCE
				/ AVOIDING ANY DATA FIELD PROBLEMS
	DCA	.+1
	.-.
	MQA
	JMP I	SUPNXT

	1400 			/ SUB OF SUB
	1400 			/ SUB OF NORMAL
	0000 			/ SUB OF SUP (OR SUP OF SUB)
EISUP1,	1000 			/ SUP OF NORMAL
	1000 			/ SUP OF SUP

/
/	We are here because the user tried to Hyphenate a char which	/A231
/	was not alpha , so check for 8 bit				/A231
/	

XVHYP3,	TAD	(-ECNDOV)	/ Check if we are on a dead		/A231
	SZA CLA			/ Yes , go check it out			/A231
	JMP	XVHYP4		/ No , go on as normal			/A231
	JMS	BHOOK		/ Call the Blaster again		/A231
	XVMNPH			/ Check for Mutli Nat for Hyphen	/A231
	JMP	XVHYP4		/ And exit				/A231




	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

XVHYP2,	BKPPTR
	JMP I	TLITDA
	JMS	CHKALP
	JMP	XVHYP3		/ Go check for 8 bit 			/M231
	AC2000
	MQA 			/ SET BREAK BIT
	DCA I	CURPTR 		/ STORE UPDATED CHAR
XVHYP4,	ADVPTR
	NOP 			/ RESTORE CURSOR
	JMP	EIFIX							/C168

TLITDA,	EIBAD 			/ **TEMP FOR OS/ 8 LIT POOL LIMIT BYPASS


/***********************************************************************
/****			LEFT AND RIGHT ARROW ROUTINES 		    ****
/***********************************************************************

	IFDEF	LFTRGT  <	/ LEFT AND RIGHT CURSOR
XVLARO,	IAC			/ MOVE MODE
XVRARO,	JMS	ARMSET		/ SET MOVE MODE
	JMS	ARCURM		/ GO MOVE CURSOR
	JMP	EIBAD		/ (STX/ETX OR SCROLL)
	JMP	EINEXT		/ DIDN'T SCROLL, SUPER!
			>	/ END IFDEF LFTRGT


/***********************************************************************
/****			GOLD LEFT AND RIGHT ARROW ROUTINES 	    ****
/***********************************************************************

XVGLAR,	IAC			/ MOVE MODE
XVGRAR,	JMS	ARMSET		/ SET MOVE MODE
	DCA	ARCTMP		/ SAVE CURSOR DIRECTION
	TAD	ARCTMP
	JMS	ARCURM		/ MOVE CURSOR
	JMP	EIBAD		/ (CAN'T, GO BUZZ)

GLDARR,	TAD	ARCTMP
	JMS	ARCURM		/ KEEP MOVING TILL WE GET
	JMP	EINEXT		/ TO THE END OF THE LINE
	JMP	GLDARR


/***********************************************************************
/****			UP AND DOWN ARROW ROUTINES		    ****
/***********************************************************************

XVUPAR,	IAC			/ MOVE MODE
XVDNAR,	JMS	ARMSET		/ SET MOVE MODE
	JMS	UPDNAR		/ GO MOVE THE CURSOR
	JMP	EINEXT		/ OKAY
	JMP	EIBAD		/ (CAN'T)


/***********************************************************************
/			COMMON CODE FOR UP/DOWN ARROW
/  ENTER:  AC = CURSOR DIRECTION (+1=ADV, -1=BKP)
/  EXIT:   1ST RETURN IF WE ARE SITTING ON THE FIRST OR
/		LAST LINE OF TEXT (CURSOR UNCHANGED)
/	   SKIP RETURN IF WE ACTUALLY SCROLL A LINE
/		(CURSOR MOVED TO PROPER POSITION W/IN LINE)
/***********************************************************************

UPDNAR,	XX
	DCA	ARCTMP		/ SAVE DIRECTION
	TAD	REMCUR		/ DO WE HAVE A REMEMBERED POSITION?
	SMA CLA
	JMP	UPDN0		/ YES, ALL SET
	TAD	CURSOR		/ NO, SAVE WHERE WE ARE NOW
	DCA	REMCUR

UPDN0,	TAD	ARCTMP		/ GOING FORWARD OR BACK?
	SPA CLA
	JMP	UPDNUP		/ (BACK)

/ GOING FORWARD (DOWN ARROW)

	AC0001
	JMS	ARMVSC		/ FORWARD TILL WE SCROLL
	ISZ	UPDNAR		/ ETX, TAKE SKIP RETURN
	JMS	FXSCRL		/ FIX FOR DOWN ARROW AND MATH		/A194
	JMP	UPDNXT		/ THEN GO POSITION CURSOR

/ GOING BACKWARD (UP ARROW)

UPDNUP,	JMS	SAVLMD		/ SAVE LINE MODE IF NECESSARY
	AC7777			/ BACK UP TILL WE SCROLL
	JMS	ARMVSC
	SKP			/ (STX)
	JMP	UPDNU0
	ISZ	UPDNAR		/ STX, TAKE SKIP RETURN
UPDNU1,	CURMOV			/ FIX CURSOR AT STX
	NOP
	JMP	UPDNXT		/ GO POSITION CURSOR
UPDNU0,	AC7777
	JMS	ARMVSC		/ BACK UP TILL WE SCROLL AGAIN
	JMP	UPDNU1		/ (STX, GO FIX -- NO ERROR THIS TIME)
	AC0001			/ AND FORWARD
	JMS	ARMVSC
	NOP

/ COMMON EXIT PROCESSING FOR UP & DOWN POSITION THE CURSOR ON THE LINE

UPDNXT,	CLA
	CDFEDT
	TAD	REMCUR		/ WHERE ARE WE NOW?
	CIA
	TAD	CURSOR
	SMA CLA			/ (NOT THERE YET)
	JMP I	UPDNAR		/ ALL DONE, RETURN
	CDFBUF			/ SET FIELD TO EDIT BUFFER		/A202
	TAD I	CURPTR		/ GET CURRENT CHARACTER			/A202
	CDFMYF			/ RESET DATA FIELD			/A202
	AND	P177		/ MASK OUT CHARACER			/A202
	ZZCASE			/ TEST FOR LINE ENDER CONDITIONS	/A202
	 UPDNX9-1		/ TABLE					/A202
	AC0001			/ NO MATCH ADVANCE CURSOR
	JMS	ARCURM		/ MOVE WITHOUT LEAVING LINE		/C211
UPDNX1,	JMP I	UPDNAR		/ HIT STX OR ETX
	JMP	UPDNXT		/ HAVE WE REACHED THE PROPER COLUMN COUNT

UPDNX9,	ECNWLN;	UPDNX1		/ LINE ENDER CHARACTERS			/A202
	ECNWPG; UPDNX1		/ 					/A202
	0000			/					/A202


/ ARROW KEYPAD CURSOR MOVE (MOVE W/O LEAVING LINE)
/  ENTER:  AC = CURSOR DIRECTION (+1=ADV, -1=BKP)
/  EXIT:   AC = 0
/	   1ST RETURN IF WE CAN'T MOVE ON THE LINE

ARCURM,	XX
	DCA	ARCTMP		/ SAVE DIRECTION
	DCA	SCRLFL		/ ENSURE SCROLL FLAG 0
	TAD	ARCTMP
	CURMOV			/ MOVE THE CURSOR
	JMP I	ARCURM		/ (STX OR ETX)
	CLA
	TAD	SCRLFL		/ DID WE SCROLL?
	SZA CLA
	JMP	ARCRM0		/ (YES, THAT'S A NO-NO)
	ISZ	ARCURM		/ NO, GREAT!  TAKE SKIP
	JMP I	ARCURM

ARCRM0,	TAD	ARCTMP		/ PROBLEM -- WE SCROLLED
	CIA
	JMS	ARMVSC		/ UNDO THE SCROLL
	NOP
	JMP I	ARCURM		/ TAKE FIRST RETURN



/ ROUTINE TO MOVE CURSOR TILL WE SCROLL
/  ENTER:  AC = CURSOR DIRECTION (+1=ADV, -1=BKP)
/  EXIT:   AC = 0
/	   1ST RETURN - WE HIT STX OR ETX (IF STX, WE SCROLLED)
/	   2ND RETURN - OKAY

ARMVSC,	XX
	DCA	ARCTMP		/ SAVE DIRECTION
	DCA	SCRLFL		/ ENSURE FLAG = 0

ARMVS0,	TAD	ARCTMP
	CURMOV			/ MOVE THE CURSOR
	JMP I	ARMVSC		/ (STX OR ETX)
	CLA
	TAD	SCRLFL		/ DID WE SCROLL?
	SNA CLA
	JMP	ARMVS0		/ NO, GO AGAIN
	ISZ	ARMVSC		/ YES, TAKE SKIP
	JMP I	ARMVSC		/ RETURN



/ SET MOVE MODE FOR ARROW KEYPAD
/  ENTER:  AC = MOVE MODE (0=ADV, 1=BKP)
/  EXIT:   AC = CURSOR DIRECTION (+1=ADV, -1=BKP)

ARMSET,	XX
	DCA	ARCTMP
	MODSET			/ SET MOVE MODE
	ARMODE
	TAD	ARCTMP		/ NOW SET THE CURSOR DIRECTION
	SZA
	AC7776			/ (BACKUP)
	IAC			/ (ADVANCE)
	JMP I	ARMSET

ARMODE,	SCHMOD!SLTMOD
ARCTMP,	.-.			/ TEMP STORAGE FOR THIS PAGE


	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE


/ OVERLAY TO MERGE LIST DOCUMENT

/ THE CHARACTER "<" IN A FORM DOCUMENT IS TREATED IN A SPECIAL WAY DEPENDING ON
/  WHAT FOLLOWS IT:

/	<FIELD NAME> -	SUBSTITIUTE THE TEXT OF THE NAMED FIELD IN THE
/			CURRENT RECORD AT THIS POINT IN THE OUTPUT.

/	<!S>	     -	START THE REPETITIVE ZONE HERE, NOT AT THE TOP OF THE
/			FORM DOCUMENT. (PRECEDING TEXT IS THE HEADER.)

/	<!E>	     -	END THE REPETITIVE ZONE HERE, NOT AT THE BOTTOM OF THE
/			FORM DOCUMENT. (FOLLOWING TEXT IS A TRAILER.)

/	<!R>	     -	COPY THE TEXT OF THE CURRENT RECORD FROM THE LIST
/			DOCUMENT TO THE OUTPUT.

/	<>	     -	ADVANCE TO THE NEXT RECORD IN THE LIST DOCUMENT.

/	<<	     -	OUTPUT A SINGLE "<" AT THIS POINT.

/	NO OTHER CHARACTERS IN THE FORM DOCUMENT ARE TREATED SPECIALLY.


/***************************************************************************
/****			   START OF OVERLAY				****
/***************************************************************************

	OVRNUM=OVRNUM+200 	/ NEW OVERLAY NUMBER
	OVRBLK=OVRNUM%200+DLOEDO-1 / DISK BLOCK WHERE OVERLAY IS LOADED

	RELOC

	RELOC OVLAY1
	OVRNUM

	OVMRG2=	.-OVLAY1+OVRNUM / SECOND MERGE OVERLAY
	ISZ	ECHFLG 		/ SET FLAG TO LET SCREEN SCROLL WITH US
	ISZ	MRGRSF 		/ INIT RESYNC FLAG FOR: NO RESYNC
MRGFSA,	CURMOV
	NOP

MRGFSB,	JMS	LODCHR 		/ LOOKING FOR START OF FIELD
	JMP	MRGEOF 		/ WE HIT END OF THE FORM DOCUMENT

	AND	P177 		/ STRIP MODE BITS FROM CHARACTER
	TAD	(-"<+200) 	/ IS CHARACTER = "<"?
	SZA CLA 		/ SKIP IF: SO
	JMP	MRGADV 		/ JUMP IF NOT

	TAD	CURPTR 		/ GET POINTER TO LEFT ANGLE BRACKET
	DCA	MRGPT2 		/ SAVE POINTER TO LEFT ANGLE BRACKET
	SLNMOD 			/ SET LINE MODIFIED FLAG
	JMS	JCLEAN 		/ WE'RE GOING TO CHANGE SOMETHING
	ADVPTR 			/ GET NEXT CHARACTER
	JMP	MRGETX 		/ WE HIT END OF TEXT

	AND	P177 		/ STRIP MODE BITS
	TAD	(-"<+200) 	/ IS CHARACTER ANOTHER "<"?
	SNA 			/ SKIP IF: NOT
	JMP	MRGS1A 		/ GO PROCESS A "<<" SEQUENCE

	TAD	("<-">) 	/ IS CHARACTER = ">"?
	SNA 			/ SKIP IF: NOT
	JMP	MRGS2A 		/ GO PROCESS "<>"(NULL FIELD NAME)

	TAD	(">-"!) 	/ IS CHARACTER = "!"?
	SNA CLA 		/ SKIP IF: NOT
	JMP	MRGS3A 		/ GO PROCESS SPECIAL NAME (!E, !R, !S)

/ MATCH FIELD NAME IN FORM DOCUMENT TO A FIELD NAME FROM THE MATH
/  RESULT BUFFER AND THEN THE RECORD BUFFER
	JMS	MFNIFD 		/ MATCH FIELD NAME IN FORM DOCUMENT TO
	RESBUF 			/  FIELD NAME IN MATH RESULT BUFFER

	CDFLP 			/ RESBUF IS IN LIST PROCESS. FIELD
		 		/ IF NO MATCH IS FOUND WE WILL RETURN
				/  HERE FROM THE JMS SO WE CAN TRY TO
				/   FIND A MATCH IN RECBUF.  IF A MATCH
				/    WAS FOUND IN RESBUF THEN MFNIFD
				/     RETURNS TO MRGFSA (NOT HERE!!!!).
				/      ALL FOR THE NEED OF SPACE.

	JMS	MFNIFD 		/ MATCH FIELD NAME IN FORM DOCUMENT TO
	RECBUF 			/  FIELD NAME IN RECORD BUFFER
	CDFBUF			/  DF TO THE EDITOR BUFFER FIELD
	JMP	MRGFNF 		/ NO MATCH - FIELD NAME NOT FOUND IN
				/  EITHER RESBUF OR RECBUF.
		 		/ IF NO MATCH IS FOUND WE WILL RETURN
				/  HERE FROM THE JMS SO WE CAN GO TO
				/   FIELD NOT FOUND ROUTINE.  IF A
				/    MATCH WAS FOUND IN RECBUF THEN
				/     MFNIFD RETURNS TO MRGFSA (NOT
				/      HERE!!!!).  ALL FOR THE NEED OF
				/       SPACE.




/****************************************************************************
/
/	The following routine has been made into a blasted routine	/a224
/	to make space for the multinational and technical character set	/a224
/	changes (see WPHOLE.PA for explanation).			/a224
/
/****************************************************************************

/d224	MFNIFD,	XX 			/ MATCH FIELD NAME IN FORM DOCUMENT
/d224		CDFMYF			/ CHANGE DF TO MY FIELD
/d224		TAD I	MFNIFD 		/ GET ADDRESS OF BUFFER TO MATCH
/d224		DCA	MRGPT1 		/ SAVE IT
/d224		ISZ	MFNIFD		/ BUMP RETURN
/d224		TAD I	MFNIFD		/ GET FIELD OF THAT BUFFER
/d224		DCA	TADIM1		/ SAVE IT
/d224		ISZ	MFNIFD 		/ BUMP RETURN
/d224	MRGFS1,	TAD	MRGPT2 		/ POINT TO TEXT BRACKET IN FORM
/d224		DCA	CURPTR 		/ RESET POINTER
/d224	MRGFS2,	JMS	TADIMRGPT1 	/ GET NEXT CHAR FROM RECORD	ISZ	MRGPT1 		/ BUMP RECORD PTR
/d224	SNA 			/ SKIP IF: NOT END OF RECORD
/d224	JMP I	MFNIFD 		/ FIELD NOT FOUND, END OF RECORD				/  RETURN TO CALLER
/d224		TAD	(-"<+200) 	/ IS CHARACTER = "<"?
/d224		SZA CLA 		/ SKIP IF: SO
/d224		JMP	MRGFS2 		/ LOOP TIL FIELD START
/d224		TAD	(-GPBSIZ	/ Field found, so init max siz counter	/a224
/d224		DCA	T2		/ to ignore end comparison if max siz	/a224
/d224					/ for significant field name reached	/a224
/d224	MRGFS3,	ADVPTR 			/ GET NEXT FIELD VALUE CHAR. FROM TEXT
/d224		JMP	MRGETX 		/ WE HIT THE END OF TEXT
/d224		AND	P177 		/ STRIP MODE BITS
/d224		XLTUPR 			/ XLAT CHAR TO UPPER CASE
/d224		CIA 			/ SET UP FOR COMPARE WITH RECORD'S
/d224		DCA	T1 		/  FIELD NAME VALUE
/d224		JMS	TADIMRGPT1 	/ GET NEXT CHAR FROM RECORD
/d224		XLTUPR 			/ XLAT TO UPPER CASE
/d224		TAD	T1 		/ COMPARE WITH CHARACTER FROM TEXT
/d224		ISZ	T2		/ Has the max length of FN been reached?/a224
/d224		SNA CLA 		/ NO, SKIP IF: CHARACTERS DON'T MATCH
/d224		SKP CLA			/ Yes, or match, skip on.		/a224
/d224		JMP	MRGFS1 		/ LOOP IF NOT EQUAL
/d224		JMS	TADIMRGPT1 	/ GET NEXT RECORD CHARACTER
/d224		ISZ	MRGPT1 		/ BUMP POINTER INTO RECORD
/d224		TAD	(-">+200) 	/ IS CHARACTER = ">"?
/d224		SZA CLA 		/ SKIP IF:SO
/d224		JMP	MRGFS3 		/ CHECK FOR END OF NAME
/d224		TAD	MRGPT2 		/ RESET TEXT BUFFER POINTER TO START OF
/d224		DCA	CURPTR 		/  FIELD NAME WE JUST MATCHED.
/d224		JMS	MRGDLF 		/ DELETE THAT FIELD NAME FROM TEXT
/d224	MRGFS4,	DCA	MRGPT2 		/ SET LOOKAHEAD
/d224		JMS	TADIMRGPT1 	/ CHECK FOR END OF FIELD IN RECORD
/d224		TAD	(-"<+200) 	/ IS CHARACTER = "<"?
/d224		SNA CLA 		/ SKIP IF: NOT
/d224		JMP	MRGFS5 		/ JUMP IF END OF FIELD VALUE
/d224		TAD	MRGPT2 		/ GET LOOK AHEAD CHARACTER
/d224		SZA 			/ SKIP IF: 0
/d224		INSCHR 			/ OUTPUT LOOKAHEAD
/d224		JMS	TADIMRGPT1 	/ LOAD NEW LOOKAHEAD
/d224		CLA SWP			/ ATTRIBUTED CHAR. COMES BACK IN THE MQ
/d224					/ NOW RESTORE IT TO THE AC
/d224		ISZ	MRGPT1 		/ BUMP POINTER INTO FIELD VALUE
/d224		JMP	MRGFS4 		/ LOOP TO OUTPUT NEXT FIELD VALUE CHAR.
/d224					/  INTO RESULT DOCUMENT
/d224	
/d224	MRGFS5,	TAD	MRGPT2 		/ OUTPUT LAST CHAR AT END OF FIELD
/d224		TAD	(-40) 		/ WAS THIS A SPECIAL CHAR.?
/d224		SPA SNA CLA 		/ SKIP IF: NOT
/d224		JMP	MRGFS6 		/ SPECIAL CHARACTER. DO NOT INSERT
/d224		TAD	MRGPT2 		/ REGULAR CHARACTER. INSERT INTO TEXT
/d224		INSCHR
/d224	MRGFS6,	JMP	MRGFSA 		/ BUMP RETURN FOR MATCH

/****************************************************************************
/
/	The following routine is the replacement for the above.  It	/a224
/	calls the blaster hook for this field to blast in the field	/a224
/	name search routine moved.					/a224
/
/****************************************************************************

MFNIFD,	XX			/ Replacement field name search		/a224
	CDFMYF			/ Return to home data field		/a224
	TAD I	MFNIFD		/ Set up the parameters passed after the/a224
	DCA	MRGPT1		/ call, which can not be done by the	/a224
	ISZ	MFNIFD		/ blasted routine, as the return addres	/a224
	TAD I	MFNIFD		/ points to the blaster, not the call to/a224
	DCA	TADIM1		/ here.					/a224
	ISZ	MFNIFD		/					/a224
	JMS	BHOOK		/ Blast in the routine			/a224
	  MFNHLR		/ Merge_Field_Name_HoLe_Routine		/a224
	JMP I	MFNIFD		/ Return here if not found, and exit	/a224
	SZA CLA			/ Return here if found or EOF of form	/a224
	JMP	MRGFSA		/ If found, continue			/a224
	JMP	MRGETX		/ If EOF, deal with it			/a224


/ THIS ROUTINE WILL READ A CHARACTER FROM THE BUFFER SPECIFIED WHEN
/  MFNIFD WAS CALLED.  TADIM1 IS PRIMED UPON CALL TO MFNIFD.  UPON
/   READING A CHARACTER THE DF IS ALWAYS RETURNED TO THE EDITOR BUFFER
/    FIELD SINCE OTHER ROUTINES CALLED DURING OVMRG2 DEPEND ON DF SET
/     TO THE EDITOR BUFFER FIELD.
/ THE MQ IS USED TO HOLD THE ATTRIBUTED CHARACTER SO THAT WHEN
/  LOADING CHARACTERS FROM THE LIST DOCUMENT TO THE RESULT DOC.
/   ATTRIBUTES OF CHARACTERS ARE NOT DROPPED
TADIMRGPT1,
	XX
TADIM1,	.-. 			/ LOADED WITH CDF INSTRUCTION
	TAD I	MRGPT1 		/ READ CHARACTER FROM RECORD
	MQL			/ LOAD THE ATTRIBUTED CHAR INTO THE MQ
	MQA			/ RESTORE THE CHAR INTO THE AC
	AND	P177 		/ STRIP MODE BITS
	CDFBUF			/ SET DF TO EDITOR BUFFER FIELD
	JMP I	TADIMRGPT1	/ RETURN

/ MULTIPLE LEFT ANGE BRACKET SEQUENCE HANDLER ("<<...ETC.") - DELETE
/  ONE OF THE LEFT ANGLE BRACKETS IN THE TEXT AND IGNORE ANY THAT 
/   IMMEDIATELY FOLLOW.  WHEN THE FIRST CHARACTER THAT IS NOT A "<" IS
/    READ REENTER SCAN LOOP.  THIS ENABLES US TO USE FIELD NAMES AS
/     TEXT WITHIN A DOCUMENT WITHOUT TRYING TO FIND A MATCH WITH A
/      FIELD NAME IN THE CURRENT RECORD.
MRGS1A,	DCA I	CURPTR 		/ DELETE ONE OF THE LEFT ANGLE BRACKETS
	TAD	MRGPT2 		/ RESTORE POINTER TO START OF FIELD
	DCA	CURPTR
	SLNMOD 			/ SET LINE MODIFIED FLAG
MRGS1B,	AC0001 			/ ADVANCE CURSOR 1 CHARACTER
	CURMOV
	JMP	MRGEOF 		/ EOF RETURN FROM CURMOV

	JMS	CHKSPC 		/ CHECK DISKETTE SPACE

	JMS	LODCHR 		/ GET THE NEXT CHARACTER
	JMP	MRGEOF 		/ EOF RETURN

	AND	P177 		/ STRIP MODE BITS
	TAD	(-"<+200) 	/ IS CHARACTER = "<"?
	SNA CLA 		/ SKIP IF: NOT
	JMP	MRGS1B 		/ CHARACTER = "<". GET NEXT ONE

	JMP	MRGFSB 		/ REENTER SCAN LOOP


	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE



/ ADVANCE CURSOR ONE CHARACTER AT A TIME THROUGH RESULT DOCUMENT,
/  CHECKING FOR ENOUGH ROOM ON DISKETTE TO CONTINUE THROUGH THE DOC.
MRGADV,	AC0001 			/ ADVANCE CURSOR 1 CHARACTER
	CURMOV
	JMP	MRGEOF 		/ EOF RETURN FROM CURMOV
	JMS	CHKSPC 		/ CHECK DISKETTE SPACE
	JMP	MRGFSB 		/ GO CHECK NEXT CHAR


/ FIELD NOT FOUND (NO MATCH BETWEEN FORM DOCUMENT FIELD AND ANY OF THE
/  FIELDS OF THE CURRENT RECORD BEING PROCESSED).  THEREFOR DELETE THIS
/   FIELD FROM THE RESULT DOCUMENT.
MRGFNF,	TAD	MRGPT2 		/ POINT TO START OF FIELD IN RESULT DOC.
	DCA	CURPTR
	JMS	MRGDLF 		/ AND DELETE THE FIELD
	JMP	MRGFSA 		/ THEN CONTINUE SCAN LOOP

/ EMPTY LEFT AND RIGHT ANGLE BRACKET HANDLER ("<>") - DELETE "<>" FROM
/  THE RESULT DOCUMENT AND LOAD THE NEXT RECORD TO BE PROCESSED.
MRGS2A, TAD	MRGPT2 		/ RESET POINTER TO "<"
	DCA	CURPTR
	JMS	MRGDLF 		/ DELETE "<>" FROM RESULT DOCUMENT
	JMS	MRGNXT 		/ GET NEXT RECORD
	SKP 			/  NO MORE RECORDS
	JMP	MRGFSA 		/ REENTER SCAN LOOP IF WE GOT ONE
				/ ELSE SKIP TO <!E>

/ DELETE TO AND INCLUSIVE OF THE CONTROL SEQUENCE "<!E>" IN THE RESULT
/  DOCUMENT.  IF "<!E>" IS NOT ENCOUNTED THEN DELETE TO END OF RESULT
/   DOCUMENT.
MRGS2B,	JMS	MRGDLS 		/ DELETE TO AND INCLUSIVE OF "<!" SEQ.
	TAD	(-"E+200) 	/ WAS LAST CHARACTER READ AN "E"?
	SZA CLA 		/ SKIP IF: SO
	JMP	MRGS2B 		/ DELETE MORE
	JMS	MRGDLF 		/ DELETE REST OF FIELD

/ MERGE THE TRAILER WITH RESULT DOCUMENT
MRGTRL,	OVLJMP			/ DO MERGE TRAILER OVERLAY
	OVMRG5

/ DO EXIT OVERLAY
MRGDON,	OVLJMP	 		/ DO EXIT OVERLAY
	OVMRG3




/ DELETE A CHARACTER IN THE RESULT DOCUMENT
MRGDEL,	XX 			/ DELETE CHAR SUBROUTINE
	JMS	LODCHR 		/ READ A CHARACTER
	JMP I	MRGDEL 		/  NONE LEFT - EXIT
	ISZ	MRGDEL 		/ BUMP TO OK RETURN
	AND	P177 		/ STRIP MODE BITS
	MQL 			/ HOLD CHARACTER IN MQ
	DCA I	CURPTR 		/ DELETE CHARACTER FROM TEXT
	MQA 			/ RESTORE CHAR TO AC
	JMP I	MRGDEL 		/ AND RETURN

/ DELETE A FIELD
MRGDLF,	XX 			/ DELETE FIELD SUBROUTINE
	JMS	MRGDEL 		/ DELETE ONE CHARACTER OF THE FIELD
	JMP I	MRGDLF 		/ QUIT IF NO MORE
	TAD	(-">+200) 	/ WAS CHARACTER JUST DELETED A ">"?
	SZA CLA 		/ SKIP IF: SO
	JMP	.-4 		/ DELETE TIL END
	SLNMOD 			/ SET LINE MODIFIED
	JMP I	MRGDLF 		/ THEN RETURN

/ MERGE NEXT RECORD - LOAD THE NEXT RECORD OF THE LIST DOCUMENT INTO
/  RECBUF.  IF THERE ARE NO MORE RECORDS LEFT THEN DON'T SKIP RETURN.
MRGNXT,	XX 			/ GET NEXT RECORD
	SLNMOD 			/ SET LINE MODIFIED
	JMS	FXSCRL 		/ UPDATE SCREEN
	CDFMYF 			/ CHANGE DATA FIELD MYFIELD
	CIFLP 			/ CHANGE INSTRUCTION FIELD TO LP FIELD.
	JMS I	(SELCT)		/ LOAD THE NEXT RECORD
	SNA CLA 		/ SKIP IF: NO RECORDS LEFT
	ISZ	MRGNXT 		/ BUMP RETURN - WE'VE LOADED A RECORD
	JMP I	MRGNXT 		/ RETURN



/ ANALYZE THE SPECIAL FIELD NAMES (E, R, S)
MRGS3A,	ADVPTR 			/ GET THE NAME
	JMP	MRGETX 		/  NO CHARACTERS LEFT
	DCA	MRGPT1 		/ SAVE IT, WHILE

	TAD	MRGPT2 		/ DELETE REST OF THE FIELD NAME
	DCA	CURPTR
	JMS	MRGDLF

	TAD	MRGPT1 		/ GET THE NAME BACK
	AND	P177 		/ STRIP THE MODE BITS
	XLTUPR 			/ XLAT NAME TO UPPER CASE
	TAD	(-"E+200) 	/ IS THE FIELD NAME = "E"?
	SNA 			/ SKIP IF: NOT
	JMP	MRGSEA 		/ PROCESS START OF TRAILER
	TAD	("E-"R) 	/ IS THE FIELD NAME = "R"?
	SNA 			/ SKIP IF: NOT
	JMP	MRGSRA 		/ PROCESS INSERT WHOLE RECORD
	TAD	("R-"S) 	/ IS THE FIELD NAME = "S"?
	SNA CLA 		/ SKIP IF: NOT
	DCA	MRGRSF 		/ SET RESYNC FLAG FOR: RESYNC
	JMP	MRGFSA 		/ NONE OF THE ABOVE - IGNORE THIS FIELD

/ PROCESS INSERT WHOLE RECORD - <!R> INSERT RECORD COMMAND

MRGSRA,	TAD	(RECBUF) 	/ INIT POINTER TO TOP OF RECORD
	DCA	MRGPT1
MRGSRB,	TAD I	MRGPT1 		/ GET NEXT CHAR FROM RECORD
	SNA 			/ SKIP IF: NOT END OF RECORD IN BUFFER
	JMP	MRGFSA 		/ QUIT IF NO MORE
	INSCHR 			/ INSERT INTO TEXT
	ISZ	MRGPT1 		/ BUMP TO NEXT CHAR
	JMP	MRGSRB 		/ AND LOOP FOR ALL

/ DELETE A PARTIAL FIELD (FIELD NAME WITH NO TERMINATING ">")
MRGETX,	TAD	MRGPT2 		/ RESET POINTER TO START OF FIELD NAME
	DCA	CURPTR
	JMS	MRGDLF 		/ DELETE THIS PARTIAL FIELD THEN JOIN
				/  COMMON CODE FOR EOF PROCESSING BELOW

/ PROCESS START OF TRAILER
MRGSEA,				/ <!E> LOOP BACK POINT
MRGEOF,				/ OR EOF
	JMS	MRGNXT 		/ GET NEXT RECORD
	JMP	MRGTRL 		/ SKIP TO TRAILER IF NO MORE

	TAD	FORMNO 		/ REINIT FORM DOCUMENT FOR READ
	JMS	DSKCAL
	XRDFIN

	TAD	MRGRSF 		/ IS A RESYNC NEEDED?
	SZA CLA 		/ SKIP IF: SO (MRGRSF=0)
	JMP	MRGFSA 		/ JUMP IF NO RESYNC NEEDED
MRGSEB,	JMS	MRGDLS 		/ ELSE DELETE TO RESYNC POINT
	TAD	(-"S+200) 	/ IS THE CHAR. FOLLOWING "<!" AN "S"?
	SZA CLA 		/ SKIP IF: SO
	JMP	MRGSEB 		/ KEEP GOING - WE'VE NOT FOUND "<!S>"
	JMS	MRGDLF 		/ DELETE REST OF RESYNC FIELD
	JMP	MRGFSA 		/ AND REENTER SCAN LOOP

/ DELETE UPTO AND INCLUSIVE OF THE "<!" CHARACTERS OF A SPECIAL FIELD
/  NAME SEQUENCE.
MRGDLS,	XX
	JMS	MRGDEL 		/ DELETE A CHARACTER
	JMP	MRGDON 		/  NO MORE CHARACTERS IN DOCUMENT

	TAD	(-"<+200) 	/ WAS CHARACTER DELETED = "<"?
	SZA CLA 		/ SKIP IF: SO
	JMP	MRGDLS+1 	/ NO - DELETE THE NEXT CHARACTER

	JMS	MRGDEL 		/ DELETE THE CHAR. FOLLOWING THE "<".
	JMP	MRGDON 		/  NO MORE CHARACTERS IN DOCUMENT
	TAD	(-"!+200) 	/ WAS CHARACTER DELETED = "!"?
	SZA CLA 		/ SKIP IF: SO
	JMP	MRGDLS+1 	/ NO - DELETE THE NEXT CHARACTER

	JMS	MRGDEL 		/ DELETE THE CHAR. FOLLOWING THE "!".
	JMP	MRGDON 		/  NO MORE CHARACTERS IN DOCUMENT
	XLTUPR 			/ XLAT CHAR. JUST DELETED TO UPPER CASE

	JMP I	MRGDLS 		/ RETURN

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

/***************************************************************************
/****			   START OF OVERLAY				****
/***************************************************************************

	OVRNUM=OVRNUM+200 	/ NEW OVERLAY
	OVRBLK=OVRNUM%200+DLOEDO-1 / DISK BLOCK WHERE OVERLAY IS LOADED

	RELOC

	RELOC OVLAY1
	OVRNUM

	OVRLXT=	.-OVLAY1+OVRNUM / GOLD RULER EXIT CODE
	JMP	RLXIT		/ GO TO NEXT PAGE FOR THE CODE


	OVAPAG=	.-OVLAY1+OVRNUM	/ AUTO PAGINATE OVERLAY
	AC0001

	OVGPGE=	.-OVLAY1+OVRNUM / "PAGINATE" OVERLAY
	DCA	APGFLG		/ SET/ CLEAR AUTO-PAGINATE FLAG
	TSTSLT
	JMP	EIGPG1 		/ ERROR IF IN SELECT
	JMS	BEEPER
	JMP	UNSLCT

/	THE NUMBER OF LINES THAT ARE PUT ON A PAGE IS EQUAL TO :

/	(THE NUMBER OF LINES THAT WILL FIT ON A PAGE - THE FIRST LINE)
/	* 2 , GIVING THE NUMBER OF HALF LINES TO SPACE.

/	A PAGE MARK IS INSERTED BEFORE A LINE WHEN THE PREVIOUS LINE AND ITS SPACING
/	OVERFLOWED THE PAGE.

EIGPG1,	MODSET
	EDTMOD 			/ RESET EDIT MODES
	JMS	HDRGET
	HDRPSZ 			/ GET PAGE SIZE
	TAD	(-1) 		/ MINUS THE FIRST LINE
	CLL RAL 		/ *2, GIVING HALF LINES
	DCA	EIGPGB
	DCA	EIGPGF 		/ CLEAR COUNTER

EIGPG5,	DCA	SCRLFL
	AC7777
	CURMOV
	JMP	EIGPGC 		/ BACK UP TO END PAGE
	TAD	SCRLFL
	SNA CLA
	JMP	EIGPG5
	TAD	PCTLFL
	SZA CLA
	JMP	EIGPG5
	JMS	LODCHR
	JMP	EIGPG3
	TAD	(-ECPCT1)
	SNA
	JMP	EIGPG5
	TAD	(ECPCT1-ECNWPG)
	SZA
	TAD	(ECNWPG-ECPMRK)
	SNA CLA
	JMP	EIGPG2

/	SEARCH BACK AT MOST N LINES, WHERE N=CURRENT PAGE SIZE

	TAD	SPACNG
	CIA
	TAD	EIGPGF
	DCA	EIGPGF
	TAD	EIGPGF
	TAD	EIGPGB
	SMA CLA
	JMP	EIGPG5

EIGPG3,	JMS	BEEPER
	JMP	EIGPG8

EIGPG2,	AC0001
EIGPGC,	CURMOV
	NOP
	DCA	EIGPGA 		/ CLEAR LINE COUNTER
	AC0001
	DCA	ECHFLG 		/ SET ECHO SCROLL MODE
	JMP	EIGPG9 		/ JUMP TO CHECK PRINT CONTROL

EIGPG6,	HLTTST			/ TEST FOR GOLD HALT
	JMP	EIGPGX		/ AND STOP IF ONE FOUND
	DCA	SCRLFL 		/ CLEAR SCROLL FLAG
	AC0001
	CURMOV
	JMP	EIGPGX 		/ ADVANCE TO PAGE LIMIT
	TAD	SCRLFL
	SNA CLA
	JMP	EIGPG6 		/ WATCH FOR SCROLL
	TAD	PCTLFL
	SZA CLA
	JMP	EIGPG6 		/ IGNORE IF IN PRINT CONTROL
EIGPG9,	JMS	LODCHR
	JMP	EIGPGX 		/ DON'T MISS A REAL PAGE
	TAD	(-ECPCT1)
	SNA
	JMP	EIGPG6 		/ IGNORE START CONTROL
	TAD	(ECPCT1-ECNWPG)
	SNA
	JMP	EIGPG7
	TAD	(ECNWPG-ECPMRK)
	SZA CLA
	JMP	EIGPGD 		/ DELETE PAGE MARKERS
	DCA I	CURPTR
	JMS	SCRNMD 		/ SHOW SCREEN MODIFIED
	CURMOV
	NOP
	JMP	EIGPG9 		/ AND TRY AGAIN

EIGPGD,	TAD	EIGPGA
	TAD	EIGPGF 		/ CHECK FOR PAST START POINT YET
	SZA SMA CLA
	JMS	EIGPGK 		/ CHECK H-ZONE IF SO

/============================================================================
/D182	TAD	SPACNG							/A182
/D182	TAD	EIGPGA							/A182
/D182	DCA	EIGPGA 		/ UPDATE LINE COUNTER			/A182
/D182	TAD	EIGPGB							/A182
/D182	CIA								/A182
/D182	TAD	EIGPGA 		/ COMPARE WITH LIMIT			/A182
/D182	SPA SNA CLA							/A182
/D182	JMP	EIGPG6							/A182
/D182	JMP	EIGPMK 		/ IF OVERFLOW, GO INSERT PAGE MARK	/A182
/============================================================================
/ THE FOLLOWING CODE WAS DELETED TO FIX SOME PROBLEM WITH LINE COUNTING
/ BUT WHEN IT WAS DELETED AND REPLACED WITH THE CODE ABOVE, IT CAUSED THE
/ PAGE MARKER TO BE PLACED IN THE WRONG POSITION.  THE SYMPTOMS OF THE
/ ORIGINAL PROBLEM ARE LOST AND THE BUG WAS NOT OFFICIALLY REPORTED TO Q.A.
	TAD	EIGPGB
	CIA
	TAD	EIGPGA 		/ COMPARE WITH LIMIT
	SMA SZA CLA
	JMP	EIGPMK 		/ IF OVERFLOW, GO INSERT PAGE MARK
	TAD	SPACNG
	TAD	EIGPGA
	DCA	EIGPGA 		/ UPDATE LINE COUNTER
	JMP	EIGPG6
/============================================================================

EIGPG7,	AC0001
	CURMOV
	NOP 			/ ADVANCE OVER PAGE MARKER
EIGPG8,	TAD	APGFLG		/ ARE WE IN AUTO-PAGE MODE?
	SZA CLA
	JMP	EIGPG1		/ YES, SO REPEAT THE OPERATION
	JMP	EIFIX 		/ RESET MODES AND LISTEN		/C217

/ HERE TO STOP AUTO-PAGINIATON
EIGPGX,	JMS	BEEPER		/ BUZZ THE TERMINAL
	CLA
	DCA	APGFLG		/ CLEAR THE FLAG WORD

/D217	EIGPEX,	CDFMYF		/ RESET DATA FIELD BACK TO THIS FIELD
/D217	AC7777			/ SET AC = -1
/D217	CIFMNU			/ CHANGE INSTRUCTION FIELD TO MENU FIELD
/D217	PGSWAP			/ AC=-1 SO JUST LOAD IN THE SAVE AREA

	JMP	EIFIX		/ AND EXIT BACK TO MAIN LOOP		/C168

EIGPGA,	0 			/ LINE COUNTER IN HALF LINES
EIGPGB,	0 			/ PAGE SIZE IN HALF LINES TO SKIP
EIGPGF,	0 			/ BACKING-UP LINE COUNTER

APGFLG,	0			/ AUTO-PAGINATION FLAG

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE


EIGPGK,	XX 			/ CHECK H-ZONE
	CDFMYF
	TAD	NWHMAR-NWRUL+CURUL/ GET HYPH-ZONE START POINT
	SNA
	JMP	EIGPGG 		/ JUMP IF NO H-ZONE
	DCA	EIGPGJ 		/ SAVE H-ZONE LOC
	TAD	LINE23
	DCA	CURPTR 		/ BACK UP TO START OF LINE
	DCA	CURSOR
	AC7777
	CURMOV
	JMP	EIGPGH 		/ ...AGAIN, TO END OF PREV LINE
	JMS	LODCHR
	JMP	EIGPGI 		/ SEE IF EXPLICIT LINE TERMINATOR
	AND	P177
	TAD	(-40)
	SPA CLA
	JMP	EIGPGI 		/ JUMP IF SO
	TAD	CURSOR
	CMA
	TAD	EIGPGJ 		/ COMPARE LOC WITH H-ZONE
	SPA SNA CLA
	JMP	EIGPGI 		/ JUMP IF "OK" (IE., IN ZONE)
	AC0001
	CURMOV
	NOP 			/ GET BACK TO START OF NEXT LINE
	JMS	BEEPER 		/ TELL OF H-ZONE VIOLATION
	JMS	FXSCRL 		/ UPDATE SCREEN
	GETINP 			/ GET USER RESPONSE
	TAD	(-EDGPGE)
	SNA
	JMP	EIGPGG 		/ JUMP IF JUST G-PAGE (CONTINUE)
	TAD	(EDGPGE) 	/ ELSE LEAVE TO DO REQUESTED OPERATION
	JMP	EINEXB

EIGPGI,	AC0001
EIGPGH,	CURMOV
	NOP
EIGPGG,	JMP I	EIGPGK

EIGPGJ,	.-. 			/ TEMP

/ INSERT A PAGE MARKER INTO THE BUFFER
EIGPMK,	TAD	(ECPMRK)
	MQL
	DCA	CURSOR
	TAD	LINE23
	DCA	CURPTR
	MQA
	INSCHR			/ INSERT THE PAGE MARKER
	CDFMYF
	TAD	APGFLG		/ ARE WE IN AUTO PAGE MODE?
	SZA CLA
	JMP	EIGPG1		/ YES, DO IT AGAIN...
	JMP	EIFIX		/ NO, RETURN TO MAIN LOOP		/C168


/ ENTER HERE TO FINISH UP THE GOLD RULER FUNCTION

RXLIT2=EIGPGJ			/ DEFINE TEMPORARY STORAGE LOCATION

	IFDEF	PERDEC	<
RLXIT,	TAD	(5556)
	DCA	OKSTR
			> 	/ END IFDEF PERDEC

	IFDEF	COLDEC	<
RLXIT,	TAD	(5572)
	DCA	OKSTR
			> 	/ END IFDEF COLDEC

	IFDEF	COMDEC	<
RLXIT,	TAD	(5554)
	DCA	OKSTR
			> 	/ END IFDEF COMDEC

	CDFMYF			/ PROPER FIELD				/A192
	TAD	SPLTFL 		/ SPLIT SCREEN?
	SMA CLA								/M192
	JMP	RLXIT1 		/ NO, OR NO CHANGE			/M192

	TAD	WIDPRV		/ WAS SCREEN WIDE BEFORE?
	SZA CLA
	JMP	RLXIT2		/ YES, DO NOTHING

	CDFMNU
	TAD	NWRMAR 		/ REMOVE SPLIT, IF NEC.
	CDFMYF
	TAD	(-COLM80)	/ (I.E., IF R .LT. 80)
	SMA SZA CLA
	JMP	RLXIT1

	DCA	SPLTFL
/D192	JMS	CLR132		/ REVERT TO 80-COLUMN DISPLAY AND
/D192				/ DO FINAL EXIT STUFF.

RLXIT2,	JMS	CLSSET		/ INITIALIZE SCROLL VALUES FOR STATUS

/
/ END OF PROCESSING FOR GOLD:RULER COMMAND.
/ THE USER HAS JUST INSERTED A NEW RULER INTO THE DOCUMENT.
/
/ FIX UP RULERS (I.E., CONCATENATE ADJACENT RULERS, AND DELETE RULERS
/ THAT MAKE NO NET CHANGE) BY MOVING THE CURSOR BACK THEN FORWARD
/ OVER RULER(S).
/

/ BEFORE FIXING UP RULERS TURN MATH OFF SO THAT MATH IS NOT REDUNDANT
/  ON THE SAME LINE.  WHEN FINISHED FIXING UP LINE THEN RESTORE MATH
/  TO ON/OFF STATE AT ENTRY TO RLXIT1.
/ NOTE: IT MIGHT SEEM THAT SUBR SWTHMA WOULD BE SUITABLE FOR USE HERE.
/ ALTHOUGH SWTHMA WILL PREVENT REDUNDANT CALCULATIONS FROM BEING
/ PERFORMED WHEN MOVING FORWARD, IT WILL PERMIT MATH TO BE TURNED OFF
/ UNDER CERTAIN CONDITIONS (WHEN MOVING BACKWARDS IN A WPSMATH CONTROL
/ BLOCK??), WHICH COULD MEAN THAT A SIDE EFFECT OF CHANGING A RULER
/ IS TO TURN OFF MATH.  WE MUST AVOID THIS, SO WE CAN'T USE SWTHMA ...

RLXIT1,	JMS	MNUGET		/ GET A VALUE FROM THE MENU FIELD
	MNOPTC			/ ACTIVE FEATURES CONTROL WORD
	DCA	RXLIT2		/ SAVE IT IN TEMPORARY LOCATION

	TAD	RXLIT2		/ RESTORE ACTIVE FEATURES CONTROL WORD
	AND	(-MABIT-1)	/ BUT WITH THE MATH INACTIVATED
	JMS	MNUPUT		/ PUT A VALUE INTO THE MENU FIELD
	MNOPTC			/ ACTIVE FEATURES CONTROL WORD

	AC7777			/ SETUP FOR A BACKWARD MOVE
	CURMOV			/ MOVE CURSOR BACKWARD ONE POSITION
	SKP	CLA		/ IF TOP OF DOCUMENT, THEN DON'T
				/ CURMOV FORWARD

RLXIT3,	AC0001			/ MOVE PTR FORWARD ONE
	CURMOV
	 JMP	RLXIT4		/ EOF. MAYBE HALT CAUSE THIS IS AN ERROR/a176

	TAD I	CURPTR		/ IS THIS CHAR THE TEMP MARKER?		/a176
	TAD	(-ECTMRK)						/a176
	SZA	CLA							/a176
	 JMP	RLXIT3		/ NO, KEEP LOOKING			/a176

	TAD	(ECMDFL)	/ YES, REPLACE IT WITH A LINE MODIFIED	/a176
	DCA I	CURPTR							/a176

RLXIT4,	TAD	RXLIT2		/ RESTORE ACTIVE FEATURES CONTROL WORD
				/ TO IT'S VALUE AT ENTRY TO RXLIT1
	JMS	MNUPUT		/ PUT A VALUE INTO THE MENU FIELD
	MNOPTC			/ ACTIVE FEATURES CONTROL WORD

/
/ TERMINATE NORMAL GOLD:RULER COMMAND
/
	TAD	RRDIR		/ IS THIS GOTO-RULER?
	SNA CLA
	JMP	EIFIX		/ NO (END OF NORMAL GOLD:RULER CMD):	/C168
				/    GO LISTEN FOR NEXT EDITOR COMMAND
	JMS	FXSCRL		/ GET RID OF THE EDITED RULER & SCALE
	OVLJMP			/ YES: GO DO GOTO-RULER
	OVRRGO


	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

/***************************************************************************
/****			   START OF OVERLAY				****
/***************************************************************************

	OVRNUM=OVRNUM+200
	OVRBLK=OVRNUM%200+DLOEDO-1 / DISK BLOCK WHERE OVERLAY IS LOADED

	RELOC

	RELOC OVLAY1
	OVRNUM
VIEWF1=	OVRNUM			/ used to identify view mode overlay


/ HANDLE KEYBOARD INPUT FOR GOLD:VIEW COMMAND

	OVVWDX=	.-OVLAY1+OVRNUM
	JMP	XVVWDX

/ "GOLD:VIEW" COMMAND

	OVVIEW=	.-OVLAY1+OVRNUM
	JMP	VIEW


/ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/ +++ 			Gold:Tab (Indent Tabs)				+++
/ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/
/	This Code is called from OVRULR for processing Gold:Tab.  The
/	purpose of which is to place a @W' (word wrap) at the current
/	ruler position (and perhaps, generate a new ruler).
/
/	This will make it very easy to do such things as outlines,
/	where you'd like to change the word wrap margin often.
/
/	When called, a few things could happen depending on where the
/	cursor (CURSOR) is in the ruler.
/
/	1) Cursor is on the Left Margin
/	   Clear the Ruler of the Word Wrap:
/		Modify or generate a ruler without a Word Wrap.
/		Change the old Word Wrap (if present) to a Tab.
/		 If too many tabs exist, the old Word Wrap is changed
/		to a blank.
/		 If no Word Wrap is present in the Current ruler,
/		then nothing happens.
/
/	2) Cursor is on the Right Margin
/	   Error:
/		Beep the bell.  Don't clear the UDK Stack.
/
/	3) Cursor is neither on Left or Right Margins
/	   Add Word Wrap to the Ruler:
/		Modify or generate a ruler with a Word Wrap at the Cursor.
/		Change the old Word Wrap (if present) to a Tab.
/		If too many tabs exist, the old Word Wrap is changed
/		to a blank.
/
/	Upon completion of this routine, OVXRUL is called which cleans
/	things up, and displays the newly modified or created ruler.
/
/
	OVINTB=	.-OVLAY1+OVRNUM

	DCA	RRDIR		/ CLEAR 'GOTO-RULER' FLAG

	TAD	CURSOR		/ CHECK FOR CURSOR=RIGHT MARGIN
	CIA
	TAD	RGTMAR
	SPA SNA CLA
	 JMP	INTB3		/ RIGHT MARGIN - BEEP AND RETURN TO EDITOR

INTB1,	JMS	WTOT		/ CHANGE WORD WRAP TO TAB(04) OR BLANK(01)
CHGRUL,	 04			/ WTOT ARGUMENT

	TAD	CURSOR		/ CHECK FOR CURSOR=LEFT MARGIN
	CIA
	TAD	LFTMAR
	SNA	CLA
	 JMP	INTB2		/ LEFT MARGIN - ALL DONE

	AC0001
	TAD	CURSOR
	DCA	RLPOSN		/ GET RULER POSTION OF CURSOR

	TAD	WRPVAL		/ PUT WORD WRAP AT CURSOR IN RULER
	JMS	UPDRUL

INTB2,	OVLJMP
	 OVXRUL			/ RULER COMPLEATION CODE

WRPVAL,	11			/ INTERNAL-RULER WRAP CODE


	INTBAD=	.-OVLAY1+OVRNUM		

/ +++	OVERLAY CALL WHEN THE RULER HAS AN ERROR IN IT:
/	NAMELY TOO MANY TABS.
/
/	IF THERE IS NO PREVIOUSLY DEFINED WORD WRAP .. WE RESTORE
/	THE RULER, BEEP, AND RETURN TO THE EDITOR
/
/	IF THERE WAS A WORD WRAP DEFINED, WE MAKE IT A SPACE INSTEAD
/	OF A TAB (LIKE WE DO NORMALLY)
/
	AC0001			/ SET TO PUT A SPACE IN THE RULER
	DCA	CHGRUL

	TAD	LFTMAR
	CIA
	TAD	WRPMAR
	SZA	CLA		/ WAS THERE A WORD WRAP DEFINED?
	 JMP	INTB1		/ YES, MAKE IT A SPACE

	JMS	RLEQTE		/ NO, RESTORE NEW-RULER TO CURRENT-RULER

INTB3,	JMS	BUZZER		/ BEEP (BUT DON'T CLEAR UDK STACK)
	JMP	INTB2		/ AND RETURN TO EDITOR


/ +++	SUBROUTINE:	WTOT
/
/	CHANGE THE WORD WRAP IN THE CURRENT RULER TO THE VALUE
/	SPECIFIED IN CALL+1.
/
/	IF THERE IS NO WORD WRAP DEFINED (IE. LEFT MARGIN = WORD WRAP)
/	THEN NOTHING HAPPENS AND WTOT RETURNS
/
/	CALL:	JMS	WTOT
/		 XX		VALUE TO CHANGE WRAP TO
/				(IN OUR CASE, ONLY: TAB(04) OR BLANK(01)

WTOT,	XX
	TAD	LFTMAR		/ WORD WRAP DEFINED?
	CIA
	TAD	WRPMAR
	SNA	CLA
	 JMP	WTOT1		/ NO - JUST RETURN
	AC0001
	TAD	WRPMAR
	DCA	RLPOSN		/ GET PTR TO WORD WRAP IN RULER
	TAD I	WTOT		/ GET RULER VALUE ARGUMENT
	JMS	UPDRUL		/ CHANGE RULER
WTOT1,	ISZ	WTOT		/ BUMP PTR
	JMP I	WTOT		/ FOR RETURN ...


/ ROUTINE TO CHECK FOR KEYS USED IN GOLD VIEW				/A219

VWTEST,	XX			/ CHECK FOR GOLD VIEW KEYS		/A219
	TAD	(-EDPRSC)	/ CODE FOR THE PREVIOUS SCREEN KEY	/A219
	SNA			/ DID USER PRESS PREVIOUS SCREEN KEY ?	/A219
	JMP	VWPREV		/ YES, GO HANDLE IT			/A219
	IAC			/ BUMP COUNT TO NEXT VALUE		/A219
	SNA			/ DID USER PRESS NEXT SCREEN KEY ?	/A219
	JMP	VWNEXT		/ YES, GO HANDLE IT			/A219
	TAD  (EDPRSC-1-EDLINE)	/ CODE FOR THE LINE KEY			/A219
	JMP I	VWTEST		/ RETURN TO INLINE CODE CHECK		/A219

VWNEXT,	TAD	WIDNAR		/ GET THE SCREEN WIDTH FLAG		/A219
	SZA			/ DOES IT INDICATE WIDE SCREEN ?	/A219
	TAD	(4)		/ NO, MAKE CORRECTION FOR NARROW SCREEN	/A219
	TAD  (-COLLIM-2+WIDTH)	/ CONSTRUCT OFFSET TO NEXT SCREEN	/A219
	TAD	LOWLIM		/ COMBINE WITH CURRENT SCREEN OFFSET	/A219
	DCA	VWTEMP		/ SAVE NEW OFFSET VALUE			/A219
	TAD	VWTEMP		/ GET NEW OFFSET VALUE BACK AGAIN	/A219
	TAD  (WIDTH+COLM81)	/ COMBINE WITH OVERFLOW VALUE		/A219
	SPA CLA			/ DID WE OVERFLOW THE MAXIMUM VALUE ?	/A219
	JMP	VWERR		/ YES, IGNORE IT AND GO RING THE BELL	/A219
	JMP	VWVALU		/ NO, GO UPDATE NEW LOWLIM VALUE	/A219

VWPREV,	TAD	WIDNAR		/ GET THE SCREEN WIDTH FLAG		/A219
	SZA			/ DOES IT INDICATE WIDE SCREEN ?	/A219
	TAD	(4)		/ NO, MAKE CORRECTION FOR NARROW SCREEN	/A219
	TAD  (-COLLIM-2+WIDTH)	/ CONSTRUCT OFFSET TO NEXT SCREEN	/A219
	CIA			/ NEGATE THE OFFSET VALUE		/A219
	TAD	LOWLIM		/ COMBINE WITH CURRENT SCREEN OFFSET	/A219
	DCA	VWTEMP		/ SAVE NEW OFFSET VALUE			/A219
	TAD	VWTEMP		/ GET NEW OFFSET VALUE BACK AGAIN	/A219
	SMA SZA CLA		/ DID WE OVERFLOW THE MINIMUM VALUE ?	/A219
	JMP	VWERR		/ YES, IGNORE IT AND GO RING THE BELL	/A219
VWVALU,	TAD	VWTEMP		/ NO, GET NEW LOWLIM VALUE		/A219
	DCA	LOWLIM		/ UPDATE LOMLIM WITH NEW OFFSET VALUE	/A219
	JMP	VIEW		/ GO UPDATE THE SCREEN			/A219

VWERR,	JMS	BUZZER		/ ERROR, CAN'T MOVE, RING THE BELL	/A219
	JMP	VWADX2		/ GO GET NEXT CHARACTER			/A219

VWTEMP,	XX			/ SAVE LOCATION FOR NEW LOWLIM VALUE	/A219

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

XVVWDX,	DCA	CURLIN		/ CLEAR FOR PCUR ROUTINE TO POSN CURSOR	/A161
	CIFMNU			/ CHANGE TO MENU FIELD FOR STATUS CHECK	/A161
	JMS I	(CALLN2)	/ GO CHECK IF STATUS VALUES HAVE CHANGED/A161
VWADX1,	AC7777
	DCA	CURLIN		/ SET CURLIN BACK TO CORRECT VALUE FOR VIEW
	JMS	SETCUR 		/ AND CURSOR TO BE ON SCREEN
VWADX2,	GETINP 			/ WAIT FOR KEYBOARD INPUT		/C219
	DCA	VIEWCX 		/ SAVE IT ...
	TAD	VIEWCX
/D219	TAD	(-EDLINE)
	JMS	VWTEST		/ GO CHECK FOR THE GOLD VIEW KEYS	/A219
	SNA CLA
	JMP	VWADLN
	DCA	VIEWF2		/ clear view mode flag, then exit
	JMS	CLSSET		/ CLAER SCREEN UPDATE FLAGS		/A219

/D219	AC2000
/D219	DCA	SCRLCT
/D219	AC2000
/D219	DCA	SCRNFL

	DCA	CURLIN
	TAD	VIEWCX 		/ THEN GET INPUT CHAR
	TAD	(-EDVIEW) 	/ TREAT VIEW AS NOP/RETURN
	SNA CLA
	JMP	EINEXT
	TAD	VIEWCX 		/ ELSE RELOAD INPUT CHAR
	JMP	EINEXB 		/ AND JUMP TO PROCESS IT

VWADLN,	DCA	SCRLCT
	DCA	SCRNFL
	DCA	ECHFLG
	AC7777			/ set view mode flag in case CURMOV
	DCA	VIEWF2		/   calls editor math
VWADL1,	AC0001
	CURMOV
	JMP	VWADL2
	TAD	SCRLCT
	SNA CLA
	JMP	VWADL1
VWADL2,	CDFMYF
/D219	TAD	WIDNAR 		/ WIDE SCREEN?				/M192
/D219	SNA CLA								/M192
/D219	JMP	VWADL4 		/ JUMP IF WIDE NEEDED
	TAD	SCRLCT 		/ DID WE MOVE?
	SNA
	JMS	BEEPER 		/ COMPLAIN IF NOT (MUST BE AT END OF FILE)
	SPA CLA
	JMP	VIEW 		/ ...JUST IN CASE...			/C219
	JMS	SCRNSZ 		/ CHECK FOR STILL ON SCREEN
	CLL RAR
	CIA
	TAD	SCRLCT
	SMA CLA
	JMP	VIEW 		/ JUMP IF NOT				/C219
	TAD	SCRLCT
	SNA
	JMP	VWADL3 		/ JUMP IF NO MOVEMENT
	CIA
	CLL RAL
	DCA	VIEWCX 		/ SET -COUNT OF LINES TO SCROLL UP
	JMS	PCUR 		/ ERASE BOTTOM LINES
	JMS	CLREOL		/ Clear to end of line
	JMS	NWLN 		/ CR LF
	JMS	CLREOL		/ Clear to end of line
	TAD	VIEWCX 		/ COMPUTE NEW CURLIN
	TAD	CURLIN
	DCA	CURLIN
	JMS	NWLN
	ISZ	VIEWCX
	JMP	.-2 		/ SCROLL SCREEN UPWARDS

VWADL3,	TAD	SCRLCT		/ GET NEW LOOP COUNTER
	CMA
	JMP	VIEWA0


/D219	VWADL4,
/D192	AC0001
/D192	DCA	SPLTFL 		/ FIX SPLIT SCREEN FLAG
/D219	JMS	SET132		/ MAKE SCREEN WIDE
/D219	/ FALL THRU INTO OVVIEW ...


/ "GOLD:VIEW" COMMAND

VIEW,	DCA	CURLIN		/ CLEAR FOR PCUR ROUTINE TO POSN CURSOR	/A219
	JMS	CLSCRN 		/ CLEAR SCREEN, GO TO HOME POS.
	JMS	SCRNSZ 		/ GET SCREEN SIZE
	CLL RAR
	CIA
VIEWA0,	CDFMYF
	DCA	VWX2 		/ -COUNT OF LINES TO DO
	TAD	VWX2 		/ GET PTR TO FIRST LINE
	TAD	(PTRBLK+NPTRS)
	DCA	VWX1

	TAD	CURSOR		/ SAVE CURSOR POSITION
	DCA	CURTMP
	DCA	CURSOR

	TAD I	VWX1 		/ FIND FIRST REAL LINE
	SZA CLA
	JMP	VIEWA3 		/ QUIT QUICK IF OK
VIEWA1,	ISZ	VWX1 		/ ELSE LOOP
	TAD I	VWX1
	SZA CLA
	JMP	VIEWA2
	ISZ	VWX2
	JMP	VIEWA1

				/ MOVE CURSOR TO START OF TOP LINE
VIEWA2,	TAD	VWX2		/ GET LINE LOOP COUNTER
	STL RAL			/ TIMES 2 + 1
	DCA	CURLIN		/ = LINE NUMBER FOR PCUR
	JMS	PCUR		/ MOVE CURSOR
				/ DISPLAY "...----- TOP -----..."
	TAD	(STXMSG)
	JMS	PGMSG 		/ ----- TOP -----
	ISZ	VWX2		/ BETTER NOT SKIP!

VIEWA3,
/D219	/ TEMPORARILY COPY VWX1 & VWX2 INTO SUBR ENTRY POINTS
/D219	/ TO TRANSFER VALUES TO NEXT OVERLAY.
/D219	TAD	VWX1
/D219	DCA I	ADVSPC&177
/D219	TAD	VWX2
/D219	DCA I	BKPSPC&177
	JMS	OV2JMP
	OVVWB1

VWX1,	.-.			/ PTR INTO PTRBLK FOR FIRST LINE
				/ (COPIED TO VIEWX1 IN NEXT OVERLAY)
VWX2,	.-.			/ -(# OF TEXT LINES TO DISPLAY)
				/ (COPIED TO VIEWX2 IN NEXT OVERLAY)
VIEWCX,	.-.
VIEWF2,	.-. 			/ view mode flag (if this overlay is in)

/
/	Code from VIEWBA which won't fit there 
/
/	It checks to see what type of Dead sequence is next in the buffer
/

VIEWBZ,	CIFMNU			/ Move to Menu field			/A231
	JMS I	(TCCHK)		/ Go check this dead thing		/A231
	 JMP	VIEWBA		/ Vanilla dead , display as text	/A231
	 JMP	VIEWSP		/ req space dead , go print it		/A231
	 CDFMNU			/ Point to Menu field			/A231
	 TAD	TCTMP1		/ get char itself			/A231
	 JMP	VIEWBB		/ and get back				/A231



	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

	FIELD	4
	RELOC
	*0

/***************************************************************************
/****			   START OF OVERLAY				****
/***************************************************************************

	OVRNUM=OVRNUM+200
	OVRBLK=OVRNUM%200+DLOEDO-1 / DISK BLOCK WHERE OVERLAY IS LOADED

	RELOC

	RELOC OVLAY1
	OVRNUM 			/ EDIT EXIT PROCESSING

	OVUDKS=	.-OVLAY1+OVRNUM	/ FIRST ENTRY USED ONLY AT THE VERY END
	JMP	XVUDKS		/ OF AN EDIT (IE, NOT AT GOLD TOP)

	OVXITF=	.-OVLAY1+OVRNUM
	IAC 			/ 1 IN AC INDICATES FIRST ENTRY

	OVEXIT=	.-OVLAY1+OVRNUM	/ EXIT OVERLAY
	DCA	LSTPAS 		/ IF ZERO, THIS IS NOT LAST CALL OF THIS EDIT
	TSTSLT 			/ IF EDITOR IS IN SELECT MODE
	SKP
	JMS	UNSLCS 		/ THEN DELETE SELECT MARK
	CDFMYF			/ IF SELECTED, RETURN TO THIS FIELD


/******************** EDITOR MATH INIT CALL ****************************
/ THE FOLLOWING CALL IS MADE TO THE MATH FIELD TO INITIALIZE THE MATH
/ MODULE CODE AND SET "MTHTYP" TO 1 IN THE MATH FIELD WHEN A GOLD TOP HAS
/ BEEN DONE IN A CTRL BLOCK WITHIN A EDITOR MATH WORK AREA. OTHERWISE
/ MATH WOULD NOT GET REINITALIZED AND EDITOR MATH ENDS UP BROKEN. A 1 IS
/ PLACED IN THE AC BEFORE THE CALL TO TELL "RTRN4" THAT IT IS TO INIT FOR
/ EDITOR MATH NOT LIST PROCESSING MATH. NOTE THAT THIS SAME INIT CALL
/ TAKES PLACE IN "OVINI1" AND HERE IN "OVEXIT".

	AC0001			/ SET THE AC = 1
	CIFMTH			/ CHANGE PROGRAM CONTROL TO MATH FIELD
	JMS	RTRN4		/ GO SET "MTHTYP" = 1; AND INIT MATH MODULE

/******************   END MATH INIT CALL   *****************************


	JMS	RPCHK		/ IF GOTO PAGE, DON'T ALTER SCREEN IMAGE
	JMS	SAVLMD 		/ SAVE MOD FLAG IN TEXT

				/ *** CLOSE FILE AND EXIT
	SKP CLA
	AC0001
	CHKPTR
	SMA CLA
	JMP	.-3 		/ GET TO ETX
EDEXI1,	AC7777
	CHKPTR
	SNA
	JMP	.-3 		/ COPY TO STX
	SPA CLA
	JMP	EDEXI2
	TAD I	CURPTR
	JMS	DSKCAL
	XPUTET
	JMP	EDEXI1

EDEXI2,				/ NEXT, DETERMINE TIME THIS EDIT
				/ AND NEW TOTAL EDIT TIME
	TAD	LSTPAS
	SNA CLA 		/ IF FINAL PASS, OK
	JMP	TOLVED 		/ ELSE DONT UPDATE TIMES, AND DON'T
				/ INCREMENT THE VERSION NUMBER
	CDFSYS
	TAD I	(CLOCK+3)
	DCA	MIN 		/ CURRENT MINUTES
	TAD I	(CLOCK+4) 	/ CURRENT HOUR
	CDFMYF
	JMS	TOMIN
	DCA	TMPMIN
	TAD	OLDMIN
	DCA	MIN 		/ INITIAL MINUTES
	TAD	OLDHR 		/ INITIAL HOURS
	JMS	TOMIN
	CIA
	TAD	TMPMIN 		/ CURRENT TIME - INITIAL TIME
	SPA
	TAD	(30^74)		/ IF NEGATIVE, THE CLOCK ROLLED OVER..
				/ ADD 60 * 24 = MINUTES IN A DAY
	DCA	TMPMIN
	TAD	(15)
	CIFFIO
	FILEIO
	XHDRGT 			/ GET OLD TOTAL TIME
	CLL			/ DONE TO CHECK FOR OVERFLOW IN NEXT ADD
	TAD	TMPMIN 		/ NEW TOTAL TIME
	SZL			/ SKIP IF TIME < 68:15
	AC7777			/ TIME WAS RESET, SET TO MAX
	MQL
	TAD	(15)
	CIFFIO
	FILEIO
	XHDRPT 			/ STORE NEW TOTAL TIME
	TAD	TMPMIN
	MQL
	TAD	(14)
	CIFFIO
	FILEIO
	XHDRPT 			/ SAVE TIME THIS EDIT
	JMP	LVED

TOLVED,	CDFMYF
	TAD	(10)
	CIFFIO
	FILEIO			/ GET THE VERSION NUMBER (THE NUMBER
	XHDRGT			/ OF TIMES THE DOCUMENT HAS BEEN EDITED)
	TAD	(-1)		/ DECREMENT THIS NUMBER BY ONE, SO THAT
				/ GOLD TOP, GOLD BOTTOM AND GO-TO-PAGE
	MQL			/ DON'T ALTER IT
	TAD	(10)
	CIFFIO
	FILEIO
	XHDRPT			/ REPLACE THE VERSION NUMBER

LVED,	JMS	DSKCAL
	XDSKCL 			/ AND CLOSE IT
	CDFMYF
	JMP	OVJRTN 		/ THEN RETURN TO MAIN LINE EXIT

UNSLCS,	XX 			/ UNSELECT SUBROUTINE
	MODSET
	EDTMOD 			/ SET ADVANCE MODE
	TAD	(SLCTMD)
	DCA	GRAMUN
	JMS	SETUNT
	JMS	GETUNT
	.-.
	SZA CLA
	JMP I	.-2
	JMP I	UNSLCS

TMPMIN,	0 			/ TEMP., ALWAYS CONTAINS MINUTES
MIN,	0 			/ MINUTES FOR TOMIN
HR,	0 			/ NEG OF HOURS IN TOMIN
LSTPAS,	0 			/ FLAG - ZERO INDICATES ENTRY THRU OVEXIT,
				/ OTHER WHEN ENTRY THRU OVXITF.

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

XVUDKS,	JMS	BFOVLY
	UDKOVL

	AC7777			/ SET AC = -1
	CIFMNU			/ CHANGE INSTRUCTION FIELD TO MENU FIELD
	PGSWAP			/ AC=-1 SO JUST LOAD IN THE SAVE AREA

	OVLJMP
	OVMENU 			/ RETURN TO EDITOR MENU WHEN DONE

	UDKONM=15 		/ OVERLAY NUMBER FOR DK
	BUFONM=17 		/ DUMMY OVERLAY FOR BUFFLD LOCK WORD
UDKOVL,	-DSOUDK			/ -(LENGTH OF WPUDKS CODE)		/M183
	0 			/ LOCAL START LOC OF WPUDKS CODE
	DSOUDK-DSSEDT		/ -(LENGTH OF UDK BUFFER)		/M183
	UDKSTR 			/ LOCNS OF BUFFLD TO WRITE OUT (READ BACK)
	UDKONM
	200 			/ OVERLAY TO CALL & START ADDR IN BUFFLD


BFOVLY,	XX 			/ LOAD OVERLAY INTO BUFFLD
				/ AFTER SAVEING RELEVANT LOCATIONS
				/ RESTORE THOSE LOCATIONS ON RETURN FROM OVERLAY
	TAD	(RXEWT+2000)	/ LOAD OP CODE
	JMS	BFSVRS 		/ WRITE OUT BUFFLD LOCATIONS
	DCA	BFOVT4 		/ SAVE OVERLAY NUMBER
	CIFMNU
	JMS I	OLAYCL 		/ LOAD OVERLAY
BFOVT4,	.-.
	ISZ	BFOVT1 		/ BUMP ARG PTR TO ENTRY ADDR
	RIF
	TAD	(CIF+10)
	DCA	BFOVT2 		/ STORE CIF TO BUFFLD
	TAD I	BFOVT1
	DCA	BFOVT4 		/ STORE ENTRY ADDR
BFOVT2,	.-. 			/ ---CIF BUFFLD---
	JMS I	BFOVT4 		/ CALL OVERLAY
	TAD	(RXERD)		/ RESTORE BUFFLD CONTENTS
	JMS	BFSVRS
	CLA 			/ OVERLAY NUM NOT NEEDED THIS TIME!
	CIFMNU
	JMS I	OLAYCL
	BUFONM 			/ CLEAR BUFFLD LOCK WORD
	ISZ	BFOVLY 		/ BUMP TO RETURN ADDR
	JMP I	BFOVLY

BFOVT1,	.-. 			/ TEMP

BFSVRS,	XX 			/ BUFFLD SAVE-RESTORE SUBROUTINE
	DCA	BFOVT5 		/ SAVE RXHAN OP-CODE (READ/ WRITE)
	TAD I	BFOVLY 		/ GET ARG PTR
	DCA	BFOVT1
	TAD	(DLSEDT)
	DCA	BFOVT4 		/ SET DISK LOCN
BFOVL1,	TAD I	BFOVT1 		/ GET NEXT -COUNT
	SMA
	JMP I	BFSVRS 		/ RETURN IF NOT COUNT
	DCA	BFOVT2
	ISZ	BFOVT1
	TAD I	BFOVT1 		/ GET ADDR
	DCA	BFOVT3
	ISZ	BFOVT1
BFOVL2,	TAD	BFOVT4 		/ LOAD DISK BLOCK #
	CDFBUF
	JMS	SYSIO
BFOVT5,	.-. 			/ READ-WRITE OP-CODE
BFOVT3,	.-. 			/ ADDR
	ISZ	BFOVT4 		/ BUMP DISK BLOCK #
	TAD	(400)
	TAD	BFOVT3
	DCA	BFOVT3 		/ BUMP ADDR
	ISZ	BFOVT2
	JMP	BFOVL2 		/ LOOP TIL COUNT COMPLETE
	JMP	BFOVL1

/ SUBROUTINE TO CONVERT HOURS AND MINUTES TO MINTUTES

TOMIN,	0
	SNA
	JMP	MIN2 		/ IF ZERO AC (NO HOURS), JUMP
	CIA
	DCA	HR 		/ LOOP CONTROL
LOOP,	TAD	(74)
	ISZ	HR
	JMP	LOOP
MIN2,	TAD	MIN 		/ ADD MINUTES-FROM-HOURS TO MINUTES
	JMP I	TOMIN

RPCHK,	0			/ IF GOTO PAGE, LEAVE SCREEN ALONE
	TAD	RPBIN1		/ GOTO PAGE FLAG
	SPA CLA			/ SKIP IF NOT GOTO PAGE
	JMP	RPXCHK		/ CONTINUE GOTO PAGE CLOSE

	JMS	CLR132		/ 80-COL. MODE
	CLA
	DCA	SPLTFL		/ THIS MAKES FOR 24 LINES

	CIFMNU			/ CHANGE TO MENU INSTRUCTION FIELD
	AC0003			/ SET UP FOR CLEAR SCREEN REQUEST
	JMS I	(CALLN1)	/ GO TO STATUS LINE ROUTINE FOR CLEAR

	TAD	(NPTRS)		/ PICK UP MAXIMUM NUMBER OF LINES
	DCA	SCRNLN		/ SAVE FOR USE BY PROMPT ROUTINE

	JMS	PROMPT		/"...FILING BEING DONE" MSG
	MSGF			/ MSG POINTER

RPXCHK,	CIFMNU			/ CHANGE INSTRUCTION FIELD TO MENU FIELD
	PGSWAP			/ AC=0, SAVE SWAP AREA & RELOAD MENU CODE

	JMP I	RPCHK		/ RESUME CLOSE PROCESS

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

/***************************************************************************
/****			   START OF OVERLAY				****
/***************************************************************************

	OVRNUM=OVRNUM+200
	OVRBLK=OVRNUM%200+DLOEDO-1 / DISK BLOCK WHERE OVERLAY IS LOADED

	RELOC

	RELOC	OVLAY1
	OVRNUM

	OVDEAD=	.-OVLAY1+OVRNUM	/ THE USER TYPED "GOLD:DEAD"
	JMP	XVDEAD


	OVRQSP=	.-OVLAY1+OVRNUM	/ THE USER TYPED "GOLD:SPACE"
	JMP	XVRQSP		/ (REQUIRED OR NONBREAKING SPACE)


	RPPER9=	.-OVLAY1+OVRNUM
	JMP	XPPER9		/ MULTIPLE MATH 'START' BLOCKS FOUND

	RPPER5=	.-OVLAY1+OVRNUM
	JMP	XPPER5		/ REPORT INVALID CHARACTER STRING

	RPPER3=	.-OVLAY1+OVRNUM
/	JMP	XPPER3

XPPER3,	TAD	(RANBAD)
	SKP
XPPER5,	TAD	(CHABAD)	/ AC => ADDR. OF MSG. STRING
	SKP
XPPER9,	TAD	(RPPME9)
	DCA	RPMSG		/ SUPPLY FOR OUTPUT TO SCREEN
	JMS	PUTMSG		/ DISPLAY AN ERROR MSG. ON THE
				/ SAME LINE AS PAGE NUMBER MSG.
RPMSG,		.-.		/ ADDR. OF DESIRED ERROR MSG.
	JMS	PUTMSG
	RPPRETRY
	JMS	GETLIN
	RPBUF								/C206
	OVLJMP;	OVRPP4		/ STARTUP REPOSITIONING AGAIN...

RPBUF,	-1								/C206
	ZBLOCK	1

/***********************************************************************
/****			PREVIOUS AND NEXT SCREEN ROUTINES	    ****
/***********************************************************************

OVPRSC=	.-OVLAY1+OVRNUM		/ ENTER FOR PREVIOUS SCREEN
	IAC

OVNXSC=	.-OVLAY1+OVRNUM		/ ENTER FOR NEXT SCREEN
	DCA	ARTMP		/ AC = MOVE MODE (0=ADV, 1=BKP)
	MODSET
	ARCMOD			/ SET MOVE MODE
	AC0001			
	DCA	GRAMUN		/ SET UNIT TO LINE
	TAD	ARTMP		/ NOW GET MOVE MODE BACK AGAIN
	SNA CLA			/ DISPATCH TO PROPER ROUTINE
	JMP	NXSCR1		/ (NEXT SCREEN)

	JMS	SCRNSZ		/ PREVIOUS SCREEN ROUTINE
	DCA	CNSCRL		/ STORE SCROLL COUNT
	JMS	BACKUN		/ TRY 1ST BACKUP
	JMP	EIBAD		/ (CAN'T, GO BUZZ)

PRVSC1,	CLA
	CDFMYF
	TAD	CNSCRL		/ DONE?
	SNA CLA
	JMP	EINEXT		/ YES
	JMS	BACKUN		/ NO, TRY BACKING UP AGAIN
	JMP	EINEXT		/ (FAIL NOW IS OKAY)
	JMP	PRVSC1		/ LOOP TO TEST IF DONE

NXSCR1,	JMS	SCRNSZ		/ NEXT SCREEN ROUTINE
	CIA			/ NEGATE THE SCROLL COUNT
	IAC			/ SET TO DO ONE LESS
	DCA	CNSCRL
	JMS	SETUNT		/ SET UNIT CODE
	JMS	LODCHR		/ START US OFF
	JMP	EIBAD		/ (CAN'T, GO BUZZ)
NXSCR2,	JMS	GETUNT		/ CK FOR END OF LINE
NXSCR3,	.-.
	SZA CLA			/ DONE WITH LINE?
	JMP I	NXSCR3		/ NO, CONTINUE LOOKING

	CDFMYF
	TAD	CNSCRL		/ DONE?
	SNA CLA
	JMP	EINEXT		/ YES
	DCA	SCRLFL		/ NO, ENSURE SCROLL FLAG 0
	JMS	LODCHR		/ AND GO ANOTHER LINE
	JMP	EINEXT		/ (FAIL NOW IS OKAY)
	JMP	NXSCR2		/ LOOP TO GET END OF LINE

ARCMOD,	SCHMOD!SLTMOD
ARTMP,	.-.


/
/	We got here because we entered into a tech dead thing and now we/A226
/	want to get out							/A226
/
DEDKYX,
	CLA			/					/A226
	TAD I	CURPTR		/ get current char			/A226
DEDBNX,	TAD	(-ECSTOV)	/ Are we at the start yet ?		/A226
	SNA CLA			/ 					/A226
	JMP 	EIBAD		/ Yes ,Must have been a req space	/A226
				/ so beep and get out			/A226
	BKPPTR			/ Not there yet so keep backing up	/A226
	NOP			/ 					/A226
	JMP	DEDBNX		/ Try previous one			/A226

/
/	The compound Tech-Mcs dead has been split now back up to 2nd	/A226
/	1st non-tech char in string					/A226
/


DEDBKP,	BKPPTR			/ Backup				/A226
	NOP			/ Shouldn't happen			/A226
	SLNMOD			/ Set line modified			/A226
	AC0001			/					/A226
	JMP	EIFIX1		/ Go listen for more			/A226




	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE



/ HANDLE "GOLD:DEAD" COMMAND  (DEAD KEY = EDDEAD)

XVDEAD,	JMS	LODCHR
	JMP	EIBAD
	JMS	CHKALP
	JMP	DEDKYA 		/ JUMP IF NOT ALPHA
	BKPPTR
	JMP	EIBAD
	JMS	CHKALP
	JMP	DEDKYB 		/ JUMP IF PREV NOT ALPHA
	AC7777			/ SET CURSOR TO START OF DEAD-
	TAD	CURSOR		/  KEY SEQUENCE. FROM HERE GETS
	DCA	CURSOR		/  REFRESHED.
	SLNMOD			/ SAVE LINE POSN FOR REFRESH.
	TAD	(ECSTOV)
	JMS	INSRL1 		/ BOTH ALPHA, START OVERSTRIKE
DEDKYE,	ADVPTR
	JMP	EIBAD		/ ADVANCE OVER BOTH
	ADVPTR
	NOP
	CLA
	TAD	(ECNDOV)
	JMS	INSRL1 		/ END OVERSTRIKE
	SLNMOD
	JMP	EIFIX 		/ JUMP TO LISTEN FOR MORE

DEDKYA,	TAD	(-ECSTOV) 	/ IS CURRENT OVERSTRIKE?
	SZA CLA
	JMP	EIBAD 		/ JUMP IF NOT
	ADVPTR			/ AND NOT A "REQUIRED SPACE"?
	JMP	DEDKYC		/   (BUG)
	AND	P177		/ IGNORE ATTRIBUTES
	TAD	(-ECSPC)
	SZA CLA								/M172
	JMP	DEDKA1							/A172
/d226	BKPPTR			/ Restore pointer to beginning 		/A172
/d226	NOP			/ of dead key seq			/A172
/d226	JMP	EIBAD		/ NO-I MEAN YES IT'S A REQUIRED SPACE
				/   SO USER CAN'T BREAK APART OVERSTRIKE
				/   SEQUENCE BECAUSE, CONCEPTUALLY, IT'S
	JMP	DEDKYH		/ Check if he wants to Undead a tech	/A226


				/   NOT AN OVERSTRIKE
DEDKA1,	ADVPTR
	JMP	DEDKYC 		/ ADVANCE TO END
	TAD	(-ECNDOV)
	SZA CLA
	JMP	.-4
	DCA I	CURPTR 		/ DELETE END MARKER
DEDKYC,	BKPPTR
	JMP	EIBAD		/ BACK UP TO START
	TAD	(-ECSTOV)
	SZA CLA
	JMP	.-4
	DCA I	CURPTR 		/ DELETE START
	SLNMOD
	AC0001
	JMP	EIFIX1 		/ ADVANCE CURSOR AND LISTEN


/
/ PREVIOUS CHAR (NOW CURRENT CHAR) IS NOT PRINTABLE.
/ IF IT'S AN OVERSTRIKE SEQUENCE, THEN APPEND TO IT.
/ IF IT'S A REQUIRED SPACE OR ANYTHING ELSE, THEN USER ERROR (BEEP).
/
DEDKYB,	TAD	(-ECNDOV)	/ IS PREVIOUS CHAR AN OVERSTRIKE?
	SZA CLA
	JMP	DEDKYG		/ NO: USER ERROR
	BKPPTR			/ YES: IS PREVIOUS CHAR A REQUIRED SPACE?
	JMP	DEDKYG		/   (BUG - FIX CURSOR POS)
	AND	P177		/   (IGNORE ATTRIBUTES)
	TAD	(-ECSPC)
	SZA CLA
	JMP	DEDKYD		/ NO: APPEND TO OVERSTRIKE SEQUENCE
	ADVPTR			/ YES: USER ERROR - RESTORE CURPTR ...
	JMP	EIBAD		/   (BUG)
DEDKYG,	ADVPTR			/ ... TO POSITION AT ENTRY TO XVDEAD ...
	JMP	EIBAD		/   (BUG)
	JMP	EIBAD		/ ... AND COMPLAIN

/
/ AT ENTRY TO XVDEAD, THE CURSOR WAS ON A PRINTING CHARACTER,
/ AND A NON-REQUIRED-SPACE OVERSTRIKE SEQUENCE PRECEEDED THE CURSOR.
/ THUS, WE NEED TO APPEND THE PRINTING CHARACTER TO THE OVERSTRIKE
/ SEQUENCE.
/ (CURPTR IS NOW ON CHAR BEFORE ECNDOV)
/
DEDKYD,	ADVPTR			/ ADVANCE CURPTR TO ECNDOV
	JMP	EIBAD		/   (BUG)
	CLA			/ DELETE ECNDOV
	DCA I	CURPTR		/   IN EDIT BUFFER
	AC0010			/ Incase it is a technical re-display hash/A172
	PUTOUT								/A172
	JMS	PUTSPC							/A172
	 EXGOVS								/A172
	JMP	DEDKYE		/ GO INSERT ECNDOV AFTER PRINTING CHAR

/
/ HANDLE "GOLD SPACE"   (REQUIRED SPACE = EDRQSP)
/
/ A "REQUIRED SPACE" IS A SPACE THAT WILL NOT BE USED AS A LINE BREAK
/ BY THE JUSTIFICATION ROUTINES (A NONBREAKING SPACE).
/
/ "REQUIRED SPACE" IS IMPLEMENTED AS AN OVERSTRIKE SEQUENCE CONTAINING
/ TWO SPACES.  THIS APPEARS IN THE EDIT BUFFER AS:
/      ECSTOV ECSPC ECSPC ECNDOV
/ (THE ECSPC CHARS MAY HAVE ATTRIBUTES SET.)
/ SUCH A SEQUENCE IS IMPOSSIBLE TO ENTER MANUALLY BECAUSE OVERSTRIKE
/ SEQUENCES MAY ONLY CONTAIN PRINTING CHARACTERS.
/ CONCEPTUALLY, SUCH SEQUENCES ARE HEREBY REDEFINED AS A "REQUIRED SPACE",
/ AND THUS MAY NOT BE MANIPULATED OR DISPLAYED AS OVERSTRIKE SEQUENCES.
/
/ THIS ROUTINE INSERTS A "REQUIRED SPACE" INTO THE EDIT BUFFER.
/
XVRQSP,	SLNMOD			/ TELL FXSCRL WE'RE MODIFYING EDIT BUFFER
	TAD	(ECSTOV)	/ INSERT ECSTOV INTO EDIT BUFFER
	JMS	INSRL1
	TAD	(ECSPC)		/ INSERT ECSPC
	JMS	INSRL1
	TAD	(ECSPC)		/ INSERT ECSPC
	JMS	INSRL1
	TAD	(ECNDOV)	/ INSERT ECNDOV
	JMS	INSRL1
	JMP	EIFIX		/ DONE


/
/	Test if user is trying to UNDEAD a tech-MCs-Linedrawing compose	/A226
/	seq which he has previously extended with extra chars		/A226
/
DEDKYH,	
	ADVPTR			/ Look at char after space		/A226
	JMP	EIBAD		/ Bug .. 				/A226
	AND	P177		/ Strip off attributes			/A226
	TAD	(-60)		/ Is it greater than 60			/A226
	SPA SNA			/ ?					/A226
	JMP	DEDKYX		/ No , back pointer up and get out	/A226
	TAD	(60-64)		/ Is it less than or equal to 63	/A226
	SMA SZA			/ 					/A226
	JMP	DEDKYX		/ No , Backup and get out		/A226
	CLA			/					/A226
	ADVPTR			/ Move on to "real" char		/A226
	JMP	EIBAD		/ Bug.. shouldn't happen		/A226
	ADVPTR			/ Now we should be on the End Dead	/A226
	JMP 	EIBAD		/ Bug.. shouldn't happen		/A226
	TAD	(-ECNDOV)	/ Is it really the end of dead ?	/A226
	SNA CLA			/					/A226
	JMP	DEDKYX		/ Yes , backup and get out		/A226
	TAD	(ECNDOV)	/ Put End of Dead here			/A226
	JMS	INSRL1		/ Now insert it				/A226
DEDSNX,	TAD	(-ECNDOV)	/ Is it end of dead ?			/A226
	SNA CLA			/					/A226
	JMP	DEDKRB		/ Yes , go rubout End of dead		/A226
	ADVPTR			/ Try the next one 			/A226
	JMP 	EIBAD		/ Bug.. shouldn't happen		/A226
	JMP	DEDSNX		/ Try next 				/A226
DEDKRB,	DCA I	CURPTR		/ Rubout the end of dead		/A226
	JMP	DEDBKP		/ Go back to 2nd char in dead seq	/A226

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE


/***************************************************************************
/****			   START OF OVERLAY				****
/***************************************************************************

	OVRNUM=OVRNUM+200 	/ NEW OVERLAY NUMBER
	OVRBLK=OVRNUM%200+DLOEDO-1 / DISK BLOCK WHERE OVERLAY IS LOADED

	RELOC

	RELOC OVLAY1
	OVRNUM


/ MERGE TRAILER FOR LIST PROCESSING.
/
/ THE CHARACTER "<" IN A FORM DOCUMENT TRAILER IS TREATED IN A SPECIAL WAY
/  DEPENDING ON WHAT FOLLOWS IT:
/
/	<FIELD NAME> -	SUBSTITIUTE THE TEXT OF THE NAMED FIELD IN THE
/			CURRENT RECORD AT THIS POINT IN THE OUTPUT.  IF A
/			MATCH FOR THIS FIELD IS NOT FOUND WITHIN THE CURRENT
/			MATH RESULT BUFFER THEN THIS FIELD IS OUTPUT JUST AS
/			IT APPEARS IN THE FORM DOCUMENT.
/
/	<!S>	     -	OUTPUT THIS FIELD AS IS.  DO NOT TREAT THIS FIELD AS
/			THE START OF A REPETITIVE ZONE.
/
/	<!E>	     -	OUTPUT THIS FIELD AS IS.  DO NOT TREAT THIS FIELD AS
/			THE END OF A REPETITIVE ZONE.
/
/	<!R>	     -	OUTPUT THIS FIELD AS IS.  DO NOT TREAT THIS FIELD AS
/			A COMMAND TO COPY THE TEXT OF THE CURRENT RECORD FROM
/			THE LIST DOCUMENT TO THE OUTPUT.
/
/	<>	     -	OUTPUT THIS FIELD AS IS.  DO NOT TREAT THIS FIELD AS
/			A COMMAND TO ADVANCE TO THE NEXT RECORD IN THE LIST
/			DOCUMENT.
/
/	<<	     -	OUTPUT A SINGLE "<" AT THIS POINT.
/
/	NO OTHER CHARACTERS IN THE FORM DOCUMENT ARE TREATED SPECIALLY.


	OVMRG5=	.-OVLAY1+OVRNUM / FIFTH MERGE OVERLAY

TMRGSA,	CURMOV
	NOP
TMRGSB,	JMS	LODCHR 		/ LOOKING FOR START OF FIELD
	JMP	TMRGDON 	/ WE HIT END OF THE FORM DOCUMENT

	AND	P177 		/ STRIP MODE BITS FROM CHARACTER
	TAD	(-"<+200) 	/ IS CHARACTER = "<"?
	SNA CLA 		/ SKIP IF: NOT
	JMP	TMRGS7		/ START OF FIELD NAME - PROCESS IT
TMRGSC,	JMS	TMRGADV 	/ ADVANCE CURSOR BY ONE CHARACTER
	JMP	TMRGSB		/ CONTINUE LOOKING FOR START OF FIELD

TMRGS7,	TAD	CURPTR 		/ GET POINTER TO LEFT ANGLE BRACKET
	DCA	MRGPT2 		/ SAVE POINTER TO LEFT ANGLE BRACKET
	SLNMOD 			/ SET LINE MODIFIED FLAG
	JMS	JCLEAN 		/ WE'RE GOING TO CHANGE SOMETHING
	ADVPTR 			/ GET NEXT CHARACTER
	JMP	TMRGDON 	/ WE HIT END OF TEXT

	AND	P177 		/ STRIP MODE BITS
	TAD	(-"<+200) 	/ IS CHARACTER ANOTHER "<"?
	SNA 			/ SKIP IF: NOT
	JMP	TMLLAB 		/ GO PROCESS A "<<" SEQUENCE

	TAD	("<-">) 	/ IS CHARACTER = ">"?
	SNA 			/ SKIP IF: NOT
	JMP	TMRGSA 		/ NULL FIELD NAME - IGNORE

	TAD	(">-"!) 	/ IS CHARACTER = "!"?
	SNA CLA 		/ SKIP IF: NOT
	JMP	TMRGSA 		/ SPECIAL NAME - IGNORE


/ MATCH TRAILER FIELD NAME IN FORM DOCUMENT TO FIELD NAME FROM MATH
/  RESULT BUFFER.
	CDFMYF			/ CHANGE DF TO MY FIELD
	JMS	TMFNIF 		/ MATCH FIELD NAME IN FORM DOCUMENT TO
	RESBUF 			/  FIELD NAME IN MATH RESULT BUFFER

	CDFLP			/ RESBUF IS IN LIST PROCESS. FIELD
	JMP	TMRGSC 		/ NO MATCH FOUND
	JMP	TMRGSA 		/ MATCH - SCAN DOCUMENT FOR NEXT FN


/ MATCH FIELD NAME IN FORM DOCUMENT TO A FIELD NAME FROM RECORD.

TMFNIF,	XX 			/ MATCH FIELD NAME IN FORM DOCUMENT
	TAD I	TMFNIF 		/ GET ADDRESS OF BUFFER TO MATCH
	DCA	MRGPT1 		/ SAVE IT
	ISZ	TMFNIF		/ BUMP RETURN
	TAD I	TMFNIF		/ GET FIELD OF THAT BUFFER
	DCA	TTADI1		/ SAVE IT
	ISZ	TMFNIF 		/ BUMP RETURN
TMRGS1,	TAD	MRGPT2 		/ POINT TO TEXT BRACKET IN FORM
	DCA	CURPTR 		/ RESET POINTER
TMRGS2,	JMS	TTADIMRGPT1 	/ GET NEXT CHAR FROM RECORD
	ISZ	MRGPT1 		/ BUMP RECORD PTR
	SNA 			/ SKIP IF: NOT END OF RECORD
	JMP	TMRGS8 		/ FIELD NOT FOUND, END OF RECORD
	TAD	(-"<+200) 	/ IS CHARACTER = "<"?
	SZA CLA 		/ SKIP IF: SO
	JMP	TMRGS2 		/ LOOP TIL FIELD START
TMRGS3,	ADVPTR 			/ GET NEXT FIELD VALUE CHAR. FROM TEXT
	JMP	TMRGDON 	/ WE HIT THE END OF TEXT
	AND	P177 		/ STRIP MODE BITS
	XLTUPR 			/ XLAT CHAR TO UPPER CASE
	CIA 			/ SET UP FOR COMPARE WITH RECORD'S
	DCA	T1 		/  FIELD NAME VALUE
	JMS	TTADIMRGPT1 	/ GET NEXT CHAR FROM RECORD
	XLTUPR 			/ XLAT TO UPPER CASE
	TAD	T1 		/ COMPARE WITH CHARACTER FROM TEXT
	SZA CLA 		/ SKIP IF: CHARACTERS MATCH
	JMP	TMRGS1 		/ LOOP IF NOT EQUAL
	JMS	TTADIMRGPT1 	/ GET NEXT RECORD CHARACTER
	ISZ	MRGPT1 		/ BUMP POINTER INTO RECORD
	TAD	(-">+200) 	/ IS CHARACTER = ">"?
	SZA CLA 		/ SKIP IF:SO
	JMP	TMRGS3 		/ CHECK FOR END OF NAME
	TAD	MRGPT2 		/ RESET TEXT BUFFER POINTER TO START OF
	DCA	CURPTR 		/  FIELD NAME WE JUST MATCHED.
	JMS	TMRGDLF 	/ DELETE THAT FIELD NAME FROM TEXT
TMRGS4,	DCA	MRGPT2 		/ SET LOOKAHEAD
	JMS	TTADIMRGPT1 	/ CHECK FOR END OF FIELD IN RECORD
	TAD	(-"<+200) 	/ IS CHARACTER = "<"?
	SNA CLA 		/ SKIP IF: NOT
	JMP	TMRGS5 		/ JUMP IF END OF FIELD VALUE
	TAD	MRGPT2 		/ GET LOOK AHEAD CHARACTER
	SZA 			/ SKIP IF: 0
	INSCHR 			/ OUTPUT LOOKAHEAD
	JMS	TTADIMRGPT1 	/ LOAD NEW LOOKAHEAD
	CLA SWP			/ ATTRIBUTED CHAR COMES BACK IN THE MQ
				/ SO RESTORE IT TO THE AC
	ISZ	MRGPT1 		/ BUMP POINTER INTO FIELD VALUE
	JMP	TMRGS4 		/ LOOP TO OUTPUT NEXT FIELD VALUE CHAR.
				/  INTO RESULT DOCUMENT

TMRGS5,	TAD	MRGPT2 		/ OUTPUT LAST CHAR AT END OF FIELD
	TAD	(-40) 		/ WAS THIS A SPECIAL CHAR.?
	SPA SNA CLA 		/ SKIP IF: NOT
	JMP	TMRGS6 		/ SPECIAL CHARACTER. DO NOT INSERT
	TAD	MRGPT2 		/ REGULAR CHARACTER. INSERT INTO TEXT
	INSCHR
TMRGS6,	ISZ	TMFNIF		/ BUMP RETURN FOR MATCH
TMRGS8,	JMP I	TMFNIF		/ RETURN


/ THIS ROUTINE WILL READ A CHARACTER FROM THE BUFFER SPECIFIED WHEN
/  MFNIFD WAS CALLED.  TADIM1 IS PRIMED UPON CALL TO MFNIFD.  UPON
/   READING A CHARACTER THE DF IS ALWAYS RETURNED TO THE EDITOR BUFFER
/    FIELD SINCE OTHER ROUTINES CALLED DURING OVMRG2 DEPEND ON DF SET
/     TO THE EDITOR BUFFER FIELD.
/ THE MQ IS USED TO SAVE THE CHARACTER WITH IT'S ATTRIBUTES SO THAT
/  ANY ATTRIBUTES IT HAS WILL BE CARRIED OVER FROM THE LIST DOCUMENT
/   TO THE RESULT DOCUMENT
TTADIMRGPT1,
	XX
TTADI1,.-. 			/ LOADED WITH CDF INSTRUCTION
	TAD I	MRGPT1 		/ READ CHARACTER FROM RECORD
	MQL			/ SAVE THE ATTRIBUTED CHAR IN THE MQ
	MQA			/ RESTORE CHAR TO THE AC
	AND	P177 		/ STRIP MODE BITS
	CDFBUF 			/ SET DF TO EDITOR BUFFER FIELD
	JMP I	TTADIMRGPT1 	/ RETURN




/ ADVANCE CURSOR ONE CHARACTER AT A TIME THROUGH RESULT DOCUMENT,
/  CHECKING FOR ENOUGH ROOM ON DISKETTE TO CONTINUE THROUGH THE DOC.
TMRGADV,XX
	AC0001 			/ ADVANCE CURSOR 1 CHARACTER
	CURMOV
	JMP	TMRGDON 	/ EOF RETURN FROM CURMOV
	JMS	CHKSPC 		/ CHECK DISKETTE SPACE
	JMP I	TMRGADV 	/ RETURN


/ MULTIPLE LEFT ANGLE BRACKET SEQUENCE HANDLER ("<<...ETC.") - DELETE A
/  LEFT ANGLE BRACKET FROM THIS FIELD NAME .  WHEN THE FIRST CHARACTER
/   THAT IS NOT A "<" IS READ REENTER SCAN LOOP.

TMLLAB,				/ TRAILER_MULTIPLE_LEFT_ANGLE_BRACKET_PROCESSOR
	DCA I	CURPTR		/ DELETE A LEFT ANGLE BRACKET
	TAD	MRGPT2		/ RESTORE POINTER TO START OF FIELD
	DCA	CURPTR
	SLNMOD			/ SET LINE MODIFIED FLAG
TMLLA1,	JMS	TMRGADV 	/ ADVANCE CURSOR ONE CHARACTER

	JMS	LODCHR 		/ GET THE NEXT CHARACTER
	JMP	TMRGDON 	/ EOF RETURN

	AND	P177 		/ STRIP MODE BITS
	TAD	(-"<+200) 	/ IS CHARACTER = "<"?
	SNA CLA 		/ SKIP IF: NOT
	JMP	TMLLA1 		/ CHARACTER = "<". GET NEXT ONE

	JMP	TMRGSB 		/ REENTER SCAN LOOP

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE


/ DELETE A CHARACTER IN THE RESULT DOCUMENT
TMRGDEL,XX 			/ DELETE CHAR SUBROUTINE
	JMS	LODCHR 		/ READ A CHARACTER
	JMP I	TMRGDEL 	/  NONE LEFT - EXIT
	ISZ	TMRGDEL 	/ BUMP TO OK RETURN
	AND	P177 		/ STRIP MODE BITS
	MQL 			/ HOLD CHARACTER IN MQ
	DCA I	CURPTR 		/ DELETE CHARACTER FROM TEXT
	MQA 			/ RESTORE CHAR TO AC
	JMP I	TMRGDEL 	/ AND RETURN

/ DELETE A FIELD
TMRGDLF,XX 			/ DELETE FIELD SUBROUTINE
	JMS	TMRGDEL 	/ DELETE ONE CHARACTER OF THE FIELD
	JMP I	TMRGDLF 	/ QUIT IF NO MORE
	TAD	(-">+200) 	/ WAS CHARACTER JUST DELETED A ">"?
	SZA CLA 		/ SKIP IF: SO
	JMP	.-4 		/ DELETE TIL END
	SLNMOD 			/ SET LINE MODIFIED
	JMP I	TMRGDLF 	/ THEN RETURN


TMRGDON,OVLJMP	 		/ DO EXIT OVERLAY
	OVMRG3


	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

/***************************************************************************
/****			   START OF OVERLAY				****
/***************************************************************************

	OVRNUM=OVRNUM+200
	OVRBLK=OVRNUM%200+DLOEDO-1 / DISK BLOCK WHERE OVERLAY IS LOADED

	RELOC

	RELOC OVLAY1
	OVRNUM

	OVRPP4=	.-OVLAY1+OVRNUM
	JMP	RPERR		/ SECONDARY ENTRY POINT AFTER
				/ REPORTING INPUT STRING ERROR


/****************************************************************

/  START OF THE NEW V2 FAST FORWARD AND REVERSE (GOTO PAGE)

/****************************************************************

	OVRPPG=	.-OVLAY1+OVRNUM	/ BEGINNING OF V2.0 GO-TO-PAGE



RPCMMA=	",-200			/ ASCII COMMA
RPPLUS=	"+-200			/ ASCII PLUS SIGN
RPMINU=	"--200			/ ASCII MINUS SIGN
RPPRCT=	"%-200			/ ASCII PERCENT SIGN
/D206	TMP=	EIGES4+1	/ BUFFER CONTIANING ASCZI CHARS.

/ -----------------------------------------------------------------------------
/ SHARING MAIN MEMORY LOCATIONS TO CONSERVE SPACE HERE PLUS
/ PERMITTING ACCESS TO THESE VALUES FROM ANY V2.0 GO-TO-PAGE
/ OVERLAY...


RPWORD=	SRCDIR			/ FLAG WORD FOR POSITIONING INFO.
				/ (STORED IN MAIN EDITOR MEMORY PAGE 0)
	ABSOL=	4000		/ BIT0 ON = ABSOLUTE PAGE/BLK #
				/     OFF = OFFSET PAGE/BLK #
	REVERS=	2000		/ BIT1 ON = REVERSE (-) DIRECTION
				/     OFF = FORWARD (+) DIRECTION
	PGMODE=	1000		/ BIT2 ON = POSITION TO A PAGE
				/     OFF = POSITION TO A BLOCK
/ -----------------------------------------------------------------------------

/ RPINIT - Rapid Positioning INITialization

/	Here whenever the response to the "ENTER PHRASE:"
/	message was terminated via the PAGE key.
/	Begin the V2.0 repositioning procedure to a user
/       defined page or block.

/ RPINIT PSEUDO CODE:

/begin
/	if   the reply to the "ENTER PHRASE:" message was the
/		PAGE key preceeded by data, error exit back
/		to request the search string again
/	  else,   continue by displaying the "ENTER PAGE NUMBER:"
/		  message and inputting the user response
/
/	if   the reply to the "ENTER PAGE NUMBER:" message was
/		solely the RETURN key, abort process by returning
/		to the Editor keyboard loop routine
/	  else,
/		if  the 1st char. supplied in response to the
/			"ENTER PAGE NUMBER:" message was the -
/			sign, set BIT1 on in RPWORD
/		   else
/				leave BIT1 reset
/			set Range Factor (T1) to -1 to account for
/			special character in input buffer and
/			set buffer offset (T2) to 1 to skip first
/			input buffer char.
/				 else, clear Range Factor (T1) and
/					start buffer offset (T2)
/					set BIT0 in RPWORD
/
/
/
/				WITH THE PAGE KEY IN RESPONSE
/				TO THE "ENTER PHRASE:" MSG.

	TAD	GETLEN		/ # OF CHARS (from French bug fix 112
	SZA CLA			/ SKIP IF VALID USER RESPONSE
	JMP	EIFIND		/ EXIT:USER SUPPLIED CHARS. WITH
				/ THE PAGE KEY.  ASK FOR PHRASE AGAIN.
				/ REPEAT THE SEARCH PROCESS; NOTE
				/ THAT THE AC MUST BE ZERO

RPERR,	JMS	PROMPT		/ CLEAR SCROLL LINE THEN ASK FOR PAGE NUMBER
	EIRPG1			/ POINTER TO "ENTER PAGE NUMBER:"
	JMS	GETLIN		/ GET PAGE INFO. FROM USER
	EIRPG2			/ POINTER TO NEG. INPUT RANGE VALUE;
				/ OUR INPUT BUFFER ALSO STARTS IN THAT
				/ WORD IMMEDIATELY FOLLOWING EIRPG2

/ NOW SEE IF THE USER HAS DECIDED AGAINST CONTINUING THIS
/ POSITIONING REQUEST BY LOOKING FOR THE 'RETURN' KEY AS THE
/ ONLY RESPONSE TO THE "ENTER PAGE NUMBER:" MSG...

	TAD	GETLEN		/ # OF CHARS. IN THE INPUT BUFFER
	SNA CLA			/ SKIP IF OTHER THAN 'RETURN'
	JMP	EINEXT		/ ABORT POSITIONING REQ.


/ USER INPUT IS IN BUFFER AT EIRPG2+1.  STRIP ALLOWABLE SPECIAL
/ CHARS. (+,-,%) BEFORE CONVERTING ASCII NUMERICS INTO THEIR
/ CUMULATIVE BINARY VALUE...
	DCA	RPWORD		/ CLEAR POSITIONING FLAGS' WORD
	DCA	T1		/ INIT. 'RANGE' FACTOR
	DCA	T2		/ AND INPUT BUFFER CHAR. OFFSET
	TAD I	(EIRPG2+1)	/ GET THE 1ST INPUT CHAR.
	TAD	(-RPPLUS)	/ COMPARE TO + SIGN
	SNA			/ SKIP IF NOT +
	JMP	SETSPC		/ LEAVE BIT 1 OFF
	TAD	(RPPLUS-RPMINU)	/ COMPARE TO - SIGN
	SNA CLA			/ SKIP IF NOT + OR -
	JMP	SETNEG		/ GO SET REVERSE DIRECTION FLAG
	TAD	(ABSOL)		/ BIT0 ON (ABSOLUTE #, NOT OFFSET)
	DCA	RPWORD		/ SET BIT0 ON IN POSITION WORD
	JMP	PAGBLK		/ NOW SEE IF PAGE OR BLOCK POSITIONING

SETNEG,	TAD	(REVERS)	/ BIT1 ON = REVERSE DIRECTION
	DCA	RPWORD		/    OFF = FORWARD DIRECTION
SETSPC,	AC7777			/ TAKE 1 AWAY FROM RANGE VALUE LATER
	DCA	T1		/ TO ACCOUNT FOR THE SPECIAL DIRECTION SIGN
	ISZ	T2		/ T2 => OFFSET OF 1 BEYOND 1ST CHAR.

/ THE ONLY OTHER ALLOWABLE SPECIAL CHAR. IS THE % SIGN (AS THE
/ LAST INPUT CHAR. ONLY).  IF PRESENT, POSITION TO A BLOCK, ELSE
/ POSITION TO A PAGE
PAGBLK,	TAD	GETLEN		/ # OF ACTUAL CHARS. IN BUFFER
	TAD	(EIRPG2)	/ PLUS THE ADDR. OF INPUT BUFFER-1
	DCA	T3		/ T3 => PTR. TO LAST CHAR. IN EIRPG2
	TAD I	T3		/ GET THE LAST CHAR. FROM THE INPUT BUFFER
	TAD	(-60)		/ COMPARE TO ASCII 0
	SPA			/ SKIP IF = OR > 0
	JMP	RPERCH		/ EXIT: INVALID CHAR.
	TAD	(-11)		/ COMPARE REMAINDER TO 9
	SMA SZA CLA		/ SKIP IF CHAR. 0-9
	JMP	RPERCH		/ EXIT:INVALID CHAR.

	TAD	(PGMODE)	/ BIT2 ON FOR PAGE MODE
	TAD	RPWORD		/ INCLUDE IN POSITION FLAGS' WORD
	DCA	RPWORD		/ UPDATE MEMORY

	TAD	T2		/ AC=> OFFSET BEYOND +/- IF PRESENT
	TAD	(EIRPG2)	/ + ADDR. OF 1ST INPUT CHAR.-1
	DCA	X0		/ INIT. AUTO-INDEX REG. TO POINT AT
				/ FIRST NUMERIC CHAR.
	TAD	T1		/ -1 FOR +/- AND -1 FOR %
	TAD	GETLEN		/ GET  # OF INPUT CHARS.
	TAD	(-3)		/ SEE IF MORE THAN 3 NORMAL CHARS.
	SMA SZA			/ SKIP WITH 1-3 CHARS. ONLY
	JMP	DOTHOU		/ > 3 = THOUSANDS AND HUNDREDS
	TAD	(3)		/ GET ORIG. RANGE VALUE
	CIA			/ MAKE INTO NEG. CHAR. CTR.
	DCA	T3		/ T3 => # OF HUNDREDS CHARS TO MOVE
	JMP	DOHUNS		/ CLEAR THOUS. COUNT AND DO HUNDR.
DOTHOU,	CLA			/ AC => 0
	TAD I	X0		/ GET THE THOUS. DIGIT
	DCA	EIRPG3		/ SUPPLY IT FOR CONVERSION		/A206
	DCA	EIRPG3+1	/ ASCIZ TERMINATOR...			/A206

/D206	DCA	TMP		/ SUPPLY IT FOR CONVERSION
/D206	DCA	TMP+1		/ ASCIZ TERMINATOR...

/  If  current string char. is a comma bump string pointer (X0)
/      beyond it to point at hundreds and account for the
/      presence of a special char. in string range (-1)
/    else string pointer (X0) is at hundreds and don't have to
/         account for the presence of a special char.
/  if  total # of input chars. (GETLEN) less the presence of any
/      special chars. (T1&AC) is greater than 4
/		then exit to report 'RANGE' error
/    else  convert ASCII chars. (EIRPG2) to binary


	TAD	X0		/ POINTS AT CURRENT CHAR.
	DCA	T2		/ MAKE A COPY, LEAVING X0 ALONE
	ISZ	T2		/ PERFORM AUTO-INDEX TO...
	TAD I	T2		/ GET THE CHAR. AFTER THE THOU.
	TAD	(-RPCMMA)	/ IS IT A COMMA?
	SZA CLA			/ SKIP TO ACCOUNT FOR COMMA
	JMP	CKRANG		/ PROCESS AS IS...
	ISZ	X0		/ BUMP PTR. TO HUNDREDS CHAR.
	AC7777			/ AC => -1 TO ACCOUNT FOR COMMA
				/ VALIDATE THE # OF DIGITS IN STRING
CKRANG,	TAD	GETLEN		/ GETLIN SUPPLIED # OF INPUT CHARS.
	TAD	T1		/ MINUS 1 FOR +/- AND -1 FOR %
	TAD	(-4)		/ - MAX. # OF NUMERICS ALLOWED (9999)
	SMA SZA CLA		/ SKIP WITH VALID RANGE
	JMP	RPERRG		/ ERROR:INVALID # OF NUMERICS SUPPLIED
				/ BY THE USER
	AC7775			/ AC => -3
	DCA	T3		/ T3 => MOVE 3 CHARS. AFTER THOUS. MOVED
	JMP	TOMNU		/ PAGE JUMP...

RPERRG,	OVLJMP;RPPER3		/ ERROR:MORE THAN 4 NUMERICS SUPPLIED

RPERCH,	CLA
	OVLJMP;RPPER5		/ ERROR:CHAR. WASN'T A VALID NUMERIC
				/ OR ONE OF THE ALLOWABLE SPECIAL
				/ CHARS. (+,-,% OR ,)

EIRPP2,	HLT / CODE NOT USED ?	CLA 	/ AC MUST BE 0 TO INFORM OVEXIT THAT
				/ THIS IS NOT THE FINAL END OF THIS EDIT


/?	JMP	RPTOP		/ GO CLOSE DOC.
				/ THEN RE-OPEN IT, THEREBY SUPPLYING
				/ THE MAIN HDR. BLOCK AND ITS NEW
				/ PARELLEL RAPID PAGE DATA STRUCTURE
				/ IN THEIR RESPECTIVE SCROLL BUFFERS

EIRPG2,	-6			/ 6 CHAR. MAX. INPUT RANGE (+9,999)
	ZBLOCK	6		/ START OF 6 CHAR. INPUT BUFFER

EIRPG3,	ZBLOCK	6		/ START OF 6 CHAR. WORK BUFFER		/A206

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

TOMNU,	CIFMNU			/ CHANGE FOR MENU FLD
	JMS I	CVDCAL		/ ASCIZ TO BINARY VIA CVDBN
	EIRPG3			/ GET ASCIZ CHARS. HERE			/A206
/D206	TMP			/ GET ASCIZ CHARS. HERE

	JMP	RPERCH		/ CHAR. WASN'T 0-9
DOHUNS,	DCA	RPBIN2		/ UPDATE BINARY # OF THOUSANDS
	TAD	(EIRPG3-1)						/A206
/D206	TAD	(TMP-1)
	DCA	X1		/ X1 => MOVE TO THIS BUFFER
	TAD I	X0		/ GET INPUT CHAR.
	DCA I	X1		/ MOVE INTO TEMP. BUFFER
	ISZ	T3		/ T3 => # OF CHARS. TO MOVE
	JMP	.-3		/ LOOP IF MORE TO MOVE
	DCA I	X1		/ SUPPLY ASCIZ DELIMTER
	CIFMNU			/ CHANGE TO MENU FLD
	JMS I	CVDCAL		/ ASCIZ TO BINARY VIA CVDBN
	EIRPG3			/ GET ASCIZ CHARS. HERE			/A206
/D206	TMP			/ GET ASCIZ CHARS. HERE
	JMP	RPERCH		/ CHAR. WASN'T 0-9
	DCA	RPBIN1		/ UPDATE BINARY # OF HUNDREDS

/ initialize GOTO PAGE pointers

	TAD	(55)
	DCA	RPCUOF		/ OFFSET TO 1ST DESCRIPTOR WORD IN 1ST RPPGDS BLOCK ONLY
	TAD	(55)
	DCA	RPMTRL		/ OFFSET TO DEFAULT RULER BLOCK
	DCA	RPMTBK		/ NO MATH BLOCK OFFSET
	DCA	RPPG0		/ 0 = NOT OVER --TOP--
	AC0001
	DCA	RPCUBK		/ START WITH 1ST RPPGDS BLOCK
	AC0001
	DCA	RPRLHN		/ DEFAULT RULER BLOCK IS IN 1ST RPPGDS BLOCK


/ RaPid POSItioning

/ HERE TO BEGIN THE ACTUAL REPOSITIONING TO THAT PAGE OR BLOCK
/ SPECIFIED BY USER INPUT.

/ RPPOSI PSEUDO CODE:

/  if  RPWORD = "absolute" positioning go test block or page
/    else if RPWORD = "forward" direction leave RPBIN1 and RPBIN2
/            as is
/           else convert the positive binary page value in RPBIN1
/                and RPBIN2 into negative values (-)

/ DETERMINE WHAT THE PAGE NUMBER VALUE SUPPLIED BY THE USER WAS.
/ IF IT WAS AN ABOSULTE NUMBER, THEN RPBIN1 AND RPBIN2 CAN
/ REMAIN AS IS; OTHERWISE, THE OFFSET VALUE STORED WITHIN
/ RPBIN1 AND RPBIN2 MUST BE CONVERTED TO AN ABSOLUTE BLOCK
/ NUMBER OR PAGE NUMBER.  HOWEVER, THE DISTINCTION BETWEEN PAGE
/ AND BLOCK POSITIONING MUST BE MADE PRIOR TO THIS CONVERSION,
/ SO THAT BLOCK CALCULATION DOES NOT USE CURPG1 AN CURPG2


				/ START THE ACTUAL REPOSITIONING...
	TAD	RPWORD		/ GET POSITIONING FLAGS
	AND	(REVERS)	/ TEST REVERSE (-) OFFSET FLAG
	SNA CLA			/ SKIP TO COMPLEMENT OFFSET
	JMP	CKMODE		/ NOT - SO CHECK MODE TYPE
	TAD	RPBIN2		/ GET # OF THOUSANDS SUPPLIED
	CIA			/ MAKE NEGITIVE TO BACKUP
	DCA	RPBIN2		/ SAVE -THOUSANDS #
	TAD	RPBIN1		/ GET # OF HUNDREDS SUPPLIED
	CIA			/ MAKE NEGITIVE TO BACKUP
	DCA	RPBIN1		/ SAVE -HUNDREDS #

/ DETERMINE IF REPOSITIONING TO A PAGE OR BLOCK TO CONTINUE
/ OFFSET CONVERSION, IF NECESSARY...

/ If  RPWORD = "offset" calculate absolute page #
/		if RPWORD = positive offset set CURPTR direction
/			offset (T1) to +1
/		   else set CURPTR direction offset (T1) to -1
/    else set CURPTR direction offset (T1) to +1

CKMODE,	TAD	RPWORD		/ POSITION FLAGS
	SPA CLA			/ SKIP TO PROCESS OFFSET
	JMP	FORDIR		/ JMP TO SET CURPTR OFFSET +1

	AC7777			/ GOTO PAGE "REQ" FLAG
	CDILP			/ DF & IF TO FIELD 5
	JMS	RPPMENU		/ GET CURRENT EDIT BUFFER PAGE VALUE
				/ INTO CURPG1 & CURPG2

	TAD	CURPG2		/ CURRENT THOUS. PAGE #
	TAD	RPBIN2		/ + OFFSET = DESIRED THOUSANDS #
	DCA	RPBIN2		/ ABSOLUTE THOUSANDS PAGE #
	TAD	CURPG1		/ CURRENT HUNDREDS PAGE #
	TAD	RPBIN1		/ + OFFSET = DESIRED HUNDREDS #
	DCA	RPBIN1		/ ABSOLUTE HUNDREDS PAGE #
FORDIR,	DCA	RPBOTF		/ RPBOTF = 0 => DOING V2 GOTO PAGE, NOT V2 GOLD BOTTOM

	AC7777
	TAD	RPBIN1		/ FORCE TO TOP OF DESIRED PAGE
	SMA			/ SKIP IF TOP-OF-PAGE NOT AVAILABLE
	JMP	FORDR		/ TOP-OF-PAGE AVAILABLE
	DCA	RPPG0		/ RESULT INTO --TOP-- FLAG
	TAD	RPBIN2		/ CHECK FOR THOUSANDS
	SNA			/ SKIP IF THOUSANDS
	JMP	FORDR		/ NO THOUSANDS
	TAD	(-1)		/ DECREMENT BY ONE
	DCA	RPBIN2		/ AND SAVE AS NEW THOUSANDS COUNT
	TAD	(1747)		/ PAGE 1000 OR 2000 OR 3000 WAS DESIRED
				/ SO SET RPBIN1 TO 999 AND DECREMENT
				/ RPBIN2 BY ONE
	TAD	RPBIN1		/ ADDED TO CURRENT HUNDREDS
FORDR,	DCA	RPBIN1		/ RPBIN1 = DESIRED PAGE NUMBER

	AC4000			/ MINUS FLAG FOR GOTO PAGE INIT.
	TAD	RPBIN1		/ USE AVAIL. MEMORY WORD
	DCA	RPBIN1		/ DON'T DISPLAY FILE INFO. AT OPEN TIME...
	DCA	CURPG1		/ CLEAR PAGE MARK COUNTER

	TAD	RPPG0		/ GET --TOP-- FLAG
	SNA			/ SKIP IF AT --TOP-- OF DOC
	JMP	OVL2		/ JUMP IF NOT APPLICABLE

	TAD	(1)		/ FOR INCR. OF --TOP-- FLAG
	SZA CLA			/ SKIP IF REALLY AT --TOP--
	JMP	OVL2		/ JUMP IF BEYOND --TOP--

	TAD	RPWORD		/ WHAT TYPE OF POSITION REQ.?
	AND	(2000)		/ WAS IT RELATIVE POSITIONING?
	SZA CLA			/ SKIP IF ERROR W/ ABSOLUTE PAGE0
	DCA	RPPG0		/ CLEAR --TOP--FLAG
				/ RPPG0 = + IF OK
				/ RPPG0 = - IF ERROR
OVL2,	OVLJMP;	OVPAGE		/ show "REPOSITIONING TO..."  message...

/ tell the user to standby while the doc. is closed (updating
/  descriptor words) and then re-opened (supplies the doc. header
/  block and the RPPGDS block in their repective buffers)


	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

/***************************************************************************
/****			   START OF OVERLAY				****
/***************************************************************************

	OVRNUM=OVRNUM+200
	OVRBLK=OVRNUM%200+DLOEDO-1 / DISK BLOCK WHERE OVERLAY IS LOADED

	RELOC
	RELOC OVLAY1
	OVRNUM


/ GOLD:SEARCH GOLD:RULER COMMAND  (GOTO-RULER)

	OVGSGR=	.-OVLAY1+OVRNUM

/ PROMPT FOR "ADVANCE" OR "BACKUP"

	JMS	PROMPT		/ CLEAR SCROLL LINE THEN DISPLAY PROMPT
	 EIRRAB			/   PTR TO "Press ADVANCE or BACK UP"

/ WAIT UNTIL USER TYPES "ADVANCE" OR "BACKUP",
/ AND SET RRDIR ACCORDINGLY

RRPRLP,	GETINP			/ GET KEYBOARD CHAR

	ZZCASE			/ DISPATCH ADVANCE,BACKUP
	RRDISP-1
	JMS	BEEPER		/ NEITHER ADVANCE NOR BACKUP - ERROR
	JMP	RRPRLP		/ TRY AGAIN

/ USER TYPED "ADVANCE" KEY

RRPRAD,	AC0001			/ SET RRDIR:=1 TO INDICATE ADVANCE
	SKP

/ USER TYPED "BACKUP" KEY

RRPRBK,	AC7777			/ SET RRDIR:=-1 TO INDICATE BACKUP
	DCA	RRDIR
	JMS	FXSCRL		/ GET RID OF PROMPT
				/ (REPLACE PROMPT LINE WITH DOCMT TEXT)

/ START GOTO-RULER PROCESSING

	OVRRGO=	.-OVLAY1+OVRNUM
	JMP	XVRRGO


/ DISPATCH TABLE FOR GOLD:SEARCH GOLD:RULER PROMPT
RRDISP,	EDADVN;	RRPRAD		/      ADVANCE
	EDGADV;	RRPRAD		/ GOLD:ADVANCE
	EDBKUP;	RRPRBK		/      BACKUP
	EDGBKP;	RRPRBK		/ GOLD:BACKUP
	EDNWLN;	RRABOR		/      RETURN  (ABORT GOTO-RULER)
	0

/ SUBR RRGETN -- MOVE CURSOR IN TEXT BUFFER,				/M157
/   EXHAUSTING ETX (STX) BUFFER,
/   BUT STOP WHEN DISK ACTIVITY OCCURS.
/   AC DETERMINES DIRECTION
/   RROROF MUST BE SET UP WITH OFFSET OF ORIGINAL ETX (STX) BLOCK.
/
/ CALL:
/	/ DF = DOESN'T MATTER
/	TAD	RRDIR		/ AC=DIRECTION TO MOVE: +=>FORWARD, -=>BACKWARD
/	JMS	RRGETN		/ GET NEXT (OR LAST) CHARACTER
/	 JMP	ETXSTX		/ REACHED ETX (OR STX), AC=0
/	 JMP	ETBSTB		/ NO MORE CHARS AVAILABLE WITHOUT DISK INPUT
/				/ (ACTUALLY, THE NEXT DOCUMENT BLOCK HAS BEEN
/				/  READ INTO THE ETX (OR STX) BUFFER,
/				/  BUT LITTLE OF ITS DATA HAS BEEN USED YET/M157
/	...			/ MOVED CURSOR 1 POSITION.		/M157
/				/ MAY HAVE MOVED CHAR FROM ETX (OR STX)
/				/ BUFFER TO TEXT BUFFER,
/				/ BUT DID NO DISK I/O.
/	/ ON ALL RETURNS, DF = CDFMYF, AC=0				/M157
/

RRGETN,	XX
	CDFMYF			/ MAKE SURE WERE LOOKING AT OUR FIELD	/A199
	TAD	RRDIR		/ AC=DIRECTION OF NEXT CHAR		/A199
	SMA			/ MOVE FORWARD OR BACKWARD?
	 JMP	RRGEFW		/ FORWARD

/ MOVING BACKWARD

	CURMOV
	 JMP	RRGEX1		/ REACHED STX: TAKE 1ST RETURN
	JMS	RRGTTP		/ GET CURRENT SCTOP,SCTPH INTO AC,MQ

/ CHECK WHETHER ANOTHER DOCUMENT BLOCK WAS READ INTO
/ THE ETX (OR STX) BUFFER.
/ ASSUME AC = OFFSET OF CURRENT ETX (STX) BLOCK.

RRGETS,	CIA			/ DID ANY DISK INPUT OCCUR?
	CDFMYF
	TAD	RROROF		/ (COMPARE OFFSETS INTO HDR BLK)
	SNA CLA			/ (SKIP IF THERE WAS DISK INPUT)
	 ISZ	RRGETN		/ NO: TAKE 3RD (NORMAL) RETURN
RRGEX2,	ISZ	RRGETN
RRGEX1,	JMP I	RRGETN

/ MOVING FORWARD

RRGEFW,	CURMOV
	 JMP	RRGEX1		/ REACHED ETX: TAKE 1ST RETURN
	TAD	(-5)		/ AC=FUNCT # TO READ SCBOT,SCBTH
	JMS	DSKCAL		/ GET AC=CURRENT SCBOT
	XRPRD			/   (&MQ=CURRENT SCBTH, NOT NEEDED)
	JMP	RRGETS		/ GO CHECK FOR DISK I/O

/ SUBR RRGTTP -- Rapid Ruler GeT ToP ptrs sctop,sctph
/
/ RETURNS WPFILS VARIABLES SCTOP,SCTPH IN AC,MQ.
/
/ CALL:
/	/ AC = DOESN'T MATTER
/	/ DF = DOESN'T MATTER
/	JMS	RRGTTP		/ GET SCTOP,SCTPH IN AC,MQ
/	/ AC = SCTOP FROM WPFILS
/	/ MQ = SCTPH FROM WPFILS
/	/ DF = CDFMYF
/
/ TEMPS USED:
/	CURID,CURTOP(=CURID+1)
/
/ DUE TO THE CLUMSINESS OF THE AVAILABLE WPFILS CALLS,
/ A RATHER ROUNDABOUT APPROACH MUST BE USED TO GET
/ THE TOP POINTERS.

RRGTTP,	XX
	AC7777
	TAD	(CURID)		/ MQ=PTR TO LOCS TO RETURN CURRENT SCTOP,SCTPH
	MQL			/   (CURID IS USED AS A TEMP)
	AC7775			/ WPFILS-GET ORIG & CUR SCTOP,SCTPH
	JMS	DSKCAL
	XRPRD			/ (MISC GOTO-PAGE FUNCTIONS)
	CLA			/ FORGET "ORIGINAL" SCTOP
	CDFLP
	TAD I	(CURID)		/ GET CURRENT SCTPH FROM WPFILS
	MQL			/ RETURN SCTPH IN MQ
	TAD I	(CURTOP)	/ RETURN CURRENT SCTOP FROM WPFILS IN AC
	CDFMYF
	JMP I	RRGTTP		/ EXIT

/ SUBR RRRFSP -- Rapid Ruler Restore File System Pointers
/
/ (CREATED TO SAVE A LITTLE SPACE ON CALLING PAGE)

RRRFSP,	XX
	TAD	(-4)
	JMS	DSKCAL
	XRPRD
	JMP I	RRRFSP

/ SUBR RRSVBK --
/ PREPARE TO USE RANDOM-ACCESS TO JUMP TO RULER,
/ USING BLOCK POINTERS (SCTOP,SCTPH).
/ (CREATED TO SAVE SPACE ON CALLING PAGE.)

/ RPCUOF := EXTRA OVERSHOOT CORRECTION IF NO RULER FOUND;		/A157

RRSVBK,	XX
	CDFMYF								/A157
	CIA			/ REVERSE DIRECTION TO CANCEL OVERSHOOT	/A157
	DCA	RPCUOF		/ SAVE 'HIT ETX OR STX' FLAG		/A157

/ (SCTOP,SCTPH HAVE OVERSHOT RULER BY AT LEAST ONE BLOCK -
/  CORRECT OVERSHOOT)
/ IF ADVANCING TO RULER, THEN
/	DECREMENT SCTOP,SCTPH BY 1 BLOCK;
/ IF BACKING UP TO RULER, THEN
/	(LATER ON WE WILL WANT TO OPEN BLOCK *AFTER* THE
/	 BLOCK THAT CONTAINS THE RULER, THEN BACKUP TO RULER,
/	 SO ADVANCE AN EXTRA BLOCK)
/	INCREMENT SCTOP,SCTPH BY 2 BLOCKS;
/ INCREMENT SCTOP,SCTPH BY RPCUOF;					/A157

	TAD	RRDIR		/ ADVANCING OR BACKING UP TO RULER?
	SMA CLA
	AC7775			/ ADVANCING:  DECREMENT 1 BLOCK
	TAD	(2)		/ BACKING UP: INCREMENT 2 BLOCKS
	TAD	RPCUOF		/ CORRECT EXTRA OVERSHOOT IF REACHED	/A157
				/   ETX OR STX				/A157
	MQL			/ MQ = BLOCK INCREMENT TO CORRECT OVERSHOOT
	TAD	(-6)		/ READ DESC WORD, INC SCTOP,SCTPH BY MQ
	JMS	DSKCAL
	XRPRD

/ CONVERT SCTOP,SCTPH TO A PHYSICAL BLOCK #.				/A157

	JMS	RRGTTP		/ GET SCTTOP IN AC			/A157
	TAD	(HDRBUF+2)	/ + ADDR OF DOCMT HEADER BUFFER		/A157
				/ + SKIP OVER COS COMPATABILY WORDS	/A157
	DCA	T1		/ SAVE PTR TO CORRESPONDING PHYS BLK #	/A157
	CDFBUF			/ FIELD OF DOCUMENT HEADER BUFFER	/A157
	TAD I	T1		/ GET PHYSICAL BLOCK #			/A157

/ SAVE PHYSICAL BLOCK # OF BLOCK WITH RULER				/A157
/ (OR OF LAST BLOCK DEFINED IN GOTO-PAGE STRUCTURE) INTO RPCUBK,	/A157
/ TO BE USED MUCH LATER AFTER DOCUMENT HAS BEEN CLOSED (FILED OUT)	/A157
/ AND THE REOPENED.							/A157
/ NOTE: THE PHYSICAL BLOCK # IS SAVED BECAUSE SCTOP,SCTPH ARE		/A157
/ RELATIVE BLOCK #S.  THE ACTUAL BLOCK REFERED TO BY SCTOP,SCTPH	/A157
/ MAY BE PUSHED DOWN OR UP WHEN THE DOCUMENT IS FILED,			/A157
/ RENDERING SCTOP,SCTPH INVALID, BUT THE PHYSICAL BLOCK #		/A157
/ WILL NOT CHANGE.							/A157

	CDFMYF								/A157
	DCA	RPCUBK							/A157
	JMS	RRRFSP		/ RESTORE FILE SYSTEM POINTERS
	JMP I	RRSVBK		/ EXIT

/ CHECK BUFFER FOR ACTUAL RULER CODE.  THE ABOVE CODE FOR RULER CHECK	/A199
/ FAILS WHEN THE BUFFER IS FULL AND ESPECIALLY WHEN CURMOVING BACKWARD	/A199

	RRSAVE=	RRRFSP		/ DEFINE TEMPORARY STORAGE LOCATION	/A199

RRCBUF,	XX			/ CHECK BUFFER FOR RULER CODE		/A199
	TAD	CURPTR		/ GET THE CURRENT CURSOR POSITION	/A199
	DCA	RRSAVE		/ SAVE FOR LATER RESTORE		/A199

RRCHK1,	CDFMYF			/ SWITCH BACK TO THIS FIELD		/A199
	TAD	RRDIR		/ GET THE DIRECTION VALUE		/A199
	CHKPTR			/ MOVE AND CHECK THE POINTER		/A199
	SNA			/ CHECK FOR A NULL CHARACTER		/A199
	JMP	RRCHK1		/ YES, IGNORE THE NULL			/A199

	SPA			/ CHECK FOR A END OF BUFFER INDICATOR	/A199
	JMP	RRCHK2		/ YES, GO HANDLE END OF BUFFER		/A199

	TAD	(-ECNDRL)	/ CHECK FOR A END OF RULER CODE		/A199
	SZA			/ SKIP IF SO				/A199
	IAC			/ CHECK FOR A START OF RULER CODE	/A199
	SZA CLA			/ SKIP IF SO				/A199
	JMP	RRCHK1		/ NO MATCH, GO CHECK NEXT CHARACTER	/A199

	ISZ	RRCBUF		/ BUMP RETURN ADDRESS FOR FOUND RULER	/A199
RRCHK2,	CLA			/ CLEAN UP FROM END OF BUFFER CHECK	/A199
	TAD	RRSAVE		/ PICK UP ORIGINAL CURSOR POSITION	/A199
	DCA	CURPTR		/ RESTORE CURSOR POINTER		/A199
	JMP I	RRCBUF		/RETURN TO CALLER			/A199


	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

/*******************************************************************
/
/	START GOTO-RULER PROCESSING
/
/
/ COME HERE TO GOTO THE NEXT (OR PREVIOUS) RULER.
/
/ 'RRDIR' MUST BE SET TO INDICATE DIRECTION:
/	RRDIR=+1 => ADVANCE TO NEXT RULER;
/	RRDIR=-1 => BACKUP TO PREVIOUS RULER.
/
/*******************************************************************
/
/
/
/ IF WE ARE ADVANCING TO NEXT RULER THEN
/     IF RULER MODIFIED FLAG IS SET THEN
/         SCROLL FORWARD TO RULER;
/         DONE.
/     ELSE (RULER MODIFIED FLAG IS NOT SET)
/         (PREPARE TO SCAN FORWARD THROUGH TEXT & STX BUFFERS)
/         GET CURRENT VALUE OF SCBOT FOR RRGETN;
/
XVRRGO,	DCA	ECHFLG		/ DON'T DISPLAY CURMOV'S
	CDFMYF			/ MAKE SURE WE ARE IN THIS FIELD

	TAD	RRDIR		/ ARE WE ADVANCING?
	SPA CLA
	 JMP	RRBK		/ NO: MUST BE BACKING UP

	TAD	RLRMOD		/ YES: IS THE RULER MODIFIED FLAG SET?
	SZA CLA
	 JMP	RRSC		/ YES AND YES: GO SCROLL TO RULER

	TAD	(-5)		/ NO: GET SCBOT IN AC FOR RRGETN
	JMS	DSKCAL
	 XRPRD
	JMP	RRSNEB		/ GO SCAN TEXT&ETX(STX) BUFFERS FOR RULER
/
/ IF MOVING BACKWARDS, THEN
/	(WE MAY BE AT A RULER NOW.  WE DON'T WANT TO FIND THIS
/	 CURRENT RULER AS THE PREVIOUS RULER, SO WE MOVE THE CURSOR
/	 BACK 1 CHAR.  THE BACKUP IS HARMLESS IF THERE WAS NO
/	 RULER PRESENT.)
/	MOVE CURSOR TO START OF LINE;
/	BACKUP CURSOR 1 CHAR;  (TO SKIP OVER CURRENT RULER IF ANY)
/	GET SCTOP FOR RRGETN.
/
	/ THE CONVENTION IS THAT CURSOR IS "AT" A RULER IF CURSOR
	/ IS ANYWHERE ON LINE FOLLOWING RULER.
RRBK,	TAD	LINE23		/ MOVE CURSOR TO START OF LINE		/M157
	DCA	CURPTR
	DCA	CURSOR

	AC7777			/ BACKUP 1 CHAR
	CURMOV			/ SKIP OVER CURRENT RULER IF ANY
	 JMP	RRERRB		/   REACHED STX: NO PREVIOUS RULER
	JMS	RRGTTP		/ GET SCTOP IN AC FOR RRGETN
/
/ SCAN FORWARD (OR BACKWARD) THROUGH EDIT BUFFER SEARCHING FOR A RULER.
/ CONTINUE SCAN UNTIL ETX (OR STX) BUFFER IS EXHAUSTED.
/
RRSNEB,	DCA	RROROF		/ SAVE OFFSET OF ORIGINAL ETX(STX) BLOCK
	MQA
	DCA	RRORID		/ SAVE HDR BLK ID # OF ORIGINAL BLOCK

/ CLEAR ENTRY POINT OF SUBR SETRUL, WHICH IS USED DURING RULER PROCESSING.
/ SETRUL'S ENTRY POINT IS USED HERE AS A FLAG
/ WHICH TELLS US WHEN CURMOV HAS ENCOUNTERED A RULER.

	CDFMYF
	DCA	SETRUL

RRSNEL,
/D214	CDFSYS			/ CHECK FOR PENDING GOLD:HALT
/D214	TAD I	HLTFLG		/ WITHOUT UPDATING STATUS LINE (FOR SPEED)
/D199	CDFMYF
/D214	SZA CLA			/ SKIP IF NO GOLD:HALT
/D214	 JMP	RRABOR		/ GOLD:HALT: ABORT GOTO-RULER

/D199	TAD	RRDIR		/ AC=DIRECTION OF NEXT CHAR
	JMS	RRGETN		/ MOVE CURRSOR TO NEXT CHAR
	 JMP	RRERRT		/   ETX (OR STX) - NO NEXT RULER
	 JMP	RR3X		/   END OF EDIT & ETX (STX) BUFFERS	/C199

	TAD	SETRUL		/ HAS CURSOR PASSED OVER A RULER?
	SNA CLA
	 JMP	RRSNEL		/ NO: CONTINUE SCAN FOR RULER
	JMP	RRSCDN		/ YES: FOUND DESTINATION RULER

/ CHECK REAL BUFFER FOR RULER						/A199

RR3X,	TAD	SETRUL		/ HAS CURSOR PASSED OVER A RULER?	/A199
	SZA CLA								/A199
	JMP	RRSCDN		/ YES: FOUND DESTINATION RULER		/A199
	JMS	RRCBUF		/ NO: GO CHECK BUFFER FOR RULER CODE	/A199
	JMP	RR3		/ REAL END OF BUFFER, CHECK STRUCTURE	/A199
	JMP	RRSCLP		/ JUMP INTO RRSC CODE BELOW		/A199

/ SCROLL FORWARD (OR BACKWARD) TO NEXT RULER

RRSC,	AC0001			/ ECHO TEXT WE SCROLL OVER
	DCA	ECHFLG

/ MOVE FORWARD OR BACKWARD TO START OF NEXT RULER

RRSCLP,	CDFMYF			/ SETRUL'S ENTRY POINT IS USED AS A FLAG /A199
	DCA	SETRUL		/ INDICATES CURMOV HAS CROSSED A RULER.	 /A199

	TAD	RRDIR		/ PICK UP DIRECTION TO MOVE
	CURMOV			/ MOVE FORWARD OR BACKWARD
	 JMP	RRERRT		/   ETX OR STX

/D214	TAD	ECHFLG		/ ARE WE ECHOING CURMOV'S?
/D214	SZA CLA
/D214	 HLTTST			/ YES: UPDATE STATUS LINE
/D214	 NOP			/   IGNORE HLTTST RESULT
/D214	CDFSYS			/ CHECK FOR PENDING GOLD:HALT
/D214	TAD I	HLTFLG		/ WITHOUT UPDATING STATUS LINE(FOR SPEED)
/D214	SZA CLA			/ SKIP IF NO GOLD:HALT REQUEST
/D214	 JMP	RRABOR		/ GOLD:HALT: ABORT GOTO-RULER

	TAD	ECHFLG		/ GET THE ECHO FLAG			/C214
	SNA CLA			/ ARE WE ECHOING CURMOV'S?		/C214
	JMP	RRSC2		/ NO, SKIP THE HALT TEST		/C214
	HLTTST			/ YES: UPDATE STATUS LINE & CHECK FLAG	/C214
	 JMP	RRABOR		/ GOLD:HALT: ABORT GOTO-RULER		/C214

RRSC2,	CDFMYF			/ DID CURMOV PASS OVER A RULER?
	TAD	SETRUL
	SNA CLA			/ (CURMOV CALLS SETRUL TO PROCESS A RULER)
	 JMP	RRSCLP		/ NO: KEEP LOOKING FOR RULER

/ FOUND RULER.  LEAVE CURSOR JUST AFTER RULER.

RRSCDN,	TAD	RRDIR		/ WERE WE ADVANCING OR BACKING UP?
	SPA CLA			/ ADVANCING: DON'T MOVE CURSOR
	 AC0001			/ BACKING UP: ADVANCE CURSOR TO AFTER RULER
	CURMOV
	 NOP			/   IMPOSSIBLE

/ GOTO-RULER IS DONE! (SUCCESS)

	JMP	EIFIX		/ GO LISTEN FOR NEXT EDITOR CMD


/ NEXT RULER IS NOT IN TEXT BUFFER OR ORIGINAL ETX (OR STX) BUFFER,
/ THEREFORE WE MUST USE GOTO-PAGE STRUCTURE TO FIND NEXT RULER.
/
/ FIRST, SAVE WPFILS' FILE SYSTEM POINTERS, BECAUSE
/ READING SUCCESSIVE GOTO-PAGE DESCRIPTOR WORDS MODIFIES THE
/ FILE SYSTEM POINTERS, AND AFTER SCANNING DESC WORDS FOR A RULER,
/ WE NEED A WAY TO RETURN TO OUR STARTING POINT IN THE DOCUMENT.
/ WARNING: DO NOT PERFORM ANY CURMOV, ADVCHR, ETC. THAT INVOLVES
/ DISK SCROLLING AFTER MODIFYING THE FILE SYSTEM POINTERS,
/ OR ELSE THE DOCUMENT WILL BE CORRUPTED!

RR3,	AC7776			/ AC=-2 => SAVE FILE SYSTEM POINTERS
	JMS	DSKCAL
	 XRPRD
	CLA			/ FORGET # OF PAGES IN STX BUFFER

/ SET UP SCTOP,SCTPH TO ACCESS THE GOTO-PAGE DESCRIPTOR WORD
/ FOR THE BLOCK CURRENTLY LOADED IN THE ETX (OR STX) BUFFER

	TAD	RRORID		/ COPY RRORID ...
	MQL
	TAD	RROROF		/   ... AND RROROF ...
	JMS	DSKCAL		/   ... TO SCTPH AND SCTOP
	 XRSCTP

/ SCAN GOTO-PAGE STRUCTURE FORWARD (OR BACKWARD) UNTIL A BLOCK
/ CONTAINING A RULER IS FOUND.
/ KEEP TRACK OF THE # OF BLOCKS SKIPPED, SO WE CAN ESTIMATE
/ WHETHER IT'S FASTER TO SCROLL TO RULER OR JUMP TO IT.

	DCA	RRBLCT		/ CLEAR # OF BLOCKS SKIPPED OVER

/ SCANNING FORWARD (BACKWARD):						/A157
/ START AT ORIGINAL SCTOP,SCTPH (SCBOT,SCBTH) DESCRIPTOR WORD, AND	/A157
/ INCREMENT (DECREMENT) UNTIL ETX (STX) OR RULER FOUND.			/A157

RRDW,
/D214	CDFSYS								/A157
/D214	TAD I	HLTFLG		/ DID USER TYPE GOLD:HALT?		/A157
/D214	SZA CLA								/A157
/D214	 JMP	RRHLT		/ YES: STOP WHERE YOU ARE		/A157
	CDFMYF								/A157
	TAD	RRDIR		/ GET DIRECTION TO SCAN			/A157
	MQL			/ SET INCREMENT OR DECREMENT		/A157
	TAD	(-6)		/ READ G-T-P DESC WORD, INC		/A157
	JMS	DSKCAL		/   (AC=DESC WORD, -1==ETX OR STX)	/A157
	 XRPRD								/A157
	CMA			/ REACHED ETX OR STX?			/A157
	SNA								/A157
	 JMP	RRFNDE		/ YES-NO NEXT RULER, OR GTP STRUCT	/A157
				/   INCOMPLETE				/A157
	ISZ	RRBLCT		/ NO: COUNT # OF BLOCKS SCANNED		/A157
RRAER2,	IFNZRO RPRULR-4000 < ? >/ PREFIX FILE CHANGED			/A157
	SPA CLA			/ DOES CURRENT BLK CONTAIN A RULER?	/A157
	 JMP	RRDW		/ NO: CONTINUE LOOKING FOR A RULER	/A157
	JMP	RRFND		/ YES-FOUND DESTINATION RULER		/A157

/ REACHED ETX OR STX WHILE SCANNING TEXT & ETX (STX) BUFFERS FOR RULER
/ OR WHILE SCROLLING TO RULER --
/ ERROR (BEEP) IF HAVEN'T FOUND RULER YET;
/ LEAVE CURSOR AT BOTTOM (OR TOP) OF DOCUMENT.

RRERRT,	CDFMYF
	TAD	SETRUL		/ FOUND RULER JUST BEFORE ETX OR STX?
	SNA CLA			/ SKIP IF: YES				/M163
RRERRB,	 JMS	BUZZER		/ WARN USER, GET NEXT EDITOR COMMAND	/M163
	JMP	EIFIX		/ YES-NO ERROR: GET NEXT EDITOR CMD	/M163

/ USER TYPED GOLD:HALT

RRHLT,	JMS	RRRFSP		/ RESTORE FILE SYSTEM POINTERS
RRABOR,	JMP	EIFIX		/ GO LISTEN FOR NEXT EDITOR COMMAND


/ HIT ETX (OR STX IF CORRUPT GTP STRUCT) WHILE SCANNING GTP DESC WORDS.
/ EITHER THERE IS NO NEXT RULER, OR THE GTP STRUCTURE IS INCOMPLETE.
/ PREPARE TO OPEN AT LAST KNOWN BLOCK, THEN CURMOV TO RULER OR ETX.

RRFNDE,	CDFMYF
	TAD	RRDIR		/ AC=FLAG TO CORRECT OVERSHOOT AT ETX(STX)

/ RRFND: FOUND NEXT RULER USING GOTO-PAGE DESCRIPTOR WORDS.
/ PREPARE TO USE RANDOM-ACCESS TO JUMP TO RULER,
/ USING BLOCK POINTERS (SCTOP,SCTPH) SET BY SCAN LOOP ABOVE.
/ NO HARM DONE IF WE LATER DECIDE TO SCROLL INSTEAD.

RRFND,	JMS	RRSVBK

/ ESTIMATE WHETHER RULER IS CLOSE ENOUGH TO SCROLL DIRECTLY TO IT,
/ OR IF IT WOULD BE FASTER TO USE GOTO-PAGE TECHNIQUES TO JUMP TO
/ RULER (RANDOM-ACCESS)

	TAD	RRBLCT		/ IS RULER WITHIN 20 BLOCKS?
	TAD	(-20)		/   (TO PULL A # OUT OF MY EAR)
	SPA SNA CLA
	JMP	RRSC2		/ YES: SCROLL TO THE RULER (NO ECHO)
				/ NO: JUMP TO THE RULER

/ NOW ENTER COMMON CODE FOR GOTO-RULER, GOTO-PAGE,
/ GOLD:BOTTOM, (GOLD:TOP?,) AND FILE-DOCUMENT (GOLD:F)
/
/ THE FOLLOWING FLAGS ARE VALID ONLY DURING AND IMMEDIATELY
/ FOLLOWING THIS COMMON CODE:
/
/ 'RRDIR' IS THE FLAG THAT DISTINGUISHES GOTO-RULER FROM
/   GOTO-PAGE AND GOLD:BOTTOM.
/ RRDIR=+1 == GOTO-RULER (ADVANCING)
/ RRDIR=-1 == GOTO-RULER (BACKING UP)
/ RRDIR=0  == GOTO-PAGE OR GOLD:BOTTOM (*NOT* GOLD-RULER)
/
/ 'RPBIN1' BIT 0 IS THE FLAG THAT DISTINGUISHES A
/   GOTO-PAGE, GOTO-RULER, OR GOLD:BOTTOM FROM A GOLD:F
/   (FILE DOCUMENT):
/ RPBIN1<0  == GOTO-PAGE, GOTO-RULER, OR GOLD:BOTTOM
/	       (INHIBITS CERTAIN SCREEN MESSAGES)
/ RPBIN1>=0 == FILE DOCUMENT
/ AT EXIT FROM OVINIT, RPBIN1 BIT 0 := 1, BITS 1-11 ARE UNCHANGED.
/
/ 'RPBOTF' IS A FLAG TO DISTINGUISH BETWEEN GOTO-PAGE & GOLD:BOTTOM
/ (NOT USED FOR GOTO-RULER):
/ RPBOTF>=0 == GOTO-PAGE
/ RPBOTF<0  == GOLD:BOTTOM
/
/
/ OUTLINE OF WHAT HAPPENS NEXT:
/
/ OVRRDS DISPLAYS A MESSAGE SIMILAR TO THE GOTO-PAGE MESSAGE,
/   AND SETS RPBIN1:=4000 SO COMMON CODE LEAVES SCREEN ALONE;
/ THE COMMON CODE CALLS 2 OVERLAYS AS SUBROUTINES:
/   OVEXIT:
/	FILES THE DOCUMENT;
/   OVINIT:
/	INITIALIZES THE EDITOR (INCLUDING THE EDIT BUFFER & WPFILS);
/	OPENS THE DOCUMENT AT THE TOP;
/ THE GOTO-RULER/GOTO-PAGE/GOLD:BOTTOM OVERLAY RUNS:
/   OVRRP2:
/	JUMP TO ORIGINAL GOTO-PAGE/GOLD:BOT OVERLAY (OVRPP2)
/	  IF NOT DOING GOTO-RULER;
/ 	OPEN THE DOCUMENT AT THE PHYSICAL BLOCK SPECIFIED BY RPCUBK;
/	CURMOV FORWARD OR BACKWARD TO THE NEXT RULER; AND
/	REPAINT THE SCREEN;
/	JUMP TO GET NEXT EDITOR COMMAND (DONE!).
/

	OVLJMP			/ GO DISPLAY GOTO-RULER SCREEN, ETC...
	OVRRDS

/ VARIABLES

RRBLCT,	.-.			/ BLOCK COUNT WHILE SCANNING DESCRIPTOR
				/ WORDS FOR NEXT RULER
				/ = # OF BLOCKS FROM ETB (OR STB) TO
				/   NEXT RULER.

/ OFFSET OF [[ORIGINAL BLOCK IN ETX (OR STX) BUFFER] + 1].
/ THIS VALUE IS COMPARED TO CURRENT SCBOT (OR SCTOP) TO TELL
/ WHEN A NEW BLOCK HAS BEEN READ (THEREFORE ALL OF THE OLD
/ BLOCK HAS BEEN COPIED INTO THE EDIT BUFFER).
/ ALSO USED WHEN SCANNING GOTO-PAGE DESC WORDS FOR A RULER.

RROROF,	.-.

/ HEADER ID # OF [[ORIGINAL BLOCK IN ETX (OR STX) BUFFER] + 1].

RRORID,	.-.

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

/***************************************************************************
/****			   START OF OVERLAY				****
/***************************************************************************

	OVRNUM=OVRNUM+200
	OVRBLK=OVRNUM%200+DLOEDO-1 / DISK BLOCK WHERE OVERLAY IS LOADED

	RELOC
	RELOC OVLAY1
	OVRNUM


	OVRPRL=	.-OVLAY1+OVRNUM
	CDILP			/ NO ROOM HERE
	JMP	RPERRE		/ GO FIX POINTERS FOR SCROLL AT EXIT TIME


/
/ CONTINUE NORMAL GOTO-PAGE OR GOLD:BOTTOM
/
	OVRPP2=	.-OVLAY1+OVRNUM
/									/A157
/ CLEAR CURRENT RULER (CURUL) FOR GOTO-PAGE AND GOLD:BOTTOM.		/A157
/ THIS IS USUALLY NOT NEEDED UNLESS DESTINATION PAGE IS IN FIRST BLOCK.	/A157
/ (OVINIT USED TO CLEAR CURUL, BUT NO LONGER DOES SO FOR GOTO-PAGE,	/A157
/ GOLD:BOTTOM, OR GOTO-RULER, FOR THE CONVENIENCE OF GOTO-RULER)	/A157
/									/A157
	JMS	CLRULR		/ CLEAR NWRUL				/A157
	JMS	COPRUL		/ COPY NWRUL TO CURUL (CLEAR CURUL)	/A157
	JMP	RP7777		/ SETUP


/ Enter here to continue V2 GOTO PAGE request.

/ The edit buffer has been flushed; thereby updating the RPPGDS
/   block descriptors and closing the document.

/ The document has been re-opened thereby loading the HEADER block
/   and the RPPGDS block into the appropriate scroll buffers.


/ *****************************************************************
/ ***								***

/ 'SRCDIR' HAS THE WORKING COPY OF THE RPPGDS DESCRIPTOR WORD
/ 'RPCUOF' HAS + OFFSET TO THE BLOCK CONTAINING THE DESIRED PAGE  (END LOAD)
/ 'RPMTRL' HAS + OFFSET TO RULER BLOCK (LOAD RULER)

/ ***								***
/ *****************************************************************

/ BEGIN LOOKING FOR DESIRED PAGE

RPDESC,	AC0001			/ ('JMP' HERE AFTER SETUP AT 'XVRPP2')
	JMS	ADJUST
RP7777,	AC7777			/ RPDSCP FLAG INTO AC
	JMS	DSKCAL		/ CALL WPFILS TO READ THE DESCRIPTOR WORD
	XRPRD			/ WPFILS ENTRY FOR 'RPINIT'

	CDFMYF			/ DATA FIELD SET TO 'BUFFER' AT 'DSKCAL' EXIT
	DCA	SRCDIR		/ SAVE THE PRESENT RPPGDS WORD

	TAD	SRCDIR		/ GET IT BACK FOR SOME TESTS
	CMA			/ -1 IS RPPGDS TERMINATOR
	SNA CLA			/ SKIP NEXT IF REAL DESCRIPTOR
	JMP	TRYBOT		/ FOUND DESCRIPTOR LIST TERMINATOR
				/ IF NOT PROCESSING V2 GOLD BOTTOM,
				/ THEN THIS IS AN ERROR CONDITION
	AC4000			/ RPRULR
	AND	SRCDIR		/
	SNA CLA			/ SKIP WITH A RULER IN THIS BLOCK
	JMP	TRYPGE		/ JMP WITHOUT A RULER
	TAD	RPMTRL		/ SAVE PREVIOUS RULER OFFSET.
	DCA	RPMTBK		/  ...

	TAD	RPRLHN		/ BLK. ID # OF EX-RULER
	DCA	RPPRRL		/ BLK ID # FOR PREVIOUS RULER

	TAD	RPCUOF		/ AC = OFFSET TO CURRENT DESCRIPTOR WORD
	DCA	RPMTRL		/ THIS IS LATEST RULER BLOCK

	TAD	RPCUBK		/ RPPGDS BLOCK IDENTIFIER
	DCA	RPRLHN		/ SAVE UNTIL RULER LOAD REQUIRED	/ A78

TRYPGE,	CDILP			/ FOR ROOM
	JMS	RPXHLT		/ TEST desc. for desired page-blk.
	JMP	RPDESC		/ return here if LO page not found
/				 not honoring GOLD_HALT any longer	/A154
	SNA			/ return here if LO page found
/ 				  SKIP IF USER DESIRED PAGE GREATER THAN 999
				/ AC = 0 IF NO 1000'S PAGE # SUPPLIED
				/ SO WE'RE AT THE BLOCK CONTAINING THE PAGE
/D154	JMP	RPNOHLT		/ not honoring GOLD_HALT anymore
	JMP	RPSURL		/ jump with blk. containing desired page	/A154
	TAD	(-1)		/ TAKE AWAY A THOUSAND
	DCA	RPBIN2		/ UPDATE MEMORY THOUSAND PAGE #
	ISZ	CURPG3		/ UPDATE THOUSANDS # OF PAGES COUNTED
	TAD	SRCDIR		/ TOTAL PAGES IN THIS BLOCK
	AND	(37)		/ INTO THE AC
	TAD	CURPG1		/ -REMAINDER OF PAGES IN THIS BLOCK
	CIA			/ NEG COUNT OF PAGES LEFT IN BLOCK
	TAD	(1750)		/ FROM 1000 = NEW HUNDREDS PAGE #
	DCA	RPBIN1		/ UPDATE MEMORY HUNDREDS PAGE #
	DCA	CURPG1		/ RESET PAGE COUNTER
	JMP	RPDESC		/ CONTINUE WITH NEXT DESCRIPTOR

