TITLE USER4  07/16/80    PRINTER PATCH AREA
subttl  Installation f}r Philips GP 300   TK 02.05.83

	; FOR WORDSTAR RELEASE 2.X AND 3.0

;DEFINITIONEN

CR	EQU	0DH
LF	EQU	0AH

LISTF	EQU	5
BDOS	EQU	0005H

	aseg
	org	0690H

	PAGE 63
	; ITEMS RELATING TO ALL PRINTERS
;
; PRINTER CHARACTERISTICS AND PRINTING METHOD
;
  ;PRINTER TYPE / OVERSTRIKE METHOD **** VERY
  ; IMPORTANT: DETERMINES METHOD OF DOUBLE
  ; STRIKE, UNDERLINE, ETC, AND WHETHER DAISY-
  ; LIKE PRINTER CAPABLES OF MICROSPACE JUSTIFY.

  ;POSMTH=FF HEX:
  ; PRINTER CAN OVERPRINT ONLY BY CARRIAGE
  ; RETURN WITHOUT LINE FEED.
  ;POSMTH=0:
  ; PRINTER CAN OVERPRINT BY BACKSPACING AS
  ; WELL AS BY CARRIAGE RETURNING.
  ; NOTE: WITH POSMTH=0, CR-OVERPRINT IS USED
  ; ONLY FOR OVERPRINT LINES IN FILE. FOR
  ; PRINTERS THAT CAN BACKSPACE BUT NOT RETURN
  ; CARRIAGE WITHOUT LINE FEED (EG SELECTRIC),
  ; USE POSMTH=0 AND DON'T USE OVERPRINT LINES.
  ;POSMTH=1:
  ; PRINTER IS A DAISY WHEEL OR SIMILAR INCRE-
  ; MENTAL PRINTER. CAN PRINT WITHOUT SPACING;
  ; CAN SPACE AND ROLL IN SMALL INCREMENTS.
  ; MICROJUSTIFICATION OCCURS ONLY IF POSMTH=1.
  ; ADDITIONAL PATCH ITEMS IN USER5.MAC ARE SET
  ; BY THE INSTALL PROGRAM FOR DAISIES.
POSMTH:	DB 0FFH
	  ;FF SEND CR THEN ANOTHER WHOLE LINE
	  ;00 SEND BACKSPACE THEN CHAR TO 
	  ;     PRINT OVER LAST CHAR SENT
	  ;01 DAISY WHEEL PRINTER WITH ALL NECESS
	  ;     ITEMS IN USER4 AND USER5 INSTALLED.


BLDSTR:	DB 5	;NUMBER OF STRIKES FOR "BOLDFACE"
	  ;SET 3, 4, 5, ETC FOR DARKER "BOLDFACE"
	  ;ON NON-DAISY PRINTER. FOR DAISY
	  ;PRINTERS, 2 IS USED - DON'T CHANGE.
DBLSTR: DB 2	;NUMBER OF STRIKES FOR "DOUBLE
		;STRIKE". INCREASE AS DESIRED.

	DB 0,0,0	;RESERVED

	page
; ****** USER-PATCHABLE FUNCTION
;  STRINGS FOR NON-DAISY PRINTERS ******

;EACH STRING CONSISTS OF THE NUMBER OF BYTES,
;FOLLOWED BY THE BYTES TO BE SENT.
;IF FUNCTION IS NOT AVAILABLE,
;NUMBER OF BYTES SHOULD BE ZERO.

;  ITEMS ON NEXT N PAGES APPLY ONLY WHEN
;  POSMTH (ABOVE) IS 0 OR FF, NOT 1.

;
;STRING TO ADVANCE TO NEXT LINE, USED WHEN
;CR,LF ENCOUNTERED IN FILE.
;
;  IF YOUR PRINTER REQUIRES NULLS SENT
;  AFTER CARRIAGE RETURN (FOR DELAY),
;  INCREASE COUNT SO SOME OF 
;  FOLLOWING ZEROES ARE SENT.
;
;  IF YOUR PRINTER AUTO LINE-FEEDS AFTER
;  CR CODE, REMOVE LF. (IF POSSIBLE,
;  TURN AFF AUTO-LF IN YOUR PRINTER
;  INSTEAD, FOR GREATER FLEXIBILY OF 
;  WORDSTAR USE).
;
PSCRLF:	DB 2	;NUMBER OF CHARACTERS
	DB CR	;1ST CHAR: CARR RET
	DB LF	;2ND CHAR: LINE FEED
	DB 0,0,0,0	;SPACE FOR 8
	DB 0,0,0,0	;..MORE CHARS
