;*************************** AMUS Program Label ******************************
; Filename: OKI393.M68                                        Date: 08/02/89
; Category: Printer Driver Hash Code: 542-147-247-706      Version: 1.1(107)
; Initials: AODP/AM       Name: GARY D. CHESSER
; Company: EMERGITECH                              Telephone #: 61488666712
; Related Files: OKI393.WRT shows usage of printer driver from within write
; Min. Op. Sys.: 1.3                           Expertise Level: BEG
; Special: Need to know how to set up in WRITE.INI. Call me for help.9-5 EST.
;
; Description: This is a printer Driver for the Okidata 393.
; It will make use of a number of the features of the OKIDATA 393 printer.
; Triple high, Triple wide, Italics, ect. Print OKI393.WRT from within
; ALPHA WRITE to find all the characteristics of this PDV.
;
; This will also work with OKIDATA 390 & 320 but they don't support all the
; function of the 393.
;*****************************************************************************
;***************************************************************************
;*
;*               Printer Driver for Okidata 393 AS OF 11/7/88
;*    [1] MAKE CALLS MACRO CALLS FOR MARGIN BLOCKS
;***************************************************************************
;                                                               ASL-     -
;                                 NOTICE
;
;All  rights  reserved.  This software is the property of Alpha Microsystems
;and the material contained herein is the  proprietary  property  and  trade
;secrets  of  Alpha Microsystems, embodying substantial creative efforts and
;confidential information, ideas and expressions, no part of  which  may  be
;reproduced  or  transmitted  in  any  form  or  by  any  means, electronic,
;mechanical,  or  otherwise,  including  photocopying  or  input  into   any
;information  storage  or  retrieval  system  without  the  express  written
;permission of Alpha Microsystems.
;
;CAUTION: Unauthorized distribution or reproduction  of  this  material  may
;subject you to legal action.
;
;Copyright (C) 1983,1984 - Alpha Microsystems
;

       SEARCH  SYS
       SEARCH  SYSSYM
       COPY    PDVSYM

       OBJNAM  .PDV

       VMAJOR=1.
       VMINOR=1.
       VEDIT=107.

;Edit History:
;[AO4] 06/30/88 AO/GDC CHANGE RIBBON COLORS TO BELOW
;[AO3] 06/07/88 AO/GDC SET THE CODES FOR OKI39300
;[A02] 12/29/87 AO/GSA Added LPI 6/8
;[AO1] 06/19/86 AO/GSA
;       ADDED OKIDATA 84 CODES AS FOLLOWS:
;       10cpi, 12cpi, 17cpi,
;       Primary Ribbon Color = HIGH SPEED DRAFT
;       Secondary Ribbon Color = LETTER QUALITY
;       Third Ribbon Color = UTILITY PRINTING MODE
;       Fourth Ribbon Color = NEAR LETTER QUALITY
;       Fifth Ribbon Color = ITALICS ON
;       Sixth Ribbon Color = ITALICS OFF
;
;[107] 5 August 1984
;       Fix problem with leaving bold, underscore or strikeout on across
;       multiple lines when left paper offset was non-zero. /RBC
;[106] 8 June 1984
;       Make use PDVSYM for all symbols. /RBC
;[105] 3 June 1984
;       Output both CR's and LF's to make .LST files VUE compatible. /RBC
;[104] 15 May 1984
;       Update impure area definition. /RBC
;[103] 21 April 1984
;       Make PDLF output CRLF's instead of just line feeds. /RBC
;[102] 01 Dec 1983
;       Major rewrite of module. /PPJ
;[101] 20 February 1983
;       Handle special print position code. /RBC
;[100] 12 January 1983
;       Created. /RBC
;

PAGE
;************************
;*      PDV entry       *
;************************
;Define the entry points of the .PDV
;
;  CAUTION: Do Not Change the order or size of the entry points.
;           If any of the functions are not implemented replace the entry
;           point with 'JMP IGNORE'.
;
;  A3 indexes the impure area defined above on entry to the driver.
;
PDV:    PHDR    -1,0,PH$REE!PH$REU
       LWORD   PD$FED                  ; SUPPORTS SHEET FEEDER
       JMP     PDINI                   ; PDINI,  initialize printer
       JMP     IGNORE                  ; PDCLS,  shut down printer
       JMP     PDCHR                   ; PDCHR,  output a character in D1
       JMP     PDCTL                   ; PDCTL,  output control string indexed by D1
       JMP     PDSPL                   ; PDSPL,  output special string & character
       JMP     PDMNLN                  ; PDMNLN, move to next line & start new line
       JMP     PDMTOF                  ; PDMTOF, move to Top of Form & setup for new page
       JMP     IGNORE                  ; PDPSON, enable proportional
       JMP     IGNORE                  ; PDSOF,  disable proportional
       JMP     PDUNDR                  ; PDUNDR, toggle underscore
       JMP     PDBOLD                  ; PDBOLD, toggle bold
       JMP     PDSTRK                  ; PDSTRK, toggle strikeout
       JMP     IGNORE                  ; PDBAR,  toggle over-bar
       JMP     IGNORE                  ; PDSLPI, set Lines Per Inch
       JMP     IGNORE                  ; PDSHMI, set Horizontal Motion Index
       JMP     PDSCPI                  ; PDSCPI, set Characters Per Inch
       JMP     PDSTM                   ; PDSTM,  set Top Margin
       JMP     PDMTM                   ; PDMTM,  move to Top Margin
       JMP     PDSLPO                  ; PDSLPO, set Left Paper Offset
       JMP     PDMLPO                  ; PDMLPO, move to Left Paper Offset
       JMP     PDSLPP                  ; PDSLPP, set Lines per Page
       JMP     PDSLSP                  ; PDSLSP, set line spacing (in 1/2 lines)
       JMP     PDOVRP                  ; PDOVRP, setup to overprint last char.
       JMP     PDLF                    ; PDLF,   output LFs per count in D2
       JMP     IGNORE                  ;   ENTRY RESERVED FOR ALPHA MICRO
       JMP     IGNORE                  ;   ENTRY RESERVED FOR ALPHA MICRO
       JMP     IGNORE                  ;   ENTRY RESERVED FOR ALPHA MICRO
       JMP     IGNORE                  ;   ENTRY RESERVED FOR ALPHA MICRO
       JMP     IGNORE                  ;   ENTRY RESERVED FOR ALPHA MICRO
       JMP     IGNORE                  ;   ENTRY RESERVED FOR ALPHA MICRO
       JMP     IGNORE                  ;   ENTRY RESERVED FOR ALPHA MICRO
       JMP     IGNORE                  ;   ENTRY RESERVED FOR ALPHA MICRO
       JMP     IGNORE                  ;   ENTRY RESERVED FOR USER DEFINITION
       JMP     IGNORE                  ;   ENTRY RESERVED FOR USER DEFINITION
       JMP     IGNORE                  ;   ENTRY RESERVED FOR USER DEFINITION
       JMP     IGNORE                  ;   ENTRY RESERVED FOR USER DEFINITION
       JMP     IGNORE                  ;   ENTRY RESERVED FOR USER DEFINITION
       JMP     IGNORE                  ;   ENTRY RESERVED FOR USER DEFINITION
       JMP     IGNORE                  ;   ENTRY RESERVED FOR USER DEFINITION
       JMP     IGNORE                  ;   ENTRY RESERVED FOR USER DEFINITION

