home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
BEEHIVE
/
UTILITYS
/
PACK10.ARC
/
PACK.Z80
< prev
Wrap
Text File
|
1991-03-10
|
29KB
|
1,465 lines
.title 'Pack Disk'
; FDC, 29 August 1987
version equ 10
fcb1: equ 5ch
fcb2: equ 6ch
buff: equ 80h
lf: equ 10
cr: equ 13
ctrlz: equ 26
MAXLIN: equ 128 ; maximum input line length
extrn print,cout,cin,condin,crlf,pfn2,pa2hc,phlfdc,phl4hc
extrn caps,issp,sksp,compb,getcrt,getmdisk
extrn z3init,z3log,getwhl,getefcb,retud,dnscan
extrn f$open,f$read,f$close,bdos,bios
extrn mulhd,divhd
public $memry
start: jp pack
db 'Z3ENV'
db 1 ; external environment
z3eadr dw 0f000h ; environment address
dirflg: db 0 ; always set C=1 on directory writes if non-zero
pack: ld hl,(z3eadr)
call z3init ; initialise z3lib routines
call assign ; assign data areas
ld c,12 ; get cp/m version number
call bdos
ld a,h
or a
jr nz,badver
ld a,l
cp 22h
jr z,chkwhl
badver: call pname
call print
db ' requires CP/M 2.2 (or ZRDOS)',cr,lf,0
quit: rst 0
chkwhl: call getwhl ; priviledged?
jr z,quit ; silently deny access if not
ld a,(fcb1+1) ; help requested?
cp '/'
jr z,ghelp
cp ' '
jr nz,pack1
ghelp: call help
rst 0 ; warm boot
pack1: call options ; process options
call gnames ; read input file and build name tables
xor a
ld (fixmob),a
ld hl,wild
call fnam ; terminate mobile list with *:*.*
ld de,fcb1
call f$close
call quitif ; quit if errors
ld a,(verbose)
or a
call nz,showlist
call maktab ; make group table
call quitif ; quit if errors
ld a,(verbose)
or a
call nz,showtab
ld hl,0
ld (rdcnt),hl ; clear counters
ld (wrcnt),hl
ld a,(stats) ; just statistics?
or a
jr nz,pack5
ld a,(blshf)
ld b,a
ld hl,128
pack2: add hl,hl ; find group size
djnz pack2
ex de,hl
call getheap ; reserve 2 buffers
ld (grp1),hl
call getheap
ld (grp2),hl
call chkro ; check for read only disk
call print
db 'Ready to pack disk ',0
ld a,(disk)
add 'A'
call cout
call print
db cr,lf,'Are you sure you wish to proceed? (y/n) - ',0
pack3: call cin
and 5fh
cp 'Y'
jr z,pack4
cp 'N'
jr nz,pack3
rst 0
pack4: call cout
call crlf
pack5: call sort ; sort groups
ld a,(stats)
or a
jr nz,pack6
call fixdir ; fix directory
call resdrv ; reset drive
call print
db 'Disk packed',cr,lf,0
rst 0
pack6: ld hl,(rdcnt)
call phlfdc
call print
db ' group reads and ',0
ld hl,(wrcnt)
call phlfdc
call print
db ' group writes required to pack disk.',cr,lf,0
rst 0
assign: pop bc ; return address
ld hl,($memry)
ld de,128 ; stack size
add hl,de
ld sp,hl ; assign stack above program
push bc
ld (inline),hl ; input line buffer
ld de,MAXLIN
add hl,de
ld (heap),hl ; set top of heap
ret
; Read input file and build fixed and mobile name tables
gnames: ld hl,0
ld (errors),hl ; no errors yet
ld de,fcb1
call z3log ; log in to file DU
call f$open ; open it
jr z,opok
call print ; report file missing
db 'Can''t find ',0
inc de
call pfn2
call crlf
rst 0 ; and quit
opok: xor a
ld (fixmob),a ; initially expect mobile names
ld h,a
ld l,a
ld (fixcnt),hl ; no fixed or
ld (mobcnt),hl ; mobile files yet
ld hl,(heap)
ld (fixpnt),hl ; this is where they go
ld (mobpnt),hl
ld hl,0
ld (linnum),hl ; line number
ld (bufcnt),a ; no bytes in buffer
gnam1: call getlin ; get next input line
ret z ; all done
ld hl,(inline) ; point to line
call sksp ; skip spaces
ld a,(hl)
or a ; empty line?
jr z,gnam1 ; ignore
cp ';' ; fixed / mobile spec?
jr nz,gnam2
call cmd ; process fixed / mobile spec
jr gnam1
gnam2: call fnam ; process filename
jr gnam1
; Process command line
cmd: inc hl ; skip over ';'
call sksp ; and spaces
ld de,fixstr ; 'FIXED'
ld b,5
call compb
ld a,1 ; flag if fixed
jr z,cmd1
ld de,mobstr ; 'MOBILE'
ld b,6
call compb
ld a,0 ; flag if mobile
ret nz
cmd1: ld (fixmob),a ; set new flag value
ret
; Extract filename from input line
fnam: call gdir ; get directory
ret nz ; ignore if error
push hl ; save pointer to start of name
push bc ; and user number
ld de,16
call getheap ; extend heap
ld hl,(mobcnt)
add hl,hl ; x 2
add hl,hl ; x 4
add hl,hl ; x 8
add hl,hl ; x 16 (size of mobile list)
ld a,(fixmob)
or a ; fixed or mobile?
jr z,fnam2
ld a,h
or l ; empty?
jr z,fnam1
ld b,h
ld c,l
ld hl,(mobpnt)
dec hl
add hl,bc ; last byte of current location
ld de,16 ; offset
ex de,hl
add hl,de
ex de,hl
lddr ; make space to expand fixed list
fnam1: ld hl,(fixcnt)
inc hl ; increment number of fixed files
ld (fixcnt),hl
ld hl,(mobpnt)
ld de,16
ex de,hl
add hl,de ; shift mobile base up
ld (mobpnt),hl
ex de,hl ; address of next fixed entry in hl
jr fnam3
fnam2: ld de,(mobpnt)
add hl,de ; address of next mobile entry
push hl
ld hl,(mobcnt)
inc hl
ld (mobcnt),hl
op