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
Wrap
Text File
|
2000-06-30
|
8KB
|
289 lines
; Z80DOS - Z80 Disk Operating System Nov 15, 1988
;
; Version 2.31 Fast file lookup for random record fix
; Date: 15 Nov 88
; Update: Eugene Nolan
;
;-----------------------------------------------------------------------
;
; Version 2.3 Fast file lookup, ZRL compatibility
; Date: 4 Nov 88
; Update: Eugene Nolan
;
;-----------------------------------------------------------------------
;
; Version 2.0a - BETA TEST VERSION - 6 Nov 87 by Carson Wilson
;
; Support file: Z80DTIME.Z80
; Version: 2.0
; Date: 6 Nov 87
; Author: Carson Wilson
; Changes: Added internal time routine for systems without a
; real time clock. This routine assembles if RTC is false.
; Cleaned up and clarified code.
;
; Description: Time Functions, Exit Routine, RAM Area
;
;-----------------------------------------------------------------------
;
; Time Routines
;
;-----------------------------------------------------------------------
;
; STIME - Set file's time and date at DMA buffer.
;
; Entry: E = 2 - set creation date or get time stamp
; E = 4 - Set last update time/date
; E = 8 - Set last access time/date
;
; Exit: Z if time stamps present
; NZ if no time stamps
;
STIME: LD HL,(DIRBUF) ; Get directory entry
LD BC,060H ; Offset entry point time/date stamp
ADD HL,BC ; Add offset to time stamp
LD A,(HL) ; Get time stamp byte
SUB 021H ; Time stamp present?
RET NZ ; No, return
LD D,A ; Yes, clear d
ADD HL,DE ; Add entry (update/create/access)
LD A,E ; Set access time if E ge 8 <crw>
AND 8 ;
JR Z,STIM1 ; E lt 8
SRL E ; E ge 8, set to 4
;
STIM1: LD B,E ; Save # bytes to write
LD A,(SECPNT) ; Get sector pointer
RRCA ; Shift 2 times
RRCA
LD E,A ; Save it
RRCA ; Shift 2 times
RRCA
ADD A,E ; Add it (a=0,10,20)
LD E,A ; Save in e
ADD HL,DE ; Add offset
LD A,(FUNCT)
CP 54 ; If set DOS time
RET Z ; Just point to date stamp
PUSH HL ; Save result
LD C,0 ; Time return date/time pointer in hl
PUSH BC ; Save 2 or 4 byte count <crw>
CALL TIME ; Return pointer in hl
POP BC
POP DE ; Get pointer
LD C,B ; Set write 2 or 4 bytes <crw>
LD B,0
LDIR ; Copy 2 or 4 bytes to directory buff.
XOR A ; Set zero flag - time stamps present
RET ; And return to caller
;
; GetStp - Store time stamp following file find, open, or make.
;
; Exit: HL points to file's 10-byte time stamp stored in DOS.
; This buffer is used by subsequent disk commands if
; DOS-time (dtime) has been activated by command 55.
;
GETSTP: LD E,2 ; Point to file's stamp
CALL STIME ; Point to beginning of
; ; last file's stamp
LD DE,CDATE ; Point to DOS stamp buffer
LD (PEXIT),DE ; Save for return in HL
LD BC,10
JR NZ,GTSTP1 ; STime said no stamp found
LDIR ; Save full stamp
RET ; Back to calling program
;
GTSTP1: LD B,C ; No stamp found
;
GTSTP2: LD A,0 ; So zero out DOS buffer
LD (DE),A
INC DE
DJNZ GTSTP2
RET ; Return to calling program
;
;-----------------------------------------------------------------------
;
; Time - get time for stamping from DOS storage or get real time
;
; Entry: DTIME = 0 Get real time
; DTIME <> 0 Get time from DOS buffer and reset DTIME.
;
; Format of time returned to pointer in HL:
;
; HL + 0 = low byte of date since Dec. 31, 1977
; HL + 1 = high byte of date since Dec. 31, 1977
; HL + 2 = hours (BCD)
; HL + 3 = minutes (BCD)
; HL + 4 = seconds (BCD) (not used in time stamp)
;
TIME: LD A,(DTIME) ; Get time from buffer?
OR A
JR Z,BTIME ; No, get real time
LD A,(FUNCT) ; Yes, check function
CP 22 ; Creating file?
LD HL,CDATE ; If so, point to
JR Z,TIME2 ; Stored create date
LD HL,UDATE ; No, point to update date/time
;
TIME2: XOR A
LD (DTIME),A ; Use buffer for this call only
RET
;
;-----------------------------------------------------------------------
;
; GetTim and SetTim - Get or Set Time using memory or Real Time Clock
;
;-----------------------------------------------------------------------
;
; Get time to address DE
;
GETTIM: PUSH DE ; Save address to put time
LD C,0 ; Get time address
CALL BTIME ; Execute p2bios call
POP DE ; Restore address to put time
LD BC,5 ; 5 bytes to move
LDIR ; Store the time
RET ; Return to caller (or DOS)
;
; Set time from address DE
;
SETTIM: EX DE,HL ; Get address time in hl
LD C,0FFH ; Set time from address
;
; Real Time Clock (RTC) or memory "clock" interface:
;
; Entry: C = 0: Load 5-byte buffer at HL with time
; C <> 0: 5-byte entry pointed to by HL sets system time
IF RTC ; Real time clock available
BTIME: PUSH HL ; Save value in HL
LD HL,(TIMEAD) ; Get address time routine
EX (SP),HL ; Put address on stack and restore hl
RET ; Execute BIOS time routine
;
ELSE ; Use memory "clock"
BTIME: LD A,C ; Test flag
OR A
JR NZ,SET ; C <> 0, set time
LD HL,TIMEBUF ; Point HL to buffer
RET
;
SET: LD DE,TIMEBUF ; Point to storage
LD BC,5 ; Copy five bytes
LDIR
RET
ENDIF ; RTC
;
;-----------------------------------------------------------------------
;
; UseStp - Use stored time stamp for very next DOS call.
; All other DOS calls cancel DOS time thru p2exit.
;
USESTP: OR 0FFH
LD (DTIME),A ; Use DOS time
POP HL ; Clean up stack
JR P2EXT0
;
;-----------------------------------------------------------------------
;
; DOS exit routines
;
;-----------------------------------------------------------------------
;
P2EXIT: XOR A
LD (DTIME),A ; Turn off DOS time <crw>
LD A,(FLDRV) ; Test drive select used flag
OR A
JR Z,P2EXT0 ; No then exit
LD A,(FCB0) ; Get FCB byte 0
LD (IX+0),A ; Save it
LD A,(DRIVE) ; Get old drive number
CALL SELDK ; Select disk
;
P2EXT0: PUSH IX ; Save IX
POP DE ; Restore DE
POP IX ; Restore IX
LD SP,(SPSAVE) ; Get old sp
LD HL,(PEXIT) ; Get exit code
LD A,(FUNCT) ; Get function code
LD C,A ; Restore C
LD A,L ; Copy function code
LD B,H
RET ; And return to caller
;
;-----------------------------------------------------------------------
;
; RAM area
;
;-----------------------------------------------------------------------
;
TABCNT: DEFB 0 ; Tab counter
TABCX1: DEFB 0 ; Temporary tab counter (used by rdbuf)
FCONTP: DEFB 0 ; List enable flag (control p)
LASTCH: DEFB 0 ; Last character
DELAY: DEFB 0FFH ; Delay counter
;
TRANS: DEFW 0 ; Translation vector
TEMP0: DEFW 0 ; Number of files on drive
DIRBUF: DEFW 0 ; Directory buffer
IXP: DEFW 0 ; Disk parameter block
CSV: DEFW 0 ; Checksum pointer
ALV: DEFW 0 ; Allocation vector pointer
;
MAXSEC: DEFW 0 ; Maximum number of sectors/track
NBLOCK: DEFB 0 ; Number of blocks
NMASK: DEFB 0 ; Mask number of blocks
NEXTND: DEFB 0 ; Extent mask
MAXLEN: DEFW 0 ; Maximum block number-1
NFILES: DEFW 0 ; Maximum number of files-1
NDIR0: DEFB 0 ; First two entries alv buffer
NDIR1: DEFB 0
NCHECK: DEFW 0 ; Number of checksum entries
NFTRK: DEFW 0 ; First track number
;
DSKRO: DEFW 0 ; Disk R/O vector
LOGIN: DEFW 0 ; Login vector
DIFF: DEFW 0 ; Disk changed vector <crw>
;
DMA: DEFW 080H ; DMA address
;
FUNCT: DEFB 0 ; Function number
PEXIT: DEFW 0 ; Exit code
FLDRV: DEFB 0 ; Drive select used flag
RDWR: DEFB 0 ; Read/write flag
;
FCB0: DEFB 0 ; FCB byte 0
USER: DEFB 0 ; User number
DRIVE: DEFB 0 ; Drive number
DEFDRV: DEFB 0 ; Default drive number
RECDIR: DEFW 0 ; Record directory (checksum)
FILCNT: DEFW 0 ; File counter
SECPNT: DEFB 0 ; Sector pointer
SUBFLG: DEFB 0 ; Submit flag (reset disk command)
;
DCOPY: DEFW 0 ; Copy address FCB
SEAREX: DEFB 0 ; Exit code search
SEARNB: DEFB 0 ; Search number of bytes
SEARQU: DEFB 0 ; Search question mark used
SEARPU: DEFB 0 ; Search public file
;
RETFLG: DB 0 ; Allow retry on error when non-zero
;
DTIME: DB 0 ; Flag for UseStp <crw>
CDATE: DS 2 ; Create date storage
UDATE: DS 4 ; Update date/time
ADATE: DS 4 ; Last access date/time <crw>
;
SPSAVE: DEFW 0 ; Stack pointer location
DEFS 54
DOSSTK EQU $ ; DOS internal 64 byte stack
DOSSTOP EQU $
;
IF ((DOSSTOP-DOS) GT 3584)
* BDOS OVER 3584 BYTES - TOO LARGE!! *
ENDIF
;
; END Z80DTIME.Z80
;