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 / Z80DS231.LBR / Z80DTIME.ZZ0 / Z80DTIME.Z80
Text File  |  2000-06-30  |  8KB  |  289 lines

  1.  
  2. ; Z80DOS - Z80 Disk Operating System                Nov 15, 1988
  3. ;
  4. ; Version 2.31    Fast file lookup for random record fix
  5. ; Date:     15 Nov 88
  6. ; Update:    Eugene Nolan
  7. ;
  8. ;-----------------------------------------------------------------------
  9. ;
  10. ; Version 2.3    Fast file lookup, ZRL compatibility
  11. ; Date:     4 Nov 88
  12. ; Update:    Eugene Nolan
  13. ;
  14. ;-----------------------------------------------------------------------
  15. ;
  16. ; Version 2.0a - BETA TEST VERSION - 6 Nov 87 by Carson Wilson
  17. ;
  18. ; Support file: Z80DTIME.Z80
  19. ; Version:    2.0
  20. ; Date:     6 Nov 87
  21. ; Author:    Carson Wilson
  22. ; Changes:    Added internal time routine for systems without a
  23. ;        real time clock.  This routine assembles if RTC is false.
  24. ;        Cleaned up and clarified code.
  25. ;
  26. ; Description:    Time Functions, Exit Routine, RAM Area
  27. ;
  28. ;-----------------------------------------------------------------------
  29. ;
  30. ; Time Routines
  31. ;
  32. ;-----------------------------------------------------------------------
  33. ;
  34. ; STIME - Set file's time and date at DMA buffer.
  35. ;
  36. ;    Entry:    E = 2 - set creation date or get time stamp
  37. ;        E = 4 - Set last update time/date
  38. ;        E = 8 - Set last access time/date
  39. ;
  40. ;    Exit:    Z  if time stamps present
  41. ;        NZ if no time stamps
  42. ;
  43. STIME:    LD    HL,(DIRBUF)    ; Get directory entry
  44.     LD    BC,060H        ; Offset entry point time/date stamp
  45.     ADD    HL,BC        ; Add offset to time stamp
  46.     LD    A,(HL)        ; Get time stamp byte
  47.     SUB    021H        ; Time stamp present?
  48.     RET    NZ        ; No, return
  49.     LD    D,A        ; Yes, clear d
  50.     ADD    HL,DE        ; Add entry (update/create/access)
  51.     LD    A,E        ; Set access time if E ge 8 <crw>
  52.     AND    8        ;
  53.     JR    Z,STIM1        ; E lt 8
  54.     SRL    E        ; E ge 8, set to 4
  55. ;
  56. STIM1:    LD    B,E        ; Save # bytes to write
  57.     LD    A,(SECPNT)    ; Get sector pointer
  58.     RRCA            ; Shift 2 times
  59.     RRCA
  60.     LD    E,A        ; Save it
  61.     RRCA            ; Shift 2 times
  62.     RRCA
  63.     ADD    A,E        ; Add it (a=0,10,20)
  64.     LD    E,A        ; Save in e
  65.     ADD    HL,DE        ; Add offset
  66.     LD    A,(FUNCT)
  67.     CP    54        ; If set DOS time
  68.     RET    Z        ; Just point to date stamp
  69.     PUSH    HL        ; Save result
  70.     LD    C,0        ; Time return date/time pointer in hl
  71.     PUSH    BC        ; Save 2 or 4 byte count <crw>
  72.     CALL    TIME        ; Return pointer in hl
  73.     POP    BC
  74.     POP    DE        ; Get pointer
  75.     LD    C,B        ; Set write 2 or 4 bytes <crw>
  76.     LD    B,0
  77.     LDIR            ; Copy 2 or 4 bytes to directory buff.
  78.     XOR    A        ; Set zero flag - time stamps present
  79.     RET            ; And return to caller
  80. ;
  81. ; GetStp - Store time stamp following file find, open, or make.
  82. ;
  83. ;    Exit:    HL points to file's 10-byte time stamp stored in DOS.
  84. ;        This buffer is used by subsequent disk commands if
  85. ;        DOS-time (dtime) has been activated by command 55.
  86. ;
  87. GETSTP:    LD    E,2        ; Point to file's stamp
  88.     CALL    STIME        ; Point to beginning of
  89. ;                ;   last file's stamp
  90.     LD    DE,CDATE    ; Point to DOS stamp buffer
  91.     LD    (PEXIT),DE    ; Save for return in HL
  92.     LD    BC,10
  93.     JR    NZ,GTSTP1    ; STime said no stamp found
  94.     LDIR            ; Save full stamp
  95.     RET            ; Back to calling program
  96. ;
  97. GTSTP1:    LD    B,C        ; No stamp found
  98. ;
  99. GTSTP2:    LD    A,0        ; So zero out DOS buffer
  100.     LD    (DE),A
  101.     INC    DE
  102.     DJNZ    GTSTP2
  103.     RET            ; Return to calling program
  104. ;
  105. ;-----------------------------------------------------------------------
  106. ;
  107. ; Time - get time for stamping from DOS storage or get real time
  108. ;
  109. ; Entry:    DTIME = 0    Get real time
  110. ;        DTIME <> 0    Get time from DOS buffer and reset DTIME.
  111. ;
  112. ; Format of time returned to pointer in HL:
  113. ;
  114. ;    HL + 0 = low  byte of date since Dec. 31, 1977
  115. ;    HL + 1 = high byte of date since Dec. 31, 1977
  116. ;    HL + 2 = hours     (BCD)
  117. ;    HL + 3 = minutes (BCD)
  118. ;    HL + 4 = seconds (BCD) (not used in time stamp)
  119. ;
  120. TIME:    LD    A,(DTIME)    ; Get time from buffer?
  121.     OR    A
  122.     JR    Z,BTIME        ; No, get real time
  123.     LD    A,(FUNCT)    ; Yes, check function
  124.     CP    22        ; Creating file?
  125.     LD    HL,CDATE    ; If so, point to
  126.     JR    Z,TIME2        ; Stored create date
  127.     LD    HL,UDATE    ; No, point to update date/time
  128. ;
  129. TIME2:    XOR    A
  130.     LD    (DTIME),A    ; Use buffer for this call only
  131.     RET
  132. ;
  133. ;-----------------------------------------------------------------------
  134. ;
  135. ; GetTim and SetTim - Get or Set Time using memory or Real Time Clock
  136. ;
  137. ;-----------------------------------------------------------------------
  138. ;
  139. ; Get time to address DE
  140. ;
  141. GETTIM:    PUSH    DE        ; Save address to put time
  142.     LD    C,0        ; Get time address
  143.     CALL    BTIME        ; Execute p2bios call
  144.     POP    DE        ; Restore address to put time
  145.     LD    BC,5        ; 5 bytes to move
  146.     LDIR            ; Store the time
  147.     RET            ; Return to caller (or DOS)
  148. ;
  149. ; Set time from address DE
  150. ;
  151. SETTIM:    EX    DE,HL        ; Get address time in hl
  152.     LD    C,0FFH        ; Set time from address
  153. ;
  154. ; Real Time Clock (RTC) or memory "clock" interface:
  155. ;
  156. ;    Entry:    C =  0: Load 5-byte buffer at HL with time
  157. ;        C <> 0: 5-byte entry pointed to by HL sets system time
  158.  
  159.      IF    RTC        ; Real time clock available
  160. BTIME:    PUSH    HL        ; Save value in HL
  161.     LD    HL,(TIMEAD)    ; Get address time routine
  162.     EX    (SP),HL        ; Put address on stack and restore hl
  163.     RET            ; Execute BIOS time routine
  164. ;
  165.      ELSE            ; Use memory "clock"
  166. BTIME:    LD    A,C        ; Test flag
  167.     OR    A
  168.     JR    NZ,SET        ; C <> 0, set time
  169.     LD    HL,TIMEBUF    ; Point HL to buffer
  170.     RET
  171. ;
  172. SET:    LD    DE,TIMEBUF    ; Point to storage
  173.     LD    BC,5        ; Copy five bytes
  174.     LDIR
  175.     RET
  176.      ENDIF            ; RTC
  177. ;
  178. ;-----------------------------------------------------------------------
  179. ;
  180. ; UseStp - Use stored time stamp for very next DOS call.
  181. ;       All other DOS calls cancel DOS time thru p2exit.
  182. ;
  183. USESTP:    OR    0FFH
  184.     LD    (DTIME),A    ; Use DOS time
  185.     POP    HL        ; Clean up stack
  186.     JR    P2EXT0
  187. ;
  188. ;-----------------------------------------------------------------------
  189. ;
  190. ; DOS exit routines
  191. ;
  192. ;-----------------------------------------------------------------------
  193. ;
  194. P2EXIT:    XOR    A
  195.     LD    (DTIME),A    ; Turn off DOS time <crw>
  196.     LD    A,(FLDRV)    ; Test drive select used flag
  197.     OR    A
  198.     JR    Z,P2EXT0    ; No then exit
  199.     LD    A,(FCB0)    ; Get FCB byte 0
  200.     LD    (IX+0),A    ; Save it
  201.     LD    A,(DRIVE)    ; Get old drive number
  202.     CALL    SELDK        ; Select disk
  203. ;
  204. P2EXT0:    PUSH    IX        ; Save IX
  205.     POP    DE        ; Restore DE
  206.     POP    IX        ; Restore IX
  207.     LD    SP,(SPSAVE)    ; Get old sp
  208.     LD    HL,(PEXIT)    ; Get exit code
  209.     LD    A,(FUNCT)    ; Get function code
  210.     LD    C,A        ; Restore C
  211.     LD    A,L        ; Copy function code
  212.     LD    B,H
  213.     RET            ; And return to caller
  214. ;
  215. ;-----------------------------------------------------------------------
  216. ;
  217. ; RAM area
  218. ;
  219. ;-----------------------------------------------------------------------
  220. ;
  221. TABCNT:    DEFB    0        ; Tab counter
  222. TABCX1:    DEFB    0        ; Temporary tab counter (used by rdbuf)
  223. FCONTP:    DEFB    0        ; List enable flag (control p)
  224. LASTCH:    DEFB    0        ; Last character
  225. DELAY:    DEFB    0FFH        ; Delay counter
  226. ;
  227. TRANS:    DEFW    0        ; Translation vector
  228. TEMP0:    DEFW    0        ; Number of files on drive
  229. DIRBUF:    DEFW    0        ; Directory buffer
  230. IXP:    DEFW    0        ; Disk parameter block
  231. CSV:    DEFW    0        ; Checksum pointer
  232. ALV:    DEFW    0        ; Allocation vector pointer
  233. ;
  234. MAXSEC:    DEFW    0        ; Maximum number of sectors/track
  235. NBLOCK:    DEFB    0        ; Number of blocks
  236. NMASK:    DEFB    0        ; Mask number of blocks
  237. NEXTND:    DEFB    0        ; Extent mask
  238. MAXLEN:    DEFW    0        ; Maximum block number-1
  239. NFILES:    DEFW    0        ; Maximum number of files-1
  240. NDIR0:    DEFB    0        ; First two entries alv buffer
  241. NDIR1:    DEFB    0
  242. NCHECK:    DEFW    0        ; Number of checksum entries
  243. NFTRK:    DEFW    0        ; First track number
  244. ;
  245. DSKRO:    DEFW    0        ; Disk R/O vector
  246. LOGIN:    DEFW    0        ; Login vector
  247. DIFF:    DEFW    0        ; Disk changed vector <crw>
  248. ;
  249. DMA:    DEFW    080H        ; DMA address
  250. ;
  251. FUNCT:    DEFB    0        ; Function number
  252. PEXIT:    DEFW    0        ; Exit code
  253. FLDRV:    DEFB    0        ; Drive select used flag
  254. RDWR:    DEFB    0        ; Read/write flag
  255. ;
  256. FCB0:    DEFB    0        ; FCB byte 0
  257. USER:    DEFB    0        ; User number
  258. DRIVE:    DEFB    0        ; Drive number
  259. DEFDRV:    DEFB    0        ; Default drive number
  260. RECDIR:    DEFW    0        ; Record directory (checksum)
  261. FILCNT:    DEFW    0        ; File counter
  262. SECPNT:    DEFB    0        ; Sector pointer
  263. SUBFLG:    DEFB    0        ; Submit flag (reset disk command)
  264. ;
  265. DCOPY:    DEFW    0        ; Copy address FCB
  266. SEAREX:    DEFB    0        ; Exit code search
  267. SEARNB:    DEFB    0        ; Search number of bytes
  268. SEARQU:    DEFB    0        ; Search question mark used
  269. SEARPU:    DEFB    0        ; Search public file
  270. ;
  271. RETFLG:    DB    0        ; Allow retry on error when non-zero
  272. ;
  273. DTIME:    DB    0        ; Flag for UseStp <crw>
  274. CDATE:    DS    2        ; Create date storage
  275. UDATE:    DS    4        ; Update date/time
  276. ADATE:    DS    4        ; Last access date/time <crw>
  277. ;
  278. SPSAVE:    DEFW    0        ; Stack pointer location
  279.     DEFS    54
  280. DOSSTK    EQU    $        ; DOS internal 64 byte stack
  281. DOSSTOP    EQU    $
  282. ;
  283.      IF    ((DOSSTOP-DOS) GT 3584)
  284.     *    BDOS OVER 3584 BYTES - TOO LARGE!! *
  285.      ENDIF
  286. ;
  287. ; END Z80DTIME.Z80
  288. ;
  289.