Compucolor.org – Virtual Media

Listing of file='TIME.MAC;0C' on disk='vmedia/taylor-sideB-sector.ccvf'

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;	TIME - TIME CONTROL ROUTINE
;
;	   KEEPS TRACK OF TIME. USES THE REAL-TIME CLOCK
;	   TO DETERMINE IF TIME HAS EXPIRED. SETTIM MUST
;	   BE CALLED FIRST TO SET UP THE FINISHING TIME.
;
	TITLE	TIME

	ENTRY	TIME

;
;	VALUES ON ENTRY:
;	   IRRELEVANT
;
;	RETURNS:
;	   NOTHING - COUNTERS ARE PUBLIC
;
;	FLAGS SET:
;	   <Z> IS SET WHEN TIME REACHES ZERO
;	   (I.E. <Z> NOT SET INDICATES STILL TIMING)
;
;	DESTROYS:
;	   ALL REGISTERS
;
;
;	EXTERNALS :- REQUIRED SUBROUTINES
;
	EXTRN	DECOUT	;CONVERTS A BYTE TO ASCII DECIMAL NO.
	EXTRN	OSTR	;OUTPUT A STRING

SECS	EQU	81B9H	;SECONDS OF REAL-TIME CLOCK
MINS	EQU	81BAH	;MINUTES

;..............................................................


TIME:	LDA	MINS	;FIND MINUTES LEFT
	MOV	B,A
	LDA	FINMIN
	SUB	B
	JNC	TIM10
	ADI	60
TIM10:	MOV	D,A
	LDA	SECS	;CALCULATE SECONDS LEFT
	MOV	B,A
	LDA	FINSEC
	SUB	B
	JNC	TIMDSP	;FRACTION OF A MINUTE?
	MOV	E,A
	MOV	A,D	;CHECK IF MINUTES AND SECONDS EXPIRED
	ORA	A
	JZ	TIMDSP
	MOV	A,E
	ADI	60	;CORRECT SECONDS
	DCR	D	;FIX UP MINUTES
TIMDSP:	MOV	E,A
	LXI	H,SECMSG	;DISPLAY TIME LEFT
	CALL	DECOUT		;CONVERT SECONDS
	LXI	H,MINMSG
	MOV	A,D
	CALL	DECOUT		;CONVERT MINUTES
	LXI	H,MINMSG
	MVI	M,' '		;CHOP OFF LEADING ZERO ON MINS
	INX	H
	INX	H
	INX	H
	MVI	M,':'		;INSERT COLON BEFORE SECS
	LXI	H,TIMMSG
	CALL	OSTR		;OUTPUT TIME MESSAGE
	MOV	A,E
	ORA	D		;SET <Z> ACCORDINGLY AND RETURN
	RET

;..............................................................

	ENTRY	SETTIM

;	   SETS UP THE FINISHING TIME FOR THE TIME ROUTINE
;
;	VALUES ON ENTRY:
;	   A = NUMBER OF MINUTES TO RUN FOR
;
;	RETURNS NOTHING
;
;	DESTROYS: A,B REGS.
;

SETTIM:	MOV	B,A
	LDA	SECS
	STA	FINSEC
	LDA	MINS
	ADD	B
	CPI	60
	JC	SETT10
	SUI	60
SETT10:	STA	FINMIN
	RET

;..............................................................
;
;	DATA AREA
;

FINSEC:	DB	0	;FINISHING SECONDS
FINMIN:	DB	0	;FINISHING MINUTES

;
;	TIME MESSAGE
;
;	(USES BLIND CURSOR - MUCH NEATER)
;

TIMMSG:	DB	3,100,27,0,3,'TIME LEFT'
	DB	3,100,30,1,3
MINMSG:	DB	' 10'
SECMSG:	DB	':00',239

	END