TITLE "Z3DIRTDU - Z3lib 4.0" ;================================================================ ; The Libraries, Version 4, (C) 1989 by Alpha Systems Corp. ;---------------------------------------------------------------- ; Author : Harold F. Bower ; Derived from Z3DIRTDU.Z80 Ver 1.1 by Richard Conn ; Date : 30 Mar 89 ; Version : 1.2 ; Module : Z3DIRTDU ; Abstract: This module contains the routine DIRTDU which scans ; the resident named directory buffer for a specified ; name, and returns the Drive and User number if found. ; Revision: ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points PUBLIC DIRTDU ; External References EXT GETNDR, CAPS .Z80 CSEG ;=============================================================== ; NAME - DIRTDU ; Entry: HL - Points to a directory name ; Exit : Found: ; - B = Disk # (A = 0), C = User area ; - A <> 0 and Zero Flag Reset (NZ) ; Not Found - A = 0 and Zero Flag Set (Z) ; Uses : AF,BC,HL ; Special Requirements: None ;=============================================================== DIRTDU: PUSH DE ;save DE ; Save DIR Name in Buffer LD DE,DIRBUF ;pt to buffer LD B,8 ;8 chars max DD1: LD A,(HL) ;get char CALL DELCHK ;check for delimiter JR C,DD3 LD (DE),A ;store char INC HL ;pt to next INC DE DJNZ DD1 ;count down ; Name longer than 8 chars - skip to delimiter DD2: LD A,(HL) ;skip to delimiter INC HL ;pt to next CALL DELCHK ;check for delimiter JR NC,DD2 DEC HL ;pt to delimiter JR DD4 ; Name shorter than 8 chars - space fill DD3: LD A,' ' ;space fill LD (DE),A ;store space INC DE ;pt to next DJNZ DD3 ;count down ; HL pts to delimiter, buffer contains name DD4: PUSH HL ;save ptr to delimiter LD DE,DIRBUF ;pt to directory name buffer CALL GETNDR ;pt to named dir JR Z,DDEXIT ; ..jump error exit if Dir Not found ; Scan for Directory Name DD5: LD A,(HL) ; End of dir? OR A JR Z,DDEXIT ; ..jump to Not Found error if so PUSH HL ;save ptr to current entry PUSH DE ;save ptr to target name INC HL ;pt to name INC HL LD B,8 ;8 chars DD6: LD A,(DE) ;get target name CP (HL) ;compare JR NZ,DD7 INC HL ;pt to next INC DE DJNZ DD6 ;count down ; DIR Names Match POP DE ;restore ptrs POP HL LD B,(HL) ;get disk number DEC B ;disk A = 0 INC HL ;get user number LD C,(HL) ;... in C DEFB 3EH ; Fake a "LD A,0AFH" for Good return DDEXIT: XOR A ; Enter here for Error return OR A ; ..set flags in case we "fell thru" POP HL ;restore ptr to delimiter POP DE ;restore DE RET ; Advance to Next DIR Entry DD7: POP DE ;restore ptrs POP HL LD BC,18 ;pt to next entry ADD HL,BC JR DD5 ;resume search ; Check for Delimiter in A ; RETURN: Carry Set (C) if delimiter ; Carry clear (NC) if legal char DELCHK: CALL CAPS ;capitalize char CP '0' ;numeric? RET C ; Error, return C CP '9'+1 JR C,DEL2 ; Set NC for Good Number CP 'A' ;alphabetic? RET C ; Error, return C CP 'Z'+1 JR C,DEL2 ; Set NC for Good Letter SCF RET ; Is not a delimiter DEL2: SCF CCF ; Carry Clear means good char RET ; Data Storage/Buffers DSEG ; Put in Data Segment DIRBUF: DEFS 8 ;8 chars for name END