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 / CPM / BDOS / Z80DOS10.LBR / SAVESTMP.ZZ0 / SAVESTMP.Z8°
Text File  |  2000-06-30  |  5KB  |  216 lines

  1. ; Program:    SAVESTAMP for Z80DOS systems.
  2. ; Author:    Carson Wilson
  3. ; Assembly:    Z80ASM, PDLN, SYSLIB
  4. ; Date:     September 26, 1987
  5. ; Version:    1.0
  6. ;
  7. ; Purpose:    Copies create date from one file to another under Z80DOS.
  8. ;
  9. ; Usage:    By using SAVESTAMP, the creation date of modified files
  10. ;        can be preserved after using an editor or other program which
  11. ;        renames the original file to filename.BAK.
  12. ;
  13. ; Syntax:
  14. ;
  15. ;    SAVESTMP or SAVESTMP /                    - Display help.
  16. ;    SAVESTMP [du: or dir:]dest.fil [du: or dir:]source.fil    - ZCPR usage
  17. ;    SAVESTMP [d:]dest.fil [d:]source.fil            - CP/M usage
  18. ;
  19.  
  20. bdos    equ    5
  21. bell    equ    7
  22. tab    equ    9
  23. cr    equ    0dh
  24. lf    equ    0ah
  25. fcb1    equ    5ch
  26. fcb2    equ    6ch
  27. defDMA    equ    80h
  28. dmastp    equ    0e0h    ; Stamp indicator in DMA after search
  29. bwrite    equ    14    ; BIOS write block call with SYSLIB
  30. seldsk    equ    14    ; BDOS select disk
  31. sfirst    equ    17
  32. user    equ    32    ; BDOS set/get user
  33. GetStp    equ    54    ; Z80DOS function call
  34. user1    equ    69h    ; ZCPR user # for fcb1
  35. user2    equ    79h
  36.  
  37. vers    equ    10
  38.  
  39.     .request SYSLIB
  40.  
  41.     external moveb,bios,print,pfn2
  42.  
  43. begin:
  44.     jp    start
  45.     db    'Z3ENV'
  46.     db    3
  47. envaddr:
  48.     dw    00000h        ; Environment address
  49.     dw    begin
  50. start:
  51.     call    print
  52.     db    cr,lf,'SAVESTAMP: ',0    ; sign-on
  53.     ld    a,(defdma)
  54.     or    a
  55.     jr    z,help        ; No input?
  56.     ld    a,(fcb1+1)    ; Get 1st char. after possible spaces
  57.     cp    '/'        ; Help?
  58.     jp    nz,copystmp    ; No
  59.     ld    a,(fcb1+2)
  60.     cp    ' '        ; Next char. non-blank?
  61.     jp    nz,copystmp    ; Yes
  62. ;
  63. ; Display help
  64. ;
  65. help:
  66.     call    print
  67.     db    'Version ',vers/10+'0','.',vers    mod 10+'0','.'
  68.     db    tab,'Copies Z80DOS file create date.',cr,lf
  69.     db    ' Syntax:',cr,lf
  70.     db    tab,'SAVESTMP [du: or dir:]dest.fil [du: or dir:]source.fil'
  71.     db    tab,'- ZCPR usage',cr,lf
  72.     db    tab,'SAVESTMP [d:]dest.fil [d:]source.fil'
  73.     db    tab,tab,tab,'- CP/M usage',cr,lf,0
  74.     ret
  75. ;
  76. ; Copy create date, if any
  77. ;
  78. copystmp:
  79.     ld    hl,(envaddr)    ; Get environment address
  80.     ld    a,h        ; Test if running under Z3
  81.     or    l
  82.     ld    (z3flg),a    ; Zero if not ZCPR environment
  83.                 ; ..non-zero if ZCPR
  84.     jr    z,getsrc    ; Don't set user
  85. ;
  86. ; Search for source file
  87. ;
  88.     ld    a,(user2)    ; Get ZCPR source user
  89.     ld    e,a
  90.     ld    c,user
  91.     call    bdos        ; Select source user
  92. getsrc:
  93.     ld    de,fcb2
  94.     push    de        ; Save for error message
  95.     ld    c,sfirst    ; Search for first
  96.     call    bdos
  97.     pop    de        ; Retrieve file name
  98.     inc    a
  99.     jp    z,missing    ; A = 0ffh --> 0 = error
  100. ;
  101.     ld    c,getstp    ; Z80DOS call
  102.     call    bdos        ; HL --> file's stamp if any
  103.     ld    de,stamp    ; Point to buffer for source stamp
  104.     ld    b,2
  105.     call    moveb        ; SYSLIB copy 2 byte stamp to buffer
  106. ;
  107. ; Search for dest. file
  108. ;
  109.     ld    a,(z3flg)    ; ZCPR?
  110.     or    a
  111.     jr    z,getdest    ; No, don't select user
  112.     ld    a,(user1)    ; Get ZCPR dest. user
  113.     ld    e,a
  114.     ld    c,user
  115.     call    bdos        ; Select dest. user
  116. getdest:
  117.     ld    de,fcb1
  118.     push    de        ; For error message
  119.     ld    c,sfirst    ; Load BIOS dirbuf with dir. sector
  120.     call    bdos
  121.     pop    de
  122.     inc    a
  123.     jp    z,missing    ; 0ffh --> 0 = dest. file not found
  124. ;
  125.     dec    a        ; Save directory return code
  126.     push    af
  127. ;
  128. ; Got both files, now test destination for stamps
  129. ;
  130.     ld    a,(dmastp)    ; Test time stamps on dest.
  131.     cp    '!'
  132.     jr    z,stamps    ; Stamps found
  133.     pop    af
  134.     jp    nostamps    ; Not found, abort
  135. ;
  136. ; Stamps exist on destination, so copy stamp
  137. ;
  138. stamps:
  139.     call    print
  140.     db    'Altering creation date of ',0
  141.     ld    de,fcb1+1
  142.     call    pfn2
  143.     call    print
  144.     db    ' . . . ',0
  145. ;
  146. ; First select disk, if necessary
  147. ;
  148.     ld    a,(fcb1)    ; Dest. file's disk
  149.     or    a        ; Default disk?
  150.     jr    z,copy        ; Yes, so don't select disk
  151.     dec    a        ; 0 = A for SelDsk
  152.     ld    e,a        ; Non-default disk
  153.     ld    c,seldsk    ; Select disk so that BIOS sector
  154.     call    bdos        ; ..write goes to right disk!
  155. copy:
  156.     pop    af        ; Retrieve dir. search code
  157.     ld    e,a        ; (A = 0, 1, or 2)
  158.     sla    a        ; Multiply by 10
  159.     sla    a
  160.     add    a,e
  161.     sla    a
  162.     add    a,2        ; A = offset to create date (2,12,22)
  163.     ld    e,a        ; Save in E
  164.     xor    a
  165.     ld    d,a        ; Zero D
  166.     ld    hl,dmastp    ; Dir. stamp location in DMA buffer
  167.     add    hl,de
  168.     ex    de,hl        ; DE --> Dest file's create stamp
  169.  
  170.     ld    hl,stamp    ; Point to buffer holding source stamp
  171.     ld    b,2
  172.     call    moveb        ; SYSLIB copy 2 bytes from buffer to DMA
  173.  
  174.     ld    c,1        ; Force directory sector write of DMA
  175.     ld    a,bwrite    ; BIOS write sector
  176.     call    bios
  177.     or    a        ; BIOS return code: A = 0 --> okay
  178.     jp    nz,badwrite
  179.     call    print        ; Write ok
  180.     db    'Done.',cr,lf,0
  181.     ret            ; Done
  182. ;
  183. ; Error Routines
  184. ;
  185. nostamps:
  186.     call    print
  187.     db    bell,'No time stamps present on destination disk!'
  188.     db    cr,lf,0
  189.     ret
  190. ;
  191. missing:
  192.     inc    de
  193.     call    pfn2        ; SYSLIB print file name
  194.     call    print
  195.     db    ' not found.',cr,lf,bell,0
  196.     ret
  197. ;
  198. badwrite:
  199.     call    print
  200.     db    bell,'Write error!',cr,lf,0
  201.     ret
  202. ;
  203. ; Data area
  204. ;
  205.     dseg
  206.  
  207. z3flg:
  208.     ds    1        ; ZCPR environment
  209. stamp:
  210.     ds    2        ; Save date stamp
  211.  
  212.     end
  213.  
  214. ; END SAVESTMP.Z80
  215.  
  216.