?? delay_ms.c
字號:
/*
delay_ms.c
Uses tcint8.c source from pctime13 as a ms-resolution timer.
*/
#include <stdtypes.h>
#include <stdlib.h>
#include <time.h>
#include <sys\timeb.h>
#include <tcint70.h>
// use pctime stuff if defined...
#define USE_PCINT70 1
int timer_init_flag = 0;
/* timer_init_flag is used to tell if caller has ever initialized
the ms-resolution timer. If not, we will do it here and
then release it on exit. If it HAS been set, the caller
must call "quit8()" before exiting his program.
EXAMPLE STARTUP CODE:
// set up ms resolution timer...
timer_init_flag = 1;
init8h( 1000 );
ticks_8h = 0L;
atexit( quit8h );
init70h();
atexit( quit70h );
*/
VOID delay_ms( UINT16 delay )
/*
Intercepts timer, SEE NOTES ABOVE!
*/
{
#ifndef USE_PCINT70
// do standard ms delay using crappy 18/sec tick...
struct timeb start, now;
short time1, time2;
ftime ( &start );
time2 = 1000 - start.millitm; // #ms to next second
// add ms/tick to guarantee at least the requested delay
delay += 60;
while ( 1 )
{
ftime ( &now );
if ( start.time == now.time ) // seconds the same...
time1 = now.millitm - start.millitm;
else
time1 = time2 + (short)((now.time - start.time) * 1000) + \
now.millitm;
if ( time1 > delay ) break;
}
#else
if ( !timer_init_flag )
{
init70h();
atexit ( quit70h );
timer_init_flag = 1;
}
// add 1ms tick to guarantee at least the requested delay
delay++;
delay70h( delay );
#endif
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -