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

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