;
;STRING TO RETURN CARRIAGE TO BEGINNING
;OF SAME LINE, TO OVERPRINT
;
;USED FOR UNDERLINE, DOUBLESTRIKE, ETC IF 
; POSMTH (ABOVE) IS FF.
;AND WHEN CR WITHOUT LF IS ENCOUNTERED
; IN FILE IF POSMTH IS FF OR 0.
;ALSO USED WHEN POSMTH IS FF AND BACKSPACE 
; (^H) IS ENCOUNTERED IN FILE.
;
PSCR:	DB 1	;2 CHARS: CR 
	DB CR	;CARRIAGE RETURN
	DB 0
	DB 0,0,0,0	;SPACE FOR 5
			;MORE CHARS.

	page
	;NON-DAISY STRINGS ...
;
; STRING TO DO CARRIAGE RETURN AND HALF LINE 
; FEED, FOR PRINTERS THAT CAN DO HALF LINE FEED
; DOWNWARD BUT NOT UPWARD. USED TO PRINT 
; SUBSCRITS AND SUPERSCRIPTS AT HALF-LINE
; INTERVALS IF ROLUP (BELOW) NOT INSTALLED 
; AND POSMTH IS FF OR 0.
;
; FOR EXAMPLE, FOR A SELECTRIC THAT ALWAYS 
; FEEDS HALF LINES, INSTALL ONE CRLF HERE,
; TWO IN "PSCRLF" ABOVE.
;
PSHALF:	DB 0
	DB 0,0,0,0,0,0

;
;STRING TO BACKSPACE, IF TO OVERPRINT LAST
;CHAR PRINTED.
;
;USED FOR UNDERLINE, DOUBLE STRIKE, ETC IF
;POSMTH (ABOVE) IS 0. ALSO USED WHEN BACKSPACE
;(^H) ANCOUNTERED IN FILE IF POSMTH IS 0.
;
PBACK:	DB 1
	DB 8	; ASCII BACKSPACE
	DB 0,0,0,0

	PAGE
	;NON-DAISY STRINGS...
 ;  **** THE FOLLOWING ARE OPTIONAL 
 ;	STRINGS, PERMITTING USE OF ADDITIONAL
 ;	FEATURES IF SUPPORTED BY YOUR PRINTER.
;
;STRING TO SET ALTERNATE CHARACTER
;WIDTH, IF AVAILABLE.
; 
PALT:	DB 0	;0 CHARS: NOT AVAILABLE
	DB 0,0,0,0
;
;STRING TO RESET TO STANDARD CHARACTER WIDTH
;
PSTD:	DB 0,0,0,0,0

;
;STRING TO ROLL CARRIAGE UP A PARTIAL LINE
; WITHOUT ALTERING CARRIAGE COLUMN,
; IF AVAILABLE, FOR USE BEFORE SUPERSCRIPT
; AND AFTER SUBSCRIPT. ROLDOW SHOULD ALSO
; BE INSTALLED TO ROLL CARRIAGE SAME AMOUNT
; IN OTHER DIRECTION. APPLIES IF POSMTH=FF OR 0.
;
ROLUP:	DB 4,1BH,4CH,8DH,0AH

; 
;STRING TO ROLL DOWN, AS AFTER SUPRSCRIPT,
; IF AVAILABLE. USED ONLY IF ROLUP ALSO
; INSTALLED.
;
ROLDOW:	DB 4,0AH,8DH,1BH,4BH


 ; ***** USER-PATCHABLE ITEMS FOR BOTH
 ;	BOTH DAISY AND NON-DAISY PRINTERS ********
