Precise Timer
Read timer at a higher rate.

you can read the timer at a higher rate using this code, compliments of seav and qbtm magazine:

FUNCTION CLOCK& 

' Get the number of timer ticks at
' 0000:046C
DEF SEG = 0
Ticks& = PEEK(&H46C)
Ticks& = Ticks& + PEEK(&H46D) * 256&
Ticks& = Ticks& + PEEK(&H46E) * 65536&
DEF SEG

' Latch the counter and obtain the PIT
' countdown status.
OUT &H43, &H4
LSB = INP(&H40)
HSB = 255 - INP(&H40)

' Compute the CLOCK& value
CLOCK& = Ticks& * 256& + HSB

END FUNCTION

'to test it:
CLS
DO
timerVal! = TIMER
clockVal! = CLOCK / 4660.859#

LOCATE 1
PRINT USING "CLOCK: #####.###"; clockVal!
PRINT USING "TIMER: #####.###"; timerVal!
LOOP UNTIL LEN(INKEY$)


(orig. posted by Toonski).


PreciseTimer - page last edited 2004-09-10 22:24:29 by 203.109.254.49 (home) (edit)
Blast WIKI - by RoboticBoy - edited and tweaked for our evil purposes by Hexadecimal Disaster