You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

108 lines
3.4 KiB

;:::::::::::::::::::::::::::::::::::::::***************************
; Time-handling Routines ** Machine-Dependant **
; Retro-Brew Hardware with HBIOS ***************************
;
; This module incorporates provisions for an HBIOS clock for
; obtaining Time and Date Info.
;
; 1.1 - 24 Mar 14 - Initial N8VEM test release WW-LN
; 1.0 - 18 Jul 96 - Initial Release. HFB
;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; This code module should handle all Time-related segments
; including any necessary time format conversion routines.
CSEG
;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; TIME - Set or Return the time string as defined for ZSDOS. If Reading,
; The Six digit BCD ZSDOS Clock string is copied to the location
; addressed by Register pair DE. As an enhancement, the tenths-of-seconds
; value is returned in Reg D. If Setting the Clock, the RTC clock string
; will be set from the 6 bytes addressed by DE.
;
; ENTER: C - 0 to Read the Clock, Non-0 (1 recommended) to Set the Clock
; DE = Pointer to receive 6-byte Time/Date on Read, Source for Set
;
; EXIT : E = Original contents of Target Seconds field
; D = Tenths of Seconds field
; HL = Pointer to Target Seconds field
; A = 1 for success, 0 if Unable to Set or Read
; BC = Address of User General-Purpose Down-Counter
;
; NOTE: The Wall Clock string is arranged as BCD digits with Tenths-
; of-Seconds byte appended. The entire string is:
;
; YR MO DA HH MM SS TT
;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
IF CLOCK
TIME:
LD A,C
OR A
JR NZ,WRCLK
;
;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; R e a d T h e C l o c k
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
RDCLK:
PUSH DE ; Save the final destination
LD HL,TIMBUF ; Point HL to temp buf
LD B,20H ; HBIOS function to read RTC
CALL HBX_INVOKE ; Do it
LD HL,TIMBUF ; Setup HL as source
POP DE ; And recover final destination
LD BC,5 ; Copy first 5 bytes
LDIR ; Do it
LD A,(DE) ; Now get the original seconds value to A
INC BC ; Setup to copy last byte, BC := 1
LDIR ; Do it
EX DE,HL ; Set HL to seconds dest for return
DEC HL ; Decrement to point back at seconds value
LD D,0 ; Tenths is always zero
LD E,A ; Get original seconds value
LD BC,DCNTR ; BC must point to countdown timer on return
LD A,1 ; Signal success
RET
;
if CLKSET
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; S e t T h e C l o c k
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;
WRCLK:
EX DE,HL ; Make incoming DE the copy source in HL
LD DE,TIMBUF ; We are copying to time buffer
LD BC,6 ; For 6 bytes
LDIR ; Do it, time buffer now ready
LD HL,TIMBUF ; Point to time buffer
LD B,21H ; Set clock function
CALL HBX_INVOKE ; Do it via HBIOS
LD BC,DCNTR ; BC must point to countdown timer on return
LD A,1 ; Signal success
RET
else
XOR A ; Set Error Return
RET ; and exit
endif ; clkset
ENDIF ; Clock
;.....
; Buffer space in the Common RAM Area for Time & Date
DSEG
DCNTR: DEFS 1
TIMBUF: DEFS 6
CSEG ; End up by restoring CSEG
;=========================== END of TIM-WW ==================================