; TITLE "SDIR09 - Syslib 4.0" NAME ('DIRPAC') ;================================================================= ; The Libraries, Version 4, (C) 1989 by Alpha Systems Corp. ;----------------------------------------------------------------- ; Author : Harold F. Bower ; Derived from SDIR09.Z80 Ver 1.5 by Richard Conn ; Date : 17 Sep 89 ; Version : 1.6 ; Module : SDIR09 ; Abstract: This module contains the routine DIRPACK which re- ; structures the directory (by packing entries) to include ; only those entries marked by DIRSEL (or DIRNSEL). A side ; effect of this routine is that the Flag Extent (Set by ; DIR:) be correct. In most cases, a default of 0 is Ok, ; except when the Extent Size is greater than 16K. ; Revision: ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points PUBLIC DIRPACK ; From SYSLIB Get.. EXT DIRBUF ; Definitions ESIZE EQU 16 ; Size of each Buffer Entry .Z80 CSEG ;=============================================================== ; NAME - DIRPACK ; Entry: HL - Points to a Directory Buffer ; BC - Contains the number of files in Buffer ; Exit : - Nothing Returned. The buffer is restructured ; Uses : - None ; Special Requirements: Required side effect is that the Flag ; Extent (Set by DIR:) be correct. In most cases, default ; of 0 is Ok, except when extent size is greater than 16K ;=============================================================== DIRPACK: PUSH HL ; Save Regs PUSH DE PUSH AF PUSH HL ; Save HL LD HL,0 LD (FCOUNT),HL ; Init file count POP HL ; Get HL LD (DIRBUF),HL ; Save ptr PUSH BC ; Save counter DPLOOP: POP BC ; Get counter LD A,B ; Check for Done OR C JR Z,DPDONE DEC BC ; Count down PUSH BC ; Save counter BIT 7,(HL) ; Does 1st byte indicate file is selected? JR Z,DPNEXT ; Found Selected Entry RES 7,(HL) ; Clear MSB of selected entry EX DE,HL ; Ptr to Current entry to DE LD HL,(FCOUNT) ; Increment File Count INC HL LD (FCOUNT),HL LD HL,(DIRBUF) ; Pt to Next Entry Position EX DE,HL ; HL pts to Current, DE pts to Next Entry LD BC,ESIZE ; Copy Entry LDIR LD (DIRBUF),DE ; Save ptr to Next Entry JR DPLOOP ; Continue ; Skip to Next Entry DPNEXT: LD BC,ESIZE ; Skip Entry ADD HL,BC JR DPLOOP ; Continue ; Compression Complete -- Set up returned values DPDONE: LD BC,(FCOUNT) ; Put File Count in BC POP AF ; Restore regs POP DE POP HL RET ; Data Storage DSEG ; Put in the Data Segment FCOUNT: DEFS 2 ; File Count END