home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Oakland CPM Archive
/
oakcpm.iso
/
cpm
/
packet
/
rli120.ark
/
EXTDIR.MAC
< prev
next >
Wrap
Text File
|
1986-08-12
|
7KB
|
531 lines
; EXTDIR.MAC - 12/30/85 - Extended directory listing.
.z80
maclib TNC.LIB
entry dir,dira,dirn,dirs
external seenew,waitc,fcb,fcb2,event,log,logtxt,llogtxt
external maxdrv,ckdrv,@prtx,@outch,@fill,ercant,erfind
external @mcmd,$memry,memtop,@outn,@outnb,numb,bindec
; shtyp =
; 1, show $dir only
; 2, show $sys only
; 4, show $new only
; 7, show all
; call getfree returns free space on current drive in HL.
asciictl
bdosdef
tncdefs
dseg
m1: dw $+2
db cr,tab,'Drive '
m2: db ' contains ',0
m3: dw $+2
db 'K in ',0
m4: dw $+2
db ' files with ',0
m5: dw $+2
db 'K free',cr,0
bufptr: ds 2
dsm: ds 2
blm: ds 2
bsh: ds 1
cnt: ds 2
drm: ds 2
frsiz: ds 2
rec: ds 2
fcnt: ds 1
span: ds 2
x7: ds 2
rec2: ds 2
rec1: ds 2
x10: ds 2
recptr: ds 2
drv: ds 1
files: ds 2
tot: ds 2
ptr: ds 2
shtyp: ds 1
cseg
dir: ld b,1 ; Normal only
cmpm seenew,true ; See new too?
jr nz,aldirb ; No
ld b,5
jr aldirb
dira: ld b,7
jr aldirb
dirs: ld b,2
jr aldirb
dirn: ld b,4
aldirb: ld a,b
ld (shtyp),a
movcmd logtxt,0,llogtxt 1
ld (hl),cr
mvim event,'F'
call log
ld a,(fcb2)
or a
jr nz,onedir
mvim fcb2,1
aldirc: zmov fcb,fcb2,fcbsize
ld a,(fcb)
call ckdrv
call c,prtdir
ld a,(fcb2)
ld hl,maxdrv
cp (hl)
jp z,waitc
inc a
ld (fcb2),a
jr aldirc
; Drive specified. Do only that one.
onedir: zmov fcb,fcb2,fcbsize
ld a,(fcb)
call ckdrv
jp nc,erfind
call prtdir
jp waitc
; List the directory.
prtdir: movw ptr,$memry
; Get default drive
dodosv ckcur
ld (drv),a
ld hl,fcb
ld a,(hl)
or a
jr nz,bgn
ld a,(drv)
inc a
bgn: ld (hl),a
ld hl,fcb
inc hl
ld a,(hl)
cp ' '
jr nz,sext
fill ,11,'?'
sext: ld hl,fcb
ld de,12
add hl,de
ld (hl),'?'
dodosa setdma,defdma
; Select drive
ld hl,fcb
ld e,(hl)
dec e
dodosa seldsk
call getfree
ld (frsiz),hl
; Set up pointers to memory structures.
ld de,(ptr)
ld hl,(drm) ; Max files on disk -1
inc hl ; Max files on disk
add hl,hl ; Times two
add hl,de
ld (rec),hl
ld (recptr),hl
ld de,(memtop)
or a ; Clear carry
sbc hl,de
jp nc,er
ld hl,0
ld (cnt),hl
ld (files),hl
ld (tot),hl
; Search first
ld de,fcb
dodosa search
jr nx1
; Search next
nx: ld de,fcb
dodosa next
nx1: inc a
jp z,srt
dec a
and 3
add a,a
add a,a
add a,a
add a,a
add a,a
ld hl,defdma+1
add a,l
ld l,a
ld (bufptr),hl
ld b,0
add a,3
ld l,a ; Point to f4'
ld a,(hl)
and 80h ; File has new attr set?
jr z,nxa ; No
ld b,4 ; Is new file
nxa: ld a,l
add a,6
ld l,a
ld a,(hl)
and 80h ; $sys file?
jr z,nxb ; No
ld a,2
or b ; Is sys as well
ld b,a
nxb: ld a,b
or a
jr nz,nxc
ld b,1 ; Normal file
nxc: ld a,(shtyp)
and b ; We show this kind?
jr z,nx ; No
; Move file.ext to buffer.
; Store file, extension, extent number, record count.
ld hl,(bufptr)
ld de,(recptr)
ld bc,12
ldir
inc hl
inc hl
ld a,(hl)
ld (de),a
inc de
ld (recptr),de
ld hl,(cnt)
inc hl
ld (cnt),hl
ld hl,13
add hl,de
ld de,(memtop)
or a ; Clear carry
sbc hl,de
jp c,nx
er: call ercant
jp exit
srt: ld hl,(cnt)
ld a,l
or h
jp z,prtt
push hl ; Save count on top of stack.
; Fill list of pointers to records with initial record addresses.
ld de,(rec)
ld hl,(ptr)
ld bc,13
srta: ld (hl),e
inc hl
ld (hl),d
inc hl
; Increment address
ex de,hl
add hl,bc
ex de,hl
; Decrement count
ex (sp),hl
dec hl
ld a,l
or h
ex (sp),hl
jr nz,srta
pop hl ; Clean up stack
movw x10,cnt
dec hl
ld a,l
or h
jp z,prt
ld hl,(x10)
; x10/2
srtb: or a ; Clear carry
ld a,h
rra
ld h,a
ld a,l
rra
ld l,a
or h
jp z,prt
ld a,l
or 1
ld l,a
ld (span),hl
inc hl
srtc: ld (x7),hl
ld de,(span)
or a ; Clear carry
sbc hl,de
srtd: ld (rec2),hl
ex de,hl
ld hl,(span)
add hl,de
ld (rec1),hl
ld a,12
call cpr ; Compare file, extension, extent
jp p,srte ; Don't exchange
; Exchange the two record ponters.
ld bc,(ptr)
dec bc
dec bc
ld de,(rec2)
ld hl,(rec1)
add hl,hl
add hl,bc
ex de,hl
add hl,hl
add hl,bc
ld c,(hl)
ld a,(de)
ex de,hl
ld (hl),c
ld (de),a
inc hl
inc de
ld c,(hl)
ld a,(de)
ex de,hl
ld (hl),c
ld (de),a
ld de,(rec2)
ld hl,(span)
ld a,e
sub l
ld l,a
ld a,d
sbc a,h
ld h,a
jp m,srte
or l
jr z,srte
jp srtd
srte: ld de,(x10)
ld hl,(x7)
inc hl
ld a,e
sub l
ld a,d
sbc a,h
jp p,srtc
ld hl,(span)
jp srtb
; Print the sorted file names.
prt: ld hl,(ptr)
ld (recptr),hl
mvim fcnt,4 ; Names/line
prta: dcxm cnt
ld a,h
or l
jp z,prtd
ld hl,(recptr)
ld a,11
push hl
ld e,(hl)
inc hl
ld d,(hl)
inc hl
ld c,(hl)
inc hl
ld b,(hl)
ex de,hl
ld e,a
prtb: ld a,(bc)
cp (hl)
inc hl
inc bc
jr nz,prtc
dec e
jr nz,prtb
prtc: pop hl
jr nz,prtd
inc hl
inc hl
ld (recptr),hl
jr prta
prtd: ld hl,(recptr)
ld e,(hl)
inc hl
ld d,(hl)
inc hl
ld (recptr),hl
ex de,hl
ld b,8
call @outn
ld c,'.'
call @outch
ld b,3
call @outn
ld e,(hl)
ld d,0
inc hl
ld a,(hl)
ex de,hl
add hl,hl
add hl,hl
add hl,hl
add hl,hl
ex de,hl
ld hl,blm
add a,(hl)
rrca
rrca
rrca
and 1fh
ld l,a
ld h,0
add hl,de
ld a,(blm)
rrca
rrca
rrca
and 1fh
cpl
and l
ld l,a
ex de,hl
ld hl,(tot)
add hl,de
ld (tot),hl
inxm files
ex de,hl
call bindec
ld hl,numb+1
ld b,4
call @outn
ld c,'k'
call @outch
dtz cnt
jp z,prtt
ld hl,fcnt
dec (hl)
jr z,prte
ld c,' '
call @outch
ld c,'|'
call @outch
ld c,' '
call @outch
jp prta
prte: mvim fcnt,4
ld c,cr
call @outch
jp prta
prtn: call bindec
ld hl,numb
ld b,5
jp @outnb
prtt: ld hl,fcb
ld a,(hl)
add a,'A'-1
ld (m2),a
prtx m1
ld hl,(tot)
call prtn
prtx m3
ld hl,(files)
call prtn
prtx m4
ld hl,(frsiz)
call prtn
prtx m5
jp exit
; (HL) rec1 #, (DE) rec2 #
cpr: ld bc,(ptr)
dec bc
dec bc
add hl,hl
add hl,bc
ex de,hl
add hl,hl
add hl,bc
ex de,hl
ld c,(hl)
inc hl
ld b,(hl)
ex de,hl
ld e,(hl)
inc hl
ld d,(hl)
ex de,hl
ld e,a
cpra: ld a,(bc)
cp (hl)
inc bc
inc hl
ret nz ; Records different
dec e
jr nz,cpra
ret ; Records same
exit: ld a,(drv)
ld e,a
dodosa seldsk
ret
; Calculate free space on current drive, return in HL.
getfree: dodosa getdpb
inc hl
inc hl
ld a,(hl)
ld (bsh),a
inc hl
ld a,(hl)
ld (blm),a
inc hl
inc hl
ld e,(hl)
inc hl
ld d,(hl)
ld (dsm),de
inc hl
ld e,(hl)
inc hl
ld d,(hl)
ld (drm),de
dodosa getalv
ex de,hl
ld hl,(dsm)
inc hl
ld bc,0
fra: push de
ld a,(de)
ld e,8
frb: rla
jr c,frc
inc bc
frc: ld d,a
dec hl
ld a,l
or h
jr z,frd
ld a,d
dec e
jr nz,frb
pop de
inc de
jr fra
frd: pop de
ld l,c
ld h,b
ld a,(bsh)
sub 3
ret z
fre: add hl,hl
dec a
jr nz,fre
ret
end