/	FOCAL69 8K OVERLAY

/	LAST EDIT: 21-SEP-2017   WDC
	
/	DISASSEMBLED FROM SECOND HALF OF DEC-08-AJ1E-PB
/	PAPER TAPE BY BILL CATTEY 21 SEPTEMBER 2017

/	WITH EXTENSIVE COMMENTS FROM SOURCE CODE ANNOTATIONS
/	MADE BY CHARLES LASNER IN THE FOCAL69 CODELINE.

/	UNDERSTANDING THIS CODE WAS SIGNIFICANTLY EASED
/	BY CHARLES' WORK ON THE P?S/8 FOCAL 8K OVERLAY.
/	NEARLY ALL THE COMMENTS IN THIS FILE COME FROM THERE.
/
/	SUPPORT FOR VIDEO TERMINAL STYLE RUBOUT ADDED
/	CONDITIONAL ON VTRUB=1
/	A HANDY DEFINITIFION FILE VTRUB.PA IS INCLUDED
/
/	ASSEMBLY INSTRUCTIONS, NO VIDEO RUBOUT:
/	.R PAL8
/	*8KNOVT.BN<8KVT.PA
/
/	ASSEMBLY INSTRUCTION, WITH VIDEO RUBOUT:
/	.R PAL8
/	*8KVT.BN<VTRUB.PA,8KVT.PA
/
/	OVERLAY INSTRUCTIONS:
/	SELECT EITHER 8KNOVT OR 8KVT.
/	IF 4WORD IS USED, LOAD IT FIRST.
/	SO THE 4 COMBINATIONS OF ARGUMENT LINE TO ABSLDR WOULD BE:
/
/	8K WITH NO VIDEO RUBOUT:            *FOCAL,8KNVT/G
/	8K WITH VIDEO RUBOUT:               *FOCAL,8KVT/G
/	4WORD AND 8K WITH NO VIDEO RUBOUT:  *FOCAL,4WORD,8KNOVT/G
/	4WORD AND 8K WITH VIDDEO RUBOUT:    *FOCAL,4WORD,8KVT/G
/

/ DEFINITIONS FROM FOCAL69
/ THESE MUST NOT CHANGE BECAUSE THEY SAY WHERE THE PATCH BITS LAND

	ADD=	0061		/CHAR. BUF. IN.
	AXIN=   0010            /PACKING AUTO-INDEX REGISTER
	AXOUT=	0017		/OUTPUT INDEX
	BUFR=   0060            /POINTER TO NEXT FREE LOCATION IN TEXT BUFFER
	C200=	0123		/PAGE ZERO CONSTANT 200
	CFRS=   0133            /POINTER TO DUMMY LINE
	COMBOT= 0226            /PDL PROTECTION POINTER
	COMBUF= 0132            /START OF COMMAND BUFFER STORED HERE
	DDTJR=	0004		/USED FOR DEBUGGING
	DGRP=   0425            /DO ROUTINE ADDRESS
	DGRP1=  0441            /DO ROUTINE ADDRESS
	END=    0134            /FIRST VARIABLE LOCATION IN 8K VERSION
	ENDT=   0135            /END OF TEXT POINTER
	ERG=    2225            /ERASE LINES ADDRESS
	ERT=    2214            /ERASE TEXT ADDRESS
	ERV=    2217            /ERASE VARIABLES ADDRESS
	ERVX=   2237            /ERASE VARIABLES ADDRESS
	FINDN=  2246            /FINDLN ADDRESS
	GET3=   2345            /GET ONE HALFWORD ADDRESS
	GONE=   0232            /COMMAND PROCESSOR ADDRESS
	GS1=    1437            /SUBSCRIPT SEARCH ROUTINE ADDRESS
	INPUTX= 0271            /IMMEDIATE COMMAND ADDRESS
	LASTV=  0031            /ADDRESS OF LAST VARIABLE
	LIBRARY=7503		/DISK MONITOR INTERACTIVE
	MODIFY= 1256            /MODIFY ROUTINE ADDRESS
	OP=	3115		/XMEM TEMP
	OUTDG=  6154            /OUTPUT ONE DIGIT ROUTINE
	PACKST= 0027            /RUBOUT PROTECTION WORD
	PACX=	2530		/BUFFER CHAR PACK ROUTINE
	PC=     0022            /PROGRAM COUNTER
	PCK1=   2535            /PACK ONE HALFWORD ROUTINE
	PDLXR=  0013            /PUSHDOWN LIST AUTO-INDEX REGISTER
	PT1=    0030            /TEMPORARY FOR TDUMP ROUTINE, ETC.
	RECOVR=	2740		/START OF RECOVERY ROUTINE
	RECOVX= 2761            /ADDRESS INSIDE RECOVERY ROUTINE
	RETRN=  1563            /ADDRESS OF RETURN ROUTINE
	RUB1=   3004            /RUBOUT ADDRESS
	START=  0177            /FOCAL'S INTERNAL STARTING ADDRESS
	TDUMP=  3052            /SYMBOL TABLE TYPEOUT ROUTINE
	THISLN= 0023            /LINE POINTER FOR FINDLN
	TSTGRP=	0163
	WALL=   0664            /WRITE COMMAND ADDRESS
	WRITE=  0635            /WRITE COMMAND ADDRESS
	WTEST2= 0653            /WRITE COMMAND ADDRESS
	XDELETE=2062            /DELETE ROUTINE ADDRESS
	XENDLN= 2360            /ENDLN ROUTINE
	XRT=    0011            /TEXT, ETC. AUTO-INDEX REGISTER

