home *** CD-ROM | disk | FTP | other *** search
- ; ZSDOS datestamping overlay for ARK04 by Howard Goldstein
-
- ; This overlay allows ARK04.COM to use the "last modified" date and time of
- ; the file being inserted into the archive for the date/time stamp in the
- ; archive's directory. If the file has no "modified" stamp, then the "create"
- ; stamp is used. If this is not available we fall back to current time, and
- ; if not running under ZS/ZDDOS or if a clock is not installed, then
- ; default time and date stored at the beginning of ARK04.COM are used.
- ; In order for this overlay to work correctly, ARK04.COM must first be patched
- ; with ARK04FIX.HEX.
-
- org 103h ; Overlay starts here
-
- gtim equ 98 ; ZSDOS get time function
- gstmp equ 102 ; ZSDOS get stamp
- gdma equ 47 ; ZSDOS return dma address function
- setdma equ 26 ; Set dma
- bdos equ 5
- lf equ 10
-
- ; Overlay header -- do not change!
-
- yr: ds 1
- mo: ds 1
- day: ds 1
- hr: ds 1
- mn: ds 1
-
- jp tdate
- jp fdate
- cdate: ds 3
- puts: ds 3
-
- ; Tdate: get current time and print signon.
- ; IX, IY, and BC must be preserved
-
- tdate: push ix
- push iy
- push bc
- ld hl,vermsg
- call puts
- ld de,curdt ; Place to store time
- ld c,gtim ; Get current time
- call bdos
- dec a
- ld (nozd),a ; Save return code as a flag
- pop bc
- pop iy
- pop ix
- ret
-
- ; FDATE: get file's date stamp. If datestamp = 0 use current
- ; time/date. If date stamping not supported use default values.
-
- fdate: push ix
- push iy
- push bc
- ld a,(nozd) ; ZSDOS functions supported?
- or a
- jr nz,fdexit ; No, use default date/time
- ld c,gdma ; Save current dma address
- call bdos
- ld (savdma),hl
-
- ; Set DMA for get stamp functin
-
- ld de,stpbuf
- ld c,setdma
- call bdos
-
- pop de ; Pt to target fcb
- push de
- ld c,gstmp
- call bdos
- dec a ; Test return
- jr nz,usecur ; Date stamps not supported, use cur t/d
- ld de,modmo ; Look at returned (modified) month
- ld a,(de)
- dec de ; Point to year
- or a
- jr nz,convert ; Good date, go convert to binary
-
- ld de,stpbuf+1 ; Look at returned (created) month
- ld a,(de)
- dec de ; Point to year
- or a
- jr nz,convert ; Good date, go convert to binary
-
- usecur: ld de,curdt ; Pt to current date/time
-
- ; Convert ZSDOS BCD date/time string to binary. Enter with DE pointing
- ; to string.
-
- convert:
- ld hl,yr ; Point to destination
- ld b,5 ; 5 bytes
- loop: ld a,(de) ; Get bcd byte
- call bcd2bin ; Convert to binary
- ld (hl),a ; Store
- inc hl
- inc de
- djnz loop
-
- fdexit: call cdate ; Give it to ark
- ld de,(savdma) ; Restore dma
- ld c,setdma
- call bdos
- pop bc
- pop iy
- pop ix
- ret
-
- ; Convert BCD value in A to binary value returned in A
-
- bcd2bin:
- PUSH DE
- ld d,a ; Save original in d
- and 0f0h
- ld e,a ; Save high nybble in e
- ld a,d ; Recover original
- and a,0fh ; Get low nybble
- srl e ; Divide high nybble by 2
- add a,e ; Add to low nybble
- srl e
- srl e ; Divide high nybble by 4
- add a,e ; Add to low nybble again for final result
- POP DE
- ret
- ;
-
- vermsg: db 'ZSDOS version',lf,0
-
- nozd: ds 1 ; ZSDOS flag
- savdma: ds 2 ; Original DMA address stored here
- curdt: ds 5 ; Current date/time
- stpbuf: ds 10 ; Buffer for file's stamps
- modyr: ds 1
- modmo: ds 9
-
- end