Mail Archives: djgpp/2000/02/18/14:30:11
In article <A34D5D3BF0DFD2119E3D0008C70840FA04FD8D AT TWZNT11>, djgpp AT delorie DOT com wrote:
>If you have the Allegro game lib, it has timer interrupt routines.
>
>Otherwize you might be getting into re-programing the PIT chip.
>Easy in real mode, but I dont know about protected.
>
>There might be somthing in the x2ftp ftp site.
>ftp://x2ftp.oulu.fi/pub/msdos/programming
>
>Nigel Atkinson
>
I don't know, why I never tried to reprogram the PIT with a djgpp program, but
now you gave me the idea. Thanks!
So here is the output of the last 20 minutes.
It won't work under windows, you should not try to access a floppy drive with
the timer ticking faster, and your system time will be wrong afterwards.
Otherwise it should be quite easy to use and shouldn't do any harm (but don't
blame me if it does!). It will give you a timing accuracy of 1 ms.
#include <pc.h>
#include <stdio.h>
#include <conio.h>
#include <sys/farptr.h>
#include <go32.h>
void Set_Timer()
{
outportb(0x43,0x36);
outportb(0x40,0xa9);
outportb(0x40,0x04);
}
void Reset_Timer()
{
outportb(0x43,0x36);
outportb(0x40,0x0);
outportb(0x40,0x0);
}
void Zero_Timer ()
{
_farpokew (_dos_ds, 0x046c, 0);
}
unsigned int Read_Timer ()
{
return _farpeekw (_dos_ds, 0x046c);
}
int main ()
{
unsigned int start, stop;
Set_Timer();
Zero_Timer();
start=Read_Timer();
getch();
stop = Read_Timer();
Reset_Timer();
printf ("start = %u, stop = %u, diff = %u\n", start, stop,
stop-start);
return 0;
}
--
Manni
- Raw text -