;
; STRINGS FOR USER-DEFINED FUNCTIONS 1-4, INVOKABLE
; WITH PRINT CONTROL CHARACTERS IMBEDDED IN FILE.
;    USE ONLY WITH EXTREME CAUTION AND VERY THOROUGH
; TESTING ON DAISY PRINTERS, AS WORDSTAR'S CONTROL
; SEQUENCES AND YOURS COULD EASILY INTERFERE.
;    LINES CONTAINING CONTROLS THAT INVOKE THESE
; ALWAYS PRINT FORWARD EVEN IF BIDIRECTION PRINT IS ON.
;
USR1:	DB 2		; ^Q=CSI
	DB 1BH,5BH,0,0
USR2:	DB 1		; ^W=CPL
	DB 78H,0,0,0
USR3:	DB 1		; ^E=SM
	DB 68H,0,0,0
USR4:	DB 1		; ^R=RM
	DB 6CH,0,0,0


	;DAISY / NON-DAISY ITEMS...

 ;STRINGS USED BY BOTH DIASIES AND NON-DAISIES.
 ;AUTOMATICALLY PATCHED FOR DAISIES BY INSTALL PROGRAM;
 ;MEDDLE WITH CAUTION FOR DAISY PRINTERS.
;
; CHANGE RIBBON COLOR (OPTIONAL)
;
RIBBON:	DB 1	;CHANGE TO ALTERNATE COLOR   ="Shift out"
	DB 0EH,0,0,0

RIBOFF:	DB 1	;CHANGE BACK TO BLACK	     ="Shift in"
	DB 0FH,0,0,0
