	.title	IMP_TRANSFER	Transfer Cluster
;
; This module defines the base cluster for a shareable library. It holds
; a set of transfer vectors at the beginning set up to call a library
; initialisation procedure. When this has been called once, the vectors
; are reset from the 'real' vectors which point at the appropriate
; procedures. Also included are definitions of any data which the library
; requires users to have access to.
;
; All PSECTS defined by this module must be writeable.
;
; They are given below ALPHABETICALLY. They will appear in the following
; order in the final image.
;
	.psect	Imp_001_Init_Vecs	CON,EXE,LCL,NOSHR,PIC,RD,REL,WRT
	.psect	Imp_002_Real_Vecs	CON,EXE,LCL,NOSHR,PIC,RD,REL,WRT
	.psect	Imp_003_Univ_Data	CON,NOEXE,LCL,NOSHR,PIC,RD,REL,WRT
;
; The following information decides the size of the shareable library's
; vector area:
;
max_jsbs	=	50				; number of JSB_ENTRYs
max_calls	=	300				; number of CALL_ENTRYs
max_init_code	=	100				; size of init code
;
; This section computes the size of the vector area from the above
; maximum values.
;
jsb_size	=	6				; size of JSB_ENTRY
call_size	=	jsb_size+2			; size of CALL_ENTRY
vec_single_max	=	<jsb_size*max_jsbs>+<call_size*max_calls>
vec_area_size	=	<vec_single_max*2>+max_init_code
;
; To avoid having to relink all images which
; access the shareable library, entry points
; already defined within this module MUST NOT
; be removed or the order of definition changed.
;
; Updating the module
;
; Any additions must be made at the end of the module. Two
; macros are defined to assist in updating :
;
;      CALL_ENTRY :: To add entry points for procedures which are
;                    called by either CALLS or CALLG.
;
	.macro CALL_ENTRY,name
		.psect	imp_001_init_vecs
			.transfer name
			.mask	name
			jsb	init_library
		.psect	imp_002_real_vecs
			.mask	name
			jmp	name+2+init_size
	.endm

;
;      JSB_ENTRY  :: To add entry points for subroutines which are
;                    called by the JSB instruction.
;
	.macro	JSB_ENTRY,name
		.psect	imp_001_init_vecs
			.transfer name
			jsb	init_library
		.psect	imp_002_real_vecs
			jmp	name+init_size
	.endm
;
;*********************************************
;*********************************************
;***                                       ***
;***   V E C T O R   P S E C T   B A S E   ***
;***                                       ***
;*********************************************
;*********************************************
;
	.psect	imp_001_init_vecs
init_base:
	.psect	imp_002_real_vecs
