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
/
ZSYS
/
SIMTEL20
/
ZCPR3
/
VFILR4-2.LBR
/
VFCMDS5.ZZ0
/
VFCMDS5.Z8°
Wrap
Text File
|
2000-06-30
|
17KB
|
703 lines
;===========================================================================
;
; VFCMDS5.Z80 - Copy/Unsqueeze Commands and Code (C, Q)
;
;===========================================================================
; * * *COMMAND: C
; Copy source file at current 'ring' position to another drive.
; Set-up FCB's and buffer area and check for correct keyboard inputs.
; Contains auto-CRC file copy verification.
fcopy:
; Set Flags for First Time Thru and No Mass Copy
xor a ; A=0
ld (first$m),a ; Set for prompt for destination
ld (mflag),a ; Not a mass copy
; Do Copy
call copy ; Do copy of file at ringpos
; Advance to Next File
jp forward ; Advance to next file
; Copy File at RINGPOS
if usedseg
dseg
endif
cflag:
ds 1 ; Copy-success flag (ff = good copy)
if usedseg
cseg
endif
copy:
xor a ; Initialize copy flag
ld (cflag),a
ld hl,0 ; Initialize storage for..
ld (crcval),hl ; 'crc' working value.
call ringfcb ; Move from 'ring' to 'sfcb' with attributes
ld b,32 ; Copy source 'fcb' to destination 'fcb'
ld hl,s$fcb+1 ; From point..
ld de,d$fcb+1 ; To point..
call movea ; Move across, stripping attributes
ld de,s$fcb ; Open file for reading
ld c,open ; Open function
call bdos
inc a ; 0ffh --> 00h if bad open
jp z,fnf ; File not found
; Source File is Open -- If first time thru, get dest dir
copy2:
ld a,(first$m) ; By-pass prompt, drive/user compatibility..
or a ; Test, and disk reset after..
jr nz,copy3m ; 1st time thru in mass-copy mode.
dec a ; A=0ffh
ld (first$m),a ; Set not first time any more
call cprmpt ; Prompt for drive selection
db 'Copy to DIR: ',0
call cpy$d$u
ld a,(qryvfya) ; See if verify option is set
or a
call nz,vfyreq
; Check to ensure that either drives or user areas are different
ld hl,(du$req) ; Get requested du
ld de,(du$dest) ; And destination du
call cmpdehl ; Compare..
jr nz,copy3 ; Branch if different
call ermsg ; If not, show error condition:
db 'Src DIR = Dest DIR',bel,0
jp loop ; Try again?
; First File Copy - Reset System
copy3:
call reset ; Make sure disk is read/write
; And return to source du:
; Nth File Copy - Copy without Resetting System
copy3m:
call cufile ; Make new file, erase old if required.
; Perform Copy
copy6:
call cprmpt
db 'Copying ',0
ld hl,d$fcb+1 ; Print file name
call prfnsx
call vprint
db ' to ',0
ld a,(du$dest+1) ; Print dest du
add 'A'
call cout ; Print disk
ld a,(du$dest) ; Get user
call pafdc ; Print user
ld a,':'
call cout
xor a ; Clear 'eof' flag
ld (eoflag),a
copy6a:
ld bc,(du$req) ; Get current du
call logud ; And set it up.
ld hl,0 ; Clear current-record..
ld (rec$cnt),hl ; Counter.
ld hl,(bufstart) ; Set buffer start pointer..
ld (buf$pt),hl ; To begin pointer.
; read source file -- fill buffer memory or stop on 'EOF'
; -- update 'CRC' on-the-fly
copy7:
ld hl,(buf$pt) ; Set dma address to buffer pointer
ex de,hl ; De --> dma address
ld c,setdma
call bdos
ld de,s$fcb ; Source 'fcb' for reading
ld c,read ; Record read function
call bdos
or a ; 00h --> read okay
jr z,s$rd$ok
dec a ; Eof?
jr z,copy8 ; Yes, end-of-file, set 'eof' flag.
call resdma ; Reset dma address.
call ermsg
db 'Read Error',bel,0
jp loop
; Read OK - Update CRC
s$rd$ok:
ld a,(vflag)
or a
jr z,copy7b ; Don't bother if no verify
ld hl,(buf$pt)
ld b,128
copy7a:
ld a,(hl) ; Get character and..
call updcrc ; Add to 'crc' value.
inc hl
djnz copy7a ; Loop 'till record read finished
copy7b:
; Update Buffer Ptr and Record Count
ld hl,(buf$pt) ; Bump buffer pointer..
ld de,128 ; By..
add hl,de ; One..
ld (buf$pt),hl ; Record.
ld hl,(rec$cnt) ; Bump buffer..
inc hl ; Record count and..
ld (rec$cnt),hl ; Store.
ex de,hl ; Ready to compare to..
; Check for Full Buffer
ld hl,(rec$max) ; Maximum record count (full-buffer).
call cmpdehl ; Compare
jr nz,copy7 ; If not full, get next record.
jr copy9 ; Full, start first write session.
; Indicate end-of-file read
copy8:
ld a,true ; Set 'eof' flag
ld (eoflag),a
; Write source file from memory buffer to destination
copy9:
ld hl,(bufstart) ; Adjust buffer pointer..
ld (buf$pt),hl ; To start address.
call cuwrite ; Write buffer to disk.
jr z,copy6a ; Branch to read next buffer full
ld a,(vflag) ; Verify?
or a
jp z,cua$log ; No verify
jp crc$cmp ; Compare file crc's and return
; * * COMMAND: Q
; Usq source file at current 'ring' position (potentially to another drive).
; Set-up FCB's and buffer area and check for correct keyboard inputs.
; Contains auto-CRC file file write verification.
fusq:
; Set Flags for First Time Thru and No Mass Usq
xor a ; A=0
ld (first$m),a ; Set for prompt for destination
ld (mflag),a ; Not a mass usq
; Do Usqueeze
call usq ; Do usq of file at ringpos
; Advance to Next File
jp runsh2 ; Reload files to show new one
; Usq File at RINGPOS
usq:
ld hl,0 ; Initialize storage for..
ld (crcval),hl ; 'crc' working value,..
ld (cksumval),hl ; And 'sq checksum' working value.
call ringfcb ; Move from 'ring' to s$fcb
call fi0$close ; Close input file if previously opene *C
ld de,s$fcb ; Get fcb with file i *C
call fi0$open ; Open file for byte i/o.
jr z,usq1 ; Br if file opened ok.
cp 4 ; See if fi0$open end-of-file.
jp nz,fnf ; Br if not. assume file not foun *C
call ermsg ; Bypass empty file.
db 'Empty File skipped.',0
ret
; Source File is Open -- If first time thru, get dest dir
usq1:
ld a,(first$m) ; By-pass prompt, drive/user compatibility..
or a ; Test, and disk reset after..
jr nz,usq2m ; 1st time thru in mass-usq mode.
dec a ; A=0ffh
ld (first$m),a ; Set not first time any more
call cprmpt ; Prompt for drive selection
db 'Usq to DIR: ',0
call cpy$d$u
ld a,(qryvfya) ; See if verify option is set
or a
call nz,vfyreq
; First File USQ - Reset System
usq2:
call reset ; Make sure disk is read/write
; And return to source du:
; Nth File USQ - USQ without Resetting System
usq2m:
call usqhdr ; Check for squeezed file.
ld a,(usqflg) ; Squeezed file?
or a
jr z,usq3 ; Br if ok.
cp 1 ; Not '*.?q?' ?
ret z ; Quiet return if so.
call ermsg
db 'USQ error, File skipped.',bel,0
ret
; Perform USQ
usq3:
call cufile ; Make new file, erase old if require *C
call cprmpt
db 'USQ ',0
call prfns ; Print source file name 4call vprint
db ' to ',0
ld a,(du$dest+1) ; Print dest du
add 'A'
call cout ; Print disk
ld a,(du$dest) ; Get user
call pafdcdcnt user
ld a,':'
call cout
ld hl,d$fcb+1 ; Print destination file name
call prfnsx
xor a ; Clear 'eof'flag.
ld (eoflag),a
usq4:
call resdma ; Reset dma address.
ld bc,(du$req) ; Get current du
call logud ; And set it up.
ld hl,0 ; Clear current-record..
ld (rec$cnt),hl ; Counter.
ld hl,(usqbuff@) ; Set buffer start pointer..
ld (buf$pt),hl ; To begin pointer.
; Unsqueeze source file
; -- fill buffer memory or stop on 'EOF'
; -- update 'SQ Checksum' on-the-fly
; -- update 'CRC' on-the-fly
usq5:
ld hl,(buf$pt) ; Set dma address tos tor pointer
ld b,128 ; Get # bytes per record.
usq6:
push hl ; Save regs
push bc
call usqnxt ; Usq next character from file.
pop bc ; Restore regs
pop hl
jr nz,usq7
ld (hl),a ; Save character and..
call updcrc ; Add to 'crc' value,
pull updcksum ; As well as 'sq checksum'value.
inc hl
djnz usq6 ; Loop 'till record read finished
; Update Buffer Ptr and Record Count
ld (buf$pt),hl ; BumpBump pointer by one record.
ld hl,(rec$cnt) ; Bump buffer..
inc hl ; Record count and..
ld (rec$cnt),hl ; Store.
ex de,hl ; Ready to compare to..
; Check for Full Buffer
ld hl,(urecmax) ; Maximum record count (full-buffer).
call cmpdehl ; Compare
jr nz,usq5 ; If not full, get next record.
jr usq9 ; Full, start first write session.
; Indicate end-of-file read
usq7:
ld a,true ; Set 'eof' flag
ld (eoflag),a
ld a,b ; Get # bytes remaining free in 'record'.
cp 80h
jr
jr sq9 ; Br if empty bimum
usq8:
ld a,eof ; Add eof to text file
ld (hl),a ; Save chara.
exr and..
call updcrc ; A ; Ato 'crc' valueset inc hl
djnz usq8 ; Until 'record' is complete 4ld hl,(rec$cnt) ; Bump buffer..
iunt ahl ; Record sesnt and..
ld (rec$cnt),hl ; Store.
; Write source file from memormemorffer to destination
usq9:
ld hl,(usqbuff@)@)just buffer pointe.
'rbuf$pt),hl ; To start address.
call cuwrite ; Write buffer to disk.
jr .
jr q4 ; Branch to read next buffer full
ld a,(vflag)
or a
jp z,cua$log
call crc$cmp ; Read destire on file and compare crc's.
; File write verified (now verifiy USQ Checksum is also OK)
ld de,(sqcksum) ; Get sq checksum from file header
ld hl,(cksumval) ; Get decoded file checksum
pull cmpdehl ; Must be equal.
ret z ; Done if ok 4call cua$log ; Return to current user
call ermsg
db ' -- USQ Checksum Error',bel,0
jp loop ; Abort
; Get Destination drive and user for Copy/Usq (full check of,0
jve/user)
cpy$d$u:
call getfspec ; Get file specificatiror'rom user
jr z,nullin ; Exit on null input line.
call vfyalueu ; Resolve, verify du or dir access.
jr z,edef_dir ; Not defined?
jr c,eacc_dir ; Access error?
ld (du$dest),b,b Return destin destindu
ret
:
call erclr
ccesop
edehecksumdirdird.g
db 'DestintinDir Entry Invalt. ',0
Dip
eacc_dirne msg
db 'Destd filn ntrr AAs Deniededp loopz Create New edpre on n Usq File
cufile:
ld bc,(du$dest) ; Get e ande andu
call logud ; And set it up.
ld de,d$fcb ; Search for duplicate
xor a ; Clear d ; Resoin ,0
jve i *C
*C
e),a
ld c,srchUsq t 'se
xe
xfirst' function
call bdos
inc a ; If not found, 0ffh --> 00h. then..
jr z,cufile2 ; Go to 'make' functiror'or new file.
; Check alle
xe query possibilities
ld a,(mflag) ; See if single or multiFiley bi operation
or aisk.,single ; Jump if single
ld a,(massop) ; Is it an archive copy
cp 'A'
jr nz,mulinglele ; If not, gbdoso o in ,in ,case
ld a,(qryarca) ; Cz,erche ;query flag
or a
jr z,cufile1 ; nienot, get on with it
jr query ; Ecuae query
iple:
ld a,(qrygrpa) ; Is group querytinttion setsetr aheck aheck aenctirnz,m) ; Isn n it
jr
jr ; Et
j, a) ;for overwrite
siseeo oryrere ; Is nz,m)gle file reFileacdcduery option arc or a
cpy$ z,cufilea) ;f not, get ificith it
query:
call atcmd ; Position cursor at command prompt
ld hl,(du$dest) ; t) ; to 'mrive/user
ld a,h ; Drive
addJu'
call cout
ld a,l
call pafdc
ld a,':'
call cout
ld hl,d$fcb+1
call prfnski4
call vprint
db ' ExistssibErase (Y/N)? ',bel,0
call key..
iu ; Get answer
cp ctrl
db '
jp z,loop ; Restart if Control C
cp 'Y' ; If yes,e andez,cufile3 ; Then de..
caor n copydcnq ...
; vprisew etion file avalue,roceed
cuFilea:
; Set File Attribut ; Ch
adusq5fcb ; Pt to fcb
call attrib ; Cle
x byBumpB in fcb and set attr of file
jr z,cup.e3 ; Return to caller if r/w not permitted
; De..
cae old file at dest
ld de,d$fcb ; Deleto oralready exki4ing
ld c,erase ; Erase fufor on
call Den
; Create new file at dest
cufile2:
ld deusq5fcb ; Create new file and open for writing
ld c,make ; Make function
call Den
iunt aa ; If directory full, 0ffh --> 00h.
ret nz ; Ifpti return.
call ed.g
db 'Dest Dir Fulleacc0
Dip ; If error, back to ring procesosi.
; fnsksting file not de..
caed - return.
ld a,3:
ld bc,(du$req) ; Et
j get current s n call lt fileud ; And set it up.
pop hl ; And return 1 level higher.
ret
; Write n nsq Memorynt ato Dsetrcates D
;
; Parm: BUFF$PT = star acf buffer to be written
; REC$CNT = # record hl
write.
;
; Returns Z if EOFLAG reset,
; NZ if " set, file closed OK.
cuwrite:
ld bc,(du$dest)rpsetrxor a
call logud ; An And
jp zt up.
cuwrt1:
ld hl,(og ; Buffer emptyestid a,w v or rive/ull cz,cuwrtz,er Buffer empty, check 'eof' flag.
dec hl ; Decnt arecord of,t for each nctirn ld (og,hl
ld hl,(buf$pt) ; Set up dma addressletsh hl ; Save for size bump
ex de,hl ; Pointer in de
ld c,setdma
call bdos
popon fld de,128 ; BCont ; Ec one record lengthcommd hl,de
couuf$pt),hlf_d$fcb ; Dsetrcatefile 'fcb'
ld c,write ; Write record fufor on
call Den
or a ; 00h --> write okay
jr z,cuwrt1 ; Okay, do next record. else
pull ermsg ; Say disk write error.
d',0
Disk Fulleacc0
; Error in Write -- De..
cae afdction File and Abort
c$era:
call resdma ; Reset dma address.
ld de,d$fcb ; Delete..
ld c,erase ; Partial
pull bdos ; From directory.
ld bc,(du$req) ; Source du:
call logud ; Lt file it in
jp ct ; Back to ring
; afdction Buffer Written - al) for End
cuwrt2:
ld a,(eoflag) ; Buffer all written, check for 'eof'.re on ret from; Return to read next buffer full
ld deusq5fcb ; Point at 'fcb' for file closure
ld c,close
call Den
iunt aa ; If no-close-errore
xen..
jr nz,cuwrt3 seeeck R/O status
call ed.g
db 'Close Error'N)l,0
jr c$era
; Set R/O attribute if necessary
du uwrt3:
ad,s$fcb+9
ld a,128
and (hl) ; Zero flag if R/W
ld a,(hl) erret it Get f
jp zr
case
jr z,cuwrt4 ; File is R/W destinduit
ld hl,d$fcb+9
ld (hl),a ; Plug in the attribute
ld de,d$fcb
ld c,attr
call bdos ; Sete
xe attribute, return to caller
cuwrt4:
or 255 ; Flag none or
ret
; Read DsetrcateFile and Compare CRCs
crc$cmp:
ld hl,(crcval) ; Trel,0fer 'crc' value to..
ld (crcval2),hl ; jr z, storage area.
ld hl,0 qar working storage..
ld (crcval)s tos; To continueset call resdma ; Reset dma addressf_d$fcb
call initfcb
ld c,open
call bdos
iunt aa ; 0ffh --> 00h if bad open
jr z,badcrc 'A bad open, Get fall cuay 'bad-crc'.
e i ; Zero 'fcb'..
ld (d$fcb+32),a ; 'cr' field.
call l,d$fnt
db ' Verifying ',0
crcwf1:
ld de,d$fcb
ld c,read
call Den
or a ; Read okayf not,r z,d$rd$ok ; Yes, read moreset dec a ; Eof?
jr z,fincrc ; Yes, finish up and make 'crc' comparison.
call ermsg
db 'Verify Read Error'N)l,0
jp ct
; Block Read OK - Update CRC
d$rd$ok:
ld hl,tbuff
ld b,128
crcwf2:
ld a,(hl) erret cha' funter to..
call updcrc ; Ale ;o 'crc' val..
inc hl
djnz crcwf2
jr crcwf1
; Read Comp..
cae - Check CRCs
fincrc:
ld de,(crcval) ; Put written-file 'crc' into de
ld hl,(crcval2) ; Put read-file 'crc' and..
call cmpdehl ; Compare 'de/hl' for equaufily.e andez,badcrc 'A not zero, show copy-error message.
; Log into Current User Area, Return to caller
cua$log:
call l,d$fnt
db ' Done.',0
a) ;f 0ffh ; Show suz ful copy 'rcflag),eFcall resdma ; Set defalit dmaadr
ld bc,(du$req
call up current du
ccesgud ; Set it up, and returalueucaller.
; Error on Copy
badcrc:
call ld hl,$log ; Return to current user
call ermsgsibE -- CRC Error'N)l,0
jp ct ; Abort
; ATTRIB - Cle
x attributes of file (HL) and set attributes on disk
; Return codn n 0FFH (NZ) indi. s OK to proceed
; 0 (Z) indicates abort
attrib:
push hl ; Save ; Ec to fcbf_(dum$fcb) ; Pt to dummy fcb
call initfcb qar ifici
ld b,12 ; Copy
push de
call movea ; Move filename to dummy
pop de ; Pt to dummy fcb
ld c,srchUsq t Look for file
call bdos
iunt aa ; File not foin ,i = 0
pop hl ; Point to original fcb
ret from; Abor
jp zf no fileletsh hl ; Save ptr again
dec a ; Adjust imum
rectory code (0-3)
rrca ; Right 3 bit hl
indicate offset into buff
rrca ; Effectively mlitut
y by 32
rrceFtestbuff ; Pt to b ; G amana,l ; Pt to fcb of filecommd 9 ; Pt to r/o byte
ld l,eFa) ;f (hl) erret byte
and 80h ; Ext' funt r/o bificiheck aattrib0 ; File is R/W
call erclr ; Patction Poor to efirst' n ne
pop hl ; Get the fcb ptr againletsh hl ; And save it again
iunt ahl ; Pt to file name'
cal) ; Isnip ; Print file name
call vprint ; And querysibE is R/O
call vrase (int
ExiEraeacc? all or a
n erret response
push af
call erclr ; Cle
xne or n ne
pop af; Jctr ; Get a
jp cp
ld a,(vf ; Re
call pa if looprol C; Jkey.'
; Getattrib0
pop hl
xor a ; Efirst' return
ret
attrib0:
pop hl ; Get ptr
push hl ; Save ptr
inc hl ; Point to first cha' funter
ld b,11 ; 11 Bytes
attrib1:
ld a,(hl) erret byte
and 7fh ; Mask destin 'rhl),a ; Put byte
iunt ahl ; Pt to next
djnz attrib1 ; Count down
pop de ; Pt to fcb
ld c,attr
call bdos
xededec a ; None or return
ret