10-22-2003, 11:43 AM
10-22-2003, 11:48 AM
TIMER
10-22-2003, 11:53 AM
TIMER give you the number of seconds that have passed since midnight. You can use it to time just about anything. It's only limitation is that it changes only about 18 times a second, so it won't work if you want to do something at a higher frequency than that.
Example:Many qb game programming libraries, such as directQB, UGL, and Future.Library come with timing routines that are better suited for animation etc. I'd suggest you check one of them out (I'd recommend DirectQB only because it's the best documented) and read it's manual and learn how to use it's timing routines.
Example:
Code:
INPUT "How many seconds do you want to wait?", seconds
timeToWaitFor! = TIMER + seconds
DO: LOOP UNTIL TIMER >= timeToWaitFor!
10-23-2003, 08:32 PM
Best documented, pfffft.
10-24-2003, 02:04 PM
Well atleast its best among the documented libraries =P
10-24-2003, 06:34 PM
If you're using a library solely for its timing routines, you might as well use Seav's routine that changes the timer's refresh rate:
Code:
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$)