home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / ZCPR2 / PAGE.MAC < prev    next >
Text File  |  2000-06-30  |  27KB  |  1,307 lines

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