/*
Copyright (C) Magna Carta Software, Inc. 1990, 1991. All Rights Reserved.
C COMMUNICATIONS TOOLKIT v1.0
CCTUTIL.C -- Utility Functions for CCT.
*/
#define CCT_DEVELOPMENT
#if (defined(CCTW) || defined(_WINDOWS))
#include <windows.h>
#endif
#include <dos.h>
#include <compat.h>
#if defined(MSC)
/* #include <conio.h> */
#endif
/* #include <stdio.h> */
#include <stdlib.h>
#if !defined(TYPES_DEFINED)
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned long DWORD;
#define TYPES_DEFINED
#endif
#define LOW_TIME 0X46C
/*
MS_PAUSE -- Introduce a delay for x milliseconds calibrated to 1/18th sec.
This function accesses the time through the BIOS.
The variable "duration" is measured in milliseconds (e.g. 200 <=> 0.2 sec.)
*/
void ms_pause(WORD duration)
{
WORD ticks;
WORD ticksnow;
/* CONVERT MILLISECONDS TO 18ths OF A SECOND */
ticks = max(duration /55, 1);
for (; ticks > 0; --ticks) {
ticksnow = (volatile WORD) peek(0, LOW_TIME);
_enable();
#if defined(_MSC_VER)
while (ticksnow == (*(volatile WORD *) &(peek(0, LOW_TIME))));
#else
while (ticksnow == (volatile WORD) peek(0, LOW_TIME));
#endif
}
}