' def fnCTICKS.def -- returns the number of clock ticks since midnight
'
'       Allows the caller to `mark' the time, with an optional offset
'       ahead in time.  Useful in timing routines
'
' USAGE:
'       HUN.SCNDS = 100
'       MARK! = FNCTICKS (HUN.SCNDS)  ' # of clock ticks that will
'                    'have occurred since midnite (in 1 sec. from now)
'
'input: HUN.SCNDS = hundredths of seconds from now
'output: TIME.MARK! = time marker calculated (clock ticks since midnight)
'
'$INCLUDE: 'qb.bi'
DEF fncticks! (hun.scnds!)
	'$INCLUDE: 'TICKS.def'
	'$DYNAMIC
	DIM Registers AS RegType
	Registers.ax = 0       'set AH (& AL) to 0 to get clock setting
	CALL interrupt(&H1A, Registers, Registers)
	''CALL int86(&H1A, VARPTR(registers%(0)), VARPTR(registers%(0)))
	cx! = Registers.cx: dx! = Registers.dx
	cticks! = (cx! * 2 ^ 16 + dx!) + (hun.scnds! / 100 * ticks.per.sec!)
	IF cticks! > ticks.per.day! THEN cticks! = cticks! - ticks.per.day!'passed midnite
	fncticks! = FIX(cticks!)
END DEF


