; dos3b/asm
*TITLE	'<DOS+II PRINTER DRIVERS>'
;
; printer spooler in file DOSRTCK/ASM (real time spool)
;
; local variable equivalences
;
PDCB@	EQU	2		;printer DCB number
PRGRPH	EQU	'#'             ;convert graphics to this
;
; driver address for printer (SVC 18)
;
PRTCODE JP	NZ,PRIN 	;@CTL request (status)
	PUSH	BC		;save
	LD	A,B		;get character
	BIT	3,(IX+5)	;transparent mode?
	JP	NZ,PR11 	;go if yes
	CP	0BH		;top of form?
	JR	Z,PR5		;go if yes
	CP	0CH		;TOF?
	JR	Z,PR5		;go this too
;
PR1	BIT	4,(IX+5)	;low case on?
	JR	NZ,PR1X 	;go if yes
	CALL	UCASE		;else make it upper case
;
PR1X	CP	13		;C/R?
	JR	NZ,PR8		;go if not
	INC	(IX+21) 	;any chars on line?
	DEC	(IX+21)
	JR	NZ,PR8		;go if yes
;
PR2	LD	A,10		;else convert to LF
PR8	CALL	PR11		;output the char
	CP	10		;LF
	JR	Z,PR6		;go if yes
	CP	0BH		;FF?
	JR	Z,PR7		;go if yes
	CP	0CH		;FF?
	JR	Z,PR7		;go if yes
	CP	13		;CR?
	JR	NZ,PR14 	;go if not
	BIT	6,(IX+5)	;LF on CR?
	JR	NZ,PR2		;go if yes
	JR	PR6		;else skip
;
PR14	INC	(IX+21) 	;bump char counter
	LD	A,(IX+20)	;get max chars/line
	OR	A		;nil?
	JR	Z,PR13		;go if yes
	CP	(IX+21) 	;see if end of line
	JR	NZ,PR13 	;go if not
	LD	A,13		;else send CR
	JR	PR1X		;send it for new line
;
PR6	LD	(IX+21),0	;reset char counter
	INC	(IX+19) 	;bump line counter
	LD	A,(IX+17)	;printed lines/page
	CP	(IX+19) 	;compare with line cnt
	JR	NZ,PR13 	;go if not at end
;
PR5	BIT	2,(IX+5)	;real FF?
	JR	NZ,PR8		;go if yes
	LD	A,(IX+18)	;get page length
	SUB	(IX+19) 	;less lines printed
	LD	C,A		;counter
	JR	Z,PR7		;go if nil
;
PR9	LD	A,10		;LF
	CALL	PR11		;send it
	DEC	C		;more?
	JR	NZ,PR9		;go if yes
;
PR7	LD	(IX+19),0	;clear line counter
	LD	(IX+21),0	;clear char counter
PR13	POP	BC		;restore
	XOR	A		;Z status
	RET
;
;	ACTUAL CHARACTER OUTPUT
;
PR11	BIT	0,(IX+5)	;translation on ?
	JR	Z,PR15		;nope
	LD	L,(IX+6)	;get table address
	LD	H,(IX+7)
	LD	B,(IX+8)	;table length
	CALL	XLATE		;translate it
;
PR15	PUSH	AF		;save char
	PUSH	BC
	SET	5,(IX+5)	;no int de-spool
	CALL	SPOOL		;attempt de-spool
	RES	5,(IX+5)	;int de-spool ok
	POP	BC
	POP	AF		;get char
	CALL	BUFFADD 	;see if room in buffer
	JR	NC,PR15 	;full, wait for room
	LD	(IX+13),E	;update
	LD	(IX+14),D	;ring
	RET			;done
 