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 / BEEHIVE / OS / Z80D24SR.ARC / Z80DTIME.Z80 < prev    next >
Text File  |  1991-02-10  |  6KB  |  238 lines

  1. ;
  2. ; Z80DOS - Z80 Disk Operating System
  3. ;
  4. ; Version 2.4    Maskable disk reset's using variable fixdrv
  5. ;        Now can assemble with Z80MR if Z80MR equate
  6. ;        set to -1.
  7. ;        Gene Nolan 4/9/89
  8. ;
  9. ;
  10. ;------------------------------------------------------
  11. ;
  12. ; Version 2.3    Fast file lookup
  13. ; Date:        4 Nov 88
  14. ; Update:    Eugene Nolan
  15. ;
  16. ;--------------------------------------------------------------
  17. ;
  18. ; Version 2.0a - BETA TEST VERSION - 6 Nov 87 by Carson Wilson
  19. ;
  20. ; Support file:    Z80DTIME.Z80
  21. ; Version:    2.0
  22. ; Date:        6 Nov 87
  23. ; Author:    Carson Wilson
  24. ; Changes:    Added internal time routine for systems without a 
  25. ;        real time clock.  This routine assembles if RTC is false.
  26. ;        Cleaned up and clarified code.
  27. ;
  28. ; Description:    Time Functions, Exit Routine, RAM Area
  29. ;         
  30.  
  31. ; ---------------------------------------------------------------------
  32.  
  33. ; Time Routines
  34.  
  35. ; -------------------------
  36.  
  37. ;
  38. ; STime - Set file's time and date at DMA buffer.
  39. ;
  40. ;    Entry:    E = 2 - set creation date or get time stamp
  41. ;        E = 4 - Set last update time/date
  42. ;        E = 8 - Set last access time/date
  43. ;
  44. ;    Exit:    Z  if time stamps present
  45. ;        NZ if no time stamps
  46.  
  47. STime:    ld    hl,(dirbuf)        ; get directory entry
  48.     ld    bc,060h            ; offset entry point time/date stamp
  49.     add    hl,bc            ; add offset to time stamp
  50.     ld    a,(hl)            ; get time stamp byte
  51.     sub    021h            ; time stamp present?
  52.     ret    NZ            ; no, return
  53.     ld    d,a            ; yes, clear d
  54.     add    hl,de            ; add entry (update/create/access)
  55.     ld    a,e            ; set access time if E ge 8 <crw>
  56.     and    8            ;
  57.     jr    Z,STim1            ; E lt 8
  58.     srl    e            ; E ge 8, set to 4
  59. STim1:    ld    b,e            ; save # bytes to write
  60.     ld    a,(secpnt)        ; get sector pointer
  61.     rrca                ; shift 2 times
  62.     rrca
  63.     ld    e,a            ; save it
  64.     rrca                ; shift 2 times
  65.     rrca
  66.     add    a,e            ; add it (a=0,10,20)
  67.     ld    e,a            ; save in e
  68.     add    hl,de            ; add offset
  69.     ld    a,(funct)
  70.     cp    54            ; if set DOS time
  71.     ret    Z            ; ..just point to date stamp
  72.     push    hl            ; save result
  73.     ld    c,0            ; time return date/time pointer in hl
  74.     push    bc            ; save 2 or 4 byte count <crw>
  75.     call    time            ; return pointer in hl
  76.     pop    bc
  77.     pop    de            ; get pointer
  78.     ld    c,b            ; set write 2 or 4 bytes <crw>
  79.     ld    b,0
  80.     ldir                ; copy 2 or 4 bytes to directory buff.
  81.     xor    a            ; set zero flag - time stamps present
  82.     ret                ; and return to caller
  83.  
  84. ;
  85. ; GetStp - Store time stamp following file find, open, or make.
  86. ;
  87. ;    Exit:    HL points to file's 10-byte time stamp stored in DOS.
  88. ;        This buffer is used by subsequent disk commands if
  89. ;        DOS-time (dtime) has been activated by command 55.
  90. ;
  91. GetStp:
  92.     ld    e,2            ; Point to file's stamp
  93.     call    STime            ; Point to beginning of
  94.                     ; ..last file's stamp
  95.     ld    de,cdate        ; Point to DOS stamp buffer
  96.     ld    (pexit),de        ; Save for return in HL
  97.     ld    bc,10
  98.     jr    NZ,GtStp1        ; STime said no stamp found
  99.     ldir                ; Save full stamp
  100.     ret                ; Back to calling program
  101. GtStp1:
  102.     ld    b,c            ; No stamp found
  103. GtStp2:
  104.     ld    a,0            ; ..so zero out DOS buffer
  105.     ld    (de),a
  106.     inc    de
  107.     djnz    GtStp2
  108.     ret                ; Return to calling program
  109.  
  110. ; ------------------------------------------------------------------
  111.  
  112. ; Time - get time for stamping from DOS storage or get real time
  113.  
  114. ;
  115. ; Entry:    DTime = 0    Get real time
  116. ;        DTime <> 0    Get time from DOS buffer and reset DTime.
  117. ;
  118. ; Format of time returned to pointer in HL:
  119. ;
  120. ;    HL + 0 = low  byte of date since Dec. 31, 1977
  121. ;    HL + 1 = high byte of date since Dec. 31, 1977
  122. ;    HL + 2 = hours     (BCD)
  123. ;    HL + 3 = minutes (BCD)
  124. ;    HL + 4 = seconds (BCD) (not used in time stamp)
  125. ;
  126.  
  127. time:
  128.     ld    a,(dtime)        ; Get time from buffer?
  129.     or    a
  130.     jr    Z,btime            ; No, get real time
  131.  
  132.     ld    a,(funct)        ; Yes, check function
  133.     cp    22            ; Creating file?
  134.     ld    hl,cdate        ; If so, point to 
  135.     jr    Z,time2            ; ..stored create date
  136.     ld    hl,udate        ; No, point to update date/time
  137. time2:
  138.     xor    a
  139.     ld    (dtime),a        ; Use buffer for this call only
  140.     ret
  141.  
  142. ; -------------------------------------------------------------------
  143.  
  144. ; GetTim and SetTim - Get or Set Time using memory or Real Time Clock
  145.  
  146. ; -------------------------------------------------------------------
  147.  
  148. ;
  149. ; Get time to address DE
  150. ;
  151. gettim:    
  152.     push    de            ; Save address to put time
  153.     ld    c,0            ; Get time address
  154.     call    btime            ; Execute p2bios call
  155.     pop    de            ; Restore address to put time
  156.     ld    bc,5            ; 5 bytes to move
  157.     ldir                ; Store the time
  158.     ret                ; Return to caller (or DOS)
  159. ;
  160. ; Set time from address DE
  161. ;
  162. settim:    ex    de,hl            ; get address time in hl
  163.     ld    c,0ffh            ; set time from address
  164.  
  165. ;    fall    thru
  166.  
  167. ;
  168. ; Real Time Clock (RTC) or memory "clock" interface:
  169. ;
  170. ;    Entry:    C =  0: Load 5-byte buffer at HL with time
  171. ;        C <> 0: 5-byte entry pointed to by HL sets system time
  172.  
  173.     if    RTC            ; Real time clock available
  174. btime:
  175.     push    hl            ; Save value in HL
  176.     ld    hl,(timead)        ; Get address time routine
  177.     ex    (sp),hl            ; Put address on stack and restore hl
  178.     ret                ; Execute BIOS time routine
  179.  
  180.      else                ; Use memory "clock"
  181. btime:
  182.     ld    a,c            ; Test flag
  183.     or    a
  184.     jr    NZ,set            ; C <> 0, set time
  185.     ld    hl,timebuf        ; Point HL to buffer
  186.     ret
  187. set:
  188.     ld    de,timebuf        ; Point to storage
  189.     ld    bc,5            ; Copy five bytes
  190.     ldir
  191.     ret
  192.      endif    ; RTC
  193.  
  194. ; ---------------------------------------------------------
  195. ;
  196. ; UseStp - Use stored time stamp for very next DOS call.
  197. ;        All other DOS calls cancel DOS time thru p2exit.
  198. ;
  199. UseStp:
  200.     or    0ffh
  201.     ld    (dtime),a        ; Use DOS time
  202.     pop    hl            ; clean up stack
  203.     jr    p2ext0
  204.  
  205. ; -------------------------------------------------------------------------
  206.  
  207. ; DOS exit routines
  208.  
  209. ; -------------------
  210.  
  211.  
  212. p2exit:    xor    a
  213.     ld    (dtime),a        ; Turn off DOS time <crw>
  214.     ld    (retflg),a        ; Turn off retries
  215.     ld    a,(fldrv)        ; Test drive select used flag
  216.     or    a
  217.     jr    Z,p2ext0        ; No then exit
  218.     ld    a,(FCB0)        ; Get FCB byte 0
  219.     ld    (ix+0),a        ; Save it
  220.     ld    a,(drive)        ; Get old drive number
  221.     call    seldk            ; Select disk
  222. p2ext0:    push    ix            ; Save IX
  223.     pop    de            ; Restore DE
  224.     pop    ix            ; Restore IX
  225.     ld    sp,(spsave)        ; Get old sp
  226.     ld    hl,(pexit)        ; Get exit code
  227.     ld    a,(funct)        ; Get function code
  228.     ld    c,a            ; Restore C
  229.     ld    a,l            ; Copy function code
  230.     ld    b,h
  231.     ret                ; And return to caller
  232.     if    ($-dos) gt 3584
  233.     * BDOS over 3584 bytes - too large!! *
  234.     endif
  235.  
  236. ; END Z80DTIME.Z80
  237.  
  238.