/OVRDRV - OVERLAY DRIVER FOR RESORC
/ASSUMES EVERYTHING IS IN FIELD 1
/
/
/
/
/
/
/
/
/
/COPYRIGHT  (C)  1977,1978 BY DIGITAL EQUIPMENT CORPORATION
/
/
/
/
/
/
/
/
/
/
/THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE
/AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT
/CORPORATION.  DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
/FOR ANY ERRORS THAT MAY APPEAR IN THIS DOCUMENT.
/
/THE SOFTWARE DESCRIBED IN THIS DOCUMENT IS FURNISHED TO THE PURCHASER
/UNDER A LICENSE FOR USE ON A SINGLE COMPUTER SYSTEM AND CAN BE COPIED
/(WITH INCLUSION OF DIGITAL'S COPYRIGHT NOTICE) ONLY FOR USE IN SUCH
/SYSTEM, EXCEPT AS MAY OTHERWISE BE PROVIDED IN WRITING BY DIGITAL.
/
/DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY FOR THE USE
/OR RELIABILITY OF ITS SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY
/DIGITAL.
/
/
/
/
/
/
/
/
/
/

/OVERLAY DRIVER
/FOR LINKER PROGRAM MODULES
/V1B


/THIS SECT IS TWO LOCATIONS AND CONTAINS THE TRANSFER VECTOR TO SWAPER
/AND A FLAG THAT INDICATES WHETHER A JMP (1) OR JMS (0) WAS PERFORMED
/TO THE TRANSFER VECTOR

	.GLOBAL XFERV

/THIS IS THE MAIN DRIVER SECTION

	.SECT	SWAPER,R
	.GLOBAL	SWPTAB

	FIELD	1

SWAP,	6102			/VERSION NUMBER
	DCA	AC		/SAVE CALLING AC
	RAL
	DCA	LINK		/AND LINK
	RDF			/GET CALLING DF
	TAD	(CDF		/FORM CDF
SWAP0,	JMP	ONCE		/DO ONCE ONLY CODE - REPLACED BY DCA EXIT
	CDF	.		/CHANGE TO THIS DATA FIELD
	TAD I	SWAP		/GET OVERLAY,LEVEL,FIELD
	DCA	BINDAT		/SAVE
	ISZ	SWAP		/BUMP POINTER
	TAD I	SWAP		/GET SUBROUTINE ADDRESS
	DCA	XITLOC		/SAVE
	TAD	BINDAT		/FORM CDF TO CALLED SUBROUTINE
	AND	(7
	RAL CLL
	RTL
	TAD	(CDF
	DCA	SWAP1A		/SAVE
	TAD	SWAP1A		/FORM CIF TO CALLED SUBROUTINE
	IAC
	DCA	EXIT+1		/SAVE FOR EXIT
/LOAD OVERLAY OF CALLED SUBROUTINE

LOAD,	TAD	BINDAT
	AND	(1600		/EXTRACT LEVEL OF CALLED SUBROUTINE
	RTR CLL			/5 RIGHT
	RTR
	RAR
	DCA	PNTR		/SAVE
	TAD	PNTR
	TAD	(SWPTAB		/COMPUTE ENTRY INTO SWAP TABLE
	DCA	FLD		/POINTS TO FIELD OF OVERLAY
	TAD	PNTR		/COMPUTE ENTRY INTO CURRENT OVERLAY TABLE
	RTR CLL
	TAD	(CURTAB
	DCA	PNTR
	TAD	BINDAT		/EXTRACT DESIRED OVERLAY NUMBER
	AND	(170
	RTR CLL			/RIGHT 3
	RAR
	CIA			/NEGATE
	DCA	TEMP
	TAD	TEMP
	TAD I	PNTR		/COMPARE WITH CURRENT OVERLAY NUMBER FOR LEVEL
	SNA CLA			/SAME?
	JMP	SWAP1		/YES, NO READING NEEDED
LOAD1,	TAD	TEMP		/NO, SET TO NEW
	CIA
	DCA I	PNTR		/OVERLAY NUMBER
	TAD	FLD		/SET UP POINTERS TO
	IAC
	DCA	ADDRES		/ADDRESS
	TAD	ADDRES
	IAC
	DCA	RELBLK		/RELATIVE BLOCK NUMBER
	TAD	RELBLK
	IAC
	DCA	LENGTH		/LENGTH OF OVERLAY
	TAD	TEMP		/TEST OVERLAY NUMBER
	SNA CLA			/0?
	JMP	LOAD2		/YES, NO MULTIPLICATION NEEDED
	TAD I	LENGTH		/BLOCK NUMBER = (LENGTH OF OVERLAY)
	JMP I	.+1		/TIMES (THE NUMBER OF THE OVERLAY)
	PATCH
LOAD2,	TAD I	RELBLK		/PLUS (RELATIVE BLOCK OF LEVEL)
	TAD	STRBLK		/PLUS (STARTING BLOCK OF PROGRAM)
	DCA	REDBLK		/SAVE IN CALL LOCATION
	TAD I	ADDRES		/GET ADDRESS TO LOAD
	DCA	REDADD		/SAVE IN CALL LOCATION
	TAD I	FLD		/GET FIELD
	AND	(7		/MASK
	RTR CLL
	RAR			/POSITION
	TAD I	LENGTH		/GET LENGTH
	RTL
	RTL
	RTL
	DCA	REDCNT		/FORM CONTROL WORD
	CIF	0
	JMS I	(7607		/CALL SYSTEM HANDLER TO READ IN OVERLAY
REDCNT,	7756			/FUNCTION CONTROL WORD (POINTS TO MREAD-1 FOR "ONCE"
REDADD,	-7607			/BUFFER ADDRESS (CONTAINS SYS: ENTRY POINT FOR "ONCE"
REDBLK,	0			/STARTING BLOCK NUMBER
	HLT			/ERROR RETURN ADDRESS

SWAP1,	TAD	XFERV		/GET JMP-JMS FLAG
	SZA CLA			/SET?
	JMP	SWAP2		/YES, EXECUTE A JMP
	CLA CLL CMA RTL		/-3
	TAD	SWAP		/BACK UP TO CALLER'S PC
	DCA	SWAP
	TAD I	SWAP
SWAP1A,	0			/CDF TO CALLED SUBROUTINE
	DCA I	XITLOC		/SAVE IN CALLED SUBROUTINE
	ISZ	XITLOC		/BUMP TRANSFER ADDRESS
/**	CDF	.
	TAD	(ISZ XFERV
	DCA I	SWAP		/SET BACK UP ENTRY IN XFER VECTOR TABLE
SWAP2,	DCA	XFERV		/CLEAR FLAG
	TAD	LINK		/RESTORE LINK AND AC
	RAR CLL
	TAD	AC
EXIT,	0			/SET DF TO CALLING FIELD
	0			/SET IF TO CALLED FIELD
	JMP I	XITLOC		/GO TO CALLED SUBROUTINE

/VARIABLE LOCATIONS
/SOME OF THE FOLLOWING LOCATIONS CONTAIN
/ONCE ONLY CODE TO SET UP STARTING BLOCK
/AND CHECK THAT FILE CAME FROM SYS:
CURTAB=.			/CURRENT OVERLAY IN LEVEL TABLE (8 ENTRIES)
STRBLK=.			/ENTRY 0 IS USED TO HOLD STARTING BLOCK OF FILE
ONCE,	DCA	EXIT		/SAVE CALLING FIELD
				/ALSO ENTRY 0
	TAD	.-1		/SET UP SO WON'T BE EXECUTED AGAIN
				/ALSO ENTRY 1
	DCA	SWAP0
				/ALSO ENTRY 2
	CDF	0
				/ALSO ENTRY 3
	TAD I	FLD		/GET STARTING BLOCK FROM "SOFSET"
				/ALSO ENTRY 4
	SNA
				/ALSO ENTRY 5
	HLT			/ERROR, K.M. PATCHES NOT IN
				/ALSO ENTRY 6
	DCA	STRBLK		/SAVE
				/ALSO ENTRY 7
	TAD I	REDCNT		/CHECK FILE CAME FROM SYS:
	TAD	REDADD

BINDAT,				/CONTAINS OVERLAY,LEVEL,FIELD OF DESIRED SUBROUTINE
	SNA CLA			/FROM SYS: ?
XITLOC,				/CONTAINS LOCATION TO GO TO IN DESIRED SUBROUTINE
	JMP	SWAP0+1		/YES, OK
PNTR,				/POINTS INTO CURTAB
	HLT			/NO, ERROR
TEMP,				/TEMP STORAGE
	JMP	.-1		/DON'T ALLOW CONTINUE
FLD,				/POINTS TO FIELD WORD IN SWPTAB
	7747			/POINTER TO "SOFSET"

ADDRES=REDADD			/POINTS TO ADDRESS WORD IN SWPTAB
RELBLK=REDBLK			/POINTS TO RELATIVE BLOCK WORD IN SWPTAB
LENGTH=REDCNT			/POINTS TO LENGTH WORD IN SWPTAB

AC,	0			/SAVED AC
LINK,	0			/SAVED LINK

	PAGE

/PATCH TO FIX BLOCK POSITION CALCULATION
PATCH,	IAC		/CONVERT PAGES TO BLOCKS
	CLL RAR
	DCA	PTEMP
	TAD	PTEMP	/MULTIPLY BLOCK LENGTH
	ISZ I	PPNT	/BY OVERLAY NUMBER
	JMP	.-2
	JMP I	.+1
	LOAD2
PPNT,	TEMP
PTEMP,	0



/THIS AREA CONTAINS OVERLAY DATA FOR MAIN AND THE 7 LEVELS
/THE FORMAT OF EACH ENTRY IS:
/WORD1:	FIELD OF LEVEL
/WORD2:	ADDRESS OF LEVEL
/WORD3:	RELATIVE BLOCK OF 1ST OVERLAY IN LEVEL
/WORD4:	LENGTH OF THE LEVEL (ANY AND ALL OVERLAYS-EACH)
/	(ALL OVERLAYS IN A LEVEL ARE THE SAME LENGTH)

SWPTAB,

	*.+40

/THIS AREA CONTAINS THE TRANSFER VECTORS FOR EACH ENTRY POINT
/IN ALL THE OVERLAYS IN ALL THE LEVELS
/ITS SIZE SHOULD BE MODIFIED BY THE USER
/TO FIT THE MAXIMUM NUMBER OF TRANSFER VECTORS NEEDED
/EACH TRANSFER VECTOR OCCUPIES 4 LOCATIONS
/THE TABLE IS INITIALLY SET UP FOR 24(DEC) (30(OCT)) VECTORS
/THE MAXIMUM SIZE THIS TABLE CAN BE IS 3774 (OCT) LOCATIONS FOR
/511 (DEC) (777 (OCT)) VECTORS
/THE FORMAT OF EACH VECTOR ENTRY IS:
/WORD1:	ISZ	XFERV
/WORD2:	JMS I	XFERV+1
/WORD3:	LEVEL/OVERLAY/FIELD
/WORD4:	ADDRESS

	.FSECT TRANVC
	FIELD SWAPER

	SIZE=14		/MODIFY THIS LINE TO CHANGE THE SIZE OF THE TABLE

	*SIZE^4

XFERV,	0
	SWAPER


