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 / BEEHIVE / ZSUS / ZSUS001.LBR / FOR12.LBR / VARLOAD2.ZZ0 / VARLOAD2.Z80
Text File  |  1989-03-18  |  3KB  |  135 lines

  1. ; VARLOAD.Z80
  2. ;
  3. ; ZCPR3 Shell (Environment) Variable manipulation routines.
  4. ; Routines in this module:
  5. ;    VARLOAD -- loads the shell variable file into memory.
  6. ;    VARDEF    -- finds a variable name in the file.
  7. ;    DELVAR    -- deletes a variable.
  8. ;    ADDVAR    -- adds a variable.
  9. ;    WRTVARS -- writes out the variable file.
  10. ; These routines take various parameters passed in the DE and HL registers.
  11. ;
  12. ; Author: Dreas Nielsen
  13. ; Revision history:
  14. ;     Date         Comments
  15. ;    -------        -----------
  16. ;    7/11/86        First version.
  17. ;    1/15/87        Changed from a single file to separate library modules
  18. ;            using shared (semi-PUBLIC) data
  19. ;
  20. ;    3/19/89        Deleted internal SETDMA and READ code for SYSLIB
  21. ;            equivalents (SETDMA and F$READ), deleted F$CLOSE
  22. ;            call and external as this is an R/O module.  Note
  23. ;            that VARLOAD is non-reentrant unless Z3VARS is
  24. ;            explicitly reset to 0000H elsewhere.
  25. ;                            Bruce Morgen
  26. ;
  27.     PUBLIC    VARLOAD,Z3VARS
  28. ;
  29. ; SYSLIB and Z3LIB routines --
  30.     EXT    RETUD,LOGUD,DNSCAN,ROOT,GETFN1
  31.     EXT    INITFCB,F$OPEN,F$READ,INITFCB,SETDMA
  32. ;
  33. EOF    EQU    'Z'-'@'
  34. ;
  35. ;================  PUBLIC Storage  ================
  36. ;
  37. Z3VARS:
  38.     DW    0        ;addr of start of list
  39. ;
  40. ;================  semi-PUBLIC Storage  ================
  41. ;
  42. SHVFCB:    DB    0        ;SHVFCB: fcb for shell variable file
  43.     DB    'SH      VAR'
  44.     DS    24
  45. RNAME:    DB    'ROOT',0    ;name of root directory
  46. ;
  47. ;================  Private Storage  ================
  48. ;
  49. CURRDU:    DW    00
  50. ;
  51. ;
  52. ;===================================================
  53. ;
  54. ;----  VARLOAD  ----
  55. ;
  56. ; Enter with:
  57. ;    HL = address of beginning of list.
  58. ; Return with:
  59. ;    if successful,
  60. ;        A  = 00 and Z
  61. ;        HL = next free addr after var list;
  62. ;    if unsuccessful,
  63. ;        A=NZ and NZ.
  64. ;
  65. ; This routine will look for the SH.VAR file (by whatever name) in the ROOT
  66. ; directory.  If this directory does not exist, it will look at the bottom
  67. ; of the path.  This behavior is different from that of Richard Conn's 
  68. ; original utilities.  It is presumed that there is sufficient space for the
  69. ; variable list in memory.  No bounds checking is done.
  70. ;
  71. VARLOAD:
  72.     LD    A,(Z3VARS+1)
  73.     OR    A
  74.     JR    Z,VARLD1
  75.     XOR    A
  76.     RET
  77. ;
  78. VARLD1:    PUSH    BC        ;save regs
  79.     PUSH    DE
  80.     LD    (Z3VARS),HL
  81.     CALL    RETUD
  82.     LD    (CURRDU),BC
  83.     CALL    XROOT
  84.     CALL    LOGUD
  85.     LD    HL,(Z3VARS)    ;clear varlist in case of error
  86.     LD    (HL),EOF
  87. ;
  88. ; Get proper name for variable file, or use default
  89.     CALL    SHVNAM
  90. ;
  91. ; Look for Variable File
  92. V2:
  93.     LD    DE,SHVFCB    ;try to open file
  94.     CALL    INITFCB        ;init FCB
  95.     CALL    F$OPEN
  96.     JR    NZ,VARL2    ;no file, but that's OK
  97. ;
  98. ; Read in Variable File
  99.     LD    HL,(Z3VARS)    ;pt to named variable list
  100. VARL1:
  101.     CALL    SETDMA
  102.     LD    DE,128        ;increment DMA addr for next read
  103.     ADD    HL,DE
  104.     LD    DE,SHVFCB    ;read a sector
  105.     CALL    F$READ
  106.     JR    Z,VARL1        ;if OK, read another
  107. VARL2:    LD    BC,(CURRDU)
  108.     CALL    LOGUD
  109.     LD    A,EOF        ;find next free address
  110.     LD    HL,(Z3VARS)
  111.     LD    BC,65535
  112.     CPIR
  113.     POP    DE        ;restore regs
  114.     POP    BC
  115.     RET    PO
  116.     XOR    A        ;return Z for OK
  117.     RET    
  118. ;
  119. XROOT:                ;find 'ROOT:' or end of path
  120.     LD    HL,RNAME    ;does 'ROOT:' exist?
  121.     CALL    DNSCAN
  122.     RET    NZ        ;ret if yes
  123.     JP    ROOT        ;otherwise find end of path
  124. ;
  125. SHVNAM:    CALL    GETFN1
  126.     LD    A,(HL)
  127.     CP    ' '        ;is filename undefined?
  128.     RET    Z
  129.     LD    DE,SHVFCB+1    ;move filename into fcb
  130.     LD    BC,11
  131.     LDIR
  132.     RET
  133. ;
  134.     END
  135.