; VARLOAD.Z80 ; ; ZCPR3 Shell (Environment) Variable manipulation routines. ; Routines in this module: ; VARLOAD -- loads the shell variable file into memory. ; VARDEF -- finds a variable name in the file. ; DELVAR -- deletes a variable. ; ADDVAR -- adds a variable. ; WRTVARS -- writes out the variable file. ; These routines take various parameters passed in the DE and HL registers. ; ; Author: Dreas Nielsen ; Revision history: ; Date Comments ; ------- ----------- ; 7/11/86 First version. ; 1/15/87 Changed from a single file to separate library modules ; using shared (semi-PUBLIC) data ; 7/27/89 Shortened code. Made SHVNAM and XROOT symbols ; public so that they can be called by WRTVARS. ; Howard Goldstein ; ; PUBLIC VARLOAD,Z3VARS,XROOT,SHVNAM ; ; SYSLIB and Z3LIB routines -- EXT RETUD,LOGUD,DNSCAN,ROOT,GETFN1 EXT SETDMA,F$READ,F$OPEN,F$CLOSE,INITFCB ; EOF EQU 'Z'-'@' ; ;================ PUBLIC Storage ================ ; Z3VARS: DW 00 ;addr of start of list ; ;================ semi-PUBLIC Storage ================ ; SHVFCB: DB 0 ;SHVFCB: fcb for shell variable file DB 'SH VAR' DS 24 RNAME: DB 'ROOT',0 ;name of root directory ; ;=================================================== ; ;---- VARLOAD ---- ; ; Enter with: ; HL = address of beginning of list. ; Return with: ; if successful, ; A = 00 and Z ; HL = next free addr after var list; ; if unsuccessful, ; A=NZ and NZ. ; ; This routine will look for the SH.VAR file (by whatever name) in the ROOT ; directory. If this directory does not exist, it will look at the bottom ; of the path. This behavior is different from that of Richard Conn's ; original utilities. It is presumed that there is sufficient space for the ; variable list in memory. No bounds checking is done. ; VARLOAD: PUSH BC ;save regs PUSH DE LD A,(Z3VARS+1) OR A JR NZ,VARLD4 ; LD (Z3VARS),HL LD (HL),EOF ;clear varlist in case of error CALL RETUD PUSH BC ;save current du on stack CALL XROOT CALL LOGUD ; ; Get proper name for variable file, or use default CALL SHVNAM ; ; Look for Variable File V2: LD DE,SHVFCB ;try to open file CALL INITFCB ;init FCB CALL F$OPEN JR NZ,VARL3 ;no file, but that's OK ; ; Read in Variable File LD HL,(Z3VARS) ;pt to named variable list VARL1: CALL SETDMA LD DE,128 ;increment DMA addr for next read ADD HL,DE LD DE,SHVFCB ;read a sector CALL F$READ JR Z,VARL1 ;if OK, read another VARL2: CALL F$CLOSE ;close file VARL3: POP BC ;restore original du CALL LOGUD VARLD4: LD A,EOF ;find next free address LD HL,(Z3VARS) LD BC,65535 CPIR XOR A ;return Z for OK POP DE ;restore regs POP BC RET ; XROOT: ;find 'ROOT:' or end of path LD HL,RNAME ;does 'ROOT:' exist? CALL DNSCAN RET NZ ;ret if yes CALL ROOT ;otherwise find end of path RET ; SHVNAM: CALL GETFN1 LD A,(HL) CP ' ' ;is filename undefined? RET Z LD DE,SHVFCB+1 ;move filename into fcb LD BC,11 LDIR RET ; END