delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/29/01:51:22

Message-ID: <336F644E.2113@post.comstar.ru>
Date: Tue, 06 May 1997 10:03:10 -0700
From: Dim Zegebart <zager AT post DOT comstar DOT ru>
Reply-To: zager AT post DOT comstar DOT ru
Organization: zager AT post DOT comstar DOT ru
MIME-Version: 1.0
To: DJGPP Mail List <djgpp AT delorie DOT com>
Subject: Real time clock and system timer ?

Hi,
just a couple of small questions ;)
As I realised, _bios_time(0,...) uses function 0x02 of 0x1A int.
to read the current time from real time clock, and
time(),gettime(),gettimeofday() use system clock counter at 0x46c to
do the same thing. For some unknown reasons, then I'm run Allegro based
programm for 24h my timer lose 8sec per 1h. ;( ( I think this is my
fault not Allegro)
So, I decide to synchronize dos timer to real time clock earch hour (see
below)
But settime use int. 0x21 (he-he, it's dos) function 0x2d and it's also
change my
real time clock ;( So, my question is - How to adjust system timer clock
to real time clock ?

int clock_check_handler()
{ struct time cur_timer;
  int h,m,s,hs;
  unsigned long ticks;
 
   gettime(&cur_timer);
  _bios_timeofday(_TIME_GETCLOCK,&ticks);
  hs=ticks/0.182;
  s=ticks/18.2;
  hs-=s*100;
  h=s/3600;
  s-=h*3600;
  m=s/60;
  s-=m*60;

  if (cur_timer.ti_sec!=s)
   { cur_timer.ti_hour=h;
     cur_timer.ti_min=m;
     cur_timer.ti_sec=s;
     cur_timer.ti_hund=hs;
     settime(&cur_timer);
     printf ("Sync\n");
     return(1);
   }
  return(0);
}

-- 
Regards,
Dim Zegebart, 
Moscow Russia.
Ghostly basement : http://www.geocities.com/siliconvalley/pines/7817

- Raw text -


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