; 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 ; ; 3/19/89 Deleted internal SETDMA and READ code for SYSLIB ; equivalents (SETDMA and F$READ), deleted F$CLOSE ; call and external as this is an R/O module. Note ; that VARLOAD is non-reentrant unless Z3VARS is ; explicitly reset to 0000H elsewhere. ; Bruce Morgen ; PUBLIC VARLOAD,Z3VARS ; ; SYSLIB and Z3LIB routines -- EXT RETUD,LOGUD,DNSCAN,ROOT,GETFN1 EXT INITFCB,F$OPEN,F$READ,INITFCB,SETDMA ; EOF EQU 'Z'-'@' ; ;================ PUBLIC Storage ================ ; Z3VARS: DW 0 ;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 ; ;================ Private Storage ================ ; CURRDU: DW 00 ; ; ;=================================================== ; ;---- 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: LD A,(Z3VARS+1) OR A JR Z,VARLD1 XOR A RET ; VARLD1: PUSH BC ;save regs PUSH DE LD (Z3VARS),HL CALL RETUD LD (CURRDU),BC CALL XROOT CALL LOGUD LD HL,(Z3VARS) ;clear varlist in case of error LD (HL),EOF ; ; 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,VARL2 ;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: LD BC,(CURRDU) CALL LOGUD LD A,EOF ;find next free address LD HL,(Z3VARS) LD BC,65535 CPIR POP DE ;restore regs POP BC RET PO XOR A ;return Z for OK RET ; XROOT: ;find 'ROOT:' or end of path LD HL,RNAME ;does 'ROOT:' exist? CALL DNSCAN RET NZ ;ret if yes JP ROOT ;otherwise find end of path ; 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