home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / zcpr2 / print3.mqc / PRINT3.MAC
Encoding:
Text File  |  1985-02-10  |  29.5 KB  |  1,490 lines

  1. ;
  2. ;  PROGRAM:  PRINT III (PRINT3)
  3. ;  VERSION:  1.3
  4. ;  DATE:  17 May 83
  5. ;  AUTHOR:  RICHARD CONN
  6. ;  PREVIOUS VERSIONS:  1.2 (26 Apr 83), 1.1 (26 Apr 83), 1.0 (22 Apr 83)
  7. ;
  8. VERS    equ    13
  9.  
  10. FALSE    equ    0
  11. TRUE    equ    NOT FALSE
  12.  
  13. timeok    equ    FALSE    ;TRUE to enable TIME feature, FALSE to disable
  14.  
  15. ;
  16. ;    PRINT3 is THE file print utility for ZCPR2.  Installable by GENINS,
  17. ; PRINT3 provides a wide range of options for the user.  First, PRINT3 allows
  18. ; the user to employ wild cards and file name lists (lists of files separated
  19. ; by commas, like: file1,file2,file3,...).  Second, PRINT3 provides the
  20. ; following options:
  21. ;        E    Exact Mode
  22. ;                No heading appears, no line numbering,
  23. ;                no page numbering, tab expansion, form
  24. ;                feeds
  25. ;        F    File Name Toggle
  26. ;                The Heading Line can optionally contain
  27. ;                the name of the file
  28. ;        H@head@    Heading Text
  29. ;                The user may specify the text of the heading
  30. ;                to appear at the top of every page
  31. ;        I    Inspect Files
  32. ;                The user approves each file to be printed
  33. ;                before the printing process begins
  34. ;        L    Toggle Line Numbering
  35. ;                Each line may or may not begin with a line
  36. ;                number
  37. ;        M    Multiple Runs Toggle
  38. ;                The user may or may not be prompted to set
  39. ;                the Top of Form on his printer; Multiple Runs
  40. ;                ON means that he will not be prompted
  41. ;        N    Toggle Page Numbering
  42. ;                The numbering of each page is turned on or
  43. ;                off
  44. ;        Onn    Offset Each Line
  45. ;                Move each line in the indicated number of
  46. ;                characters from the left
  47. ;        Snnnn    Skip to Specified Page
  48. ;                Printing begins on the indicated page
  49. ;        T    Toggle Time Display
  50. ;                Time/Date information is optionally included
  51. ;                in the page header
  52. ;
  53.  
  54.  
  55. ;
  56. ;    This program is Copyright (c) 1982, 1983 by Richard Conn
  57. ;    All Rights Reserved
  58. ;
  59. ;    ZCPR2 and its utilities, including this one, are released
  60. ; to the public domain.  Anyone who wishes to USE them may do so with
  61. ; no strings attached.  The author assumes no responsibility or
  62. ; liability for the use of ZCPR2 and its utilities.
  63. ;
  64. ;    The author, Richard Conn, has sole rights to this program.
  65. ; ZCPR2 and its utilities may not be sold without the express,
  66. ; written permission of the author.
  67. ;
  68.  
  69. ;
  70. ;  BASIC SYSLIB ROUTINES NEEDED BY TEMPLATE
  71. ;
  72. ESIZE    EQU    16    ; SIZE OF DIR ENTRY (FROM SYSLIB DIRF ROUTINE)
  73.  
  74.     EXT    DIRFS    ; DIRECTORY PROCESSOR
  75.     EXT    DIRPACK    ; PACK DIRECTORY
  76.  
  77.     EXT    ZGPINS    ; INIT BUFFERS
  78.     EXT    ZFNAME    ; FILE NAME PROCESSOR
  79.  
  80.     EXT    INITFCB    ; INIT FCB
  81.     EXT    RETUD    ; RETURN CURRENT USER/DISK
  82.     EXT    PUTUD    ; SAVE CURRENT USER/DISK
  83.     EXT    GETUD    ; RESTORE CURRENT USER/DISK
  84.     EXT    LOGUD    ; LOG INTO USER/DISK
  85.     EXT    PRINT    ; PRINT STRING PTED TO BY RET ADR
  86.     EXT    PADC    ; PRINT A IN DEC
  87.     EXT    COUT    ; CONSOLE OUTPUT ROUTINE
  88.     EXT    CONDIN    ; CONDITIONAL INPUT ROUTINE
  89.     EXT    CIN    ; CONSOLE INPUT ROUTINE
  90.     EXT    CAPS    ; CAPITALIZE ROUTINE
  91.     EXT    CRLF    ; NEW LINE ROUTINE
  92.     EXT    CLINE    ; COMMAND LINE STRING SAVE ROUTINE
  93.     EXT    CODEND    ; CODE END COMPUTATION ROUTINE
  94.  
  95.     EXT    F$OPEN    ; FILE OPEN
  96.     EXT    F$READ    ; BLOCK READ
  97.     EXT    F$CLOSE    ; FILE CLOSE
  98.  
  99.     EXT    EVAL10    ; STRING TO BINARY CONVERSION
  100.     EXT    LHLDC    ; LST: HL AS DEC OUTPUT
  101.     EXT    LPSTR    ; LST: (HL) STRING OUTPUT
  102.     EXT    LPRINT    ; LST: STRING OUTPUT
  103.     EXT    LCRLF    ; LST: NEW LINE
  104.     EXT    LOUT    ; LST: OUTPUT
  105.     EXT    MOVEB    ; MOVEB ROUTINE
  106.  
  107.     if    timeok
  108.     EXT    TIME    ; TIME Library Module Routine
  109.     endif
  110.  
  111. ;
  112. ;  CP/M EQUATES
  113. ;
  114. CPM    EQU    0    ; WARM BOOT
  115. BDOSE    EQU    CPM+5    ; BDOS ENTRY
  116. FCB    EQU    CPM+5CH    ; FCB
  117. TBUFF    EQU    CPM+80H    ; INPUT LINE BUFFER
  118. DEL    EQU    7FH    ; <DEL>
  119. CR    EQU    13    ; <CR>
  120. FF    EQU    12    ; <FF>
  121. LF    EQU    10    ; <LF>
  122. CTRLC    EQU    'C'-'@'    ; ^C
  123. CTRLG    EQU    'G'-'@'
  124. CTRLH    EQU    'H'-'@'
  125. CTRLI    EQU    'I'-'@'
  126. CTRLX    EQU    'X'-'@'
  127. CTRLZ    EQU    'Z'-'@'
  128.  
  129. ;
  130. ;  OTHER EQUATES
  131. ;
  132. EOLD    EQU    0FFH    ; END OF LOAD DELIMITER
  133.  
  134. ;
  135. ;  Branch to Start of Program
  136. ;
  137.     JMP    START
  138.  
  139. ;
  140. ;******************************************************************
  141. ;
  142. ;  SINSFORM -- ZCPR2 Utility Standard General Purpose Initialization Format
  143. ;
  144. ;    This data block precisely defines the data format for
  145. ; initial features of a ZCPR2 system which are required for proper
  146. ; initialization of the ZCPR2-Specific Routines in SYSLIB.
  147. ;
  148.  
  149. ;
  150. ;  EXTERNAL PATH DATA
  151. ;
  152. EPAVAIL:
  153.     DB    0FFH    ; IS EXTERNAL PATH AVAILABLE? (0=NO, 0FFH=YES)
  154. EPADR:
  155.     DW    40H    ; ADDRESS OF EXTERNAL PATH IF AVAILABLE
  156.  
  157. ;
  158. ;  INTERNAL PATH DATA
  159. ;
  160. INTPATH:
  161.     DB    0,0    ; DISK, USER FOR FIRST PATH ELEMENT
  162.             ; DISK = 1 FOR A, '$' FOR CURRENT
  163.             ; USER = NUMBER, '$' FOR CURRENT
  164.     DB    0,0
  165.     DB    0,0
  166.     DB    0,0
  167.     DB    0,0
  168.     DB    0,0
  169.     DB    0,0
  170.     DB    0,0    ; DISK, USER FOR 8TH PATH ELEMENT
  171.     DB    0    ; END OF PATH
  172.  
  173. ;
  174. ;  MULTIPLE COMMAND LINE BUFFER DATA
  175. ;
  176. MCAVAIL:
  177.     DB    0FFH    ; IS MULTIPLE COMMAND LINE BUFFER AVAILABLE?
  178. MCADR:
  179.     DW    0FF00H    ; ADDRESS OF MULTIPLE COMMAND LINE BUFFER IF AVAILABLE
  180.  
  181. ;
  182. ;  DISK/USER LIMITS
  183. ;
  184. MDISK:
  185.     DB    4    ; MAXIMUM NUMBER OF DISKS
  186. MUSER:
  187.     DB    31    ; MAXIMUM USER NUMBER
  188.  
  189. ;
  190. ;  FLAGS TO PERMIT LOG IN FOR DIFFERENT USER AREA OR DISK
  191. ;
  192. DOK:
  193.     DB    0FFH    ; ALLOW DISK CHANGE? (0=NO, 0FFH=YES)
  194. UOK:
  195.     DB    0FFH    ; ALLOW USER CHANGE? (0=NO, 0FFH=YES)
  196.  
  197. ;
  198. ;  PRIVILEGED USER DATA
  199. ;
  200. PUSER:
  201.     DB    10    ; BEGINNING OF PRIVILEGED USER AREAS
  202. PPASS:
  203.     DB    'chdir',0    ; PASSWORD FOR MOVING INTO PRIV USER AREAS
  204.     DS    41-($-PPASS)    ; 40 CHARS MAX IN BUFFER + 1 for ending NULL
  205.  
  206. ;
  207. ;  CURRENT USER/DISK INDICATOR
  208. ;
  209. CINDIC:
  210.     DB    '$'    ; USUAL VALUE (FOR PATH EXPRESSIONS)
  211.  
  212. ;
  213. ;  DMA ADDRESS FOR DISK TRANSFERS
  214. ;
  215. DMADR:
  216.     DW    80H    ; TBUFF AREA
  217.  
  218. ;
  219. ;  NAMED DIRECTORY INFORMATION
  220. ;
  221. NDRADR:
  222.     DW    00000H    ; ADDRESS OF MEMORY-RESIDENT NAMED DIRECTORY
  223. NDNAMES:
  224.     DB    64    ; MAX NUMBER OF DIRECTORY NAMES
  225. DNFILE:
  226.     DB    'NAMES   '    ; NAME OF DISK NAME FILE
  227.     DB    'DIR'        ; TYPE OF DISK NAME FILE
  228.  
  229. ;
  230. ;  REQUIREMENTS FLAGS
  231. ;
  232. EPREQD:
  233.     DB    0FFH    ; EXTERNAL PATH?
  234. MCREQD:
  235.     DB    000H    ; MULTIPLE COMMAND LINE?
  236. MXREQD:
  237.     DB    0FFH    ; MAX USER/DISK?
  238. UDREQD:
  239.     DB    000H    ; ALLOW USER/DISK CHANGE?
  240. PUREQD:
  241.     DB    000H    ; PRIVILEGED USER?
  242. CDREQD:
  243.     DB    0FFH    ; CURRENT INDIC AND DMA?
  244. NDREQD:
  245.     DB    0FFH    ; NAMED DIRECTORIES?
  246. Z2CLASS:
  247.     DB    11    ; CLASS 11
  248.     DB    'ZCPR2'
  249.     DS    10    ; RESERVED
  250.  
  251. ;
  252. ;  END OF SINSFORM -- STANDARD DEFAULT PARAMETER DATA
  253. ;
  254. ;******************************************************************
  255. ;
  256.  
  257. ;
  258. ;  **** Special Initial Value Area for GENINS
  259. ;
  260. LWIDTH:
  261.     DB    132    ; WIDTH OF LINE
  262. LTPP:
  263.     DB    44    ; LINES OF TEXT PER PAGE
  264. LSPP:
  265.     DB    5    ; LINES TO SKIP PER PAGE
  266. CWIDTH:
  267.     DB    80    ; WIDTH OF SCREEN
  268. CTPP:
  269.     DB    22    ; LINES OF TEXT PER SCREEN
  270. CSPP:
  271.     DB    1    ; LINES TO SKIP PER SCREEN
  272. ;
  273. ;  NOTE:  LTPP + LSPP + 2 (HEADER SIZE) = TOTAL LINES PER PAGE ON PRINTER
  274. ;  NOTE:  CTPP + CSPP + 1 (FOOTER SIZE) = TOTAL LINES PER SCREEN ON CONSOLE
  275. ;
  276. DLNUMFL:
  277.     DB    0    ; LINE NUMBER FLAG (DEFAULT TO NO)
  278. DPNUMFL:
  279.     DB    0FFH    ; PAGE NUMBER FLAG (DEFAULT TO YES)
  280. DEXACT:
  281.     DB    0    ; EXACT PRINT FLAG (DEFAULT TO NO)
  282. DFNPFL:
  283.     DB    0FFH    ; FILE NAME PRINT FLAG (DEFAULT TO YES)
  284. DTIMEPFL:
  285.     DB    0FFH    ; TIME PRINT FLAG (DEFAULT TO YES)
  286. DMULTFL:
  287.     DB    0FFH    ; MULTIPLE RUN FLAG (DEFAULT TO YES)
  288. DINSPECT:
  289.     DB    0    ; INSPECT FILES (DEFAULT TO NO)
  290. DOFFSET:
  291.     DB    0    ; INITIAL COLUMN OFFSET (DEFAULT TO NO COLUMNS)
  292. ;
  293. ;  OTHER BUFFERS
  294. ;
  295. SKIPFL:
  296.     DB    0    ; SKIP FLAG (DEFAULT TO NO)
  297. SKIPNUM:
  298.     DS    2    ; PAGE NUMBER TO SKIP TO
  299. LNUM:
  300.     DS    2    ; CURRENT LINE NUMBER
  301. PNUM:
  302.     DS    2    ; CURRENT PAGE NUMBER
  303. HBUF:
  304.     DS    100    ; BUFFER FOR HEADING
  305. ;
  306.     if    timeok
  307. TIMEBF:
  308.     DS    100    ; BUFFER FOR TIME STAMP
  309.     endif
  310. ;
  311. LNUMFL:
  312.     DB    0    ; LINE NUMBER FLAG (DEFAULT TO NO)
  313. PNUMFL:
  314.     DB    0FFH    ; PAGE NUMBER FLAG (DEFAULT TO YES)
  315. EXACT:
  316.     DB    0    ; EXACT PRINT FLAG (DEFAULT TO NO)
  317. FNPFL:
  318.     DB    0FFH    ; FILE NAME PRINT FLAG (DEFAULT TO YES)
  319. TIMEPFL:
  320.     DB    0FFH    ; TIME PRINT FLAG (DEFAULT TO YES)
  321. MULTFL:
  322.     DB    0FFH    ; MULTIPLE RUN FLAG (DEFAULT TO YES)
  323. INSPECT:
  324.     DB    0    ; INSPECT FILES (DEFAULT TO NO)
  325. OFFSET:
  326.     DB    0    ; OFFSET ON PAGE
  327.  
  328. ;
  329. ;  Start of Program
  330. ;
  331. START:
  332.     LXI    H,0    ; GET STACK PTR
  333.     DAD    SP
  334.     SHLD    STACK    ; SAVE IT
  335.     LXI    SP,STACK    ; SET SP
  336.     CALL    PUTUD    ; SAVE CURRENT USER/DISK AWAY
  337.     CALL    RETUD    ; GET CURRENT USER/DISK
  338.     MOV    A,B    ; SAVE DISK
  339.     STA    DISK
  340.     MOV    A,C    ; SAVE USER
  341.     STA    USER
  342.  
  343.     CALL    ZGPINS    ; INIT BUFFERS
  344.  
  345.     LXI    H,TBUFF    ; SAVE COMMAND LINE
  346.     CALL    CLINE
  347.     SHLD    CMDLNE    ; SAVE PTR
  348.  
  349. ;
  350. ;  **** Banner of Program
  351. ;
  352.     CALL    PRINT
  353.     DB    'PRINT III,  Version '
  354.     DB    VERS/10+'0','.',(VERS MOD 10)+'0',0
  355.  
  356. ;
  357. ;  Check for Help Request
  358. ;
  359.     LDA    FCB+1    ; GET FIRST CHAR OF FILE NAME
  360.     CPI    ' '    ; NO FILE SPEC?
  361.     JZ    HELP
  362.     CPI    '/'    ; OPTION CAUGHT?
  363.     JNZ    ECONT
  364.  
  365. ;
  366. ;  **** Print Help Information
  367. ;
  368. HELP:
  369.     CALL    PRINT
  370.     DB    CR,LF,'PRINT III Command --'
  371.     db    cr,lf,'    PRINT III is invoked by the following command line:'
  372.     db    cr,lf,'        PRINT file1,file2,...,filen o...'
  373.     db    cr,lf,'where each "filen" is an ambiguous file name and type'
  374.     db    cr,lf,'and "o" is zero or more of the following options:'
  375.     db    cr,lf,'    E    Exact Print (expand tabs, form feed, no line'
  376.     db    cr,lf,'            or page numbers, no heading)'
  377.     db    cr,lf,'    F    Toggle File Name Display'
  378.     db    cr,lf,'    H@head@    Specify Page Heading (@ is any printing char)'
  379.     db    cr,lf,'    I    Inspect and Select Files First'
  380.     db    cr,lf,'    L    Toggle Numbering of Each Line'
  381.     db    cr,lf,'    M    Toggle Multiple Runs (MR=No TOF Msg)'
  382.     db    cr,lf,'    N    Toggle Numbering of Each Page'
  383.     db    cr,lf,'    Onn    Offset Printout by nn Characters from Left'
  384.     db    cr,lf,'    Snnnn    Skip to Specified Page before Printing'
  385. ;
  386.     if    timeok
  387.     db    cr,lf,'    T    Toggle Time Display (if available) in header'
  388.     endif
  389. ;
  390.     db    cr,lf,'Examples:'
  391.     db    cr,lf,'        PRINT MYFILE.TXT,*.MAC LH''SAMPLE'''
  392.     db    cr,lf,'            -- Number Lines, SAMPLE is Heading'
  393.     db    cr,lf,'        PRINT MYFILE.* S25E'
  394.     db    cr,lf,'            -- Skip to Page 25, Exact Print'
  395.     db    cr,lf,'    At any time, ^C aborts PRINT III and ^X skips to next '
  396.     db    'file'
  397.     DB    CR,LF,0
  398.  
  399. ;
  400. ;  RETURN TO OS
  401. ;
  402. RETURN:
  403.     LHLD    STACK    ; GET OLD STACK
  404.     SPHL        ; SET IT
  405.     RET
  406.  
  407. ;
  408. ;  PROGRAM'S INIT ROUTINE
  409. ;
  410. ECONT:
  411.     CALL    INIT    ; PROG INIT ROUTINE
  412. ;
  413. ;  EXTRACT FLAGS IF PRESENT
  414. ;
  415.     LXI    H,0    ; SET FILE COUNT
  416.     SHLD    FILECNT
  417.     LHLD    CMDLNE    ; PT TO BUFFER
  418. ;
  419. ;  SKIP TO FILE NAME STRING
  420. ;
  421.     CALL    SBLANK    ; SKIP OVER BLANKS
  422. ;
  423. ;  SKIP TO END OF FILE NAME STRING
  424. ;
  425.     CALL    SNBLANK    ; SKIP OVER NON-BLANKS
  426. ;
  427. ;  CHECK FOR LEADING SLASH ON OPTION AND SKIP IT IF SO
  428. ;
  429. OPT:
  430.     CPI    '/'    ; OPTION CHAR?
  431.     JNZ    OPTION
  432.     INX    H    ; SKIP SLASH
  433. ;
  434. ;  PROCESS LIST OF OPTIONS
  435. ;
  436. OPTION:
  437.     MOV    A,M    ; GET BYTE
  438.     ORA    A    ; DONE?
  439.     JZ    DSPEC
  440.     INX    H    ; PT TO NEXT CHAR
  441.     CPI    ' '    ; SKIP OVER SPACES
  442.     JZ    OPTION
  443.     MOV    C,A    ; COMMAND IN C
  444.     LXI    D,OPTAB    ; PT TO OPTION TABLE
  445. OPTL:
  446.     LDAX    D    ; GET OPTION LETTER
  447.     ORA    A    ; END OF TABLE?
  448.     JZ    HELP    ; HELP IF SO
  449.     CMP    C    ; MATCH?
  450.     JZ    OPTM    ; PROCESS IF SO
  451.     INX    D    ; PT TO NEXT ENTRY
  452.     INX    D
  453.     INX    D
  454.     JMP    OPTL
  455. ;
  456. ;  PROCESS OPTION
  457. ;
  458. OPTM:
  459.     PUSH    H    ; SAVE HL ON STACK
  460.     LXI    H,OPTION    ; GET RETURN ADDRESS
  461.     XTHL        ; ... ON STACK AND RESTORE HL
  462.     INX    D    ; PT TO ADDRESS
  463.     LDAX    D    ; GET ADDRESS LOW
  464.     MOV    B,A    ; ... IN B
  465.     INX    D
  466.     LDAX    D    ; GET ADDRESS HIGH
  467.     MOV    D,A    ; ... IN D
  468.     MOV    E,B    ; LOW IN E
  469.     PUSH    D    ; PUT ADDRESS ON STACK
  470.     MOV    A,C    ; COMMAND IN A
  471.     RET        ; "CALL" OPTION ROUTINE
  472.  
  473. ;
  474. ;  **** PROGRAM INIT ROUTINE
  475. ;    THIS ROUTINE IS USED BY THE PROGRAM TO PERFORM ANY INITS
  476. ;
  477. INIT:
  478.     lxi    h,dlnumfl    ;copy defaults into buffers
  479.     lxi    d,lnumfl
  480.     mvi    b,8        ;8 bytes
  481.     call    moveb        ;do copy
  482.     xra    a    ;A=0
  483.     sta    skipfl    ;set no skip
  484.     sta    hbuf    ;set no heading
  485. ;
  486.     if    timeok
  487.     call    time    ;get time string
  488.     lxi    d,timebf    ;store in buffer
  489. initt:
  490.     mov    a,m    ;get byte
  491.     stax    d    ;put byte
  492.     inx    h    ;pt to next
  493.     inx    d
  494.     ora    a    ;done?
  495.     jnz    initt
  496.     endif
  497. ;
  498.     RET
  499.  
  500. ;
  501. ;  **** OPTION TABLE
  502. ;    EACH OPTION IS A CAPITAL LETTER OR SPECIAL CHAR FOLLOWED BY
  503. ;        AN ADDRESS; THE TABLE IS TERMINATED BY A BINARY ZERO
  504. ;
  505. OPTAB:
  506.     db    'E'
  507.     dw    optexact
  508.     db    'F'
  509.     dw    optfn
  510.     db    'H'
  511.     dw    opthd
  512.     db    'I'
  513.     dw    optinsp
  514.     db    'L'
  515.     dw    optln
  516.     db    'M'
  517.     dw    optmult
  518.     db    'N'
  519.     dw    optpn
  520.     db    'O'
  521.     dw    optoffs
  522.     db    'S'
  523.     dw    optskip
  524. ;
  525.     if    timeok
  526.     db    'T'
  527.     dw    opttime
  528.     endif
  529. ;
  530.     DB    0    ; END OF TABLE
  531. ;
  532. ;  Option:  E (Toggle exact mode)
  533. ;
  534. optexact:
  535.     lda    exact    ;get flag
  536.     cma        ;flip it
  537.     sta    exact    ;put flag
  538.     ret
  539. ;
  540. ;  Option:  F (Toggle file name display)
  541. ;
  542. optfn:
  543.     lda    fnpfl    ;get flag
  544.     cma        ;flip it
  545.     sta    fnpfl    ;put flag
  546.     ret
  547. ;
  548. ;  Option:  H (Set Heading)
  549. ;
  550. opthd:
  551.     lxi    d,hbuf    ;pt to heading buffer
  552.     mov    a,m    ;get delim
  553.     ora    a    ;none?
  554.     rz
  555.     mov    b,a    ;delim in B
  556.     inx    h    ;pt to next char
  557. opthd1:
  558.     mov    a,m    ;get next char
  559.     ora    a    ;done?
  560.     jz    opthd3
  561.     cmp    b    ;done by trailing delim?
  562.     jz    opthd2
  563.     stax    d    ;save char
  564.     inx    h    ;pt to next
  565.     inx    d
  566.     jmp    opthd1
  567. opthd2:
  568.     inx    h    ;skip over delim
  569. opthd3:
  570.     xra    a    ;store ending 0
  571.     stax    d
  572.     ret
  573. ;
  574. ;  Toggle Inspect Option
  575. ;
  576. optinsp:
  577.     lda    inspect    ;flip flag
  578.     cma
  579.     sta    inspect
  580.     ret
  581. ;
  582. ;  Set Line Number Flag
  583. ;
  584. optln:
  585.     lda    lnumfl    ;flip flag
  586.     cma
  587.     sta    lnumfl
  588.     ret
  589. ;
  590. ;  Set Multiple Run Flag
  591. ;
  592. optmult:
  593.     lda    multfl    ;flip flag
  594.     cma
  595.     sta    multfl
  596.     ret
  597. ;
  598. ;  Set Page Numbering Flag
  599. ;
  600. optpn:
  601.     lda    pnumfl    ;flip flag
  602.     cma
  603.     sta    pnumfl
  604.     ret
  605. ;
  606. ;  Set Page Offset
  607. ;
  608. optoffs:
  609.     call    eval10    ;get number
  610.     mov    a,e    ;get low-order byte
  611.     sta    offset    ;set offset
  612.     ret
  613. ;
  614. ;  Set Skip Flag and get number
  615. ;
  616. optskip:
  617.     mvi    a,0ffh    ;set flag
  618.     sta    skipfl
  619.     call    eval10    ;get number
  620.     xchg
  621.     shld    skipnum    ;set page number to skip to
  622.     xchg        ;HL pts to next char
  623.     mov    a,d    ;see if page number was zero
  624.     ora    e
  625.     rnz
  626.     xra    a    ;if zero, just turn off skip flag
  627.     sta    skipfl
  628.     ret
  629. ;
  630.     if    timeok
  631. ;
  632. ;  Set Time Flag
  633. ;
  634. opttime:
  635.     lda    timepfl    ;flip flag
  636.     cma
  637.     sta    timepfl
  638.     ret
  639. ;
  640.     endif
  641. ;
  642. ;  BEGIN MOVING THROUGH FILE NAMES, SEPARATED BY COMMAS
  643. ;
  644. DSPEC:
  645.     LHLD    CMDLNE    ; PT TO FIRST BYTE
  646.     CALL    SBLANK    ; SKIP TO NON-BLANK
  647. ;
  648. ;  MAJOR REENTRY POINT WHEN FILE SPECS ARE SEPARATED BY COMMAS
  649. ;    HL PTS TO FIRST BYTE OF NEXT FILE SPEC
  650. ;
  651. DSPEC1:
  652.     LXI    SP,STACK    ; RESET STACK
  653.     CALL    GETUD    ; RESET USER IF NECESSARY
  654.     LXI    D,NTFCB    ; PT TO FCB IN DE, PT TO FIRST CHAR OF FILE NAME IN HL
  655.  
  656.     CALL    ZFNAME    ; EXTRACT FILE NAME INTO FCB, AND GET DISK AND USER
  657.     JZ    DERR    ; ERROR HANDLER
  658.  
  659.     SHLD    NEXTCH    ; SAVE PTR TO DELIMITER WHICH ENDED SCAN
  660.     MOV    A,B    ; SAVE POSSIBLE DRIVE SPEC
  661.     CPI    0FFH    ; CURRENT DISK?
  662.     JZ    DSPEC2
  663.     LDA    MDISK    ; GET MAX DISK NUMBER
  664.     DCR    B    ; ADJUST TO WITHIN BOUNDS 0-15
  665.     CMP    B    ; WITHIN BOUNDS?
  666.     MOV    A,B    ; GET DISK NUMBER IN A
  667.     JNC    USPEC
  668. DERR:
  669.     CALL    PRINT
  670.     DB    CR,LF,'Invalid Disk Specification',0
  671.     JMP    DRETURN
  672.  
  673. ;
  674. ;  SET CURRENT DISK
  675. ;
  676. DSPEC2:
  677.     LDA    DISK    ;GET CURRENT DISK
  678.     MOV    B,A    ;... IN B
  679.  
  680. ;  CHECK FOR USER NUMBER
  681. USPEC:
  682.     MOV    A,C    ; GET NEW USER NUMBER
  683.     CPI    0FFH    ; DEFAULT USER?
  684.     JZ    USPEC1
  685.     CPI    '?'    ; ALL USERS NOT ALLOWED?
  686.     JZ    UERR
  687.     LDA    MUSER    ; GET MAX USER NUMBER
  688.     CMP    C
  689.     MOV    A,C    ; USER NUMBER IN A
  690.     JNC    FCT
  691. UERR:
  692.     CALL    PRINT
  693.     DB    CR,LF,'Invalid User Number',0
  694.     JMP    DRETURN
  695. USPEC1:
  696.     LDA    USER    ;GET CURRENT USER
  697.     MOV    C,A    ;... IN C
  698.  
  699. ;
  700. ;  LOAD DIRECTORY AND PERFORM FUNCTION
  701. ;
  702. FCT:
  703.     MOV    A,B    ; SAVE NEW DISK/USER AWAY
  704.     STA    CDISK    ; CURRENT DISK
  705.     MOV    A,C
  706.     STA    CUSER    ; CURRENT USER
  707.     CALL    LOGUD    ; LOG INTO ACCOUNT
  708.     CALL    CODEND    ; PT TO END OF CODE
  709.     CALL    RETUD    ; GET USER NUMBER FOR DIRFS
  710.     MVI    A,11000000B    ; SELECT SYS AND NON-SYS FILES
  711.     ORA    C    ; OR IN USER NUMBER
  712.     LXI    D,NTFCB    ; PT TO FCB
  713.     CALL    INITFCB    ; INIT THE FCB
  714.     CALL    DIRFS    ; LOAD DIR, SELECT FILES, PACK, AND ALPHABETIZE
  715. ;
  716. ;  DETERMINE BEGINNING OF SCRATCH AREA (SCRATCH) AND SZIE IN PAGES (BCNT)
  717. ;
  718.     PUSH    H    ; SAVE PTR AND COUNT
  719.     PUSH    B
  720.     LXI    D,ESIZE    ; SET PTR TO NEXT FREE BLOCK
  721. FCTFRE:
  722.     MOV    A,B    ; DONE?
  723.     ORA    C
  724.     JZ    FCTFR1
  725.     DAD    D    ; PT TO NEXT
  726.     DCX    B    ; COUNT DOWN
  727.     JMP    FCTFRE
  728. FCTFR1:
  729.     INR    H    ; NEXT PAGE
  730.     MVI    L,0
  731.     SHLD    SCRATCH    ; SET PTR TO SCRATCH AREA
  732.     XCHG        ; PTR IN DE
  733.     LHLD    BDOSE+1    ; COMPUTE BLOCK BUFFER SIZE
  734.     MOV    A,H    ; ADJUST FOR ZCPR2
  735.     SUI    10
  736.     SUB    D    ; A=SIZE IN BLOCKS
  737.     STA    BCNT    ; SET BLOCK COUNT
  738.     POP    B    ; RESTORE AND SAVE REGS
  739.     POP    H
  740. ;
  741. ;  ALLOW USER TO INSPECT FILES
  742. ;
  743.     PUSH    H
  744.     PUSH    B
  745.     CALL    ICHECK    ; CHECK FOR INSPECT OPTION AND INSPECT IF SET
  746.     POP    B    ; RESTORE COUNT AND PTR
  747.     POP    H
  748.  
  749. ;
  750. ;  PERFORM FUNCTION; HL PTS TO FILE AND BC CONTAINS NUMBER OF FILES
  751. ;
  752. FCTL:
  753.     MOV    A,B        ; CHECK FOR COMPLETION (COUNT = 0)
  754.     ORA    C
  755.     JZ    FCTL1
  756.     DCX    B        ; COUNT DOWN
  757.     LXI    SP,STACK    ; RESET STACK
  758.     PUSH    B        ; SAVE COUNT AND POINTER
  759.     PUSH    H
  760.     CALL    FUNCTION    ; PERFORM FUNCTION
  761. FCTLNXT:
  762.     LXI    SP,STACK-4    ; RESTORE STACK
  763.     POP    H        ; GET PTR AND COUNT
  764.     POP    B
  765.     LXI    D,ESIZE        ; PT TO NEXT ENTRY
  766.     DAD    D
  767.     JMP    FCTL
  768.  
  769. ;
  770. ;  CHECK FOR NEXT FILE SPEC
  771. ;
  772. FCTL1:
  773.     CALL    GETUD    ; RETURN TO HOME USER/DISK
  774.     LHLD    NEXTCH    ; GET PTR
  775.     MOV    A,M    ; GET DELIM
  776.     CPI    ','    ; ANOTHER FILE?
  777.     JNZ    DRETURN
  778.     INX    H    ; PT TO CHAR AFTER COMMA
  779.     JMP    DSPEC1    ; CONTINUE PROCESSING
  780.  
  781. ;
  782. ;  **** EMERGENCY ABORT
  783. ;
  784. ABORT:
  785.     CALL    PRINT
  786.     DB    CR,LF,'** PRINT III Abort **',CR,LF,0
  787.     CALL    GETUD    ; RETURN HOME AND FALL THRU TO DRETURN
  788. ;
  789. ;  **** FUNCTION COMPLETE -- CLEANUP AND EXIT
  790. ;    FILL THIS IN WITH CLEANUP CODE FOR EXIT
  791. ;
  792. DRETURN:
  793.     JMP    RETURN
  794.  
  795. ;
  796. ;  **** INSPECT FILES -- THIS ROUTINE IS TO PERFORM A FILE INSPECTION
  797. ;    ON INPUT, HL PTS TO FIRST 16-BYTE ENTRY AND BC=NUMBER OF ENTRIES
  798. ;
  799. ICHECK:
  800.     mov    a,b    ;any files?
  801.     ora    c
  802.     rz
  803.     push    h    ;save ptrs
  804.     push    b
  805.     lxi    d,esize    ;size of entry
  806. ichk1:
  807.     mvi    m,0    ;clear MSBytes
  808.     dad    d    ;pt to next
  809.     dcx    b    ;count down
  810.     mov    a,b    ;done?
  811.     ora    c
  812.     jnz    ichk1
  813.     pop    b    ;restore ptrs
  814.     pop    h
  815.     lda    inspect    ;inspect?
  816.     ora    a    ;0=no
  817.     rz
  818.     call    print
  819.     db    cr,lf,'PRINT III File Inspect Mode',0
  820. ichk2:
  821.     call    print
  822.     db    cr,lf,'Select ',0
  823.     call    prfn    ;print file name
  824.     call    print
  825.     db    ' -- (Y/N/Q=Select Rest/S=Skip Rest/other=Y)? '
  826.     db    0
  827.     call    cin    ;get response
  828.     call    caps    ;capitalize
  829.     call    cout    ;echo
  830.     cpi    'Q'    ;select rest?
  831.     jz    ichkyr
  832.     cpi    'S'    ;skip rest
  833.     jz    ichknr
  834.     cpi    'N'    ;no to this one?
  835.     jnz    ichk3
  836.     mvi    m,0ffh    ;set NO flag in file FCB
  837. ichk3:
  838.     dad    d    ;pt to next one
  839.     dcx    b    ;count down
  840.     mov    a,b    ;done?
  841.     ora    c
  842.     jnz    ichk2
  843.     RET
  844. ;  Check Rest of Files as Selected
  845. ichkyr:
  846.     call    print
  847.     db    cr,lf,'    Rest of Files Selected',0
  848.     ret
  849. ;  Check Rest of Files as NOT Selected
  850. ichknr:
  851.     mvi    m,0ffh    ;set NO flag
  852.     dad    d    ;pt to next
  853.     dcx    b    ;count down
  854.     mov    a,b    ;done?
  855.     ora    c
  856.     jnz    ichknr
  857.     call    print
  858.     db    cr,lf,'    Rest of Files NOT Selected',0
  859.     ret
  860. ;
  861. ;  **** FUNCTION -- MAIN FUNCTION OF TEMPLATE
  862. ;    ON ENTRY, HL PTS TO NAME OF FILE (16 BYTES) AND USER IS LOGGED INTO
  863. ;        DIRECTORY CONTAINING INDICATED FILE
  864. ;
  865. FUNCTION:
  866. ;
  867. ;  FILE PRINT Routine -- Print the File Whose Name is Pointed to by
  868. ;    HL; we are already logged into the correct directory
  869. ;
  870.     mov    a,m    ;file selected?
  871.     ora    a    ;0=yes
  872.     rnz
  873.     lda    multfl    ;multiple runs?
  874.     ora    a    ;0=no
  875.     jnz    fprint    ;go right into function
  876.     call    print
  877.     db    cr,lf,'File: ',0
  878.     call    prfn    ;print file name
  879.     call    print
  880.     db    ' -- Please Set Top of Form'
  881.     db    cr,lf,'    Strike Any Key When Ready ',0
  882.     call    cin    ;get response
  883.     cpi    ctrlc    ;abort?
  884.     jz    abort
  885.     cpi    ctrlx
  886.     rz
  887. fprint:
  888.     call    prinit    ;init print buffers
  889.     call    fload    ;load buffer initially
  890.     call    prhead    ;print heading line
  891.     lhld    scratch    ;pt to first char in file
  892.     shld    nxtln    ;set pointer to next line
  893. fprloop:
  894.     call    prline    ;print line of file
  895.     jnz    fprloop    ;done if EOF
  896.     lda    ltpp    ;check for new page
  897.     mov    b,a
  898.     lda    lcount    ;LTPP and Line Count are Equal if New Page
  899.     cmp    b    ;equal?
  900.     jnz    fprlp1
  901.     call    lcrlf    ;advance 2 lines
  902.     call    lcrlf
  903. fprlp1:
  904.     call    page    ;advance to top of next page
  905.     ret
  906. ;
  907. ;  Init Print Buffers and Print File Name
  908. ;
  909. prinit:
  910.     lxi    d,tfcb    ;set up FCB
  911.     mvi    b,12    ;12 bytes
  912.     call    moveb
  913.     lxi    h,0    ;HL=0
  914.     shld    lnum    ;set line number
  915.     inx    h    ;HL=1
  916.     shld    pnum    ;set page number
  917.     lda    ltpp    ;set line count
  918.     sta    lcount
  919.     call    print
  920.     db    cr,lf,'Printing File ',0
  921.     lxi    h,tfcb    ;pt to FCB
  922.     call    prfn    ;print file name
  923.     ret
  924. ;
  925. ;  FILE LOAD (FLOAD) Routine -- Initial Load of memory buffer
  926. ;
  927. fload:
  928.     lxi    d,tfcb    ;pt to file fcb
  929.     call    initfcb    ;init file's fcb
  930.     call    f$open    ;open file for input
  931.     jz    fload1    ;open was OK
  932.     call    print
  933.     db    cr,lf,'File ',0
  934.     xchg        ;HL pts to FCB
  935.     call    prfn    ;print file name
  936.     call    print
  937.     db    ' NOT Found',0
  938.     pop    d    ;clear return address
  939.     ret        ;abort printout of this file
  940. ;
  941. ;  This is an entry point for further memory loads of the file
  942. ;
  943. fload1:
  944.     lda    bcnt    ;get number of blocks to load
  945.     mov    c,a    ;... in C
  946.     lhld    scratch    ;get address of first block to load into
  947.     shld    nxtblk    ;set pointer to next block to load
  948. fload2:
  949.     call    rdblk    ;read a block (128 bytes)
  950.     jnz    eof    ;eof encountered?
  951.     call    rdblk    ;read another block (128 bytes)
  952.     jnz    eof    ;eof encountered?
  953.     dcr    c    ;count down
  954.     jnz    fload2
  955.     lhld    nxtblk    ;pt to next byte to load
  956.     mvi    m,eold    ;mark end of load
  957.     ret
  958. eof:
  959.     lxi    d,tfcb    ;close file
  960.     call    f$close
  961.     lhld    nxtblk    ;ensure ^Z
  962.     mvi    m,ctrlz
  963.     ret
  964. rdblk:
  965.     lxi    d,tfcb    ;pt to FCB
  966.     call    f$read    ;read next block
  967.     ora    a    ;error?
  968.     rnz
  969.     lhld    nxtblk    ;get ptr to next block
  970.     xchg        ; as dest
  971.     lxi    h,tbuff    ;ptr to DMA address
  972.     mvi    b,128    ;copy 128 bytes
  973. rdblk1:
  974.     mov    a,m    ;get byte
  975.     ani    7fh    ;mask out msb
  976.     stax    d    ;put byte
  977.     inx    h    ;pt to next
  978.     inx    d
  979.     dcr    b    ;count down
  980.     jnz    rdblk1
  981.     xchg        ;new nxtblock
  982.     shld    nxtblk
  983.     ret
  984.  
  985. ;
  986. ;  Line Print Routine
  987. ;    Print Next Line with Optional Disk Load
  988. ;    Input Parameter is NXTLN, which is the address of the first char
  989. ; on the next line
  990. ;    Output Parameter is Zero Flag, with Z meaning done with print, NZ
  991. ; meaning more yet to print
  992. ;
  993. prline:
  994.     call    proffs    ;print offset
  995.     lhld    lnum    ;increment line number
  996.     inx    h
  997.     shld    lnum
  998.     lhld    nxtln    ;pt to first char of next line
  999.     mvi    c,0    ;init char count
  1000.     mov    a,m    ;get first char of line
  1001.     cpi    ctrlz    ;EOF?
  1002.     cnz    prlnum    ;print line number (optional)
  1003. prl1:
  1004.     mov    a,m    ;get char
  1005.     cpi    eold    ;end of load?
  1006.     jz    prload
  1007.     cpi    ctrlz    ;eof?
  1008.     jz    prexit
  1009.     inx    h    ;pt to next char
  1010.     cpi    ctrli    ;tab?
  1011.     jz    prtab
  1012.     cpi    cr    ;<CR>?
  1013.     jz    prcr
  1014.     cpi    ff    ;form feed?
  1015.     jz    prff
  1016.     cpi    lf    ;end of line?
  1017.     jz    prldn
  1018.     cpi    ctrlh    ;back space?
  1019.     jz    prbs
  1020.     cpi    ctrlg    ;ring bell?
  1021.     jz    prbell
  1022.     cpi    del    ;delete char?
  1023.     jz    prl1    ;skip it
  1024.     cpi    ' '    ;other control char?
  1025.     jc    prl1    ;skip if other control char
  1026.     call    prout    ;print char
  1027.     inr    c    ;increment char count
  1028.     call    eoltest    ;check to see if at end of line and newline if so
  1029.     jmp    prl1
  1030. ;
  1031. ;  End of Load Reached -- Load More of File from Disk
  1032. ;
  1033. prload:
  1034.     push    b    ;save char count
  1035.     call    fload1    ;use load routine
  1036.     pop    b    ;get char count
  1037.     lhld    scratch    ;next byte is here
  1038.     jmp    prl1    ;continue processing
  1039. ;
  1040. ;  Tabulate
  1041. ;
  1042. prtab:
  1043.     mvi    a,' '    ;space
  1044.     call    prout
  1045.     inr    c    ;new char
  1046.     call    eoltest    ;process EOL
  1047.     mov    a,c    ;done?
  1048.     ani    7
  1049.     jnz    prtab    ;continue tabulation
  1050.     jmp    prl1    ;continue processing
  1051. ;
  1052. ;  Exit with Zero Flag Set if Done
  1053. ;
  1054. prexit:
  1055.     xra    a    ;set zero flag
  1056.     ret
  1057. ;
  1058. ;  Carriage Return -- Reset Character Count and Continue
  1059. ;
  1060. prcr:
  1061.     call    prout    ;send CR to printer
  1062.     mvi    c,0    ;reset char count
  1063.     jmp    prl1    ;continue processing
  1064. ;
  1065. ;  Form Feed -- Advance to Top of Next Page
  1066. ;
  1067. prff:
  1068.     call    page    ;page eject with heading
  1069.     mvi    c,0    ;reset char count
  1070.     jmp    prl1    ;continue processing
  1071. ;
  1072. ;  Line Feed -- End of Routine
  1073. ;
  1074. prldn:
  1075.     call    prout    ;echo LF to printer
  1076.     shld    nxtln    ;set ptr to first char of next line
  1077.     mvi    a,0ffh    ;set not done
  1078.     ora    a    ;set flags
  1079.     ret
  1080. ;
  1081. ;  Backspace on Printer
  1082. ;
  1083. prbs:
  1084.     mov    a,c    ;check for beginning of line
  1085.     ora    a
  1086.     jz    prl1    ;continue if at BOL
  1087.     mvi    a,ctrlh    ;backspace
  1088.     call    prout
  1089.     dcr    c    ;back up char position
  1090.     jmp    prl1    ;continue
  1091. ;
  1092. ;  Ring Bell on Printer
  1093. ;
  1094. prbell:
  1095.     call    prout    ;ring the bell
  1096.     jmp    prl1    ;continue without advancing char position
  1097. ;
  1098. ;  Test for End of Line and Process if so
  1099. ;
  1100. eoltest:
  1101.     lda    offset    ;get offset
  1102.     mov    b,a    ;... in B
  1103.     lda    lwidth    ;get line width
  1104.     sub    b    ;compute remaining width
  1105.     sui    4    ;4 chars less for continuation mark
  1106.     mov    b,a    ;result in B
  1107.     lda    lnumfl    ;line numbering (lines are 7 chars shorter if so)
  1108.     ora    a    ;0=no
  1109.     jz    eolt1
  1110.     mov    a,b    ;reduce by 7 for line numbers
  1111.     sui    7
  1112.     mov    b,a
  1113. eolt1:
  1114.     mov    a,b    ;get line width
  1115.     cmp    c    ;there?
  1116.     rnz        ;continue if not
  1117.     mov    a,m    ;get next char
  1118.     cpi    cr    ;new line next?
  1119.     rz        ;continue if so
  1120.     cpi    ctrlh    ;backspace next?
  1121.     rz        ;continue if so
  1122.     mvi    a,' '    ;print continuation chars
  1123.     call    prout
  1124.     mvi    a,'<'
  1125.     call    prout
  1126.     mvi    a,'<'
  1127.     call    prout
  1128.     mvi    a,cr    ;new line
  1129.     call    prout
  1130.     mvi    a,lf
  1131.     call    prout
  1132.     mvi    c,0    ;reset char position
  1133.     lda    skipfl    ;skipping?
  1134.     ora    a    ;0=no
  1135.     rnz
  1136.     lda    lnumfl    ;printing line numbers?
  1137.     ora    a    ;0=no
  1138.     rz
  1139.     call    lprint
  1140.     db    '     : ',0
  1141.     ret
  1142. ;
  1143. ;  Output a character to the printer
  1144. ;    A = Character
  1145. ;
  1146. prout:
  1147.     mov    b,a    ;char in B
  1148.     call    condin    ;check for abort
  1149.     jz    prout1
  1150.     cpi    ctrlc    ;abort?
  1151.     jz    abort
  1152.     cpi    ctrlx    ;abort this one file?
  1153.     jz    cxabort
  1154. prout1:
  1155.     lda    skipfl    ;skipping?
  1156.     ora    a    ;set flags (Z=no skip=print char)
  1157.     mov    a,b    ;restore char
  1158.     cz    lout    ;send character to printer
  1159.     cpi    lf    ;special tests if it is a line feed
  1160.     rnz        ;done if non-LF char
  1161.     lda    lcount    ;decrement line counter
  1162.     dcr    a
  1163.     sta    lcount
  1164.     rnz
  1165. ;
  1166. ;  Paging Required
  1167. ;    Skip to top of next page; reset LCOUNT (Lines Left on Page Count);
  1168. ;    print header
  1169. ;
  1170. prout0:
  1171.     lda    ltpp    ;get number of text lines per page
  1172.     sta    lcount    ;set as new line count
  1173.     push    h    ;save ptr
  1174.     lhld    pnum    ;increment page number
  1175.     inx    h
  1176.     shld    pnum
  1177.     lda    lspp    ;get number of lines to skip per page
  1178.     call    lineskp    ;skip lines
  1179.     pop    h    ;restore ptr
  1180.     mov    a,m    ;check next character
  1181.     cpi    ctrlz    ;EOF?
  1182.     jnz    prhead    ;print 2-line heading if NOT EOF
  1183.     ret
  1184. ;
  1185. ;  Abort current file with final page eject
  1186. ;
  1187. cxabort:
  1188.     lda    lcount    ;get count of remaining lines
  1189.     call    lineskp    ;skip lines
  1190.     lda    lspp    ;number of lines to skip per page
  1191.     call    lineskp    ;skip lines
  1192.     jmp    fctlnxt    ;continue with next file
  1193. ;
  1194. ;  Skip out rest of page
  1195. ;    Form Feed Function
  1196. ;
  1197. page:
  1198.     lda    lcount    ;get count of remaining lines
  1199.     call    lineskp    ;skip lines
  1200.     jmp    prout0    ;process top of new page
  1201. ;
  1202. ;  Skip out lines on page
  1203. ;    A = number of lines to skip
  1204. ;
  1205. lineskp:
  1206.     mov    b,a    ;line count in B
  1207.     ora    a    ;any?
  1208.     rz
  1209.     lda    skipfl    ;skipping?
  1210.     ora    a
  1211.     rnz
  1212. lines1:
  1213.     mvi    a,cr    ;output new line to printer
  1214.     call    lout
  1215.     mvi    a,lf
  1216.     call    lout
  1217.     dcr    b    ;count down
  1218.     jnz    lines1
  1219.     ret
  1220. ;
  1221. ;  Print Line Number (optional)
  1222. ;
  1223. prlnum:
  1224.     lda    skipfl    ;skipping?
  1225.     ora    a    ;0=no
  1226.     rnz
  1227.     lda    lnumfl    ;get flag
  1228.     ora    a    ;0=don't number lines
  1229.     rz
  1230.     push    h    ;save ptr
  1231.     lhld    lnum    ;get line number
  1232.     call    lhldc    ;print line number
  1233.     call    lprint    ;print separator
  1234.     db    ': ',0
  1235.     pop    h    ;restore ptr
  1236.     ret
  1237. ;
  1238. ;  Print 2-line heading and control skipping
  1239. ;
  1240. prhead:
  1241.     push    h    ;save ptr
  1242.     lda    skipfl    ;currently skipping?
  1243.     ora    a    ;0=no
  1244.     cnz    skiptst    ;test for shut off
  1245.     lda    exact    ;exact says no heading
  1246.     ora    a    ;0FFH=yes
  1247.     jnz    prhead1
  1248.     call    proffs    ;print offset
  1249.     lda    pnumfl    ;number pages?
  1250.     ora    a    ;0=no
  1251.     cnz    prpnum    ;print page heading and number
  1252.     lda    fnpfl    ;print file name?
  1253.     ora    a    ;0=no
  1254.     cnz    prfname    ;print file name
  1255. ;
  1256.     if    timeok    ;time available?
  1257.     lda    timepfl    ;print time?
  1258.     ora    a    ;0=no
  1259.     cnz    prtime    ;print time
  1260.     endif
  1261. ;
  1262.     lda    hbuf    ;print heading?
  1263.     ora    a    ;0=no
  1264.     cnz    prhdg    ;print heading
  1265. prhead1:
  1266.     pop    h    ;restore ptr
  1267. prhead2:
  1268.     lda    skipfl    ;skipping?
  1269.     ora    a
  1270.     rnz
  1271.     call    lcrlf    ;new line
  1272.     jmp    lcrlf
  1273. ;
  1274. ;  Test for completion of skipping
  1275. ;
  1276. skiptst:
  1277.     lhld    pnum    ;get page number
  1278.     xchg        ;... in DE
  1279.     lhld    skipnum    ;get page to skip to
  1280.     mov    a,h    ;compare them
  1281.     cmp    d
  1282.     rnz
  1283.     mov    a,l
  1284.     cmp    e
  1285.     rnz
  1286.     xra    a    ;A=0 to stop skipping
  1287.     sta    skipfl    ;set flag
  1288.     ret
  1289. ;
  1290. ;  Print Line Offset
  1291. ;
  1292. proffs:
  1293.     lda    skipfl    ;skipping?
  1294.     ora    a
  1295.     rnz
  1296.     push    b    ;save BC
  1297.     lda    offset    ;get offset
  1298.     ora    a    ;any?
  1299.     jz    proff2
  1300.     mov    c,a    ;offset in B
  1301. proff1:
  1302.     mvi    a,' '    ;space over
  1303.     call    prout
  1304.     dcr    c    ;count down
  1305.     jnz    proff1
  1306. proff2:
  1307.     pop    b
  1308.     ret
  1309. ;
  1310. ;  Print Page Number
  1311. ;
  1312. prpnum:
  1313.     lda    skipfl    ;skipping?
  1314.     ora    a
  1315.     rnz
  1316.     call    lprint    ;print header
  1317.     db    'Page ',0
  1318.     lhld    pnum    ;print current page number
  1319.     call    lhldc    ;print as decimal
  1320.     ret
  1321. ;
  1322. ;  Print File Name
  1323. ;
  1324. prfname:
  1325.     lda    skipfl    ;skipping?
  1326.     ora    a
  1327.     rnz
  1328.     call    prdash    ;print separator
  1329.     lxi    h,tfcb+1    ;pt to first char
  1330.     mvi    b,8    ;8 chars
  1331.     call    lfn1
  1332.     mvi    a,'.'
  1333.     call    lout
  1334.     mvi    b,3    ;3 chars
  1335.     call    lfn1
  1336.     ret
  1337. lfn1:
  1338.     mov    a,m    ;get char
  1339.     ani    7fh    ;mask
  1340.     call    lout    ;send to printer
  1341.     inx    h    ;pt to next
  1342.     dcr    b    ;count down
  1343.     jnz    lfn1
  1344.     ret
  1345. ;
  1346. ;  Print Separator
  1347. ;
  1348. prdash:
  1349.     call    lprint
  1350.     db    ' -- ',0
  1351.     ret
  1352. ;
  1353.     if    timeok
  1354. ;
  1355. ;  Print Time
  1356. ;
  1357. prtime:
  1358.     lda    skipfl    ;skipping?
  1359.     ora    a
  1360.     rnz
  1361.     call    prdash    ;print separator
  1362.     lxi    h,timebf    ;pt to time stamp
  1363.     call    lpstr    ;print
  1364.     ret
  1365. ;
  1366.     endif
  1367. ;
  1368. ;  Print Header
  1369. ;
  1370. prhdg:
  1371.     lda    skipfl    ;skipping?
  1372.     ora    a
  1373.     rnz
  1374.     call    prdash    ;print separator
  1375.     lxi    h,hbuf    ;pt to heading
  1376.     call    lpstr    ;print
  1377.     ret
  1378. ;
  1379. ;  UTILITIES
  1380. ;    SBLANK  -- SKIP BLANKS PTED TO BY HL UNTIL NON-BLANK ENCOUNTERED; HL
  1381. ;    SNBLANK -- SKIP NON-BLANKS PTED TO BY HL UNTIL BLANK OR EOL; HL
  1382. ;    PRFN    -- PRINT FILE NAME PTED TO BY HL; AFFECT NOTHING
  1383. ;
  1384.  
  1385. ;
  1386. ;  SKIP UNTIL NON-BLANK
  1387. ;
  1388. SBLANK:
  1389.     MOV    A,M    ; LOOK FOR BLANK
  1390.     INX    H    ; PT TO NEXT
  1391.     CPI    ' '    ; BLANK?
  1392.     JZ    SBLANK
  1393.     DCX    H    ; BACK UP
  1394.     RET
  1395.  
  1396. ;
  1397. ;  SKIP UNTIL BLANK OR EOL
  1398. ;
  1399. SNBLANK:
  1400.     MOV    A,M    ; GET CHAR
  1401.     INX    H    ; PT TO NEXT
  1402.     CPI    ' '    ; BLANK?
  1403.     JZ    SNB1
  1404.     ORA    A    ; EOL?
  1405.     JNZ    SNBLANK
  1406. SNB1:
  1407.     DCX    H    ; BACK UP
  1408.     RET
  1409.  
  1410. ;
  1411. ;  PRINT FILE NAME PTED TO BY HL
  1412. ;    OUTPUT TO CON:
  1413. ;
  1414. PRFN:
  1415.     PUSH    H    ; SAVE REGS
  1416.     PUSH    B
  1417.     CALL    RETUD    ; GET CURRENT USER/DISK
  1418.     MOV    A,B    ; PRINT DISK
  1419.     ADI    'A'    ; LETTER
  1420.     CALL    COUT
  1421.     MOV    A,C    ; PRINT USER
  1422.     CALL    PADC
  1423.     CALL    PRINT
  1424.     DB    ': ',0
  1425.     INX    H    ; PT TO FILE NAME
  1426.     MVI    B,8    ; PRINT NAME
  1427.     CALL    PRNT
  1428.     MVI    A,'.'    ; DECIMAL
  1429.     CALL    COUT
  1430.     MVI    B,3    ; PRINT TYPE
  1431.     CALL    PRNT
  1432.     POP    B    ; GET REGS
  1433.     POP    H
  1434.     RET
  1435.  
  1436. ;
  1437. ;  PRINT CHARS PTED TO BY HL FOR B BYTES
  1438. ;    OUTPUT TO CON:
  1439. ;
  1440. PRNT:
  1441.     MOV    A,M    ; GET CHAR
  1442.     CALL    COUT
  1443.     INX    H    ; PT TO NEXT
  1444.     DCR    B    ; COUNT DOWN
  1445.     JNZ    PRNT
  1446.     RET
  1447.  
  1448. ;
  1449. ;  BUFFERS
  1450. ;
  1451. DISK:
  1452.     DS    1    ; HOME DISK NUMBER
  1453. USER:
  1454.     DS    1    ; HOME USER NUMBER
  1455. CDISK:
  1456.     DS    1    ; CURRENT DISK NUMBER
  1457. CUSER:
  1458.     DS    1    ; CURRENT USER NUMBER
  1459. CMDLNE:
  1460.     DS    2    ; PTR TO COMMAND LINE STRING
  1461. NEXTCH:
  1462.     DS    2    ; PTR TO NEXT CHAR IN MULTIFILE COMMAND LINE
  1463. FILECNT:
  1464.     DS    2    ; COUNT OF NUMBER OF FILES RENAMED
  1465. SCRATCH:
  1466.     DS    2    ; ADDRESS OF FIRST FREE BYTE
  1467. BCNT:
  1468.     DS    1    ; NUMBER OF PAGES IN SCRATCH AREA
  1469. NTFCB:
  1470.     DS    36    ; FCB FOR NEW FILE
  1471. ;
  1472. ;  PRINT3 Buffers
  1473. ;
  1474. tfcb:
  1475.     ds    36    ; FCB for current file
  1476. nxtblk:
  1477.     ds    2    ; pointer to next block to load
  1478. nxtln:
  1479.     ds    2    ; pointer to next line to read
  1480. lcount:
  1481.     ds    1    ; count of text lines left on page
  1482. ;
  1483. ;  Stack
  1484. ;
  1485.     DS    100    ; STACK AREA
  1486. STACK:
  1487.     DS    2    ; OLD STACK PTR
  1488.  
  1489.     END
  1490.