/VALUES DERIVED FROM EARLIER DEFINED VALUES

IFNDEF VTRUB <
	IOBUF=	3120		/LOCATION OF I/O BUFFER
	>

IFDEF VTRUB <
        FLTXR=	0014		/ IOBUF MOVES.  ADJUST FLTXR
	OPTR0=	2663		/ IOBUF MOVES. ADGUST OPTR0, O AND I
      	PRINTC=	4551
	>

	COMEIN= IOBUF+20        /COMMAND - INPUT BUFFER


/	MISCELLANEOUS DEFINITIONS.

	NCOMEO=	0100		/NEW COMMAND BUFFER ADDRESS
	P8K=    0167            /8K POINTERS START HERE
	F1SUB0= 2564		/1ST FIELD 1 SUBROUTINES LIVE HERE
	F1SUB1=	6160		/2ND FIELD 1 SUBROUTINES LIVE HERE
	F1SUB2=	7525		/3RD FIELD 1 SUBROUTINES LIVE HERE
	F1SUB3=	7557
/	DIRECT PATCHES TO 4K FOCAL 69

	FIELD	0		/ENSURE FIELD ZERO

	*0000			/BECAUSE IT IS IN THE BINARY

	0000			/BECAUSE IT IS IN THE BINARY

	*PC			/OVER PC

PC,	0000

IFDEF VTRUB <
        *FLTXR

FLTXR,	IOBUF-1
	>

	*LASTV			/LAST VARIABLE POINTER

LASTV,	COMEIN			/USE OLD COMMAND BUFFER, OLD DUMMY LINE AS WELL

	*BUFR			/USER TEXT POINTER

BUFR,	LINE1	/BUFFER START, IN FIELD 1

	*COMBUF			/OVER COMMAND BUFFER POINTER

COMBUF,	AXIN			/POINT TO NEW INPUT BUFFER

CFRS,	NCOMEO			/POINT TO NEW DUMMY LINE / BADGE LINE

	*ENDT			/OVER RESET VALUE FOR ERASE

ENDT,	LINE1			/POINT TO NEW SPACE

	*P8K			/OVER AVAILABLE POINTER SPACE

DPC,	PCD			/TAD I PC ROUTINE POINTER
DTHIS,	THISD			/TAD I THISLN ROUTINE POINTER
DPT1,	PT1D			/TAD I PT1 ROUTINE POINTER
DXRT,	XRTD			/TAD I XRT ROUTINE POINTER
DAXIN,	AXIND			/DCA I AXIN ROUTINE POINTER
DAXOUT,	AXOUTD			/DCA I AXOUT ROUTINE POINTER (NOT IN P?S?)

	*START+2		/OVER TAD CFRSX

	NOP			/JUST POINT TO LOCATION ZERO (ZEROPC) IN TEXT FIELD
	*COMBOT			/OVER END OF COMMAND BUFFER POINTER

