home *** CD-ROM | disk | FTP | other *** search
- ; Program: SAVESTAMP for Z80DOS systems.
- ; Author: Carson Wilson
- ; Assembly: Z80ASM, PDLN, SYSLIB
- ; Date: September 26, 1987
- ; Version: 1.0
- ;
- ; Purpose: Copies create date from one file to another under Z80DOS.
- ;
- ; Usage: By using SAVESTAMP, the creation date of modified files
- ; can be preserved after using an editor or other program which
- ; renames the original file to filename.BAK.
- ;
- ; Syntax:
- ;
- ; SAVESTMP or SAVESTMP / - Display help.
- ; SAVESTMP [du: or dir:]dest.fil [du: or dir:]source.fil - ZCPR usage
- ; SAVESTMP [d:]dest.fil [d:]source.fil - CP/M usage
- ;
-
- bdos equ 5
- bell equ 7
- tab equ 9
- cr equ 0dh
- lf equ 0ah
- fcb1 equ 5ch
- fcb2 equ 6ch
- defDMA equ 80h
- dmastp equ 0e0h ; Stamp indicator in DMA after search
- bwrite equ 14 ; BIOS write block call with SYSLIB
- seldsk equ 14 ; BDOS select disk
- sfirst equ 17
- user equ 32 ; BDOS set/get user
- GetStp equ 54 ; Z80DOS function call
- user1 equ 69h ; ZCPR user # for fcb1
- user2 equ 79h
-
- vers equ 10
-
- .request SYSLIB
-
- external moveb,bios,print,pfn2
-
- begin:
- jp start
- db 'Z3ENV'
- db 3
- envaddr:
- dw 00000h ; Environment address
- dw begin
- start:
- call print
- db cr,lf,'SAVESTAMP: ',0 ; sign-on
- ld a,(defdma)
- or a
- jr z,help ; No input?
- ld a,(fcb1+1) ; Get 1st char. after possible spaces
- cp '/' ; Help?
- jp nz,copystmp ; No
- ld a,(fcb1+2)
- cp ' ' ; Next char. non-blank?
- jp nz,copystmp ; Yes
- ;
- ; Display help
- ;
- help:
- call print
- db 'Version ',vers/10+'0','.',vers mod 10+'0','.'
- db tab,'Copies Z80DOS file create date.',cr,lf
- db ' Syntax:',cr,lf
- db tab,'SAVESTMP [du: or dir:]dest.fil [du: or dir:]source.fil'
- db tab,'- ZCPR usage',cr,lf
- db tab,'SAVESTMP [d:]dest.fil [d:]source.fil'
- db tab,tab,tab,'- CP/M usage',cr,lf,0
- ret
- ;
- ; Copy create date, if any
- ;
- copystmp:
- ld hl,(envaddr) ; Get environment address
- ld a,h ; Test if running under Z3
- or l
- ld (z3flg),a ; Zero if not ZCPR environment
- ; ..non-zero if ZCPR
- jr z,getsrc ; Don't set user
- ;
- ; Search for source file
- ;
- ld a,(user2) ; Get ZCPR source user
- ld e,a
- ld c,user
- call bdos ; Select source user
- getsrc:
- ld de,fcb2
- push de ; Save for error message
- ld c,sfirst ; Search for first
- call bdos
- pop de ; Retrieve file name
- inc a
- jp z,missing ; A = 0ffh --> 0 = error
- ;
- ld c,getstp ; Z80DOS call
- call bdos ; HL --> file's stamp if any
- ld de,stamp ; Point to buffer for source stamp
- ld b,2
- call moveb ; SYSLIB copy 2 byte stamp to buffer
- ;
- ; Search for dest. file
- ;
- ld a,(z3flg) ; ZCPR?
- or a
- jr z,getdest ; No, don't select user
- ld a,(user1) ; Get ZCPR dest. user
- ld e,a
- ld c,user
- call bdos ; Select dest. user
- getdest:
- ld de,fcb1
- push de ; For error message
- ld c,sfirst ; Load BIOS dirbuf with dir. sector
- call bdos
- pop de
- inc a
- jp z,missing ; 0ffh --> 0 = dest. file not found
- ;
- dec a ; Save directory return code
- push af
- ;
- ; Got both files, now test destination for stamps
- ;
- ld a,(dmastp) ; Test time stamps on dest.
- cp '!'
- jr z,stamps ; Stamps found
- pop af
- jp nostamps ; Not found, abort
- ;
- ; Stamps exist on destination, so copy stamp
- ;
- stamps:
- call print
- db 'Altering creation date of ',0
- ld de,fcb1+1
- call pfn2
- call print
- db ' . . . ',0
- ;
- ; First select disk, if necessary
- ;
- ld a,(fcb1) ; Dest. file's disk
- or a ; Default disk?
- jr z,copy ; Yes, so don't select disk
- dec a ; 0 = A for SelDsk
- ld e,a ; Non-default disk
- ld c,seldsk ; Select disk so that BIOS sector
- call bdos ; ..write goes to right disk!
- copy:
- pop af ; Retrieve dir. search code
- ld e,a ; (A = 0, 1, or 2)
- sla a ; Multiply by 10
- sla a
- add a,e
- sla a
- add a,2 ; A = offset to create date (2,12,22)
- ld e,a ; Save in E
- xor a
- ld d,a ; Zero D
- ld hl,dmastp ; Dir. stamp location in DMA buffer
- add hl,de
- ex de,hl ; DE --> Dest file's create stamp
-
- ld hl,stamp ; Point to buffer holding source stamp
- ld b,2
- call moveb ; SYSLIB copy 2 bytes from buffer to DMA
-
- ld c,1 ; Force directory sector write of DMA
- ld a,bwrite ; BIOS write sector
- call bios
- or a ; BIOS return code: A = 0 --> okay
- jp nz,badwrite
- call print ; Write ok
- db 'Done.',cr,lf,0
- ret ; Done
- ;
- ; Error Routines
- ;
- nostamps:
- call print
- db bell,'No time stamps present on destination disk!'
- db cr,lf,0
- ret
- ;
- missing:
- inc de
- call pfn2 ; SYSLIB print file name
- call print
- db ' not found.',cr,lf,bell,0
- ret
- ;
- badwrite:
- call print
- db bell,'Write error!',cr,lf,0
- ret
- ;
- ; Data area
- ;
- dseg
-
- z3flg:
- ds 1 ; ZCPR environment
- stamp:
- ds 2 ; Save date stamp
-
- end
-
- ; END SAVESTMP.Z80
-