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 / ZSYS / SIMTEL20 / ZCPR3 / VFILER.MAC < prev    next >
Text File  |  2000-06-30  |  99KB  |  4,466 lines

  1.  
  2. ;  TITLE 'VFILER'
  3.  
  4. ;  VERSION:  3.0
  5. ;  DATE:  26 June 84
  6. ;  AUTHOR:  Richard Conn
  7.  
  8. ;  Changes to make Version 3.4 by Richard Conn:
  9. ;    Symbol CCP changed to CCPLEN (when Z3BASE.LIB was added, the
  10. ;    symbol CCP in Z3BASE.LIB conflicted with this symbol in VFILER;
  11. ;    how did version 3.3 ever assemble in the first place, unless someone
  12. ;    has modified Z3BASE.LIB from the original format?)
  13. ;  Comments on version 3.3 changes added, prefixed by <RLC>
  14.  
  15. ;  THE FOLLOWING MAJOR CHANGES WERE MADE BY JAY SAGE AND BOB DEMROW TO
  16. ;  MAKE VERSION 3.3.  The changes were built from version 3.1.
  17.  
  18. ;  The following changes were contributed by Jay P. Sage and marked by
  19. ;  <JPS> on the lines or at the blocks changed or added:
  20. ;    1. Code modified to eliminate double loading of program, once to
  21. ;       establish shell and once to run shell.  Program now checks after
  22. ;       shell is established to see if any commands are pending in the
  23. ;       command line.  If there are none, the code is run immediately
  24. ;       without reloading from disk.  Otherwise, pending commands are run
  25. ;       first as in previous versions.
  26. ;    <RLC> Good idea
  27. ;    2. The disk logging command was extended to include setting of the
  28. ;       file selection mask in system file name 4.  This command was also
  29. ;       renamed from 'N' to 'L' to be consistent with common usage in
  30. ;       previous versions of VFILER and other programs.  An equate is
  31. ;       provided early in the code for those who want to change this. 
  32. ;       The response to the 'L' command is now a general ambiguous file
  33. ;       specification.  If it includes a directory specification, then
  34. ;       that directory is logged into.  Otherwise, one remains in the
  35. ;       current directory.  If it includes a file name specification,
  36. ;       then that name is copied to system file name 4 and is used as a
  37. ;       mask for file selection.  Otherwise '*.*' is used automatically. 
  38. ;       Note that the colon must now be included to specify only a new
  39. ;       directory.  Since a carriage return alone cancels the command,
  40. ;       '*.*' would have to be entered to stay in the currect directory
  41. ;       but include all files.  As a shortcut one can enter just a colon
  42. ;       or semicolon.
  43. ;    <RLC> Fine; note that the change of the command name to 'N' was
  44. ;    <RLC> done in the first place to be consistent with FRIENDLY,
  45. ;    <RLC> the "commercial VFILER" sold by Ampro Computers; but, then
  46. ;    <RLC> again, if you use FRIENDLY, you probably don't use VFILER,
  47. ;    <RLC> so the problem of consistency may not come up
  48. ;    3. Several changes were made in the command table to allow for
  49. ;       synonyms.  The 'X' abort operation was deleted from the 'L'
  50. ;       command but was made equivalent to control-c in the main command
  51. ;       table.  The functions control-a and control-f, though included in
  52. ;       the help screen, had not previously been implemented.  They are
  53. ;       here made synonyms for '-' and '+', respectively.  (The built-in
  54. ;       help screen was modified to make this clear.)  For ease in
  55. ;       entering commands, '<' and ',' were made the same as control-s,
  56. ;       and '>' and '.' were made the same as control-d.
  57. ;    <RLC> Fine; I debated for some time about adding synonyms, and
  58. ;    <RLC> had originally decided against it; let's try this change
  59. ;    <RLC> as-is and see how it works; however, re the addition of
  60. ;    <RLC> ^A and ^F as synonyms for - and +, I'm sorry I forgot to
  61. ;    <RLC> delete these from the Help screen -- they were intentionally
  62. ;    <RLC> omitted because of potential conflict with arrow keys from
  63. ;    <RLC> Z3TCAP -- if an arrow key generated ^A or ^F, then the ^A/^F
  64. ;    <RLC> movement functions were overriddent by ^A/^F arrows, so I
  65. ;    <RLC> decided to drop them completely and have only - and +; again,
  66. ;    <RLC> let's try this change for a while and see how it works out
  67. ;    4. When files are deleted with the 'D' command, notice to that
  68. ;       effect is displayed on the command line at the bottom of the
  69. ;       screen.
  70. ;    5. Highlighting  on the 'Z80 Code' and '8080 Code' messages was
  71. ;       deleted.
  72. ;    <RLC> Cosmetic
  73. ;    6. Rename function made to completely update file ring and display.
  74. ;       This solves the problem of renamed files being out of place.
  75. ;    <RLC> Good idea
  76.  
  77. ;  The following changes were contributed by R.I.Demrow and are marked by
  78. ;  <RID> on all lines that were changed.
  79. ;    1. Replaced Z3ENV equate by MACLIB reference to Z3BASE.LIB.  This
  80. ;       library includes definitions for true and false, the value of
  81. ;       Z3ENV, and the value of I8080 (indicates whether to use Z80
  82. ;       opcodes)
  83. ;    <RLC> Good idea; it is nice to have these equates carried in thru
  84. ;    <RLC> Z3BASE.LIB, but don't expect to find matching CRCs from one
  85. ;    <RLC> assembly to the next -- the COM files will differ depending
  86. ;    <RLC> on values in Z3BASE; I feel, tho, that the convenience of
  87. ;    <RLC> including Z3BASE outweighs the inconvenience of matching CRCs
  88. ;    2. Added highlighting to current file and current disk on top line
  89. ;       of display.
  90. ;    <RLC> See comment under next change
  91. ;    3. Tagged files are now highlighted on the screen.
  92. ;    <RLC> There was a lot of debate during the design of FRIENDLY as
  93. ;    <RLC> to whether to point to a file via a pointer or via highlighting;
  94. ;    <RLC> the highlighting option was ruled against for the simple reason
  95. ;    <RLC> that pointing is very important and fundamental to the VFILER
  96. ;    <RLC> concept, and, on some terminals in certain kinds of lighting,
  97. ;    <RLC> it is nearly impossible to distinguish a highlighted file from
  98. ;    <RLC> one which is not highlighted; however, in this case, the file
  99. ;    <RLC> is highlighted AND followed by a tag character, so the best of
  100. ;    <RLC> both worlds is retained
  101. ;    4. Two new group functions were added: mass print and mass view.
  102. ;    <RLC> Not a bad idea, but I prefer using the PRINT and PAGE
  103. ;    <RLC> commands for these operations; note that a VFILER.CMD file
  104. ;    <RLC> could provide PRINT and PAGE easily without any cost inside
  105. ;    <RLC> of VFILER
  106. ;    5. The simulated clear-to-end-of-line function was corrected.  It
  107. ;       only cleared part of line before, and it had the wrong divisor in
  108. ;       a modulus calculation.
  109. ;    <RLC> Good
  110. ;    6. Changed code to make use of TCAP information about length of
  111. ;       printer page.  That information was obtained in the previous code
  112. ;       but was not utilized.
  113. ;    <RLC> Good
  114.  
  115.  
  116. ;  PREVIOUS VERSIONS:  2.0 (18 Sep 83), 1.8 (17 Sep 83)
  117. ;  PREVIOUS VERSIONS:  1.7 (9 Sep 83), 1.6 (18 Aug 83), 1.5 (20 July 83)
  118. ;  PREVIOUS VERSIONS:  1.4 (19 July 83), 1.3 (18 July 83)
  119. ;  PREVIOUS VERSIONS:  1.2 (18 July 83), 1.1 (17 July 83), 1.0 (16 July 83)
  120. ;  DERIVATION:  From FILER (Version 1.6) by Richard Conn
  121. ;        FILER from DISK7, Version 7.6C, by Frank Gaude'
  122.  
  123.  
  124. VERS    EQU    34           ;<RLC> Version Number
  125.                 ;<JPS><RID> version number
  126.  
  127.     MACLIB Z3BASE.LIB    ;<RID>  USE LIB TO GET Z3ENV, I8080, FALSE, 
  128.                 ; and TRUE
  129.  
  130. ; VFILER is copyright (c) 1983, 1984, 1985 by Richard Conn
  131. ; All Rights Reserved
  132. ; VFILER may be used freely by the ZCPR3 Community
  133.  
  134. ; VFILER is a screen-oriented, ZCPR3-specific file utility.  It can not be
  135. ; installed to run under conventional CP/M.  VFILER
  136. ; extensively employs cursor addressing to position a pointer on the
  137. ; screen, allow the user to manipulate the pointer (up, down, right, left,
  138. ; next screen, previous screen, GOTO file).  The pointer points to files
  139. ; in the current user directory and displays the user's position dynamically
  140. ; on the screen.  Once pointing to a file, user commands can be used to
  141. ; manipulate the file (delete, copy, view on console, print on printer, tag
  142. ; for later copy or delete, and untag).  In the way of being ZCPR3-specific,
  143. ; VFILER can chain to external programs via the MCL and then return (ala
  144. ; MENU), and it recognizes Named Directories (so the user can log into B:, B4:,
  145. ; and MYDIR:, for example).
  146.  
  147. ; VFILER is installed by Z3INS.
  148.  
  149. ; VFILER works with ZCPR3 only, with 32k or more of RAM.  File copy
  150. ; functions are faster with large amounts of RAM.
  151.  
  152. ; VFILER can be assembled for use with a Z80 or 8080 microprocessor.
  153.  
  154.        
  155. ;  SYSLIB, Z3LIB, and VLIB References
  156. ;
  157.     ext    z3vinit,cls,gotoxy,ereol,envptr,getcrt,getprt,vprint
  158.     ext    z3log,retud
  159.     ext    fi0$open,f0$get,dutdir,fi0$close
  160.     ext    sksp,putcl,getmdisk
  161.     ext    cin,cout,caps,lout,crlf,lcrlf,pafdc,phlfdc
  162.     ext    pfind,dnscan
  163.     ext    getsh,getcl1,qshell,shpush,getzrun,putzex,putcst
  164.     ext    getefcb,shpop,getsh2,getfn2,getshm,putshm
  165.     ext    codend
  166.     ext    stndout,stndend,getcl2,zprsfn            ;<JPS>
  167. ;
  168. ;  Basic Definitions
  169. ;
  170.  
  171. DIM     EQU    1        ;GOTO DIM
  172. BRIGHT     EQU    2        ;GOTO BRIGHT
  173.  
  174. ;
  175. ; User-Customized Definition
  176. ;
  177. VFNAME     MACRO            ;;Name of VFILER
  178.      DB    'VFILER'
  179.      ENDM
  180. VFNFILL     MACRO            ;;Spaces to fill out name to 8 chars
  181.      DB    '  '
  182.      ENDM
  183. ;
  184. Z80     EQU    NOT I8080    ;<JPS> from Z3BASE.LIB
  185. BIHELP     EQU    TRUE         ;TRUE to provide built-in help info
  186. WARMBOOT EQU    FALSE        ;set TRUE to warmboot on exit
  187. DEFALPHA EQU    TRUE        ;set TRUE to alpha by name and type, FALSE for
  188.                 ; ... type and name by default
  189. EPS     EQU    18*4        ;N lines x 4 cols per screen
  190.                 ;  EPS = Entries Per Screen
  191. TAGCH     EQU    '#'        ;character used to mark tagged files
  192. DIRCMD     EQU    'L'        ;command used to log new dir -- be sure it
  193.                 ;does not conflict with other commands -- used
  194.                 ;to be 'N' for new (I prefer 'L' for log) <JPS>
  195.  
  196. ;
  197. ;  Command Line Builder Constants
  198. ;
  199. FPESC     EQU    '%'        ;escape char
  200. FPDISK     EQU    'D'        ;disk only (D)
  201. FPUSER     EQU    'U'        ;user only (U)
  202. FPFILE     EQU    'F'        ;file name only
  203. MNOTE     EQU    '#'        ;denotes comment area in macro file
  204. UIN1     EQU    27H        ;single quote for user input
  205. UIN2     EQU    22H        ;double quote for user input
  206.  
  207. ;
  208. ; Cursor Positioning Addresses
  209. ;
  210. EPSLINE    EQU    (EPS/4)+4    ;position of last line of EPS
  211. BANADR    EQU    1*256+24    ;banner address
  212. CURHOME    EQU    3*256+1        ;home address of cursor
  213. BOTADR    EQU    24*256+1    ;bottom of screen
  214. CPMADR    EQU    EPSLINE*256+1    ;command prompt message
  215. CPADR    EQU    EPSLINE*256+22    ;command prompt
  216. ERADR    EQU    (EPSLINE+1)*256+15    ;error message
  217. FSADR    EQU    ERADR        ;file size message
  218. FNADR    EQU    1*256+62    ;address of current file name
  219. DUADR    EQU    1*256+4        ;address of current DU
  220.  
  221. ;
  222. ; System Functions
  223. ;
  224. RDCON    EQU    1
  225. WRCON    EQU    2
  226. PUNCH    EQU    4
  227. LIST    EQU    5
  228. DIRCON    EQU    6
  229. RDBUF    EQU    10
  230. CONST    EQU    11
  231. RESETDK    EQU    13
  232. LOGIN    EQU    14
  233. OPEN    EQU    15
  234. CLOSE    EQU    16
  235. SRCHF    EQU    17
  236. SRCHN    EQU    18
  237. ERASE    EQU    19
  238. READ    EQU    20
  239. WRITE    EQU    21
  240. MAKE    EQU    22
  241. REN    EQU    23
  242. INQDISK    EQU    25
  243. SETDMA    EQU    26
  244. INQALC    EQU    27
  245. ATTR    EQU    30
  246. GETPARM    EQU    31
  247. SGUSER    EQU    32
  248. COMPSZ    EQU    35
  249.  
  250. ;
  251. ; System Addresses
  252. ;
  253. OS$BASE EQU    000H        ;system base..
  254. CCPLEN    EQU    800H        ;..and 'ccp' length in bytes.
  255.                 ;<RLC> Changed name from CCP to CCPLEN
  256. GET    EQU    0FFH        ;get user area e-reg value
  257. BDOS    EQU    OS$BASE+05H
  258. FCB    EQU    OS$BASE+5CH
  259. FCBEXT    EQU    FCB+12
  260. FCBRNO    EQU    FCB+32
  261. FCB2    EQU    OS$BASE+6CH
  262. TBUF    EQU    OS$BASE+80H
  263. TPA    EQU    OS$BASE+100H
  264.  
  265. ;
  266. ; ASCII Definitions
  267. ;
  268. CTRLA    EQU    'A'-'@'        ;<JPS>
  269. CTRLC    EQU    'C'-'@'        ;..control-C..
  270. CTRLD    EQU    'D'-'@'
  271. CTRLE    EQU    'E'-'@'
  272. CTRLF    EQU    'F'-'@'        ;<JPS>
  273. CTRLR    EQU    'R'-'@'
  274. CTRLS    EQU    'S'-'@'        ;..XOFF..
  275. CTRLX    EQU    'X'-'@'
  276. BS    EQU    08H        ;..backspace..
  277. TAB    EQU    09H        ;..tab..
  278. LF    EQU    0AH        ;..linefeed..
  279. FF    EQU    0CH        ;..formfeed..
  280. CR    EQU    0DH        ;..carriage return..
  281. CAN    EQU    18H        ;..cancel..
  282. EOFCHAR    EQU    1AH        ;..end-of-file..
  283. CTRLZ    EQU    1AH        ;..clear screen..
  284. ESC    EQU    1BH        ;..and escape character.
  285.  
  286. ;
  287. ; MACROS TO PROVIDE Z80 EXTENSIONS
  288. ;   MACROS INCLUDE:
  289. ;
  290. ;    BR    - JUMP RELATIVE
  291. ;    BRC    - JUMP RELATIVE IF CARRY
  292. ;    BRNC    - JUMP RELATIVE IF NO CARRY
  293. ;    BRZ    - JUMP RELATIVE IF ZERO
  294. ;    BRNZ    - JUMP RELATIVE IF NO ZERO
  295. ;    BJNZ    - DECREMENT B AND JUMP RELATIVE IF NO ZERO
  296. ;
  297. BR    MACRO    ?N    ;;JUMP RELATIVE
  298.     IF    Z80
  299.      .z80
  300.      jr    ?N
  301.      .8080
  302.     ELSE
  303.      jmp    ?N
  304.     ENDIF
  305.     ENDM
  306. ;
  307. BRC    MACRO    ?N    ;;JUMP RELATIVE ON CARRY
  308.     IF    Z80
  309.      .z80
  310.      jr    c,?N
  311.      .8080
  312.     ELSE
  313.      jc    ?N
  314.     ENDIF
  315.     ENDM
  316. ;
  317. BRNC    MACRO    ?N    ;;JUMP RELATIVE ON NO CARRY
  318.     IF    Z80
  319.      .z80
  320.      jr    nc,?N
  321.      .8080
  322.     ELSE
  323.      jnc    ?N
  324.     ENDIF
  325.     ENDM
  326. ;
  327. BRZ    MACRO    ?N    ;;JUMP RELATIVE ON ZERO
  328.     IF    Z80
  329.      .z80
  330.      jr    z,?N
  331.      .8080
  332.     ELSE
  333.      jz    ?N
  334.     ENDIF
  335.     ENDM
  336. ;
  337. BRNZ    MACRO    ?N    ;;JUMP RELATIVE ON NO ZERO
  338.     IF    Z80
  339.      .z80
  340.      jr    nz,?N
  341.      .8080
  342.     ELSE
  343.      jnz    ?N
  344.     ENDIF
  345.     ENDM
  346. ;
  347. BJNZ    MACRO    ?N    ;;DECREMENT B AND JUMP RELATIVE ON NO ZERO
  348.     IF    Z80
  349.      .z80
  350.      djnz    ?N
  351.      .8080
  352.     ELSE
  353.      dcr    b
  354.      jnz    ?N
  355.     ENDIF
  356.     ENDM
  357. ;
  358. ; END OF Z80 MACRO EXTENSIONS
  359. ;
  360.  
  361. ;
  362. ; Environment Definition
  363. ;
  364.     if    z3env ne 0
  365. ;
  366. ; External ZCPR3 Environment Descriptor
  367. ;
  368.     jmp    start
  369.     db    'Z3ENV'    ;This is a ZCPR3 Utility
  370.     db    1    ;External Environment Descriptor
  371. z3eadr:
  372.     dw    z3env
  373. start:
  374.     lhld    z3eadr    ;pt to ZCPR3 environment
  375. ;
  376.     else
  377. ;
  378. ; Internal ZCPR3 Environment Descriptor
  379. ;
  380. ;    MACLIB    Z3BASE        ;<JPS> already included above
  381.     MACLIB    SYSENV
  382. z3eadr:
  383.     jmp    start
  384.     SYSENV
  385. start:
  386.     lxi    h,z3eadr    ;pt to ZCPR3 environment
  387.     endif
  388.  
  389. ;
  390. ;  Start of Program -- Initialize ZCPR3 Environment
  391. ;  Once Environment is Initialized, One of Three Major Functions
  392. ;  will be Performed:
  393. ;    1.  VFILER will be installed as a Shell if invoked explicitly
  394. ;        by user command
  395. ;    2.  The VFILER Function will be performed if VFILER is invoked
  396. ;        by ZCPR3 as a Shell and ZEX is not Running
  397. ;    3.  A Command Line will be Input by VFILER from ZEX and Passed
  398. ;        on to ZCPR3 without Processing
  399. ;
  400.     call    z3vinit    ;initialize the ZCPR3 Env and the VLIB Env
  401. ;
  402. ;  Set Opsys Stack Pointer
  403. ;
  404.     if    not WARMBOOT
  405.     lxi    h,0        ;clear hl-pair then..
  406.     dad    sp        ;..add stack address.
  407.     shld    stack
  408.     endif            ;not warmboot
  409.  
  410. ;
  411. ; Check to see if VFILER was executed as a shell
  412. ;
  413.     call    qshell        ;get and test message from ZCPR3
  414.     jz    runsh        ;execute shell procedures
  415. ;
  416. ; Initialize VFILER as a Shell
  417. ;
  418.     call    shtest1        ;there must be a shell stack
  419.     call    shtest2        ;there must be a command line buffer
  420. ;
  421. ; FUNCTION 1:  Set Up VFILER as a Shell
  422. ;  Run Shell Via Exit to Opsys
  423. ;
  424.     call    getefcb        ;determine name of program
  425.     brz    shgo1        ;name not given, so use default
  426.     inx    h        ;pt to name
  427.     lxi    d,filercmd    ;define name of program
  428.     mvi    b,8
  429.     call    moveb        ;copy name
  430. shgo1:
  431.     call    idu        ;set initial disk/user
  432.     lxi    h,filercmd    ;establish shell
  433.     call    shpush        ;push onto shell stack
  434.     brnz    shgo2        ;error?
  435.  
  436.     call    filsel        ;select file mask <JPS>
  437. ;
  438. ;  Print Done Message
  439. ;
  440.     call    vprint
  441.     db    ' Shell Installed',cr,lf,0
  442.     mvi    b,0        ;shell message 0
  443.     mvi    a,0        ;no wait
  444.     call    putshm        ;set shell message
  445.  
  446.         ;changes made by <JPS>
  447. ;    jmp    chain2        ;set IDU into command line and go
  448.     call    chain2        ;set IDU into command line
  449.     call    getcl2        ;see if any more commands on line
  450.     ora    a
  451.     brz    runsh        ;if none, run shell immediately
  452.     jmp    os$ccp1        ;else return to opsys
  453.  
  454. ;
  455. ;  Establish File Selection (made into subroutine <JPS>)
  456. ;
  457. filsel:
  458.     call    getfn2        ;setup file name
  459.     lxi    d,11*3        ;use 4th system file
  460.     dad    d
  461.     lxi    d,fcb+1        ;pt to FCB
  462.     xchg
  463.     mvi    b,11        ;copy 11 chars
  464.     call    moveb
  465.     lxi    h,joker        ;make wild if FCB is empty
  466.     mvi    b,11        ;11 chars
  467.     ldax    d        ;check first char
  468.     cpi    ' '
  469.     cz    moveb
  470.     ret
  471. ;
  472. ;  Error in Shell Stack Installation
  473. ;
  474. shgo2:
  475.     cpi    2        ;shell stack full
  476.     brnz    shgo3
  477.     call    vprint
  478.     db    ' Shell Stack Full',0
  479.     ret
  480. shgo3:
  481.     call    vprint
  482.     db    ' Shell Entry Size',0
  483.     ret
  484.  
  485. ;
  486. ;  VFILER was invoked as a Shell
  487. ;    Check for ZEX Input in Progress
  488. ;
  489. runsh:
  490.     call    getzrun        ;check ZEX message byte
  491.     jnz    zexrun        ;process ZEX command line if ZEX running
  492. ;
  493. ; FUNCTION 2: Run VFILER and Perform Main Function
  494. ;
  495.     mvi    a,0        ;set no shell message
  496.     call    putcst
  497.     call    setup        ;init buffers and pointers
  498.     call    stackset    ;setup stack
  499. ;
  500. ;  Process Initial Help if Available and Requested
  501. ;
  502.     if    BIHELP        ;built-in help available?
  503.     lda    fcb+1        ;check for initial help
  504.     cpi    '/'
  505.     brnz    runsh1
  506.     call    helpmsg        ;print help message
  507.     call    sak        ;strike any key to continue
  508.     br    runsh2
  509. runsh1:
  510.     endif        ;BIHELP
  511. ;
  512. ;  Check for Delay Before Resuming VFILER and Delay if Set
  513. ;
  514.     mvi    b,0
  515.     call    getshm        ;get shell message 0
  516.     ani    80h        ;check MSB
  517.     cnz    sak        ;pause for input
  518. ;
  519. ;  Begin VFILER Processing
  520. ;
  521. runsh2:
  522.     call    stackset    ;reset stack
  523.     call    fload        ;load files
  524.     push    psw
  525.     call    setscr        ;set up screen display variables
  526.     pop    psw
  527.     brnz    runsh4        ;continue if OK
  528. ;
  529. ;  Entry Point to Log Into New Dir and Resume
  530. ;
  531. runsh3:
  532.     call    logdir        ;error - log into another dir
  533.     br    runsh2
  534. ;
  535. ;  Entry Point for Command Processing
  536. ;    Display Screen and Input/Process Command
  537. ;
  538. runsh4:
  539.     call    stackset    ;reset stack
  540.     call    refresh        ;refresh screen display
  541. ;
  542. ;  Display Current File and Input/Process Command
  543. ;
  544. loopfn:
  545.     call    loopfn1        ;print current file name
  546. ;
  547. ;  Input/Process Command
  548. ;
  549. loop:
  550.     call    stackset    ;reset stack
  551.     call    loopfn2        ;get command from user
  552.     call    loopfn3        ;process command in A
  553.     br    loop        ;continue
  554. ;
  555. ;  Set Stack Pointer
  556. ;
  557. stackset:
  558.     pop    d        ;get return address
  559.     lhld    crctbl        ;top of stack
  560.     sphl            ;start local stack
  561.     push    d        ;return address on new stack
  562.     ret
  563. ;
  564. ; Check for Presence of Shell Stack
  565. ;
  566. shtest1:
  567.     call    getsh        ;get shell stack data
  568.     rnz
  569.     pop    psw        ;clear stack
  570.     call    vprint
  571.     db    'No Shell Stack',0
  572.     ret
  573.  
  574. ;
  575. ; Check for Command Line
  576. ;
  577. shtest2:
  578.     call    getcl1        ;get command line data
  579.     rnz
  580.     pop    psw        ;clear stack
  581.     call    vprint
  582.     db    'No Cmd Line',0
  583.     ret
  584.  
  585. ;
  586. ; FUNCTION 3: Run ZEX on Top of VFILER
  587. ;  Accept Command Line and Pass it to ZCPR3
  588. ;
  589. zexrun:
  590.     call    vprint        ;print prompt
  591.     db    'VFILER> ',0
  592.     mvi    a,1        ;tell ZEX that it is prompted
  593.     call    putzex
  594.     call    getcl1        ;pt to command line buffer
  595.     mov    a,l        ;set ptr to first char
  596.     adi    4
  597.     mov    c,a
  598.     mov    a,h
  599.     aci    0
  600.     mov    b,a        ;BC pts to first char
  601.     mov    m,c        ;store low
  602.     inx    h
  603.     mov    m,b        ;store high
  604.     inx    h        ;pt to char count
  605.     xchg            ;... in DE
  606.     mvi    c,rdbuf        ;input line via BDOS
  607.     push    d        ;save ptr
  608.     call    bdos
  609.     pop    h        ;pt to char count
  610.     inx    h
  611.     mov    e,m        ;get char count
  612.     inx    h        ;pt to first char
  613.     push    h        ;save ptr
  614.     mvi    d,0        ;DE=char count
  615.     dad    d
  616.     xra    a        ;A=0
  617.     mov    m,a        ;store ending 0
  618.     pop    h        ;pt to first char
  619.     call    putzex        ;resume ZEX (A=0)
  620.     call    putcst        ;set command status to normal (A=0)
  621.     ret            ;return to opsys
  622.  
  623. ;
  624. ;**************************************************
  625. ;
  626. ; CRT Routine for VFILER
  627. ;
  628. VCLS:
  629.     CALL    CLS        ;try to clear the screen
  630.     RNZ            ;OK if done
  631.     PUSH    H        ;save regs
  632.     PUSH    B
  633.     CALL    GETCRT        ;get CRT Data
  634.     INX    H        ;get number of lines on screen
  635.     MOV    B,M        ;B=number of lines
  636. VCLS1:
  637.     CALL    CRLF        ;new line
  638.     BJNZ    VCLS1
  639.     POP    B        ;restore regs
  640.     POP    H
  641.     RET
  642. ;
  643. ; EREOL Routine for VFILER
  644. ;
  645. VEREOL:
  646.     CALL    EREOL        ;try to erase to EOL
  647.     RNZ            ;OK if done
  648.     PUSH    B        ;save count
  649.     MVI    A,' '        ;space out
  650.     CALL    VEREOL1        ;send B spaces
  651.     POP    B        ;get count
  652.     MVI    A,BS        ;backspace in
  653. VEREOL1:
  654.     CALL    COUT        ;send char
  655.     BJNZ    VEREOL1        ;count down
  656.     RET
  657. ;
  658. ;  Setup Screen Display Variables
  659. ;
  660. SETSCR:
  661.     LXI    H,CURHOME    ;set cursor home
  662.     SHLD    CURAT
  663.     LHLD    RING        ;set ring position
  664. ;
  665. ;  Entry to Reset Ring Position at HL
  666. ;
  667. SETSCR1:
  668.     SHLD    RINGPOS
  669. ;
  670. ;  Entry to Reset Local Ring Position at HL
  671. ;
  672. SETSCR2:
  673.     SHLD    LOCBEG        ;front of ring
  674.     LXI    D,EPS*13    ;new end?
  675.     DAD    D
  676.     XCHG
  677.     LHLD    RINGEND        ;end of ring
  678.     XCHG
  679.     CALL    CMPDEHL
  680.     BRC    SETSCR3
  681.     XCHG
  682. SETSCR3:
  683.     XCHG
  684.     SHLD    LOCEND
  685.     RET
  686.  
  687. ;
  688. ; Display file name of current file
  689. ;
  690. LOOPFN1:
  691.     LXI    H,FNADR        ;position cursor for file name print
  692.     CALL    GOTOXY
  693.     LHLD    RINGPOS        ;pt to current file name
  694.     INX    H        ;pt to first char
  695. ;<RID>    JMP    PRFN        ;print file name
  696.     CALL    STNDOUT        ;<RID> turn on highlighting
  697.     CALL    PRFN        ;<RID> print file name
  698.     CALL    STNDEND        ;<RID> turnoff highlighting;
  699.     RET            ;<RID>
  700. ; Get command from user and clear error line if any
  701. ;
  702. LOOPFN2:
  703.     CALL    ATCMD        ;position at command prompt
  704.     CALL    DKEYIN        ;wait for character from keyboard
  705.     PUSH    PSW        ;save command
  706.     LDA    ERMFLG        ;error message?
  707.     ORA    A        ;0=no
  708.     CNZ    ERCLR        ;erase old error message
  709.     POP    PSW        ;get command
  710.     RET
  711. ;
  712. ; Process Command
  713. ;
  714. LOOPFN3:
  715.     CPI    MNOTE        ;command summary
  716.     BRZ    CPROCM
  717.     CPI    '0'        ;macro?
  718.     BRC    CPROC0
  719.     CPI    '9'+1        ;macro?
  720.     BRNC    CPROC0
  721. CPROCM:
  722.     CALL    CMACRO        ;process macro command
  723.     MOV    B,A        ;save command
  724.     CALL    ERMSG
  725.     DB    'No U Fct ',0
  726.     MOV    A,B        ;get macro digit
  727.     JMP    COUT        ;return for loop processing
  728. CPROC0:
  729.     CALL    CTPROC        ;process command or return if not found
  730.     CALL    ERMSG
  731.     DB    'Invld Cmd: ',0
  732.     MOV    A,B        ;get char
  733.     CPI    ' '        ;expand if less than space
  734.     BRNC    CPROC1
  735.     MVI    A,'^'        ;control
  736.     CALL    COUT
  737.     MOV    A,B        ;get byte
  738.     ADI    '@'        ;convert to letter
  739. CPROC1:
  740.     JMP    COUT        ;return for loop processing
  741.  
  742. ;
  743. ; SET UP BUFFERS
  744. ;
  745. SETUP:
  746.     CALL    RETUD        ;get home DU
  747.     MOV    A,B
  748.     STA    H$DR        ;home drive
  749.     MOV    A,C
  750.     STA    H$U$A        ;home user area
  751.     CALL    CODEND        ;start of free space
  752.     LXI    D,100H        ;256 bytes/unit
  753.     DAD    D
  754.     SHLD    CRCTBL        ;table for CRC list et al
  755.     DAD    D
  756.     DAD    D        ;allow 512 bytes
  757.     SHLD    CMDBUF        ;command line buffer
  758.     MVI    M,64        ;64 bytes in line
  759.     LXI    D,70        ;arbitrary beyond EOL
  760.     DAD    D
  761.     SHLD    DUM$FCB        ;dummy FCB
  762.     INR    H
  763.     MVI    L,0        ;next page
  764.     SHLD    BUFENTRY    ;free space to end of TPA
  765.  
  766. ;
  767. ;  Set CRT/Printer Data
  768. ;
  769.     CALL    GETCRT        ;CRT DATA
  770.     MOV    A,M
  771.     STA    CWIDTH        ;WIDTH
  772.     INX    H
  773.     MOV    B,M
  774.     INX    H
  775.     MOV    A,M
  776.     STA    CTPP        ;TEXT
  777.     MOV    C,A
  778.     MOV    A,B        ;TOTAL NUMBER OF LINES
  779.     SUB    C
  780.     DCR    A        ;1 LESS
  781.     STA    CSPP        ;LINES TO SKIP
  782.     CALL    GETPRT        ;PRINTER DATA
  783.     MOV    A,M
  784.     STA    LWIDTH        ;WIDTH
  785.     INX    H
  786.     MOV    B,M
  787.     INX    H
  788.     MOV    A,M
  789.     STA    LTPP        ;TEXT
  790.     MOV    C,A
  791.     MOV    A,B        ;TOTAL NUMBER OF LINES
  792.     SUB    C
  793.     STA    LSPP        ;LINES TO SKIP
  794.     INX    H
  795.     MOV    A,M
  796.     STA    LFFEED        ;CAN FORM FEED?
  797.  
  798. ;
  799. ;  Begin Further Inits
  800. ;
  801.     XRA    A
  802.     STA    HELPDISP    ;no help display yet
  803. ;
  804.     MVI    A,DEFALPHA    ;alpha by name and type
  805.     STA    ALPHA
  806. ;
  807.     LHLD    ENVPTR        ;pt to ZCPR3 Env Desc
  808.     LXI    D,80H+10H    ;pt to cursor commands
  809.     DAD    D
  810.     LXI    D,CTABLE    ;pt to area
  811.     MVI    B,4        ;4 commands
  812. CURINIT:
  813.     MOV    A,M        ;get command
  814.     STAX    D        ;put it
  815.     INX    H        ;pt to next
  816.     INX    D
  817.     INX    D
  818.     INX    D
  819.     BJNZ    CURINIT
  820. ;
  821.     CALL    IDU        ;set initial disk/user
  822.     CALL    LOGRDU        ;log into it
  823. ;
  824.     LHLD    BUFENTRY    ;base address
  825.     SHLD    RING        ;beginning of ring
  826. ;
  827.     LXI    H,CURHOME    ;home address for cursor
  828.     SHLD    CURAT
  829. ;
  830.     CALL    GETMDISK    ;get max disk number (1-N)
  831.     ADI    '@'        ;convert to ASCII (A-P)
  832.     STA    MAXDR        ;set letter
  833. ;
  834.     RET
  835.  
  836. ;  set initial disk/user
  837. IDU:
  838.     LXI    D,FCB        ;log into DU specification
  839.     CALL    Z3LOG        ;perform login
  840. IDU1:
  841.     CALL    RETUD        ;get current DU in BC
  842.     MOV    A,C        ;get current user
  843.     CALL    IDU$USET    ;set it
  844.     MOV    A,B        ;get current disk
  845.     CALL    IDU$DSET    ;set it
  846.     RET
  847. IDU$USET:
  848.     STA    C$U$A        ;..store as current and..
  849.     STA    O$USR        ;..as original for exit.
  850.     STA    R$U$A        ;..requested user area
  851.     RET
  852. IDU$DSET:
  853.     STA    C$DR
  854.     STA    R$DR        ;requested disk
  855.     RET
  856.  
  857. ; check for existance of file whose first 12 FCB bytes are pted to by DE
  858. ;   return with A=0 if not found, A=0FFH if found
  859.  
  860. FILECHK:
  861.     LXI    H,S$FCB        ;copy into FCB
  862.     XCHG
  863.     MVI    B,12        ;12 bytes
  864.     CALL    MOVE        ;copied into S$FCB
  865.     XCHG            ;HL pts to FCB
  866.     CALL    INITFCB        ;init FCB
  867.     LXI    D,S$FCB        ;pt to FCB
  868.     JMP    FFIND
  869.  
  870. ;
  871. ; Select drive and user area (system reset for disk change on-the-fly)
  872. ; <JPS>
  873. ;
  874. LOGDIR:
  875.     CALL    CPRMPT        ;prompt to get drive/user selection
  876.     DB    'Login DIR (and file mask): ',0
  877.     CALL    DEFSPEC        ;define full file specification
  878. LOG1:
  879.     CALL    LOGRDU        ;set current and log in
  880.     JMP    CRLF        ;new line and exit
  881.  
  882. ;
  883. ; Actually log into DU requested
  884. ;
  885. LOGRDU:
  886.     LDA    R$DR        ;make requested disk current
  887.     STA    C$DR
  888.     CALL    RESET        ;reset disk system
  889.     LDA    R$U$A        ;establish requested area..
  890.     STA    C$U$A        ;..as current area.
  891.     CALL    SET$USR
  892.     LXI    H,0        ;initialize tagged..
  893.     SHLD    TAG$TOT        ;..file size accumulator.
  894.     RET
  895.  
  896. ;
  897. ; Define file specification <JPS>
  898. ; (comes before DEF$D$U and includes preparing to change system file 4 for new
  899. ; mask)
  900. ;
  901. DEFSPEC:
  902.     CALL    RDSPEC        ;get user input
  903.     CALL    TOKEN1        ;position HL to first token and test for end
  904.     JZ    LOOP        ;if no entry, loop back for another command
  905.     LXI    D,FCB        ;use default FCB
  906.     CALL    ZPRSFN        ;parse the filespec into FCB
  907.     CALL    FILSEL        ;copy filespec into system file 4
  908.     CALL    TOKEN1        ;back to first token
  909.     XRA    A        ;scan for DIR before DU
  910.     CALL    DNSCAN        ;scan again to get drive and user values
  911.     BRNZ    DEFDU2        ;if found, enter new values
  912.     RET            ;otherwise, just return
  913.  
  914. ;
  915. ; Define current drive and user area
  916. ; many modifications <JPS>
  917. ;
  918. DEF$D$U:
  919.     CALL    RDSPEC        ;read DU and filespec <JPS>
  920.     CALL    TOKEN1        ;position HL to first token
  921.     JZ    LOOP
  922.  
  923.         ;delete this redundant test <JPS>
  924. ;
  925. ;    MOV    A,M        ;check for exit
  926. ;    CALL    CAPS
  927. ;    CPI    'X'
  928. ;    BRNZ    DEFDU1
  929. ;    INX    H        ;check for space or EOL
  930. ;    MOV    A,M
  931. ;    DCX    H
  932. ;    ANI    7FH        ;mask MSB
  933. ;    CPI    ' '+1
  934. ;    JC    OS$CCP        ;abort
  935. ;DEFDU1:
  936.  
  937.     XRA    A        ;A=0 to scan for DIR before DU
  938.     CALL    DNSCAN        ;look for DU or DIR form and return DU
  939.     BRZ    ERRET        ;error
  940. DEFDU2:
  941.     MOV    A,B        ;return disk and user
  942.     STA    R$DR
  943.     INR    A        ;set FCB
  944.     STA    FCB
  945.     MOV    A,C
  946.     STA    R$U$A
  947.     RET
  948. ;
  949. ; position to first token and set flag to show end of buffer
  950. ;
  951. TOKEN1:
  952.     LHLD    CMDBUF        ;pt to possible drive
  953.     INX    H
  954.     INX    H
  955.     CALL    SKSP        ;skip over leading spaces and return
  956.     MOV    A,M        ;check for no input
  957.     ORA    A
  958.     RET
  959. ;
  960. ; reads line of input from user -- pulled out as subroutine <JPS>
  961. ;
  962. RDSPEC:
  963.     LHLD    CMDBUF        ;pt to command line buffer
  964.     INX    H
  965.     INX    H
  966.     MVI    B,20        ; # of blanks to..
  967.     CALL    FILL        ;..clear 'cmdbuf'.
  968.     LHLD    CMDBUF        ;get DU selection from..
  969.     XCHG
  970.     MVI    C,RDBUF        ;..console buffer read.
  971.     CALL    BDOS
  972.     JMP    CONVERT        ;make sure alpha is upper case and return
  973. ;
  974. ; Error return and recovery from command cancellation
  975. ;
  976. ERRET:
  977.     CALL    ERMSG
  978.     DB    'DIR Entry Error',0
  979.     JMP    LOOP
  980. COMCAN:
  981.     LDA    CANFLG        ;check for nature of abort
  982.     ORA    A        ;..from..
  983.     JZ    RUNSH2        ;no file found, so run the shell again
  984.     JMP    RUNSH4        ;..error/command abort.
  985. ;
  986. ; find file along path (file FCB pted to by DE)
  987. ;   on return, A=0FFH if found, A=0 if not found, and flags set
  988. ;
  989. FFIND:
  990.     MVI    A,0FFH        ;look in current dir also
  991.     JMP    PFIND        ;path search from Z3LIB
  992. ; log in default directory
  993. DLOGIN:
  994.     LDA    C$DR        ;disk in B
  995.     MOV    B,A
  996.     LDA    C$U$A        ;user in C
  997.     MOV    C,A        ;fall thru to SLOGIN
  998. ; log in DU in BC
  999. SLOGIN:
  1000.     PUSH    H        ;save regs
  1001.     PUSH    D
  1002.     PUSH    B
  1003.     MOV    A,C        ;set user
  1004.     CALL    SET$USR
  1005.     POP    B
  1006.     MOV    A,B        ;set disk
  1007.     CALL    SET$DR
  1008.     POP    D        ;restore regs
  1009.     POP    H
  1010.     RET
  1011.  
  1012. ; e x i t
  1013.  
  1014. ; return to ccp
  1015.  
  1016. ;
  1017. ; Entry point for VFILER exit
  1018. ;
  1019. OS$CCP:
  1020.     CALL    SHPOP        ;clear shell stack
  1021. ;
  1022. ; Entry point for command line exec
  1023. ;
  1024. OS$CCP1:
  1025.     LDA    O$USR        ;get and set original..
  1026.     CALL    SET$USR        ;..user area and..
  1027.     LXI    D,TBUF        ;..tidy up..
  1028.     MVI    C,SETDMA    ;..before going home.
  1029.     CALL    BDOS
  1030.  
  1031.      IF WARMBOOT
  1032.     JMP    OS$BASE
  1033.      ENDIF            ;warmboot
  1034.  
  1035.      IF    NOT WARMBOOT
  1036.     LHLD    STACK        ;put pointer..
  1037.     SPHL            ;..back to 'sp'.
  1038.     RET            ;return to ccp
  1039.     NOP            ; to try jump to start
  1040.     NOP
  1041.  
  1042.      ENDIF            ;not warmboot
  1043.  
  1044. ;
  1045. ;  FLOAD loads the files into the buffer, setting up the ring
  1046. ;  Return with NZ if load OK, Z if no files loaded
  1047. ;
  1048. FLOAD:
  1049.     CALL    FRESTOR        ;get bytes remaining on drive (decode default)
  1050. ;
  1051. ;  Set up file name from System File 4
  1052. ;    Select all files if no entry in System File 4
  1053. ;
  1054.     CALL    GETFN2        ;pt to first system file name
  1055.     LXI    D,11*3        ;pt to 4th file name
  1056.     DAD    D
  1057.     LXI    D,FCB+1        ;pt to FCB
  1058.     MVI    B,11        ;11 bytes
  1059.     CALL    MOVEB
  1060.     LXI    H,JOKER        ;..treat as '*.*' with 'joker'..
  1061.     MVI    B,11        ; # of characters to move
  1062.     LDAX    D        ;get first char of file name
  1063.     CPI    ' '        ;if space, fill with *.*
  1064.     CZ    MOVEB        ;set field to *.*
  1065.     LDAX    D        ;get first char of file name
  1066.     CPI    '/'        ;if opt, fill with *.*
  1067.     CZ    MOVEB
  1068. ;
  1069. ; Build ring with filename positioned in default FCB area
  1070. ;
  1071.     MVI    C,SETDMA    ;initialize dma address..
  1072.     LXI    D,TBUF        ;..to default buffer.
  1073.     CALL    BDOS
  1074.     XRA    A        ;clear search 'fcb'..
  1075.     STA    FCBEXT        ;extent byte..
  1076.     STA    FCBRNO        ;..and record number.
  1077.     LXI    D,FCB        ;default FCB for search
  1078.     CMA
  1079.     STA    CANFLG        ;make cancel flag true
  1080.     MVI    C,SRCHF        ;..of first occurrence.
  1081.     CALL    BDOS
  1082.     INR    A        ; 0ffh --> 00h if no file found
  1083.     BRNZ    SETRING        ;if found, branch and build ring.
  1084.     STA    CANFLG        ;make log-cancel toggle false (0)
  1085.     CALL    ERMSG        ;else say none found, fall thru to log.
  1086.     DB    'No File Found',0
  1087.     XRA    A        ;Set Error Code
  1088.     RET
  1089.  
  1090. ; establish ring (circular list) of filenames
  1091.  
  1092. SETRING:
  1093.     LHLD    RING        ;initialize ring pointer
  1094.     SHLD    RINGPOS        ;start --> current position of ring
  1095.  
  1096. ; put each found name in ring.  a-reg --> offset into 'tbuf' name storage
  1097.  
  1098. TO$RING:
  1099.     DCR    A        ;un-do 'inr' from above and below
  1100.     ADD    A        ;times 32 --> position index
  1101.      ADD    A
  1102.     ADD    A
  1103.     ADD    A
  1104.     ADD    A
  1105.     ADI    TBUF        ;add page offset and..
  1106.     MOV    L,A        ;..put address into..
  1107.     MVI    H,0        ;..hl-pair.
  1108.     LDA    FCB        ;get drive/user designator and..
  1109.     MOV    M,A        ;..put into 'fcb' buffer.
  1110.     XCHG
  1111.     LHLD    RINGPOS        ;pointer to current load point in ring
  1112.     XCHG
  1113.     MVI    B,12        ;move drive designator and name to ring
  1114.     CALL    MOVE
  1115.     XCHG            ;de-pair contains next load point address
  1116.     MVI    M,' '        ;space for potential..
  1117.     INX    H        ;..tagging of files for mass copy.
  1118.     SHLD    RINGPOS        ;store and search..
  1119.     MVI    C,SRCHN        ;..for next occurrence.
  1120.     LXI    D,FCB        ;filename address field
  1121.     CALL    BDOS
  1122.     INR    A        ;if all done, 0ffh --> 00h.
  1123.     BRNZ    TO$RING        ;if not, put next name into ring.
  1124. ;
  1125. ; All filenames in ring -- setup ring size and copy-buffer start point
  1126. ;
  1127.     LHLD    RINGPOS        ;next load point of ring is start of buffer
  1128.     SHLD    RINGEND        ;set ring end..
  1129.     SHLD    BUFSTART    ;..and copy-buffer start.
  1130.     PUSH    H
  1131.     LHLD    RING
  1132.     LXI    D,13        ;compare 'ringend' (tab base+13)
  1133.     DAD    D
  1134.     XCHG
  1135.     POP    H
  1136.     CALL    CMPDEHL
  1137.     BRNZ    SORT        ;sort if more than one file in ring
  1138.     XRA    A        ;set NZ for Return
  1139.     DCR    A
  1140.     RET
  1141. ;
  1142. ; Sort ring of filenames
  1143. ;
  1144. SORT:
  1145.     LHLD    RING        ;initialize 'i' sort variable and..
  1146.     SHLD    RINGI
  1147.     LXI    D,13        ;..also 'j' variable.
  1148.     DAD    D
  1149.     SHLD    RINGJ
  1150. SORTLP:
  1151.     LHLD    RINGJ        ;compare names 'i & j'
  1152.     XCHG
  1153.     LHLD    RINGI
  1154.     PUSH    H        ;save position pointers..
  1155.     PUSH    D        ;..for potential swap.
  1156.     LDA    ALPHA        ;check for type of alphabetization
  1157.     ORA    A        ;if Zero, alpha by type and name
  1158.     JZ    SORTTN
  1159.  
  1160. ; sort by file name and type
  1161.     MVI    B,12        ; # of characters to compare
  1162.     CALL    CMPSTR        ;do comparison
  1163.     BR    NOCMP        ;final test
  1164.  
  1165. ; sort by file type and name
  1166. SORTTN:
  1167.     PUSH    H        ;save ptrs
  1168.     PUSH    D
  1169.     LXI    B,9        ;pt to type
  1170.     DAD    B
  1171.     XCHG
  1172.     DAD    B
  1173.     XCHG
  1174.     MVI    B,3        ;3 chars in file type
  1175.     CALL    CMPSTR        ;compare type
  1176.     POP    D        ;get ptrs
  1177.     POP    H
  1178.     BRNZ    NOCMP        ;final test
  1179.     PUSH    H
  1180.     PUSH    D
  1181.     MVI    B,8        ;8 chars in file name
  1182.     INX    H        ;pt to first
  1183.     INX    D
  1184.     CALL    CMPSTR        ;compare name
  1185.     POP    D        ;get ptrs
  1186.     POP    H
  1187.     BRNZ    NOCMP        ;final test
  1188.     LDAX    D        ;final compare and fall thru
  1189.     CMP    M
  1190.  
  1191. ; final test for swapping purposes
  1192. NOCMP:
  1193.     POP    D
  1194.     POP    H
  1195.     MVI    B,13
  1196.     BRNC    NOSWAP
  1197. ;
  1198. ; Swap if 'j' string larger than 'i'
  1199. ;
  1200. SWAP:
  1201.     MOV    C,M        ;get character from one string..
  1202.     LDAX    D        ;..and one from other string.
  1203.     MOV    M,A        ;second into first
  1204.     MOV    A,C        ;first into second
  1205.     STAX    D
  1206.     INX    H        ;bump swap pointers
  1207.     INX    D
  1208.     BJNZ    SWAP
  1209. NOSWAP:
  1210.     LHLD    RINGJ        ;increment 'j' pointer
  1211.     LXI    D,13
  1212.     DAD    D
  1213.     SHLD    RINGJ
  1214.     XCHG            ;see if end of 'j' loop
  1215.     LHLD    RINGEND
  1216.     CALL    CMPDEHL
  1217.     JNZ    SORTLP        ;no, so more 'j' looping.
  1218.     LHLD    RINGI        ;bump 'i' pointer
  1219.     LXI    D,13
  1220.     DAD    D
  1221.     SHLD    RINGI
  1222.     DAD    D        ;set start over 'j' pointer
  1223.     SHLD    RINGJ
  1224.     XCHG            ;see if end of 'i' loop
  1225.     LHLD    RINGEND
  1226.     CALL    CMPDEHL
  1227.     JNZ    SORTLP        ;must be more 'i' loop to do
  1228. ;
  1229. ; Sort done -- initialize tables for fast crc calculations
  1230. ;
  1231.     CALL    INITCRC
  1232. ;
  1233. ; Calculate buffer maximum available record capacity
  1234. ;
  1235. B$SIZE:
  1236.     LXI    B,0        ;count records
  1237.     LHLD    BDOS+1        ;get 'bdos' entry (fbase)
  1238.  
  1239.      IF    NOT WARMBOOT
  1240.     LXI    D,-(CCPLEN)
  1241.     DAD    D
  1242.      ENDIF            ;not warmboot
  1243.  
  1244.     DCX    H
  1245.     XCHG            ;de-pair --> highest address of buffer
  1246.     LHLD    BUFSTART    ;start address of buffer (end of ring list)
  1247. B$SIZE2:
  1248.     INX    B        ;increase record count by one
  1249.     PUSH    D
  1250.     LXI    D,128        ; 128-byte record
  1251.     DAD    D        ;buffer address + record size
  1252.     POP    D
  1253.     CALL    CMPDEHL        ;compare for all done
  1254.     BRNC    B$SIZE2        ;more will fit?
  1255.     DCX    B        ;set maximum record count less one
  1256.     MOV    A,B        ;memory available for copy?
  1257.     ORA    C
  1258.     BRNZ    B$SIZE3        ;yes, buffer memory space available.
  1259.     CALL    ERMSG
  1260.     DB    'No Room',0
  1261.     XRA    A        ;Error code
  1262.     RET
  1263. B$SIZE3:
  1264.     MOV    L,C        ;store..
  1265.     MOV    H,B        ;..maximum..
  1266.     SHLD    REC$MAX        ;..record count.
  1267.     XRA    A        ;return NZ for OK
  1268.     DCR    A
  1269.     RET
  1270. ;
  1271. ; left to right compare of two strings (de-pair points to 'a' string;
  1272. ; hl-pair, to 'b'; b-reg contains string length.)
  1273. ;
  1274. CMPSTR:
  1275.     LDAX    D        ;get an 'a' string character and..
  1276.     CMP    M        ;..check against 'b' string character.
  1277.     RNZ            ;if not equal, set flag.
  1278.     INX    H        ;bump compare..
  1279.     INX    D        ;..pointers and..
  1280.     DCR    B        ; (if compare, set as equal.)
  1281.     BRNZ    CMPSTR        ;..do next character.
  1282.     RET
  1283. ;
  1284. ; COMMAND: MACRO (0-9)
  1285. ; Process macro command
  1286. ;
  1287. CMACRO:
  1288.     PUSH    PSW        ;save digit
  1289.     LXI    H,MACFCB    ;set up name of macro file
  1290.     LXI    D,S$FCB
  1291.     PUSH    D
  1292.     MVI    B,12        ;12 chars
  1293.     CALL    MOVE
  1294.     XCHG
  1295.     CALL    INITFCB        ;init FCB
  1296.     POP    D        ;pt to FCB
  1297.     CALL    FFIND        ;search along path for file
  1298.     BRNZ    CMFOUND        ;file found
  1299.     POP    PSW        ;clear stack
  1300.     POP    D        ;clear ret address
  1301.     CALL    ERMSG
  1302.     DB    'File ',0
  1303.     LXI    H,MACFCB+1
  1304.     CALL    PRFN        ;print file name
  1305.     CALL    VPRINT
  1306.     DB    ' NOT Found',0
  1307.     JMP    LOOP
  1308. ; found macro file
  1309. CMFOUND:
  1310.     CALL    SLOGIN        ;log in
  1311.     CALL    FI0$CLOSE        ; CLOSE FILE IF ALREADY OPEN
  1312.     LXI    D,S$FCB        ;pt to FCB
  1313.     CALL    FI0$OPEN    ;open for byte-oriented input
  1314.     POP    PSW        ;get command
  1315.     MOV    C,A        ;... in C
  1316. ; new line
  1317. CMFL1:
  1318.     CALL    F0$GET        ;get first char of line
  1319.     JNZ    CMFLERR        ;EOF encountered
  1320.     CMP    C        ;match?
  1321.     BRZ    CMFL3
  1322. ; skip out line
  1323. CMFL2:
  1324.     CALL    F0$GET        ;skip out line
  1325.     JNZ    CMFLERR
  1326.     CPI    LF        ;EOL?
  1327.     BRNZ    CMFL2
  1328.     BR    CMFL1
  1329. ; found command
  1330. CMFL3:
  1331.     MVI    A,MNOTE        ;macro note?
  1332.     CMP    C
  1333.     JZ    CMFLNOTE
  1334.     PUSH    D
  1335.     LHLD    CRCTBL    ;buffer for command line
  1336.     LXI    D,256    ;+256
  1337.     DAD    D
  1338.     POP    D
  1339. ; skip leading blanks in command line
  1340. CMFL4:
  1341.     CALL    F0$GET        ;get next char
  1342.     BRNZ    CMFL6        ;mark end of buffer and go
  1343.     CPI    ' '        ;skip leading blanks
  1344.     BRZ    CMFL4
  1345. ; load command line into buffer
  1346. CMFL5:
  1347.     ANI    7FH        ;mask char
  1348.     CPI    CR        ;EOL?
  1349.     BRZ    CMFL6
  1350.     CPI    CTRLZ        ;EOF?
  1351.     BRZ    CMFL6
  1352.     CPI    FPESC        ;file pted to?
  1353.     JZ    CMFLIF
  1354.     CPI    UIN1        ;user input?
  1355.     BRZ    CMFL5A
  1356.     CPI    UIN2
  1357.     BRZ    CMFL5A
  1358. CMFL50:
  1359.     MOV    M,A        ;store char
  1360.     INX    H        ;pt to next
  1361. CMFL51:
  1362.     CALL    F0$GET        ;get next char
  1363.     BRZ    CMFL5
  1364.     BR    CMFL6
  1365.  
  1366. ; print prompt to user and get input
  1367. CMFL5A:
  1368.     PUSH    H        ;save buffer ptr
  1369.     CALL    CPRMPT        ;at command prompt line
  1370.     DB    0
  1371. CMFL5B:
  1372.     CALL    F0$GET        ;get next char
  1373.     BRNZ    CMFL5B1
  1374.     ANI    7FH        ;mask
  1375.     CPI    UIN1        ;end of prompt?
  1376.     BRZ    CMFL5C
  1377.     CPI    UIN2
  1378.     BRZ    CMFL5C
  1379.     CPI    CR        ;end of prompt?
  1380.     BRZ    CMFL5C
  1381.     CPI    CTRLZ        ;eof?
  1382.     BRZ    CMFL5C
  1383.     CALL    COUT        ;send char
  1384.     BR    CMFL5B
  1385. CMFL5B1:
  1386.     MVI    A,CTRLZ        ;eof
  1387. CMFL5C:
  1388.     PUSH    PSW        ;save offending char
  1389.     LHLD    BUFSTART    ;pt to buffer
  1390.     MVI    M,128        ;128 char in line
  1391.     INX    H        ;set no chars
  1392.     MVI    M,0
  1393.     DCX    H        ;pt to count
  1394.     XCHG
  1395.     MVI    C,RDBUF        ;get line from user
  1396.     CALL    BDOS
  1397.     LHLD    BUFSTART
  1398.     INX    H        ;pt to count
  1399.     MOV    A,M        ;get count
  1400.     INX    H        ;pt to first char
  1401.     PUSH    H        ;save ptr
  1402.     ADD    L
  1403.     MOV    L,A
  1404.     MOV    A,H
  1405.     ACI    0
  1406.     MOV    H,A        ;HL pts to after last char
  1407.     MVI    M,0        ;store ending zero
  1408.     POP    H        ;HL pts to first char of line
  1409.     POP    PSW        ;get char
  1410.     POP    D        ;DE pts to next char in buffer
  1411.     MOV    B,A        ;char in B
  1412. CMFL5D:
  1413.     MOV    A,M        ;copy chars
  1414.     ORA    A        ;zero=done
  1415.     BRZ    CMFL5E
  1416.     STAX    D        ;put char
  1417.     INX    H        ;pt to next
  1418.     INX    D
  1419.     BR    CMFL5D
  1420. CMFL5E:
  1421.     XCHG            ;HL pts to next char in buffer
  1422.     MOV    A,B        ;check offending char
  1423.     CPI    UIN1        ;user input?
  1424.     BRZ    CMFL51
  1425.     CPI    UIN2
  1426.     BRNZ    CMFL5
  1427.     BR    CMFL51
  1428. ; complete buffer and test for content
  1429. CMFL6:
  1430.     MVI    M,0        ;store ending 0
  1431.     PUSH    D
  1432.     LHLD    CRCTBL        ;pt to first char in line
  1433.     LXI    D,256
  1434.     DAD    D
  1435.     POP    D
  1436.     MOV    A,M        ;get first char
  1437.     ORA    A        ;empty?
  1438.     BRNZ    CMFL7
  1439. ; error return
  1440. CMFLERR:
  1441.     PUSH    B
  1442.     CALL    DLOGIN        ;return home
  1443.     POP    B
  1444.     MOV    A,C        ;invalid command
  1445.     RET
  1446. ; try to chain
  1447. CMFL7:
  1448.     PUSH    H        ;save ptr
  1449.     CALL    DLOGIN        ;return home
  1450.     POP    H
  1451.     CALL    CHAIN        ;chain to command line pted to by HL
  1452.     JMP    LOOP
  1453.  
  1454. ; print documentation built into the macro file
  1455. CMFLNOTE:
  1456.     CALL    VCLS        ;new screen
  1457.     MVI    C,0        ;set tab counter
  1458. CMFLN1:
  1459.     CALL    F0$GET        ;get next char
  1460.     BRNZ    CMFLN4        ;done
  1461.     ANI    7FH        ;mask
  1462.     CPI    CTRLZ        ;eof=done
  1463.     BRZ    CMFLN4
  1464.     CPI    TAB        ;tab process
  1465.     BRZ    CMFLN2
  1466.     CALL    COUT        ;print char
  1467.     CPI    CR        ;new line?
  1468.     BRZ    CMFLN3
  1469.     INR    C        ;new pos
  1470.     CPI    LF
  1471.     BRNZ    CMFLN1
  1472.     DCR    C        ;back up position count
  1473.     BR    CMFLN1
  1474. CMFLN2:
  1475.     MVI    A,' '        ;space over for tab
  1476.     CALL    COUT
  1477.     INR    C        ;incr position
  1478.     MOV    A,C        ;done?
  1479.     ANI    7        ;every 8
  1480.     BRNZ    CMFLN2
  1481.     BR    CMFLN1
  1482. CMFLN3:
  1483.     MVI    C,0        ;bol for CR
  1484.     BR    CMFLN1
  1485. CMFLN4:
  1486.     CALL    DLOGIN        ; RETURN HOME
  1487.     LHLD    RINGPOS        ;print current file
  1488.     INX    H
  1489.     CALL    PRFN
  1490.     CALL    VPRINT
  1491.     DB    '  Enter Digit or RETURN - ',0
  1492.     CALL    DKEYIN
  1493.     POP    D        ;get ret address
  1494.     CPI    '0'        ;in range?
  1495.     JC    RUNSH4
  1496.     CPI    '9'+1        ;in range?
  1497.     JNC    RUNSH4
  1498.     PUSH    D        ;replace ret address
  1499.     JMP    CMACRO
  1500.  
  1501. ; insert file pted to (% prefix command)
  1502. CMFLIF:
  1503.     CALL    F0$GET        ;get next char
  1504.     JNZ    CMFL6
  1505.     CPI    FPESC        ;doubled?
  1506.     JZ    CMFL50
  1507.     LXI    D,CMFL51    ;return address
  1508.     PUSH    D        ;... on stack
  1509.     ANI    5FH        ;capitalize
  1510.     CPI    FPFILE        ;file only?
  1511.     BRZ    CMFLIF1
  1512.     CPI    FPDISK        ;disk only?
  1513.     BRZ    CMFLIF2
  1514.     CPI    FPUSER        ;user only?
  1515.     BRZ    CMFLIF3
  1516.     CALL    CMFLIF2        ;Disk
  1517.     CALL    CMFLIF3        ;User
  1518.     MVI    M,':'        ;separator
  1519.     INX    H        ;fall thru to file name
  1520. CMFLIF1:
  1521.     XCHG            ;save ptr to next
  1522.     LHLD    RINGPOS        ;pt to current file
  1523.     INX    H
  1524.     MVI    B,8        ;8 chars in filename
  1525.     CALL    CMFL5X
  1526.     MVI    A,'.'        ;put dot
  1527.     STAX    D
  1528.     INX    D
  1529.     MVI    B,3        ;3 chars max
  1530.     CALL    CMFL5X
  1531.     XCHG            ;HL pts to next
  1532.     RET
  1533. CMFLIF2:
  1534.     LDA    C$DR        ;store disk
  1535.     ADI    'A'
  1536.     MOV    M,A
  1537.     INX    H        ;pt to next
  1538.     RET
  1539. CMFLIF3:
  1540.     LDA    C$U$A        ;user
  1541.     CPI    10        ;less than 10?
  1542.     BRC    CMFLIF32
  1543.     MVI    B,'0'        ;compute 10's
  1544. CMFLIF30:
  1545.     SUI    10        ;subtract 10's
  1546.     BRC    CMFLIF31
  1547.     INR    B
  1548.     BR    CMFLIF30
  1549. CMFLIF31:
  1550.     ADI    10
  1551.     MOV    M,B        ;store 10's
  1552.     INX    H
  1553. CMFLIF32:
  1554.     ADI    '0'        ;store 1's
  1555.     MOV    M,A
  1556.     INX    H
  1557.     RET
  1558. CMFL5X:
  1559.     MOV    A,M        ;get char
  1560.     CPI    ' '
  1561.     BRZ    CMFL5X1
  1562.     STAX    D        ;put char
  1563.     INX    H        ;pt to next
  1564.     INX    D
  1565.     BJNZ    CMFL5X
  1566.     RET
  1567. CMFL5X1:
  1568.     INX    H        ;advance
  1569.     BJNZ    CMFL5X1
  1570.     RET
  1571. ;
  1572. ; Process command from table
  1573. ;
  1574. CTPROC:
  1575.     MOV    B,A        ;command in B
  1576.     LXI    H,CTABLE    ;pt to table
  1577.     MOV    A,M        ;any cursor commands?
  1578.     ORA    A
  1579.     JNZ    CTPR1
  1580.     LXI    H,CTAB1
  1581. ;
  1582. ; Command table scanner
  1583. ;    HL = Table
  1584. ;    B  = Command Letter
  1585. ;
  1586. CTPR1:
  1587.     MOV    A,M        ;get table command char
  1588.     ORA    A        ;end of table?
  1589.     RZ            ;done if so
  1590.     CMP    B        ;match?
  1591.     BRZ    CTPR2
  1592.     INX    H        ;skip to next entry
  1593.     INX    H
  1594.     INX    H
  1595.     BR    CTPR1
  1596. CTPR2:
  1597.     INX    H        ;pt to address
  1598.     MOV    A,M        ;get low
  1599.     INX    H
  1600.     MOV    H,M        ;get high
  1601.     MOV    L,A
  1602.     XTHL            ;address on stack
  1603.     RET            ;"jump" to routine
  1604.  
  1605. ; Command Table
  1606. CTABLE:
  1607.     DB    0        ;user cursor positioning
  1608.     DW    UP
  1609.     DB    0
  1610.     DW    DOWN
  1611.     DB    0
  1612.     DW    FORWARD
  1613.     DB    0
  1614.     DW    REVERSE
  1615. CTAB1:
  1616.     DB    CTRLC        ;if exit, then to opsys
  1617.     DW    OS$CCP
  1618.     DB    'X'        ;alternate exit <JPS>
  1619.     DW    OS$CCP
  1620.     DB    CTRLR        ;screen refresh?
  1621.     DW    RUNSH4
  1622.     DB    CTRLE        ;system cursor positioning
  1623.     DW    UP
  1624.     DB    CTRLX
  1625.     DW    DOWN
  1626.     DB    CTRLD
  1627.     DW    FORWARD
  1628.     DB    CTRLS
  1629.     DW    REVERSE
  1630.  
  1631.     DB    '.'        ;alternate commands <JPS>
  1632.     DW    FORWARD
  1633.     DB    '>'
  1634.     DW    FORWARD
  1635.     DB    ','
  1636.     DW    REVERSE
  1637.     DB    '<'
  1638.     DW    REVERSE
  1639.  
  1640.     DB    CR        ;nop
  1641.     DW    LOOP
  1642.     DB    '+'        ;jump forward
  1643.     DW    JUMPF
  1644.     DB    CTRLF        ;jump forward <JPS>
  1645.     DW    JUMPF
  1646.     DB    '-'        ;jump backward
  1647.     DW    JUMPB
  1648.     DB    CTRLA        ;jump backward <JPS>
  1649.     DW    JUMPB
  1650.     DB    ' '        ;go forward
  1651.     DW    FORWARD
  1652.     DB    BS        ;back up?
  1653.     DW    REVERSE
  1654.     DB    'A'        ;alphabetize?
  1655.     DW    ALPHASW
  1656.     DB    'C'        ;copy a file?
  1657.     DW    FCOPY
  1658.     DB    'D'        ;delete a file?
  1659.     DW    FDEL
  1660.     DB    'F'        ;show file size?
  1661.     DW    FSIZE
  1662.     DB    'G'        ;group operation?
  1663.     DW    GROUP$OP
  1664.     DB    'H'        ;external help?
  1665.     DW    EXTHELP
  1666.     DB    'J'        ;jump to a file?
  1667.     DW    GOTO
  1668.     DB    DIRCMD        ;log-in another drive?
  1669.     DW    RUNSH3
  1670.     DB    'P'        ;output file to 'list' device?
  1671. ;    DW    LSTFILE        ;<RID>
  1672.     DW    SPRINT        ;<RID>
  1673.     DB    'Q'        ;screen refresh?
  1674.     DW    RUNSH4
  1675.     DB    'R'        ;rename?
  1676.     DW    RENAME
  1677.     DB    'S'        ;free bytes on..
  1678.     DW    DSTAT        ;..requested drive?
  1679.     DB    'T'        ;if tag, put TAGCH in..
  1680.     DW    TAG        ;..front of cursor.
  1681.     DB    'U'        ;remove TAGCH from..
  1682.     DW    UNTAG        ;..in front of cursor?
  1683.     DB    'V'        ; 'view' file at console?
  1684.     DW    VIEW
  1685.     DB    'Z'        ;run ZCPR3 command
  1686.     DW    RUNZCPR3
  1687. ;
  1688.     IF    BIHELP        ;built-in help?
  1689.     DB    '?'        ;help
  1690.     DW    HELP
  1691.     DB    '/'        ;help also
  1692.     DW    HELP
  1693.     ELSE
  1694.     DB    '?'        ;help
  1695.     DW    EXTHELP
  1696.     DB    '/'        ;help also
  1697.     DW    EXTHELP
  1698.     ENDIF        ;BIHELP
  1699. ;
  1700.     DB    0        ;end of table
  1701.  
  1702. ; h e l p  (menu)
  1703.  
  1704.     IF    BIHELP        ;built-in Help?
  1705. HELPMSG:
  1706.     CALL    VPRINT
  1707.     DB    CR,LF,CR,LF
  1708.     DB    '    '
  1709.     DB    '-- Tagging Commands --    --------- File Operat'
  1710.     DB    'ions ----------',CR,LF
  1711.     DB    '    '
  1712.     DB    '   T - ',DIM,'Tag File',BRIGHT
  1713.     DB    '            C - ',DIM,'Copy File',BRIGHT,'       '
  1714.     DB    'D - ',DIM,'Delete File',BRIGHT,CR,LF
  1715.     DB    '    '
  1716.     DB    '   U - ',DIM,'Untag File',BRIGHT
  1717.     DB    '          F - ',DIM,'File Size',BRIGHT,'       '
  1718.     DB    'R - ',DIM,'Rename File',BRIGHT,CR,LF
  1719.     DB    '    '
  1720.     DB    '                          G - ',DIM,'Group '
  1721.     DB    'Copy/Delete/FSize/Tag/Untag',BRIGHT,CR,LF    ;<RID>
  1722.     DB    '        '
  1723.     DB    '                              ',DIM,'Group '    ;<RID>
  1724.     DB    'Print/View',BRIGHT,CR,LF,CR,LF            ;<RID>
  1725.     DB    '                 '
  1726.     DB    '-- File Print & View --   --- User  Functions ---',CR,LF
  1727.     DB    '  -- Cursor --   '
  1728.     DB    'P - ',DIM,'Print',BRIGHT
  1729.     DB    '      V - ',DIM,'View',BRIGHT
  1730.     DB    '   0-9 - ',DIM,'Execute',BRIGHT,'  ',MNOTE,' - ',DIM,'Help'
  1731.     DB    BRIGHT,CR,LF
  1732.     DB    '       ^E        '
  1733.     DB    CR,LF
  1734.     DB    '        ^        '
  1735.     DB    '-- Movement Commands --   ---- Miscellaneous ----',CR,LF
  1736.     DB    '   ^S <-+-> ^D   '
  1737.     DB    '  <SP> - ',DIM,'File Forward'
  1738.     DB    BRIGHT,'      A - ',DIM,'Toggle Alpha Sort',BRIGHT,CR,LF
  1739.     DB    '        v        '
  1740.     DB    '  <BS> - ',DIM,'File Backward'
  1741.     DB    BRIGHT,'     H - ',DIM,'Help File',BRIGHT,CR,LF
  1742.     DB    '       ^X        '
  1743.     DB    '   +   - ',DIM,'Screen Forward',BRIGHT
  1744.     DB    '    '
  1745.  
  1746.     DB    DIRCMD            ;changes to reflect command choice <JPS>
  1747.  
  1748.     DB    ' - ',DIM,'Log DIR and/or Mask',BRIGHT,CR,LF
  1749.     DB    '                 '
  1750.     DB    '   -   - ',DIM,'Screen Backward',BRIGHT
  1751.     DB    '   S - ',DIM,'Disk Status',BRIGHT,CR,LF
  1752.     DB    '  -- Screen --   '
  1753.     DB    '   J   - ',DIM,'Jump to a File',BRIGHT
  1754.     DB    '    Z - ',DIM,'ZCPR3 Command',BRIGHT,CR,LF
  1755.     DB    '    ^A  ',DIM,'Backward',BRIGHT,' '        ;<JPS>
  1756.     DB    '   Q   - ',DIM,'Refresh Screen',BRIGHT
  1757.     DB    '   ^C - ',DIM,'Exit',BRIGHT,CR,LF
  1758.     DB    '    ^F  ',DIM,'Forward',BRIGHT,' '        ;<JPS>
  1759.  
  1760.     IF    BIHELP                        ;<JPS>
  1761.     DB    '             '                    ;<JPS>
  1762.     DB    '? or / - ',DIM,'Toggle Help Screen',BRIGHT    ;<JPS>
  1763.     ENDIF                            ;<JPS>
  1764.  
  1765.     DB    0
  1766.     RET
  1767. HELP:
  1768.     LDA    HELPDISP    ;toggle flag
  1769.     CMA
  1770.     STA    HELPDISP
  1771.     JMP    RUNSH4        ;refresh screen and restart
  1772.     ENDIF        ;BIHELP
  1773. ;
  1774. ; COMMAND: H
  1775. ;
  1776. EXTHELP:
  1777.     CALL    CPRMPT
  1778.     DB    'Read Help File (Y/N)? ',0
  1779.     CALL    CIN
  1780.     CALL    CAPS
  1781.     CPI    'Y'
  1782.     JNZ    LOOPFN
  1783.     CALL    ERMSG
  1784.     DB    DIM,'Chaining to Help File ...',BRIGHT,0
  1785.     LXI    H,MOREHELP    ;run HELP Command
  1786.     CALL    CHAIN        ;chain to it
  1787.     JMP    LOOPFN
  1788.  
  1789. ;
  1790. ; COMMAND: A
  1791. ;
  1792. ; Toggle alphabetize switch and reload files
  1793. ;
  1794. ALPHASW:
  1795.     LDA    ALPHA        ;toggle flag
  1796.     CMA
  1797.     STA    ALPHA
  1798.     CALL    CPRMPT        ;tell user what is happening
  1799.     DB    'Sorting by File ',0
  1800.     LDA    ALPHA        ;get flag
  1801.     ORA    A        ;check it
  1802.     BRZ    ASWTN
  1803.     CALL    VPRINT
  1804.     DB    'Name and Type',0
  1805.     JMP    RUNSH2
  1806. ASWTN:
  1807.     CALL    VPRINT
  1808.     DB    'Type and Name',0
  1809.     JMP    RUNSH2        ;reload files
  1810.  
  1811. ;
  1812. ; COMMAND: Z
  1813. ;
  1814. ; Execute ZCPR3 command line
  1815. ;
  1816. RUNZCPR3:
  1817.     CALL    ERMSG        ;position at error message line
  1818.     DB    0
  1819.     LXI    H,H$DR        ;pt to Home Drive (followed by Home User)
  1820.     CALL    PRDU        ;print DU
  1821.     CALL    VPRINT        ;print prompt
  1822.     DB    '> ',0
  1823.     PUSH    D
  1824.     LHLD    CRCTBL        ;use last half of CRC Table
  1825.     LXI    D,256
  1826.     DAD    D
  1827.     POP    D
  1828.     MVI    M,126        ;store length of line
  1829.     INX    H
  1830.     MVI    M,0        ;store count
  1831.     DCX    H        ;pt to beginning
  1832.     XCHG            ;DE pts to buffer
  1833.     PUSH    D
  1834.     MVI    C,RDBUF        ;Read Line from User
  1835.     CALL    BDOS
  1836.     POP    H
  1837.     INX    H        ;pt to char count
  1838.     MOV    E,M
  1839.     INX    H        ;pt to first char
  1840.     MVI    D,0        ;set no high-order offset
  1841.     PUSH    H        ;save current ptr for later
  1842.     DAD    D
  1843.     MVI    M,0        ;store ending zero
  1844.     POP    H        ;pt to first char of command line
  1845.     MOV    A,M        ;abort if no first char
  1846.     ORA    A
  1847.     JZ    LOOP
  1848.     CALL    CHAIN        ;chain to it
  1849.     JMP    LOOPFN        ;continue
  1850.  
  1851. ; chain to command pted to by HL ending in zero
  1852.  
  1853. CHAIN:
  1854.     CALL    PUTCL        ;store command line
  1855.     BRNZ    CHAIN1
  1856.     CALL    ERMSG
  1857.     DB    'CL Err',0
  1858.     RET
  1859. CHAIN1:
  1860.     MVI    B,0        ;set shell message 0
  1861.     MVI    A,80H        ;enable wait
  1862.     CALL    PUTSHM
  1863.     CALL    CHAIN2        ;<JPS>
  1864.     JMP    OS$CCP1        ;run command line - moved <JPS>
  1865.  
  1866.  
  1867.         ;made a subroutine <JPS>
  1868. CHAIN2:
  1869.     LDA    C$DR        ;get current disk
  1870.     ADI    'A'        ;convert to ASCII
  1871.     STA    FILE$D        ;store in proper place
  1872.     LDA    C$U$A        ;get current user
  1873.     LXI    H,FILE$U    ;store user number
  1874.     MVI    C,'0'        ;set char
  1875. CHAIN3:
  1876.     SUI    10        ;convert to ASCII
  1877.     BRC    CHAIN4
  1878.     INR    C        ;increment 10's char
  1879.     BR    CHAIN3
  1880. CHAIN4:
  1881.     MOV    M,C        ;store 10's digit char
  1882.     INX    H        ;pt to 1's digit
  1883.     ADI    10+'0'        ;add back for 1's digit
  1884.     MOV    M,A        ;store 1's digit char
  1885.     CALL    GETSH2        ;pt to shell buffer
  1886.     LXI    D,8        ;skip 8 chars (VFILER Name)
  1887.     DAD    D
  1888.     LXI    D,FILE$D    ;place DU
  1889.     XCHG
  1890.     MVI    B,5        ;store 5 chars (duu:0)
  1891.     CALL    MOVEB
  1892.     RET            ;<JPS>
  1893.  
  1894. ;
  1895. ; COMMAND: G
  1896. ;
  1897. ; Group operation
  1898. ;
  1899. GROUP$OP:
  1900.     CALL    CPRMPT
  1901.     DB    'Group Cmd (Copy/View/Print/Delete/File Sizes/'  ;<RID>
  1902.     DB    'Tag/Untag)? ',0                 ;<RID>
  1903.     CALL    KEYIN        ;get response
  1904.     MOV    B,A        ;command in B
  1905.     LXI    H,GTABLE    ;pt to table
  1906.     CALL    CTPR1        ;process command
  1907.     JMP    LOOP        ;resume if not found
  1908. ;
  1909. ; Group Command Table
  1910. ;
  1911. GTABLE:
  1912.     DB    'C'
  1913.     DW    MASS$COPY
  1914.     DB    'D'
  1915.     DW    MASS$DEL
  1916.     DB    'P'        ;<RID>
  1917.     DW    MASS$PRINT    ;<RID>
  1918.     DB    'V'        ;<RID>
  1919.     DW    MASS$VIEW    ;<RID>
  1920.     DB    'F'
  1921.     DW    MASS$FSIZE
  1922.     DB    'T'
  1923.     DW    MASS$TAG
  1924.     DB    'U'
  1925.     DW    MASS$UNTAG
  1926.     DB    0        ;end of table
  1927.  
  1928. ;
  1929. ; COMMAND: GU
  1930. ;
  1931. MASS$UNTAG:
  1932.     MVI    B,' '        ;untag char
  1933. ;
  1934. ;  Common Entry Point for Mass Untag/Tag - B = Untag/Tag Char
  1935. ;
  1936. MUTLOOP:
  1937.     LHLD    RINGPOS        ;move to tag
  1938.     LXI    D,12
  1939.     DAD    D
  1940.     MOV    M,B        ;set tag byte
  1941.     INX    H        ;pt to next
  1942.     SHLD    RINGPOS
  1943.     XCHG            ;done?
  1944.     LHLD    LOCEND
  1945.     CALL    CMPDEHL
  1946.     BRNZ    MUTLOOP
  1947.     LXI    H,CURHOME    ;reset cursor
  1948.     SHLD    CURAT
  1949.     LHLD    LOCBEG        ;set ring position
  1950.     JMP    JFW0        ;reset screen from LOCBEG
  1951.  
  1952. ;
  1953. ; COMMAND: GT
  1954. ;
  1955. MASS$TAG:
  1956.     MVI    B,TAGCH        ;tag char
  1957.     BR    MUTLOOP        ;do work
  1958.  
  1959. ;
  1960. ; COMMAND: U
  1961. ;
  1962. UNTAG:
  1963.     MVI    B,' '        ;set tag byte
  1964. ;
  1965. ;  Common Entry Point for Untag/Tag - B = Untag/Tag Char
  1966. ;
  1967. UT:
  1968.     LHLD    RINGPOS        ;move back one..
  1969.     LXI    D,12        ;..character position..
  1970.     DAD    D        ;..and check tagging status.
  1971.     MOV    M,B        ;if file previously tagged, remove..
  1972.     CALL    REFFN        ;refresh file name
  1973.     JMP    FORWARD
  1974.  
  1975. ;
  1976. ; COMMAND: T
  1977. ;
  1978. TAG:
  1979.     MVI    B,TAGCH        ;tag char
  1980.     BR    UT        ;do tag
  1981.  
  1982. ;
  1983. ; Refresh file name with new tag
  1984. ;
  1985. REFFN:
  1986.     CALL    CLRCUR        ;clear cursor
  1987.     MVI    A,' '        ;one more space
  1988.     CALL    COUT
  1989.     LHLD    RINGPOS        ;reprint file name
  1990. ;<RID>    INX    H
  1991. ;<RID>    CALL    PRFN
  1992. ;<RID>    MOV    A,M        ;print tag
  1993. ;<RID>    JMP    COUT
  1994.     CALL    HILITFN        ;<RID> brighten
  1995.     RET            ;<RID>
  1996.  
  1997. ;    
  1998. ; COMMAND: GF
  1999. ;
  2000. MASS$FSIZE:
  2001.     CALL    WORKMSG        ;print 'Working' msg
  2002.     LXI    H,0        ;zero total
  2003.     SHLD    TAG$TOT
  2004.     LHLD    RINGPOS        ;save ring position
  2005.     SHLD    SRINGPOS
  2006.     LHLD    RING        ;set new ring position
  2007.     SHLD    RINGPOS
  2008. ;
  2009. ;  Main Loop to Compute File Sizes
  2010. ;
  2011. MASS$FS:
  2012.     LHLD    RINGEND        ;at end of ring?
  2013.     XCHG
  2014.     LHLD    RINGPOS
  2015.     CALL    CMPDEHL        ;same if so
  2016.     BRZ    MASS$FS2
  2017.     LXI    D,12        ;pt to tag
  2018.     DAD    D
  2019.     MOV    A,M        ;get tag
  2020.     INX    H        ;pt to next file
  2021.     CPI    TAGCH        ;tagged?
  2022.     BRNZ    MASS$FS1    ;skip if not tagged
  2023. ;
  2024. ;  Compute Size of Tagged File
  2025. ;
  2026.     PUSH    H        ;save ptr to next file
  2027.     CALL    SIZER        ;compute file size
  2028.     XCHG            ;size in DE
  2029.     LHLD    TAG$TOT        ;get total
  2030.     DAD    D
  2031.     SHLD    TAG$TOT        ;new total
  2032.     POP    H        ;get ptr to next file
  2033. MASS$FS1:
  2034.     SHLD    RINGPOS        ;set ptr to next file
  2035.     BR    MASS$FS
  2036. ;
  2037. ;  File Size Accumulation Done - Print Result
  2038. ;
  2039. MASS$FS2:
  2040.     LHLD    SRINGPOS    ;restore ring position
  2041.     SHLD    RINGPOS
  2042.     CALL    FSNOTE        ;print file size message
  2043.     CALL    VPRINT        ;print specific
  2044.     DB    'Tagged Files is ',0
  2045.     LHLD    TAG$TOT        ;get total
  2046.     BR    FSIZE1        ;print size in HL and return
  2047.  
  2048. ;
  2049. ; COMMAND: F
  2050. ;
  2051. ; determine and display file size in kilobytes -- round up to next disk
  2052. ; allocation block -- accumulate tagged file summation
  2053. ;
  2054. FSIZE:
  2055.     CALL    SIZER        ;compute file size of current file
  2056.     PUSH    H        ;save value
  2057.     CALL    FSNOTE        ;print file size message
  2058.     LHLD    RINGPOS        ;print file name
  2059.     INX    H
  2060.     CALL    PRFN
  2061.     CALL    VPRINT        ;print trailer
  2062.     DB    ' is ',0
  2063.     POP    H        ;get size
  2064. ;
  2065. ;  Print file size in HL and exit to screen
  2066. ;
  2067. FSIZE1:
  2068.     CALL    PHLFDC          ;print value in HL as floating
  2069.     MVI    A,'K'        ;print suffix
  2070.     CALL    COUT
  2071.     JMP    LOOPFN        ;resume
  2072.  
  2073. ;
  2074. ;  Compute File Size at RINGPOS
  2075. ;    Return Size in HL
  2076. ;
  2077. SIZER:
  2078.     CALL    RINGFCB        ;move name to 's$fcb'
  2079. ;
  2080. ; Determine file record count and save in RCNT
  2081. ;
  2082.     MVI    C,COMPSZ
  2083.     LXI    D,S$FCB
  2084.     CALL    BDOS
  2085.     LHLD    S$FCB+33
  2086.     SHLD    RCNT        ;save record count and..
  2087.     LXI    H,0
  2088.     SHLD    S$FCB+33    ;..reset opsys
  2089. ;
  2090. ; Round up to next disk allocation block
  2091. ;
  2092.     LDA    B$MASK        ;sectors/block - 1
  2093.     PUSH    PSW        ;save 'blm'
  2094.     MOV    L,A
  2095.     XCHG
  2096.     LHLD    RCNT        ;..use here.
  2097.     DAD    D        ;round up to next block
  2098.     MVI    B,3+1        ;convert from..
  2099.     CALL    SHIFTLP        ;..records to kilobytes.
  2100.     POP    PSW        ;retrieve 'blm'
  2101.     RRC            ;convert..
  2102.     RRC            ;..to..
  2103.     RRC            ;..kilobytes/block.
  2104.     ANI    1FH
  2105.     CMA            ;finish rounding
  2106.     ANA    L
  2107.     MOV    L,A        ;hl-pair contains # of kilobytes
  2108.     RET
  2109.  
  2110. ;
  2111. ; COMMAND: - (Previous Screen)
  2112. ;
  2113. JUMPB:
  2114.     LXI    H,CURHOME    ;set cursor home
  2115.     SHLD    CURAT
  2116.     LHLD    RING        ;at front?
  2117.     XCHG
  2118.     LHLD    LOCBEG
  2119.     CALL    CMPDEHL
  2120.     BRZ    JUMPBW        ;back up and wrap around
  2121.     SHLD    LOCEND        ;set new end
  2122.     LXI    D,-EPS*13    ;back up
  2123.     DAD    D
  2124.     SHLD    LOCBEG        ;new beginning
  2125.     SHLD    RINGPOS        ;new position
  2126.     JMP    RUNSH4
  2127. JUMPBW:
  2128.     LHLD    LOCBEG        ;at first screen?
  2129.     XCHG
  2130.     LHLD    RING        ;pt to first element of ring
  2131.     CALL    CMPDEHL
  2132.     BRZ    JBW0        ;advance to end
  2133.     LXI    H,-EPS*13    ;back up
  2134.     DAD    D        ;first element of new local ring
  2135.     BR    JFW0
  2136. JBW0:
  2137.     LXI    D,EPS*13    ;pt to next screen
  2138.     DAD    D
  2139.     XCHG
  2140.     LHLD    RINGEND
  2141.     CALL    CMPDEHL
  2142.     XCHG
  2143.     BRZ    JBW1
  2144.     BRC    JBW0
  2145. JBW1:
  2146.     LXI    D,-EPS*13
  2147.     DAD    D        ;pt to first element of new local ring
  2148.     BR    JFW0
  2149. ;
  2150. ; COMMAND: + (Next Screen)
  2151. ;
  2152. JUMPF:
  2153.     LXI    H,CURHOME    ;set cursor to home
  2154.     SHLD    CURAT
  2155.     LHLD    LOCEND        ;see if Local End <= Ring End
  2156.     XCHG
  2157.     LHLD    RINGEND
  2158.     CALL    CMPDEHL
  2159.     BRZ    CMDLOOP
  2160.     LHLD    LOCEND        ;new screen starting at LOCEND
  2161.     BR    JFW0
  2162.  
  2163. ;
  2164. ;  Reset to Beginning of RING and Resume Command Looping
  2165. ;
  2166. CMDLOOP:
  2167.     CALL    SETSCR        ;reset all screen pointers
  2168. CMDLRET:
  2169.     JMP    RUNSH4
  2170. ;
  2171. ;  Reset RING Position to HL
  2172. ;
  2173. JFW0:
  2174.     CALL    SETSCR1        ;reset RINGPOS on ...
  2175.     BR    CMDLRET
  2176. ;
  2177. ;  Reset Local Ring to HL
  2178. ;
  2179. JFW0A:
  2180.     CALL    SETSCR2        ;reset LOCBEG on ...
  2181.     BR    CMDLRET
  2182.  
  2183. ;
  2184. ; COMMAND: ' ', Left-Arrow
  2185. ;
  2186. FORWARD:
  2187.     CALL    CLRCUR        ;clear cursor
  2188.     CALL    FOR0        ;position on screen and in ring
  2189.     CALL    SETCUR        ;set cursor
  2190.     JMP    LOOPFN
  2191. ;  advance routine
  2192. FOR0:
  2193.     LHLD    RINGPOS        ;at end of loop yet?
  2194.     LXI    D,13        ;i.e., will we be at end of loop?
  2195.     DAD    D
  2196.     XCHG
  2197.     LHLD    LOCEND
  2198.     CALL    CMPDEHL        ;compare 'present' to 'end'
  2199.     BRNZ    FORW        ;to next print position
  2200.     CALL    CUR$FIRST    ;position cursor
  2201.     LHLD    LOCBEG        ;set position pointer to beginning and..
  2202.     SHLD    RINGPOS
  2203.     RET
  2204. FORW:
  2205.     LHLD    RINGPOS        ;advance in ring
  2206.     LXI    D,13
  2207.     DAD    D
  2208.     SHLD    RINGPOS        ;new position
  2209.     CALL    CUR$NEXT    ;position cursor
  2210.     RET
  2211.  
  2212. ;
  2213. ; COMMAND: BS, Right-Arrow
  2214. ;
  2215. REVERSE:
  2216.     CALL    CLRCUR        ;clear cursor
  2217.     CALL    REV0        ;position on screen and in ring
  2218.     CALL    SETCUR        ;set cursor
  2219.     JMP    LOOPFN
  2220. ;  Back Up Routine
  2221. REV0:
  2222.     LHLD    LOCBEG
  2223.     XCHG
  2224.     LHLD    RINGPOS        ;see if at beginning of ring
  2225.     CALL    CMPDEHL
  2226.     BRNZ    REV1        ;skip position pointer reset if not..
  2227.     CALL    CUR$LAST    ;end of local ring
  2228.     LHLD    LOCEND        ;set to end +1 to backup to end
  2229.     LXI    D,-13
  2230.     DAD    D
  2231.     SHLD    RINGPOS
  2232.     RET
  2233. REV1:
  2234.     CALL    CUR$BACK    ;back up 1
  2235. REV2:
  2236.     LHLD    RINGPOS
  2237.     LXI    D,-13        ;one ring position..
  2238.     DAD    D        ;..backwards.
  2239.     SHLD    RINGPOS
  2240.     RET
  2241.  
  2242. ;
  2243. ; COMMAND: Up-Arrow
  2244. ;
  2245. UP:
  2246.     CALL    CLRCUR        ;clear cursor
  2247.     LHLD    RINGPOS        ;see if wrap around
  2248.     LXI    D,-13*4        ;4 entries
  2249.     DAD    D
  2250.     XCHG
  2251.     LHLD    LOCBEG        ;beginning of local screen
  2252.     CALL    CMPDEHL
  2253.     BRC    UP2        ;wrap around
  2254.     MVI    B,4        ;back up 4 entries
  2255. UP1:
  2256.     PUSH    B        ;save count
  2257.     CALL    REV0        ;back up in ring and on screen (no print)
  2258.     POP    B        ;get count
  2259.     BJNZ    UP1
  2260.     BR    DOWN1A
  2261. UP2:
  2262.     LHLD    RINGPOS        ;advance to beyond end
  2263.     LXI    D,13*4
  2264.     DAD    D
  2265.     XCHG
  2266.     LHLD    LOCEND        ;compare to local end
  2267.     XCHG
  2268.     CALL    CMPDEHL
  2269.     BRZ    DOWN1A        ;at end, so too far
  2270.     BRC    DOWN1A        ;beyond end, so back up
  2271.     SHLD    RINGPOS        ;new ring position
  2272.     LHLD    CURAT        ;advance cursor
  2273.     INR    H        ;next line
  2274.     SHLD    CURAT
  2275.     BR    UP2
  2276.  
  2277. ;
  2278. ; COMMAND: Down-Arrow
  2279. ;
  2280. DOWN:
  2281.     CALL    CLRCUR        ;clear cursor
  2282.     LHLD    RINGPOS        ;see if wrap around
  2283.     LXI    D,13*4        ;4 entries
  2284.     DAD    D
  2285.     XCHG
  2286.     LHLD    LOCEND        ;end of local screen
  2287.     XCHG
  2288.     CALL    CMPDEHL
  2289.     BRZ    DOWN2        ;wrap around
  2290.     BRC    DOWN2        ;wrap around
  2291.     MVI    B,4        ;forward 4 entries
  2292. DOWN1:
  2293.     PUSH    B        ;save count
  2294.     CALL    FOR0        ;advance in ring and on screen (no print)
  2295.     POP    B        ;get count
  2296.     BJNZ    DOWN1
  2297. DOWN1A:
  2298.     CALL    SETCUR        ;set cursor
  2299.     JMP    LOOPFN
  2300. DOWN2:
  2301.     LHLD    CURAT        ;preserve column
  2302.     MOV    B,L        ;column number in B
  2303.     LXI    H,CURHOME    ;home position
  2304.     SHLD    CURAT        ;set new position
  2305.     LHLD    LOCBEG        ;beginning of local ring
  2306.     SHLD    RINGPOS        ;new ring position
  2307. DOWN3:
  2308.     LHLD    CURAT        ;check for at top of column
  2309.     MOV    A,L        ;get col
  2310.     CMP    B        ;there?
  2311.     BRZ    DOWN1A
  2312.     LHLD    RINGPOS        ;advance in ring
  2313.     LXI    D,13        ;13 bytes/entry
  2314.     DAD    D
  2315.     SHLD    RINGPOS
  2316.     LHLD    CURAT        ;get cursor position
  2317.     LXI    D,19        ;advance 19 bytes/screen entry
  2318.     DAD    D
  2319.     SHLD    CURAT
  2320.     BR    DOWN3
  2321.  
  2322. ;
  2323. ; COMMAND: S
  2324. ;
  2325. ; Determine remaining storage on requested disk
  2326. ;
  2327. DSTAT:
  2328.     CALL    CPRMPT
  2329.     DB    'Status of Disk (Letter): ',0
  2330.     CALL    KEYIN        ;get char
  2331.     PUSH    PSW
  2332.     CALL    CRLF
  2333.     POP    PSW
  2334.     SUI    'A'        ;convert to number
  2335.     JC    LOOP
  2336.     MOV    B,A        ;... in B
  2337.     LDA    MAXDR        ;compare to max
  2338.     SUI    'A'
  2339.     CMP    B
  2340.     JC    LOOPFN
  2341.     MOV    A,B        ;get disk
  2342.     STA    R$DR        ;requested drive
  2343.     CALL    RESET        ;..login as current.
  2344.     CALL    FRESTOR        ;determine free space remaining
  2345.     CALL    PRINT$FRE    ;print value
  2346.     LDA    C$DR        ;login original as..
  2347.     CALL    SET$DR        ;..current drive.
  2348.     JMP    LOOPFN
  2349.  
  2350. ;
  2351. ; COMMAND: GD
  2352. ;
  2353. MASS$DEL:
  2354.     MOV    A,B        ;<RID> recover the opcode
  2355.     STA    MASSOP        ;<RID> need it later
  2356.     CALL    CPRMPT
  2357.     DB    'Mass Delete (Y/N/V=Verify)? ',0
  2358.     CALL    KEYIN        ;get response
  2359.     CPI    'Y'
  2360.     BRZ    MD1
  2361.     CPI    'V'
  2362.     JNZ    LOOP        ;return to position
  2363. MD1:
  2364.     STA    MDFLG        ;set flag
  2365. ;<RID>    STA    MASSOP    
  2366.     JMP    MASS$RUN
  2367.  
  2368. ;
  2369. ; COMMAND: D
  2370. ;
  2371. FDEL:
  2372.     XRA    A        ;set no mass operation
  2373.     STA    MFLAG
  2374.     CALL    DELETE        ;delete file
  2375. ;
  2376. ;  Was Deletion Done?  Abort if Not
  2377. ;
  2378.     LDA    DELCODE        ;0=not done
  2379.     ORA    A
  2380.     JZ    LOOPFN        ;abort if not
  2381. ;
  2382. ;  Reset Local Display
  2383. ;
  2384.     LHLD    LOCEND        ;move in end
  2385.     LXI    D,-13
  2386.     DAD    D
  2387.     SHLD    LOCEND
  2388.     XCHG
  2389.     LHLD    RINGPOS        ;position beyond end of ring?
  2390.     CALL    CMPDEHL
  2391.     BRNZ    FDEL1
  2392. ;
  2393. ;  Cursor Beyond End of Display
  2394. ;
  2395.     CALL    CUR$BACK    ;back up cursor
  2396.     LHLD    LOCEND        ;reset position
  2397.     LXI    D,-13
  2398.     DAD    D
  2399.     SHLD    RINGPOS
  2400. FDEL1:
  2401.     LHLD    LOCEND        ;get local end
  2402.     XCHG            ;... in DE
  2403.     LHLD    LOCBEG        ;erased all local files?
  2404.     CALL    CMPDEHL
  2405.     JZ    CMDLOOP        ;reset
  2406.     JMP    JFW0A        ;rescreen from LOCBEG
  2407.  
  2408. ;
  2409. ;  Delete filename at RINGPOS
  2410. ;
  2411. DELETE:
  2412.     XRA    A
  2413.     STA    DELCODE        ;set deletion not done
  2414.     CALL    RINGFCB        ;get file name
  2415.     LDA    MFLAG        ;mass operation?
  2416.     ORA    A        ;0=no
  2417.     BRZ    DEL1A        ;do delete with message <JPS>
  2418. ;
  2419. ;  Test for Verify on Mass Delete
  2420. ;
  2421.     LDA    MDFLG        ;verify?
  2422.     CPI    'V'
  2423.     BRNZ    DEL1        ;delete without verify
  2424. ;
  2425. ;  Verify and Delete only if Approved
  2426. ;
  2427.     CALL    CPRMPT
  2428.     DB    'Delete ',0
  2429.     CALL    PRFNS        ;print file name in S$FCB
  2430.     CALL    VPRINT
  2431.     DB    ' (Y/N)? ',0
  2432.     CALL    KEYIN
  2433.     CPI    'Y'
  2434.     RNZ            ;abort if not approved
  2435. ;
  2436. ; Delete File (Mass Operation)
  2437. ;
  2438. DEL1:
  2439.     LDA    MDFLG        ;mass operation - verify on?
  2440.     CPI    'V'
  2441.     BRZ    DEL2
  2442. DEL1A:    CALL    ERMSG        ;print information for mass del w/o verify
  2443.     DB    'Deleting File ',0
  2444.     CALL    PRFNS
  2445. ;
  2446. ;  Delete File in S$FCB
  2447. ;
  2448. DEL2:
  2449.     LXI    H,S$FCB        ;set file to R/W
  2450.     CALL    ATTRIB
  2451.     RZ            ;abort
  2452.     LXI    D,S$FCB        ;point at delete 'fcb'
  2453.     MVI    C,ERASE        ;erase function
  2454.     CALL    BDOS
  2455.     INR    A
  2456.     BRNZ    DELCL        ;close up erased position
  2457. FNF$MSG:
  2458.     CALL    FNF1        ;show error message
  2459.     JMP    LOOPFN
  2460.  
  2461. ;
  2462. ; Close up erased position
  2463. ;
  2464. DELCL:
  2465.     MVI    A,0FFH
  2466.     STA    DELCODE        ;set deletion done
  2467.     LHLD    RINGPOS        ;prepare move up pointers
  2468.     PUSH    H
  2469.     LXI    D,13        ;13 bytes/entry
  2470.     DAD    D        ;de-pair = 'to' location
  2471.     POP    D        ;hl-pair = 'from' location
  2472. ;
  2473. ;  Move 13-byte ring entries from HL to DE
  2474. ;
  2475. MOVUP:
  2476.     XCHG            ;HL=dest
  2477.     PUSH    H        ;check if at end
  2478.     LHLD    RINGEND        ;get old end pointer
  2479.     CALL    CMPDEHL        ;check against current end location
  2480.     POP    H
  2481.     XCHG            ;DE=dest
  2482.     BRZ    MOVDONE        ;must be at end of ring
  2483.     MVI    B,13        ;one name size
  2484.     CALL    MOVE        ;move one name up
  2485.     BR    MOVUP        ;go check end parameters
  2486. ;
  2487. ;  Move Complete
  2488. ;
  2489. MOVDONE:
  2490.     LHLD    RING        ;see if ring is empty
  2491.     XCHG
  2492.     SHLD    RINGEND        ;set new ring end if all moved
  2493.     CALL    CMPDEHL        ;..(listend --> listpos --> ring)
  2494.     RNZ
  2495.     CALL    ERMSG
  2496.     DB    'List Empty',0
  2497.     JMP    RUNSH3        ;go to drive/user area with files
  2498.  
  2499. ;
  2500. ; COMMAND: R
  2501. ;
  2502. ; Set-up to rename file at cursor position -- scan keyboard buffer and
  2503. ; move filename to destination FCB (DFCB)
  2504. ;
  2505. RENAME:
  2506.     LHLD    RINGPOS        ;move name from ring to rename 'fcb'
  2507.     LXI    D,D$FCB        ;place to move name
  2508.     MVI    B,12        ;amount to move
  2509.     CALL    MOVE
  2510.     CALL    CPRMPT        ;new name prompt
  2511.     DB    'Rename File to: ',0
  2512.     LXI    D,D$FCB+16    ;pt to FCB to fill
  2513.     CALL    FILENAME    ;get file name
  2514.     LXI    H,D$FCB+1    ;check for any wild cards -- none permitted
  2515.     MVI    B,11        ;11 bytes
  2516. WILDCHK:
  2517.     MOV    A,M        ;get char
  2518.     INX    H        ;pt to next
  2519.     CPI    '?'        ;wild?
  2520.     BRZ    WILDFND
  2521.     BJNZ    WILDCHK
  2522.  
  2523. ; copy old file status bit ($r/o or $sys) to new filename
  2524.  
  2525. CPYBITS:
  2526.     LXI    D,D$FCB+1    ;first character of old name..
  2527.     LXI    H,D$FCB+17    ;..and of new name.
  2528.     MVI    B,11        ; # of bytes with tag bits
  2529. CBITS1:
  2530.     LDAX    D        ;fetch bit of old name character
  2531.     ANI    80H        ;strip upper bit and..
  2532.     MOV    C,A        ;..save in c-reg.
  2533.     MVI    A,7FH        ;mask for character only
  2534.     ANA    M        ;put masked character into a-reg
  2535.     ORA    C        ;add old bit
  2536.     MOV    M,A        ;copy new byte back
  2537.     INX    H        ;bump copy pointers
  2538.     INX    D
  2539.     BJNZ    CBITS1        ;DJNZ
  2540.  
  2541. ; check if new filename already exists.  if so, say so.  then go
  2542. ; to command loop without moving ring position
  2543.  
  2544.     LDA    D$FCB        ;copy new name to source 'fcb'
  2545.     STA    S$FCB
  2546.     MVI    B,11
  2547.     LXI    H,D$FCB+17    ;copy new name to..
  2548.     LXI    D,S$FCB+1    ;..source 'fcb' for existence check.
  2549.     CALL    MOVE
  2550.     LXI    H,S$FCB+12    ;clear 'fcb' system..
  2551.     CALL    INITFCB        ;..fields.
  2552.     LXI    D,S$FCB        ;search to see if this file exists
  2553.     MVI    C,SRCHF        ;search first function
  2554.     CALL    BDOS
  2555.     INR    A        ; 0ffh --> 00h if file not found
  2556.     BRZ    RENFILE        ;to rename, if duplicate doesn't exists.
  2557.     CALL    ERMSG        ;announce the situation
  2558.     DB    'File Already Exists',0
  2559.     JMP    COMCAN        ;try again?
  2560.  
  2561. ; wild char found in file name -- error
  2562.  
  2563. WILDFND:
  2564.     CALL    ERMSG
  2565.     DB    'AFN NOT Allowed',0
  2566.     JMP    COMCAN
  2567.  
  2568. ; copy new name into ring position
  2569.  
  2570. RENFILE:
  2571.         ;following not needed with full screen refresh
  2572. ;<JPS>    LHLD    RINGPOS        ;get ring position pointer
  2573. ;<JPS>    INX    H        ;pt to name
  2574. ;<JPS>    PUSH    H        ;save ptr
  2575. ;<JPS>    XCHG
  2576. ;<JPS>    LXI    H,D$FCB+17    ;point at new name and..
  2577. ;<JPS>    MVI    B,11
  2578. ;<JPS>    CALL    MOVE        ;..move.
  2579. ;<JPS>    LHLD    CURAT        ;get current position on screen
  2580. ;<JPS>    LXI    D,4        ;advance 4 chars
  2581. ;<JPS>    DAD    D
  2582. ;<JPS>    CALL    GOTOXY
  2583. ;<JPS>    POP    H        ;get ptr
  2584. ;<JPS>    CALL    PRFN        ;print file name
  2585. ;<JPS>    MOV    A,M        ;print tag
  2586. ;<JPS>    CALL    COUT
  2587.     LXI    D,D$FCB        ;rename 'fcb' location
  2588.     MVI    C,REN        ;rename function
  2589.     CALL    BDOS
  2590.     INR    A        ; 0ffh --> 00h if rename error
  2591. ;<JPS>    JNZ    LOOP        ;if okay, proceed, else..
  2592. ;<JPS>    JMP    FNF$MSG        ;..show no-file msg.
  2593.     JZ    FNF$MSG        ;if error, report it <JPS>
  2594.     JMP    RUNSH2        ;start over <JPS>
  2595.  
  2596. ; get file name from user and process into FCB pted to by DE
  2597. FILENAME:
  2598.     PUSH    D        ;save ptr
  2599.     LHLD    CMDBUF        ;command line location
  2600.     XCHG
  2601.     MVI    C,RDBUF        ;console read-buffer function
  2602.     CALL    BDOS
  2603.     CALL    CONVERT        ;capitalize alpha
  2604.     POP    H        ;set to null drive
  2605.     MVI    M,0        ;..required by 'bdos'.
  2606.     INX    H
  2607.  
  2608. ; initialize new filename field with spaces
  2609.  
  2610.     PUSH    H        ;save start pointer
  2611.     MVI    B,11        ; # of spaces to 'blank'
  2612.     CALL    FILL
  2613.     POP    H
  2614.     XCHG
  2615.     LHLD    CMDBUF        ;put length..
  2616.     INX    H
  2617.     MOV    C,M        ;..in c-reg.
  2618.     INX    H
  2619.     XCHG            ;de-pair --> buffer pointer and hl-pair..
  2620.     CALL    UNSPACE        ;..--> 'fcb' pointer.  remove leading spaces.
  2621.  
  2622. ; extend buffer to spaces beyond command length
  2623.  
  2624. EXTEND:
  2625.     PUSH    H
  2626.     MOV    L,C        ;double-byte remaining length
  2627.     MVI    H,0
  2628.     DAD    D        ;to buffer end +1
  2629.     MVI    M,' '        ;force illegal character end
  2630.     POP    H
  2631.  
  2632. ; start filename scan
  2633.  
  2634. SCAN:
  2635.     MVI    B,8        ; 8 characters in filename
  2636. SCAN1:
  2637.     CALL    CKLEGAL        ;get and see if legal character
  2638.     JC    COMCAN        ;all of command line?
  2639.     CPI    ' '        ;see if end of parameter field
  2640.     RZ            ;rename file
  2641.     CPI    '.'        ;at end of filename
  2642.     BRZ    SCAN2        ;process filetype field
  2643.     CPI    '*'        ;rest wild?
  2644.     BRZ    SCAN1B
  2645.     MOV    M,A        ;put character into destination 'fcb'
  2646.     INX    H
  2647.     BJNZ    SCAN1
  2648.  
  2649. ; entry if eight characters without a 'period'
  2650.  
  2651. SCAN1A:
  2652.     CALL    CKLEGAL        ;scan buffer up to period or end
  2653.     RC            ;no extent if not legal
  2654.     CPI    ' '        ;end of parameter field?
  2655.     RZ
  2656.     CPI    '.'
  2657.     BRNZ    SCAN1A        ;do till end or period
  2658.     BR    SCAN2A        ;continue at correct place
  2659.  
  2660. ; make rest of entry wild
  2661.  
  2662. SCAN1B:
  2663.     MVI    M,'?'        ;fill with ?'s
  2664.     INX    H
  2665.     BJNZ    SCAN1B
  2666.     LDAX    D        ;get next char
  2667.     INX    D        ;pt to after dot
  2668.     CPI    '.'        ;must be dot
  2669.     JNZ    COMCAN        ;cancel if not
  2670.     BR    SCAN2A
  2671.  
  2672. ; build filetype field
  2673.  
  2674. SCAN2:
  2675.     INX    H        ;advance ptr to file type field
  2676.     BJNZ    SCAN2
  2677. SCAN2A:
  2678.     MVI    B,3        ;length of filetype field
  2679. SCAN3:
  2680.     CALL    CKLEGAL        ;get and check character
  2681.     BRC    SCAN4        ;name done if illegal
  2682.     CPI    ' '        ;end of parameter field?
  2683.     BRZ    SCAN4
  2684.     CPI    '.'        ;check if another period
  2685.     BRZ    SCAN4
  2686.     CPI    '*'        ;rest wild?
  2687.     BRZ    SCAN4B
  2688.     MOV    M,A
  2689.     INX    H
  2690.     BJNZ    SCAN3        ;get next character
  2691.     BR    SCAN4A
  2692. SCAN4:
  2693.     INX    H        ;advance to end of type field
  2694.     BJNZ    SCAN4
  2695. SCAN4A:
  2696.     CALL    INITFCB        ;..and zero counter fields.
  2697.     RET
  2698. SCAN4B:
  2699.     MVI    M,'?'        ;make wild
  2700.     INX    H
  2701.     BJNZ    SCAN4B
  2702.     BR    SCAN4A        ;complete rest
  2703.  
  2704. ;
  2705. ; COMMAND: J
  2706. ;
  2707. GOTO:
  2708.     CALL    CPRMPT
  2709.     DB    'Jump to Filename: ',0
  2710.     LXI    D,D$FCB        ;pt to FCB
  2711.     CALL    FILENAME    ;get file name
  2712.     LHLD    RING        ;pt to first element of ring
  2713.     SHLD    RINGPOS        ;set position
  2714.     SHLD    LOCBEG        ;set local beginning
  2715.     PUSH    H
  2716.     LHLD    CRCTBL        ;pt to CRC Table
  2717.     MVI    M,0        ;set local counter
  2718.     POP    H
  2719. GOTOL:
  2720.     CALL    GOTOCOMP    ;compare
  2721.     BRZ    GOTOF        ;we are there
  2722.     PUSH    H
  2723.     LHLD    CRCTBL        ;pt to table
  2724.     INR    M
  2725.     MOV    A,M
  2726.     POP    H
  2727.     CPI    EPS
  2728.     BRNZ    GOTOL1
  2729.     LHLD    CRCTBL        ;zero first entry
  2730.     MVI    M,0
  2731.     LHLD    LOCBEG        ;reset local beginning
  2732.     LXI    D,EPS*13
  2733.     DAD    D
  2734.     SHLD    LOCBEG
  2735. GOTOL1:
  2736.     LHLD    RINGPOS        ;advance to next entry
  2737.     LXI    D,13
  2738.     DAD    D
  2739.     SHLD    RINGPOS        ;new position
  2740.     XCHG            ;position in DE
  2741.     LHLD    RINGEND        ;check for completion
  2742.     CALL    CMPDEHL        ;compare current position with end of ring
  2743.     BRNZ    GOTOL
  2744.     LHLD    RING        ;pt to first element
  2745.     SHLD    RINGPOS        ;set position
  2746.     CALL    FNF1        ;print message
  2747.     JMP    CMDLOOP
  2748. GOTOF:
  2749.     LHLD    LOCBEG        ;we have local beginning
  2750.     PUSH    H
  2751.     XCHG            ;ring location in DE
  2752.     LXI    H,CURHOME    ;set cursor ptr
  2753.     SHLD    CURAT
  2754. GOTOF0:
  2755.     LHLD    RINGPOS        ;at position?
  2756.     CALL    CMPDEHL
  2757.     BRZ    GOTOF1
  2758.     LXI    H,13        ;advance location
  2759.     DAD    D
  2760.     PUSH    H
  2761.     CALL    CUR$NEXT    ;advance cursor
  2762.     POP    D        ;pt to next ring position
  2763.     BR    GOTOF0
  2764. GOTOF1:
  2765.     POP    H        ;pt to local ring
  2766.     JMP    JFW0A        ;process
  2767. GOTOCOMP:
  2768.     LHLD    RINGPOS        ;pt to current entry
  2769.     INX    H        ;pt to first char of file name
  2770.     LXI    D,D$FCB+1    ;pt to first char of new file
  2771.     MVI    B,11        ;11 bytes
  2772. GOTOC1:
  2773.     LDAX    D        ;get char
  2774.     CPI    '?'        ;match?
  2775.     BRZ    GOTOC2
  2776.     CMP    M        ;match?
  2777.     RNZ            ;no match
  2778. GOTOC2:
  2779.     INX    D        ;pt to next
  2780.     INX    H
  2781.     BJNZ    GOTOC1
  2782.     RET
  2783.  
  2784. ;
  2785. ; COMMAND: V
  2786. ;
  2787. ; Type file to console with pagination set to 'lps' -- single-line scroll
  2788. ; using <space> bar , <ctrl-x> to cancel, any other key to page screen.
  2789. ;
  2790. VIEW:
  2791.     CALL    VIEWFL        ;<RID>
  2792.     JMP    RUNSH4        ;<RID>
  2793.  
  2794. VIEWFL:                ;<RID>
  2795.     CALL    VCLS
  2796.     CALL    VPRINT
  2797.     DB    CR,LF,DIM,'<CTRL-C> Cancels, <SP> Turns Up One Line, '
  2798.     DB    'Other Keys Page Screen',BRIGHT,CR,LF,LF,0
  2799.     MVI    A,1        ;initialize..
  2800.     STA    LPSCNT        ;..lines-per-screen counter.
  2801.     STA    VIEWFLG        ; 'view' paginate if not zero
  2802.     MVI    A,WRCON        ;write console out function
  2803.     BR    CURRENT        ;to common i/o processing
  2804. ;
  2805. ; COMMAND: P
  2806. ;
  2807. ; Send file to logical list device -- any keypress cancels
  2808. ;
  2809. SPRINT:                ;<RID>
  2810. ;
  2811. ;<RID> Set Flags for First Time Thru and No Mass Print
  2812. ;                
  2813.     XRA    A        ;<RID> A=0
  2814.     STA    FIRST$M        ;<RID> set for prompt for destination
  2815. ;
  2816. ;<RID>  Do Print
  2817. ;
  2818.     CALL    LSTFILE        ;<RID> print file at RINGPOS
  2819. ;
  2820. ;<RID>  Advance to Next File
  2821. ;
  2822.     JMP    RUNSH4        ;<RID> refresh screen and reset stack
  2823. ;
  2824. ;
  2825. LSTFILE:
  2826.     LDA    FIRST$M        ;<RID> by-pass prompt.
  2827.     ORA    A        ;<RID>
  2828.     BRNZ    SKPPRMT        ;<RID>..1st time thru in mass-print mode.
  2829.     DCR    A        ;<RID> A=0FFH
  2830.     STA    FIRST$M        ;<RID> set not first time any more
  2831.     CALL    CPRMPT
  2832.     DB    'Print on LST Device (Y/N)? ',0
  2833.     CALL    KEYIN        ;get response
  2834.     CPI    'Y'
  2835.     JNZ    LOOP
  2836. SKPPRMT:            ;<RID>
  2837.     CALL    ERMSG
  2838.     DB    'Printing ',0
  2839.     LHLD    RINGPOS        ;pt to file name
  2840.     INX    H
  2841.     CALL    PRFN        ;print it
  2842.     MVI    A,1        ;one for..
  2843.     STA    VIEWFLG        ;..output to printer.
  2844.     DCR    A        ;zero for..
  2845.     STA    LPSCNT        ;..lines-per-page counter
  2846.     STA    EOFLAG        ;<RID> used to provide formfeed at end of file
  2847.     MVI    A,LIST        ;out to 'list' device function and fall thru
  2848.  
  2849. ; output character for console/list/punch processing
  2850.  
  2851. CURRENT:
  2852.     STA    CON$LST        ;save bdos function
  2853.  
  2854. ; output file to console/printer/punch
  2855.  
  2856.     CALL    RINGFCB        ;position name to 'fcb'
  2857.     XCHG            ;HL pts to S$FCB
  2858.     CALL    INITFCB        ;set 'fcb' for use
  2859.     LXI    D,TBUF        ;set to use default dma buffer
  2860.     MVI    C,SETDMA    ;address set function
  2861.     CALL    BDOS
  2862.     LXI    D,S$FCB        ;open file for reading
  2863.     MVI    C,OPEN        ;file open function code
  2864.     CALL    BDOS
  2865.     INR    A        ; 0ffh --> 00h if open not okay
  2866.     BRNZ    ZEROCR        ;if not okay, show error message.
  2867. ;
  2868. ;  File Not Found Error
  2869. ;
  2870. FNF:
  2871.     CALL    FNF1        ;print file not found message
  2872.     JMP    LOOP
  2873. ;
  2874. ;  Print File Not Found Message
  2875. ;
  2876. FNF1:
  2877.     CALL    ERMSG
  2878.     DB    'File NOT Found',0
  2879.     RET
  2880. ;
  2881. ; Continue
  2882. ;
  2883. ZEROCR:
  2884.     XRA    A
  2885.     STA    S$FCB+32    ;zero file 'current record' field
  2886.     STA    CHARCNT        ;zero char count for tabbing
  2887.     CALL    PHEAD        ;print heading if output to LST device
  2888. READMR:
  2889.     LXI    D,S$FCB        ;point at file 'fcb' for reading
  2890.     MVI    C,READ        ;record read function
  2891.     CALL    BDOS
  2892.     ORA    A        ;check if read okay
  2893.     BRNZ    CURDONE        ;eof?
  2894.     LXI    H,TBUF        ;point at record just read
  2895.     MVI    B,128        ;set record character counter to output
  2896. READLP:
  2897.     MOV    A,M        ;get a character
  2898.     ANI    7FH        ;force to 'ascii'
  2899.     CPI    EOFCHAR        ;see if end-of-file
  2900.     BRZ    CURDONE        ;back to ring loop if 'eof'
  2901.     MOV    E,A        ;put character for 'bdos' call
  2902.     PUSH    B
  2903.     PUSH    H
  2904.     PUSH    D        ; (character in e-reg)
  2905.     LDA    CON$LST        ;get function for punch/list/console output
  2906.     MOV    C,A
  2907.     MOV    A,E        ;check char
  2908.     CPI    TAB        ;tabulate?
  2909.     BRNZ    NOTAB
  2910.     MVI    E,' '        ;space over
  2911. TABL:
  2912.     PUSH    B        ;save key regs
  2913.     PUSH    D
  2914.     CALL    BDOS
  2915.     POP    D        ;get key regs
  2916.     POP    B
  2917.     CALL    INCCCNT        ;increment char count
  2918.     ANI    7        ;check for done at every 8
  2919.     BRNZ    TABL
  2920.     BR    TABDN
  2921. NOTAB:
  2922.     CALL    BDOS        ;send character
  2923.     CALL    INCCCNT        ;increment char count
  2924. TABDN:
  2925.     LDA    VIEWFLG        ;if 'view'..
  2926.     ORA    A
  2927.     POP    D        ;get char in E in case PAGER is called
  2928.     CNZ    PAGER        ;..check for 'lf'.
  2929.     MVI    E,GET        ;get status or char
  2930.     MVI    C,DIRCON    ;console status function
  2931.     CALL    BDOS        ;status?
  2932.     POP    H
  2933.     POP    B
  2934.     ANI    7FH        ;if character there, then abort..
  2935.     CNZ    CANVIEW        ;already got char
  2936.     INX    H        ;if not, bump buffer pointer.
  2937.     BJNZ    READLP        ;no, more in present record.
  2938.     BR    READMR        ;yes, get next record.
  2939. CURDONE:
  2940.     MVI    A,TRUE        ;<RID> set eoflag for formfeed at end of file
  2941.     STA    EOFLAG        ;<RID>
  2942.     LDA    CON$LST        ;console?
  2943.     CPI    WRCON
  2944.     JZ    BOTTOM        ;<RID> prompt for user
  2945.     JMP    FORMFD        ;<RID>
  2946. ;<RID>    JMP    RUNSH4        ;refresh screen and continue user input
  2947.  
  2948. PAGER:
  2949.     MOV    A,E        ; (character in e-reg)
  2950.     CPI    LF
  2951.     RNZ
  2952.     XRA    A        ;zero char count
  2953.     STA    CHARCNT
  2954.     LDA    CON$LST        ;printer or console?
  2955.     CPI    LIST        ;check for printer
  2956.     BRZ    PAGEP
  2957.     LDA    CTPP        ;get number of lines of text per screen
  2958.     MOV    B,A        ;... in B
  2959.     LDA    LPSCNT        ;is counter..
  2960.     INR    A        ;..at..
  2961.     STA    LPSCNT        ;..limit..
  2962.     CMP    B        ;..of lines-per-screen?
  2963.     RC            ;no, return.
  2964.     XRA    A        ;yes, initialize..
  2965.     STA    LPSCNT        ;..for next screen full.
  2966.     CALL    VPRINT
  2967.     DB    '  ',DIM,'[View More...]',BRIGHT,CR,0    ;show msg line
  2968.     CALL    DKEYIN        ;wait for keyboard input
  2969.     CPI    ' '        ;see if <space> bar..
  2970.     PUSH    PSW
  2971.     CALL    VPRINT
  2972.     DB    '                ',CR,0    ;clear above msg line
  2973.     POP    PSW
  2974.     BRNZ    CANVIEW        ;..if not, see if cancel.
  2975.     LDA    CTPP        ;set for single line
  2976.     DCR    A
  2977.     STA    LPSCNT        ;..scroll and..
  2978.     RET            ;..return for one more line.
  2979.  
  2980. PAGEP:
  2981.     LDA    LTPP        ;get number of lines of text per page
  2982.     MOV    B,A        ;... in B
  2983.     LDA    LPSCNT        ;is counter..
  2984.     INR    A        ;..at..
  2985.     STA    LPSCNT        ;..limit..
  2986.     CMP    B        ;..of lines-per-screen?
  2987.     RC            ;no, return.
  2988. FORMFD:    XRA    A        ;<RID> zero for..
  2989.     STA    LPSCNT        ;..lines-per-page counter
  2990.     LDA    LFFEED        ;form feed available?
  2991.     ORA    A        ;0=no
  2992.     JZ    PRFEED
  2993.     CALL    LCRLF        ;new line
  2994.     MVI    A,FF        ;send form feed char
  2995.     CALL    LOUT
  2996.     LDA    EOFLAG        ;<RID> if true then output final formfeed
  2997.     ORA    A        ;<RID>    
  2998.     RNZ            ;<RID> don't do heading if final formfeed
  2999.     JMP    PHEAD        ;print header and done
  3000. PRFEED:
  3001.     LDA    LSPP        ;number of lines to skip
  3002.     MOV    B,A        ;number of lines to skip
  3003.     MVI    C,LIST        ;LST output
  3004. PAGELST:
  3005.     CALL    LCRLF        ;new line on LST
  3006.     BJNZ    PAGELST
  3007.     JMP    PHEAD        ;print heading and done
  3008.  
  3009. CANVIEW:
  3010.     CPI    CTRLC        ;^C?
  3011.     JZ    COMCAN
  3012.     RET            ;return for another page
  3013.  
  3014. INCCCNT:
  3015.     LDA    CHARCNT        ;increment char count
  3016.     INR    A
  3017.     STA    CHARCNT
  3018.     RET
  3019.  
  3020. PHEAD:
  3021.     LDA    CON$LST        ;printing to printer?
  3022.     CPI    LIST
  3023.     RNZ
  3024.     LXI    H,HEADMSG    ;print heading
  3025. PHEAD1:
  3026.     MOV    A,M        ;get char
  3027.     ORA    A        ;done?
  3028.     BRZ    PHEAD2
  3029.     CALL    LOUT        ;send to printer
  3030.     INX    H        ;pt to next
  3031.     BR    PHEAD1
  3032. PHEAD2:
  3033.     LXI    H,S$FCB+1    ;pt to file name
  3034.     MVI    B,8        ;8 chars
  3035.     CALL    PHEAD3
  3036.     MVI    A,'.'        ;dot
  3037.     CALL    LOUT
  3038.     MVI    B,3        ;3 more chars
  3039.     CALL    PHEAD3
  3040.     CALL    LCRLF        ;new line
  3041.     CALL    LCRLF        ;blank line
  3042.     RET
  3043. PHEAD3:
  3044.     MOV    A,M        ;get char
  3045.     CALL    LOUT        ;LST it
  3046.     INX    H        ;pt to next
  3047.     BJNZ    PHEAD3
  3048.     RET
  3049.  
  3050. ;
  3051. ; COMMAND: GC
  3052. ;
  3053. ; Copy files tagged using the 't' command.  auto-erase if file exists
  3054. ; on requested destination drive or in user area.
  3055. ;
  3056. MASS$COPY:
  3057.     MOV    A,B        ;<RID> recover opcode
  3058.     STA    MASSOP        ;<RID>
  3059.     CALL    ERMSG
  3060.     DB    'Mass Copy',0
  3061. ;<RID>    XRA    A        ;A=0
  3062. ;<RID>    STA    MASSOP        ;set operation to mass copy
  3063. ;
  3064. ;  Main Entry Point for Mass Operation of Copy or Delete
  3065. ;    On entry, MASSOP = 0 if copy, 0FFH if delete
  3066. ;
  3067. MASS$RUN:
  3068.     LHLD    RINGPOS        ;save position
  3069.     SHLD    SRINGPOS
  3070.     LHLD    RING
  3071.     LXI    D,-13        ;back up to before first ring element
  3072.     DAD    D
  3073.     SHLD    RINGPOS        ;set position
  3074. ;
  3075. ;  Set Flags for First Time Thru and Mass Operation
  3076. ;
  3077.     XRA    A        ;A=0
  3078.     STA    FIRST$M        ;set for prompt for dest with first file
  3079.     DCR    A        ;A=0FFH
  3080.     STA    MFLAG        ;this is a mass operation
  3081. ;
  3082. ;  Main Mass Operation Loop
  3083. ;
  3084. MASS$OLP:
  3085.     LHLD    RINGPOS        ;re-entry point for next file
  3086.     LXI    D,13        ;advance to next
  3087.     DAD    D
  3088.     SHLD    RINGPOS
  3089.     XCHG            ;at ring..
  3090. ;
  3091. ;  Check for Loop Completion -- DE = Current RINGPOS
  3092. ;
  3093. MASS$OLP1:
  3094.     LHLD    RINGEND        ;..end yet?
  3095.     CALL    CMPDEHL        ;compare present position with end
  3096. ;    BRZ    MASS$OLX    ;done
  3097.     JZ    MASS$OLX    ;<JPS>
  3098. ;
  3099. ;  Check for Tagged File at RINGPOS
  3100. ;
  3101.     LHLD    RINGPOS        ;get position
  3102.     LXI    D,12        ;get 1st possible tag location
  3103.     DAD    D
  3104.     MOV    A,M        ;get tag
  3105.     CPI    TAGCH
  3106.     BRNZ    MASS$OLP    ;not tagged, so skip
  3107. ;
  3108. ;  Select Mass Operation
  3109. ;
  3110.     LDA    MASSOP        ;get type of mass operation
  3111. ;<RID>    ORA    A        ;0=COPY
  3112. ;<RID>    BRZ    MASS$OC        ;do copy
  3113.     CPI    'C'        ;<RID> check if copy
  3114.     BRZ    MASS$OC        ;<RID> yes its copy
  3115.     CPI    'P'        ;<RID> check if print
  3116.     BRZ    MASS$LST    ;<RID> yes its print
  3117.     CPI    'D'        ;<RID> check if delete
  3118.     BRZ    MDELETE        ;<RID> its delete
  3119.     CPI    'V'        ;<RID> check if view
  3120.     BRZ    MASS$FVIEW    ;<RID> its view
  3121.     CALL    ERMSG        ;<RID> should be one of above
  3122.     DB    'Illegal character',0    ;<RID>
  3123.     JMP    LOOP        ;<RID> get new comand
  3124.  
  3125. ;<RID>    COMMAND:    GP
  3126. ;
  3127. ;<RID> Print tagged files using the 't' command
  3128. ;
  3129.  
  3130. MASS$PRINT:            ;<RID>
  3131.     MOV    A,B        ;<RID> recover opcode
  3132.     STA    MASSOP        ;<RID>
  3133.     CALL    ERMSG        ;<RID>
  3134.     DB    'Mass Print',0    ;<RID>
  3135.     BR    MASS$RUN    ;<RID>
  3136.  
  3137. MASS$LST:            ;<RID>
  3138.     CALL    LSTFILE        ;<RID>
  3139.     BR    MASS$OLP    ;<RID> skip to next
  3140.  
  3141. ;<RID>    COMMAND:    GV
  3142. ;
  3143. ;<RID> View tagged files using the 't' command
  3144. ;
  3145.  
  3146. MASS$VIEW:            ;<RID>
  3147.     MOV    A,B        ;<RID> recover opcode
  3148.     STA    MASSOP        ;<RID>
  3149.     CALL    ERMSG        ;<RID>
  3150.     DB    'Mass View',0    ;<RID>
  3151. ;    BR    MASS$RUN    ;<RID>
  3152.     JMP    MASS$RUN    ;<JPS>
  3153.  
  3154. MASS$FVIEW:
  3155.     CALL    VIEWFL        ;<RID>
  3156.     BR    MASS$OLP    ;<RID>
  3157.  
  3158.  
  3159. ;  Do Mass Delete - Current File Delete
  3160. ;
  3161. MDELETE:            ;<RID>
  3162.     CALL    DELETE        ;delete filename at RINGPOS
  3163. ;
  3164. ;  Advance to Next File if Delete Aborted
  3165. ;
  3166.     LDA    DELCODE        ;deletion done?
  3167.     ORA    A        ;0=no
  3168. ;    BRZ    MASS$OLP    ;skip to next if not
  3169.     JZ    MASS$OLP    ;<JPS>
  3170. ;
  3171. ;  Stay at Current File if Delete Done - Ring was Compressed by Delete
  3172. ;
  3173.     LHLD    RINGPOS        ;get current ring position
  3174.     XCHG            ;... in DE (don't advance)
  3175. ;    BR    MASS$OLP1    ;loop until thru ring list
  3176.     JMP    MASS$OLP1    ;<JPS>
  3177. ;
  3178. ;  Do Mass Copy - Current File Copy
  3179. ;
  3180. MASS$OC:
  3181.     CALL    COPY        ;do copy
  3182. ;    BR    MASS$OLP    ;loop until thru ring list
  3183.     JMP    MASS$OLP    ;<JPS>
  3184. ;
  3185. ;  Exit Mass Operation Loop
  3186. ;
  3187. MASS$OLX:
  3188.     LHLD    SRINGPOS    ;reset ring position
  3189.     SHLD    RINGPOS
  3190.     LDA    MASSOP        ;<RID> (if delete, restart)
  3191. ;<RID>    ORA    A        ;NZ=delete
  3192. ;<RID>    JNZ    RUNSH2
  3193.     CPI    'D'        ;<RID> check if delete
  3194.     JZ    RUNSH2        ;<RID> else either print or copy
  3195.     LHLD    LOCBEG        ;copy, so reset local ring
  3196.     JMP    JFW0A        ;rescreen
  3197.  
  3198. ;
  3199. ; COMMAND: C
  3200. ;
  3201. ; Copy source file at current 'ring' position to another drive.  set-up
  3202. ; fcb's and buffer area and check for correct keyboard inputs.  contains
  3203. ; auto-crc file copy verification.
  3204. ;
  3205. FCOPY:
  3206. ;
  3207. ;  Set Flags for First Time Thru and No Mass Copy
  3208. ;
  3209.     XRA    A        ;A=0
  3210.     STA    FIRST$M        ;set for prompt for destination
  3211.     STA    MFLAG        ;not a mass copy
  3212. ;
  3213. ;  Do Copy
  3214. ;
  3215.     CALL    COPY        ;do copy of file at RINGPOS
  3216. ;
  3217. ;  Advance to Next File
  3218. ;
  3219.     JMP    FORWARD        ;advance to next file
  3220. ;
  3221. ;  Copy File at RINGPOS
  3222. ;
  3223. COPY:
  3224.     LXI    H,0        ;initialize storage for..
  3225.     SHLD    CRCVAL        ;..'crc' working value.
  3226.     CALL    RINGFCB        ;move from 'ring' to 'sfcb'
  3227.     LXI    H,S$FCB+12    ;set pointer to source extent field
  3228.     CALL    INITFCB
  3229.     MVI    B,32        ;copy source 'fcb' to destination 'fcb'
  3230.     LXI    H,S$FCB+1    ;from point..
  3231.     LXI    D,D$FCB+1    ;..to point..
  3232.     CALL    MOVE        ;..move across.
  3233.     LXI    D,S$FCB        ;open file for reading
  3234.     MVI    C,OPEN        ;open function
  3235.     CALL    BDOS
  3236.     INR    A        ; 0ffh --> 00h if bad open
  3237.     JZ    FNF        ;file not found
  3238. ;
  3239. ;  Source File is Open -- If first time thru, get dest dir
  3240. ;
  3241. COPY2:
  3242.     LDA    FIRST$M        ;by-pass prompt, drive/user compatibility..
  3243.     ORA    A        ;..test, and disk reset after..
  3244.     BRNZ    COPY3M        ;..1st time thru in mass-copy mode.
  3245.     DCR    A        ;A=0FFH
  3246.     STA    FIRST$M        ;set not first time any more
  3247.     CALL    CPRMPT        ;prompt for drive selection
  3248.     DB    'Copy to DIR: ',0
  3249.     CALL    DEF$D$U
  3250. ;
  3251. ; Check to ensure that either drives or user areas are different
  3252. ;
  3253.     LDA    FCB        ;get requested drive from 'fcb' and..
  3254.     MOV    B,A        ;..put into b-reg for..
  3255.     LDA    S$FCB        ;..comparison
  3256.     CMP    B
  3257.     BRNZ    COPY3        ;branch if different
  3258.     LDA    R$U$A        ;requested user area --> rua
  3259.     MOV    B,A
  3260.     LDA    C$U$A        ;current user area --> cua
  3261.     CMP    B
  3262.     BRNZ    COPY3
  3263.     CALL    ERMSG        ;if not, show error condition:
  3264.     DB    'Src DIR = Dest DIR',0
  3265.     JMP    LOOP        ;try again?
  3266. ;
  3267. ;  First File Copy - Reset System
  3268. ;
  3269. COPY3:
  3270.     CALL    RESET        ;make sure disk is read/write
  3271.     CALL    DLOGIN        ;return home
  3272. ;
  3273. ;  Nth File Copy - Copy without Resetting System
  3274. ;
  3275. COPY3M:
  3276.     LDA    FCB        ;put requested drive into..
  3277.     STA    D$FCB        ;..place in destination fcb (used to log in)
  3278.     LDA    R$U$A        ;toggle to..
  3279.     CALL    SET$USR        ;..requested user area.
  3280.     LXI    D,D$FCB        ;search for duplicate
  3281.     MVI    C,SRCHF        ; 'search first' function
  3282.     CALL    BDOS
  3283.     INR    A        ;if not found, 0ffh --> 00h.  then..
  3284.     BRZ    COPY5        ;go to 'make' function for new file.
  3285.     LDA    MFLAG        ;auto-erase..
  3286.     ORA    A        ;..if..
  3287.     BRZ    COPY4M        ;..in mass-copy mode.
  3288.     CALL    ERMSG        ;If found, ask to replace:
  3289.     DB    0
  3290.     LXI    H,D$FCB+1
  3291.     CALL    PRFN
  3292.     CALL    VPRINT
  3293.     DB    ' Exists on Dest -- Erase (Y/N)? ',0
  3294.     CALL    KEYIN        ;get answer
  3295.     CPI    'Y'        ;if yes, then delete and copy ...
  3296.     BRZ    COPY4M        ;... else fall thru to CUA$LOG and exit
  3297. ;
  3298. ;  Log into Current User Area
  3299. ;
  3300. CUA$LOG:
  3301.     LDA    C$U$A        ;reset to current user area
  3302.     JMP    SET$USR        ;set user and return to caller
  3303.  
  3304. ;
  3305. ;  Erase destination file and proceed
  3306. ;
  3307. COPY4M:
  3308. ;
  3309. ;  Set File Attributes
  3310. ;
  3311.     LXI    H,D$FCB        ;pt to FCB
  3312.     CALL    ATTRIB        ;clear bytes in FCB and set attr of file
  3313.     BRZ    CUA$LOG        ;return to caller if R/W not permitted
  3314. ;
  3315. ;  Delete old file at dest
  3316. ;
  3317.     LXI    D,D$FCB        ;delete file already existing
  3318.     MVI    C,ERASE        ;erase function
  3319.     CALL    BDOS
  3320. ;
  3321. ;  Create new file at dest
  3322. ;
  3323. COPY5:
  3324.     LXI    D,D$FCB        ;create new file and open for writing
  3325.     MVI    C,MAKE        ;make function
  3326.     CALL    BDOS
  3327.     INR    A        ;if directory full, 0ffh --> 00h.
  3328.     BRNZ    COPY6        ;if not, branch.
  3329.     CALL    ERMSG
  3330.     DB    'Dest Dir Full',0
  3331.     JMP    LOOPFN        ;if error, back to ring processor.
  3332. ;
  3333. ;  Perform Copy
  3334. ;
  3335. COPY6:
  3336.     CALL    CPRMPT
  3337.     DB    'Copying File ',0
  3338.     LXI    H,D$FCB+1    ;print file name
  3339.     CALL    PRFNSX
  3340.     CALL    VPRINT
  3341.     DB    ' to ',0
  3342.     LDA    D$FCB        ;print dest DU
  3343.     ADI    '@'
  3344.     CALL    COUT        ;print disk
  3345.     LDA    R$U$A        ;get user
  3346.     CALL    PAFDC        ;print user
  3347.     MVI    A,':'
  3348.     CALL    COUT
  3349.     XRA    A        ;clear 'eof'..
  3350.     STA    EOFLAG        ;..flag.
  3351. COPY6A:
  3352.     CALL    CUA$LOG        ;current user area
  3353.     LXI    H,0        ;clear current-record..
  3354.     SHLD    REC$CNT        ;..counter.
  3355.     LHLD    BUFSTART    ;set buffer start pointer..
  3356.     SHLD    BUF$PT        ;..to begin pointer.
  3357. ;
  3358. ; read source file -- fill buffer memory or stop on 'eof' -- update 'crc'
  3359. ; on-the-fly
  3360. ;
  3361. COPY7:
  3362.     LHLD    BUF$PT        ;set dma address to buffer pointer
  3363.     XCHG            ; de-pair --> dma address
  3364.     MVI    C,SETDMA
  3365.     CALL    BDOS
  3366.     LXI    D,S$FCB        ;source 'fcb' for reading
  3367.     MVI    C,READ        ;record read function
  3368.     CALL    BDOS
  3369.     ORA    A        ; 00h --> read okay
  3370.     BRZ    S$RD$OK
  3371.     DCR    A        ;eof?
  3372.     BRZ    COPY8        ;yes, end-of-file, set 'eof' flag.
  3373.     CALL    ERMSG
  3374.     DB    'Read Error',0
  3375.     JMP    LOOPFN
  3376. ;
  3377. ;  Read OK - Update CRC
  3378. ;
  3379. S$RD$OK:
  3380.     LHLD    BUF$PT
  3381.     MVI    B,128
  3382. COPY7A:
  3383.     MOV    A,M        ;get character and..
  3384.     CALL    UPDCRC        ;..add to 'crc' value.
  3385.     INX    H
  3386.     DCR    B
  3387.     BRNZ    COPY7A        ;loop 'till record read finished
  3388. ;
  3389. ;  Update Buffer Ptr and Record Count
  3390. ;
  3391.     LHLD    BUF$PT        ;bump buffer pointer..
  3392.     LXI    D,128        ;..by..
  3393.     DAD    D        ;..one..
  3394.     SHLD    BUF$PT        ;..record.
  3395.     LHLD    REC$CNT        ;bump buffer..
  3396.     INX    H        ;..record count and..
  3397.     SHLD    REC$CNT        ;..store.
  3398.     XCHG            ;ready to compare to..
  3399. ;
  3400. ;  Check for Full Buffer
  3401. ;
  3402.     LHLD    REC$MAX        ;..maximum record count (full-buffer).
  3403.     CALL    CMPDEHL        ;compare
  3404.     BRNZ    COPY7        ;if not full, get next record.
  3405.     BR    COPY9        ;full, start first write session.
  3406. ;
  3407. ; Indicate end-of-file read
  3408. ;
  3409. COPY8:
  3410.     MVI    A,TRUE        ;set 'eof' flag
  3411.     STA    EOFLAG
  3412. ;
  3413. ; Write source file from memory buffer to destination
  3414. ;
  3415. COPY9:
  3416.     LDA    R$U$A        ;set user to requested..
  3417.     CALL    SET$USR        ;..area.
  3418.     LHLD    BUFSTART    ;adjust buffer pointer..
  3419.     SHLD    BUF$PT        ;..to start address.
  3420. COPY10:
  3421.     LHLD    REC$CNT        ;buffer empty?
  3422.     MOV    A,H
  3423.     ORA    L
  3424.     BRZ    COPY11        ;buffer empty, check 'eof' flag.
  3425.     DCX    H        ;dec buffer record count for each write
  3426.     SHLD    REC$CNT
  3427.     LHLD    BUF$PT        ;set up dma address
  3428.     PUSH    H        ;save for size bump
  3429.     XCHG            ;pointer in de-pair
  3430.     MVI    C,SETDMA
  3431.     CALL    BDOS
  3432.     POP    H
  3433.     LXI    D,128        ;bump pointer one record length
  3434.     DAD    D
  3435.     SHLD    BUF$PT
  3436.     LXI    D,D$FCB        ;destination file 'fcb'
  3437.     MVI    C,WRITE        ;write record function
  3438.     CALL    BDOS
  3439.     ORA    A           ; 00h --> write okay
  3440.     BRZ    COPY10        ;okay, do next record.  else..
  3441.     CALL    ERMSG        ;..say disk write error.
  3442.     DB    'Copy Disk Full',0
  3443. ;
  3444. ;  Error in Write -- Delete Destination File and Abort
  3445. ;
  3446. C$ERA:
  3447.     LXI    D,D$FCB        ;delete..
  3448.     MVI    C,ERASE        ;..partial..
  3449.     CALL    BDOS        ;..from directory.
  3450.     JMP    LOOPFN        ;back to ring
  3451. ;
  3452. ;  Destination Buffer Written - Check for End
  3453. ;
  3454. COPY11:
  3455.     LDA    EOFLAG        ;buffer all written, check for 'eof'.
  3456.     ORA    A
  3457.     JZ    COPY6A        ;branch to read next buffer full
  3458.     LXI    D,D$FCB        ;point at 'fcb' for file closure
  3459.     MVI    C,CLOSE
  3460.     CALL    BDOS
  3461.     INR    A        ;if no-close-error then..
  3462.     BRNZ    CRC$CMP        ;..compare file crc's.
  3463.     CALL    ERMSG
  3464.     DB    'Copy Close Error',0
  3465.     JMP    C$ERA
  3466. ;
  3467. ; Read Destination File and Compare CRCs
  3468. ;
  3469. CRC$CMP:
  3470.     LHLD    CRCVAL        ;transfer 'crc' value to..
  3471.     SHLD    CRCVAL2        ;..new storage area.
  3472.     LXI    H,0        ;clear working storage..
  3473.     SHLD    CRCVAL        ;..to continue.
  3474.     LXI    D,TBUF
  3475.     MVI    C,SETDMA
  3476.     CALL    BDOS
  3477.     LXI    H,D$FCB+12
  3478.     CALL    INITFCB
  3479.     LXI    D,D$FCB
  3480.     MVI    C,OPEN
  3481.     CALL    BDOS
  3482.     INR    A        ; 0ffh --> 00h if bad open
  3483.     JZ    BADCRC        ;if bad open, just say 'bad-crc'.
  3484.     XRA    A        ;zero 'fcb'..
  3485.     STA    D$FCB+32    ;..'cr' field.
  3486. CRCWF1:
  3487.     LXI    D,D$FCB
  3488.     MVI    C,READ
  3489.     CALL    BDOS
  3490.     ORA    A        ;read okay?
  3491.     BRZ    D$RD$OK        ;yes, read more.
  3492.     DCR    A        ;eof?
  3493.     BRZ    FINCRC        ;yes, finish up and make 'crc' comparison.
  3494.     CALL    ERMSG
  3495.     DB    'Copy Read Error',0
  3496.     JMP    LOOP
  3497. ;
  3498. ;  Block Read OK - Update CRC
  3499. ;
  3500. D$RD$OK:
  3501.     LXI    H,TBUF
  3502.     MVI    B,128
  3503. CRCWF2:
  3504.     MOV    A,M        ;get character to..
  3505.     CALL    UPDCRC        ;..add to 'crc' value. 
  3506.     INX    H
  3507.     BJNZ    CRCWF2
  3508.     BR    CRCWF1
  3509. ;
  3510. ;  Read Complete - Check CRCs
  3511. ;
  3512. FINCRC:
  3513.     LHLD    CRCVAL        ;put written-file 'crc' into..
  3514.     XCHG            ;..de-pair.
  3515.     LHLD    CRCVAL2        ;put read-file 'crc' and..
  3516.     CALL    CMPDEHL        ;..compare 'de/hl' for equality.
  3517.     BRNZ    BADCRC        ;if not zero, show copy-error message.
  3518.     CALL    VPRINT        ;if zero, show 'verified' message.
  3519.     DB    ' -- Verified',0
  3520.     JMP    CUA$LOG        ;return to current user and return to caller
  3521. ;
  3522. ;  Error on Copy
  3523. ;
  3524. BADCRC:
  3525.     CALL    CUA$LOG        ;return to current user
  3526.     CALL    ERMSG
  3527.     DB    ' -- CRC Error',0
  3528.     JMP    LOOP        ;abort
  3529.  
  3530. ;
  3531. ; clear attributes of file (HL) and set attributes on disk
  3532. ; return code of 0FFH (NZ) indicates OK to proceed, 0 (Z) indicates abort
  3533. ;
  3534. ATTRIB:
  3535.     PUSH    H        ;save regs
  3536.     PUSH    H
  3537.     PUSH    D
  3538.     LHLD    DUM$FCB        ;init FCB
  3539.     LXI    D,12        ;12 bytes in
  3540.     DAD    D
  3541.     POP    D
  3542.     CALL    INITFCB
  3543.     LHLD    DUM$FCB        ;pt to dummy FCB
  3544.     XCHG            ;... in DE
  3545.     POP    H
  3546.     MVI    B,12        ;copy
  3547.     PUSH    D
  3548.     CALL    MOVE
  3549.     POP    D        ;pt to FCB
  3550.     MVI    C,SRCHF        ;look for file
  3551.     CALL    BDOS
  3552.     INR    A        ;file not found = 0
  3553.     POP    H
  3554.     RZ            ;abort if no file
  3555.     PUSH    H        ;save ptr
  3556.     DCR    A        ;adjust
  3557.     RRC            ;right 3 bits to indicate offset into BUFF
  3558.     RRC
  3559.     RRC
  3560.     LXI    H,TBUF        ;pt to buffer
  3561.     ADD    L        ;pt to FCB of file
  3562.     ADI    9        ;pt to R/O Byte
  3563.     MOV    L,A
  3564.     MOV    A,M        ;get byte
  3565.     ANI    80H        ;extract R/O Bit
  3566.     BRZ    ATTRIB0
  3567.     CALL    ERMSG
  3568.     DB    0
  3569.     POP    H
  3570.     PUSH    H
  3571.     INX    H        ;pt to file name
  3572.     CALL    PRFN        ;print file name
  3573.     CALL    VPRINT
  3574.     DB    ' is R/O -- Erase (Y/N)? ',0
  3575.     CALL    KEYIN
  3576.     CPI    'Y'
  3577.     JZ    ATTRIB0
  3578.     POP    H
  3579.     XRA    A        ;error return
  3580.     RET
  3581. ATTRIB0:    
  3582.     POP    H        ;get ptr
  3583.     PUSH    H        ;save ptr
  3584.     INX    H        ;pt to first char
  3585.     MVI    B,11        ;11 Bytes
  3586. ATTRIB1:
  3587.     MOV    A,M        ;get byte
  3588.     ANI    7FH        ;mask it
  3589.     MOV    M,A        ;put byte
  3590.     INX    H        ;pt to next
  3591.     DCR    B        ;count down
  3592.     JNZ    ATTRIB1
  3593.     POP    D        ;pt to FCB
  3594.     MVI    C,ATTR
  3595.     CALL    BDOS
  3596.     XRA    A
  3597.     DCR    A        ;no error return
  3598.     RET
  3599.  
  3600. ;
  3601. ;**************************************************
  3602. ;
  3603. ; CRC subroutines
  3604. ;
  3605. ; initialize tables for fast crc calculations
  3606.  
  3607. INITCRC:
  3608.     LHLD    CRCTBL
  3609.     MVI    C,0        ;table index
  3610. GLOOP:
  3611.     XCHG
  3612.     LXI    H,0        ;initialize crc register pair
  3613.     MOV    A,C
  3614.     PUSH    B        ;save index in c-reg
  3615.     MVI    B,8
  3616.     XRA    H
  3617.     MOV    H,A
  3618. LLOOP:
  3619.     DAD    H
  3620.     BRNC    LSKIP
  3621.     MVI    A,10H        ;generator is x^16 + x^12 + x^5 + x^0 as..
  3622.     XRA    H        ;..recommended by ccitt for asynchronous..
  3623.     MOV    H,A        ;..communications.  produces the same..
  3624.     MVI    A,21H        ;..results as public domain programs..
  3625.     XRA    L        ;..chek, comm7, mdm7, and modem7.
  3626.     MOV    L,A
  3627. LSKIP:
  3628.     BJNZ    LLOOP
  3629.     POP    B
  3630.     XCHG            ;de-pair now has crc, hl pointing into table.
  3631.     MOV    M,D        ;store high byte of crc..
  3632.     INR    H
  3633.     MOV    M,E        ;..and store low byte.
  3634.     DCR    H
  3635.     INX    H        ;move to next table entry
  3636.     INR    C        ;next index
  3637.     BRNZ    GLOOP
  3638.     RET
  3639.  
  3640. UPDCRC:
  3641.     PUSH    B        ;update 'crc'..
  3642.     PUSH    H        ;..accumulator..
  3643.     LHLD    CRCVAL        ;pick up partial remainder
  3644.     XCHG            ;de-pair now has partial
  3645.     MVI    B,0
  3646.     XRA    D
  3647.     MOV    C,A
  3648.     LHLD    CRCTBL
  3649.     DAD    B
  3650.     MOV    A,M
  3651.     XRA    E
  3652.     MOV    D,A
  3653.     INR    H
  3654.     MOV    E,M
  3655.     XCHG
  3656.     SHLD    CRCVAL
  3657.     POP    H
  3658.     POP    B
  3659.     RET
  3660.  
  3661. ;
  3662. ;**************************************************
  3663. ;
  3664. ; WORKHORSE Routines
  3665. ;
  3666. ; conin routine (waits for response)
  3667. ;
  3668. KEYIN:
  3669.     CALL    CIN        ;get input
  3670.     CALL    CAPS        ;capitalize
  3671.     JMP    COUT        ;echo
  3672.  
  3673. ; direct console input w/o echo (waits for input)
  3674.  
  3675. DKEYIN:
  3676.     CALL    CIN        ;get char from BIOS
  3677.     JMP    CAPS        ;capitalize
  3678.  
  3679. ; convert keyboard input to upper case
  3680.  
  3681. CONVERT:
  3682.     LHLD    CMDBUF        ; 'current keyboard buffer length'..
  3683.     INX    H
  3684.     MOV    B,M        ;..to b-reg.
  3685.     MOV    A,B
  3686.     ORA    A        ;if zero length, skip conversion.
  3687.     JZ    COMCAN
  3688. CONVLP:
  3689.     INX    H        ;point at character to capitalize
  3690.     MOV    A,M
  3691.     CALL    CAPS
  3692.     MOV    M,A        ;put back into buffer
  3693.     BJNZ    CONVLP
  3694.     RET
  3695. ;
  3696. ; Fill buffer with 'spaces' with count in b-reg
  3697. ;
  3698. FILL:
  3699.     MVI    M,' '        ;put in space character
  3700.     INX    H
  3701.     BJNZ    FILL        ;no, branch.
  3702.     RET
  3703. ;
  3704. ; Ignore leading spaces (ls) in buffer, length in c-reg.
  3705. ;
  3706. UNSPACE:
  3707.     LDAX    D        ;get character
  3708.     CPI    ' '
  3709.     RNZ            ;not blank, a file is entered.
  3710.     INX    D        ;to next character
  3711.     DCR    C
  3712.     JZ    COMCAN        ;all spaces --> command recovery error
  3713.     BR    UNSPACE
  3714. ;
  3715. ; Check for legal filename character -- return with carry set if illegal
  3716. ;
  3717. CKLEGAL:
  3718.     LDAX    D        ;get character from de-pair
  3719.     INX    D        ;point at next character
  3720.     CPI    ' '        ;less than space?
  3721.     RC            ;return carry if unpermitted character
  3722.     PUSH    H
  3723.         PUSH    B
  3724.     CPI    '['        ;if greater than 'z', exit with..
  3725.     BRNC    CKERR        ;..carry set.
  3726.     MVI    B,CHR$TEND-CHR$TBL
  3727.     LXI    H,CHR$TBL
  3728. CHR$LP:
  3729.     CMP    M  
  3730.     BRZ    CKERR
  3731.     INX    H
  3732.     BJNZ    CHR$LP
  3733.     ORA    A        ;clear carry for good character
  3734.     POP    B
  3735.     POP    H
  3736.     RET
  3737.  
  3738. CKERR:
  3739.     POP    B
  3740.     POP    H
  3741.     STC                 ;error exit with carry set
  3742.     RET
  3743.  
  3744. CHR$TBL:
  3745.     DB    ',',':',';','<','=','>'    ;invalid character table
  3746. CHR$TEND:
  3747.     DS    0
  3748. ;
  3749. ; Print file name in S$FCB
  3750. ;
  3751. PRFNSX:
  3752.     PUSH    H        ;save regs
  3753.     PUSH    B
  3754.     BR    PRFNS0
  3755. PRFNS:
  3756.     PUSH    H        ;affect only PSW
  3757.     PUSH    B
  3758.     LXI    H,S$FCB+1
  3759. PRFNS0:
  3760.     CALL    PRFN        ;print file name
  3761.     POP    B        ;restore
  3762.     POP    H
  3763.     RET
  3764. ;
  3765. ; Print file name pted to by HL
  3766. ;
  3767. PRFN:
  3768.     MVI    B,8        ;8 chars
  3769.     CALL    PRFNS1
  3770.     MVI    A,'.'
  3771.     CALL    COUT
  3772.     MVI    B,3        ;file type and fall thru
  3773. PRFNS1:
  3774.     MOV    A,M        ;get char
  3775.     CALL    COUT
  3776.     INX    H        ;pt to next
  3777.     BJNZ    PRFNS1
  3778.     RET
  3779. ;
  3780. ; Copy filename from RINGPOS to SFCB
  3781. ;
  3782. RINGFCB:
  3783.     LHLD    RINGPOS        ;move name from ring to source 'fcb'
  3784.     LXI    D,S$FCB        ;place to move filename and..
  3785.     MVI    B,12        ;..amount to move (fall thru to MOVE)
  3786. ;
  3787. ; move subroutine -- move b-reg # of bytes from hl-pair to de-pair
  3788. ;
  3789. MOVE:
  3790.     MOV    A,M        ;get hl-pair referenced source byte
  3791.     ANI    7FH        ;strip attributes
  3792.     STAX    D        ;put to de-pair referenced destination
  3793.     INX    H        ;fix pointers for next search
  3794.     INX    D
  3795.     BJNZ    MOVE
  3796.     RET
  3797.  
  3798. MOVEB:
  3799.     PUSH    H        ;SAVE HL, DE
  3800.     PUSH    D
  3801.     CALL    MOVE
  3802.     POP    D        ;RESTORE DE, HL
  3803.     POP    H
  3804.     RET
  3805. ;
  3806. ; Initialize FCB system fields (entry with hl-pair pointing to FCB)
  3807. ;
  3808. INITFCB:
  3809.     MVI    B,21        ;fill ex, s1, s2, rc, cr counters with zeros.
  3810. INITLP:
  3811.     MVI    M,0        ;put zero (null) in memory
  3812.     INX    H
  3813.     BJNZ    INITLP
  3814.     RET
  3815. ;
  3816. ; Disk system reset -- login requested drive
  3817. ;
  3818. RESET:
  3819.     MVI    C,RESETDK    ;reset system
  3820.     CALL    BDOS
  3821.     LDA    R$DR        ;make requested drive..
  3822. SET$DR:
  3823.     MOV    E,A        ;..current
  3824.     MVI    C,LOGIN
  3825.     JMP    BDOS        ;return to caller
  3826. ;
  3827. ; Set/reset (or get) user area (call with binary user area in a-reg)
  3828. ;
  3829. SET$USR:
  3830.     MOV    E,A        ;user number in E
  3831. GET$USR:
  3832.     MVI    C,SGUSER
  3833.     JMP    BDOS        ;return to caller
  3834. ;
  3835. ; Compare de-pair to hl-pair and set flags accordingly
  3836. ;
  3837. CMPDEHL:
  3838.     MOV    A,D        ;see if high bytes set flags
  3839.     CMP    H
  3840.     RNZ            ;return if not equal
  3841.     MOV    A,E
  3842.     CMP    L        ;low bytes set flags instead
  3843.     RET
  3844. ;
  3845. ; Shift hl-pair b-reg bits (-1) to right (divider routine)
  3846. ;
  3847. SHIFTLP:
  3848.     DCR    B
  3849.     RZ
  3850.     MOV    A,H
  3851.     ORA    A
  3852.     RAR
  3853.     MOV    H,A
  3854.     MOV    A,L
  3855.     RAR
  3856.     MOV    L,A
  3857.     BR    SHIFTLP
  3858.  
  3859. ;
  3860. ; Determine free storage remaining on selected drive
  3861. ;
  3862. FRESTOR:
  3863.     MVI    C,INQDISK    ;determine current drive
  3864.     CALL    BDOS        ;returns 0 as a:, 1 as b:, etc.
  3865.     INR    A        ;make 1 --> a:, 2 --> b:, etc.
  3866.     STA    FCB
  3867.     MVI    C,GETPARM    ;current disk parameter block
  3868.     CALL    BDOS
  3869.     INX    H        ;bump to..
  3870.     INX    H
  3871.     MOV    A,M        ;..block shift factor.
  3872.     STA    BSHIFTF        ; 'bsh'
  3873.     INX    H        ;bump to..
  3874.     MOV    A,M        ;..block mask.
  3875.     STA    B$MASK        ; 'blm'
  3876.     INX    H        ;bump to..
  3877.     INX    H        ;..get..
  3878.     MOV    E,M        ;..maximum block number..
  3879.     INX    H        ;..double..
  3880.     MOV    D,M        ;..byte.
  3881.     XCHG
  3882.     SHLD    B$MAX        ; 'dsm'
  3883.     MVI    C,INQALC    ;address of allocation vector
  3884.     CALL    BDOS
  3885.     XCHG            ;get its length
  3886.     LHLD    B$MAX
  3887.     INX    H
  3888.     LXI    B,0        ;initialize block count to zero
  3889. GSPBYT:
  3890.     PUSH    D        ;save allocation address
  3891.     LDAX    D
  3892.     MVI    E,8        ;set to process 8 bits (blocks)
  3893. GSPLUP:
  3894.     RAL            ;test bit
  3895.     BRC    NOT$FRE
  3896.     INX    B
  3897. NOT$FRE:
  3898.     MOV    D,A        ;save bits
  3899.     DCX    H
  3900.     MOV    A,L
  3901.     ORA    H    
  3902.     BRZ    END$ALC        ;quit if out of blocks
  3903.     MOV    A,D        ;restore bits
  3904.     DCR    E        ;count down 8 bits
  3905.     BRNZ    GSPLUP        ;branch to do another bit
  3906.     POP    D        ;bump to next count..
  3907.     INX    D        ;..of allocation vector.
  3908.     BR    GSPBYT        ;process it
  3909.  
  3910. END$ALC:
  3911.     POP    D        ;clear alloc vector pointer from stack
  3912.     MOV    L,C        ;copy # blocks to hl-pair
  3913.     MOV    H,B
  3914.     LDA    BSHIFTF        ;get block shift factor
  3915.     SUI    3        ;convert from sectors to thousands (k)
  3916.     BRZ    PRT$FRE        ;skip shifts if 1k blocks
  3917. FREK$LP:
  3918.     DAD    H        ;multiply blocks by k-bytes per block
  3919.     DCR    A        ;multiply by 2, 4, 8, or 16.
  3920.     BRNZ    FREK$LP
  3921. PRT$FRE:
  3922.     SHLD    DISKSP        ;save disk space
  3923.     RET
  3924. ;
  3925. ;  Print free space on disk
  3926. ;
  3927. PRINT$FRE:
  3928.     CALL    ERMSG        ;position and set flags
  3929.     DB    0
  3930.     LHLD    DISKSP
  3931.     CALL     PHLFDC        ; # of free k-bytes in hl-pair
  3932.     CALL    VPRINT
  3933.     DB    'K Bytes on Disk',0
  3934.     RET
  3935.  
  3936. ;
  3937. ;**************************************************
  3938. ;
  3939. ; MESSAGE Routines
  3940. ;
  3941. ; Print VFILER Banner
  3942. ;
  3943. BANNER:
  3944.     CALL    VCLS        ;clear screen
  3945.     LXI    H,BANADR
  3946.     CALL    GOTOXY
  3947.     CALL    VPRINT        ;print banner
  3948.     DB    'VFILER, Version '
  3949.     DB    VERS/10+'0','.',(VERS MOD 10)+'0'
  3950.      IF    Z80
  3951.     DB    '  '
  3952. ;    DB    DIM        ;<JPS>
  3953.     DB    '[Z80 Code]'
  3954. ;    DB    BRIGHT        ;<JPS>
  3955.      ELSE
  3956.     DB    '  '
  3957. ;    DB    DIM        ;<JPS>
  3958.     DB    '[8080 Code]'
  3959. ;    DB    BRIGHT        ;<JPS>
  3960.      ENDIF
  3961.     DB    0
  3962.     RET
  3963. ;
  3964. ; Home the Cursor
  3965. ;
  3966. CUR$FIRST:
  3967.     LXI    H,CURHOME    ; HOME ADDRESS
  3968.     SHLD    CURAT        ; SET CURSOR POSITION
  3969.     JMP    GOTOXY
  3970. ;
  3971. ; Last File Position
  3972. ;
  3973. CUR$LAST:
  3974.     LHLD    RINGPOS        ; ADVANCE
  3975.     SHLD    LOCPOS        ; SET LOCAL POSITION
  3976. CL0:
  3977.     LXI    D,13
  3978.     DAD    D
  3979.     XCHG
  3980.     LHLD    LOCEND        ; END OF LOCAL RING?
  3981.     CALL    CMPDEHL
  3982.     RZ
  3983.     XCHG            ; NEW POSITION
  3984.     SHLD    LOCPOS
  3985.     PUSH    H        ; SAVE POSITION
  3986.     CALL    CUR$NEXT    ; ADVANCE CURSOR
  3987.     POP    H        ; GET POSITION
  3988.     BR    CL0
  3989. ;
  3990. ; Advance the Cursor
  3991. ;
  3992. CUR$NEXT:
  3993.     LHLD    CURAT        ; COMPUTE NEW POSITION
  3994.     MOV    A,L        ; CHECK FOR NEW LINE
  3995.     ADI    19        ; SIZE OF EACH ENTRY
  3996.     CPI    70
  3997.     BRNC    CN1        ; ADVANCE TO NEXT LINE
  3998.     MOV    L,A        ; NEW POSITION
  3999.     SHLD    CURAT
  4000.     JMP    GOTOXY
  4001. CN1:
  4002.     MOV    A,H        ; GET LINE
  4003.     LXI    H,CURHOME    ; GET COL
  4004.     MOV    H,A        ; SET LINE AND FALL GO TO CUR$DOWN
  4005.     SHLD    CURAT
  4006.     BR    CUR$DOWN
  4007. ;
  4008. ; Back Up the Cursor
  4009. ;
  4010. CUR$BACK:
  4011.     LXI    H,CURHOME    ; GET HOME
  4012.     XCHG            ; ... IN DE
  4013.     LHLD    CURAT
  4014.     CALL    CMPDEHL        ; COMPARE
  4015.     BRZ    CUR$LAST    ; GOTO END IF LAST
  4016.     MOV    A,L        ; CHECK FOR FIRST COL
  4017.     CMP    E
  4018.     BRZ    CB1
  4019.     SUI    19        ; BACK UP ONE COL
  4020.     MOV    L,A
  4021.     SHLD    CURAT        ; NEW POS
  4022.     JMP    GOTOXY
  4023. CB1:
  4024.     MOV    A,E        ; GET HOME COL
  4025.     ADI    19*3        ; GET LAST COL
  4026.     MOV    L,A
  4027.     DCR    H        ; PREV LINE
  4028.     SHLD    CURAT
  4029.     JMP    GOTOXY
  4030. ;
  4031. ; Move Cursor Down One Line
  4032. ;
  4033. CUR$DOWN:
  4034.     LXI    H,CURHOME    ; GET HOME ADDRESS
  4035.     MOV    B,H        ; LINE IN B
  4036.     LHLD    CURAT        ; GET CURRENT ADDRESS
  4037.     INR    H        ; MOVE DOWN
  4038.     MOV    A,H        ; CHECK FOR TOO FAR
  4039.     SUB    B
  4040.     CPI    EPS/4
  4041.     BRNC    CD1
  4042.     SHLD    CURAT        ; OK, SO SET POSITION
  4043.     JMP    GOTOXY
  4044. CD1:
  4045.     MOV    A,L        ; GET COL
  4046.     LXI    H,CURHOME
  4047.     MOV    L,A
  4048.     SHLD    CURAT
  4049.     JMP    GOTOXY
  4050. ;
  4051. ; Refresh Screen
  4052. ;
  4053. REFRESH:
  4054.     LHLD    CURAT    ; SAVE CURSOR AND RING POSITIONS
  4055.     SHLD    SCURAT
  4056.     LHLD    RINGPOS
  4057.     SHLD    SRINGPOS
  4058.     CALL    BANNER    ; PRINT BANNER
  4059. ;
  4060.     IF    BIHELP        ;built-in help?
  4061.     LDA    HELPDISP    ;DISPLAY HELP?
  4062.     ORA    A    ;0=NO
  4063.     BRZ    REF1
  4064.     CALL    HELPMSG    ;PRINT HELP MESSAGE
  4065.     BR    REF2
  4066. REF1:
  4067.     ENDIF        ;BIHELP
  4068. ;
  4069.     CALL    DISPFILES    ; DISPLAY FILES
  4070. REF2:
  4071.     LXI    H,DUADR        ; DU ADDRESS
  4072.     CALL    GOTOXY
  4073.     LXI    H,C$DR        ; PT TO CURRENT DRIVE (FOLLOWED BY CUR USER)
  4074.     CALL    STNDOUT        ;<RID> TURNON HIGHLIGHTING
  4075.     CALL    PRDU        ; PRINT DU:DIR>
  4076.     CALL    STNDEND        ;<RID> TURN OFF HIGHLIGHTING
  4077.     LXI    H,CPMADR    ; COMMAND PROMPT MESSAGE
  4078.     CALL    GOTOXY
  4079.     CALL    VPRINT        ; PROMPT WITH DRIVE PREFIX
  4080.     DB    DIM
  4081.     DB    'Command (? = ',0
  4082.     LDA    HELPDISP    ; IN HELP NOW?
  4083.     ORA    A        ; 0=NO
  4084.     BRZ    REF3
  4085.     CALL    VPRINT
  4086.     DB    'Files',0
  4087.     BR    REF4
  4088. REF3:
  4089.     CALL    VPRINT
  4090.     DB    'Help',0
  4091. REF4:
  4092.     CALL    VPRINT
  4093.     DB    ')?',BRIGHT,0
  4094.     LHLD    SCURAT        ; RESTORE CURSOR AND RING POSITIONS
  4095.     SHLD    CURAT
  4096.     LHLD    SRINGPOS
  4097.     SHLD    RINGPOS
  4098.     CALL    SETCUR        ; RESTORE CURSOR ON SCREEN
  4099.     RET
  4100. ;
  4101. ;  Print DU pted to by HL
  4102. ;
  4103. PRDU:
  4104.     PUSH    H        ; SAVE REGS
  4105.     PUSH    B
  4106.     MOV    A,M        ; GET DRIVE
  4107.     MOV    B,A
  4108.     ADI    'A'        ; CONVERT TO LETTER
  4109.     CALL    COUT
  4110.     INX    H        ; PT TO USER
  4111.     MOV    A,M        ; GET USER
  4112.     MOV    C,A
  4113.     CALL    PAFDC        ; PRINT USER AS FLOATING
  4114.     MVI    A,':'        ; PRINT COLON
  4115.     CALL    COUT
  4116.     CALL    DUTDIR        ; SCAN NAMED DIRECTORY TABLE
  4117.     BRZ    PRDU2        ; NO NAME?
  4118.     MVI    B,8        ; PRINT NAME
  4119. PRDU1:
  4120.     MOV    A,M        ; GET CHAR
  4121.     CPI    ' '        ; DONE IF SPACE ENCOUNTERED
  4122.     BRZ    PRDU3
  4123.     CALL    COUT
  4124.     INX    H
  4125.     BJNZ    PRDU1
  4126.     BR    PRDU3
  4127. PRDU2:
  4128.     CALL    VPRINT
  4129.     DB    'Noname',0
  4130. PRDU3:
  4131.     POP    B        ; RESTORE REGS
  4132.     POP    H
  4133.     RET
  4134.  
  4135. ;
  4136. ; Refresh File Display
  4137. ;
  4138. DISPFILES:
  4139.     CALL    CUR$FIRST    ; POSITION CURSOR AT FIRST POSITION
  4140.     LHLD    LOCBEG        ; PT TO FIRST FILE NAME
  4141.     SHLD    LOCPOS        ; SAVE LOCAL POSITION
  4142. DSPF1:
  4143.     LHLD    LOCEND        ; AT END?
  4144.     XCHG
  4145.     LHLD    LOCPOS
  4146.     CALL    CMPDEHL
  4147.     JZ    CUR$FIRST    ; POSITION AT FIRST ENTRY AND RETURN
  4148.     MVI    B,4        ; 4 SPACES
  4149.     MVI    A,' '
  4150. DSPF2:
  4151.     CALL    COUT
  4152.     BJNZ    DSPF2
  4153.     PUSH    H        ; SAVE CURRENT LOCAL POSITION IN RING
  4154. ;<RID>    INX    H        ; PT TO FILE NAME
  4155. ;<RID>    CALL    PRFN        ; PRINT FILE NAME
  4156. ;<RID>    MOV    A,M        ; PRINT TAG
  4157. ;<RID>    CALL    COUT
  4158.     CALL    HILITFN        ;<RID> brigten filename
  4159.     POP    H        ; GET CURRENT LOCAL POSITION
  4160.     LXI    D,13
  4161.     DAD    D
  4162.     SHLD    LOCPOS
  4163.     CALL    CUR$NEXT    ; ADVANCE CURSOR
  4164.     BR    DSPF1
  4165.  
  4166. HILITFN:            ;<RID>
  4167.     PUSH    H        ;<RID> save for later
  4168.     LXI    D,12        ;<RID> locate the tag byte
  4169.     DAD    D        ;<RID>
  4170.     MOV    A,M        ;<RID> put tag byte in a for store
  4171.     STA    TAGFLG        ;<RID>
  4172.     POP    H        ;<RID> back to beginning of filename
  4173.     INX    H        ;<RID> point to filename
  4174.     LDA    TAGFLG        ;<RID>
  4175.     CPI    ' '        ;<RID> if space don't highlight
  4176.     CNZ    STNDOUT        ;<RID> set highlight on
  4177.     CALL    PRFN        ;<RID> put out filename
  4178.     MOV    A,M        ;<RID> get tag byte
  4179.     CALL    COUT        ;<RID> and output it
  4180.     LDA    TAGFLG        ;<RID>
  4181.     CPI    ' '        ;<RID>
  4182.     CNZ    STNDEND        ;<RID> turn off highlighting
  4183.     RET            ;<RID>
  4184. ; Position Cursor at CURAT
  4185. ;
  4186. SETCUR:
  4187.     LDA    HELPDISP    ; NOGO IF IN HELP DISPLAY
  4188.     ORA    A
  4189.     RNZ
  4190.     LHLD    CURAT
  4191.     CALL    GOTOXY
  4192.     CALL    VPRINT
  4193.     DB    DIM,'-->',BRIGHT,0
  4194.     RET
  4195. ;
  4196. ; Clear Cursor
  4197. ;
  4198. CLRCUR:
  4199.     LDA    HELPDISP    ; NOGO IF IN HELP DISPLAY
  4200.     ORA    A
  4201.     RNZ
  4202.     LHLD    CURAT
  4203.     CALL    GOTOXY
  4204.     CALL    VPRINT
  4205.     DB    '   ',0
  4206.     RET
  4207. ;
  4208. ; Command Prompt
  4209. ;
  4210. CPRMPT:
  4211.     LXI    H,CPADR    ; GET ADDRESS
  4212. MPRINT:
  4213.     PUSH    H    ; SAVE ADDRESS
  4214.     CALL    GOTOXY
  4215.     PUSH    B
  4216. ;<RID>    MVI    B,76-(CPADR MOD 255)
  4217.     LDA    CWIDTH    ;<RID> find screen length in chars
  4218.     SUI    (CPADR MOD 256)-1    ;<RID> determine number of char. to blank   
  4219.     MOV    B,A    ;<RID> put number in b
  4220.     CALL    VEREOL    ; ERASE TO EOL
  4221.     POP    B
  4222.     POP    H    ; GET ADDRESS
  4223.     CALL    GOTOXY    ; POSITION CURSOR
  4224.     JMP    VPRINT    ; PRINT MESSAGE AND RETURN
  4225. ;
  4226. ; Working Message
  4227. ;
  4228. WORKMSG:
  4229.     CALL    ERMSG
  4230.     DB    DIM,'Working ...',BRIGHT,0
  4231.     RET
  4232. ;
  4233. ; Error Message
  4234. ;
  4235. ERMSG:
  4236.     MVI    A,0FFH    ; SET ERROR MESSAGE FLAG
  4237.     STA    ERMFLG
  4238.     LXI    H,ERADR    ; GET ADDRESS
  4239.     BR    MPRINT
  4240. ;
  4241. ; Print File Size Info
  4242. ;
  4243. FSNOTE:
  4244.     CALL    ERMSG    ; USE THIS ROUTINE
  4245.     DB    'Size of ',0
  4246.     RET
  4247. ;
  4248. ; Position for File Size Print
  4249. ;
  4250. ATFS:
  4251.     LXI    H,FSADR+13    ; POSITION FOR PRINT OF FILE SIZE
  4252.     JMP    GOTOXY
  4253. ;
  4254. ; Clear Error Message
  4255. ;
  4256. ERCLR:
  4257.     XRA    A    ; CLEAR FLAG
  4258.     STA    ERMFLG
  4259.     LXI    H,ERADR    ; POSITION
  4260.     CALL    GOTOXY
  4261.     PUSH    B
  4262. ;<RID>    MVI    B,76-(ERADR MOD 255)
  4263.     LDA    CWIDTH    ;<RID> find screen length in chars
  4264.     SUI    (ERADR MOD 256)-1    ;<RID> determine number of char. to blank   
  4265.     MOV    B,A    ;<RID> put number in b
  4266.     CALL    VEREOL    ; ERASE TO EOL
  4267.     POP    B
  4268.     RET
  4269. ;
  4270. ; Position at Command Prompt and Clear It
  4271. ;
  4272. ATCMD:
  4273.     LXI    H,CPADR    ; POSITION
  4274.     CALL    GOTOXY
  4275.     PUSH    B
  4276. ;<RID>    MVI    B,76-(CPADR MOD 255)
  4277.     LDA    CWIDTH    ;<RID> find screen length in chars
  4278.     SUI    (CPADR MOD 256)-1    ;<RID> determine number of char. to blank   
  4279.     MOV    B,A    ;<RID> put number in b
  4280.     CALL    VEREOL    ; CLEAR MESSAGE
  4281.     POP    B
  4282.     LXI    H,CPADR    ; REPOSITION
  4283.     JMP    GOTOXY
  4284. ;
  4285. ; Position at Bottom of Screen and Prompt for Continuation
  4286. ;
  4287. BOTTOM:
  4288.     LXI    H,BOTADR    ; POSITION
  4289.     CALL    GOTOXY
  4290. ;
  4291. ; Prompt for Continuation
  4292. ;
  4293. SAK:
  4294.     CALL    VPRINT
  4295.     DB    DIM,'Strike Any Key -- ',BRIGHT,0
  4296.     JMP    KEYIN
  4297.  
  4298.  
  4299. ;
  4300. ; S T O R A G E
  4301. ;
  4302. ; Initialized
  4303. ;
  4304. HEADMSG:
  4305.     DB    'File: ',0
  4306. MOREHELP:
  4307.     DB    'HELP '    ;HELP Command for further info
  4308.     VFNAME        ;VFILER Name
  4309.     DB    0
  4310. MACFCB:
  4311.     DB    0
  4312.     VFNAME        ;VFILER Name
  4313.     VFNFILL        ;Filler
  4314.     DB    'CMD'
  4315. FILERCMD:
  4316.     VFNAME        ;VFILER Name
  4317.     VFNFILL        ;Filler
  4318.     DB    ' '    ;one space
  4319. FILE$D:
  4320.     DB    'x'
  4321. FILE$U:
  4322.     DB    'xx'
  4323.     DB    ':'    ;colon
  4324.     DB    0
  4325. JOKER:
  4326.     DB    '???????????'    ;*.* equivalent
  4327. FIRST$M:
  4328.     DB    FALSE        ;1st time thru in mass-copy mode
  4329. MFLAG:
  4330.     DB    TRUE        ;multiple file copy flag-->0 for mass copy
  4331. TAG$TOT:
  4332.     DW    0        ;summation of tagged file sizes
  4333. CMDBUF:
  4334.     DS    2        ;command buffer maximum length, usage, and..
  4335. ;
  4336. ; Uninitialized
  4337. ;
  4338. STACK:
  4339.     DS    2
  4340. LWIDTH:
  4341.     DS    1    ;WIDTH OF LINE
  4342. LTPP:
  4343.     DS    1    ;LINES OF TEXT PER PAGE
  4344. LSPP:
  4345.     DS    1    ;LINES TO SKIP PER PAGE
  4346. LFFEED:
  4347.     DS    1    ;PRINTER CAN FORMFEED? (0=NO)
  4348. CWIDTH:
  4349.     DS    1    ;WIDTH OF SCREEN
  4350. CTPP:
  4351.     DS    1    ;LINES OF TEXT PER SCREEN
  4352. CSPP:
  4353.     DS    1    ;LINES TO SKIP PER SCREEN
  4354. ALPHA:
  4355.     DS    1        ;alphabetization flag (0=type and name, 0FFH=
  4356.                 ;...name and type)
  4357. B$MAX:
  4358.     DS    2        ;highest block number on drive
  4359. B$MASK:
  4360.     DS    1        ;sec/blk-1
  4361. BSHIFTF:
  4362.     DS    1        ;# of shifts to multiply by sec/blk
  4363. BUFENTRY:
  4364.     DS    2        ;buffer start
  4365. BUF$PT:
  4366.     DS    2        ;copy buffer current pointer..
  4367. BUFSTART:
  4368.     DS    2        ;..and begin pointer.
  4369. CANFLG:
  4370.     DS    1        ;no-file-found cancel flag
  4371. C$DR:
  4372.     DS    1        ;'current drive'
  4373. C$U$A:
  4374.     DS    1        ;'current user area' (must follow C$DR)
  4375. CHARCNT:
  4376.     DS    1        ;character count for tab expansion
  4377. CON$LST:
  4378.     DS    1        ;bdos function storage
  4379. CRCTBL:
  4380.     DS    2        ;tables for 'crc' calculations
  4381. CRCVAL:
  4382.     DS    2        ;2-byte 'crc' value of working file and..
  4383. CRCVAL2:
  4384.     DS    2        ;..of finished source read-file.
  4385. CURAT:
  4386.     DS    2        ;current cursor position
  4387. DELCODE:
  4388.     DS    1        ;deletion code (0=delete not done)
  4389. D$FCB:
  4390.     DS    33        ;fcb for destination file/new name if rename
  4391. DISKSP:
  4392.     DS    2        ;space remaining on disk
  4393. DUM$FCB:
  4394.     DS    2        ;dummy FCB for file attributes
  4395. DRLET:
  4396.     DS    1        ;scratch for drive letter
  4397. EOFLAG:
  4398.     DS    1        ;file copy loop 'eof' flag
  4399. ERMFLG:
  4400.     DS    1        ;error message present flag
  4401. H$DR:
  4402.     DS    1        ;home drive
  4403. H$U$A:
  4404.     DS    1        ;home user area (must follow H$DR)
  4405. HELPDISP:
  4406.     DS    1        ;display help screen (0=no)
  4407. LPSCNT:
  4408.     DS    1        ;lines-per-screen for 'view'
  4409. LOCBEG:
  4410.     DS    2        ;local beginning of ring
  4411. LOCEND:
  4412.     DS    2        ;local end of ring
  4413. LOCPOS:
  4414.     DS    2        ;local ring position (temp)
  4415. MASSOP:
  4416.     DS    1        ;mass file operation code (0=no)
  4417. MAXDR:
  4418.     DS    1        ;max driver letter
  4419. MDFLG:
  4420.     DS    1        ;mass delete verify flag
  4421. O$USR:
  4422.     DS    1        ;store initial user area for exit
  4423. R$DR:
  4424.     DS    1        ;'requested drive'
  4425. RCNT:
  4426.     DS    2        ;# of records in file and..
  4427. REC$CNT:
  4428.     DS    2        ;..currently in ram buffer.
  4429. REC$MAX:
  4430.     DS    2        ;maximum 128-byte record capacity of buffer
  4431. RING:
  4432.     DS    2        ;ptr to beginning of ring
  4433. RINGI:
  4434.     DS    2        ;ring sort pointer
  4435. RINGJ:
  4436.     DS    2        ;another ring sort pointer
  4437. RINGEND:
  4438.     DS    2        ;current ring end pointer
  4439. RINGPOS:
  4440.     DS    2        ;current ring position in scan
  4441. R$U$A:
  4442.     DS    1        ;'requested user area'
  4443. SCURAT:
  4444.     DS    2        ;save cursor position
  4445. S$FCB:
  4446.     DS    36        ;fcb for source (random record) file
  4447. SRINGPOS:
  4448.     DS    2        ;save ring position
  4449. TAGFLG:                ;<RID> temp for tag
  4450.     DS    1        ;<RID>
  4451. T$DR:
  4452.     DS    1        ;temp disk
  4453. TEST$RT:
  4454.     DS    1        ;intermediate right-justify data
  4455. T$U$A:
  4456.     DS    1        ;temp user
  4457. T$UN$FG:
  4458.     DS    1        ;tag/untag file summation switch
  4459. USER:
  4460.     DS    1        ;temp user buffer
  4461. VIEWFLG:
  4462.     DS    1        ;<RID> (00h) 1-->to list/punch else to crt 'view'
  4463.  
  4464.     END
  4465.  
  4466.