/LETTER-QUALITY PRINTER HANDLER FOR V3D		-JVZ-
/THIS IS MY OWN RENDITION, BASED ON A DISASSEMBLY OF DEC'S
/VERSION.  I HAVE ADDED BACKSPACE AND MARGIN RECOGNITION &
/SET IT UP FOR 10-PITCH, 1/2" OFFSET & NO INITIAL FORMFEED
	*0
	-1
	DEVICE	LQPR
	DEVICE	LPT
	1040
	LQP&177!4000
	ZBLOCK 2
	LQSK=6500	/SKIP ON DONE FLAG
	LQRB=6501	/READ BUFFER
	LQMP=6502	/MOVE PAPER
	LQMC=6503	/MOVE CARRIAGE
	LQPC=6504	/PRINT A CHARACTER
	LQRS=6505	/READ STATUS
	LQLS=6506	/LOAD STATUS
	LQRE=6507	/RESTORE
	PAGE

TEMP,	PAG2-ONCE-1
BUFP,	0
WCNT,	0
SAVE,	0
LQP,	"D&77		/VERSION ID
	CLA STL RTL	/2
	LQLS		/SET RIBBON LIFT
ONCE,	JMS PAGE2	/FIND OUT WHERE WE ARE
	RDF		/AND WHERE WE CAME FROM
	TAD CDI0
	DCA CDIX
	TAD I LQP	/GET FUNCTION WORD
	AND (70		/STRIP BUFFER FIELD
	TAD (CDF
	DCA CDFX
	TAD I LQP	/GET DOUBLE WORD COUNT
	AND (3700
	CMA
	DCA WCNT
	ISZ LQP
	TAD I LQP
	DCA BUFP
	ISZ LQP
	TAD I LQP	/BLOCK NUMBER
	CLA / SZA	/INITIALIZATION?
	JMP COUNT-1	/NO, SET D.F.
	TAD (15		/CR
	JMS LQPRNT
	TAD (14		/FF
	JMP COUNT-1
UNPAC,	JMS SUB1	/1
	CLL RTR
	DCA TEMP
	JMS SUB1	/2
	BSW
	TAD TEMP
	CLL RTR
	JMS LQPRNT	/3
COUNT,	ISZ WCNT	/DONE?
	JMP UNPAC	/NO
CTRLZ,	TAD (13		/FLUSH LINES & SPACES
	JMS LQPRNT
CTRLO,	ISZ LQP
	ISZ LQP
CDIX,	CDF CIF
	JMP I LQP
SUB1,	0
	TAD I BUFP
	JMS LQPRNT
	TAD I BUFP
	AND .+2
	ISZ BUFP
	7400		/NOP
	JMP I SUB1
LQPRNT,	0		/PRINT A CHARACTER
	AND (177	/NO PARITY BITS, PLEASE
	DCA SAVE
	TAD SAVE
	TAD (300-"Z	/EOF?
	SNA
	JMP CTRLZ	/YES
	TAD (32-40	/SET UP FOR PAGE 2
CDI0,	CDF CIF 0
	JMS I PAGE2	/AC=CHAR-40
MARGIN,	74		/1/2 INCH OFFSET
	KRS
	AND (177
	TAD (300-"L	/CTRL/L?
	SNA
	JMP CTRLL
	TAD ("L-"O	/CTRL/O?
	SNA
	JMP CTRLO
	TAD ("O-"C	/CTRL/C?
	SNA CLA
	JMP I (7600	/YES
CDFX,	CDF
	JMP I LQPRNT	/NO
CTRLL,	TAD SAVE	/PAUSE AFTER A FF
	TAD (-14
	SZA CLA
	JMP CDFX	/NOT YET
	KCC
	KSF
	JMP .-1		/WAIT A WHILE
	JMP CDFX
PAGE2,	0		/FIND OUT WHAT PAGE WE'RE ON
	LQRE		/RESTORE, CLEAR DONE
	LQSK
	JMP .-1
	TAD MARGIN
	LQMC
	TAD TEMP
	TAD PAGE2
	DCA PAGE2
	DCA ONCE	/ONCE ONLY, YOU KNOW
	JMP ONCE+1	/THIS SHOULD USE THE TEMP LOCS
	PAGE

PITCH,	30		/CARRIAGE CONSTANT
LS,	20		/LINE SPACING  "
LINES,	-102		/ 66 LINES / PAGE
PAG2,	0		/AC=CHAR-40
	SPA
	JMP LQCC	/CONTROL CHARACTERS
	SNA
	JMP LQSP	/SPACE
	TAD (40		/RESTORE
LQVT,	DCA CHAR	/SAVE FOR LATER
CKSTAT,	LQRS		/READ THE STATUS
	CLL BSW
	SMA CLA		/TROUBLE?
	JMP READY	/NO
	STL
	LQRE		/RESET & TRY AGAIN
	LQRS
	TAD (400
	SZL CLA
	JMP .-3
	TAD I PAG2	/RESTORE MARGIN
	LQMC
	DCA CCTR	/CLEAR LINE POSITION
	DCA CPOS
	ISZ LCTR	/MOVE DOWN A LINE
READY,	LQRS		/CHECK AGAIN
	TAD (400	/CHECKS FOR ALL DONE
	SNL CLA
	JMP CKSTAT	/HANG FIRE FOR A WHILE
MOVP,	TAD LCTR	/CHECK PAPER POSITION
	SNA
	JMP MOVC	/TOP OF FORM
	CIA
	DCA LCTR
	TAD LS		/MULTIPLY LS X PAPER POS.
	ISZ LPOS
	ISZ LCTR
	JMP .-3
	LQMP		/MOVE TO THIS POSITION
	TAD LPOS
	TAD LINES	/COMPUTE NEW POSITION
	SMA
	JMP .-2		/MODULO PAGE SIZE
	CIA
	TAD LINES
	CIA
	DCA LPOS	/SAVE REMAINDER
MOVC,	TAD CCTR	/NOW CHECK CARRIAGE
	SNA
	JMP PRNTC	/HOME
	TAD CPOS
	DCA CPOS	/UPDATE THE POSITION
	TAD CCTR
	STL
	SMA		/TAKE ABSOLUTE VALUE
	CLL CIA
	DCA CCTR
	TAD PITCH
	ISZ CCTR	/MULTIPLY PITCH X POS.
	JMP .-2
	RAR		/SHIFT IN DIRECTION BIT
	LQMC
PRNTC,	TAD CHAR	/GET THE CHAR BACK
	SNA
	JMP I PAG2	/IGNORE NULLS
	CLL RAL		/MYSTERIOUS X2
	LQPC
LQSP,	ISZ CCTR
	40-15		/NOP
	JMP I PAG2
LQCC,	TAD LQSP+1	/CHECK FOR A CR
	SNA
	JMP LQCR
	IAC
	SNA
	JMP LQFF
	IAC
	SNA
	JMP LQVT	/FLUSH SPACES
	IAC
	SNA
	JMP LQLF
	IAC
	SNA
	JMP LQTB
	IAC
	SNA CLA
	CMA
	TAD CCTR
	JMP LQBS
LQTB,	TAD CCTR	/TABS
	TAD CPOS
	TAD (10
	AND (7770
	CIA
LQCR,	TAD CPOS
	CIA
LQBS,	DCA CCTR
	JMP I PAG2
LQLF,	ISZ LCTR
	TAD LCTR
	TAD LPOS
	TAD LINES
	SMA CLA
	JMP LQVT	/ADVANCE TO NEXT PAGE
	JMP I PAG2
LQFF,	TAD LINES
	TAD LPOS
	CIA
	DCA LCTR
	JMP LQVT
CCTR,	0
CPOS,	0
LCTR,	0
LPOS,	0
CHAR,	0
	PAGE
	$