real_base:
;
;***********************************************
;***********************************************
;***                                         ***
;***   V E C T O R   D E F I N I T I O N S   ***
;***                                         ***
;***********************************************
;***********************************************
;
;+++START:UNIVED
   Call_Entry EDWIN_BBC_MODE
   Call_Entry EDWIN_CHARLES_END_SHEET
   Call_Entry EDWIN_LASER_POSITION
   Call_Entry EDWIN_LASER_RESOLUTION
   Call_Entry EDWIN_HP_AC_ARC
   Call_Entry EDWIN_HP_C_ARC
   Call_Entry EDWIN_HP_MESSAGE
   Call_Entry EDWIN_HP_SETPEN
   Call_Entry EDWIN_SET_CHAR_FONT
   Call_Entry EDWIN_SET_CHAR_QUAL
   Call_Entry EDWIN_SET_CHAR_ROT
   Call_Entry EDWIN_SET_CHAR_SIZE
   Call_Entry EDWIN_SET_CHAR_SLANT
   Call_Entry EDWIN_SET_CHORD_STEP
   Call_Entry EDWIN_SET_COLOUR
   Call_Entry EDWIN_SET_COL_MODE
   Call_Entry EDWIN_SET_SHADE_MODE
   Call_Entry EDWIN_SET_SPEED
   Call_Entry EDWIN_SET_STYLE
   Call_Entry EDWIN_AREA_DEV
   Call_Entry EDWIN_DRIVE_DEV
   Call_Entry EDWIN_REQUEST_DEV
   Call_Entry EDWIN_SAMPLE_DEV
   Call_Entry EDWIN_SET_COLOUR_MAP
   Call_Entry EDWIN_VERSION
   Call_Entry EDWIN_DEFAULT_DEV
   Call_Entry EDWIN_ERROR
   Call_Entry EDWIN_NUMBER
   Call_Entry EDWIN_SINI
   Call_Entry EDWIN_REVIEW
   Call_Entry EDWIN_ARC
   Call_Entry EDWIN_CIRCLE
   Call_Entry EDWIN_POLYGON
   Call_Entry EDWIN_RECTANGLE
   Call_Entry EDWIN_SECTOR
   Call_Entry EDWIN_INQ_TEXT_SIZE
   Call_Entry EDWIN_TEXT
   Call_Entry EDWIN_TEXT_COL_ESC
   Call_Entry EDWIN_TEXT_FONT_ESC
   Call_Entry EDWIN_UINFS
   Call_Entry EDWIN_FLUSH
   Call_Entry EDWIN_OPER_INTERACT
   Call_Entry EDWIN_OPER_MESSAGE
   Call_Entry EDWIN_SCREEN_TTGET
   Call_Entry EDWIN_SET_DEVICE
   Call_Entry EDWIN_TTGET
   Call_Entry EDWIN_TTMODE
   Call_Entry EDWIN_TTPUT
   Call_Entry EDWIN_TTREAD
   Call_Entry EDWIN_AREA
   Call_Entry EDWIN_ASPECT_RATIO
   Call_Entry EDWIN_CHAR
   Call_Entry EDWIN_CLIP_OFF
   Call_Entry EDWIN_CLIP_ON
   Call_Entry EDWIN_DEVICE_DATA
   Call_Entry EDWIN_INIT
   Call_Entry EDWIN_INQ_POSITION
   Call_Entry EDWIN_INQ_VIEWPORT
   Call_Entry EDWIN_INQ_WINDOW
   Call_Entry EDWIN_LINE_ABS
   Call_Entry EDWIN_LINE_REL
   Call_Entry EDWIN_MAP_TO_DCS
   Call_Entry EDWIN_MAP_TO_VCS
   Call_Entry EDWIN_MARK_ABS
   Call_Entry EDWIN_MARK_REL
   Call_Entry EDWIN_MOVE_ABS
   Call_Entry EDWIN_MOVE_REL
   Call_Entry EDWIN_NEW_FRAME
   Call_Entry EDWIN_REQUEST
   Call_Entry EDWIN_SAMPLE
   Call_Entry EDWIN_SET_MARK_SIZE
   Call_Entry EDWIN_STORE_OFF
   Call_Entry EDWIN_STORE_ON
   Call_Entry EDWIN_TERM
   Call_Entry EDWIN_UPDATE
   Call_Entry EDWIN_VIEWPORT
   Call_Entry EDWIN_VIEW_OFF
   Call_Entry EDWIN_VIEW_ON
   Call_Entry EDWIN_WINDOW
;
;*************************************************************
;*************************************************************
;***                                                       ***
;***   E N D   O F   V E C T O R   D E F I N I T I O N S   ***
;***                                                       ***
;*************************************************************
;*************************************************************
;
	.psect	imp_001_init_vecs
	init_size	=	.-init_base
	.psect	imp_002_real_vecs
	real_size	=	.-real_base

	.if Not_Equal init_size-real_size
		.error "vector copy size mismatch"
	.endc

	.if Greater init_size-vec_single_max
		.error "vector size limit exceeded"
	.endc
;
;*************************************************
;*************************************************
;***                                           ***
;***   I N I T I A L I S A T I O N   C O D E   ***
;***                                           ***
;*************************************************
;*************************************************
;
	.psect	imp_002_real_vecs		; tag onto end of second area
init_library:					; JSBed to by first ever call
	subl2	#jsb_size,(sp)			; retry this call later
	pushr	^m<r0,r1,r2,r3,r4,r5>		; used by string instructions
	movc3	#init_size,real_base,init_base	; patch up vectors
;
; set up IMP event/signal/diag tables for this image
;
	calls	#0,G^LL___SET_IMAGE
;
; user library-initialisation procedures could go in here
;

;
; go back and retry the call which entered the shareable image
;
	popr	^m<r0,r1,r2,r3,r4,r5>		; restore saved registers
	rsb					; end of initialisation
;
;***********************************************************
;***********************************************************
;***                                                     ***
;***   P A D D I N G   B E F O R E   D A T A   A R E A   ***
;***                                                     ***
;***********************************************************
;***********************************************************
;

	.psect	imp_002_real_vecs		; tag onto end of second area
padding:

pad_size	=	vec_area_size-<.-real_base>-init_size

	.if Less_Than	Pad_Size
		.error	"initialisation code is too large"
	.endc
	.blkb	pad_size
	
real_end:

;
;*************************************************
;*************************************************
;***                                           ***
;***   D A T A   A R E A   G O E S   H E R E   ***
;***                                           ***
;*************************************************
;*************************************************
;
	.psect	imp_003_univ_data
;
; the data area is of size 0 in this module. Its presence in the TRANSFER
; module simply allows us to ensure that the module which really defines
; the data specifies the correct attributes to fix the PSECT in the same
; image section as the things above.
;
	.end