PAGE
;************************
;*      PDSPL           *
;************************
; Output a control string & then the byte in D2
;  String number is in D1.
;
PDSPL:  BCALL   PDCTL                   ; output the string
       MOVB    D2,D1
       ORB     #^H80,D1                ; make sure it gets thru TRMSER
       FILOTB  PTDDB(A3)               ; output it
IGNORE: RTN                             ; just return to caller of .PDV

PAGE
;************************
;*      PDCTL           *
;************************
; Output a control string.
;  String index is in D1
;
PDCTL:  CMPB    D1,#MAXCDE              ; valid special code ?
       BHI     99$                     ;   no, ignore it
       ADDW    D1,D1                   ; make index into word offset
       MOVW    CTLTBL[~D1],D1          ; get string offset
       LEA     A6,CTLTBL[~D1]
       JMP     STROUT                  ; go output it

99$:    RTN

; Printer control string table
; CAUTION: Do Not Change the order of the string table.
;          If the string is not implemented put a length of zero at the label.
;
DEFINE  STRING  TAG
       WORD    TAG-CTLTBL
ENDM

CTLTBL: STRING  CHOME                   ; 00 return carriage home
       STRING  MOVAHT                  ; 01 move to absolute horizontal tab
       STRING  ROLUP                   ; 02 roll up a partial line
       STRING  ROLDWN                  ; 03 roll down a partial line
       STRING  NEGLF                   ; 04 output negative line feed
       STRING  SPLPT0                  ; 05 special print position 0
       STRING  SPLPT1                  ; 06 special print position 1
       STRING  RIBSC1                  ; 07 print in Secondary ribbon color 1
       STRING  RIBSC2                  ; 08 print in Secondary ribbon color 2
       STRING  RIBSC3                  ; 09 print in Secondary ribbon color 3
       STRING  RIBPRM                  ; 10 print in Primary ribbon color
       STRING  FEDTR1                  ; 11 select Feeder tray 1
       STRING  FEDTR2                  ; 12 select Feeder tray 2
       STRING  FEDTR3                  ; 13 select Feeder tray 3
       STRING  FEDTR4                  ; 14 select Feeder tray 4
       STRING  FEDTGL                  ; 15 select Feeder tray 1 & then tray 2
       STRING  FEDEJT                  ; 16 select Feeder eject
       STRING  USR1                    ; 17 user function 1
       STRING  USR2                    ; 18 user function 2
       STRING  USR3                    ; 19 user function 3
       STRING  USR4                    ; 20 user function 4
TBLEND:                                 ; end of table

MAXCDE  =       <<TBLEND-CTLTBL>/2.>    ; maximum special code

PAGE
;************************
;*      PDCHR           *
;************************
; Output the character in D1
;
PDCHR:  FILOTB  PTDDB(A3)
       ADDW    #1,CURCOL(A3)           ; advance to next column
       BTST    #FM%BLD,FM.FLG(A3)      ; bold active ?
       BEQ     99$                     ;   no, just return
       MOV     BLDPTR(A3),A6           ;   yes, save this character
       MOVB    D1,(A6)+
       MOV     A6,BLDPTR(A3)
99$:    RTN

PAGE
;************************
;*      STROUT          *
;************************
; Output string indexed by A6 to DDB indexed by A3
;
STROUT: SAVE    A0,D1,D2                ; save registers
       MOV     A6,A0
       CLR     D2
       MOVB    (A0)+,D2                ; get string length
       BR      20$                     ;  and enter loop at end

10$:    MOVB    (A0)+,D1                ; get byte from string
       FILOTB  PTDDB(A3)               ; output it
20$:    DBF     D2,10$                  ; loop until all characters output
       REST    A0,D1,D2                ; restore registers
       RTN

