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 / ENTERPRS / CPM / UTILS / S / Z80DOS10.ARC / Z80DTIME.Z80 < prev    next >
Text File  |  1989-09-15  |  7KB  |  252 lines

  1. ; Z80DOS - Z80 Disk Operating System
  2. ;
  3. ; Version 1.0 - 05 Sept. 87 by Carson Wilson
  4. ;
  5.  
  6. ; -------------------------------------------------------------------
  7. ;
  8. ; Z80DTIME.Z80 - Time Functions, Exit Routine, RAM Area
  9. ;
  10. ; -------------------------------------------------------------------
  11.  
  12. ;    Time Routines
  13.  
  14. ;
  15. ; Set file's time and date
  16. ;
  17. ;    Entry:    E = 2 - set creation date or get time stamp
  18. ;        E = 4 - Set last update time/date
  19. ;        E = 8 - Set last access time/date
  20. ;
  21. ;    Exit:    Z  if time stamps present
  22. ;        NZ if no time stamps
  23.  
  24. stime:    ld    hl,(dirbuf)        ; get directory entry
  25.     ld    bc,060h            ; offset entry point time/date stamp
  26.     add    hl,bc            ; add offset to time stamp
  27.     ld    a,(hl)            ; get time stamp byte
  28.     sub    021h            ; time stamp present?
  29.     ret    nz            ; no, return
  30.     ld    d,a            ; yes, clear d
  31.     add    hl,de            ; add entry (update/create/access)
  32.     ld    a,e            ; set access time if E ge 8 <crw>
  33.     and    8            ;
  34.     jr    z,stim1            ; E lt 8
  35.     srl    e            ; E ge 8, set to 4
  36. stim1:    ld    b,e            ; save # bytes to write
  37.     ld    a,(secpnt)        ; get sector pointer
  38.     rrca                ; shift 2 times
  39.     rrca
  40.     ld    e,a            ; save it
  41.     rrca                ; shift 2 times
  42.     rrca
  43.     add    a,e            ; add it (a=0,10,20)
  44.     ld    e,a            ; save in e
  45.     add    hl,de            ; add offset
  46.     ld    a,(funct)
  47.     cp    54            ; if set DOS time
  48.     ret    z            ; ..just point to date stamp
  49.     push    hl            ; save result
  50.     ld    c,0            ; time return date/time pointer in hl
  51.     push    bc            ; save 2 or 4 byte count <crw>
  52.     call    time            ; return pointer in hl
  53.     pop    bc
  54.     pop    de            ; get pointer
  55.     ld    c,b            ; set write 2 or 4 bytes <crw>
  56.     ld    b,0
  57.     ldir                ; copy 2 or 4 bytes to directory buff.
  58.     xor    a            ; set zero flag - time stamps present
  59.     ret                ; and return to caller
  60.  
  61. ;
  62. ; Store time stamp following file find, open, or make. <crw>
  63. ;
  64. ;    Exit:    HL points to file's 10-byte time stamp
  65. ;        stored in DOS for subsequent commands
  66. ;        when DOS-time is on (command 55).
  67. ;
  68. GetStp:
  69.     ld    e,2            ; point to file's stamp
  70.     call    stime            ; point to beginning of
  71.                     ; ..last file's stamp
  72.     ld    de,cdate        ; point to DOS storage
  73.     ld    (pexit),de        ; save for return
  74.     ld    bc,10
  75.     jr    nz,GtStp1        ; no stamp found
  76.     ldir                ; save full stamp
  77.     ret
  78. GtStp1:
  79.     ld    b,c
  80. GtStp2:
  81.     ld    a,0            ; else zero out storage
  82.     ld    (de),a
  83.     inc    de
  84.     djnz    GtStp2
  85.     ret                ; return to calling program
  86. ;
  87. ; Time - get time for stamping from DOS storage or BIOS <crw>
  88. ;
  89. ;    Entry:    rdwr and dtime both = 0ffh, get time from DOS
  90. ;            and reset dtime to 0
  91. ;        else get time from BIOS
  92. ;
  93. ; Format of time returned to pointer in HL:
  94. ;
  95. ;    HL + 0 = low  byte of date since Dec. 31, 1977
  96. ;    HL + 1 = high byte of date since Dec. 31, 1977
  97. ;    HL + 2 = hours     (BCD)
  98. ;    HL + 3 = minutes (BCD)
  99. ;    HL + 4 = seconds (BCD) (not used in time stamp)
  100. ;
  101.  
  102. time:
  103.     ld    a,(dtime)        ; Use DOS time?
  104.     or    a
  105.     jr    z,btime            ; no, get BIOS time
  106.     ld    a,(funct)
  107.     cp    22            ; creating file?
  108.     ld    hl,cdate        ; point to create date
  109.     jr    z,time2            ; yes
  110.     ld    hl,udate        ; no, point to update date/time
  111. time2:
  112.     xor    a
  113.     ld    (dtime),a        ; use DOS time for one call only
  114.     ret
  115. ;
  116. ; Get BIOS time to address DE
  117. ;
  118. gettim:    push    de            ; save address to put time
  119.     ld    c,0            ; get time address
  120.     call    btime            ; execute p2bios call
  121.     pop    de            ; restore address to put time
  122.     ld    bc,5            ; 5 bytes to move
  123.     ldir                ; store the time
  124.     ret                ; and return to caller
  125. ;
  126. ; Set BIOS time from address DE
  127. ;
  128. settim:    ex    de,hl            ; get address time in hl
  129.     ld    c,0ffh            ; set time address
  130.                     ; and fall through to p2bios call
  131. ;
  132. ; Get/Set time in BIOS clock interface
  133. ;
  134. ;    Entry:    C =  0: On return HL points to 5-byte time entry
  135. ;        C <> 0: 5-byte entry pointed to by HL sets system time
  136.  
  137. btime:                    ; get system time
  138.     push    hl            ; save value in hl
  139.     ld    hl,(timead)        ; get address time routine
  140.     ex    (sp),hl            ; put address on stack and restore hl
  141.     ret                ; execute BIOS time routine
  142. ;
  143. ; Use stored time stamp for very next DOS call <crw>
  144. ; ..all other DOS calls cancel DOS time thru p2exit
  145. ;
  146. UseStp:
  147.     or    0ffh
  148.     ld    (dtime),a        ; Use DOS time
  149.     pop    hl            ; clean up stack
  150.     jr    p2ext0
  151.  
  152. ; ----------------------------
  153.  
  154. ;    DOS exit routines
  155.  
  156. ; ----------------------------
  157.  
  158.  
  159. p2exit:    xor    a
  160.     ld    (dtime),a        ; turn off DOS time <crw>
  161.     ld    a,(fldrv)        ; test drive select used flag
  162.     or    a
  163.     jr    z,p2ext0        ; no then exit
  164.     ld    a,(FCB0)        ; get FCB byte 0
  165.     ld    (ix+0),a        ; save it
  166.     ld    a,(drive)        ; get old drive number
  167.     call    seldk            ; select disk
  168. p2ext0:    push    ix            ; save ix
  169.     pop    de            ; restore de
  170.     pop    ix            ; restore ix
  171.     ld    sp,(spsave)        ; get old sp
  172.     ld    hl,(pexit)        ; get exit code
  173.     ld    a,(funct)        ; get function code
  174.     ld    c,a            ; restore c
  175.     ld    a,l            ; copy function code
  176.     ld    b,h
  177.     ret                ; and return to caller
  178.  
  179. ; --------------------
  180.  
  181. ;    RAM area
  182.  
  183. ; --------------------
  184.  
  185. tabcnt:    defb    0            ; tab counter
  186. tabcx1:    defb    0            ; temporary tab counter (used by rdbuf)
  187. fcontp:    defb    0            ; list enable flag (control p)
  188. lastch:    defb    0            ; last character
  189. delay:    defb    0ffh            ; delay counter
  190. ;
  191. trans:    defw    0            ; translation vector
  192. temp0:    defw    0            ; number of files on drive
  193. dirbuf:    defw    0            ; directory buffer
  194. ixp:    defw    0            ; disk parameter block
  195. csv:    defw    0            ; check sum pointer
  196. alv:    defw    0            ; allocation vector pointer
  197. ;
  198. maxsec:    defw    0            ; maximum number of sectors/track
  199. nblock:    defb    0            ; number of blocks
  200. nmask:    defb    0            ; mask number of blocks
  201. nextnd:    defb    0            ; extent mask
  202. maxlen:    defw    0            ; maximum block number-1
  203. nfiles:    defw    0            ; maximum number of files-1
  204. ndir0:    defb    0            ; first two entries alv buffer
  205. ndir1:    defb    0
  206. ncheck:    defw    0            ; number of checksum entries
  207. nftrk:    defw    0            ; first track number
  208. ;
  209. dskro:    defw    0            ; disk R/O vector
  210. login:    defw    0            ; login vector
  211. DMA:    defw    080h            ; DMA address
  212. ;
  213. funct:    defb    0            ; function number
  214. pexit:    defw    0            ; exit code
  215. fldrv:    defb    0            ; drive select used flag
  216. rdwr:    defb    0            ; read/write flag
  217. ;
  218. FCB0:    defb    0            ; FCB byte 0
  219. user:    defb    0            ; user number
  220. drive:    defb    0            ; drive number
  221. defdrv:    defb    0            ; default drive number
  222. recdir:    defw    0            ; record directory (checksum)
  223. filcnt:    defw    0            ; file counter
  224. secpnt:    defb    0            ; sector pointer
  225. subflg:    defb    0            ; submit flag (reset disk command)
  226. ;
  227. dcopy:    defw    0            ; copy address FCB
  228. searex:    defb    0            ; exit code search
  229. searnb:    defb    0            ; search number of bytes
  230. searqu:    defb    0            ; search question mark used
  231. searpu:    defb    0            ; search public file
  232. ;next two flags added by b.h.
  233. diff:    db    0            ; Disk changed flag
  234. retflg:    db    0            ; allow retry on error when non-zero
  235. ;
  236. dtime    db    0            ; Flag for UseStp <crw>
  237. cdate    ds    2            ; Create date storage
  238. udate    ds    4            ; Update date/time
  239. adate    ds    4            ; Last access date/time <crw>
  240. ;
  241. spsave:    defw    0            ; stack pointer location
  242.     defs    64
  243. DOSs:    equ    $            ; DOS internal 64 byte stack
  244. DOSstop    equ    $
  245. ;
  246.      if    ((DOSstop-DOS) gt 3584)
  247.     * BDOS over 3584 bytes - too large!! *
  248.      endif
  249.  
  250. ; END Z80DTIME.Z80
  251.  
  252.