" 
" Begin include file ...... getprt.incl.alm
" Modified 10/1/74 by Noel I. Morris for PRU1200 operation
" Modified 8/26/75 by Noel I. Morris
" Modified 8/24/78 by Sherman D. Sprague for PRU1200 vfc corrections
" Modified 4/12/82 by Sherman D. Sprague to support EURC controlers

"	tsx2	getprt		to find an available printer
"	sta	prtchanno		channel number


	equ	p300l,288		PRT300 buffer image length
	equ	p1200l,240	PRU1200 buffer image length


getprt:	stx2	getprtx2		save xrs
	stx0	getprtx2+1
	stc1	prtfirst		set first time switch

getpr1:	stz	prtfnd		clear printer found switch
	eax0	0		try all channels
ploop:	lda	prtname,0		get printer name
	sta	prname		save it for later
	tsx2	getperiph		search for PRPH card
	tra	pnext		if none, try next printer
	stc1	prtfnd		set printer found switch

	lda	com|2,7		IOM # in A
	sta	gp_iom		store it for later use
	sba	1,dl
	als	6
	ada	com|3,7		add channel #
	ldq	com|3,7
	stq	gp_chn 		store the channel # for later use
	als	18		move to AU
	sta	pchan		save channel #
	lda	com|5,7		print train type in A
	sta	ptrain		save it

	lda	com|4,7		model # in A
prfork:	sta	prmodel		save it for later
	cmpa	=401,dl		>401 ?
	tpl	pr1200		if so, must be PRU1200/1600

	cmpa	=202,dl		<202 ?
	tmoz	pr202		if so, must be PRT202

	lda	=h p300i		get name of PRT300 image file in BOS
	tsx2	ldtrain		grab the correct train image

	lda	prmodel		get model # again
	cmpa	=303,dl		is it PRT303?
	tze	pr303		if so, must convert image to ASCII

	tsx2	xio_wait		load PRT300 image
	vfd	18/gptrain,12/p300l/6
	vfd	18/pchan,o18/14
	tra	primerr
	tra	pok

" 

pr1200:	lda	=o010000,dl	set device address of 1
	stca	pchan,04		..

	tsx2	xio_wait		read detailed status
	vfd	18/prstat,12/4
	vfd	18/pchan,o18/03
	tra	primerr

	tsx2	getmpc		check mpc type
	arg	gp_chn		the CHN the printer might be on
	arg	gp_iom		the IOM the printer might be on
	tra	no_mpc_card	could not match the PRPH to a MPC

	lda	com|2,7		get the mpc model number
	cmpa	=8000,dl		is it an EURC ?
	tmoz	not_eurc

          eax5      0		set up the CSL to convert
          eax6      1		the ascii status we recieved

gpcvst:	csl  (x6),(x5),bool(03)	from the EURC controler
          descb     prstat,8		get the first 9 bits
          descb     prstat,8		store back 8
          eax6      9,6		set up for the next 9
          eax5      8,5		set up to store the next 8
          cmpx5     128,du		did we do all the bits of
          tnz       gpcvst		status yet ?


not_eurc:	lda	=o6000,dl		check for VFC loaded and synched
	cnaa	prstat		both bits must be on
	tze	vfcok		if so, skip VFC load

	tsx2	xio_wait		now load the VFC image
	vfd	18/prvfc,12/3
	vfd	18/pchan,o18/05
	tra	primerr

vfcok:	lda	prstat		get belt number
	arl	35-15		right-justified
	ana	=o77777,dl	mask

	eax7	np1200id		number of known belts in X7
	cmpa	p1200id-1,7	search for belt number
	tze	gpbelt		if found, go load it
	eax7	-1,7		step to next
	tpnz	*-3		and loop
	tra	gpnotrain		cannot find this belt number

gpbelt:	stz	ptrain		clear the word
	sxl7	ptrain		save belt index
	lda	=hp1200i		load correct PRU1200 image
	tsx2	ldtrain		..

	ldq	p1200l,dl		length of image in Q
gpcvt:	mvt	(rl),(rl)		convert image to ASCII
	desc6a	gptrain,ql
	desc9a	gptraina,ql
	arg	geastabu

	qls	6-2		number of words in image in tally field
	stcq	prld,06		set for call

	tsx2	xio_wait		load the image
prld:	vfd	18/gptraina,12/0
	vfd	18/pchan,o18/01
	tra	primerr
	tra	pok

pr303:	lda	=o010000,dl	set device address to 1 for PRT303
	stca	pchan,04		..

	ldq	p300l,dl		length of image in Q
	tra	gpcvt		go convert to ASCII and load it

pr202:	tsx2	xio_wait		see if printer is ready
	zero
	vfd	18/pchan,o18/40
	tra	primerr
	tra	pok		return if OK

" 