PAGE
;************************
;*      PDINI           *
;************************
; Initialize the printer
;
PDINI:  MOVW    #-1,HMISAV(A3)          ; no HMI yet
       MOVW    #-1,LPISAV(A3)          ; no LPI yet
       MOVW    #-1,CPISAV(A3)          ; no CPI yet
       MOVW    #-1,TPMSAV(A3)          ; no top margin yet
       MOVW    #-1,LPOSAV(A3)          ; no left paper offset yet
       CLRW    CURCOL(A3)              ; at column 0
       CLR     CURLIN(A3)              ; at start of page
       RTN

;************************
;*      PDCLS           *
;************************
; Shut down the printer
;
PDCLS:                                  ; not needed since nothing is altered

PAGE
;************************
;*      PDSTM           *
;************************
; Set Top Margin from value in D2
;  D2 contains the number of lines required in the Top Margin
;
PDSTM:  MOVW    D2,TPMSAV(A3)           ; save top margin value
       RTN

;************************
;*      PDMTM           *
;************************
; Move to Top Margin
;
PDMTM:  PUSHW   D2                      ; save register
       MOVW    TPMSAV(A3),D2           ; get offset value
       BCALL   PDLF                    ; go output line feeds
       POPW    D2
       RTN

;************************
;*      PDLF            *
;************************
; Output Line feeds per count in D2
;
PDLF:   PUSHB   D1
       BR      15$                     ;  and enter loop at end

10$:    MOVB    #$CR,D1                 ; output a carriage return              [103]
       FILOTB  PTDDB(A3)               ;                                       [103]
       MOVB    #$LF,D1                 ;   then a line feed                    [103]
       FILOTB  PTDDB(A3)               ; output a single space
       ADD     #2,CURLIN(A3)           ; bump number of 1/2 lines
15$:    DBF     D2,10$                  ;  and loop until all done
       POPB    D1
       RTN

PAGE
;************************
;*      PDSLPO          *
;************************
; Set Left Paper Offset
;  D2 contains the number of 1/10 inch units required
;
PDSLPO: MOVW    D2,LPOSAV(A3)           ; save left paper offset
       RTN

;************************
;*      PDMLPO          *
;************************
; Move to Left Paper Offset
;
PDMLPO: SAVE    D1,D2
       MOVW    LPOSAV(A3),D2           ; get offset value
       MOVW    D2,BLDCOL(A5)           ; set bold column in case it is on      [107]
       MOVW    D2,UNDCOL(A5)           ; set underline column in case it is on [107]
       MOVW    D2,STKCOL(A5)           ; set strikeout column in case it is on [107]
       MOVB    #32.,D1                 ; [AO3]    get a space
       BR      15$                     ;  and enter loop at end

10$:    ADDW    #1,CURCOL(A3)           ; bump current column
       FILOTB  PTDDB(A3)               ; output a single space
15$:    DBF     D2,10$                  ;  and loop until all done
       REST    D1,D2
       RTN

PAGE
;************************
;*      PDSLPP          *
;************************
; Set lines per page
;  D2 contains the form length in number of lines
;
PDSLPP: MOVW    D2,LPPSAV(A3)           ; save for later
       RTN

PAGE
;************************
;*      PDSLSP          *
;************************
; Set line spacing
;  D2 contains the number of 1/2 lines
;
PDSLSP: MOVW    D2,LSPSAV(A3)           ; save for later
       RTN

PAGE
;************************
;*      PDMTOF          *
;************************
; Move to Top of Form and setup for new page
;
PDMTOF: CLR     D7
       MOVW    LPPSAV(A3),D7           ; get lines per page
       ADD     D7,D7                   ; convert to number of 1/2 lines
       CMP     D7,CURLIN(A3)           ; are we already at new page ?
       BEQ     10$                     ;   yes, don't output a Form Feed
       PUSHB   D1                      ; save register
       MOVB    #$FF,D1
       FILOTB  PTDDB(A3)               ; output a Form Feed
       POPB    D1                      ; restore register
10$:    CLR     CURLIN(A3)              ; at start of page
       RTN

PAGE
;************************
;*      PDMNLN          *
;************************
; Move to Next Line and setup for new line
;
PDMNLN: SAVE    D1,D2
       CALL    BLDTST                  ; go output bold (if any)
;[AO1]  CALL    UNDTST                  ; go output underline (if any)
       CALL    STKTST                  ; go output strikout (if any)
;[105]  MOVB    #$CR,D1
;[105]  FILOTB  PTDDB(A3)               ; output the CR
       CLRW    CURCOL(A3)              ; back to column 0
       MOVW    LSPSAV(A3),D2           ; get current line spacing
       ADDW    #1,D2                   ; round it up
       LSRW    D2,#1                   ; convert to number of whole LFs
       BR      20$                     ; enter at end of loop

10$:    ADD     #2.,CURLIN(A3)          ; bump current line number by full line
       MOVB    #$CR,D1                 ; output a carriage return              [105]
       FILOTB  PTDDB(A3)               ;                                       [105]
       MOVB    #$LF,D1                 ;                                       [105]
       FILOTB  PTDDB(A3)               ; output the LF
20$:    DBF     D2,10$                  ;  and loop until done

       REST    D1,D2
       RTN

PAGE
;************************
;*      PDUNDR          *
;************************
; Toggle Underscore  [AO1] Modified
;
PDUNDR: LEA     A6,UNDON                ; assume we are enabling underscore
       BCHG    #FM%UND,FM.FLG(A3)      ; toggle underscore
       BEQ     UNDR1                   ;  and go do it if end of field
       LEA     A6,UNDOFF               ; turn it off
UNDR1:  JMP     STROUT

