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

  1. ;
  2. ;  Program:  LD
  3. ;  Author:  Richard Conn
  4. ;  Version:  1.1
  5. ;  Date:  6 Jan 83
  6. ;  Previous Versions:  1.0 (6 Dec 82)
  7. ;
  8. ;    LD Loads the named Directory file (LD=Load Directory) NAMES.DIR or
  9. ; that file specified in the command line into the memory-resident directory
  10. ; buffer.  It also has the capability of displaying the contents of this
  11. ; buffer to the user.  Forms of this command are:
  12. ;
  13. ;        LD        <-- Display Loaded Directory
  14. ;        LD filename    <-- Load Directory filename.DIR
  15. ;        LD filename.typ    <-- Load Directory filename.typ
  16. ;        LD //        <-- Ask for Help
  17. ;
  18. vers    equ    11
  19.  
  20. ;
  21. ;    This program is Copyright (c) 1982, 1983 by Richard Conn
  22. ;    All Rights Reserved
  23. ;
  24. ;    ZCPR2 and its utilities, including this one, are released
  25. ; to the public domain.  Anyone who wishes to USE them may do so with
  26. ; no strings attached.  The author assumes no responsibility or
  27. ; liability for the use of ZCPR2 and its utilities.
  28. ;
  29. ;    The author, Richard Conn, has sole rights to this program.
  30. ; ZCPR2 and its utilities may not be sold without the express,
  31. ; written permission of the author.
  32. ;
  33.  
  34.  
  35. ;
  36. ;  Constants
  37. ;
  38. cr    equ    0dh
  39. lf    equ    0ah
  40. tfcb    equ    5ch    ; ZCPR2 FCB
  41.  
  42. ;
  43. ;  Externals
  44. ;
  45.     ext    zgpins    ; installation program
  46.     ext    zfninit    ; reinit NAMES.DIR
  47.     ext    zdname    ; load names into buffer
  48.     ext    codend    ; end of code
  49.     ext    moveb    ; move routine
  50.     ext    print    ; print routine
  51.     ext    padc    ; print A as decimal chars
  52.     ext    cout    ; output char
  53.     ext    crlf    ; new line
  54.     ext    retud    ; return current user/disk
  55.  
  56. ;
  57. ;  Branch to Start of Program
  58. ;
  59.     jmp    start
  60.  
  61. ;
  62. ;******************************************************************
  63. ;
  64. ;  SINSFORM -- ZCPR2 Utility Standard General Purpose Initialization Format
  65. ;
  66. ;    This data block precisely defines the data format for
  67. ; initial features of a ZCPR2 system which are required for proper
  68. ; initialization of the ZCPR2-Specific Routines in SYSLIB.
  69. ;
  70.  
  71. ;
  72. ;  EXTERNAL PATH DATA
  73. ;
  74. EPAVAIL:
  75.     DB    0FFH    ; IS EXTERNAL PATH AVAILABLE? (0=NO, 0FFH=YES)
  76. EPADR:
  77.     DW    40H    ; ADDRESS OF EXTERNAL PATH IF AVAILABLE
  78.  
  79. ;
  80. ;  INTERNAL PATH DATA
  81. ;
  82. INTPATH:
  83.     DB    0,0    ; DISK, USER FOR FIRST PATH ELEMENT
  84.             ; DISK = 1 FOR A, '$' FOR CURRENT
  85.             ; USER = NUMBER, '$' FOR CURRENT
  86.     DB    0,0
  87.     DB    0,0
  88.     DB    0,0
  89.     DB    0,0
  90.     DB    0,0
  91.     DB    0,0
  92.     DB    0,0    ; DISK, USER FOR 8TH PATH ELEMENT
  93.     DB    0    ; END OF PATH
  94.  
  95. ;
  96. ;  MULTIPLE COMMAND LINE BUFFER DATA
  97. ;
  98. MCAVAIL:
  99.     DB    0FFH    ; IS MULTIPLE COMMAND LINE BUFFER AVAILABLE?
  100. MCADR:
  101.     DW    0FF00H    ; ADDRESS OF MULTIPLE COMMAND LINE BUFFER IF AVAILABLE
  102.  
  103. ;
  104. ;  DISK/USER LIMITS
  105. ;
  106. MDISK:
  107.     DB    4    ; MAXIMUM NUMBER OF DISKS
  108. MUSER:
  109.     DB    31    ; MAXIMUM USER NUMBER
  110.  
  111. ;
  112. ;  FLAGS TO PERMIT LOG IN FOR DIFFERENT USER AREA OR DISK
  113. ;
  114. DOK:
  115.     DB    0FFH    ; ALLOW DISK CHANGE? (0=NO, 0FFH=YES)
  116. UOK:
  117.     DB    0FFH    ; ALLOW USER CHANGE? (0=NO, 0FFH=YES)
  118.  
  119. ;
  120. ;  PRIVILEGED USER DATA
  121. ;
  122. PUSER:
  123.     DB    10    ; BEGINNING OF PRIVILEGED USER AREAS
  124. PPASS:
  125.     DB    'chdir',0    ; PASSWORD FOR MOVING INTO PRIV USER AREAS
  126.     DS    41-($-PPASS)    ; 40 CHARS MAX IN BUFFER + 1 for ending NULL
  127.  
  128. ;
  129. ;  CURRENT USER/DISK INDICATOR
  130. ;
  131. CINDIC:
  132.     DB    '$'    ; USUAL VALUE (FOR PATH EXPRESSIONS)
  133.  
  134. ;
  135. ;  DMA ADDRESS FOR DISK TRANSFERS
  136. ;
  137. DMADR:
  138.     DW    80H    ; TBUFF AREA
  139.  
  140. ;
  141. ;  NAMED DIRECTORY INFORMATION
  142. ;
  143. NDRADR:
  144.     DW    00000H    ; ADDRESS OF MEMORY-RESIDENT NAMED DIRECTORY
  145. NDNAMES:
  146.     DB    64    ; MAX NUMBER OF DIRECTORY NAMES
  147. DNFILE:
  148.     DB    'NAMES   '    ; NAME OF DISK NAME FILE
  149.     DB    'DIR'        ; TYPE OF DISK NAME FILE
  150.  
  151. ;
  152. ;  REQUIREMENTS FLAGS
  153. ;
  154. EPREQD:
  155.     DB    0FFH    ; EXTERNAL PATH?
  156. MCREQD:
  157.     DB    000H    ; MULTIPLE COMMAND LINE?
  158. MXREQD:
  159.     DB    0FFH    ; MAX USER/DISK?
  160. UDREQD:
  161.     DB    000H    ; ALLOW USER/DISK CHANGE?
  162. PUREQD:
  163.     DB    000H    ; PRIVILEGED USER?
  164. CDREQD:
  165.     DB    000H    ; CURRENT INDIC AND DMA?
  166. NDREQD:
  167.     DB    0FFH    ; NAMED DIRECTORIES?
  168. Z2CLASS:
  169.     DB    0    ; CLASS 0
  170.     DB    'ZCPR2'
  171.     DS    10    ; RESERVED
  172.  
  173. ;
  174. ;  END OF SINSFORM -- STANDARD DEFAULT PARAMETER DATA
  175. ;
  176. ;******************************************************************
  177. ;
  178.  
  179. ;
  180. ;  Start of Program
  181. ;
  182. start:
  183.     call    zgpins    ; init ZCPR2 routines
  184.     call    retud    ; get current user number
  185.     mov    a,b    ; save current disk number away
  186.     sta    cdisk
  187.     mov    a,c    ; save current user number away
  188.     sta    cuser
  189.  
  190.     call    print
  191.     db    'LD  Version '
  192.     db    (vers/10)+'0','.',(vers mod 10)+'0',0
  193.  
  194.     lhld    ndradr    ; check for facility support in the first place
  195.     mov    a,h
  196.     ora    l    ; HL=0 if no facilities for mem-based named dirs
  197.     jnz    start0
  198.     call    print
  199.     db    cr,lf,'Memory-Based Named Directories Not Supported'
  200.     db    cr,lf,'on this System -- Aborting',0
  201.     ret
  202.  
  203. start0:
  204.     lxi    h,tfcb+1    ; pt to first byte of file name
  205.     mov    a,m    ; get it
  206.     cpi    ' '    ; display loaded directory if no file name given
  207.     jz    ldisp
  208.     cpi    '/'    ; option?
  209.     jnz    start1    ; load directory if file specified
  210.  
  211.     call    print
  212.     db    cr,lf,'    LD is the Load Directory program for ZCPR2.'
  213.     db    cr,lf,'The functions of LD are to load the memory-resident'
  214.     db    cr,lf,'named directory buffer from the specified or implied'
  215.     db    cr,lf,'disk file and to display the contents of the named'
  216.     db    cr,lf,'directory buffer.'
  217.     db    cr,lf
  218.     db    cr,lf,'    The forms of the LD command are --',cr,lf
  219.     db    cr,lf,'        LD        <-- Display Loaded Directory'
  220.     db    cr,lf,'        LD filename    <-- Load filename.DIR'
  221.     db    cr,lf,'        LD filename.typ    <-- Load filename.typ'
  222.     db    cr,lf,'        LD //        <-- Print this Help Message'
  223.     db    cr,lf,0
  224.     ret
  225.  
  226. ;
  227. ;  Process Load Function
  228. ;
  229. start1:
  230.     lxi    d,8    ; pt to file type
  231.     dad    d
  232.     mov    a,m    ; get first char of file type
  233.     cpi    ' '    ; any file type?
  234.     jnz    setname    ; yes, so user file given totally
  235.     lxi    d,dirtyp    ; set file type to DIR
  236.     xchg        ; copy type into TFCB
  237.     mvi    b,3    ; 3 bytes
  238.     call    moveb
  239. setname:
  240.     lxi    d,tfcb    ; pt to FCB
  241.     mvi    a,80h    ; only set FCB
  242.     call    zfninit    ; set new NAMES.DIR file
  243.     call    codend    ; get end of code
  244.     call    zdname    ; load NAMES.DIR file (or user file)
  245.     jz    loaderr    ; load error
  246.     lhld    ndradr    ; pt to named directory buffer
  247.     mov    a,m    ; get limit
  248.     cmp    c    ; within range?
  249.     jnc    load1
  250.     call    print
  251.     db    cr,lf,'Load Error -- Not Enough Room in Memory Buffer'
  252.     db    cr,lf,'for Directory Names -- Aborting',0
  253.     ret
  254. loaderr:
  255.     call    print
  256.     db    cr,lf,'Load Error -- File Not Found -- Aborting',0
  257.     ret
  258. load1:
  259.     inx    h    ; pt to dir size
  260.     mov    m,c    ; set dir size
  261.     inx    h    ; pt to first byte of first entry
  262.     xchg        ; ... in DE
  263.     call    codend    ; pt to first loaded byte in HL
  264. load2:
  265.     mvi    b,10    ; 10 bytes/entry
  266. load3:
  267.     mov    a,m    ; get byte
  268.     stax    d    ; put byte
  269.     inx    h    ; pt to next
  270.     inx    d
  271.     dcr    b    ; count down
  272.     jnz    load3
  273.     dcr    c    ; count down entries
  274.     jnz    load2
  275.     call    print
  276.     db    cr,lf,'Load Complete',0
  277.     ret
  278.  
  279. ;
  280. ;  Display Contents of Loaded Directory
  281. ;
  282. ldisp:
  283.     lhld    ndradr    ; get address
  284.     call    print
  285.     db    cr,lf,'**********************************************'
  286.     db    cr,lf,'** Memory-Based Named Directory Definitions **'
  287.     db    cr,lf,'** Number of Entries Permitted: ',0
  288.     mov    a,m    ; get count
  289.     call    padc    ; print as decimal
  290.     call    print
  291.     db    '         **'
  292.     db    cr,lf,'** Number of Entries Loaded: ',0
  293.     inx    h    ; pt to count
  294.     mov    a,m    ; get count
  295.     call    padc
  296.     call    print
  297.     db    '            **'
  298.     db    cr,lf,'**********************************************',0
  299.     ora    a    ; any entries?
  300.     jnz    ldisp0
  301.     call    print
  302.     db    cr,lf,'    -- No Named Directories Loaded --',0
  303.     ret
  304. ldisp0:
  305.     call    print
  306.     db    cr,lf,'    -- Named Directory Display --',0
  307.     inx    h    ; pt to first entry
  308.     mov    b,a    ; count in B
  309.     mvi    c,0ffh    ; set current disk indicator to nothing
  310.     mvi    d,0    ; set entry counter
  311. ldisp1:
  312.     mov    a,m    ; get next disk
  313.     cmp    c    ; same as current indicator?
  314.     jz    ldisp2    ; process if same
  315.     mov    c,a    ; set new disk
  316.     call    crlf    ; new line
  317.     adi    'A'    ; convert to letter
  318.     call    cout
  319.     call    print
  320.     db    ' --',0
  321.     mvi    d,0ffh    ; set for increment to zero
  322. ldisp2:
  323.     inx    h    ; pt to user number
  324.     lda    puser    ; get priv user number
  325.     dcr    a    ; back up to last non-priv number
  326.     cmp    m    ; compare to entry
  327.     jnc    ldisp3    ; go ahead and display if non-priv number
  328.     push    b    ; save BC
  329.     lda    cuser    ; get current user
  330.     mov    b,a    ; ... in B
  331.     lda    puser    ; check for privileged user
  332.     dcr    a    ; set top of non-priv users
  333.     cmp    b    ; privileged?
  334.     pop    b    ; restore BC
  335.     jc    ldisp3    ; privileged
  336.     mov    a,l    ; pt to next entry
  337.     adi    9    ; 9 bytes to next entry
  338.     mov    l,a
  339.     mov    a,h
  340.     aci    0
  341.     mov    h,a
  342.     jmp    ldisp5
  343. ldisp3:
  344.     inr    d    ; increment entry counter
  345.     mov    a,d    ; get count
  346.     ani    3    ; check for 4th
  347.     cz    crlf
  348.     mov    a,m    ; get user number
  349.     call    padc    ; print user number as decimal chars
  350.     mvi    a,':'    ; print colon
  351.     call    cout
  352.     mvi    a,' '    ; print space
  353.     call    cout
  354.     inx    h    ; pt to first char of name
  355.     mvi    e,8    ; print 8-char name
  356. ldisp4:
  357.     mov    a,m    ; get char of dir name
  358.     call    cout
  359.     inx    h    ; pt to next
  360.     dcr    e    ; count down
  361.     jnz    ldisp4
  362. ldisp5:
  363.     dcr    b    ; count down
  364.     jnz    ldisp1
  365.     call    print
  366.     db    cr,lf,cr,lf,'** Current Directory **',cr,lf,'    ',0
  367.     lhld    ndradr    ; get address of buffer
  368.     inx    h    ; pt to entry count
  369.     mov    b,m    ; get entry count
  370.     inx    h    ; pt to first entry
  371. cdisp:
  372.     mov    c,m    ; get next disk number
  373.     inx    h    ; pt to user number
  374.     lda    cdisk    ; compare to current disk
  375.     cmp    c
  376.     jnz    cdisp2    ; skip if no match
  377.     lda    cuser    ; compare current user
  378.     cmp    m    ; to user pted to
  379.     jnz    cdisp2    ; skip if no match
  380.     inx    h    ; we have found it, so pt to first char
  381.     lda    cdisk    ; print current disk letter
  382.     adi    'A'
  383.     call    cout
  384.     lda    cuser    ; print current user number
  385.     call    padc
  386.     mvi    a,':'    ; print separator
  387.     call    cout
  388.     mvi    a,' '
  389.     call    cout
  390.     mvi    b,8    ; print 8 chars
  391. cdisp1:
  392.     mov    a,m    ; get char
  393.     call    cout    ; print char
  394.     inx    h    ; pt to next
  395.     dcr    b    ; count down
  396.     jnz    cdisp1
  397.     ret
  398. cdisp2:
  399.     lxi    d,9    ; skip to next entry
  400.     dad    d
  401.     dcr    b    ; count down
  402.     jnz    cdisp
  403.     call    print
  404.     db    'Not Named in Directory Buffer',0
  405.     ret
  406.  
  407. ;
  408. ;  Buffers
  409. ;
  410. cdisk:    ds    1    ; current disk number
  411. cuser:    ds    1    ; current user number
  412. dirtyp:    db    'DIR'    ; type of Directory file
  413.  
  414.     end
  415.