home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / uploads / zxd166.z80 < prev    next >
Encoding:
Text File  |  1994-09-02  |  37.5 KB  |  1,313 lines

  1.     TITLE    "ZSDOS EXtended Directory Lister"
  2. ;==========================================================================
  3. ;  Z X D    Z-System eXtended Directory Lister
  4. ;--------------------------------------------------------------------------
  5. ; Derived from XD III Ver 1.2, 8 Apr 84 by Richard Conn.
  6. ;  Changes Copyright (C) 1988 by Harold F. Bower, All Rights Reserved
  7. ;--------------------------------------------------------------------------
  8. ;   ZXD was modified from XD III to take advantage of the Date Stamping
  9. ; capabilities of ZSDOS.  Features of Rick Conn's full-blown XDIR were
  10. ; added, as well as modified formats for Date Stamp displays.  Version 4
  11. ; of "The Libraries" MUST be used to link this program due to the added
  12. ; files tailored for Date/Time Stamping support.
  13. ;
  14. ;    Link as:   ZLINK ZXD,DSLIB/,Z3LIB/,SYSLIB/
  15. ;
  16. ; Revisions:
  17. ;  1.66 -  3 May 92 - Use GETNAME/PRTNAME for Help.            HFB
  18. ;  1.65 -  4 Apr 92 - Modified to use 3 bytes of size of ZSDOS2    .    HFB
  19. ;  1.64 - 11 Jul 91 - Corrected bug in No-Date Listing            HFB
  20. ;  1.63 - 14 Oct 90 - Changed to use pointers instead of recs        HFB
  21. ;  1.62 - 21 May 89 - Added embedded Config tag for ZCNFG        HFB
  22. ;  1.61 - 20 May 89 - Corrected default DU under vanilla CP/M        HFB
  23. ;  1.60 - 15 May 89 - Added Parse routine to work w/o ZCPR 3        HFB
  24. ;  1.6  - 13 May 89 - Maximized Library usage                HFB
  25. ;  1.50 -  9 Jan 89 - Added CP/M Plus free space calc             HFB
  26. ;  1.5  - 27 Dec 88 - Added CP/M Plus Time/Date in header        HFB
  27. ;  1.4  - 10 Dec 88 - Corrected glitch in hilite on/off            HFB
  28. ;  1.3a -  5 Dec 88 - Print Create date if no Modify exists, check only
  29. ;        DOS clock, Not DateStamper if ZDDOS.             HFB
  30. ;  1.3  - 30 Nov 88 - Final release                    HFB
  31. ;  1.2a - 25 Nov 88 - Added DateStamper (tm) clock if no ZS        HFB
  32. ;  1.2  - 17 Nov 88 - Formal release version                HFB
  33. ;  1.1b - 11 Nov 88 - Fixed select glitch for /as Option.        HFB
  34. ;  1.1a -  5 Nov 88 - Added WHEEL sensing & Disabling             HFB
  35. ;  1.1  - 26 Sep 88 - Added video attributes under ZCPR3        HFB
  36. ;  1.0  - 17 Sep 88 - Initial Release                    HFB
  37. ;==========================================================================
  38.  
  39. VERS    EQU    16        ; Released Version
  40. rev    equ    '6'
  41. DATE      MACRO
  42.     DEFB    '3 May 92'
  43.       ENDM
  44.  
  45. ;---------
  46. ; ZXD -- Simple Extended Disk Directory Program
  47.  
  48. ;    ZXD produces a formatted, alphabetized listing of the contents of
  49. ; the disk directory of the implied (current logged-in) or specified disk.
  50.  
  51. ;    ZXD is invoked by a command line of the following form --
  52.  
  53. ;    ZXD [dir:]fn.ft [/]ooo...
  54. ;    or
  55. ;    ZXD /oooo...
  56. ; Where:
  57. ;   dir      = optional directory name or disk/user specification (du)
  58. ;        If dir is omitted, ZXD defaults to the current disk/user
  59. ;   fn.ft = optional ambiguous file name and type (* and ? may be used)
  60. ;   o      = option letters as:
  61. ;        Aa - Set the attributes of the files to be displayed;
  62. ;          a=S for System Files
  63. ;          a=N for Non-System Files
  64. ;          a=A for All Files (System and Non-System)
  65. ;        Oo - Set Output Parameters;
  66. ;          o=A to Toggle File Attributes
  67. ;          o=F to Form Feed at end
  68. ;          o=H to Toggle Hor/Vert
  69. ;        P  - Print display as well as show it on the screen
  70. ;        PF - Same as POF
  71. ;        U  - Print all user areas
  72. ;        W  - Print both Created and Modified dates
  73. ;        D  - Toggle display of Date (US/European) from default
  74. ;        T  - Toggle Method of Time Stamps to use (P2Dos/DateStamper)
  75. ;        S  - Sort with reversed parameters (Name then Type or reversed)
  76. ;        N  - Toggle Date/No-Date in listing
  77. ; Options may be combined as desired; note that AA is the same as AS and AN,
  78. ; but AS by itself negates AN and vice-versa, with AN taking precedence
  79. ;
  80. ; If the User does not have WHEEL privileges, options A, P and U are not
  81. ; recognized, and do not appear in the on-line Help message.
  82. ;.....
  83. ;  CP/M Equates
  84.  
  85. BDOS    EQU    0005H
  86. FCB    EQU    005CH
  87. BUFF    EQU    0080H
  88.  
  89. CR    EQU    0DH
  90. FF    EQU    0CH
  91. LF    EQU    0AH
  92.  
  93. FNSIZE    EQU    16        ; Basic File Name & Type Size
  94. ESIZE    EQU    FNSIZE+15    ; Entry Size + Create, Access & Modify times
  95. OPTCH    EQU    '/'        ; Option char
  96. MAXENT    EQU    40        ; Maximum number of entries/screen (20 lines)
  97.  
  98.  
  99.     PUBLIC    COUT        ; Call to BOUT will be COUT to SYSLIB routines
  100.  
  101. ; External Library references:
  102.  
  103.     EXT    DDIRQS, FINDCK, RDCLK, P2UTIM, TIMINI, RCLOCK    ; Dslib
  104.     EXT    RCLOCK, GETDOS, DOSTYP, DOSVER            ;   "
  105.  
  106.     EXT    Z3VINIT, STNDOUT, STNDEND, TINIT, DINIT        ; Vlib
  107.  
  108.     EXT    Z3LOG, WHRENV, DUTDIR, GETWHL, ZPRSFN        ; Z3lib
  109.     EXT    GETNAME, PRTNAME                ;   "
  110.  
  111.     EXT    DFREE, DPARAM, FSIZE, LCRLF, CIN, LOUT, FILLB     ; Syslib
  112.     EXT    CODEND, RETUD, LOGUD, COMPHD, SCTLFL, SOUT, BOUT ;   "
  113.     EXT    SCRLF, SHLDC, SADC, SAFDC, SPRINT, SPSTR     ;   "
  114.  
  115. ;=================================================================
  116. ;        S T A R T    T H E    P R O G R A M
  117. ;=================================================================
  118.  
  119.     JP    START        ; Bypass header and start execution
  120.  
  121.     DEFB    'Z3ENV'        ; This is a ZCPR3 Utility
  122.     DEFB    1        ; External Environment Descriptor
  123. Z3EADR:    DEFW    0001        ; Set Non-zero to force search
  124.     DEFW    0000        ; Filler for Type 4 Header
  125.     DEFB    'ZXD     ',0    ; Use this Configuration File
  126.  
  127. ;.....
  128. ;  Default Flags
  129.  
  130. IUSR:    DEFB    0        ; All users (0 = no, FF = All users)
  131. IFMT:    DEFB    0        ; 0=Vertical format, FF= Horizontal format
  132. IFF:    DEFB    0        ; enable form feed at end (0=no)
  133. ISORT:    DEFB    0        ; 0=Sort Name then Type, FF=Type then Name
  134. INDATE:    DEFB    0        ; 0=Print With Dates, FF=Print without Dates
  135. WIDE:    DEFB    0        ; 0=only modified dates, FF=create/modified
  136. STMODE:    DEFB    0FFH        ; 0=P2Dos Stamps, FF=DateStamper Stamps
  137. USEUR:    DEFB    0        ; 0=US Date Format, FF=European Date Format
  138. IATT:    DEFB    10000000B    ; Non-System files only
  139. BLNKYR:    DEFB    0        ; 0=Always print Year, FF=Blank Year if current
  140.  
  141. ; ********* Start of ZXD *********
  142.  
  143. START:    LD    (STACK),SP    ; Save stack ptr for return
  144.     CALL    CODEND        ; Determine free space
  145.     LD    DE,100H        ; Allow 1 page for command line & stack
  146.     EX    DE,HL
  147.     ADD    HL,DE
  148.     LD    (BUFFER),HL    ; Start of free Buffer area
  149.     LD    SP,HL        ; Set local stack
  150.     PUSH    DE        ; Save page addr for command line copy
  151.  
  152.     LD    HL,(Z3EADR)    ; Pt to candidate ZCPR3 environment
  153.     CALL    WHRENV        ; ..and find a valid one
  154.     LD    (Z3EADR),HL
  155.     CALL    Z3VINIT        ; Initialize the ZCPR3 Env
  156.     CALL    GETNAME        ;1.66 Get name by which invoked
  157.     CALL    RETUD        ; Get entry DU for later restoration
  158.     LD    (ENTRUD),BC    ; .on exit
  159.     LD    (FCB+13),BC    ; ..and default DU if no args
  160.     CALL    TIMINI        ; Initialize Clock and Dos Typeing
  161.     CALL    TINIT        ; Initialize the Terminal
  162.     CALL    GETWHL        ; Get any existing Wheel byte
  163.     OR    A        ; ..setting flags
  164.     LD    (WHEEL),A    ; Save it locally for later testing
  165.     JR    NZ,START0    ; ..jump if User has wheel
  166.     LD    (IUSR),A    ; Disable "All User" w/Null in A
  167.     LD    A,10000000B    ; ..and set for only Non-System files
  168.     LD    (IATT),A
  169.  
  170. START0:    CALL    SPRINT        ; Print the opening banner
  171.     DEFB    'ZXD  Ver ',VERS/10+'0','.',VERS MOD 10 + '0',rev,0
  172.  
  173. ; Save command line in CMDLNE buffer
  174.  
  175.     POP    DE        ; Restore page addr to DE
  176.     LD    HL,BUFF+1    ; Copy input line into command line buffer
  177. START1:    LD    A,(HL)        ; Get byte
  178.     LDI            ; Move a byte and advance ptrs
  179.     OR    A        ; End of Line?
  180.     JR    NZ,START1
  181.  
  182. ; Parse Filename per ZCPR3 specifications
  183.  
  184.     LD    HL,BUFF+1
  185. FLOOP:    LD    A,(HL)        ; Scan over spaces
  186.     INC    HL        ; ..point to next
  187.     OR    A        ; End-of-Line?
  188.     JR    Z,FLOOPX    ; ..jump if so
  189.     CP    ' '        ; Space?
  190.     JR    Z,FLOOP        ; ..jump if so
  191.     DEC    HL        ; Back down to first char
  192.     LD    DE,FCB        ; Parse to this location
  193.     PUSH    DE        ; Save FCB addr
  194.     LD    B,11
  195.     LD    A,'?'
  196. FLOOP1:    INC    DE        ; Fill FN & FT fields w/"?"
  197.     LD    (DE),A
  198.     DJNZ    FLOOP1        ; ..loop til done
  199.     POP    DE        ; Restore FCB addr
  200.     LD    A,1        ; Do DU: before DIR:
  201.     CALL    ZPRSFN        ; ..do it
  202.  
  203. ; Try to display time and set current year if found w/ZSDOS or DateStamper
  204.  
  205. FLOOPX:    CALL    PRTOD        ; Print Time of Day (NZ ret is Ok)
  206.     JR    NZ,ISZS1    ; ..jump if no clock present w/0FE in A
  207.     LD    A,(BUFF)    ; Else get Current Year
  208. ISZS1:    LD    (CURYR),A    ; ..and save
  209.  
  210. ; Log into DU or DIR
  211.  
  212.     LD    DE,FCB        ; Get file name into FCB, and get user and disk
  213.     CALL    Z3LOG        ; ZCPR3 command line interpretation
  214.  
  215. ; Get and save current user number
  216.  
  217.     CALL    RETUD        ; Get current user and disk
  218.     LD    (SELUD),BC
  219.     LD    A,C        ; ..User to A
  220.     AND    1FH        ; Mask all but user bits
  221.     LD    (AFLG),A    ; current user number
  222.  
  223. ; Transfer default Flag values to working flags
  224.  
  225.     LD    HL,IUSR        ; Move eight default regs..
  226.     LD    DE,UFLG        ; ..to working locations
  227.     LD    BC,8
  228.     LDIR
  229.     LD    C,(HL)        ; Get file attributes (IATT) to C
  230.     LD    A,(AFLG)    ; Get current user number
  231.     OR    C        ; Mask in file attributes
  232.     LD    (AFLG),A    ; ..and save
  233.     XOR    A        ; A=0
  234.     LD    (PFLG),A    ; Set NO Printer output
  235.     INC    A        ; A=1 for console only
  236.     LD    (SCTLFL),A    ; Set switched output flag
  237.  
  238. ; Assume wild file name
  239.  
  240.     LD    HL,FCB+1    ; store '?' chars
  241.     LD    B,11        ; 11 chars
  242.     LD    A,(HL)        ; check for entry specified
  243.     CP    ' '        ; test for space (means no entry)
  244.     JR    Z,FILLQ        ; ..jump to fill if no entry
  245.     CP    OPTCH        ; test for option flag
  246. FILLQ:    LD    A,'?'        ; prep for '?' fill
  247.     CALL    Z,FILLB
  248.  
  249. ; Scan command line for options
  250.  
  251.     CALL    CODEND        ; Pt to first char in buffer
  252.     DEC    HL        ; ..precompensate for search increments
  253. SKIP00:    INC    HL        ; Advance to next char
  254.     LD    A,(HL)        ; Get char
  255.     CP    ' '        ; Is it a space?
  256.     JR    Z,SKIP00    ; ..loop if not to check next
  257.     OR    A        ; end of line?
  258.     JP    Z,ZXDIR        ; ..begin main processing if so
  259.     INC    HL        ; Prepare for option
  260.     CP    OPTCH        ; Is it an Option?
  261.     JR    Z,OPT        ; ..jump to process options if so
  262.     DEC    HL        ; Ok to process for DIR:filename.typ form
  263.  
  264. ; Skip over characters of file name
  265.  
  266. SKIPO1:    LD    A,(HL)        ; Get char
  267.     INC    HL        ; ..point to next
  268.     OR    A        ; Is it the end of string?
  269.     JP    Z,ZXDIR        ; ..jump to run ZX if no options follow
  270.     CP    ' '        ; Is it a space?
  271.     JR    NZ,SKIPO1    ; ..loop if not space
  272.  
  273. ; Scan complete -- look for possible following option char
  274.  
  275. SKIPO2:    LD    A,(HL)        ; Get char
  276.     INC    HL        ; ..point to next
  277.     CP    ' '        ; Is it a space?
  278.     JR    Z,SKIPO2    ; ..loop if so
  279.     CP    OPTCH
  280.     JR    Z,OPT        ; Have option Char, so jump
  281.     DEC    HL        ; Else back up since this is Option Char
  282.  
  283. ; Look for options -- main loop; HL pts to next char
  284.  
  285. OPT:    LD    A,(HL)        ; get option char
  286.     INC    HL        ; pt to next
  287.     LD    (PTR1),HL    ; Save option line ptr
  288.     OR    A        ; end of line?
  289.     JP    Z,ZXDIR        ; begin main processing
  290.     CP    ' '        ; skip over spaces
  291.     JR    Z,OPT
  292.  
  293. ; Scan option table
  294.  
  295.     CP    'O'        ; Output Control
  296.     JR    Z,OPTO
  297.     CP    'S'        ; Sort Order control
  298.     JR    Z,OPTS
  299.     CP    'N'        ; Date/No Date control
  300.     JR    Z,OPTN
  301.     CP    'W'        ; Wide Display control
  302.     JR    Z,OPTW
  303.     CP    'D'        ; Date Display (US/European) control
  304.     JR    Z,OPTD
  305.     CP    'T'        ; Time Stamp method control
  306.     JR    Z,OPTT
  307.     PUSH    AF        ; Save char while we check for Wheel
  308.     LD    A,(WHEEL)
  309.     OR    A
  310.     JR    Z,OPTER0    ; ..jump if user is not a Wheel
  311.     POP    AF        ; Else restore byte and continue
  312.     CP    'P'        ; Print Control
  313.     JR    Z,OPTP
  314.     CP    'U'        ; User Select control
  315.     JR    Z,OPTU
  316.     CP    'A'        ; Attribute Control
  317.     JR    NZ,OPTERR    ; ..list Help if not
  318.             ;..else fall thru
  319.  
  320. ; Option A -- File Attributes
  321.  
  322.     LD    A,(HL)        ; get next option letter
  323.     LD    C,10000000B    ; ..Prepare for non-system
  324.     CP    'N'        ; Non-System files?
  325.     JR    Z,OPTRET
  326.     LD    C,01000000B    ; ..Prepare for System
  327.     CP    'S'        ; System files?
  328.     JR    Z,OPTRET
  329.     LD    C,11000000B    ; ..Prepare for All files
  330.     CP    'A'        ; All files?
  331.     JR    NZ,OPTERR    ; ..jump to Help if Error (not A,N,S)
  332. OPTRET:    LD    A,(AFLG)    ; Else Set File Attribute Options
  333.     AND    00111111B    ; Mask any existing bits
  334.     OR    C        ; mask in sys/non-sys
  335.     LD    (AFLG),A    ; restore flag
  336.     INC    HL        ; pt to next
  337.     JR    OPT
  338.  
  339. ; Option P -- enable it; Printer output
  340.  
  341. OPTP:    LD    A,0FFH        ; ON
  342.     LD    (PFLG),A
  343.     LD    (SCTLFL),A    ; set S-output control
  344.     LD    A,(HL)        ; get possible 2nd letter
  345.     CP    'F'        ; set form feed if F
  346.     JR    NZ,OPT        ; process as next option letter if not F
  347.     INC    HL        ; pt to next
  348.     LD    (PTR1),HL    ; Save current addr
  349. OPTOF:    LD    HL,FFFLG    ; Toggle FF Flag
  350.     DEFB    0DDH        ; Trash IX and fall thru
  351.  
  352. ; Option W -- Wide (create and modify dates) display
  353.  
  354. OPTW:    LD    HL,WFLG        ; Set for user flag
  355.     DEFB    0DDH        ; Trash IX and fall thru
  356.  
  357. ; Option U -- Control User Selection parameter
  358.  
  359. OPTU:    LD    HL,UFLG        ; Set pointer for user flag
  360.     DEFB    0DDH        ; Trash IX and fall thru
  361.  
  362. ; Option S -- Sort Order Selection parameter
  363.  
  364. OPTS:    LD    HL,SFLG        ; Set pointer for Sort order flag
  365.     DEFB    0DDH        ; Trash IX and fall thru
  366.  
  367. ; Option D -- Swap to alternate Date display mode (US/European)
  368.  
  369. OPTD:    LD    HL,DFLG        ; Set pointer for Date Flag
  370.     DEFB    0DDH        ; Trash IX and fall thru
  371.  
  372. ; Option T -- Swap to alternate Time Stamp Method (P2Dos/DateStamper)
  373.  
  374. OPTT:    LD    HL,TFLG        ; Set pointer for TimeStamp Flag
  375.     DEFB    0DDH        ; Trash IX and fall thru
  376.  
  377. ; Option N -- Toggle between prints With Dates and Without Dates
  378.  
  379. OPTN:    LD    HL,NFLG        ; Set pointer for No Date Flag
  380.  
  381. OPFLIP:    LD    A,(HL)        ; Get byte
  382.     CPL
  383.     LD    (HL),A        ; ..and save it again
  384.     LD    HL,(PTR1)    ; Restore buffer pointer
  385.     JP    OPT        ; ..and continue
  386.  
  387. ; Option O -- control Output parameters
  388.  
  389. OPTO:    LD    A,(HL)        ; get 2nd letter
  390.     INC    HL        ; pt to next
  391.     LD    (PTR1),HL    ; Save pointer address
  392.     CP    'F'        ; form feed?
  393.     JR    Z,OPTOF
  394.     CP    'H'        ; horizontal/vertical?
  395.     JR    NZ,OPTERR    ; ..jump to Help on Error (Not F or H)
  396.     LD    HL,HFLG        ; Else flip Horiz/Vert flag
  397.     JR    OPFLIP
  398.  
  399. ;.....
  400. OPTER0:    POP    AF        ; Clear stack for Error entry
  401. OPTERR:    LD    A,1        ; set console only
  402.     LD    (SCTLFL),A    ; set output control flag
  403.     CALL    SPRINT
  404.     DEFB    CR,LF,LF,'Syntax:        ('
  405.     DATE
  406.     DEFB    ' Ver)',CR,LF,'    ',0
  407.     CALL    COMNAM        ;1.66
  408.     CALL    SPRINT        ;1.66
  409.     DEFB    '                - List per Defaults'
  410.     DEFB    CR,LF,'    ',0
  411.     CALL    COMNAM        ;1.66
  412.     CALL    SPRINT        ;1.66
  413.     DEFB    ' //                - Print this message'
  414.     DEFB    CR,LF,'    ',0
  415.     CALL    COMNAM        ;1.66
  416.     CALL    SPRINT        ;1.66
  417.     DEFB    ' /o[o..]            - List per options'
  418.     DEFB    CR,LF,'    ',0
  419.     CALL    COMNAM        ;1.66
  420.     CALL    SPRINT        ;1.66
  421.     DEFB    ' [dir:][fn[.ft]] [/][o[o..]]    - List selected w/opts'
  422.     DEFB    CR,LF,'Options:'
  423.     DEFB    CR,LF,'    Oo - Toggle Output Control Options'
  424.     DEFB    CR,LF,'        ',0
  425.  
  426.     LD    A,(WHEEL)    ; Does user have Wheel privileges?
  427.     OR    A
  428.     JR    Z,OPTER1    ; ..bypass a line if so
  429.  
  430.     CALL    SPRINT
  431.     DEFB    'o=F for Form Feed,  ',0
  432. OPTER1:    CALL    SPRINT
  433.     DEFB    'o=H for Horiz/Vert Format'
  434.     DEFB    CR,LF,'    S  - Toggle Sort (Name/Type or Type/Name)'
  435.     DEFB    CR,LF,'    N  - Toggle No-Date/Date display'
  436.     DEFB    CR,LF,'    W  - Wide display with both Create/Modify Dates'
  437.     DEFB    CR,LF,'    D  - Display Date in alternate form'
  438.     DEFB    CR,LF,'    T  - Use alternate (P2Dos/DateStamper) Stamps',0
  439.  
  440.     LD    A,(WHEEL)    ; Does user have Wheel privileges?
  441.     OR    A
  442.     JP    Z,RETURN    ; ..exit if not, Else fall thru..
  443.  
  444.     CALL    SPRINT
  445.     DEFB    CR,LF,'    Aa - Set and Display of file attributes'
  446.     DEFB    CR,LF,'        a=S for System,  a=N for Non-System'
  447.     DEFB    CR,LF,'        a=A for All Files (System and Non-System)'
  448.     DEFB    CR,LF,'    U  - Toggle User select (Current or All)'
  449.     DEFB    CR,LF,'    P  - Send display to Printer'
  450.     DEFB    CR,LF,'    PF - Same as POF'
  451.     DEFB    CR,LF,0
  452. RETURN:    CALL    DINIT        ; De-initialize the Terminal
  453.     LD    BC,(ENTRUD)    ; Get entry DU
  454.     CALL    LOGUD        ; ..and restore
  455.     LD    SP,(STACK)    ; get old stack ptr
  456.     RET            ; return to Dos
  457.  
  458. ;.....
  459. ;1.66 Print name by which invoked or default name
  460.  
  461. COMNAM:    LD    A,(Z3EADR+1)    ;1.66 Get high byte of ENV
  462.     OR    A        ;1.66 Anything there?
  463.     JP    NZ,PRTNAME    ;1.66 ..jump to print "real" name if so
  464.     CALL    SPRINT        ;1.66 Else print default name
  465.     DEFB    'ZXD',0        ;1.66
  466.     RET            ;1.66
  467.  
  468. ;.....
  469. ; Memory Overflow Error
  470.  
  471. MEMERR:    CALL    SPRINT
  472.     DEFB    '- TPA Overflow -',0
  473.     JR    RETURN
  474.  
  475. ;================================================================
  476. ; ..Begin ZX processing
  477.  
  478. ZXDIR:    LD    DE,FCB        ; Point to the File Control Block
  479.  
  480. ; Check for Print Option and Print New Line if so
  481.  
  482.     LD    A,(PFLG)    ; printer output?
  483.     OR    A        ; 0ffH=yes
  484.     CALL    NZ,LCRLF    ; new line
  485.  
  486. ; Get Files from Disk
  487.  
  488.     CALL    DPARAM        ; get disk parameters for DFREE
  489.     LD    BC,(SELUD)
  490.     CALL    LOGUD
  491.     LD    A,(TFLG)    ; Which mode of Stamps do we want?
  492.     AND    00000001B    ; ..(keeping only LSB)
  493.     LD    C,A        ; ..(Set search flag as well)
  494.     LD    A,(SFLG)    ; AND B7 of Sort Order Flag
  495.     AND    10000000B
  496.     OR    C        ; ..with Time Stamp Method
  497.     LD    C,A
  498.     LD    HL,(BUFFER)    ; Pt to free space
  499.     LD    A,(UFLG)    ; get users flag
  500.     AND    20H        ; mask for user select bit (0=name/type)
  501.     LD    B,A
  502.     LD    A,(AFLG)    ; get attributes flag
  503.     OR    B        ; mask in grouping bit
  504.     PUSH    DE        ; Save the FCB Pointer
  505.     CALL    DDIRQS        ; quick directory load with file sizes
  506.     LD    (FIRSTF),DE    ; Store the start of pointer table
  507.     POP    DE        ; ..and restore FCB pointer
  508.     JR    Z,MEMERR    ; memory overflow error?
  509.     LD    (FCOUNT),BC    ; save file count
  510.     LD    (COUNTF),BC    ; save file down count
  511.     CALL    GETDOS        ; Get the Dos Version in operation
  512.     LD    A,(DOSTYP)
  513.     CP    'S'        ; Is it ZSDOS?
  514.     JR    NZ,DOCPMS    ; ..to CP/M sizing way if not
  515.     LD    A,(DOSVER)
  516.     CP    20H        ; Is the Version # >= 2.0?
  517.     JR    C,DOCPMS    ; ..do CP/M sizing way if < 2.0
  518.     LD    DE,BUFF        ; Else this is ZSDOS2
  519.     LD    C,26        ; Set DMA to Default Buffer
  520.     CALL    BDOS
  521.     LD    A,(SELUD+1)    ; Get Desired drive
  522.     LD    E,A
  523.     LD    C,46
  524.     CALL    BDOS        ; Get Free space in K in BUFF..BUFF+3
  525.     LD    A,(BUFF+2)    ; Get third byte in Size
  526.     LD    (FREESZ+2),A    ; Save Byte 3
  527.     LD    DE,(BUFF)    ; .get bytes 1 and 2
  528.     JR    DOCPMT        ; ..and rejoin code
  529.  
  530. DOCPMS:    CALL    DFREE        ; compute amount of free space on disk
  531. DOCPMT:    LD    (FREESZ),DE    ; save 16-bits of free space count
  532.     LD    DE,0000        ; set file size counter
  533.     LD    (TOTSIZ),DE    ; save counter
  534.     XOR    A        ; Clear third byte of size too
  535.     LD    (TOTSIZ+2),A
  536.     LD    A,(PFLG)    ; set temp flag
  537.     LD    (PFLGT),A
  538.  
  539.     LD    HL,PFLGS    ; Address Save Flags location
  540.     LD    A,(PFLG)    ; save printer output flag
  541.     LD    (HL),A        ; ..in Save locn
  542.     DEC    HL        ; Point to PFLGT
  543.     LD    A,(HL)        ; Use Temp Flag
  544.     LD    (PFLG),A    ; ..in Real pointer
  545.     LD    (HL),00        ; ...and clear Temp Flag
  546.  
  547. ; Check for any files
  548.  
  549.     LD    HL,(COUNTF)    ; get file down count
  550.     LD    A,H        ; any files?
  551.     OR    L
  552.     JP    Z,NFMSG        ; ..jump to No Files message if Not
  553.  
  554. ; Everything set up now.  Set flag for number of columns in display
  555.  
  556.     LD    A,(NFLG)    ; Are we listing Without Dates?
  557.     LD    B,3
  558.     OR    A
  559.     JR    NZ,ZX2A        ; ..jump to set 3 cols if so
  560.     LD    A,(WFLG)    ; Are we listing both dates?
  561.     DEC    B
  562.     OR    A
  563.     JR    Z,ZX2A        ; ..jump to set 2 cols if Not
  564.     DEC    B        ; Else set to 1 col
  565. ZX2A:    LD    A,B        ; Get the number
  566.     LD    (NCOLS),A    ; ..and Store
  567.  
  568. ; This is the main looping entry point for each screen display
  569. ; Display the Screen Header Information
  570.  
  571. ZX6:    CALL    SCRLF        ; specific user selected
  572.     CALL    STNDOUT        ; ..Give some video highlighting
  573.     LD    A,(NCOLS)    ; Get number of columns
  574.     LD    B,A        ; ..and put in Reg
  575.     PUSH    BC        ; Save count for second header line
  576. DOHDR0:    LD    A,(UFLG)    ; Display all User Areas?
  577.     LD    HL,HDR1        ; ..prepare for a Yes
  578.     OR    A        ; Z=no
  579.     JR    NZ,DOHDR1    ; ..jump if so
  580.     LD    HL,HDR1A
  581. DOHDR1:    CALL    SPSTR        ; Print Header Text Entry
  582.     LD    A,(NCOLS)    ; Get Number of Columns in listing
  583.     LD    HL,HDR1B    ; ..prepare for both dates
  584.     CP    2        ; Are we printing with just Modified?
  585.     JR    C,DOHDR2    ; ..jump if both dates
  586.     JR    NZ,DOHDR7    ; ...or here if No dates
  587.     LD    HL,HDR1C    ; Else set for just Modified dates
  588. DOHDR2:    CALL    SPSTR        ; Print Date Entries
  589. DOHDR7:    CALL    HDRSEP        ; Print Header separator if required
  590.     DEC    B        ; More entries?
  591.     INC    B
  592.     JR    NZ,DOHDR0    ; ..loop if more than 1 column entry
  593.  
  594.     CALL    STNDEND        ; Turn Highlighting off for new line
  595.     POP    BC        ; Restore for second header line
  596.     CALL    SCRLF        ; ..and advance to next line
  597.     CALL    STNDOUT        ; Turn Highlighting on for new line
  598.  
  599. DOHDR3:    LD    A,(UFLG)    ; Are we printing all User Areas?
  600.     LD    HL,HDR2        ; ..prepare for a Yes
  601.     OR    A        ; Z=no
  602.     JR    NZ,DOHDR4    ; ..jump if so
  603.     LD    HL,HDR2A
  604. DOHDR4:    CALL    SPSTR        ; Print Header Text Entry
  605.     LD    A,(NCOLS)    ; Get Number of Columns in listing
  606.     LD    HL,HDR2B    ; ..prepare for Yes
  607.     CP    2        ; Are we printing with just Modified?
  608.     JR    C,DOHDR5    ; ..jump if both dates
  609.     JR    NZ,DOHDR6    ; ...or here if No dates
  610.     LD    HL,HDR2C    ; Else set for just Modified dates
  611. DOHDR5:    CALL    SPSTR        ; Print Date Entries
  612. DOHDR6:    CALL    HDRSEP        ; Print Header separator if required
  613.     DEC    B        ; More entries?
  614.     INC    B
  615.     JR    NZ,DOHDR3    ; ..loop if more than 1 column entry
  616.     CALL    STNDEND        ; End Reverse video
  617.  
  618. ; Prepare Columnar Output
  619.  
  620.     LD    A,(PFLGS)    ; restore print flag
  621.     LD    (PFLG),A
  622.     LD    DE,MAXENT/2    ; Calculate # of entries
  623.     LD    HL,0
  624.     LD    A,(NCOLS)    ; Get number of cols in display
  625.     LD    B,A
  626. ZX6B:    ADD    HL,DE        ; Add in # Entries per column
  627.     DJNZ    ZX6B        ; ..loop til done
  628.     EX    DE,HL        ; Put result in DE
  629.     LD    HL,(COUNTF)    ; Get file count Remaining
  630.     CALL    COMPHD        ; check for HL > DE
  631.     JR    NC,ZX7        ; subtract entries to print from total entries
  632.     LD    D,H        ; DE=HL=number of entries to print
  633.     LD    E,L
  634. ZX7:    XOR    A        ; subtr entries to print (DE) from total (HL)
  635.     SBC    HL,DE        ; HL=result
  636.     LD    (COUNTF),HL    ; save new down count
  637.     LD    B,H        ; BC=count
  638.     LD    C,L
  639.     LD    HL,(FIRSTF)    ; Point to First Record Pointer
  640.  
  641. ; At this point, BC=number of remaining entries, DE=number of entries to
  642. ;   print, and HL pts to first entry to print
  643.  
  644.     LD    (PTR1),HL    ; Save ptr to 1st entry
  645.     LD    A,(HFLG)    ; Are we listing horizontally?
  646.     LD    B,A
  647.     LD    A,(WFLG)    ; ..or showing Wide Display?
  648.     OR    B
  649.     JR    NZ,ZX7C        ; ..jump if either and don't worry about cols
  650.     PUSH    DE        ; save count
  651.  
  652.     LD    A,(NFLG)    ; Are we listing with No Dates?
  653.     OR    A
  654.     JR    Z,ZX70        ; ..jump if listing Dates
  655.     CALL    DIVDE3        ; Else div DE by 3, result * 2 in BC, A = Rem
  656.     JR    ZX72        ; ..and rejoin code
  657.  
  658. ; Divide DE by 2, result * 2 in BC (Ptr size), remainder in A
  659.  
  660. ZX70:    SRL    D        ; divide by 2
  661.     RR    E
  662.     LD    A,0        ; Get remainder in A
  663.     ADC    A,A
  664.     PUSH    HL        ; Preserve HL
  665.     LD    L,E        ; Copy result to HL
  666.     LD    H,D
  667.     ADD    HL,HL        ; Double for 2-byte ptrs
  668.     LD    C,L        ; ..and put result in BC
  669.     LD    B,H
  670.     POP    HL
  671.  
  672. ZX72:    ADD    HL,BC        ; Add offset (in BC) to 2nd Col Start
  673.     OR    A        ; Any remainder?
  674.     JR    Z,ZX7A        ; ..skip if none
  675.     INC    HL        ; Else advance 1 Ptr to next entry
  676.     INC    HL
  677. ZX7A:    LD    (PTR2),HL    ; ..Save ptr to Col 2
  678.     ADD    HL,BC        ; Add offset (in BC) to 3rd Col Start
  679.     CP    2        ; If remainder 2, advance one more Ptr
  680.     JR    C,ZX7B
  681.     INC    HL
  682.     INC    HL
  683. ZX7B:    LD    (PTR3),HL    ; ..Save ptr to Col 3
  684.     POP    DE        ; Get count back in DE
  685.  
  686. ; Main entry print routine
  687.  
  688. ZX7C:    LD    D,1        ; set Columns counter to initial value
  689. ZX8:    LD    HL,(PTR1)    ; Pt to first entry
  690.     CALL    PRENTRY        ; Print entry
  691.     LD    (PTR1),HL    ; Put pointer
  692.     LD    A,(WFLG)    ; Wide print?
  693.     OR    A
  694.     JR    NZ,ZX9        ; ..jump if so
  695.     LD    A,(HFLG)    ; Horizontal Display?
  696.     OR    A
  697.     JR    Z,ZX8A        ; ..jump if Not
  698.     DEC    D        ; Last entry in line?
  699.     CALL    NZ,SP2        ; ..print 2 spaces if so
  700.     INC    D        ; ...correct counter
  701.     JR    ZX9        ; Continue below
  702.  
  703. ZX8A:    DEC    E        ; count down
  704.     JR    Z,ZX10
  705.     LD    HL,(PTR2)    ; get ptr
  706.     CALL    PRENTSP        ; Print entry with 2 leadin spaces
  707.     LD    (PTR2),HL    ; put ptr
  708.     LD    A,(NFLG)    ; Are we listing with No Dates?
  709.     OR    A
  710.     JR    Z,ZX9        ; ..jump if listing Dates
  711.     DEC    E        ; Count down
  712.     JR    Z,ZX10        ; ..jump exit if done with screen
  713.     LD    HL,(PTR3)    ; Get ptr to 3rd list
  714.     CALL    PRENTSP        ; ..and list
  715.     LD    (PTR3),HL    ; Save ptr
  716. ZX9:    DEC    E        ; count down
  717.     JR    NZ,ZX8        ; continue if not zero
  718.     LD    (FIRSTF),HL    ; Save ptr to next set of entries to print
  719.     LD    HL,(COUNTF)    ; get count of remaining entries
  720.  
  721. ; At this point, HL=number of entries left
  722.  
  723.     LD    A,H        ; anything left?
  724.     OR    L
  725.     JR    Z,ZX10
  726.     LD    A,(PFLG)    ; printer output?
  727.     OR    A        ; 0=no
  728.     JP    NZ,ZX6
  729.     CALL    SPRINT        ; screen break
  730.     DEFB    CR,LF,'[more] ',0
  731.     CALL    CIN        ; get response
  732.     CP    3        ; abort?
  733.     JP    Z,RETURN
  734.     JP    ZX6        ; new screen display
  735.  
  736. ; No files were found.  Print message and fall thru to exit stats
  737.  
  738. NFMSG:    CALL    SPRINT        ; print everywhere
  739.     DEFB    CR,LF,'-- No files --',0
  740.             ;..fall thru..
  741.  
  742. ; Print end statistics and exit
  743. ; Print DU
  744.  
  745. ZX10:    CALL    SCRLF        ; Print everywhere
  746.     CALL    SP2        ; Give some space
  747.     CALL    RETUD        ; Get current disk
  748.     LD    A,B
  749.     ADD    A,'A'        ; convert to ASCII
  750.     CALL    SOUT        ; print everywhere
  751.     LD    A,(UFLG)    ; Are we printing all users?
  752.     OR    A
  753.     PUSH    AF
  754.     LD    A,C
  755.     CALL    Z,SAFDC        ; ..print user # if not
  756.     LD    A,':'
  757.     CALL    SOUT        ; Print Colon
  758.     POP    AF
  759.     JR    NZ,ZX11        ; Jump if printing all users
  760.     CALL    DUTDIR        ; Convert to DIR form
  761.     JR    Z,ZX11        ; ..bypass if error
  762.  
  763.     LD    B,8        ; Print DIR name
  764. DIROUT:    LD    A,(HL)        ; get char
  765.     CP    ' '        ; don't print spaces
  766.     CALL    NZ,SOUT
  767.     INC    HL        ; pt to next
  768.     DJNZ    DIROUT
  769.  
  770. ; Print Selected File Statistics
  771.  
  772. ZX11:    CALL    SPRINT
  773.     DEFB    ' -- ',0
  774.     LD    HL,(FCOUNT)    ; print file count
  775.     XOR    A        ; .dummy a 3-byte value
  776.     CALL    PRBIG        ; ..and use common routine
  777.     CALL    SPRINT
  778.     DEFB    ' Files Using ',0
  779.     LD    HL,(TOTSIZ)    ; Get total of file sizes
  780.     LD    A,(TOTSIZ+2)    ; ..including 3rd byte
  781.     CALL    PRBIG        ; Print it everywhere
  782.     CALL    SPRINT
  783.     DEFB    'K',0
  784.  
  785. ; Print Space Remaining on Disk
  786. ;  Entry Point if No Files Found
  787.  
  788.     CALL    SPACE
  789.     CALL    STNDOUT        ; Highlight this
  790.     LD    A,'('
  791.     CALL    SOUT
  792.     LD    HL,(FREESZ)    ; Get amount of free space
  793.     LD    A,(FREESZ+2)
  794.     CALL    PRBIG        ; Print it everywhere
  795.     CALL    SPRINT
  796.     DEFB    'K Free)',0
  797.     CALL    STNDEND
  798.     LD    A,(PFLG)    ; new line if printer output
  799.     OR    A
  800.     JP    Z,RETURN
  801.     CALL    SCRLF        ; new line for printer
  802.     LD    A,(PFLG)    ; print output
  803.     LD    B,A
  804.     LD    A,(FFFLG)    ; form feed
  805.     AND    B        ; if print and form feed ... NZ is set
  806.     LD    A,FF        ; form feed char
  807.     CALL    NZ,LOUT        ; form feed to printer
  808.     JP    RETURN
  809.  
  810. ;********* General Utility Routines ********
  811.  
  812. ; Print one or two spaces
  813.  
  814. SP2:    LD    A,' '
  815.     CALL    SOUT
  816. SPACE:    LD    A,' '
  817.     JP    SOUT
  818.  
  819. ;.....
  820. ; Print BCD digits as two ASCII digits
  821. ; ENTER: BCD digits in A
  822.  
  823. OUTBCD:    PUSH    AF
  824.     RRA
  825.     RRA
  826.     RRA
  827.     RRA
  828.     CALL    PT1
  829.     POP    AF
  830. PT1:    AND    0FH
  831.     ADD    A,'0'
  832.     JP    SOUT
  833.  
  834. ;.....
  835. ; Print B chars pted to by HL
  836.  
  837. PRCH:    LD    A,(HL)        ; get char
  838.     INC    HL        ; pt to next
  839.     BIT    7,A        ; Check MSB, print lowercase if set
  840.     JR    Z,PRCH0
  841.     AND    7FH        ; Mask out MSB
  842.     CP    'A'        ; Convert char to Lower case
  843.     JR    C,PRCH2        ; ..jump if less than "A"
  844.     CP    'Z'+1        ; Greater than "Z"?
  845.     JR    NC,PRCH2    ; ..jump if so
  846.     OR    20H        ; Else Make lowercase Alpha char
  847. PRCH2:    CP    ' '        ; Within printable range?
  848.     JR    NC,PRCH3    ; ..jump if so
  849.     LD    A,'?'
  850. PRCH3:    SET    7,A        ; Set MSB again
  851.     JR    PRCH1
  852.  
  853. PRCH0:    CP    ' '        ; Within printable range?
  854.     JR    NC,PRCH1    ; ..jump to print if so
  855.     LD    A,'?'        ; Print "?" if not valid char
  856. PRCH1:    BIT    7,A        ; Is MSB Set?
  857.     PUSH    AF
  858.     CALL    NZ,STNDOUT    ; ..set reverse video if so
  859.     POP    AF
  860.     PUSH    AF
  861.     AND    7FH        ; ...and mask MSB
  862.     CALL    SOUT        ; Print it
  863.     POP    AF
  864.     CALL    NZ,STNDEND    ; ..set normal video if so
  865.     DJNZ    PRCH        ; ..and loop til done
  866.     RET
  867.  
  868. ;.....
  869. ; Print individual file entry per established flags: UFLG, NFLG, WFLG, DFLG
  870. ; Enter: HL --> Addresses element in sorted DDIRQS entry
  871. ;      D = Number of entries per line remaining
  872. ;      E = Number of entries remaining until end or screen break
  873. ; Exit : HL --> Start of Next entry
  874. ;      D = # entries/line remaining + 1
  875. ;      E = Unaffected
  876.  
  877. PRENTSP: CALL    SP2        ; Print entry with 2 leading spaces
  878. PRENTRY: DEC    D        ; Count <CRLF> counter
  879.     JR    NZ,PRFENT
  880.     LD    A,(NCOLS)    ; Get count of columns
  881.     LD    D,A        ; ..and Reset Count
  882.     CALL    SCRLF
  883.  
  884. ; Print a single file entry
  885.  
  886. PRFENT:    LD    (ENTPT0),hl    ; Save entry pointer to Ptr Table
  887.     LD    A,(HL)        ; Get Record Addr pointed to
  888.     INC    HL
  889.     LD    H,(HL)
  890.     LD    L,A        ; We now point to Record
  891.     LD    (ENTPTR),HL    ; ..and Save
  892.     LD    A,(UFLG)    ; Are we to print all users?
  893.     OR    A
  894.     JR    Z,PREN1A    ; ..jump if not
  895.     LD    A,(HL)        ; If so, get user #
  896.     AND    1FH        ; ..mask other bits
  897.     CALL    SADC        ; Print user #
  898.     LD    A,':'        ; ..and colon separator
  899.     CALL    SOUT
  900. PREN1A:    INC    HL        ; Pt to first char of File Name
  901.     LD    B,8        ; ..print 8 chars
  902.     CALL    PRCH
  903.     LD    A,'.'        ; Print dot
  904.     CALL    SOUT
  905.     LD    B,3        ; Print 3 chars
  906.     CALL    PRCH
  907.     PUSH    DE        ; save Counts
  908.     PUSH    HL        ; ..and pointer
  909.     LD    HL,(ENTPTR)    ; Restore Ptr to entry
  910.     CALL    FSIZE        ; compute file size
  911.     LD    HL,(TOTSIZ)    ; Get total file size counter
  912.     LD    A,(TOTSIZ+2)    ; ..including 3rd byte
  913.     ADD    HL,DE        ; Add in new file
  914.     ADC    A,0        ; ..into 3rd byte
  915.     LD    (TOTSIZ),HL    ; Save new total file size counter
  916.     LD    (TOTSIZ+2),A    ; ..for 3 bytes
  917.     EX    DE,HL        ; Get file size into HL
  918.     CALL    SHLDC        ; ..and print (HL) value in decimal
  919.     LD    A,'k'
  920.     CALL    SOUT
  921.     POP    HL        ; pt to Extent
  922.     LD    BC,4        ; ..offset to date/time fields
  923.     ADD    HL,BC
  924.     LD    A,(NFLG)    ; Are we printing Dates?
  925.     OR    A
  926.     LD    BC,ESIZE-FNSIZE    ; ..(set offset to next entry in case not)
  927.  
  928.     CALL    Z,PRDDAT    ; Print date entry(s) if Not NFLG
  929.  
  930.     POP    DE        ; Restore counters
  931.     LD    HL,(ENTPT0)    ; Get entry pointer
  932.     INC    HL        ; .advance
  933.     INC    HL        ; ..to next entry
  934.     LD    A,(UFLG)    ; Are we working with all users?
  935.     OR    A
  936.     RET    NZ        ; ..return if So
  937.     DEC    D        ; Last entry in line?
  938.     CALL    NZ,SPACE    ; ..Print a space if not
  939.     INC    D
  940.     RET
  941.  
  942. ;.....
  943. ; Print appropriate separator based on value of DFLG (US/European)
  944.  
  945. PRSEP:    LD    A,(DFLG)
  946.     OR    A        ; Get separator for Date
  947.     LD    A,'.'        ; ..set European for default
  948.     JR    NZ,EUR1        ; Jump if European
  949.     LD    A,'/'
  950. EUR1:    JP    SOUT
  951.  
  952. ;.....
  953. ; Print Date field in display in "  HH:MM-DD.MM.YY" or "  HH:MM-MM/DD/YY"
  954. ;   form depending on USEUR flag.
  955. ; Enter: HL --> Created time field of sorted DDIRQS Directory list
  956. ;    <WFLG> = 0 if just Modified desired, FF for both Create and Modified
  957.  
  958. PRDDAT:    LD    A,(WFLG)    ; Check for Wide Display
  959.     LD    B,3        ; ..preset for 3 Date entries
  960.     OR    A
  961.     JR    NZ,DATTIM    ; jump if both dates
  962.     DEC    B        ; ..else just one..
  963.     DEC    B
  964.     LD    DE,10
  965.     ADD    HL,DE        ; ..and offset to modified
  966. DATTIM:    PUSH    BC        ; Save pass counter
  967.     CALL    SP2        ; ..and give some space
  968.     LD    A,(HL)        ; Get Years byte
  969.     INC    HL        ; ..advance to Month field
  970.     OR    (HL)        ; "Or" Years and Months
  971.     JR    NZ,DATTI0    ; ..jump to print if Ok
  972.     LD    A,(WFLG)    ; Are we printing wide?
  973.     OR    A
  974.     JR    NZ,NULDAT    ; ..jump to Null date if so
  975.     DEC    HL        ; Else back up to field start
  976.     PUSH    HL        ; Save regs
  977.     PUSH    BC
  978.     EX    DE,HL        ; Put Mod date addr in DE
  979.     LD    HL,-10        ; Back up to Create date
  980.     ADD    HL,DE
  981.     LD    BC,5
  982.     LDIR            ; Copy Create to Modify
  983.     POP    BC
  984.     POP    HL
  985.     LD    A,(HL)        ; Check for validity
  986.     INC    HL
  987.     OR    (HL)
  988.     JR    Z,NULDAT    ; ..print blank field if no date stamp
  989.  
  990. DATTI0:    PUSH    HL        ; Save Ptr to Month
  991.     INC    HL        ; ..and advance to Hours
  992.     INC    HL
  993.     BIT    7,(HL)        ; Is it a Relative count?
  994.     JR    NZ,TIME0    ; ..jump if so
  995.     CALL    PR2DIG        ; Else Print 2-digit time
  996.     JR    TIME1        ; ..and continue below
  997.  
  998. TIME0:    CALL    PRREL        ; Print Relative time
  999. TIME1:    LD    A,'-'        ; Separate Time from Date
  1000.     CALL    SOUT
  1001.     POP    HL        ; Restore ptr to Month
  1002.  
  1003.     LD    A,(DFLG)    ; US or Eur formats?
  1004.     OR    A
  1005.     JR    NZ,EUR0        ; ..jump if European format
  1006. EUR2:    LD    A,(HL)
  1007.     CALL    OUTBCD        ; Print BCD digits for Month
  1008.     LD    A,(DFLG)
  1009.     OR    A        ; Get separator for Date
  1010.     JR    NZ,PRYEAR    ; ..and jump to year if European
  1011.     CALL    PRSEP        ; Else print appropriate separator
  1012.  
  1013. EUR0:    INC    HL        ; Advance to Day
  1014.     LD    A,(HL)
  1015.     DEC    HL        ; Back up to Month
  1016.     CALL    OUTBCD        ; Print BCD digits for Day
  1017.     LD    A,(DFLG)
  1018.     OR    A        ; Get separator for Date
  1019.     PUSH    AF
  1020.     CALL    NZ,PRSEP    ; Print Seperator if Not current year
  1021.     POP    AF
  1022.     JR    NZ,EUR2        ; ..and jump if European form for Month
  1023.  
  1024. PRYEAR:    DEC    HL        ; Back up from Month to Year
  1025.     LD    A,(BLNKYR)    ; Blank current Year?
  1026.     OR    A
  1027.     JR    Z,PRYEA0    ; ..jump if not
  1028.     LD    A,(CURYR)    ; Get current year
  1029.     CP    (HL)        ; Is this file from the same year?
  1030.     JR    NZ,PRYEA0    ; ..jump if not
  1031.     CALL    SP2        ; Else fill in with spaces
  1032.     CALL    SPACE
  1033.     JR    PRYEA1
  1034.  
  1035. PRYEA0:    CALL    PRSEP        ; Not current year, print seperator
  1036.     LD    A,(HL)
  1037.     CALL    OUTBCD        ; Print Year BCD digits
  1038. PRYEA1:    LD    BC,5        ; Offset to after current date field
  1039.     ADD    HL,BC
  1040.     POP    BC
  1041.     DJNZ    DATTIM        ; ..loop for second date if necessary
  1042.     RET
  1043.  
  1044. ; Print Date and Time field as all spaces for Null date
  1045.  
  1046. NULDAT:    LD    B,14        ; 14 for entry
  1047. NULDA0:    CALL    SPACE        ; Print a space
  1048.     DJNZ    NULDA0
  1049.     DEC    HL        ; Back up to Year byte
  1050.     JR    PRYEA1        ; Exit thru above code
  1051.  
  1052. ;.....
  1053. ; Read and Print Time of day in default form as indicated by USEUR flag
  1054.  
  1055. PRTOD:    CALL    SPRINT        ; Give some space
  1056.     DEFB    '      ',0
  1057.     LD    HL,BUFF        ; Read time here
  1058.     CALL    RCLOCK        ; ..using Library routine
  1059.     RET    NZ        ; Return if Invalid Clock
  1060. PRTOD1:    CALL    STNDOUT        ; Print it in reverse video
  1061.     LD    A,(BUFF+2)    ; Get Day
  1062.     CALL    OUTBCD        ; ..and print
  1063.     CALL    SPACE        ; Space off one
  1064.  
  1065.     LD    A,(BUFF+1)    ; Get Month
  1066.     CP    10H        ; See if >SEPT
  1067.     JR    C,PRDMJ0
  1068.     SUB    6        ; If so, Get rid of BCD bias
  1069. PRDMJ0:    LD    E,A
  1070.     LD    D,0        ; Put month in DE
  1071.     LD    HL,MONTHS-3
  1072.     ADD    HL,DE
  1073.     ADD    HL,DE
  1074.     ADD    HL,DE        ; Index into month table
  1075.     LD    B,3
  1076. PRDMJL:    LD    A,(HL)
  1077.     INC    HL
  1078.     CALL    SOUT
  1079.     DJNZ    PRDMJL
  1080.     CALL    SPACE        ; Space off one
  1081.  
  1082.     LD    A,(BUFF)
  1083.     PUSH    AF
  1084.     CP    78H        ; See which century (78-99 are 19xx)
  1085.     LD    A,20H        ; ..(00-77 are 20xx)
  1086.     JR    C,PRDMJ1    ; If 21st
  1087.     LD    A,19H
  1088. PRDMJ1:    CALL    OUTBCD        ; Print prefix
  1089.     POP    AF
  1090.     CALL    OUTBCD        ; Now last two digits
  1091.     CALL    SP2        ; Separate time from date
  1092.     LD    HL,BUFF+3    ; Point to Hours
  1093.     BIT    7,(HL)        ; ..MSB Set for Relative time
  1094.     JR    NZ,PRREL    ; Use different print routine for rel time
  1095.     LD    A,(HL)        ; Get Hours
  1096.     INC    HL
  1097.     CALL    OUTBCD        ; Output hour
  1098.     LD    A,':'
  1099.     CALL    SOUT        ; Separate with a colon
  1100.     CALL    PR2DIG        ; ..then print minutes & seconds
  1101.     CALL    STNDEND        ; Turn off reverse vid
  1102.     XOR    A        ; Insure Zero flag set
  1103.     RET            ; ..and return
  1104.  
  1105. PR2DIG:    LD    A,(HL)        ; Get Minutes
  1106.     INC    HL
  1107.     CALL    OUTBCD        ; ..and output
  1108.     LD    A,':'
  1109.     CALL    SOUT        ; Separate with a colin
  1110.     LD    A,(HL)        ; Get Seconds
  1111.     CALL    OUTBCD        ; ..and output
  1112.     RET
  1113.  
  1114. ; Print Relative Stamp
  1115.  
  1116. PRREL:    LD    A,'+'
  1117.     CALL    SOUT        ; Prefix with a +
  1118.     LD    D,(HL)
  1119.     RES    7,D        ; Clear Rel count flag for dsp
  1120.     INC    HL
  1121.     LD    E,(HL)        ; Get Rel count
  1122.     EX    DE,HL        ; Put count in HL
  1123.     LD    DE,-1000
  1124.     CALL    SUBTR
  1125.     LD    DE,-100
  1126.     CALL    SUBTR
  1127.     LD    DE,-10
  1128.     CALL    SUBTR
  1129.     LD    A,L        ; Remainder
  1130.     ADD    A,'0'        ; Ascii bias
  1131.     CALL    SOUT        ; Display
  1132.     XOR    A        ; Ensure Zero Set when returning
  1133.     RET
  1134.  
  1135. SUBTR:    LD    C,'0'-1        ; Ascii count
  1136. SUBT2:    INC    C
  1137.     ADD    HL,DE        ; Really subtract
  1138.     JR    C,SUBT2        ; Keep going
  1139.     SBC    HL,DE        ; One too many,add back
  1140.     LD    A,C        ; Ascii count
  1141.     JP    SOUT        ; Else display
  1142.  
  1143. MONTHS:    DEFB    'JanFebMarAprMayJunJulAugSepOctNovDec'
  1144.  
  1145. ;.....
  1146. ; Dummy routine to use DOS IO instead of BIOS IO
  1147.  
  1148. COUT:    JP    BOUT        ; Use DOS character output
  1149.  
  1150. ;.....
  1151. ; Print separator spaces between header entries
  1152.  
  1153. HDRSEP:    LD    HL,SPCS        ; Point to three spaces
  1154.     LD    A,(UFLG)    ; Are we printing all user areas?
  1155.     OR    A
  1156.     JR    Z,HDRSE0    ; ..jump if not
  1157.     INC    HL        ; Else advance for just 2 spaces
  1158. HDRSE0:    DEC    B        ; Count down entries
  1159.     CALL    NZ,SPSTR    ; Print if Not last entry
  1160.     RET
  1161.  
  1162. ;.....
  1163. ; Header strings used for formatting
  1164.  
  1165. HDR1:    DEFB    ' UU '
  1166. HDR1A:    DEFB    'Filename.Typ  Size',0
  1167.  
  1168. HDR2:    DEFB    ' -- '
  1169. HDR2A:    DEFB    '-------- ---  ----',0
  1170.  
  1171. HDR1B:    DEFB    '     Created    '
  1172.     DEFB    '    Last Access '
  1173. HDR1C:    DEFB    '     Modified   ',0
  1174.  
  1175. HDR2B:    DEFB    '     -------    '
  1176.     DEFB    '    ---- ------ '
  1177. HDR2C:    DEFB    '     --------   ',0
  1178.  
  1179. SPCS:    DEFB    '   ',0
  1180.  
  1181. ;.....
  1182. ; Divide DE by 3 and Return:  BC = Result * 2 (ptr size);  A = Remainder
  1183.  
  1184. DIVDE3:    PUSH    HL
  1185.     LD    D,0        ; Make sure D=0
  1186.     LD    A,E        ; Value to A
  1187. DIVD31:    SUB    3
  1188.     JR    C,DIVD32    ; Jump if too much
  1189.     JR    Z,DIVD33    ; ..or exactly
  1190.     INC    D        ; Add 1 to Result
  1191.     JR    DIVD31
  1192.  
  1193. DIVD32:    ADD    A,3        ; Add back for underflow
  1194.     DEC    D        ; (prepare for next INC)
  1195. DIVD33:    INC    D        ; Add 1 for even division
  1196.     LD    E,D        ; Prepare for 16-bit Add
  1197.     LD    D,0
  1198.     LD    L,E        ; Copy the result to HL
  1199.     LD    H,D
  1200.     ADD    HL,HL        ; ..and double for Pointer size (2 bytes)
  1201. DIVD36:    LD    B,H        ; BC is result
  1202.     LD    C,L
  1203.     POP    HL        ; Restore regs
  1204.     RET
  1205.  
  1206. ;.....
  1207. ; Print Sizes in decimal with provisions for 3-byte values up to 999,999
  1208. ; Enter: A,H,L contains 24-bit value to print
  1209. ; Exit : None.  Value printed as up to 6 decimal digits
  1210.  
  1211. PRBIG:    LD    E,A        ; Save MSB
  1212.     XOR    A        ; Set flag for no digits yet
  1213.     LD    (BIGFLG+1),A    ; ..and save
  1214.     LD    A,E        ; Restore flag
  1215.     LD    DE,86A0H    ; 100,000 = 0186A0H, set lower 2 bytes
  1216.     LD    B,01        ; ..and MSB
  1217.     CALL    DIVBIG        ; Divide and print
  1218.     LD    DE,10000    ; Set 10k lower 2 bytes
  1219.     LD    B,0        ; and MSB
  1220.     CALL    DIVBIG        ; Divide and print
  1221. BIGFLG:    LD    B,00        ; .to register (inline modified)
  1222.     LD    DE,1000
  1223.     CALL    DECDSP        ; Print if non-0 or previous print
  1224.     LD    DE,100
  1225.     CALL    DECDSP        ; Print if non-0 or previous print
  1226.     LD    DE,10
  1227.     CALL    DECDSP        ; Print if non-0 or previous print
  1228.     LD    A,L        ; Get 1's
  1229.     JR    DECDS0        ; ..and print
  1230.  
  1231.  
  1232. DIVBIG:    LD    C,-1        ; Set initial result
  1233.     OR    A        ; Clear Carry
  1234. DIVBL:    INC    C        ; Bump count
  1235.     SBC    HL,DE        ; .subtract lower 2 bytes
  1236.     SBC    A,B        ; ..and upper byte
  1237.     JR    NC,DIVBL    ; ...looping til done
  1238.     ADD    HL,DE        ; Correct for underflow
  1239.     ADC    A,B
  1240.     LD    E,A        ; .(save MSB)
  1241.     LD    A,C        ; Get Result
  1242.     OR    A        ; Is digit 0?
  1243.     JR    NZ,DIVBP    ; ..jump if Not
  1244.     LD    A,(BIGFLG+1)    ; Get Prior digit print flag
  1245.     OR    A        ; Anything printed yet?
  1246.     JR    Z,DIVBX        ; ..jump if Not
  1247.     XOR    A        ; Else print a Zero
  1248. DIVBP:    ADD    A,'0'        ; Make digit Ascii
  1249.     LD    (BIGFLG+1),A    ; ..save as new flag
  1250.     CALL    SOUT        ; Print digit
  1251. DIVBX:    LD    A,E        ; Get MSB back
  1252.     RET            ; ..and quit
  1253.  
  1254. ;.....
  1255. ; Divide HL by DE converting remainder to ascii digit and printing it if
  1256. ; the number is Non-Zero or a digit was previously printed
  1257.  
  1258. DECDSP:    OR    -1        ; Clear flag and set initial count
  1259. DECDSL:    SBC    HL,DE        ; Divide by subtraction
  1260.     INC    A        ; .adjust counter
  1261.     JR    NC,DECDSL    ; ..loop til done
  1262.     ADD    HL,DE        ; Compensate for underflow
  1263.     JR    NZ,DECDS0    ; ..jump if Non-zero div result
  1264.     OR    B        ; Else check for previous print
  1265.     RET    Z        ; ..return if No prev char & Zero result
  1266.     XOR    A        ; Otherwise print a Zero
  1267. DECDS0:    ADD    A,'0'        ; Convert to Ascii digit
  1268.     LD    B,A        ; ..and set flag for next pass
  1269.     JP    SOUT        ; Jump to switched output routine & return
  1270.  
  1271. ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1272. ; Uninitialized Buffer Space
  1273.  
  1274.     DSEG        ; Put this in Data Segment
  1275.  
  1276. ;-----
  1277. ; The Next Eight entries MUST remain in the listed order
  1278.  
  1279. UFLG:     DEFS    1    ; 0=Select current user, 0FFH=Select all users
  1280. HFLG:     DEFS    1    ; 0=vertical list
  1281. FFFLG:     DEFS    1    ; Form Feed flag
  1282. SFLG:     DEFS    1    ; Sort order flag
  1283. NFLG:     DEFS    1    ; No Dates flag
  1284. WFLG:     DEFS    1    ; Wide Display flag
  1285. TFLG:     DEFS    1    ; Mode.  0=P2Dos Stamps, FF=DateStamper Stamps
  1286. DFLG:     DEFS    1    ; European/US.  0=US Dates, FF=European Dates
  1287. AFLG:     DEFS    1    ; Attribute Flag
  1288. ;-----
  1289. PFLG:     DEFS    1    ; Printer Output ON Flag
  1290.  
  1291. WHEEL:     DEFS    1    ; Storage for Wheel byte from ZCPR3
  1292. CURYR:     DEFS    1    ; Storage for current year from clock
  1293. SELUD:     DEFS    2    ; Selected Drive/User from command line
  1294. PFLGT:     DEFS    1
  1295. PFLGS:     DEFS    1
  1296. NCOLS:     DEFS    1    ; Storage for Number of columns in output
  1297.             ; 3 if NFLG, 2 if Not WFLG, else 1 if WFLG
  1298. FIRSTF:     DEFS    2    ; ptr to first file of group to print
  1299. FCOUNT:     DEFS    2    ; count of files
  1300. COUNTF:     DEFS    2    ; down count of files
  1301. FREESZ:     DEFS    3    ; Amount of Free Space on Disk (3-bytes worth)
  1302. TOTSIZ:     DEFS    3    ; Total Size of All files listed (up to 3 byes)
  1303. PTR1:     DEFS    2    ; col output ptrs
  1304. PTR2:     DEFS    2
  1305. PTR3:     DEFS    2
  1306. ENTPTR:     DEFS    2    ; current entry ptr
  1307. ENTPT0:     DEFS    2    ; Current Pointer to Pointer
  1308. BUFFER:     DEFS    2    ; pointer to free area
  1309. ENTRUD:     DEFS    2    ; Entry DU for restoration on exit
  1310. STACK:     DEFS    2    ; stack ptr
  1311.  
  1312.     END
  1313.