; Enable Auto Underscore  [AO3]
UNDON:  BYTE    3.
       BYTE    27.,45.,1.
       EVEN
; Disable Auto Underscore [A03]
UNDOFF: BYTE    3.
       BYTE    27.,45.,0.
       EVEN
PAGE
;************************
;*      PDBOLD          *
;************************
; Toggle Bold
;
PDBOLD: BCHG    #FM%BLD,FM.FLG(A3)      ; bold enabled ?
       BNE     BLDOUT                  ;  and go do it if end of field
       MOVW    CURCOL(A3),BLDCOL(A3)   ;   or set field start
       LEA     A6,BLDBUF(A3)           ; index the bold buffer
       MOV     A6,BLDPTR(A3)           ;  and save
       RTN

; Test of bold and output it if true
;
BLDTST: BTST    #FM%BLD,FM.FLG(A3)      ; bold active ?
       BEQ     BLDOTX                  ;   no, just return

; Setup to do bold & then do it
;
BLDOUT: SAVE    A2,D1-D2
       MOV     BLDPTR(A3),A2           ; index the buffer
       CLRB    @A2                     ; terminate the bold string
       CALL    BLDIT                   ; output bold string
       CALL    BLDIT                   ; output bold string
       REST    A2,D1-D2
BLDOTX: LEA     A6,BLDBUF(A3)           ; index the start of the buffer
       MOV     A6,BLDPTR(A3)
       CLRW    BLDCOL(A3)
       RTN

; Do the actual bold output
;
BLDIT:  MOVB    #$CR,D1                 ; get a carriage return
       FILOTB  PTDDB(A3)               ;  and output it

; Output leading spaces until start of bold field
;
       MOVW    BLDCOL(A3),D2           ; get start of bold field
       MOVB    #32.,D1                 ; [AO3]get a space
       BR      15$                     ;  and enter loop at end

10$:    FILOTB  PTDDB(A3)               ; output a space
15$:    DBF     D2,10$                  ; loop until start of bold field

; Output the required bold string
;
       LEA     A2,BLDBUF(A3)           ; index the bold buffer

20$:    MOVB    (A2)+,D1                ; get a character from bold string
       BEQ     99$                     ;   terminate on null
       FILOTB  PTDDB(A3)               ; output a character
       BR      20$                     ;   loop until null

99$:    RTN

PAGE
;************************
;*      PDSTRK          *
;************************
; Toggle strikeout
;
PDSTRK: BCHG    #FM%STK,FM.FLG(A3)      ; toggle strikeout flag
       BNE     STKOUT                  ;  and go do it if end of field
       MOVW    CURCOL(A3),STKCOL(A3)   ;   or set field start
       MOVB    D1,STKCHR(A3)           ; save strikeout character
       RTN

; Test for strikeout and output it if true
;
STKTST: BTST    #FM%STK,FM.FLG(A3)      ; strikeout active ?
       BEQ     STKOTX                  ;   no, just return

; Output everything up to here & return the carriage home
;
STKOUT: SAVE    D1,D2
       MOVB    #$CR,D1                 ; get a carriage return
       FILOTB  PTDDB(A3)               ;  and output it

; Output leading spaces until start of strikeout field
;
       MOVW    STKCOL(A3),D2           ; get start of strikeout field
       MOVB    #32.,D1                 ; [AO3]get a space
       BR      15$                     ;  and enter loop at end

10$:    FILOTB  PTDDB(A3)               ; output a space
15$:    DBF     D2,10$                  ; loop until start of strikeout field

; Output the required number of strikeout
;
       MOVW    CURCOL(A3),D2           ; get field end
       SUBW    STKCOL(A3),D2           ;  and calculate field length
       MOVB    STKCHR(A3),D1           ; get strikeout character
       BR      25$                     ;  and enter loop at end

20$:    FILOTB  PTDDB(A3)               ; output an strikeout
25$:    DBF     D2,20$                  ; loop until end of strikeout field
       REST    D1,D2
STKOTX: CLRW    STKCOL(A3)
       RTN

PAGE

;************************
;*      PDSCPI          *
;************************
; Set Characters Per Inch (added [AO1])
;  D2 contains the numbers of characters per inch (pitch)
;
PDSCPI: CMPW    D2,CPISAV(A3)           ; new CPI the same as old ?
       JEQ     CPIOK                   ;CHANGE BRANCH TO JUMP[A03]
       MOVW    D2,CPISAV(A3)           ; Save new CPI
       CMPW    D2,#1.                  ; [AO3] IF 1 THEN SINGLE HEIGHT
       JEQ     NORM1                   ; AND SINGLE WIDTH @ 10 PITCH
       CMPW    D2,#2.                  ; [AO3] IF 2 THEN DOUBLE WIDTH
       JEQ     DOUB1                   ; AND SINGLE HEIGHT
       CMPW    D2,#3.                  ; [AO3] IF 3 THEN TRIPLE WIDTH
       JEQ     TRIP1                   ; AND SINGLE HEIGHT
       CMPW    D2,#4.                  ; [AO3] IF 4 THEN SINGLE WIDTH
       JEQ     NORM2
                       ; AND DOUBLE HEIGHT
       CMPW    D2,#5.                  ; [AO3] IF 5 THEN DOUBLE WIDTH
       JEQ     DOUB2                   ; AND DOUBLE HEIGHT
       CMPW    D2,#6.                  ; [AO3] IF 6 THEN TRIPLE WIDTH
       JEQ     TRIP2                   ; AND DOUBLE HEIGHT
       CMPW    D2,#7.                  ; [AO3] IF 7 THEN SINGLE WIDTH
       JEQ     NORM3                   ; AND TRIPLE HEIGHT
       CMPW    D2,#8.                  ; [AO3] IF 8 THEN DOUBLE WIDTH
       JEQ     DOUB3                   ; AND TRIPLE HEIGHT
       CMPW    D2,#9.                  ; [AO3] IF 8 THEN TRIPLE WIDTH
       JEQ     TRIP3                   ; AND TRIPLE HEIGHT
