TITLE "DDIR06 - Syslib 4.0" ;================================================================= ; Copyright (C) 1989 by Harold F. Bower. Permission granted to ; Alpha Systems Corp. to distribute with The Libraries, Version 4 ;----------------------------------------------------------------- ; Author : Harold F. Bower ; Derived from SDIR06.Z80 Ver 1.5 by Richard Conn ; Date : 27 Aug 88 ; Version : 1.0 ; Module : DDIR06 ; Abstract: This module contains the routine DDIRALFA which ; alphabetizes the addressed Directory Buffer. A flag is ; passed to the routine to indicate whether to sort by ; File Name then Type, or by File Type then Name. ; Revision: ; 1.0 - 27 Aug 88 - Initial Version. HFB ; 1.1 - 5 Jan 91 - Revised to use SYSLIB's SORT. HFB ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points PUBLIC DDIRALFA ; External References EXT @FNCMP, SSBINIT, SSB, SORT, ORDER, FCOUNT, SDCOMP ; Definitions ESIZE EQU 16+15 ; Size of Entries + Create/Access/Mod times .Z80 CSEG ;=============================================================== ; NAME - DDIRALFA ; Entry: HL - Points to Directory Buffer ; BC - Contains the number of entries ; A - Sort Flag; 0 = Sort by Name/Typ, <>0 = by Typ/Name ; Exit : A = 0 on return. Flags should be Zero Set (Z) ; Uses : AF ; Special Requirements: None ;=============================================================== DDIRALFA: PUSH BC ; Save Registers PUSH DE PUSH HL LD (SSB),HL ; Save Buffer Addr in DIRBUF PUSH HL LD (CPFLG),A ; Set flag LD DE,SSB ; Point to sort spec block LD (FCOUNT),BC ; Save record count LD HL,4 ; Get offset to element size ADD HL,DE ; ..from SSB base LD BC,ESIZE LD (HL),C ; Save our element size INC HL LD (HL),B ; ..in the SSB LD HL,CMPENTRY ; Get addr of our comparison routine LD (SDCOMP),HL ; ..save in SSB LD HL,(ORDER) CALL SSBINIT ; (Re-)initialize the pointer table POP HL ; Retrieve addr of first rec LD (SSB),HL ; ..and restore ptr to record area CALL SORT ; Do the sort POP HL POP DE POP BC RET ;..... ; Compare Dir entry pted to by HL with that pted to by DE; ; No net effect on HL, DE; Ret W/Carry Set means DE < HL ; Ret W/Zero Set means DE = HL CMPENTRY: PUSH BC ; Save file count PUSH HL PUSH DE LD A,(CPFLG) ; Group by file type? OR A JR NZ,CPFCB1 ; ..jump if so ; Compare by File Name, File Type, Extension, and User Num (in that order) INC HL ; Pt to FN INC DE LD B,12 ; Compare FN, FT, EX CALL @FNCMP JR CPFXX ; ..continue below for error & user check ; Compare by file type, file name, extension, and user (in that order) CPFCB1: LD BC,9 ; Pt to FT (8 Bytes + 1 byte for user number) ADD HL,BC EX DE,HL ADD HL,BC EX DE,HL ; DE, HL now pt to their FT'S LD B,3 ; 3 bytes CALL @FNCMP ; Compare FT'S POP DE POP HL JR NZ,CMPEX ; ..exit if mismatch PUSH HL PUSH DE INC HL ; Pt to File Name INC DE LD B,8 ; 8 bytes CALL @FNCMP ; Compare FN'S JR NZ,CPFXX ; ..Exit here if No match INC DE ; Advance ptrs to EXT INC DE INC DE INC HL INC HL INC HL ; DE, HL now pt to their EXT's LD A,(DE) ; Compare CP (HL) CPFXX: POP DE ; Error exit just restores regs POP HL JR NZ,CMPEX ; ..exit if Not save LD A,(DE) ; Else compare user numbers CP (HL) CMPEX: POP BC RET ; Data Storage/Buffers DSEG ; Place in Data Segment CPFLG: DEFS 1 ; 0 = Sort by Name/Type, else by Type/Name END