/* clock.c: IBM PC Clock tick functions */

#include <dos.h>

/* Pointer to the clock tick */
static volatile unsigned long far *tptr = MK_FP(0,0x46c);

static unsigned long start = 0L;

/* clock_reset: Resets the timer */
void clock_reset(void)
{
    start = *tptr;
}

/* clock_wait: Waits a certain number of ticks */
void clock_wait(unsigned long n)
{
    start = *tptr;
    while ((*tptr - start) < n)
        ;
}

/* clock_elapsed: Returns the number of ticks since last reset */
unsigned long clock_elapsed(void)
{
    return *tptr - start;
}