COMBOT,	NCOMEO			/NEW COMMAND BUFFER ADDRESS; NO BIAS NEEDED

	*GONE+23		/OVER DCA I AXIN

	JMS I	DAXIN/[AXIND]	/CALL 8K STORE ROUTINE

	*INPUTX+2		/OVER TAD I PC

	JMS I	DPC/[PCD]	/CALL 8K READ ROUTINE

	*DGRP+11		/OVER TAD I XRT

	JMS I	DXRT/[XRTD]	/CALL 8K READ ROUTINE

	*DGRP1+4		/OVER TAD I PC

	JMS I	DPC/[PCD]	/CALL 8K READ ROUTINE

	*DGRP1+14		/OVER TAD I PT1

	JMS I	DPT1/[PT1D]	/CALL 8K READ ROUTINE

	*DGRP1+17		/OVER TAD I PT1

	JMS I	DPT1/[PT1D]	/CALL 8K READ ROUTINE

	*WRITE+15		/OVER TAD I THISLN

	JMS I	DTHIS/[THISD]	/CALL 8K READ ROUTINE

	*WTEST2+6		/OVER TAD I PT1

	JMS I	DPT1/[PT1D]	/CALL 8K READ ROUTINE

	*WALL			/OVER TAD I PT1

WALL,	JMS I	DPT1/[PT1D]	/CALL 8K READ ROUTINE

	*MODIFY+7		/OVER DCA I AXIN

	JMS I	DAXIN/[AXIND]	/CALL 8K STORE ROUTINE

	*GS1+1			/OVER TAD STARTV

	TAD	END		/USE 8K END INSTEAD

	*RETRN			/OVER TAD CFRSX

RETRN,	NOP			/JUST USE LOCATION ZERO IN TEXT FIELD (ZEROPC)
	*XDELETE+23		/OVER NOP

	CDF 10			/USE TEXT FIELD

	*ERT+2			/OVER DCA I CFRS

	/WITH THIS CHANGE WE NO LONGER CLEAR OUT VARIABLE VALUES
	CDF 10			/GOTO TEXT FIELD
ERV,	DCA I	CFRS/[LINE0]	/OVER TAD STARTV CLEAR FWD PTR IN DUMMY LINE
	CDF 0			/OVER DCA STARTV

	*ERG+4			/OVER TAD I THISLN

	JMS I	DTHIS/[THISD]	/CALL 8K READ ROUTINE
	JMS I	TSTGRP		/SKIP IF G(AC) = G(LINENO)
	JMP	START		/OVER JMP ERV
	JMS I	DTHIS		/GET THISLN FROM FIELD 1

	*ERVX			/OVER TAD STARTV

ERVX,	TAD	END		/USE 8K END INSTEAD

	*FINDN+5		/OVER TAD I XRT

	JMS I	DXRT/[XRTD]	/CALL 8K READ ROUTINE

	*FINDN+14		/OVER TAD I THISLN

	JMS I	DTHIS/[THISD]	/CALL 8K READ ROUTINE

	*GET3			/OVER TAD I AXOUT

GET3,	JMS I	DAXOUT		/NOT IN P?S 8K PATCH

	*XENDLN+1		/OVER NOP

	CDF 10			/CDF TO TEXT FIELD

	*XENDLN+14		/OVER TAD STARTV

	CDF	0		/BACK TO OUR FIELD
	JMP I	XENDLN		/RETURN WITH VARIABLES INTACT

	*PACX

PACX,	CDF 0		/OVER NOP (NOT IN P?S 8K PATCH)

	*PCK1+4	    	/OVER DCA I AXIN (DIFFERNT IN P?S)

	JMS I	DAXIN	/FIELD 1 DCA I AXIN
	DCA	ADD	/CLEAR PACKING WORD
	CLL		/WAS CLL CMA IAC
	TAD	C200	/WAS TAD P13; NEW PDLXR BOUND
	NOP		/WAS TAD AXIN

	*F1SUB0		/FIRST NICHE HOLDING FIELD 1 ROUTINES.

PCD,	0000		/FIELD 1 TAD I PC ROUTINE
	CDF 10
	TAD I	PC
	CDF 0
	JMP I	PCD

*PCD+6			/DON'T KNOW WHY LOCATION 2571 IS UNUSED.

AXOUTD,	0000		/FIELD 1 TAD I AXOUT ROUTINE
	CDF 10
	TAD I	AXOUT
	CDF 00
	JMP I	AXOUTD

IFDEF VTRUB <
        *OPTR0		/IOBUF MOVES UPDATE THESE POINTERS