;       CMPW    D2,#13.                 ; [AO3] IF 13 THEN SUPER SCRIPT IS ON
;       JEQ     ITAON
;       CMPW    D2,#14.                 ; [AO3] IF 14 THEN SUB SCRIPT IS ON
;       JEQ     ITAOFF
;       CMPW    D2,#15.                 ; [AO3] IF 15 THEN SUPER/SUB SCRIPT OFF
;       JEQ     PITC15
       CMPW    D2,#16.                 ; [AO3] IF 16 THEN 17PITCH IS OFF
       JEQ     OFF17
       CMPW    D2,#17.                 ; [AO3] IF 16 THEN 17PITCH IS OFF
       JEQ     ON17
       CMPW    D2,#18.                 ; [AO3] IF 18 THEN HIGH SPEED ON
       JEQ     HS
       CMPW    D2,#19.                 ; [AO3] IF 19 THEN NEAR LETTER QUALITY
       JEQ     NLQ
       CMPW    D2,#20.                 ; [AO3] IF 20 THEN UTILIY MODE IS ON
       JEQ     UTILIT
       CMPW    D2,#21.                 ; [AO3] IF 21 THEN LQ MODE IS ON
       JEQ     LQ
       CMPW    D2,#22.                 ; [AO3] IF 22 THEN emphasized ON
       JEQ     EMPHAS
       CMPW    D2,#23.                 ; [AO3] IF 23 THEN EMPHASIZED OFF
       JEQ     EMPOFF
       CMPW    D2,#24.                 ; [AO3] IF 24 THEN RESIDENT IS ON
       JEQ     RESID
       CMPW    D2,#25.                 ; [AO3] IF 25 THEN COURIER PRESTIGE ON
       JEQ     PREST
       CMPW    D2,#26.                 ; [AO3] IF 26 THEN COURIER LETTER ON
       JEQ     LETTER
       CMPW    D2,#27.                 ; [AO3] IF 27 THEN GOTHIC RESIDENT ON
       JEQ     GRESID
       CMPW    D2,#28.                 ; [AO3] IF 28 THEN GOTHIC IS ON
       JEQ     GOTHIC
       CMPW    D2,#30.                 ; [AO3] IF 30 THEN NORMAL IS ON
       JEQ     SUB                     ; 10PITCH,SINGLE SPACING/HEIGHT
       CMPW    D2,#31.                 ; [AO3] IF 30 THEN NORMAL IS ON
       JEQ     SUPER                   ; 10PITCH,SINGLE SPACING/HEIGHT
       CMPW    D2,#32.                 ; [AO3] IF 30 THEN NORMAL IS ON
       JEQ     SUBOFF                  ; 10PITCH,SINGLE SPACING/HEIGHT
       CMPW    D2,#33.                 ; [AO3] IF 30 THEN NORMAL IS ON
       JEQ     BUZZER                  ; 10PITCH,SINGLE SPACING/HEIGHT
       CMPW    D2,#34.                 ; [AO3] IF 30 THEN NORMAL IS ON
       JEQ     RESET                   ; 10PITCH,SINGLE SPACING/HEIGHT
       LEA     A6,CPI10                ; [AO3] Index 10CPI string
       CMPW    D2,#10.
       JEQ     CPISTR                  ; was 10 CPI
;       MOVW    #$SO,D1                 ; [AO3]Double Width Printing
;       CMPW    D2,#9.                  ; If 9 or lower, just go into double wide
;       JLOS    CPIDO                   ; 9 or lower
       LEA     A6,CPI12
       CMPW    D2,#12.                 ; 12 CPI?
       JLOS    CPISTR                  ;  yes, was 11 or 12
ON17:   MOVB    #$SI,D1                 ; [AO3]Default for 17 CPI
CPIDO:  FILOTB  PTDDB(A3)
CPIOK:  RTN

CPISTR: JMP     STROUT                  ; [AO3] Send string out

;THIS IS MY CHUMP CHANGE MACRO SECTION I WOULD HAVE DONE THIS EARLIER BUT
;I DIDN'T KNOW ENOUGH OF THIS ASSEMLBY STUFF TO DOIT SO I WILL NOWWWWWWW
;
;SHOULD ONE WANT TO MAKE A CHANGE [GOD FORBID] MAKE A MACRO AND CALL IT
;JUST LIKE I DID .....................................................

DEFINE  CANWID
       MOVB    #^D27,D1                ; DIGIT!!!!!!!!!!!
       FILOTB  PTDDB(A3)               ; THIS WILL CANCEL
       MOVB    #^D87,D1                ; DOUBLE /TRIPLE WIDE
       FILOTB  PTDDB(A3)               ; CHARACTER DISPLAY
       MOVB    #^D0,D1                 ; LAST BYTE TO PRINTER
       FILOTB  PTDDB(A3)
ENDM

DEFINE  TENPIT
       MOVB    #^D27,D1                ; SET UP PICA
       FILOTB  PTDDB(A3)               ; 10 PITCH
       MOVB    #^D80,D1                ; RIGHT HERE
       FILOTB  PTDDB(A3)               ;
ENDM