pok:	lda	pchan		channel number in A
getprtx2:	eax2	*-*
	eax0	*-*
	tra	0,2		return to caller


pnext:	eax0	1,0		step X0 to
	cmpx0	nprinters,du	try next printer
	tmi	ploop

pnext1:	szn	prtfirst		is this the first time through loop?
	tze	pnext2		if not, just try again
	tsx2	erpt		complain about no printers
	acc	"no printer ready."

pnext2:	szn	prtfnd		did we ever find a printer?
	tze	prtdef		if not, use default
	stz	prtfirst		clear first time switch
	tra	getpr1		try loop again

prtdef:	eax7	pnext1		change error location
	stx7	primerr		..

	tsx2	erpt		ask for printer info
	acc	"please enter printer channel, model, and train."

	tsx2	readtty		read answer
	tra	prtdef

	tsx2	scan		scan args
	lda	arg		channel #
	als	18
	sta	pchan
	lda	arg+2		train #
	sta	ptrain
	lda	arg+1		model #
	tra	prfork		now, examine info

primerr:	tra	pnext		****** THIS LOCATION GETS MODIFIED ******

" 

ldtrain:	stx2	ldtx2		save X2

	tsx2	search		search for train image file
	tra	gpnotrain
	ana	=o777777770000	mask the disk address
	stca	gptrainad,74	save it

	lda	ptrain		train # in A
	sba	1,dl		subtract 1 and
	als	12		shift to disk address position
	adla	gptrainad		get disk addr of desired train image
	tsx2	rdsec		read in train image
	arg	gptrain		..
	tra	gpnotrain

ldtx2:	eax2	*		restore X2
	tra	0,2		and return

gpnotrain:
	tsx2	erpt
	acc	"unable to find train image for ^a."
	arg	prname
	tra	primerr

no_mpc_card:
	tsx2	erpt
	acc	"could not find a mpc card to match ^a channel ^o."
	arg	prname
	arg	gp_chn
	tra	primerr

" 

prtname:	aci	"prta"
	aci	"prtb"
	aci	"prtc"
	aci	"prtd"
	aci	"prte"
	aci	"prtf"
	aci	"prtg"
	aci	"prth"
	equ	nprinters,*-prtname	

p1200id:	dec	600
	dec	500
	equ	np1200id,*-p1200id

gp_iom:	bss	,1
gp_chn:	bss	,1

pchan:	bss	,1
prname:	bss	,1
ptrain:	bss	,1
prmodel:	bss	,1
prstat:	bss	,4
prtfnd:	bss	,1
prtfirst:	bss	,1
gptrainad:
	vfd	24/,12/1

prvfc:	vfd	9/6,o9/204,9/4,o9/113
	vfd	o9/100,o9/60,o9/106,o9/111
	vfd	o9/202,o9/060,18/0

gptraina:	bss	,p300l/4-p300l/6

gptrain:	bss	,64

" End of include file ...... getprt.incl.alm

"
"
"                                          -----------------------------------------------------------
"
"
"
" Historical Background
"
" This edition of the Multics software materials and documentation is provided and donated
" to Massachusetts Institute of Technology by Group Bull including Bull HN Information Systems Inc. 
" as a contribution to computer science knowledge.  
" This donation is made also to give evidence of the common contributions of Massachusetts Institute of Technology,
" Bell Laboratories, General Electric, Honeywell Information Systems Inc., Honeywell Bull Inc., Groupe Bull
" and Bull HN Information Systems Inc. to the development of this operating system. 
" Multics development was initiated by Massachusetts Institute of Technology Project MAC (1963-1970),
" renamed the MIT Laboratory for Computer Science and Artificial Intelligence in the mid 1970s, under the leadership
" of Professor Fernando Jose Corbato. Users consider that Multics provided the best software architecture for
" managing computer hardware properly and for executing programs. Many subsequent operating systems
" incorporated Multics principles.
" Multics was distributed in 1975 to 2000 by Group Bull in Europe , and in the U.S. by Bull HN Information Systems Inc., 
" as successor in interest by change in name only to Honeywell Bull Inc. and Honeywell Information Systems Inc. .
"
"                                          -----------------------------------------------------------
"
" Permission to use, copy, modify, and distribute these programs and their documentation for any purpose and without
" fee is hereby granted,provided that the below copyright notice and historical background appear in all copies
" and that both the copyright notice and historical background and this permission notice appear in supporting
" documentation, and that the names of MIT, HIS, Bull or Bull HN not be used in advertising or publicity pertaining
" to distribution of the programs without specific prior written permission.
"    Copyright 1972 by Massachusetts Institute of Technology and Honeywell Information Systems Inc.
"    Copyright 2006 by Bull HN Information Systems Inc.
"    Copyright 2006 by Bull SAS
"    All Rights Reserved
"
"