www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/05/02/08:39:50

From: "Pavlos" <trash24379 AT usa DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Simple timer question...
Date: Sun, 2 May 1999 01:22:38 +0300
Organization: An OTEnet S.A. customer
Lines: 39
Message-ID: <7gfuqj$ket$1@newssrv.otenet.gr>
References: <eQKZuWASpyK3Ew2w AT zaynar DOT demon DOT co DOT uk>
NNTP-Posting-Host: dram-a16.otenet.gr
X-Trace: newssrv.otenet.gr 925597331 20957 195.167.113.239 (1 May 1999 22:22:11 GMT)
X-Complaints-To: abuse AT otenet DOT gr
NNTP-Posting-Date: 1 May 1999 22:22:11 GMT
X-Newsreader: Microsoft Outlook Express 4.72.3110.1
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

You can also try this:

#include <allegro.h>

volatile unsigned int counter=0;

void timer_handler(void)
{
 counter++;
}
END_OF_FUNCTION(timer_handler);

int main(void)
{
 unsigned int i;

 install_timer();
 LOCK_VARIABLE(counter);
 LOCK_FUNCTION(timer_handler);
 install_int(timer_handler, 1);  //1 is milliseconds between ticks

 .
 .
 Here is your code; like this
 i=counter;
 do
 {
  Blah();
  Blah();
 }while(counter-i<100);
 .
 .

 //no need to call remove_int(...), automatically called at exit
}




- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019