DEFINE  QUALIT
       MOVB    #^D27,D1                ; [AO3] 1ST NORMAL BYTE IS
       FILOTB  PTDDB(A3)               ; FILE OUT TO PRINTER
       MOVB    #^D120,D1               ; THIS IS LETTER QUALITY
       FILOTB  PTDDB(A3)               ; RIGHT DOWN
       MOVB    #^D1,D1                 ; HERE; PUMP IT UP SHLOMEBOY
       FILOTB  PTDDB(A3)
ENDM

;SET=0 {NORMAL HEIGHT}; SET=1 {DOUBLE HEIGHT}; SET=2 {TRIPLE HEIGHT}
DEFINE  HEIGHT  SET
       MOVB    #^D27,D1                ; [AO3] 1ST NORMAL BYTE IS
       FILOTB  PTDDB(A3)               ; FILE OUT TO PRINTER
       MOVB    #^D31,D1                ; NORMAL HIEGHT IS WHAT THIS
       FILOTB  PTDDB(A3)               ; MACRO IS ALL ABOUT
       MOVB    SET,D1                  ; WOW!!!!!!!!!!!!!!!!!!!
       FILOTB  PTDDB(A3)
ENDM

DEFINE  SETDOU
       MOVB    #^D27,D1                ; [AO3] 1ST NORMAL BYTE IS
       FILOTB  PTDDB(A3)               ; FILE OUT TO PRINTER
       MOVB    #^D87,D1                ; SET DOULBE WIDTH SHLOMES
       FILOTB  PTDDB(A3)               ; PRINTER
       MOVB    #^D1,D1                 ; WE'RE HERE?????????????
       FILOTB  PTDDB(A3)
ENDM

DEFINE  SETTRI
       MOVB    #^D27,D1                ; SET TRIPLE WIDTH
       FILOTB  PTDDB(A3)               ; YEA THAT'S RIGHT
       MOVB    #^D109,D1               ; 2ND NORMAL BYTE OUT TO
       FILOTB  PTDDB(A3)               ; PRINTER
ENDM

;PITCH = 1
;SINGLE HEIGHT SPACING WITH 10PITCH
NORM1:
       CANWID                          ; CANCEL DOUBLE/TRIPLE WIDE
       TENPIT                          ; TEN PITCH
;GDC    QUALIT  ;SPECIFY ME SEPERATLY   ; LETTER QUALITY
       HEIGHT  #^D0                    ; NORMAL HIEGHT; NO WHAT I'M SAYING?
       RTN

;PITCH = 2
;SINGLE HEIGHT / DOUBLE WIDTH SPACING
DOUB1:
       CANWID                          ; CANCEL THAT NASTY OL' DOUBLE/TRIPLE
       SETDOU                          ; SET DOUBLE WIDTH
;GDC    QUALIT  ;SPEICFIY SEPERATLY     ; LETTER QUALITY
       HEIGHT  #^D0                    ; NORMAL HEIGHT;  WHATEVER NORMAL IS?
       RTN

;PITCH = 3
;SINGLE HEIGHT / TRIPLE WIDTH
TRIP1:
       CANWID                          ; CANCEL DOUBLE/TRIPLE
       SETTRI                          ; SET TRIPLE WIDTH
;GDC    QUALIT                          ; LETTER QUALITY
       HEIGHT  #^D0                    ; NORMAL HEIGHT
       RTN

;PITCH = 4
;DOUBLE HEIGHT / SINGLE WIDTH SPACING
NORM2:
       CANWID                          ; CANCEL DOUBLE/TRIPLE WIDTH
       HEIGHT  #^D1                    ; DOUBLE HEIGHT ;HOW DOES HE DOIT?
;GDC    QUALIT                          ; LETTER QUALITY
       TENPIT                          ; SINGLE WIDTH
       RTN

;PITCH = 5
;DOUBLE HEIGHT / DOUBLE WIDTH SPACING
DOUB2:
       CANWID                          ; CANCEL DOUBLE/TRIPLE WIDTH
       HEIGHT  #^D1                    ; SET DOUBLE HEIGHT
;GDC    QUALIT                          ; LETTER QUALITY
       SETDOU                          ; SET DOUBLE WIDTH
       RTN

;PITCH = 6
;DOUBLE HEIGHT / TRIPLE WIDTH SPACING
TRIP2:
       CANWID                          ; CANCEL DOUBLE/TRIPLE WIDTH
       HEIGHT  #^D1                    ; SET DOUBLE HEIGHT = 1
;GDC    QUALIT                          ; LETTER QUALITY
       SETTRI                          ; SET TRIPLE WIDTH SPACING
       RTN

;PITCH = 7
;TRIPLE HEIGHT / SINGLE WIDTH SPACING
NORM3:
       CANWID                          ; CANCEL DOUBLE/TRIPLE WIDTH
       HEIGHT  #^D2                    ; SET TRIPLE HEIGHT = 2
;GDC    QUALIT                          ; LETTER QUALITY
       TENPIT                          ; SINGLE SPACING
       RTN

;PITCH = 8
;TRIPLE HEIGHT / DOUBLE WIDTH SPACING
DOUB3:
       CANWID                          ; CANCEL DOUBLE/TRIPLE WIDTH
       HEIGHT  #^D2                    ; SET TRIPLE HEIGHT
;GDC    QUALIT                          ; LETTER QUALITY
       SETDOU                          ; SET DOUBLE WIDTH
       RTN

;PITCH = 9
;TRIPLE HEIGHT / TRIPLE WIDTH SPACING
TRIP3:
       CANWID                          ; CANCEL DOUBLE/TRIPLE WIDTH
       HEIGHT  #^D2                    ; SET TRIPLE HEIGHT
