home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / PROGRAMS / WSTAR / SIMPLE.ARK / SIMPLE.MAC < prev    next >
Text File  |  1987-07-06  |  31KB  |  1,887 lines

  1. TITLE    SIMPLE printer driver for WS4, CP/M
  2.  
  3. ;
  4. ; Submit DRIVER.SUB to build a SIMPLE.DRV file that can be included in the
  5. ; WSPRINT.OVR file using WSCHANGE.
  6. ;
  7.  
  8. IF1
  9. .PRINTX -SIMPLE, 06 Jul 87-
  10. ELSE
  11. .PRINTX -Pass 2-
  12. ENDIF
  13.  
  14.     ASEG
  15.     ORG    8680H        ; Fixed load point for WS4 #21
  16. ;
  17. ; Equates
  18. ;
  19. TPA    EQU    100H        ; Where TPA starts for WordStar
  20.  
  21. ;
  22. ; Special Characters
  23. ;
  24. CR    EQU    0DH        ; Carriage return
  25. LF    EQU    0AH        ; Line feed
  26. EOF    EQU    1AH        ; End of file mark
  27. BS    EQU    08H        ; Backspace
  28. DEL    EQU    7FH        ; Delete
  29. ESC    EQU    1BH        ; Escape
  30. BESC    EQU    1CH        ; Back escape
  31. TAB    EQU    09H        ; Tab
  32. FFEED    EQU    0CH        ; Form feed
  33. SOFTHY    EQU    1EH        ; Soft hyphen
  34. HARDHY    EQU    1FH        ; Hard hyphen
  35. ;
  36. SOFTCR    EQU    10000000B+CR    ; Soft carriage return
  37. SOFTAB    EQU    10000000B+TAB    ; Soft tab (for ^P)
  38. SOFTLF    EQU    10000000B+LF    ; Soft line feed
  39. SOFTFF    EQU    10000000B+FFEED    ; Soft form feed
  40. SOFTBL    EQU    10000000B+' '    ; Soft blank
  41.  
  42. ;
  43. ; Variable Data Sizes
  44. ;
  45. TABMAX    EQU    15        ; Maximum tabs
  46. DECMAX    EQU    6        ; Maximum decimal tabs
  47. RLRSIZ    EQU    TABMAX+DECMAX+5    ; Ruler size  08may84
  48.  
  49. ;
  50. ; Standard WordStar List Output Routines
  51. ;
  52. SIBASE    EQU    280h
  53. LSTOUT    EQU    SIBASE+6    ; Prints char in A.
  54. ;
  55. LSOSTA    EQU    SIBASE+9    ; Returns output status to A (0 if busy).
  56. ;
  57. LSTRNG    EQU    SIBASE+12h    ; Send string to list device (count byte
  58.                 ; first, just like console strings).
  59.  
  60. ;
  61. ; Printer Driver Entry Points
  62. ;
  63. ;    Note that WordStar expects this table to appear exactly
  64. ;    in this order.
  65. ;
  66. PGORG:    DB    0        ; Driver model
  67.     DW    PGLEN        ; Code length
  68.     DW    PDLEN        ; Code + unitialize data length
  69.     DW    $LEN        ; String length
  70.     DW    $SYMTAB        ; Symbol table address
  71.     DB    'SIMPLE',0    ; Driver name
  72.     DW    0        ; Default output file name address
  73.  
  74.     JMP    PRINITZ        ; Initialize printer
  75.     JMP    PRINT        ; Print a line
  76.     JMP    PRESUME        ; Resume printing
  77.     JMP    PRABORT        ; Abort printing
  78.     JMP    PRUNITZ        ; Uninitialize when done printing
  79.  
  80.     PAGE
  81. ;
  82. ; Initialize
  83. ;
  84. ;    On entry: HL -> table of printer information
  85. ;          DE -> user strings
  86. ;          A is TRUE if form feeds are okay
  87. ;
  88. ;    Note that even though this simple driver does not use all of
  89. ;    the information, the entire table is defined below.
  90. ;
  91. ;    Do not modify values in the table.  WordStar updates the table
  92. ;    values while printing.
  93. ;
  94. PRINITZ:
  95.     SHLD    PRTABLE        ; Store table address
  96.     XCHG
  97.     SHLD    PRUSER
  98. ;
  99.     STA    PRFFOK        ; Form feed flag
  100. ;
  101.     XRA    A        ; Assume we're at top of first page
  102.     STA    PRLINE        ; No lines on page
  103.     STA    PRCOLM        ; At leftmost column
  104.     STA    PRFFL        ; No form feed lines
  105.     STA    PRHALF        ; No half line feed yet
  106.     STA    PRONOFF        ; No print controls on
  107.     STA    PRSSIZ        ; No string to print
  108.     STA    PR2ND        ; No second character
  109.     STA    PREXTX        ; Not an extended character
  110.     STA    PRSTRT
  111. ;
  112.     LXI    H,XTOGL        ; Zero init attr states
  113.     MVI    C,XTOGZ
  114. PRINZ1:    MOV    M,A
  115.     INX    H
  116.     DCR    C
  117.     JNZ    PRINZ1
  118. ;
  119.     DCR    A
  120.     STA    PRLQCH        ; Force PRLQ call
  121.     STA    PRTYPX        ; No last type for line
  122.     MVI    A,1
  123.     STA    PRNEXZ        ; Skip 1 byte / char
  124. ;
  125.     CALL    GETSIZ
  126. PRINI1:    XRA    A
  127.     RET
  128. ;
  129. ; Print Value Table Offsets
  130. ;
  131. PAGTOP    EQU    0        ; Top page margin
  132. PAGBOT    EQU    PAGTOP+1    ; Bottom page margin
  133. PAGSIZ    EQU    PAGBOT+1    ; Page size
  134. PAGNMT    EQU    PAGSIZ+1    ; Page number at top
  135. PAGON    EQU    PAGNMT+2    ; Page number on/off flag
  136. PAGNMP    EQU    PAGON+1        ; Column where page number prints
  137. HDMAR    EQU    PAGNMP+1    ; Heading margin
  138. FTMAR    EQU    HDMAR+1        ; Footing margin
  139. TBMASK    EQU    FTMAR+1        ; Tab mask
  140. PAGMAR    EQU    TBMASK+1    ; Left page margin
  141. PRNNLQ    EQU    PAGMAR+1    ; Near letter quality on/off
  142. PRNBID    EQU    PRNNLQ+1    ; Print bidirectional on/off
  143. PRNMIC    EQU    PRNBID+1    ; Microjustified print on/off
  144. PRNUNL    EQU    PRNMIC+1    ; Underline blanks on/off
  145. PRNHMI    EQU    PRNUNL+1    ; Standard character width (in HMI units)
  146. PRNVMI    EQU    PRNHMI+1    ; Standard line height (in VMI units)
  147. CHRWID    EQU    PRNVMI+1    ; Character width (in HMI units)
  148. ALTWID    EQU    CHRWID+1    ; Alternate pitch width (in HMI units)
  149. SSROLL    EQU    ALTWID+1    ; Subscript/superscript roll (in VMI units)
  150. LINEHT    EQU    SSROLL+1    ; Line height (in VMI units)
  151. LFMAR    EQU    LINEHT+1    ; Left margin
  152. RTMAR    EQU    LFMAR+1        ; Right margin
  153. PPMAR    EQU    RTMAR+1        ; Number of tabs
  154. TABS    EQU    PPMAR+1        ; Number of tabs
  155. DECS    EQU    TABS+1+TABMAX    ; Number of decimal tabs
  156. POCW    EQU    DECS+1+DECMAX    ; Page offset char width
  157. HENCW    EQU    POCW+1        ; Header normal char width
  158. HEACW    EQU    HENCW+1        ; Header alternate char width
  159. FONCW    EQU    HEACW+1        ; Footer normal char width
  160. FOACW    EQU    FONCW+1        ; Footer alternate char width
  161. HELH    EQU    FOACW+1        ; Header line height
  162. FOLH    EQU    HELH+1        ; Footer line height
  163. PROP    EQU    FOLH+1        ; Proportional spacing
  164. PAGNUM    EQU    PROP+1        ; Page number
  165. PAGVMI    EQU    PAGNUM+2    ; VMI units of text on a page (minus margins)
  166. VMICNT    EQU    PAGVMI+2    ; Current VMI count
  167. TOPVMI    EQU    VMICNT+2    ; VMI units in top margin
  168. BOTVMI    EQU    TOPVMI+2    ; VMI units in bottom margin
  169. LNHITE    EQU    BOTVMI+2    ; LINEHT with MS byte zero
  170. ALTPCH    EQU    LNHITE+2    ; Alternate pitch on/off
  171. HEPROP    EQU    ALTPCH+1    ; Header proportional flag
  172. HENLQ    EQU    HEPROP+1    ; Header NLQ
  173. FOPROP    EQU    HENLQ+1        ; Footer proportional flag
  174. FONLQ    EQU    FOPROP+1    ; Footer NLQ
  175. SHTBIN    EQU    FONLQ+1        ; Sheet feeder bin
  176. ;
  177.     PAGE
  178. ;
  179. ; Print a Line
  180. ;
  181. ;    On entry: HL points to start of a line of characters
  182. ;          DE contains the number of characters in the line
  183. ;          A contains the line type code & suppress printing
  184. ;            flag (MSB of A is 1 to suppress)
  185. ;
  186. ;    Type codes:    0 = line from body of text
  187. ;            1 = header line
  188. ;            2 = footer line
  189. ;
  190. ;    On exit:  A contains a return code
  191. ;
  192. ;    Return code:    0 = done printing line
  193. ;            1 = not done printing, printer is busy
  194. ;            2 = pause required, operator should resume printing
  195. ;
  196. PRINT:
  197.     SHLD    PRCHAR        ; Store pointer to current char
  198. ;
  199.     XCHG            ; Store count
  200.     SHLD    PRCOUNT
  201. ;
  202.     STA    PRTYPE        ; Store type code
  203.     ANI    7Fh
  204.     CPI    3        ; Dot command?
  205.     JZ    PRINI1
  206. ;
  207.     PUSH    PSW
  208.     LHLD    PRTABLE        ; Get page offset, space in before the
  209.     LXI    D,PAGMAR    ;    next printing character
  210.     DAD    D
  211.     MOV    A,M
  212.     STA    PROFST
  213. ;
  214.     MVI    A,1
  215.     STA    PRLEAD        ; Leading blank flag
  216.     XRA    A
  217.     STA    PUNDBL        ; Not underlining between words
  218. ;
  219.     POP    PSW
  220.     LXI    H,PRTYPX
  221.     MOV    B,M
  222.     MOV    M,A
  223.     CMP    B
  224.     JZ    PRIN9
  225. ;
  226.     ORA    A        ; Normal text line?
  227.     JZ    PRIN8
  228. ;
  229.     LXI    H,XTOGL+1    ; Clear header/footer attributes
  230.     MVI    C,XTOGZ/2
  231.     XRA    A
  232. PRIN1:    MOV    M,A
  233.     INX    H
  234.     INX    H
  235.     DCR    C
  236.     JNZ    PRIN1
  237. ;
  238.     MVI    A,1
  239. PRIN8:    MOV    L,A        ; Store print control offset
  240.     MVI    H,0
  241.     SHLD    PRTYPA
  242.     CALL    PRLQAD        ; No change in NLQ print?
  243.     LDA    PRLQPR
  244.     CMP    M
  245.     JZ    PRIN9
  246. ;
  247.     MVI    A,0FFh        ; Change NLQ state
  248.     STA    PRLQCH
  249. PRIN9:    LXI    H,PRSTRT    ; Not 1st printing line?
  250.     LDA    PRTYPE
  251.     ORA    M
  252.     JM    PRESUME
  253. ;
  254.     MVI    M,0FFH
  255. ;;;    CALL    PRBIN
  256.     JMP    PRESUME
  257.  
  258.     PAGE
  259. ;
  260. ; Resume Printing
  261. ;
  262. ;    On exit:  A contains a return code
  263. ;
  264. ;    Return code:    0 = done printing line
  265. ;            1 = not done printing, printer is busy
  266. ;            2 = pause required, operator should resume printing
  267. ;
  268. ;    Note that control must be returned to WordStar if the printer is
  269. ;    busy so that the user may abort printing from the console.
  270. ;    Therefore, you must not advance the character pointer or decrement
  271. ;    the count until after the character has been printed (in case the
  272. ;    printer is busy).
  273. ;
  274. PRESUME:
  275.     LDA    PRSSIZ        ; Not printing string?
  276.     ORA    A
  277.     JZ    PRES4
  278. ;
  279.     MOV    C,A
  280.     CALL    LSOSTA        ; Ready to print string size
  281.     LHLD    PRSPTR
  282.     JNZ    PRES3
  283. ;
  284. PRES2:    MOV    A,C
  285.     CALL    XSIZE        ; Save size
  286.     MVI    A,1
  287.     JMP    PRRET
  288.  
  289. PRES3:    MVI    A,1
  290.     CALL    LSOSTA
  291.     JZ    PRES2
  292. ;
  293.     MOV    A,M
  294.     CALL    LSTOUT
  295.     INX    H
  296.     DCR    C
  297.     JNZ    PRES3
  298. ;
  299.     XRA    A
  300.     STA    PRSSIZ
  301. PRES4:    LDA    PR2ND        ; No 2nd composite byte?
  302.     ORA    A
  303.     JZ    PRES6
  304. ;
  305.     CALL    PRLO        ; Not busy?
  306.     JNZ    PRRET
  307. ;
  308. PRES5:    LXI    H,PRCOLM    ; Bump posn, no more 2nd char
  309.     INR    M
  310.     XRA    A
  311.     STA    PR2ND
  312.     JMP    PRESUME
  313. ;
  314. PRES6:    LXI    H,PRFFL        ; No form feed lines left?
  315.     MOV    A,M
  316.     ORA    A
  317.     JZ    PRES7
  318. ;
  319.     DCR    M
  320. ;
  321.     LXI    H,$CRLF        ; Print CRLF's to next page
  322.     JMP    PRES17
  323. ;
  324. PRES7:    LDA    PRLQCH        ; No NLQ change?
  325.     ORA    A
  326.     JZ    PRES8
  327. ;
  328.     CALL    PRLQ        ; Change state
  329.     JMP    PRESUME
  330. ;
  331. PRES8:    LHLD    PRCOUNT        ; Not done printing?
  332.     MOV    A,H
  333.     ORA    L
  334.     JNZ    PRES9
  335. ;
  336.     CALL    GETSIZ        ; Get page size
  337.     JMP    PRINI1
  338. ;
  339. PRES9:    LHLD    PRCHAR
  340.     MOV    A,M
  341.     CPI    SOFTFF        ; Not a soft form feed?
  342.     JNZ    PRES11
  343. ;
  344.     LDA    PRLINE        ; Already at top of page?
  345.     ORA    A
  346.     JZ    PRSKIP
  347. ;
  348.     JMP    PRFF        ; Form feed
  349. ;
  350. PRES11:    MOV    A,M        ; 7 bit ASCII
  351.     ANI    7FH
  352. ;
  353.     LXI    H,PRSPEC1    ; Scan special char table
  354.     MOV    B,A
  355. PRES12:    MOV    A,M        ; End of table?
  356.     INX    H
  357.     CPI    0FFH
  358.     JZ    PRES13
  359. ;
  360.     CMP    B
  361.     JZ    PRES13
  362. ;
  363.     INX    H
  364.     INX    H
  365.     JMP    PRES12
  366. ;
  367. PRES13:    MOV    E,M        ; Execute special character routine
  368.     INX    H
  369.     MOV    D,M
  370.     XCHG
  371.     MOV    A,B
  372.     PCHL
  373. ;
  374. PRES14:    LDA    PROFST        ; No page offset left?
  375.     ORA    A
  376.     JZ    PRES15
  377. ;
  378.     CALL    PREXOFF        ; Not extended character
  379.     JNZ    PRESUME
  380. ;
  381.     MVI    A,' '        ; Print spaces to offset left side of page
  382.     CALL    PRLO
  383.     JNZ    PRRET
  384. ;
  385.     LXI    H,PROFST
  386.     DCR    M
  387.     JMP    PRESUME
  388. ;
  389. PRES15:    LXI    H,PRSPEC2    ; Check 2nd special char table
  390.     JMP    PRES12
  391. ;
  392. ; Print character
  393. ;
  394. PRES16:    CPI    DEL        ; Ignore non printing char?
  395.     JZ    PRSKIP
  396. ;
  397.     CPI    ' '
  398.     JC    PRSKIP
  399. ;
  400.     JNZ    PRES19        ; Not a blank?
  401. ;
  402.     CALL    PREMAIN        ; Only blanks remaining, turn something off?
  403.     JNZ    PRRET
  404. ;
  405.     LHLD    PRTYPA        ; Not underlining?
  406.     LXI    D,XUNDER
  407.     DAD    D
  408.     MOV    A,M
  409.     MOV    C,A
  410.     ANI    1
  411.     JZ    PRES21
  412. ;
  413.     LHLD    PRTABLE        ; Continuous underlining?
  414.     LXI    D,PRNUNL
  415.     DAD    D
  416.     MOV    A,M
  417.     ORA    A
  418.     JNZ    PRES21
  419. ;
  420.     LDA    PUNDBL        ; Underlining already off?
  421.     ANI    1
  422.     JNZ    PRES21
  423. ;
  424.     MOV    A,C
  425.     ORA    A
  426.     JP    PRES21    
  427. ;
  428.     MVI    A,1        ; Not underlining blanks
  429.     STA    PUNDBL
  430. ;
  431.     LHLD    PRTYPA        ; Turn underlining off
  432.     LXI    D,XUNDER
  433.     DAD    D
  434.     MOV    A,M
  435.     ANI    7FH
  436.     MOV    M,A
  437. ;
  438.     LXI    H,$PSOFF
  439. PRES17:    CALL    XSTRNG
  440.     JMP    PRESUME
  441. ;
  442. PRES19:    LDA    PRLEAD        ; Not the 1st non-blank
  443.     ANI    1
  444.     JZ    PRES20
  445. ;
  446.     CALL    PRON        ; Not everything on?
  447.     JNZ    PRESUME
  448. ;
  449. PRES20:    XRA    A        ; No longer leading blank
  450.     STA    PRLEAD
  451. ;
  452.     LDA    PUNDBL        ; Not suppressing blank underline?
  453.     ANI    1
  454.     JZ    PRES21
  455. ;
  456.     LHLD    PRTYPA        ; Already on?
  457.     LXI    D,XUNDER
  458.     DAD    D
  459.     MOV    M,A
  460.     ORA    A
  461.     JM    PRES21
  462. ;
  463.     ORI    80h        ; Turn underlining on
  464.     MOV    M,A
  465.     XRA    A        ; Underlining a non-blank now
  466.     STA    PUNDBL
  467. ;
  468.     LXI    H,$PSON
  469.     JMP    PRES17
  470. ;
  471. PRES21:    CALL    PREXOFF        ; Not extended char
  472.     JNZ    PRESUME
  473. ;
  474. PRE21A:    MOV    L,B        ; Just print char (unless busy)
  475.     MVI    H,0
  476.     LXI    D,$COMPOS
  477.     DAD    H
  478.     DAD    D
  479.     MOV    A,M
  480. ;
  481.     INX    H        ; 2nd composite char
  482.     MOV    B,M
  483.     LXI    H,PR2ND
  484.     MOV    M,B
  485. ;
  486.     LXI    H,PRCOLM
  487.     INR    M
  488. ;
  489.     CALL    PRLO        ; Print
  490.     JNZ    PRRET
  491. ;
  492.     MOV    A,B        ; Composite char?
  493.     ORA    A
  494.     JNZ    PRBS
  495. ;
  496. PRSKIP:    CALL    PRNEXT        ; Try another char
  497.     JNZ    PRSKIP
  498.     JMP    PRESUME
  499. ;
  500. PRNEXT:    PUSH    H
  501. PRNEX0:    LHLD    PRCHAR
  502.     INX    H
  503.     SHLD    PRCHAR
  504. ;
  505.     LHLD    PRCOUNT        ; Decrement count
  506.     DCX    H
  507.     SHLD    PRCOUNT
  508.     MOV    A,H
  509.     ORA    L
  510.     JZ    PRNEX1
  511. ;
  512.     LXI    H,PRNEXZ    ; More than 1 byte?
  513.     DCR    M
  514.     JNZ    PRNEX0
  515. ;
  516. PRNEX1:    MVI    A,1
  517.     STA    PRNEXZ
  518.     POP    H
  519.     RET
  520. ;
  521. ; Dispatch Tables for Special Characters
  522. ;
  523. PRSPEC1:
  524.     DB    CR
  525.     DW    PRCRLF
  526.  
  527.     DB    SOFTCR
  528.     DW    PRCRLF
  529.  
  530.     DB    LF
  531.     DW    PRLF
  532.  
  533.     DB    SOFTLF
  534.     DW    PRLF
  535.  
  536.     DB    FFEED
  537.     DW    PRFF
  538.  
  539.     DB    'C'-'@'
  540.     DW    PRPAUS
  541.  
  542.     DB    -1
  543.     DW    PRES14
  544.  
  545. ;
  546. ; Special chars processed after page offset
  547. ;
  548. PRSPEC2:
  549.     DB    TAB
  550.     DW    PRTAB
  551.  
  552.     DB    SOFTAB
  553.     DW    PRTAB
  554.  
  555.     DB    SOFTBL
  556.     DW    PRBLNK
  557.  
  558.     DB    'O'-'@'
  559.     DW    PRBIND
  560.  
  561.     DB    'F'-'@'
  562.     DW    PRPHBL
  563.  
  564.     DB    'G'-'@'
  565.     DW    PRPHRB
  566.  
  567.     DB    BS
  568.     DW    PRBS 
  569.  
  570.     DB    'N'-'@'
  571.     DW    PRNORM
  572.  
  573.     DB    'A'-'@'
  574.     DW    PRALT
  575.  
  576.     DB    'B'-'@'
  577.     DW    PRBOLD
  578.  
  579.     DB    'D'-'@'
  580.     DW    PRDBL
  581.  
  582.     DB    'S'-'@'
  583.     DW    PRUNDR
  584.  
  585.     DB    'T'-'@'
  586.     DW    PRSUPR
  587.  
  588.     DB    'V'-'@'
  589.     DW    PRSUB
  590.  
  591.     DB    'X'-'@'
  592.     DW    PRSTRK
  593.  
  594.     DB    'Y'-'@'
  595.     DW    PRITAL
  596.  
  597.     DB    HARDHY
  598.     DW    PRDASH
  599.  
  600.     DB    SOFTHY
  601.     DW    PRSKIP
  602.  
  603.     DB    'Q'-'@'
  604.     DW    PCUSQ
  605.  
  606.     DB    'W'-'@'
  607.     DW    PCUSW
  608.  
  609.     DB    'E'-'@'
  610.     DW    PCUSE
  611.  
  612.     DB    'R'-'@'
  613.     DW    PCUSR
  614.  
  615.     DB    ESC
  616.     DW    PREXTN
  617.  
  618.     DB    -1
  619.     DW    PRES16
  620.  
  621. ;
  622. PRCRLF:    CALL    PROFF        ; Turning things off?
  623.     JNZ    PRESUME
  624. ;
  625.     LHLD    PRCOUNT        ; No chars after CR?
  626.     MOV    A,H
  627.     ORA    L
  628.     JZ    PRCR
  629. ;
  630.     LHLD    PRCHAR        ; LF after CR?
  631.     INX    H
  632.     MOV    A,M
  633.     CPI    LF
  634.     JZ    PRCRL1
  635.     CPI    SOFTLF
  636.     JNZ    PRCR
  637. ;
  638. PRCRL1:    CALL    PRNEXT        ; Skip CR
  639. PRCRL2:    XRA    A
  640.     STA    PRCOLM
  641.     LXI    H,$CRLF
  642. PRCRL3:    LDA    PRLINE
  643.     INR    A
  644.     STA    PRLINE
  645.     JMP    PSTRNG
  646. ;
  647. ; Carriage return, no line feed
  648. ;
  649. PRCR:    CALL    PROFF        ; Turn things off?
  650.     JNZ    PRESUME
  651. ;
  652.     LXI    H,$CR
  653.     XRA    A
  654.     STA    PRCOLM
  655.     JMP    PSTRNG
  656. ;
  657. ; Line feed
  658. ;
  659. PRLF:    CALL    PROFF        ; Turn things off?
  660.     JNZ    PRESUME
  661. ;
  662.     LXI    H,$HLF        ; No half line feed string?
  663.     MOV    A,M
  664.     ORA    A
  665.     JZ    PRCRL2
  666. ;
  667.     LDA    PRHALF    ; 2nd half line feed?
  668.     XRI    1
  669.     STA    PRHALF
  670.     ORA    A
  671.     JZ    PRCRL3
  672. ;
  673.     JMP    PRES17
  674. ;
  675. ; Binding space
  676. ;
  677. PRBIND:    LXI    H,$CTRLO
  678.     JMP    P1STRNG
  679. ;
  680. ; Phantom blank
  681. ;
  682. PRPHBL:    LXI    H,$CTRLF
  683.     JMP    P1STRNG
  684. ;
  685. ; Phantom rubout
  686. ;
  687. PRPHRB:    LXI    H,$CTRLG
  688.     JMP    P1STRNG
  689. ;
  690. ; Normal pitch
  691. ;
  692. PRNORM:    LXI    H,$NORM
  693.     JMP    PSTRNG
  694. ;
  695. ; Alternate pitch
  696. ;
  697. PRALT:    LXI    H,$ALT
  698.     JMP    PSTRNG
  699. ;
  700. ; Bold on/off
  701. ;
  702. PRBOLD:    LXI    D,XBOLD
  703.     LXI    B,$PBON
  704.     ; Fall into PRTOGL
  705. ;
  706. ; Toggle something on/off
  707. ;
  708. PRTOGL:
  709.     LHLD    PRTYPA
  710.     DAD    D
  711.     MOV    A,M
  712.     XRI    1
  713.     MOV    M,A
  714. ;
  715.     LDA    PRLEAD    ; Only leading blanks so far?
  716.     ANI    1
  717.     JNZ    PRTOG3
  718. ;
  719.     MOV    A,M    ; Now on?
  720.     ANI    1
  721.     JNZ    PRTOG1
  722. ;
  723.     MOV    A,M    ; Already off?
  724.     ORA    A
  725.     JP    PRTOG3
  726. ;
  727.     ANI    7FH    ; Mark off
  728.     MOV    M,A    
  729.     LXI    H,$SHORT ; Offset to OFF string
  730.     JMP    PRTOG2
  731. ;
  732. PRTOG1:    MVI    A,1    ; On now
  733.     STA    PRONOFF
  734. ;
  735.     MOV    A,M    ; Already on?
  736.     ORA    A
  737.     JM    PRTOG3
  738. ;
  739.     ORI    80h
  740.     MOV    M,A
  741.     LXI    H,0        ; Normal string offset
  742. PRTOG2:    DAD    B
  743.     JMP    PSTRNG        ; Send control sequence
  744. ;
  745. PRTOG3:    JMP    PRSKIP        ; Ignore until blanks are done
  746. ;
  747. ; Doublestrike on/off
  748. ;
  749. PRDBL:    LXI    D,XDBL
  750.     LXI    B,$PDON
  751.     JMP    PRTOGL
  752. ;
  753. ; Underline on/off
  754. ;
  755. PRUNDR:    LXI    D,XUNDER
  756.     LXI    B,$PSON
  757.     XRA    A
  758.     STA    PUNDBL
  759.     JMP    PRTOGL
  760. ;
  761. ; Superscript on/off
  762. ;
  763. PRSUPR:    LXI    D,XSUPER
  764.     LXI    B,$PTON
  765.     JMP    PRTOGL
  766. ;
  767. ; Subscript on/off
  768. ;
  769. PRSUB:    LXI    D,XSUB
  770.     LXI    B,$PVON
  771.     JMP    PRTOGL
  772. ;
  773. ; Strike-out on/off
  774. ;
  775. PRSTRK:    LXI    D,XSTRIKE
  776.     LXI    B,$PXON
  777.     JMP    PRTOGL
  778. ;
  779. ; Italics on/off
  780. ;
  781. PRITAL:    LXI    D,XITALIC
  782.     LXI    B,$PYON
  783.     JMP    PRTOGL
  784. ;
  785. ; Extended character
  786. ;
  787. PREXTN:    LHLD    PRCHAR        ; ESC xx BESC?
  788.     INX    H
  789.     INX    H
  790.     MOV    M,A
  791.     CPI    BESC
  792.     JNZ    PRSKIP
  793. ;
  794.     MVI    A,1        ; Need to send string 1st?
  795.     CALL    PREXST
  796.     JNZ    PRESUME
  797. ;
  798.     MVI    A,3        ; Extended character
  799.     STA    PRNEXZ
  800.     LHLD    PRCHAR
  801.     INX    H
  802.     MOV    A,M
  803.     JMP    PRE21A
  804. ;
  805. ; Tab character (09H)
  806. ;
  807. PRTAB:                ; Tab
  808.     CALL    PREXOFF        ; Not extended?
  809.     JNZ    PRESUME
  810.     LDA    PROFST
  811. ;
  812.     
  813.     MVI    A,' '        ; Try to print a blank
  814.     CALL    PRLO
  815.     JNZ    PRRET        ; Busy
  816. ;
  817.     LDA    PRCOLM        ; Increment column
  818.     INR    A
  819.     STA    PRCOLM
  820. ;
  821.     LHLD    PRTABLE        ; Use tab mask to see if at next stop
  822.     LXI    D,TBMASK
  823.     DAD    D
  824.     ANA    M
  825.     JNZ    PRTAB
  826.     JMP    PRSKIP
  827. ;
  828. PRFF:                ; Form feed
  829.     CALL    PROFF        ; Turn things off
  830.     JNZ    PRRET        ; Busy
  831. ;
  832.     LDA    PRFFOK        ; Can't use form feeds?
  833.     ORA    A
  834.     JZ    PRFF1
  835. ;
  836.     LXI    H,@USRFF
  837.     CALL    USTRAD
  838.     MOV    A,M
  839.     ORA    A
  840.     JNZ    PRFF0
  841. ;
  842.     LXI    H,$FF
  843. PRFF0:    CALL    XSTRNG
  844.     JMP    PRFF2
  845. ;
  846. PRFF1:    LXI    H,PRLINE    ; Determine remaining lines on page
  847.     LDA    PRPGSZ
  848.     SUB    M
  849.     JC    PRFF2
  850. ;
  851.     STA    PRFFL
  852. PRFF2:    XRA    A        ; Top of page
  853.     STA    PRLINE
  854.     STA    PRCOLM
  855.     JMP    PRSKIP
  856. ;
  857. ; Backspace
  858. ;
  859. PRBS:    LXI    H,PRCOLM    ; At left stop?
  860.     MOV    A,M
  861.     ORA    A
  862.     JZ    PRSKIP
  863. ;
  864.     DCR    M        ; Back up
  865.     LXI    H,$BS        ; Backspace string
  866.     JMP    PSTRNG
  867. ;
  868. ; Pause in mid-text
  869. ;
  870. PRPAUS:    CALL    PRNEXT
  871.     LDA    PRTYPE        ; Inhibit printing?
  872.     ORA    A
  873.     JM    PRESUME
  874. ;
  875.     MVI    A,2        ; Return code 2
  876.     ORA    A
  877.     RET
  878. ;
  879. PRBLNK:            ; Convert to a blank
  880.     MVI    B,' '
  881.     JMP    PRES4
  882. ;
  883. PRDASH:
  884.     MVI    B,'-'        ; Hard Hyphen
  885.     JMP    PRES4
  886. ;
  887. PCUSQ:    LXI    H,@USRQ
  888.     JMP    USTRNG
  889. ;
  890. PCUSW:    LXI    H,@USRW
  891.     JMP    USTRNG
  892. ;
  893. PCUSE:    LXI    H,@USRE
  894.     JMP    USTRNG
  895. ;
  896. PCUSR:    LXI    H,@USRR
  897.     JMP    USTRNG
  898. ;
  899. ; Send NLQ print status
  900. ;
  901. PRLQ:    XRA    A
  902.     STA    PRLQCH
  903.     CALL    PRLQAD
  904.     MOV    A,M
  905.     STA    PRLQPR
  906. ;
  907.     LXI    H,$LQON
  908.     ANI    1
  909.     JNZ    XSTRNG
  910. ;
  911.     LXI    H,$LQOFF
  912.     JMP    XSTRNG
  913. ;
  914. PRLQAD:
  915.     LHLD    PRTABLE
  916.     LXI    D,PRNNLQ
  917.     DAD    D
  918.     RET
  919. ;
  920. ; Check extended character status
  921. ;
  922. PREXOFF:
  923.     XRA    A        ; Not an extended character
  924. ;
  925. PREXST:
  926.     LXI    H,PREXTX    ; No change?
  927.     CMP    M
  928.     RZ
  929. ;
  930.     MOV    M,A        ; New state
  931.     ORA    A
  932. ;
  933.     LXI    H,$BIDON
  934.     ORA    A
  935.     JNZ    PREXS1
  936. ;
  937.     LXI    H,$BIDOFF
  938. PREXS1:    CALL    XSTRNG
  939.     LDA    PRSSIZ        ; Any string?
  940.     ORA    A
  941.     RET
  942. ;
  943. ; Table of on/off strings
  944. ;
  945. PRPRCTL:
  946.     DW    XBOLD,$PBON
  947.     DW    XDBL,$PDON
  948.     DW    XUNDER,$PSON
  949.     DW    XSUPER,$PTON
  950.     DW    XSUB,$PVON
  951.     DW    XSTRIKE,$PXON
  952.     DW    XITALIC,$PYON
  953.     DW    0
  954. ;
  955. ; Turn print controls on or off
  956. ;
  957. ;   on exit:  Z if all done, NZ if string pending
  958. ;          B = $
  959. ;
  960. PRON:
  961.     MVI    C,0        ; Offset to ON string
  962.     MVI    A,1        ; On
  963.     JMP    PRO0
  964. ;
  965. PROFF:
  966.     CALL    PREXOFF        ; Extended chars off
  967.     RNZ
  968. ;
  969.     MVI    C,$SHORT    ; Offset to OFF string
  970.     XRA    A        ; Off
  971. ;
  972. PRO0:    LXI    H,PRONOFF
  973.     CMP    M
  974.     JZ    PRO6
  975. ;
  976.     LXI    H,PRPRCTL
  977. PRO1:    MOV    E,M        ; Get attr address
  978.     INX    H
  979.     MOV    D,M
  980.     INX    H
  981.     MOV    A,D        ; End of table?
  982.     ORA    E
  983.     JZ    PRO5
  984. ;
  985.     PUSH    H        ; Get current attr state
  986.     LHLD    PRTYPA
  987.     DAD    D
  988.     MOV    A,M
  989.     ANI    1
  990.     JZ    PRO2A        ; Off?
  991. ;
  992.     MOV    A,C        ; 0 if turning on
  993.     ORA    A
  994.     JZ    PRO3
  995. ;
  996.     MOV    A,M        ; Already off?
  997.     ORA    A
  998.     JP    PRO2A
  999. ;
  1000.     ANI    7Fh
  1001.     JMP    PRO4
  1002.  
  1003. PRO2A:    POP    H
  1004.     INX    H
  1005.     INX    H
  1006.     JMP    PRO1
  1007. ;
  1008. ; Turning on
  1009. ;
  1010. PRO3:    MOV    A,M        ; Already on?
  1011.     ORA    A
  1012.     JM    PRO2A
  1013. ;
  1014.     ORI    80H        ; Mark on
  1015. ;
  1016. PRO4:    MOV    M,A        ; New state
  1017.     POP    H        ; Get pointer to string
  1018.     MOV    E,M
  1019.     INX    H
  1020.     MOV    D,M
  1021.     INX    H
  1022.     XCHG
  1023.     PUSH    B
  1024.     MVI    B,0
  1025.     DAD    B        ; Add on/off offset
  1026.     POP    B
  1027.     CALL    XSTRNG        ; AL = 1 from XSTRNG
  1028.     RET
  1029. ;
  1030. PRO5:    LXI    H,PRONOFF    ; Change on/off state
  1031.     MOV    A,M
  1032.     XRI    1
  1033.     MOV    M,A
  1034. PRO6:    XRA    A        ; Z
  1035.     RET
  1036. ;
  1037. ; Abort Printing
  1038. ;
  1039. PRABORT:
  1040.     MVI    A,CR        ; Print a final CRLF
  1041.     CALL    PRLOWT
  1042.     MVI    A,LF
  1043.     CALL    PRLOWT
  1044.     JMP    PRRET
  1045.  
  1046.     PAGE
  1047. ;
  1048. ; Uninitialize Printing
  1049. ;
  1050. PRUNITZ:
  1051.     LXI    H,PRUNI1    ; One last form feed
  1052.     LXI    D,1
  1053.     XRA    A
  1054.     CALL    PRINT
  1055. PRUNI0:    ORA    A
  1056.     RZ
  1057.     CALL    PRESUME
  1058.     JMP    PRUNI0
  1059. ;
  1060. PRUNI1:    DB    SOFTFF        ; Form feed only if not already top of page
  1061.  
  1062.     PAGE
  1063. ;
  1064. ; Check if only blanks remain on line
  1065. ;
  1066. ;    on exit:  NZ if string to be printed
  1067. ;
  1068. PREMAIN:
  1069.     LDA    PRLEAD        ; Leading blank?
  1070.     ANI    1
  1071.     JNZ    PREMA3
  1072. ;
  1073.     LHLD    PRCOUNT
  1074.     XCHG
  1075.     LHLD    PRCHAR
  1076.     JMP    PREMA2
  1077. ;
  1078. PREMA1:    INX    H
  1079.     MOV    A,M
  1080.     ANI    7FH
  1081.     CPI    SOFTHY         ; Control char?
  1082.     JC    PREMA2
  1083. ;
  1084.     CPI    ' '
  1085.     JZ    PREMA2
  1086. ;
  1087.     CPI    SOFTBL
  1088.     JZ    PREMA2
  1089. ;
  1090.     CPI    SOFTCR
  1091.     JZ    PREMA2
  1092. ;
  1093.     CPI    SOFTLF
  1094.     JNZ    PREMA3
  1095. ;
  1096. PREMA2:    DCX    D        ; More?
  1097.     MOV    A,D
  1098.     ORA    E
  1099.     JNZ    PREMA1
  1100. ;
  1101.     JMP    PROFF        ; Turn everything off
  1102. ;
  1103. PREMA3:    XRA    A        ; Z no string
  1104.     RET
  1105. ;
  1106. ; Get page size
  1107. ;
  1108. GETSIZ:    PUSH    H
  1109.     PUSH    D
  1110.     LHLD    PRTABLE
  1111.     LXI    D,PAGSIZ
  1112.     DAD    D
  1113.     MOV    A,M
  1114.     STA    PRPGSZ
  1115.     POP    D
  1116.     POP    H
  1117.     RET
  1118.  
  1119. ;
  1120. ; Set up to print string at BX
  1121. ;
  1122. XSTRNG:
  1123.     PUSH    H
  1124.     LDA    PRTYPE        ; Printing suppressed?
  1125.     ORA    A
  1126.     JM    XSTRN3
  1127. ;
  1128. XSTRN1:    MOV    A,M        ; No redirection?
  1129.     INX    H
  1130.     CPI    -1
  1131.     JNZ    XSTRN2
  1132. ;
  1133.     PUSH    D
  1134.     MOV    E,M
  1135.     INX    H
  1136.     MOV    D,M
  1137.     XCHG
  1138.     POP    D
  1139.     JMP    XSTRN1
  1140. ;
  1141. XSTRN2:    CALL    XSIZE
  1142. XSTRN3:    POP    H
  1143.     XRA    A
  1144.     INR    A        ; NZ, AL = 1
  1145.     RET
  1146.  
  1147. ;
  1148. ; Store pointer to string to be printed
  1149. ;
  1150. ;  on entry:    HL -> string
  1151. ;        A = length;
  1152. XSIZE:
  1153.     SHLD    PRSPTR
  1154.     STA    PRSSIZ
  1155.     RET
  1156. ;
  1157. ; Print string at BX
  1158. ;
  1159. P1STRNG:
  1160.     LDA    PRCOLM
  1161.     INR    A
  1162.     STA    PRCOLM
  1163. PSTRNG:    CALL    XSTRNG
  1164.     JMP    PRSKIP
  1165. ;
  1166. USTRNG:    CALL    USTRAD
  1167.     JMP    PSTRNG
  1168. ;
  1169. USTRAD:    PUSH    D
  1170.     XCHG
  1171.     LHLD    PRUSER
  1172.     DAD    D
  1173.     POP    D
  1174.     RET
  1175. ;
  1176. ; Print a Character
  1177. ;
  1178. ;    On entry: A contains character to be printed
  1179. ;
  1180. ;    On exit:  A is zero if printed, 1 if busy
  1181. ;
  1182. PRLO:
  1183.     PUSH    B
  1184.     MOV    B,A        ; Save char to B
  1185. ;
  1186.     LDA    PRTYPE        ; Printing being suppressed?
  1187.     ORA    A
  1188.     JM    PRL2
  1189. ;
  1190.     MVI    C,10        ; Go through busy loop up to 10 times
  1191. ;
  1192. PRL0:    CALL    LSOSTA        ; Printer ready for a char?
  1193.     JNZ    PRL1
  1194. ;
  1195.     DCR    C        ; One more time
  1196.     JNZ    PRL0
  1197. ;
  1198.     POP    B        ; Return a 1 since busy
  1199.     XRA    A
  1200.     INR    A        ; (Set Z flag too)
  1201.     RET
  1202. ;
  1203. PRL1:    MOV    A,B        ; Print char
  1204.     CALL    LSTOUT
  1205. ;
  1206. PRL2:    POP    B        ; Return a zero
  1207.     XRA    A
  1208.     RET
  1209. ;
  1210. ; Print a Character if Possible
  1211. ;
  1212. ;    On entry: A contains char to be printed
  1213. ;
  1214. ;    On exit:  Char printed if possible
  1215. ;
  1216. PRLOWT:
  1217.     LXI    H,1000        ; Wait a while for printer to be not busy
  1218.     MOV    B,A
  1219. PRLOW0:    MOV    A,B        ; Try printing it
  1220.     CALL    PRLO
  1221.     RZ
  1222. ;
  1223.     DCX    H        ; Another try?
  1224.     MOV    A,H
  1225.     ORA    L
  1226.     JNZ    PRLOW0
  1227.     RET
  1228.  
  1229. PRRET:    RET
  1230.  
  1231. PGLEN    EQU    $-PGORG
  1232.  
  1233.     PAGE
  1234. ;
  1235. ; Driver Variables
  1236. ;
  1237. DATORG:
  1238. ;
  1239. PRCHAR:    DS    2        ; Pointer to current char
  1240. PRCOUNT:DS    2        ; Char count
  1241. PRTYPE:    DS    1        ; Type of line
  1242. PRTYPX:    DS    1        ; Prev line type
  1243. PRTYPA:    DS    2        ; Offset to print control toggles
  1244. ;
  1245. PRSPTR:    DS    2        ; Pointer to string to print
  1246. PRSSIZ:    DS    1        ; Length
  1247. ;
  1248. PRLINE:    DS    1        ; Current line number
  1249. PRCOLM:    DS    1        ; Current print column
  1250. PROFST:    DS    1        ; Page offset counter
  1251. PRLEAD:    DS    1        ; Leading blank flag
  1252. PRPGSZ:    DS    1        ; Page size
  1253. ;
  1254. PRTABLE:DS    2        ; Pointer to WordStar table
  1255. PRUSER:    DS    2        ; Pointer to user area strings
  1256. ;
  1257. PRLQPR:    DS    1        ; Last NLQ print state
  1258. PRLQCH:    DS    1        ; Change NLQ state
  1259. ;
  1260. PREXTX:    DS    1        ; Extended character state
  1261. ;
  1262. PRFFOK:    DS    1        ; Form feed okay flag
  1263. PRFFL:    DS    1        ; CRLF counter
  1264. PRHALF:    DS    1        ; Half line feed counter
  1265. PRNEXZ:    DS    1        ; Character size
  1266. PR2ND:    DS    1        ; Second composed character
  1267. ;
  1268. PRONOFF: DS    1        ; Print controls on/off flag
  1269. ;
  1270. PUNDBL:    DS    1        ; Underlining blanks flag
  1271. ;
  1272. PRSTRT:    DS    1        ; Printing started flag
  1273.  
  1274. ;
  1275. ; Print Control Toggles
  1276. ;
  1277. ;    Byte for current state, regular text
  1278. ;
  1279. XTOGL:
  1280. XBOLD:    DS    2
  1281. XDBL:    DS    2
  1282. XUNDER:    DS    2
  1283. XSUPER:    DS    2
  1284. XSUB:    DS    2
  1285. XSTRIKE: DS    2
  1286. XITALIC: DS    2
  1287. XTOGZ    EQU    ($-XTOGL)
  1288.  
  1289. DATLEN    EQU    $-DATORG    ; Length of uninitialized data
  1290.  
  1291. PDLEN    EQU    $-PGORG        ; Driver length
  1292.  
  1293.     PAGE
  1294.  
  1295. $ORG:
  1296. ;
  1297. ; String allocation macro
  1298. ;
  1299. STRNG    MACRO    STROFF
  1300. STPAD    SET    STROFF-$
  1301.     IF STPAD AND 0F000H
  1302.     .PRINTX /**** STRING LENGTH ERROR ****/
  1303.     ENDIF
  1304.     IF    STPAD GT 0
  1305.     DS    STPAD
  1306.     ENDIF
  1307.     ENDM
  1308. ;
  1309. BTSUPR    EQU    1    ; Superscript
  1310. BTSUB    EQU    2    ; Subscript
  1311. BTCOLR    EQU    4    ; Italics/red
  1312. BTALT    EQU    8    ; Alternate width
  1313. BTUNDR    EQU    10H    ; Underlining
  1314. BTSTRK    EQU    20H    ; Strikeout
  1315. BTEXT    EQU    40H    ; Extended character set
  1316. BTNLQ    EQU    80H    ; Near letter quality
  1317. BTPROP    EQU    100H    ; Proportional
  1318. BTBOLD    EQU    200H    ; Boldface
  1319. BTDBL    EQU    400H    ; Doublestrike
  1320. BTENH    EQU    800H       ; Enhanced (alternate mode boldface)
  1321. BTCOND    EQU    1000H      ; Condensed (needs special pass)
  1322. BTCOMP    EQU    2000H    ; Printer composed character
  1323. BSS    EQU    BTSUPR+BTSUB
  1324.  
  1325. ;
  1326. ; Offsets to custom strings in user area
  1327. ;
  1328. @USRQ    EQU    0
  1329. @USRW    EQU    25
  1330. @USRE    EQU    50
  1331. @USRR    EQU    75
  1332. @STRK    EQU    100
  1333. @USRFF    EQU    101
  1334.  
  1335. ;
  1336. ; Offsets into strings and flags
  1337. ;
  1338. $SHORT    EQU    10    ; Short string length
  1339. $LONG    EQU    25    ; Long string length
  1340. ;
  1341. $INIT    EQU    $ORG+7
  1342. $UNINT    EQU    $INIT+$LONG
  1343. $ABORT    EQU    $UNINT+$LONG
  1344. $CRLF    EQU    $ABORT+$LONG
  1345. $CR    EQU    $CRLF+$SHORT
  1346. $FF    EQU    $CR+$SHORT
  1347. $HLF    EQU    $FF+$SHORT
  1348. $BS    EQU    $HLF+$SHORT
  1349. $NORM    EQU    $BS+$SHORT
  1350. $ALT    EQU    $NORM+$SHORT
  1351. $CTRLF    EQU    $ALT+$SHORT
  1352. $CTRLG    EQU    $CTRLF+$SHORT
  1353. $CTRLO    EQU    $CTRLG+$SHORT
  1354. $PBON    EQU    $CTRLO+$SHORT
  1355. $PBOFF    EQU    $PBON+$SHORT
  1356. $PDON    EQU    $PBOFF+$SHORT
  1357. $PDOFF    EQU    $PDON+$SHORT
  1358. $PSON    EQU    $PDOFF+$SHORT
  1359. $PSOFF    EQU    $PSON+$SHORT
  1360. $PTON    EQU    $PSOFF+$SHORT
  1361. $PTOFF    EQU    $PTON+$SHORT
  1362. $PVON    EQU    $PTOFF+$SHORT
  1363. $PVOFF    EQU    $PVON+$SHORT
  1364. $PXON    EQU    $PVOFF+$SHORT
  1365. $PXOFF    EQU    $PXON+$SHORT
  1366. $PYON    EQU    $PXOFF+$SHORT
  1367. $PYOFF    EQU    $PYON+$SHORT
  1368. $BIDON    EQU    $PYOFF+$SHORT
  1369. $BIDOFF    EQU    $BIDON+$SHORT
  1370. $LQON    EQU    $BIDOFF+$SHORT
  1371. $LQOFF    EQU    $LQON+$SHORT
  1372. $BOLD    EQU    $LQOFF+$SHORT
  1373. $DOUBLE    EQU    $BOLD+1
  1374. $COMPOS    EQU    $DOUBLE+1
  1375. $SYMTAB    EQU    $COMPOS+512
  1376.  
  1377. ;
  1378. ; Name of driver
  1379. ;
  1380.     DB    'SIMPLE'
  1381.     DB    0
  1382. ;
  1383. ; Control strings
  1384. ;
  1385. STRNG    $INIT
  1386.     DB    1,CR
  1387. STRNG    $UNINT
  1388.     DB    1,CR
  1389. STRNG    $ABORT
  1390.     DB    2,CR,FFEED
  1391. STRNG    $CRLF
  1392.     DB    2,CR,LF
  1393. STRNG    $CR
  1394.     DB    1,CR
  1395. STRNG    $FF
  1396.     DB    1,FFEED
  1397. STRNG    $HLF
  1398.     DB    0
  1399. STRNG    $BS
  1400.     DB    1,08h
  1401. STRNG    $NORM
  1402.     DB    0
  1403. STRNG    $ALT
  1404.     DB    0
  1405. STRNG    $CTRLF
  1406.     DB    1,' '
  1407. STRNG    $CTRLG
  1408.     DB    1,' '
  1409. STRNG    $CTRLO
  1410.     DB    1,' '
  1411. STRNG    $PBON
  1412.     DB    0
  1413. STRNG    $PBOFF
  1414.     DB    0
  1415. STRNG    $PDON
  1416.     DB    0
  1417. STRNG    $PDOFF
  1418.     DB    0
  1419. STRNG    $PSON
  1420.     DB    0
  1421. STRNG    $PSOFF
  1422.     DB    0
  1423. STRNG    $PTON
  1424.     DB    0
  1425. STRNG    $PTOFF
  1426.     DB    0
  1427. STRNG    $PVON
  1428.     DB    0
  1429. STRNG    $PVOFF
  1430.     DB    0
  1431. STRNG    $PXON
  1432.     DB    0
  1433. STRNG    $PXOFF
  1434.     DB    0
  1435. STRNG    $PYON
  1436.     DB    0
  1437. STRNG    $PYOFF
  1438.     DB    0
  1439. STRNG    $BIDON
  1440.     DB    0
  1441. STRNG    $BIDOFF
  1442.     DB    0
  1443. STRNG    $LQON
  1444.     DB    0
  1445. STRNG    $LQOFF
  1446.     DB    0
  1447. STRNG    $BOLD
  1448.     DB    3
  1449. STRNG    $DOUBLE
  1450.     DB    2
  1451. STRNG    $COMPOS
  1452.  
  1453. ;
  1454. ; Table of composite characters
  1455. ;  entry indexed by WordStar character value
  1456. ;  first byte = printing character or null
  1457. ;  second byte = overstruck character or null
  1458. ;
  1459. ;  This table is set up for a simple ASCII printer, emulating 
  1460. ;  an IBM character set 2.
  1461. ;
  1462. UNK    EQU    '?'
  1463. COMPOS:    DB    UNK,0    ; 0
  1464.     DB    UNK,0    ; 1
  1465.     DB    UNK,0    ; 2
  1466.     DB    UNK,0    ; 3, heart
  1467.     DB    UNK,0    ; 4, diamond
  1468.     DB    UNK,0    ; 5, club
  1469.     DB    UNK,0    ; 6, spade
  1470.     DB    UNK,0    ; 7
  1471.     DB    UNK,0    ; 8
  1472.     DB    UNK,0    ; 9
  1473.     DB    UNK,0    ; A
  1474.     DB    UNK,0    ; B
  1475.     DB    UNK,0    ; C
  1476.     DB    UNK,0    ; D
  1477.     DB    UNK,0    ; E
  1478.     DB    UNK,0    ; 0F
  1479. ;
  1480.     DB    UNK,0    ; 10
  1481.     DB    UNK,0    ; 11
  1482.     DB    UNK,0    ; 12
  1483.     DB    UNK,0    ; 13
  1484.     DB    'PI'    ; 14, paragraph symbol
  1485.     DB    'So'    ; 15, section mark
  1486.     DB    UNK,0    ; 16
  1487.     DB    UNK,0    ; 17
  1488.     DB    UNK,0    ; 18
  1489.     DB    UNK,0    ; 19
  1490.     DB    '->'    ; 1A, right arrow
  1491.     DB    UNK,0    ; 1B
  1492.     DB    UNK,0    ; 1C
  1493.     DB    UNK,0    ; 1D
  1494.     DB    UNK,0    ; 1E
  1495.     DB    UNK,0    ; 1F
  1496. ;
  1497.     DB    ' ',0    ; 20  blank
  1498.     DB    '!',0    ; 21
  1499.     DB    '"',0    ; 22
  1500.     DB    '#',0    ; 23
  1501.     DB    '$',0    ; 24
  1502.     DB    '%',0    ; 25
  1503.     DB    '&',0    ; 26
  1504.     DB    "'",0    ; 27
  1505.     DB    '(',0    ; 28
  1506.     DB    ')',0    ; 29
  1507.     DB    '*',0    ; 2A
  1508.     DB    '+',0    ; 2B
  1509.     DB    ',',0    ; 2C
  1510.     DB    '-',0    ; 2D
  1511.     DB    '.',0    ; 2E
  1512.     DB    '/',0    ; 2F
  1513. ;
  1514.     DB    '0',0    ; 30
  1515.     DB    '1',0    ; 31
  1516.     DB    '2',0    ; 32
  1517.     DB    '3',0    ; 33
  1518.     DB    '4',0    ; 34
  1519.     DB    '5',0    ; 35
  1520.     DB    '6',0    ; 36
  1521.     DB    '7',0    ; 37
  1522.     DB    '8',0    ; 38
  1523.     DB    '9',0    ; 39
  1524.     DB    ':',0    ; 3A
  1525.     DB    ';',0    ; 3B
  1526.     DB    '<',0    ; 3C
  1527.     DB    '=',0    ; 3D
  1528.     DB    '>',0    ; 3E
  1529.     DB    '?',0    ; 3F
  1530. ;
  1531.     DB    '@',0    ; 40
  1532.     DB    'A',0    ; 41
  1533.     DB    'B',0    ; 42
  1534.     DB    'C',0    ; 43
  1535.     DB    'D',0    ; 44
  1536.     DB    'E',0    ; 45
  1537.     DB    'F',0    ; 46
  1538.     DB    'G',0    ; 47
  1539.     DB    'H',0    ; 48
  1540.     DB    'I',0    ; 49
  1541.     DB    'J',0    ; 4A
  1542.     DB    'K',0    ; 4B
  1543.     DB    'L',0    ; 4C
  1544.     DB    'M',0    ; 4D
  1545.     DB    'N',0    ; 4E
  1546.     DB    'O',0    ; 4F
  1547. ;
  1548.     DB    'P',0    ; 50
  1549.     DB    'Q',0    ; 51
  1550.     DB    'R',0    ; 52
  1551.     DB    'S',0    ; 53
  1552.     DB    'T',0    ; 54
  1553.     DB    'U',0    ; 55
  1554.     DB    'V',0    ; 56
  1555.     DB    'W',0    ; 57
  1556.     DB    'X',0    ; 58
  1557.     DB    'Y',0    ; 59
  1558.     DB    'Z',0    ; 5A
  1559.     DB    '[',0    ; 5B
  1560.     DB    '\',0    ; 5C
  1561.     DB    ']',0    ; 5D
  1562.     DB    '^',0    ; 5E
  1563.     DB    '_',0    ; 5F
  1564. ;
  1565.     DB    '`',0    ; 60
  1566.     DB    'a',0    ; 61
  1567.     DB    'b',0    ; 62
  1568.     DB    'c',0    ; 63
  1569.     DB    'd',0    ; 64
  1570.     DB    'e',0    ; 65
  1571.     DB    'f',0    ; 66
  1572.     DB    'g',0    ; 67
  1573.     DB    'h',0    ; 68
  1574.     DB    'i',0    ; 69
  1575.     DB    'j',0    ; 6A
  1576.     DB    'k',0    ; 6B
  1577.     DB    'l',0    ; 6C
  1578.     DB    'm',0    ; 6D
  1579.     DB    'n',0    ; 6E
  1580.     DB    'o',0    ; 6F
  1581. ;
  1582.     DB    'p',0    ; 70
  1583.     DB    'q',0    ; 71
  1584.     DB    'r',0    ; 72
  1585.     DB    's',0    ; 73
  1586.     DB    't',0    ; 74
  1587.     DB    'u',0    ; 75
  1588.     DB    'v',0    ; 76
  1589.     DB    'w',0    ; 77
  1590.     DB    'x',0    ; 78
  1591.     DB    'y',0    ; 79
  1592.     DB    'z',0    ; 7A
  1593.     DB    '{',0    ; 7B
  1594.     DB    '|',0    ; 7C
  1595.     DB    '}',0    ; 7D
  1596.     DB    '~',0    ; 7E
  1597.     DB    UNK,0    ; 7F
  1598. ;
  1599.     DB    'C,'    ; 80  c,
  1600.     DB    'u~'    ; 81  u umlaut
  1601.     DB    "e'"    ; 82  e'
  1602.     DB    'a^'    ; 83  a^
  1603.     DB    'a~'    ; 84  a umlaut
  1604.     DB    'a`'    ; 85  a`
  1605.     DB    'a['    ; 86  a ring
  1606.     DB    'c,'    ; 87  c,
  1607.     DB    'e^'    ; 88  e^
  1608.     DB    'e~'    ; 89  e umlaut
  1609.     DB    'e`'    ; 8A  e`
  1610.     DB    'i~'    ; 8B  i umlaut
  1611.     DB    'i^'    ; 8C  i^
  1612.     DB    'i`'    ; 8D  i`
  1613.     DB    'A~'    ; 8E  A umlaut
  1614.     DB    'A['    ; 8F  A ring
  1615. ;
  1616.     DB    "E'"    ; 90  E'
  1617.     DB    'ae'    ; 91  ae
  1618.     DB    'AE'    ; 92  AE
  1619.     DB    'o^'    ; 93  o^
  1620.     DB    'o~'    ; 94  o umlaut
  1621.     DB    'o`'    ; 95  o`
  1622.     DB    'u^'    ; 96  u^
  1623.     DB    'u`'    ; 97  u`
  1624.     DB    'y~'    ; 98  y umlaut
  1625.     DB    'O~'    ; 99  O umlaut
  1626.     DB    'U~'    ; 9A  U umlaut
  1627.     DB    'c|'    ; 9B  cent symbol
  1628.     DB    'L-'    ; 9C  British pound
  1629.     DB    'Y-'    ; 9D  Japanese yen
  1630.     DB    'Pt'    ; 9E  Spanish peseta
  1631.     DB    'S-'    ; 9F  curly f
  1632. ;
  1633.     DB    "a'"    ; A0  a'
  1634.     DB    "i'"    ; A1  i'
  1635.     DB    "o'"    ; A2  o'
  1636.     DB    "u'"    ; A3  u'
  1637.     DB    'n~'    ; A4  n~
  1638.     DB    'N~'    ; A5  N~
  1639.     DB    'a_'    ; A6  a_
  1640.     DB    'o_'    ; A7  o_
  1641.     DB    '?',0    ; A8  upside down ?
  1642.     DB    '/',0    ; A9  upper left corner
  1643.     DB    '\',0    ; AA  upper right corner
  1644.     DB    '12'    ; AB  1/2
  1645.     DB    '14'    ; AC  1/4
  1646.     DB    '!',0    ; AD  upside down !
  1647.     DB    '<<'    ; AE  <<
  1648.     DB    '>>'    ; AF  >>
  1649. ;
  1650.     DB    'HI'    ; B0  1/4 density block
  1651.     DB    'HX'    ; B1  1/3 density block
  1652.     DB    'H*'    ; B2  1/2 density block
  1653.     DB    '|',0    ; B3  single vertical
  1654.     DB    '|',0    ; B4  right vertical -|  1V 1H
  1655.     DB    '|',0    ; B5  right vertical =|  1V 2H
  1656.     DB    '|',0    ; B6  right vertical -|| 2V 1H
  1657.     DB    '\',0    ; B7  upper right 2V 1H
  1658.     DB    '\',0    ; B8  upper right 1V 2H
  1659.     DB    '|',0    ; B9  right vertical =|| 2V 2H
  1660.     DB    '|',0    ; BA  double vertical
  1661.     DB    '\',0    ; BB  upper right 2V 2H
  1662.     DB    '/',0    ; BC  bottom right 2V 2H
  1663.     DB    '/',0    ; BD  bottom right 2V 1H
  1664.     DB    '/',0    ; BE  bottom right 1V 2H
  1665.     DB    '\',0    ; BF  uppper right 1V 1H
  1666. ;
  1667.     DB    '\',0    ; C0  bottom left 1V 1H
  1668.     DB    '-',0    ; C1  bottom 1V 1H
  1669.     DB    '-',0    ; C2  top 1V 1H
  1670.     DB    '|',0    ; C3  left 1V 1H
  1671.     DB    '-',0    ; C4  horizontal 1H
  1672.     DB    '-|'    ; C5  cross 1V 1H
  1673.     DB    '|',0    ; C6  left 1V 2H
  1674.     DB    '|',0    ; C7  left 2V 1H
  1675.     DB    '\',0    ; C8  bottom left 2V 2H
  1676.     DB    '/',0    ; C9  top left 2V 2H
  1677.     DB    '-',0    ; CA  bottom 2V 2H
  1678.     DB    '-',0    ; CB  top 2V 2H
  1679.     DB    '|',0    ; CC  left 2V 2H
  1680.     DB    '-',0    ; CD  horizontal 2H
  1681.     DB    '-|'    ; CE  cross 2V 2H
  1682.     DB    '-',0    ; CF  bottom 1V 2H
  1683. ;
  1684.     DB    '-',0    ; D0  bottom 2V 1H
  1685.     DB    '-',0    ; D1  top 1V 2H
  1686.     DB    '-',0    ; D2  top 2V 1H
  1687.     DB    '\',0    ; D3  bottom left 2V 1H
  1688.     DB    '\',0    ; D4  bottom left 1V 2H
  1689.     DB    '/',0    ; D5  top left 1V 2H
  1690.     DB    '/',0    ; D6  top left 2V 1H
  1691.     DB    '-|'    ; D7  cross 2V 1H
  1692.     DB    '-|'    ; D8  cross 1V 2H
  1693.     DB    '/',0    ; D9  bottom right 1V 1H
  1694.     DB    '/',0    ; DA  top left 1V 1H
  1695.     DB    'H*'    ; DB  solid block
  1696.     DB    'mw'    ; DC  solid bottom half
  1697.     DB    '|',0    ; DD  solid left half
  1698.     DB    '|',0    ; DE  solid right half
  1699.     DB    '~^'    ; DF  solid top half
  1700. ;
  1701.     DB    'a',0    ; E0  alpha
  1702.     DB    'B,'    ; E1  beta
  1703.     DB    'g',0    ; E2  gamma
  1704.     DB    'n-'    ; E3  pi
  1705.     DB    'E',0    ; E4  epsilon
  1706.     DB    'r',0    ; E5  rho
  1707.     DB    'u.'    ; E6  mu
  1708.     DB    't',0    ; E7  tau
  1709.     DB    'oI'    ; E8  oI
  1710.     DB    'O-'    ; E9  O-
  1711.     DB    'n_'    ; EA  ohm
  1712.     DB    's',0    ; EB  sigma
  1713.     DB    'o|'    ; EC  o|
  1714.     DB    'O/'    ; ED  O/
  1715.     DB    'E',0    ; EE  round E
  1716.     DB    'n',0    ; EF  inverted U
  1717. ;
  1718.     DB    '=_'    ; F0  =_
  1719.     DB    '+_'    ; F1  +_
  1720.     DB    '>_'    ; F2  >_
  1721.     DB    '<_'    ; F3  <_
  1722.     DB    'f',0    ; F4  upper integral
  1723.     DB    'j',0    ; F5  lower integral
  1724.     DB    '-:'    ; F6  divide by
  1725.     DB    '~-'    ; F7  ~_
  1726.     DB    'o',0    ; F8  degree
  1727.     DB    '.',0    ; F9  high .
  1728.     DB    '-',0    ; FA  short -
  1729.     DB    'v-'    ; FB  v- divide by
  1730.     DB    'n',0    ; FC  superscript n
  1731.     DB    '2',0    ; FD  superscript 2
  1732.     DB    "'`"    ; FE  small centered block
  1733.     DB    UNK,0    ; FF  not used
  1734.  
  1735. STRNG    $SYMTAB
  1736. ;
  1737. ; Symbol table
  1738. ;
  1739. ;    WORD  symbol count
  1740. ;    REPEAT    6 BYTES symbol name
  1741. ;        WORD symbol address
  1742. ;        WORD symbol storage size
  1743. ;
  1744.     DW    SYMCNT
  1745. ;
  1746.     DB    'DATA  '    ; All strings and tables
  1747.     DW    $ORG
  1748.     DW    $LEN
  1749. ;
  1750.     DB    '$START'    ; Initialize string
  1751.     DW    $INIT
  1752.     DW    $LONG
  1753. ;
  1754.     DB    '$DONE '    ; Uninitialize string
  1755.     DW    $UNINT
  1756.     DW    $LONG
  1757.  
  1758.     DB    '$QUIT '    ; Abort string
  1759.     DW    $ABORT
  1760.     DW    $LONG
  1761.  
  1762.     DB    'CRLF  '
  1763.     DW    $CRLF
  1764.     DW    $SHORT
  1765.  
  1766.     DB    'CRET  '
  1767.     DW    $CR
  1768.     DW    $SHORT
  1769.  
  1770.     DB    '$FFEED'
  1771.     DW    $FF
  1772.     DW    $SHORT
  1773.  
  1774.     DB    'HALFLF'
  1775.     DW    $HLF
  1776.     DW    $SHORT
  1777.  
  1778.     DB    'BACKSP'
  1779.     DW    $BS
  1780.     DW    $SHORT
  1781.  
  1782.     DB    'NORMWD'
  1783.     DW    $NORM
  1784.     DW    $SHORT
  1785.  
  1786.     DB    'ALTRWD'
  1787.     DW    $ALT
  1788.     DW    $SHORT
  1789.  
  1790.     DB    'PHSP  '
  1791.     DW    $CTRLF
  1792.     DW    $SHORT
  1793.  
  1794.     DB    'PHRUB '
  1795.     DW    $CTRLG
  1796.     DW    $SHORT
  1797.  
  1798.     DB    'BINDSP'
  1799.     DW    $CTRLO
  1800.     DW    $SHORT
  1801.  
  1802.     DB    'BLDON '
  1803.     DW    $PBON
  1804.     DW    $SHORT
  1805.  
  1806.     DB    'BLDOFF'
  1807.     DW    $PBOFF
  1808.     DW    $SHORT
  1809.  
  1810.     DB    'DBLON '
  1811.     DW    $PDON
  1812.     DW    $SHORT
  1813.  
  1814.     DB    'DBLOFF'
  1815.     DW    $PDOFF
  1816.     DW    $SHORT
  1817.  
  1818.     DB    'UNDON '
  1819.     DW    $PSON
  1820.     DW    $SHORT
  1821.  
  1822.     DB    'UNDOFF'
  1823.     DW    $PSOFF
  1824.     DW    $SHORT
  1825.  
  1826.     DB    'SPRON '
  1827.     DW    $PTON
  1828.     DW    $SHORT
  1829.  
  1830.     DB    'SPROFF'
  1831.     DW    $PTOFF
  1832.     DW    $SHORT
  1833.  
  1834.     DB    'SUBON '
  1835.     DW    $PVON
  1836.     DW    $SHORT
  1837.  
  1838.     DB    'SUBOFF'
  1839.     DW    $PVOFF
  1840.     DW    $SHORT
  1841.  
  1842.     DB    'STKON '
  1843.     DW    $PXON
  1844.     DW    $SHORT
  1845.  
  1846.     DB    'STKOFF'
  1847.     DW    $PXOFF
  1848.     DW    $SHORT
  1849.  
  1850.     DB    'ITLON '
  1851.     DW    $PYON
  1852.     DW    $SHORT
  1853.  
  1854.     DB    'ITLOFF'
  1855.     DW    $PYOFF
  1856.     DW    $SHORT
  1857.  
  1858.     DB    'EXTON '
  1859.     DW    $BIDON
  1860.     DW    $SHORT
  1861.  
  1862.     DB    'EXTOFF'    
  1863.     DW    $BIDOFF
  1864.     DW    $SHORT
  1865.  
  1866.     DB    'NLQON '
  1867.     DW    $LQON
  1868.     DW    $SHORT
  1869.  
  1870.     DB    'NLQOFF'
  1871.     DW    $LQOFF
  1872.     DW    $SHORT
  1873.  
  1874.     DB    'COMPOS'
  1875.     DW    $COMPOS
  1876.     DW    512
  1877. ;
  1878.     DB    'CODE  '    ; Model 1 code
  1879.     DW    PGORG
  1880.     DW    PGLEN
  1881.  
  1882. SYMCNT    EQU    ($-$SYMTAB)/10
  1883.  
  1884. $LEN    EQU    $-$ORG
  1885.  
  1886.     END
  1887.