TITLE "SDIR06 - Syslib 4.3" NAME ('DIRALP') ;================================================================= ; The Libraries, Version 4, (C) 1989 by Alpha Systems Corp. ;----------------------------------------------------------------- ; Author : Harold F. Bower ; Derived from SDIR06.Z80 Ver 1.5 by Richard Conn ; Date : 17 Sep 89 ; Version : 1.6 ; Module : SDIR06 ; Abstract: This module contains the routine DIRALPHA 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.7 - 22 Nov 90 - Modified to use General Sort routine. HFB ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points PUBLIC DIRALPHA ; From SYSLIB Get.. EXT @FNCMP, SSBINIT, SSB, SORT, ORDER, FCOUNT, SDCOMP ; Definitions ESIZE EQU 16 ; Size of Entries .Z80 CSEG ;=============================================================== ; NAME - DIRALPHA ; 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 ; Requirements: none ;=============================================================== DIRALPHA: PUSH BC ; Save Registers PUSH DE PUSH HL LD (SSB),HL ; Save Buffer Addr in DIRBUF PUSH HL LD (CMPFLG),A ; Set flag LD DE,SSB ; Point to sort spec block LD (FCOUNT),BC ; Save record count 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,(CMPFLG) ; Group by file type? OR A JR Z,CMPFNFT ; Compare by file type, file name, extension, and user (in that order) 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 POP DE POP HL JR NZ,CMPEX ; ..exit if mismatch PUSH HL PUSH DE LD BC,12 ; PT to EXT (11 bytes for FN/FT and 1 for User) ADD HL,BC EX DE,HL ADD HL,BC EX DE,HL ; DE, HL now pt to their EXT'S LD A,(DE) ; Compare CP (HL) CMPUSR: POP DE POP HL JR NZ,CMPEX LD A,(DE) ; Compare User Numbers CP (HL) cmpex: POP BC RET ; Compare by File Name, File Type, Extension, and User Num (in that order) CMPFNFT: INC HL ; Pt to FN INC DE LD B,12 ; Compare FN, FT, EX CALL @FNCMP JR CMPUSR ; ..continue above to check user & exit ; Data Storage/Buffers DSEG ; Place in Data Segment CMPFLG: DEFS 1 ; 0 = Sort by Name/Type, else by Type/Name END