; Program: DIRFREE ; Purpose: Report directory space on specified disk ; Author: Rob Friefeld ; Date: 11 Nov 87 ; Version: 1.0 ; ; System Functions ; WRCONF EQU 2 LOGINF EQU 14 SRCHFF EQU 17 SRCHNF EQU 18 INQDISKF EQU 25 GETPARMF EQU 31 ; ; System Addresses ; OS$BASE EQU 000H ;system base.. BDOS EQU OS$BASE+05H FCB EQU OS$BASE+5CH FCB1 EQU OS$BASE+5CH ;preferred (AEH) TBUF EQU OS$BASE+80H LF EQU 0AH ;..linefeed.. CR EQU 0DH ;..carriage return.. ; ; Program ; dfree: ld hl,0 ; Initialize entry counter ld (count),hl ld a,(fcb) ; Which disk is wanted? dec a jp p,dir1 ; Spec in fcb ld c,inqdiskf ; Get default call bdos dir1: ld e,a ; Disk # 0..15 call print db cr,lf,'Directory Space, Drive ',0 ld a,'A' add e call conout call print db ':',cr,lf,0 ld c,loginf ; Log selected disk call bdos ld c,srchff ; Count all entries used dir2: ld de,dirfcb call bdos cp -1 ; No match jr z,dir3 call dircount ; Inc counter if entry active ld c,srchnf ; Next match jr dir2 dir3: ld hl,(count) ; Display entries used call phlfdc call print db '/Used ',0 ld c,getparmf ; Figure out how large directory is call bdos ld de,7 ; DRM offset add hl,de ld e,(hl) ; These numbers go to de inc hl ld d,(hl) ex de,hl inc hl ld (dirmax),hl ; # entries/directory ld de,(count) xor a sbc hl,de ; # free entries call phlfdc call print db '/Free ',0 ld hl,(dirmax) call phlfdc call print db '/Total',cr,lf,0 ret dircount: rrca ; A * 2**5 is offset into tbuf rrca rrca add a,tbuf ; LSB of entry address ld l,a ld h,0 ; HL now -> matched filename ld a,(hl) cp 0e5h ; ?erased ret z ; Yah, skip it ld hl,(count) ; Inc count inc hl ld (count),hl ret print: ex (sp),hl ld a,(hl) or a inc hl ex (sp),hl ret z call conout jr print conout: push hl push de push bc ld e,a ld c,wrconf call bdos pop bc pop de pop hl ret phlfdc: ; push hl ; push de ; push bc ; call hldc1 ; pop bc ; pop de ; pop hl ; ret ; Routine to convert HL to decimal number and display it hldc1: ld b,0 ; B holds leading zero suppression flag ld de,10000 call hldc2 ld de,1000 call hldc2 ld de,100 call hldc2 ld de,10 call hldc2 ld a,l add a,'0' jp conout hldc2: ld c,'0'-1 ; Count number of divisions by DE hldc3: inc c xor a sbc hl,de jr nc,hldc3 ; Keep subtracting until negative add hl,de ; then add one back ld a,c cp '1' jr nc,hldc4 ; > 0, turn off leading 0 flag and print ld a,b ; Check flag at B or a ld a,c ; Put character back in C jr nz,hldc5 ; If B NOT 0, this '0' is not leading ret ; Else skip hldc4: ld b,0ffh ; Turn the leading 0 flag off hldc5: jp conout ; Print the number ; ; Data ; count: ds 2 ; Entry counter dirmax: ds 2 ; Computed max entries dirfcb: ; FCB for search functions db '?' db '???????????' db '?' ds 23,0 end