;GDC    QUALIT                          ; LETTER QUALITY
       SETTRI                          ; SET TRIPLE WIDTH
       RTN

ITAON:  MOVB    #^D27,D1                ; [AO3] 1ST ITALIC BYTE IS
       FILOTB  PTDDB(A3)               ; FILE OUT TO PRINTER
       MOVB    #^D52,D1                ; 2ND ITALIC BYTE OUT TO
       FILOTB  PTDDB(A3)               ; PRINTER
       RTN

ITAOFF: MOVB    #^D27,D1                ; [AO3] 1ST ITALIC OFF BYTE IS
       FILOTB  PTDDB(A3)               ; FILE OUT TO PRINTER
       MOVB    #^D53,D1                ; 2ND ITALIC OFF BYTE OUT TO
       FILOTB  PTDDB(A3)               ; PRINTER
       RTN

SUPER:  MOVB    #^D27,D1                ; [AO3] 1ST DOUBLE BYTE IS
       FILOTB  PTDDB(A3)               ; FILE OUT TO PRINTER
       MOVB    #^D83,D1                ; 2ND DOUBLE BYTE OUT TO
       FILOTB  PTDDB(A3)               ; PRINTER
       MOVB    #^D0,D1                 ; LAST BYTE TO PRINTER
       FILOTB  PTDDB(A3)
       RTN

SUB:    MOVB    #^D27,D1                ; [AO3] 1ST DOUBLE BYTE IS
       FILOTB  PTDDB(A3)               ; FILE OUT TO PRINTER
       MOVB    #^D83,D1                ; 2ND DOUBLE BYTE OUT TO
       FILOTB  PTDDB(A3)               ; PRINTER
       MOVB    #^D1,D1                 ; LAST BYTE TO PRINTER
       FILOTB  PTDDB(A3)
       RTN

SUBOFF: MOVB    #^D27,D1                ; [AO3] 1ST DOUBLE BYTE IS
       FILOTB  PTDDB(A3)               ; FILE OUT TO PRINTER
       MOVB    #^D84,D1                ; 2ND DOUBLE BYTE OUT TO
       FILOTB  PTDDB(A3)               ; PRINTER
       RTN


OFF17:  MOVB    #^D18,D1                ; [AO3] 1ST ITALIC OFF BYTE IS
       FILOTB  PTDDB(A3)               ; FILE OUT TO PRINTER
       RTN

HS:     MOVB    #^D27,D1                ; [AO3] 1ST DOUBLE BYTE IS
       FILOTB  PTDDB(A3)               ; FILE OUT TO PRINTER
       MOVB    #^D40,D1                ; 2ND DOUBLE BYTE OUT TO
       FILOTB  PTDDB(A3)               ; PRINTER
       MOVB    #^D0,D1                 ; LAST BYTE TO PRINTER
       FILOTB  PTDDB(A3)
       RTN

NLQ:    MOVB    #^D27,D1                ; [AO3] 1ST DOUBLE BYTE IS
       FILOTB  PTDDB(A3)               ; FILE OUT TO PRINTER
       MOVB    #^D40,D1                ; 2ND DOUBLE BYTE OUT TO
       FILOTB  PTDDB(A3)               ; PRINTER
       MOVB    #^D2,D1                 ; LAST BYTE TO PRINTER
       FILOTB  PTDDB(A3)
       RTN

UTILIT: MOVB    #^D27,D1                ; [AO3] 1ST DOUBLE BYTE IS
       FILOTB  PTDDB(A3)               ; FILE OUT TO PRINTER
       MOVB    #^D120,D1               ; 2ND DOUBLE BYTE OUT TO
       FILOTB  PTDDB(A3)               ; PRINTER
       MOVB    #^D0,D1                 ; LAST BYTE TO PRINTER
       FILOTB  PTDDB(A3)
       RTN

LQ:
       QUALIT                          ; LETTER QUALITY MACRO
       RTN

EMPHAS: MOVB    #^D27,D1                ; [AO3] 1ST DOUBLE BYTE IS
       FILOTB  PTDDB(A3)               ; FILE OUT TO PRINTER
       MOVB    #^D69,D1                ; 2ND DOUBLE BYTE OUT TO
       FILOTB  PTDDB(A3)               ; PRINTER
       RTN

EMPOFF: MOVB    #^D27,D1                ; [AO3] 1ST DOUBLE BYTE IS
       FILOTB  PTDDB(A3)               ; FILE OUT TO PRINTER
       MOVB    #^D70,D1                ; 2ND DOUBLE BYTE OUT TO
       FILOTB  PTDDB(A3)               ; PRINTER
       RTN

RESID:  MOVB    #^D27,D1                ; [AO3] 1ST DOUBLE BYTE IS
       FILOTB  PTDDB(A3)               ; FILE OUT TO PRINTER
       MOVB    #^D107,D1               ; 2ND DOUBLE BYTE OUT TO
       FILOTB  PTDDB(A3)               ; PRINTER
       MOVB    #^D2,D1                 ; LAST BYTE TO PRINTER
       FILOTB  PTDDB(A3)
       RTN

PREST:  MOVB    #^D27,D1                ; [AO3] 1ST DOUBLE BYTE IS
       FILOTB  PTDDB(A3)               ; FILE OUT TO PRINTER
       MOVB    #^D107,D1               ; 2ND DOUBLE BYTE OUT TO
       FILOTB  PTDDB(A3)               ; PRINTER
       MOVB    #^D3,D1                 ; LAST BYTE TO PRINTER
       FILOTB  PTDDB(A3)
       RTN

