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 / MBUG / MBUG115.ARC / MXSET22.MAC < prev    next >
Text File  |  1979-12-31  |  22KB  |  1,121 lines

  1. ;MXSET
  2. ;**********************************************************
  3. ;
  4. ;This program will set/reset all of the major functions of the
  5. ;Epson MX80 or MX-100 printer with or without Graftrax
  6. ;The program uses Z80 Zilog mnemonics and calls are made to 
  7. ;Richard Conn's excellent SYSLIB.REL file. 
  8. ;Microsoft's M80 macro assembler is needed 
  9. ;
  10. ;***********************************************************
  11. ;
  12. ;Rev  2.2  21 April 84   Frans Van Duinen
  13. ;  fixed some bugs introduced with ver 2.1
  14. ;  capability to run under WS
  15. ;
  16. ;Rev  2.1  20 April 84   Frans Van Duinen, Toronto
  17. ;  set up for MX80 or 100 with or without Graftrax,
  18. ;  cleaned up coding
  19. ;Rev  2.0  16 April 84   David C. Naylor, Halton Hills
  20. ;  set up for MX100 without graftrax 
  21. ;
  22. ;Rev. 1.2 by Simon J. Ewins, Toronto, Ontario, Canada.
  23. ; June 28, 1983.   Toronto, Ontario.
  24. ;
  25. ;
  26. ; Legend:
  27. ;
  28. ;  <DE> - refers to content of registers, e.g. <A>
  29. ;   DE> - refers to memory location pointed to be register pair
  30. ;   <>  - not equal
  31. ;
  32. ; SYSLIB functions used
  33.     EXTRN    BBLINE        ;Get input line, returns HL>line
  34. ;                 <A> count; on input <A><>0 - capitalize
  35.     EXTRN    EVAL10        ;Convert decimal number at HL> to binary
  36. ;                 returns <DE> number, HL> next char
  37. ;                 handling of nos>65535 unknown
  38. ;                 returns zero if no valid digits
  39. ;
  40. ;Note that CIN, COUT PRINT CCOUT are not compatible with WS
  41. ;
  42. ;Conditional assembly
  43. ;
  44. FALSE    EQU    0
  45. TRUE    EQU    NOT FALSE
  46. ;
  47. MX100    EQU    TRUE    ;Set true if using wider printer
  48. GTRAX    EQU    FALSE    ;Set true if printer graftrax equiped
  49. ;
  50. ;
  51. ; Equated symbols
  52. BELL    EQU    07    ;Bell
  53. BS    EQU    08    ;Backspace
  54. LF    EQU    0AH    ;Linefeed
  55. FF    EQU    0CH    ;Formfeed
  56. CR    EQU    0DH    ;Carriage return
  57. SO    EQU    0EH    ;Turn on double width
  58. SI    EQU    0FH    ;Shift in (activates compressed)
  59. DC2    EQU    12H    ;Turn off compressed
  60. DC4    EQU    14H    ;Turn off double width
  61. EOF    EQU    1AH    ;End of file (^Z)
  62. ESC    EQU    1BH    ;Escape char
  63. ;
  64. OFF    EQU    0    ;Off flag
  65. ON    EQU    1    ;On flag for printer
  66. ;
  67. ;
  68. BDOS    EQU    5    ;Entry for BDOS
  69. ;
  70.     IF    MX100
  71. ;
  72. ; MX100 related values
  73. ;
  74. MAXWDTH    EQU    233    ;Max page width
  75. ;
  76.     ELSE
  77. ;
  78. ; MX80  related values
  79. ;
  80. MAXWDTH    EQU    132    ;Max page width
  81. ;
  82.     ENDIF
  83. ;
  84. ;Techniques:
  85. ;
  86. ;Note the sequence 
  87. ;    CALL LPRINT
  88. ;    DB   ESC,...,0
  89. ;
  90. ; The routine LPRINT never returns control. 
  91. ; instead it exits to label START, a call is used
  92. ; to pass the return address as the addr of the string
  93. ; to print. String must terminate on 00H
  94. ;
  95. ;
  96. ;Note that the sequence 
  97. ;    CALL RPRINT
  98. ;    DB   ESC,...,0
  99. ;
  100. ; does return control
  101. ;
  102. ;
  103.     .Z80
  104.     CSEG
  105. ;
  106.     JP    START        ;Skip subrtn
  107. CLR:
  108.     DB    1AH,0,0,0,0,0,0    ;Clear screen & home cursor
  109. ;                Set to sequence for your computer:
  110. ;                Osborne   - 1AH,0
  111. ;                Televideo - 1AH,0
  112. ;                Heath     - ESC,'E',0
  113. ;                If not wanted set to CR,LF,LF,LF...
  114. ;
  115. START:
  116.     CALL    CPRINT        ;Cls & display
  117.     DB    'EPSON SET-UP ver 2.2',CR,LF
  118. ;
  119.     IF    MX100
  120. ;
  121.     DB    'For MX100 '
  122. ;
  123.     ELSE
  124. ;
  125.     DB    'For MX80 '
  126. ;
  127.     ENDIF
  128. ;
  129.     IF    GTRAX
  130. ;
  131.     DB    'with Graftrax '
  132. ;
  133.     ELSE
  134. ;
  135.     DB    'without Graftrax '
  136. ;
  137.     ENDIF
  138. ;
  139.     DB    CR,LF
  140.     DB    'OPTIONS:',CR,LF
  141.     DB    'A: Select character font',CR,LF
  142. ;
  143.     IF    GTRAX
  144. ;
  145.     DB    'B: Reset printer to defaults',CR,LF
  146. ;
  147.     ELSE
  148. ;
  149.     DB    'B: Select character set',CR,LF
  150. ;
  151.     ENDIF
  152. ;
  153.     DB    'C: Set line spacing',CR,LF
  154.     DB    'D: Set page size',CR,LF
  155. ;
  156.     IF    GTRAX
  157. ;
  158.     DB    'E: Set uni-directional print ON/OFF',CR,LF
  159. ;
  160.     ELSE
  161. ;
  162.     DB    'E: Set vertical tabs',CR,LF
  163. ;
  164.     ENDIF
  165. ;
  166.     DB    'F: Set horizontal tabs',CR,LF
  167.     DB    'G: Set to top of form (FF)',CR,LF
  168.     DB    'H: Turn ON perforation skip',CR,LF
  169.     DB    'I: Turn OFF perforation skip',CR,LF
  170.     DB    'J: Enable out of paper signal',CR,LF
  171.     DB    'K: Disable out of paper signal',CR,LF
  172.     DB    'L: Print test',CR,LF
  173. ;
  174.     IF    GTRAX
  175. ;
  176.     DB    'M: Set bit 8 handling',CR,LF
  177.     DB    'N: Home printhead',CR,LF
  178.     DB    'O: Set graphics mode',CR,LF
  179. ;
  180.     ENDIF
  181. ;
  182.     DB    'Z: Keyboard to printer',CR,LF 
  183.     DB    '^C: Quit to CP/M',CR,LF,LF,0
  184.     CALL    CHOICE        ;Complete menu, get input
  185. ;
  186.     CP    'A'
  187.     JP    Z,LA        ;Select type font
  188.     CP    'B'
  189.     JP    Z,LB        ;Select character set/reset printer
  190.     CP    'C'
  191.     JP    Z,LC        ;Set line spacing 
  192.     CP    'D'
  193.     JP    Z,LD        ;Set page size
  194.     CP    'E'
  195.     JP    Z,LE        ;Set vertical tabs/reset
  196.     CP    'F'
  197.     JP    Z,LBLF        ;Set horizontal tabs
  198.     CP    'G'
  199.     JP    Z,LG        ;Force formfeed
  200.     CP    'H'
  201.     JP    Z,LH        ;Set perf skip on
  202.     CP    'I'
  203.     JP    Z,LI        ;Set perf skip off
  204.     CP    'J'
  205.     JP    Z,LJ        ;Enable paper-out detector (signal only)
  206.     CP    'K'
  207.     JP    Z,LK        ;Disable paper-out detector
  208.     CP    'L'
  209.     JP    Z,LL        ;Print test
  210. ;
  211.     IF    GTRAX
  212. ;
  213.     CP    'M'
  214.     JP    Z,LM        ;Handling of h/o bit
  215.     CP    'N'
  216.     JP    Z,LN        ;Home print head
  217.     CP    'O'
  218.     JP    Z,LO        ;Set graphics
  219. ;
  220.     ENDIF
  221. ;
  222.     CP    'Z'
  223.     JP    Z,LZ        ;Keyboard to printer
  224. ;
  225. ;            Invalid response
  226. ERROR:
  227.     CALL    PRINT
  228.     DB    BELL,0
  229.     JP    START
  230. ;
  231. ;
  232. ;
  233. ;            Select font
  234. LA:
  235.     CALL    CPRINT        ;Cls & display
  236.     DB    CR,LF,LF
  237.     DB    '1:  Set condensed ON',CR,LF
  238.     DB    '2:  Set condensed OFF',CR,LF
  239.     DB    '3:  Set enlarged ON',CR,LF
  240.     DB    '4:  Set enlarged OFF',CR,LF
  241.     DB    '5:  Set emphasized ON',CR,LF
  242.     DB    '6:  Set emphasized OFF',CR,LF
  243. ;
  244.     IF    GTRAX
  245. ;
  246.     DB    '7:  Set Italics ON',CR,LF
  247.     DB    '8:  Set Italics OFF',CR,LF
  248.     DB    '9:  Set double strike ON',CR,LF
  249.     DB    '10: Set double strike OFF',CR,LF
  250.     DB    '11: Set to subscript',CR,LF
  251.     DB    '12: Set to superscript',CR,LF
  252.     DB    '13: Set super/subscript OFF',CR,LF
  253.     DB    '14: Set permanent enlarged ON',CR,LF
  254.     DB    '15: Set permanent enlarged OFF',CR,LF
  255. ;
  256.     ENDIF
  257. ;
  258.     DB    LF,0        ;Extra LF & terminating null
  259. ;
  260.     CALL    CHOICE        ;Get response 
  261.     LD    B,1        ;Set minimum
  262. ;
  263.     IF    GTRAX
  264. ;
  265.     LD    C,16        ;Get max+1
  266. ;
  267.     ELSE
  268. ;
  269.     LD    C,7        ;Get max+1
  270. ;
  271.     ENDIF
  272. ;
  273.     CALL    NUMBER
  274.     CP    1        ;Test flag
  275.     JP    Z,START        ;Get out on thru
  276.     JP    NC,LA        ;Out of range
  277. ;
  278. ;                 Note that different selections
  279. ;                 have differing formats:
  280. ;                 1 - SI  - no ESC
  281. ;                 2 - DC2 - no ESC
  282. ;                 3 - SO  - no ESC
  283. ;                 4 - DC4 - no ESC
  284. ;                 5 - ESC,'E' 
  285. ;                 6 - ESC,'F'
  286. ;                 7 - ESC,'4'
  287. ;                 8 - ESC,'5'
  288. ;                 9 - ESC,'G'
  289. ;                10 - ESC,'H'
  290. ;                11 - ESC,'S',OFF
  291. ;                12 - ESC,'S',ON
  292. ;                13 - ESC,'T'
  293. ;                14 - ESC,'W',ON
  294. ;                15 - ESC,'W',OFF
  295. ;
  296.     LD    A,E        ;Get index
  297.     LD    HL,ATABL-1    ;Index table (offset for ascii char index)
  298.      ADD    A,L        ;Combine with index char
  299.     JR    NC,LA1        ;No carry to high byte
  300.     INC    H
  301. LA1:
  302.     LD    L,A        ;Complete index
  303. ;
  304.  
  305.     LD    A,(HL)        ;Get byte at HL>
  306.     PUSH    AF        ; & save
  307.     LD    A,E        ;Get selection back
  308.     CP    5
  309.     JR    C,LA2        ; 1-4 no ESC
  310.     LD    A,ESC
  311.     CALL    LOUT
  312. LA2:
  313.     POP    AF
  314.     CALL    LOUT        ;Byte from table
  315. ;
  316. ;
  317.     IF    GTRAX
  318. ;
  319.     LD    A,11
  320.     SUB    E        ;Normalize '11' & '12' to 0 & 1
  321.     CP    2        ;Is this option 11 or 12?
  322.     JP    C,LA3        ;Yes - put normalized
  323.     OR    A        ;Was this #1 - #10 (positive now)
  324.     JP    P,START        ;Yes - get out
  325.     CP    255        ;No - was it #13 
  326.     JP    Z,START        ;Yes - is complete
  327.     ADD    A,4        ;No - adjust 14 - 15 to 1 - 0
  328. LA3:
  329.     CALL    LOUT        ;Output 0 (option 11/14) or 1 (12/15)
  330. ;
  331.     ENDIF 
  332. ;
  333.     JP    START
  334. ;
  335. ;
  336. ATABL:    DB    SI,DC2        ;Condensed on/off - no ESC
  337.     DB    SO,DC4        ;Enlarged (double width) on/off - no ESC
  338.     DB    'E','F'        ;Emphasized on/off 
  339. ;
  340.     IF    GTRAX
  341. ;
  342.     DB    '4','5'        ;Italics on/off
  343.     DB    'G','H'        ;Double strike on/off
  344.     DB    'S','S'        ;Super/subscr - with ESC & 1,0
  345.     DB    'T'        ;Super/sub off - with Esc
  346.     DB    'W','W'        ;Double width on/off - With ESC & 1,0
  347. ;
  348.     ENDIF
  349. ;
  350. ;
  351. ;
  352. LB:
  353. ;
  354.     IF    GTRAX
  355. ;            Reset printer to default
  356.     CALL    LPRINT        ;Print & exit
  357.     DB    ESC,'@',0
  358. ;
  359. ;
  360.     ELSE
  361. ;
  362.                 ;Select character set
  363.     CALL    CPRINT        ;Cls & display
  364.     DB    CR,LF,LF
  365.     DB    '1:  North American',CR,LF
  366.     DB    '2:  British',CR,LF
  367.     DB    '3:  French',CR,LF
  368.     DB    '4:  German',CR,LF
  369.     DB    '5:  Spanish',CR,LF
  370.     DB    '6:  Italian',CR,LF
  371.     DB    '7:  Danish',CR,LF
  372.     DB    '8:  Swedish',CR,LF,LF
  373. ;
  374.     CALL    CHOICE        ;Get response
  375.     LD    B,1        ;Set minimum
  376.     LD    C,9        ; & max+1
  377.     CALL    NUMBER
  378.     CP    1        ;Test flag
  379.     JP    Z,START        ;Get out on thru
  380.     JP    NC,LB        ;Out of range
  381.     LD    A,E        ;Get index
  382.     LD    HL,BTABL-1    ;Index table (offset for ascii char index)
  383.      ADD    A,L        ;Combine with index char
  384.     JR    NC,LB1        ;No carry to high byte
  385.     INC    H
  386. LB1:    
  387.     LD    L,A        ;Complete index
  388. ;
  389.     CALL    RPRINT
  390.     DB    ESC,'R',0    ;Put out 1st part
  391.     LD    A,(HL)        ;Get language/ char set code
  392.     CALL    LOUT        ;May be zero
  393.     JP    START
  394. ;
  395. ;
  396. ;
  397. BTABL:    DB    0        ;North American
  398.     DB    3        ;British
  399.     DB    1        ;French
  400.     DB    2        ;German
  401.     DB    7        ;Spanish
  402.     DB    6        ;Italian
  403.     DB    4        ;Danish
  404.     DB    5        ;Swedish
  405. ;
  406. ;
  407.     ENDIF
  408. ;
  409. ;
  410. ;
  411. LC:            ;Set line spacing
  412.     CALL    CPRINT        ;Cls & display
  413.     DB    '1: Select 6 lines per inch',CR,LF
  414.     DB    '2: Select 8 lines per inch',CR,LF
  415.     DB    '3: Set line spacing in 1/72" increments',CR,LF
  416. ;
  417.     IF    GTRAX
  418. ;
  419.     DB    '4: Set line spacing in 1/216" increments',CR,LF
  420. ;
  421.     ENDIF
  422. ;
  423.     DB    LF,0        ;Mark end of string
  424. ;
  425.     CALL    CHOICE        ;Get input
  426.     LD    B,1        ;Set minimum
  427. ;
  428.     IF    GTRAX
  429. ;
  430.     LD    C,5        ; & max+1
  431. ;
  432.     ELSE
  433. ;
  434.     LD    C,4        ; & max+1
  435. ;
  436.     ENDIF
  437. ;
  438.     CALL    NUMBER
  439.     CP    1        ;Test flag
  440.     JP    Z,START        ;Get out on thru
  441.     JP    NC,LC        ;Out of range
  442.     LD    A,E        ;Get index
  443.     CP    2        ;Which one?
  444.     JR    Z,LC2        ;#2
  445.     JR    NC,LC3        ;#3 (or 4 if GTRAX)
  446. ;
  447.             ;Select 6 lines per inch
  448.     CALL    LPRINT        ;Print & exit
  449.     DB    ESC,'2',0    ;Set 6 lines/inch
  450. ;
  451. ;
  452. LC2:            ;Select 8 lines per inch
  453.     CALL    LPRINT        ;Print & exit
  454.     DB    ESC,'0',0    ;Set 8 lines/inch
  455. ;
  456. ;
  457. LC3:            ;Set variable line spacing
  458. ;
  459.     IF    GTRAX
  460. ;
  461.     CP    4        ;Item 4 (1/216)    
  462.     JR    NZ,LC5        ;No -
  463. ;
  464. LC4:
  465.     CALL    PRINT
  466.     DB    CR,LF,LF,'Enter quantity of 1/216 inches (max 85): ',CR,LF
  467.     DB    '---> ? ',0
  468. ;
  469.     LD    A,0        ;No capitals reqd
  470.     CALL    BBLINE        ;Get input line
  471.     LD    B,1        ;Set minimum
  472.     LD    C,0        ; & max+1 (256)
  473.     CALL    NUMBER
  474.     CP    1        ;Test flag
  475.     JP    Z,START        ;Get out on thru
  476.     JP    NC,LC4        ;Out of range
  477.     LD    A,E        ;Get index
  478.     LD    (LC42),A
  479.     CALL    LPRINT        ;Print & exit
  480.     DB    ESC,'3'        ;Set spacing in 1/216" increments
  481. LC42:    DB    1,0
  482. ;
  483. ;
  484. ;
  485.     ENDIF
  486. ;
  487. LC5:
  488.     CALL    PRINT
  489.     DB    CR,LF,LF,'Enter quantity of 1/72 inches (max 85): ',CR,LF
  490.     DB    '---> ? ',0
  491. ;
  492.     LD    A,0        ;No capitals reqd
  493.     CALL    BBLINE        ;Get input line
  494.     LD    B,1        ;Set minimum
  495.     LD    C,86        ; & max+1
  496.     CALL    NUMBER
  497.     CP    1        ;Test flag
  498.     JP    Z,START        ;Get out on thru
  499.     JP    NC,LC5        ;Out of range
  500.     LD    A,E        ;Get index
  501.     LD    (LC52),A
  502.     CALL    LPRINT        ;Print & exit
  503.     DB    ESC,'A'        ;Set LF spacing in 1/72" increments
  504. LC52:    DB    1,0
  505. ;
  506. ;
  507. LD:            ;Set page dimensions
  508.     CALL    CPRINT        ;Cls & display
  509.     DB    '1: Set form length in lines',CR,LF
  510.     DB    '2: Set form length in inches',CR,LF
  511.     DB    '3: Set width',CR,LF,0
  512. ;
  513.     CALL    CHOICE
  514.     LD    B,1        ;Set minimum
  515.     LD    C,4        ; & max+1
  516.     CALL    NUMBER
  517.     CP    1        ;Test flag
  518.     JP    Z,START        ;Get out on thru
  519.     JP    NC,LD        ;Out of range
  520.     LD    A,E        ;Get index
  521.     CP    2        ;Which one?
  522.     JP    NC,LD3        ;#3
  523.     JR    Z,LD2        ;#2
  524. ;
  525.             ;Set page length in lines
  526. LD1:
  527.     CALL    PRINT
  528.     DB    CR,LF,LF,'Enter length in lines (max 127): ',CR,LF
  529.     DB    '---> ? ',0
  530. ;
  531.     LD    A,0
  532.     CALL    BBLINE
  533.     LD    B,1        ;Set minimum
  534.     LD    C,128        ; & max+1
  535.     CALL    NUMBER
  536.     CP    1        ;Test flag
  537.     JP    Z,START        ;Get out on thru
  538.     JP    NC,LD1        ;Out of range
  539.     LD    A,E        ;Get index
  540.     LD    (LD12),A
  541.     CALL    LPRINT        ;Print & exit
  542.     DB    ESC,'C'
  543. LD12:    DB    1,0
  544. ;
  545. ;
  546. ;
  547. LD2:            ;Set page length in inch increments
  548.     CALL    PRINT
  549.     DB    CR,LF,LF,'Enter length in inches (max 22): ',CR,LF
  550.     DB    '---> ? ',0
  551. ;
  552.     LD    A,0
  553.     CALL    BBLINE
  554.     LD    B,1        ;Set minimum
  555.     LD    C,23        ; & max+1
  556.     CALL    NUMBER
  557.     CP    1        ;Test flag
  558.     JP    Z,START        ;Get out on thru
  559.     JP    NC,LD2        ;Out of range
  560.     LD    A,E        ;Get index
  561.     LD    (LD22),A
  562. ;
  563.     CALL    RPRINT
  564.     DB    ESC,'C',0
  565.     XOR    A        ;Force null
  566.     CALL    LOUT        ; & put
  567. ;
  568.     CALL    LPRINT        ;Print & exit
  569. LD22:    DB    1,0
  570. ;
  571. ;
  572. LD3:            ;Set page width
  573.     CALL    PRINT
  574.     DB    CR,LF,LF,'Enter width: ',CR,LF
  575. ;
  576.     IF    MX100
  577. ;
  578.     DB    'Up to 136 in normal or emphasized mode.',CR,LF
  579.     DB    '      233 in condensed mode.',CR,LF
  580.     DB    '       68 in enlarged mode.',CR,LF
  581.     DB    '      116 in enlarged-condensed mode',CR,LF
  582. ;
  583.     ELSE
  584. ;
  585.     DB    'Up to  80 in normal or emphasized mode.',CR,LF
  586.     DB    '      132 in condensed mode.',CR,LF
  587.     DB    '       40 in enlarged mode.',CR,LF
  588.     DB    '       60 in enlarged-condensed mode',CR,LF
  589. ;
  590.     ENDIF
  591. ;
  592.  
  593.  
  594.     DB    '---> ? ',0
  595. ;
  596.     LD    A,0
  597.     CALL    BBLINE
  598.     LD    B,1        ;Set minimum
  599.     LD    C,MAXWDTH+1    ; & max+1
  600.     CALL    NUMBER
  601.     CP    1        ;Test flag
  602.     JP    Z,START        ;Get out on thru
  603.     JP    NC,LD3        ;Out of range
  604.     LD    A,E        ;Get index
  605.     LD    (LD32),A
  606.     CALL    LPRINT        ;Print & exit
  607.     DB    ESC,'Q'
  608. LD32:    DB    1,0
  609. ;
  610. ;
  611. ;
  612. ;
  613. ;
  614. LE:
  615. ;
  616.     IF    GTRAX
  617. ;
  618. ;            Set uni-directional print on/off
  619.     CALL    CPRINT        ;Cls & display
  620.     DB    '1:  Set uni-directional print ON',CR,LF
  621.     DB    '2:  Set uni-directional print OFF',CR,LF,0
  622. ;
  623.     CALL    CHOICE        ;Ask & get input
  624.     LD    B,1        ;Set minimum
  625.     LD    C,3        ; & max+1
  626.     CALL    NUMBER
  627.     CP    1        ;Test flag
  628.     JP    Z,START        ;Get out on thru
  629.     JP    NC,LE        ;Out of range
  630.     CALL    RPRINT
  631.     DB    ESC,'U',0
  632.     LD    A,2        ;Convert index to 1/0 flag
  633.     SUB    E        ;1 now 1; 2 now 0
  634.     CALL    LOUT
  635.     JP    START
  636. ;
  637. ;
  638.     ELSE
  639. ;
  640. ;            ;Set vertical tabs
  641.     CALL    CPRINT        ;Cls & display
  642.     DB    CR,LF,LF,'Enter vertical tab positions (max 8)',CR,LF
  643.     DB    '(in ascending order) ---> ? ',0
  644. ;
  645.     LD    A,0
  646.     CALL    BBLINE        ;Get line of tabs, terminated by 00h
  647.     LD    IX,VTABS    ;Set to tab list
  648.     LD    A,1        ;Set minimum tab
  649.     LD    (IX),A        ;Prime tab list
  650.     LD    C,128        ;Set max tab+1 (we dont know page len)    
  651.     LD    B,8        ;Set loop count
  652.     CALL    TABS        ;Handle tabs, returns flag in <A>
  653.     OR    A        ;OK?
  654.     JR    Z,LE2        ;Yes
  655.     DEC    A        ;No - exit?
  656.     JP    Z,START        ;Yes -
  657.     JR    LE        ;No - ask new input
  658. ;
  659. ;            Output tab string
  660. LE2:
  661.     LD    HL,VTABS-2    ;Set to string to put
  662.     JP    HTBS2        ; & go put
  663. ;
  664. ;
  665. ;
  666.     DB    ESC,'B'        ;Vertical tabs
  667. VTABS:    DB    1,0,0,0,0,0,0,0,0  ;8 tabs & null
  668. ;
  669. ;
  670. ;
  671.     ENDIF
  672. ;
  673. ;
  674. LBLF:            ;Set horizontal tabs
  675.     CALL    CPRINT        ;Cls & display
  676.     DB    CR,LF,LF,'Enter horizontal tab positions (max 12)',CR,LF
  677.     DB    '(in ascending order) ---> ? ',0
  678. ;
  679.     LD    A,0
  680.     CALL    BBLINE
  681.     LD    IX,HTABS    ;Set to tab list
  682.     LD    A,1        ;Set minimum tab
  683.     LD    (IX),A        ;Prime tab list
  684.     LD    C,MAXWDTH+1    ;Set max tab+1 (we dont know page width)
  685.     LD    B,12        ;Set loop count
  686.     CALL    TABS        ;Handle tabs, returns flag in <A>
  687.     OR    A        ;OK?
  688.     JR    Z,LBLF2        ;Yes
  689.     DEC    A        ;No - exit?
  690.     JP    Z,START        ;Yes -
  691.     JR    LBLF        ;No - ask new input
  692. ;
  693. ;            Output tab string
  694. LBLF2:
  695.     LD    HL,HTABS-2    ;Set to string to put
  696. HTBS2:
  697.     CALL    LPR        ;Put string at HR>
  698. ;                 Is safer than RPRINT due to variable len
  699. ;                 past null may be garbage
  700.     XOR    A        ;Force null after tabs
  701.     CALL    LOUT
  702.     JP    START
  703. ;
  704. ;
  705.     DB    ESC,'D'
  706. HTABS:    DB    1,0,0,0,0,0,0,0,0,0,0,0,0  ; 12 tabs & null
  707. ;
  708. ;
  709. ;
  710. LG:            ;Set top of form (FF)
  711.     CALL    LPRINT        ;Print & exit
  712.     DB    FF,0        ;Output formfeed
  713. ;
  714. ;
  715. LH:            ;Turn on perf. skip-over
  716.     CALL    CPRINT        ;Cls & display
  717.     DB    CR,LF,LF
  718.     DB    'Enter no of lines to skip over perforation'
  719.     DB    ' (max 127)',CR,LF
  720.     DB    '---> ? ',0
  721. ;
  722.     LD    A,0
  723.     CALL    BBLINE
  724.     LD    B,1        ;Set minimum
  725.     LD    C,128        ; & max+1
  726.     CALL    NUMBER
  727.     CP    1        ;Test flag
  728.     JP    Z,START        ;Get out on thru
  729.     JP    NC,LH        ;Out of range
  730.     LD    A,E        ;Get index
  731.     LD    (LH2),A
  732.     CALL    LPRINT        ;Print & exit
  733.     DB    ESC,'N'
  734. LH2:    DB    0,0        ;Skip n lines
  735. ;
  736. ;
  737. ;
  738. LI:            ;Turn off perf. skip-over
  739.     CALL    LPRINT        ;Print & exit
  740.     DB    ESC,'O',0
  741. ;
  742. ;
  743. ;
  744. LJ:            ;Enable paper-out signal
  745.     CALL    LPRINT        ;Print & exit
  746.     DB    ESC,'9',0
  747. ;
  748. ;
  749. ;
  750. LK:            ;Disable paper-out signal
  751.     CALL    LPRINT        ;Print & exit
  752.     DB    ESC,'8',0    ;Disable paper-out sensor
  753. ;
  754. ;
  755. ;
  756. LL:            ;Print test
  757.     CALL    LPRINT
  758. ;    DB    CR,LF,LF       ;Removed re double width SO
  759.     DB    'ABCDEFGHIJKLMNOPQRSTUVWXYZ  '
  760.     DB    'abcdefghijklmnopqrstuvwxyz',CR,LF
  761.     DB    "1234567890-=['\;,./"
  762.     DB    '!@#$%^&*()_+]"|:<>?',CR,LF,LF,0
  763. ;
  764. ;
  765.     IF    GTRAX
  766. ;
  767. LM:            ;Set handling of 8th bit
  768.     CALL    CPRINT        ;Cls & display
  769.     DB    '1:  Bit 8 as is',CR,LF
  770.     DB    '2:  Bit 8 always ON',CR,LF
  771.     DB    '3:  Bit 8 always OFF',CR,LF,0
  772. ;
  773.     CALL    CHOICE        ;Ask & get input
  774.     LD    B,1        ;Set minimum
  775.     LD    C,4        ; & max+1
  776.     CALL    NUMBER
  777.     CP    1        ;Test flag
  778.     JP    Z,START        ;Get out on thru
  779.     JP    NC,LM        ;Out of range
  780.     LD    A,E        ;Get index
  781.     LD    HL,MTABL-1    ;Index table (offset for ascii char index)
  782.      ADD    A,L        ;Combine with index char
  783.     JR    NC,LM1        ;No carry to high byte
  784.     INC    H
  785. LM1:
  786.     LD    L,A        ;Complete index
  787. ;
  788.     LD    A,(HL)        ;Get byte at HL>
  789.     LD    (LMBYT),A    ; & store in string
  790.     CALL    LPRINT        ;Print & exit
  791.     DB    ESC
  792. LMBYT:    DB    0,0
  793. ;
  794. ;
  795. MTABL:    DB    '#','>','='    ;As is, on, off        
  796. ;
  797. ;
  798. ;
  799. LN:            ;Home print head
  800.     CALL    LPRINT        ;Print & exit
  801.     DB    ESC,'<',0
  802. ;
  803. ;
  804. LO:            ;Set graphics 
  805.     CALL    CPRINT        ;Cls & display
  806.     DB    '1:  Set medium density graphics',CR,LF
  807.     DB    '2:  Set high density graphics',CR,LF,0
  808. ;
  809.     CALL    CHOICE        ;Ask & get input
  810.     LD    B,1        ;Set minimum
  811.     LD    C,3        ; & max+1
  812.     CALL    NUMBER
  813.     CP    1        ;Test flag
  814.     JP    Z,START        ;Get out on thru
  815.     JP    NC,LO        ;Out of range
  816.     LD    A,E        ;Get index
  817.     CP    1        ;Medium density?
  818.     JR    NZ,LO2        ;No - high
  819. ;
  820. ;            Set medium density
  821.     CALL    LPRINT        ;Print & exit
  822.     DB    ESC,'K'
  823. ;
  824.     ENDIF
  825.     IF    GTRAX  AND  MX100
  826. ;    (nested conditionals dont work with ASM,
  827. ;     and I know M80 macros are  v e r y  flakey)
  828. ;
  829.     DB    03H,30H,0    ;816
  830. ;
  831.     ENDIF
  832.     IF    GTRAX  AND  NOT MX100
  833. ;
  834.     DB    01H,0E0H,0    ;460
  835. ;
  836.     ENDIF
  837.     IF    GTRAX
  838. ;
  839. ;
  840. ;
  841. LO2:            ;Set graphics - high density
  842.     CALL    LPRINT        ;Print & exit
  843.     DB    ESC,'L'
  844. ;
  845.     ENDIF
  846.     IF    GTRAX  AND  MX100
  847. ;
  848.     DB    06H,60H,0    ;1632
  849. ;
  850.     ENDIF
  851.     IF    GTRAX  AND  NOT MX100
  852. ;
  853.     DB    03H,0C0H,0    ;960
  854. ;
  855.     ENDIF
  856. ;
  857. ;
  858. ;            Keyboard to printer
  859. LZ:
  860.     CALL    CPRINT        ;Cls & display
  861.     DB    'All keys pressed are passed to the printer',CR,LF
  862.     DB    'This includes all control keys, except ^Z',CR,LF
  863.     DB    'Use ^Z to end',CR,LF,CR,LF,0
  864. ;
  865. LZLP:
  866.     CALL    DIN        ;Get one char
  867.     OR    A        ;Anything?
  868.     JR    Z,LZLP        ;No - try again
  869.     CALL    CCOUT        ;& display, control char as ^. 
  870.     CP    EOF        ;^Z?
  871.     JP    Z,START        ;Yes - get out
  872.     CALL    LOUT        ;No - put to printer
  873.     JR    LZLP        ;Go for next 
  874. ;
  875. ;
  876. ;    Print string on printer & exit
  877. LPRINT:
  878.     EX    (SP),HL        ;Save <HL> & get string addr
  879.     CALL    LPR        ;Print string at HL>
  880.     POP    HL        ;Restore register used 
  881.     JP    START
  882. ;
  883. ;    Print string on printer & return
  884. RPRINT:
  885.     EX    (SP),HL        ;Save <HL> & get string addr
  886.     CALL    LPR        ;Print string at HL>
  887.     EX    (SP),HL        ;Restore register used & return addr
  888.     RET
  889. ;
  890. ;            Print string at HL>
  891. ;
  892. LPR:
  893.     PUSH    AF
  894. LPRLP:
  895.     LD    A,(HL)        ;Get next char
  896.     INC    HL        ; & step past
  897.     OR    A        ;End?
  898.     JR    Z,LPREX        ;Yes
  899.     CALL    LOUT        ;Output byte in <A>
  900.     JR    LPRLP        ;Go for next byte
  901. ;
  902. LPREX:
  903.     POP    AF
  904.     RET
  905. ;
  906. ;    Print string on Console & return
  907. PRINT:
  908.     EX    (SP),HL        ;Save <HL> & get string addr
  909.     CALL    PR        ;Print string at HL>
  910.     EX    (SP),HL        ;Restore register used & return addr
  911.     RET
  912. ;
  913. ;            Print string at HL> on console
  914. ;
  915. PR:
  916.     PUSH    AF
  917. PRLP:
  918.     LD    A,(HL)        ;Get next char
  919.     INC    HL        ; & step past
  920.     OR    A        ;End?
  921.     JR    Z,PREX        ;Yes
  922.     CALL    COUT        ;Output byte in <A>
  923.     JR    PRLP        ;Go for next byte
  924. ;
  925. PREX:
  926.     POP    AF
  927.     RET
  928. ;
  929. ;
  930. ;            loop through all tabs
  931. ;                ;HL> tab source string
  932. ;                ;IX> tab destination list
  933. ;                ;<B> max no of tabs
  934. ;                ;<C> max allowed tab
  935. ;                ;Returns <A> 0 - ok, 1 zero tab found, 2 error 
  936. TABS:
  937.     PUSH    BC        ;Save no of tabs
  938.     LD    B,(IX)        ;Get minimum
  939.     CALL    NUMBER        ;Get next number in <E>, flag in <A>
  940.     POP    BC
  941.     LD    (IX),E        ;Save tab
  942.     INC    IX        ;Step to next posn
  943.     OR    A        ;Test flag
  944.     RET    NZ        ; On null response & on error     
  945.     LD    A,(HL)        ;Was current no last?
  946.     OR    A        ;(i.e. terminating null)
  947.     JR    Z,TABT        ;Yes - thru 
  948.     INC    E        ;Set as new minimum
  949.     LD    (IX),E        ; & save tab+1 for minimum check
  950.     DJNZ    TABS        ;Continue if count not out
  951. ;                 max no tabs - ignore rest
  952. TABT:            ;Thru all tabs
  953.     LD    (IX),0        ;Ensure last posn zero
  954.     RET            ;With <A> zero
  955. ;
  956. ;
  957. ;            :Get number from HL>,
  958. ;             limited by , or 00H
  959. ;             test min in <B>, max in <C>
  960. ;             returned in <E>, 
  961. ;             flag in <A> 0 - ok, 1 end input, 2 error
  962. ;             returns HL> past comma if present
  963. NUMBER:
  964.     PUSH    HL        ;Save current posn for null check
  965.     CALL    EVAL10        ;Get next number at HL> in <DE>
  966.     EX    DE,HL        ;Put curr posn in <DE>
  967.     EX    (SP),HL        ;Get prev posn in <HL>
  968.     XOR    A        ;Turn off carry flag
  969.     SBC    HL,DE        ;Did we move at all? (equal/not eq)
  970.     POP    HL        ;Either way restore 
  971.     EX    DE,HL        ;<DE> number, HL> next posn
  972.     JR    Z,NUMEX        ;Didn't move - exit
  973. ;            We picked up some number - may be zero
  974.     LD    A,D
  975.     OR    A
  976.     JR    NZ,NUMER    ;Over 255
  977.     LD    A,C        ;Get max if any
  978.     OR    A        ;Set flag
  979.     LD    A,E        ;Get number - leave flag 
  980.     JR    Z,NUMMAX    ;No maximum
  981.     CP    C        ;Over max?
  982.     JR    NC,NUMER    ;Yes - get out
  983. NUMMAX:
  984.     CP    B        ;Less minimum 
  985.     JR    C,NUMER        ;Invalid
  986.     LD    A,(HL)        ;Get delimiter following tab
  987.     OR    A        ;Null?
  988.     JR    Z,NUMTRU    ;Yes - thru
  989.     CP    ','        ;Valid delimiter?
  990.     JR    NZ,NUMER    ;No - ask new input
  991.     INC    HL        ;Step past comma
  992.     LD    A,E        ;Get no again, now check for zero
  993.     OR    A        ;Zero - treat as end
  994.     RET    Z        ;Yes - get out with
  995. ;            Number ok 
  996. NUMTRU:
  997.     XOR    A        ;Set ok flag
  998.     RET
  999. NUMEX:
  1000.     LD    A,(HL)        ;Get delimiter following tab
  1001.     OR    A        ;Null?
  1002.     JR    NZ,NUMER    ;No - invalid
  1003.     LD    A,1        ;Set exit flag
  1004.     RET
  1005. NUMER:
  1006.     CALL    PRINT        ;Put out error
  1007.     DB    BELL,CR,LF,LF,0
  1008. ;
  1009.     LD    A,2        ;Set error flag
  1010.     RET
  1011. ;
  1012. ;
  1013. ;            Ask for input - return 1 byte in <A>
  1014. CHOICE:
  1015.     CALL    PRINT        ;Show last line in menu
  1016.     DB    'Enter your choice: ',0
  1017. ;
  1018.     LD    A,1        ;Specify capitalization
  1019.     CALL    BBLINE        ;Wait for input line
  1020.     LD    A,(HL)        ;Get first char, all others ignored
  1021.     RET
  1022. ;
  1023. ;
  1024. ;            Clear screen & display text
  1025. CPRINT:
  1026.     PUSH    HL
  1027.     PUSH    AF
  1028.     LD    HL,CLR        ;Set to clear screen string
  1029. CPRTLP:
  1030.     LD    A,(HL)        ;Get next char
  1031.     INC    HL
  1032.     OR    A        ;End of string?
  1033.     JR    Z,CPRT        ;Yes -
  1034.     CALL    COUT        ;No - display
  1035.     JR    CPRTLP
  1036. ;
  1037. CPRT:
  1038.     POP    AF
  1039.     POP    HL    
  1040.     JP    PRINT        ;Go print string whose addr now on stack
  1041. ;
  1042. ;
  1043. COUT:            ;Put char in <A> to CON:
  1044.     PUSH    AF
  1045.     PUSH    BC
  1046.     PUSH    DE
  1047.     PUSH    HL
  1048.     LD    E,A        ;Set char
  1049.     LD    C,2        ;Set CONOUT funtion
  1050.     CALL    BDOS
  1051.     POP    HL
  1052.     POP    DE
  1053.     POP    BC
  1054.     POP    AF
  1055.     RET
  1056. ;
  1057. LOUT:            ;Put char in <A> to LST:
  1058.     PUSH    AF
  1059.     PUSH    BC
  1060.     PUSH    DE
  1061.     PUSH    HL
  1062.     LD    E,A        ;Set char
  1063.     LD    C,5        ;Set LISTOUT funtion
  1064.     CALL    BDOS
  1065.     POP    HL
  1066.     POP    DE
  1067.     POP    BC
  1068.     POP    AF
  1069.     RET
  1070. ;
  1071. CCOUT:            ;Put char in <A> to CON:
  1072. ;            Show control chars
  1073.     PUSH    AF
  1074.     PUSH    BC
  1075.     CP    ' '        ;Control char?
  1076.     JR    NC,CCO2        ;No
  1077.     CP    CR        ;Special?
  1078.     JR    Z,CCO2        ;Yes - as is
  1079.     CP    LF        ;Special?
  1080.     JR    Z,CCO2        ;Yes - as is
  1081.     CP    BELL        ;Special?
  1082.     JR    Z,CCO2        ;Yes - as is
  1083.     CP    BS        ;Special?
  1084.     JR    Z,CCO2        ;Yes - as is
  1085. ;            Convert & display
  1086.     CP    ESC        ;Escape?
  1087.     JR    NZ,CCO3        ;Yes - spell
  1088.     LD    A,'E'
  1089.     CALL    COUT    
  1090.     LD    A,'S'
  1091.     CALL    COUT
  1092.     LD    A,'C'
  1093.     JR    CCO2
  1094. ;
  1095. CCO3:            ;Show ^
  1096.     OR    40H        ;Convert to alpha
  1097.     PUSH    AF
  1098.     LD    A,'^'
  1099.     CALL    COUT
  1100.     POP    AF        ;Get converted
  1101. CCO2:
  1102.     CALL    COUT        ;Put char in <A>
  1103.     POP    BC
  1104.     POP    AF
  1105.     RET
  1106. ;
  1107. DIN:            ;Get char - if available
  1108.     PUSH    BC
  1109.     PUSH    DE
  1110.     PUSH    HL
  1111.     LD    C,6        ;Set Direct CON I/O funtion
  1112.     LD    E,0FFH        ;Flag as input request
  1113.     CALL    BDOS
  1114.     POP    HL
  1115.     POP    DE
  1116.     POP    BC
  1117.     RET
  1118. ;
  1119.     END
  1120.