(I can't test it self I'm not at home ATM)
Joshy
Code: Select all
#ifdef __FB_WIN32__
#include "windows.bi"
#include "win/mmsystem.bi"
#else
#error 666, sorry Windows only test !
#endif
dim shared as TIMECAPS gTimeCaps
sub _moduleInit constructor
print "module()"
timeGetDevCaps(@gTimeCaps,sizeof(TIMECAPS))
print "min: " & gTimeCaps.wPeriodMin & " max: " & gTimeCaps.wPeriodMax
timeBeginPeriod(gTimeCaps.wPeriodMin)
end sub
sub _moduleExit destructor
print "module~"
timeEndPeriod(gTimeCaps.wPeriodMin)
beep
sleep 3000,1
end sub
sub SleepMS(byval ms as ulong)
static as ulong rest=0
if ms<gTimeCaps.wPeriodMin then
ms = gTimeCaps.wPeriodMin
elseif ms>gTimeCaps.wPeriodMax then
ms = gTimeCaps.wPeriodMax
end if
' if on XP min value >1 eg. 15 store the remainder for next SleepMS() call
ms += rest : rest = ms mod gTimeCaps.wPeriodMin
SleepEx(ms, FALSE)
end sub
'
' main
'
screenres 640,480,8,2
screenset 1,0
const as single radius = 30.0f
dim as single x = -radius
while inkey()=""
cls
circle(x,240),radius,1,,,,F
flip
SleepMS(1000/(640+2*radius))
x+=1:if x-radius>639 then x=-radius
wend