'===========================================================================
' Subject: PRECISE DELAY                      Date: 05-20-97 (15:00)       
'  Author: Nick Kochakian                     Code: QB, QBasic, PDS        
'  Origin: NickK@worldnet.att.net           Packet: DATETIME.ABC
'===========================================================================
DECLARE SUB halfpause ()
DECLARE SUB secpause ()
DECLARE SUB initdelay ()
'Good delay
'
'5/20/97 By: - Nick Kochakian -
'
'This program should help programmers out alot by making delays (or pauses)
'ALOT more accurate! I hope most of you will use this code in your games,
'demos, etc.
'
'If you have any comments or questions e-mail me at: nickk@worldnet.att.net

DIM SHARED cpusec
DIM SHARED ok$

CALL initdelay
'CALL secpause 'Pause for a second
'CALL halfpause 'Pause for a half of a second

END

'You have to add these 3 lines of code for the delay init to work
ok:
ok$ = "ok"
RETURN

SUB halfpause
'Pause for a half of a second

cntend = cpusec * .5
cnt = 0
DO
cnt = cnt + 1
LOOP UNTIL cnt >= cntend
END SUB

SUB initdelay
'Init the delay

ok$ = ""

TIMER ON
ON TIMER(1) GOSUB ok:
cpusec = 0
DO
cpusec = cpusec + 1
LOOP UNTIL ok$ = "ok"

END SUB

SUB secpause
'Pause for a second

cnt = 0
DO
cnt = cnt + 1
LOOP UNTIL cnt >= cpusec

END SUB