LETTER: MOVB    #^D27,D1                ; [AO3] 1ST DOUBLE BYTE IS
       FILOTB  PTDDB(A3)               ; FILE OUT TO PRINTER
       MOVB    #^D107,D1               ; 2ND DOUBLE BYTE OUT TO
       FILOTB  PTDDB(A3)               ; PRINTER
       MOVB    #^D6,D1                 ; LAST BYTE TO PRINTER
       FILOTB  PTDDB(A3)
       RTN

GRESID: MOVB    #^D27,D1                ; [AO3] 1ST DOUBLE BYTE IS
       FILOTB  PTDDB(A3)               ; FILE OUT TO PRINTER
       MOVB    #^D107,D1               ; 2ND DOUBLE BYTE OUT TO
       FILOTB  PTDDB(A3)               ; PRINTER
       MOVB    #^D126,D1               ; LAST BYTE TO PRINTER
       FILOTB  PTDDB(A3)
       RTN

GOTHIC: MOVB    #^D27,D1                ; [AO3] 1ST DOUBLE BYTE IS
       FILOTB  PTDDB(A3)               ; FILE OUT TO PRINTER
       MOVB    #^D107,D1               ; 2ND DOUBLE BYTE OUT TO
       FILOTB  PTDDB(A3)               ; PRINTER
       MOVB    #^D127,D1               ; LAST BYTE TO PRINTER
       FILOTB  PTDDB(A3)
       RTN

BUZZER: MOVB    #^D7,D1                ; [AO3] 1ST DOUBLE BYTE IS
       FILOTB  PTDDB(A3)               ; FILE OUT TO PRINTER
       RTN

RESET:  MOVB    #^D27,D1                ; [AO3] 1ST DOUBLE BYTE IS
       FILOTB  PTDDB(A3)               ; FILE OUT TO PRINTER
       MOVB    #^D64,D1                ; 2ND DOUBLE BYTE OUT TO
       FILOTB  PTDDB(A3)               ; PRINTER
       RTN

; Setup 10 CPI codes  [AO3]
CPI10:  BYTE    2.
       BYTE    27.,80.
       EVEN
; Setup 12 CPI codes  [A03]
CPI12:  BYTE    2.
       BYTE    27.,77.
       EVEN


;************************
;*      PDOVRP          *
;************************
; Setup to overprint the last character
;
PDOVRP: SAVE    D1,D2
       MOVB    #$CR,D1                 ; get a carriage return
       FILOTB  PTDDB(A3)               ;  and output it

; Output leading spaces until positioned over last character
;
       MOVW    CURCOL(A3),D2           ; get start position of last char.
       BEQ     5$
       SUBW    #1,D2                   ; adjust to actual column number
       MOVW    D2,CURCOL(A3)
5$:     MOVB    #32.,D1                 ; get a space[AO3]
       BR      15$                     ;  and enter loop at end

10$:    FILOTB  PTDDB(A3)               ; output a space
15$:    DBF     D2,10$                  ; loop until positioned over last char
       REST    D1,D2
       RTN

PAGE
;*********************
;* Carriage Movement *
;*********************

; Move to Absolute Horizontal Tab
;
MOVAHT: BYTE    0

; Return carriage home
;
CHOME:  BYTE    1.                      ; string length
       BYTE    $CR

PAGE
;******************
;* Paper Movement *
;******************

; Roll up a partial line (positive)
;
ROLUP:  BYTE    0.                      ; string length

; Roll down a partial line (negative)
;
ROLDWN: BYTE    0.                      ; string length

;Output a negative line feed
;
NEGLF:  BYTE    0.                      ; string length

PAGE
;**************************
;* Miscellaneous Commands *
;**************************

; Print in Secondary ribbon color 1
;[AO4]
RIBSC1: BYTE    3.                      ; string length
       BYTE    27.,120.,1.             ; Correspondance Quality

; Print in Secondary ribbon color 2
;
RIBSC2: BYTE    3.                      ; string length
       BYTE    27.,120.,0.             ; Overstrike Printing

; Print in Secondary ribbon color 3
;
RIBSC3: BYTE    3.                      ; string length
       BYTE    27.,40.,2.              ; Stop Overstrike Printing

; Print in Primary ribbon color (black)
;
RIBPRM: BYTE    3.                      ; string length
       BYTE    27.,40.,0               ; Data Processing Characters

; Output character at special print position 0
;
SPLPT0: BYTE    0.                      ; string length

; Output character at special print position 1
;
SPLPT1: BYTE    0.                      ; string length

PAGE
;************************
;* Cut Sheet Feeder     *
;************************

; Select feeder tray 1
;
FEDTR1: BYTE    3.              ; string length
       BYTE    27.,25.,1.      ; character string

; Select feeder tray 2
;
FEDTR2: BYTE    3.              ; string length
       BYTE    27.,25.,2.      ; charcter string

; Select feeder tray 3
;
FEDTR3: BYTE    0.                      ; string length

; Select feeder tray 4
;
FEDTR4: BYTE    0.                      ; string length

; Select feeder tray 1 & then tray 2 thereafter
;
FEDTGL: BYTE    0.                      ; string length

; Select feeder eject
;
FEDEJT: BYTE    0.                      ; string length

PAGE
;**************************
;* Special User Functions *
;**************************

; Output user function 1
;
USR1:   BYTE    2.                      ; string length
       BYTE    27.,52.                 ; Data Processing Characters

; Output user function 2
;
USR2:   BYTE    2.                      ; string length
       BYTE    27.,53.                 ; Data Processing Characters

; Output user function 3
;
USR3:   BYTE    0.                      ; string length

; Output user function 4
;
USR4:   BYTE    0.                      ; string length

       EVEN                            ; module must end on word boundary

       END