home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / z80dos / arkdatzd.ark / ARKDATZD.Z80 < prev   
Encoding:
Text File  |  1989-02-06  |  3.3 KB  |  141 lines

  1. ; ZSDOS datestamping overlay for ARK04 by Howard Goldstein
  2.  
  3. ; This overlay allows ARK04.COM to use the "last modified" date and time of
  4. ; the file being inserted into the archive for the date/time stamp in the
  5. ; archive's directory.  If the file has no "modified" stamp, then the "create"
  6. ; stamp is used.  If this is not available we fall back to current time, and
  7. ; if not running under ZS/ZDDOS or if a clock is not installed, then
  8. ; default time and date stored at the beginning of ARK04.COM are used.
  9. ; In order for this overlay to work correctly, ARK04.COM must first be patched
  10. ; with ARK04FIX.HEX.
  11.  
  12.     org    103h        ; Overlay starts here
  13.  
  14. gtim    equ    98        ; ZSDOS get time function
  15. gstmp    equ    102        ; ZSDOS get stamp
  16. gdma    equ    47        ; ZSDOS return dma address function
  17. setdma    equ    26        ; Set dma
  18. bdos    equ    5
  19. lf    equ    10
  20.  
  21. ; Overlay header -- do not change!
  22.  
  23. yr:    ds    1
  24. mo:    ds    1
  25. day:    ds    1
  26. hr:    ds    1
  27. mn:    ds    1
  28.  
  29.     jp    tdate
  30.     jp    fdate
  31. cdate:    ds    3
  32. puts:    ds    3
  33.  
  34. ; Tdate:  get current time and print signon.
  35. ; IX, IY, and BC must be preserved
  36.  
  37. tdate:    push    ix
  38.     push    iy
  39.     push    bc
  40.     ld    hl,vermsg
  41.     call    puts
  42.     ld    de,curdt        ; Place to store time
  43.     ld    c,gtim        ; Get current time
  44.     call    bdos
  45.     dec    a
  46.     ld    (nozd),a    ; Save return code as a flag
  47.     pop    bc
  48.     pop    iy
  49.     pop    ix
  50.     ret
  51.  
  52. ; FDATE:  get file's date stamp.  If datestamp = 0 use current
  53. ; time/date.  If date stamping not supported use default values.
  54.  
  55. fdate:    push    ix
  56.     push    iy
  57.     push    bc
  58.     ld    a,(nozd)    ; ZSDOS functions supported?
  59.     or    a
  60.     jr    nz,fdexit    ; No, use default date/time
  61.     ld    c,gdma        ; Save current dma address
  62.     call    bdos
  63.     ld    (savdma),hl
  64.  
  65. ; Set DMA for get stamp functin
  66.  
  67.     ld    de,stpbuf
  68.     ld    c,setdma
  69.     call    bdos
  70.  
  71.     pop    de        ; Pt to target fcb
  72.     push    de
  73.     ld    c,gstmp
  74.     call    bdos
  75.     dec    a        ; Test return
  76.     jr    nz,usecur    ; Date stamps not supported, use cur t/d
  77.     ld    de,modmo    ; Look at returned (modified) month
  78.     ld    a,(de)
  79.     dec    de        ; Point to year
  80.     or    a
  81.     jr    nz,convert    ; Good date, go convert to binary
  82.  
  83.     ld    de,stpbuf+1    ; Look at returned (created) month
  84.     ld    a,(de)
  85.     dec    de        ; Point to year
  86.     or    a
  87.     jr    nz,convert    ; Good date, go convert to binary
  88.  
  89. usecur:    ld    de,curdt    ; Pt to current date/time
  90.  
  91. ; Convert ZSDOS BCD date/time string to binary.  Enter with DE pointing
  92. ; to string.
  93.  
  94. convert:
  95.     ld    hl,yr        ; Point to destination
  96.     ld    b,5        ; 5 bytes
  97. loop:    ld    a,(de)        ; Get bcd byte
  98.     call    bcd2bin        ; Convert to binary
  99.     ld    (hl),a        ; Store
  100.     inc    hl
  101.     inc    de
  102.     djnz    loop
  103.  
  104. fdexit:    call    cdate        ; Give it to ark
  105.     ld    de,(savdma)    ; Restore dma
  106.     ld    c,setdma
  107.     call    bdos
  108.     pop    bc
  109.     pop    iy
  110.     pop    ix
  111.     ret
  112.  
  113. ; Convert BCD value in A to binary value returned in A
  114.  
  115. bcd2bin:
  116.     PUSH    DE
  117.     ld    d,a        ; Save original in d
  118.     and    0f0h
  119.     ld    e,a        ; Save high nybble in  e
  120.     ld    a,d        ; Recover original
  121.     and    a,0fh        ; Get low nybble
  122.     srl    e        ; Divide high nybble by 2
  123.     add    a,e        ; Add to low nybble
  124.     srl    e
  125.     srl    e        ; Divide high nybble by 4
  126.     add    a,e        ; Add to low nybble again for final result
  127.     POP    DE
  128.     ret    
  129. ;
  130.  
  131. vermsg:    db    'ZSDOS version',lf,0
  132.  
  133. nozd:    ds    1        ; ZSDOS flag
  134. savdma:    ds    2        ; Original DMA address stored here
  135. curdt:    ds    5        ; Current date/time
  136. stpbuf:    ds    10        ; Buffer for file's stamps
  137. modyr:    ds    1
  138. modmo:    ds    9
  139.  
  140.     end
  141.