OPTR0,	IOBUF
OPTRO,	IOBUF
OPTRI,	IOBUF
	>

	*RECOVR+10	/NOT IN P?S 8K PATCH

	CDF 00		/REPLACE NOP WITH CDF 0

	*RECOVX+6

	JMS I	DPC	/CALL FIELD 1 TAD I PC

IFDEF VTRUB <

	*RUB1+10

VTRUB1,	JMP VTRUB2	/OVER TAD SPLAT NOW JMP VTRUB2

	>
	
	*RUB1+14

	CDF 10		/REPLACE NOP WITH CDF 10

	*TDUMP		/OVER TAD STARTV

TDUMP,	TAD	END	/INIT POINTER FOR SYMBOL DUMP.

	*TDUMP+10	/NOT IN P?S 8K PATCH

	JMP I	DDDTJR	/OVER DCA OP+1

	*OP

OP,	0003
DDDTJR,	DDTJRD		/DO FIELD 1 DDTJR WRITE

IFDEF VTRUB <
	"(^100+")-200   /IF THESE GO IN 10005 FOR X-MEM CUT THIS?
VTRUB2,	TAD RUB1+3	/USE TAD AXIN AS BS CHAR 010
	PRINTC
	TAD RUB1+1	/USE SZA CLA AS SP CHAR 040
	PRINTC
	TAD RUB1+3	/BS AGAIN
	JMP VTRUB1+1	/RESUME INPUT

	/DOES THIS LOCATION NEED TO START ON SOME KIND OF EVEN BOUNDRY?
	IOBUF=.		/SACRIFICED 6 WORDS OF VARIABLES FOR VTRUB
	>


	*F1SUB1		/SECOND NICHE HOLDING FIELD 1 ROUTINES

THISD,	0000		/TAD I THISLN FROM FIELD 1
	CDF 10
	TAD I	THISLN
	CDF 0
	JMP I	THISD

PT1D,	0000		/TAD I PT1 FROM FIELD 1
	CDF 10
	TAD I	PT1
	CDF 0
	JMP I	PT1D

	*LIBRARY+22	    

MONITD,	CDF CIF 10	/OVERWRITE OLD IOF
	JMP I	DF1MON	/OVERWRITE OLD JMP I P7600

	*F1SUB3

DF1MON,	F1MOND		/FINISH MONITOR CALL OUT IN FIELD 1.

XRTD,	0000		/TAD I XRT FROM FIELD 1
	CDF 10
	TAD I	XRT
	CDF 0
	JMP I	XRTD

AXIND,	0000		/DCA I AXIN INTO FIELD 1
	CDF 10
	DCA I	AXIN
	CDF 0
	JMP I	AXIND

DDTJRD,	CDF 10		/DCA I (4) IN FIELD 1.
	DCA I	LDDTJR
	CDF 0
	JMP I	.+2
LDDTJR,	DDTJR
	TDUMP+11

	FIELD 1

	*0

	0000			/THE BINARY HAS LOCATIONS
	0000			/0000 - 0004 FILLED WITH ZERO
	0000			/DONT KNOW WHY BUT WE WILL TOO
	0000
	0000
	5051			/DONT KNOW WHAT THIS IS YET.
F0BUFR,	BUFR			/PTR TO F0 BUFR POINTER
LINE1P,	LINE1			/INDIRECT PTR FOR START OF BUFFER.

	*NCOMEO

NCOMEO,	0			/TEXT POINTER
	0000			/DUMMY LINE NO.
	"C^100+"--200           /TITLE
	"8^100+"K-300		/8K
	" ^100+"F-300		/ F
	"O^100+"C-300		/OC
	"A^100+"L-300		/AL
	" ^100+"@-300		/ @
	"1^100+"9-200		/19
	"6^100+"9-200		/69
	"?^100+"M-300           /DUMMY C.R.
	CDF 0			/SHOULD F1MOND BE HERE INSTEAD?
	TAD	LINE1P		/NOBODY SEEMS TO CALL IT.
	DCA I	F0BUFR		/NOT SURE WHAT THIS DOES
	CIF 0
	JMP I	MONST
F1MOND,	IOF
	TAD I	F0BUFR		/NOT SURE WHY THIS IS NECESSARY
	DCA	LINE1P
	CDF CIF 0
	JMP I	MONST
MONST,	7600

LINE1=.				/USER TEXT STARTS HERE
	FIELD 0			/RESET FIELD FOR NAIVE OVERLAYS
	
$