;
; STRING TO INITIALIZE PRINTER. SENT AT
; START OF PRINTING, MAY BE USED TO TURN MOTOR
; ON, SET STANDARD CHARACTERSIZE AND LINE
; HEIGHT, OR OTHER FUNCTIONS FOR YOUR SPECIFIC
; HARDWARE. ALWAYS PATCHED BY INSTALL PROGRAM,
; ADD YOUR BYTES AFTER INSTALLATION.
;
PSINIT:	DB 4	;NUMBER OF CHARACTERS
	DB CR	;CARRIAGE RETURN, TO MAKE SURE
		;CARRIAGE STARTS AT LFT EDGE
		;OF PAPER.
	DB cr,cr,cr	;um aus ev. undefinierten 
			;  Zust{nden herauszukommen
	DB 0,0,0,0	;UP TO 16 CHARACTERS ..
	DB 0,0,0,0	;.. TOTAL TO SEND ..
	DB 0,0,0,0	;.. TO PRINTER
;
; STRING SENT TO PRINTER AT CONCLUSION OF
; PRINTING, EG TO TURN MOTOR OFF.
;
PSFINI:	DB 1
	DB cr,0,0,0
	DB 0,0,0,0
	DB 0,0,0,0
	DB 0,0,0,0	;UP TO 16 CHARS

	DB 0,0		; RESERVED

;
; CHARATER USED FOR "STRIKEOUT" PRINT ENHANCEMENT
;	(INVOCKED WITH CONTROL-X PRINT CONTROL)
SOCHR:	DB '-'
;
; CHARATER USED FOR "UNDERSCORE" PRINT ENHANCEMENT
;	(INVOCKED WITH CONTROL-X PRINT CONTROL)
ULCHR:	DB '_'

	page
;
; CUSTOMPINTER INITIALIZE SUBR, CALLED BEFORE
; STRING (PSINIT OR DINIT) IS SENT. USE FOR 
; ANYTHING THAT CAN'T BE ACCOMPLISHED WITH
; A STRING, SUCH AS ASSIGNMENT OR INITIALIZING 
; A SPECIAL DRIVER INSTALLED IN YOUR BIOS.
;
PRINIT:	NOP	;INITIALLY NUL. PATCH A JMP
	NOP	;TO YOUR ROUTINE HERE. SEE END
	RET	;OF USER1.MAC REFINDING PATCH
		;SPACE.
;
; CUSTOM PRINTER FINISH (CLOSE) SUBR, CALLED
; AFTER STRING (PSFINI OR DFINI) IS SENT.
;
PRFINI:	NOP
	NOP
	RET

	DB 0,0,0,0	; RESERVED

	PAGE
;  ***** FLAGS RELATING TO TRANSMISSION
;	 OF CHARACTERS TO PRINTER ******

;ITEM ON THIS PAGE RELATE TO AL PRINTERS.

CSWTCH:	DB 0	;WHERE TO SEND EACH OUTPUT CHARACTER:
    ; 00  TO CP/M LIST DEVICE.
    ;   HAVBSY SHOULD BE 0 (UNLESS YOU
    ;   INSTALL A "BUSY" ROUTINE AT LIBSY)
    ; 01  TO INSTALL-PROGRAM-PATCHABLE PORT DRIVER
    ; 02  TO USER SUBROUTINE, ENTRY POINTS
    ;   PUBUSY, PUSEND, AND PUINP.
    ; 03  TO OEM DAISY PRINTER DRIVER. FORCES POSMTH=1.
    ; 04  TO ALTERNATE CONSOLE PRINTER DRIVER.


HAVBSY:	DB 0FFH	;NON-ZERO IF PRINTER DRIVER
		; AS INSTALLED AND PATCHED
	; HAS A "BUSY" TEST SEPARATE FROM
	; "PRINT A CHARACTER". IF NON-ZERO,
	; CONCURRENT EDITING AND PRINTING
	; WILL PERFORM BETTER; MUST BE ZERO
	; IF CAN'T FIND OUT WHETHER PRINTER
	; IS BUSY (AS WHEN CHARACTERS ARE
	; OUTPUT THROUGH CP/M "LIST" DEVICE).

	DB 0	; RESEVED FOR EXPANSION

	PAGE
;  *****  PRINTER DRIVERS PER SE *****

; THERE ARE FIVE DRIVERS, CORRESPONDING TO
; CSWTCH (PREVIOS PAGE) = 00, 01, 02, 03, 04.
;
; EACH OF THE DRIVERS HAS THREE ENTRIES:
;  1.  BUSY STATUS ENTRY. RETURNS CY=1 IF
;	PRINTER IS NOT READY. IF UNIMPLEMENTED,
;	RETURN CY=0. HAVBSY SHOULD BE 0 IF
;	UNIMPLEMENTED AND FF IF IMPLEMENTED.
;  2.  SEND CHARACTER (A REGISTER) ENTRY.
;  3.  INPUT A CHAR TO A, OR RETURN CY=1 IF NO
;	INPUT CHARACTER READY. THIS ENTRY IS 
;	USED ONLY FOR ETX(ACK AND XON/XOFF
;	BUFFER FULL PROTOCOLS IMPLEMETED
;	WITHIN EDITOR (SE "PORTCL" BELOW).
;
; THESE ROUTINES MAY CLOBBER ALL REGISTERS.

LIBSY:	;BUSY TEST ENTRY - BUSY TEST MAY BE
	;ADDED HERE IF YOUR OPERATING SYSTEM
	;ALLOWED DETERMINING WHETHER PRINTER
	;IS READY. PATCH HAVBSY TO FF IF USED.

	NOP
	ORA A	;RETURN CY=0 TO SAY
	RET	; .. NOT BUSY.

LISEND:	;OUTPUT CHARACTER (A) TO LIST DEVICE

	MOV E,A		;CHARACTER IN E FOR CP/M
	MVI C,LISTF	;FUNCTION # IN C
	CALL BDOS	;CALL SYSTEM
	ORA A		;CLEAR CY FLAG
	RET		;RETURN TO CALLER

LISINP:	;INPUT CHARACTER TO (A) OR RETURN CY=1
	;IF NONE. THIS FUNCTION IS NOT SUPPLIED
	;BY OPERATION SYSTEM, USER MUST SUPPLY 
	;SUBROUTINE IF EXT/ACK OR XON/XOFF
	;PROTOCOL IS TO BE USED.

	NOP
	STC	;IF NO ROUTINE INSTALLED, SAY
	RET	; .. NO CHARACTER READY.



	; VORLAEUFIGES ENDE

	END
