Date: Mon, 17 Feb 1997 18:42:24 +0100 (MET) From: Jan Hubicka To: Eli Zaretskii cc: Ian Miller , djgpp AT delorie DOT com Subject: Re: Exact timming II In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Mon, 17 Feb 1997, Eli Zaretskii wrote: > > On Mon, 17 Feb 1997, Jan Hubicka wrote: > > > please can you send me separated uclock code? (I don't want to download > > whole library sources and uncompress then to my 80MB dos partition) > > Below. Btw, you don't need to uncompress the entire lot to get a single thank you.. I was laso lazy to download it throught my 4800 baud line.. > source. Just uncompress that single source and use it. Anybody who's > serious about DJGPP development should IMHO have djlsr at his disposal, > if only to see what the docs forgot to mention. I have sources at home at my 200MB disc..but not here because of lack of space..(before djgpp division 80MB -> dos and 500MB -> linux was OK) Honza > > /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ > /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ > #include > #include > #include > #include > #include > > static int uclock_bss = -1; > > /* tics = about 18.2 * 65536 (1,192,755) > > actually, it's 0x1800b0 tics/day (FAQ) > / 24*60*60 sec/day > * 65536 utics/tic > = 1,193,180 utics/sec */ > > uclock_t > uclock(void) > { > static uclock_t base = 0; > static unsigned long last_tics = 0; > unsigned char lsb, msb; > unsigned long tics, otics; > uclock_t rv; > > if (uclock_bss != __bss_count) > { > /* switch the timer to mode 2 (rate generator) */ > /* rather than mode 3 (square wave), which doesn't count linearly. */ > > outportb(0x43, 0x34); > outportb(0x40, 0xff); > outportb(0x40, 0xff); > > base = 0; > last_tics = 0; > uclock_bss = __bss_count; > } > > /* Make sure the numbers we get are consistent */ > do { > otics = _farpeekl(_dos_ds, 0x46c); > outportb(0x43, 0x00); > lsb = inportb(0x40); > msb = inportb(0x40); > tics = _farpeekl(_dos_ds, 0x46c); > } while (otics != tics); > > /* calculate absolute time */ > msb ^= 0xff; > lsb ^= 0xff; > rv = ((uclock_t)tics << 16) | (msb << 8) | lsb; > > if (base == 0L) > base = rv; > > if (last_tics > tics) /* midnight happened */ > base -= 0x1800b00000LL; > > last_tics = tics; > > /* return relative time */ > return rv - base; > } > ------------------------------------------------------------------------------ Have you browsed my www pages? Look at: http://www.paru.cas.cz/~hubicka Koules-the game for Svgalib,X11 and OS/2, Xonix-the game for X11 czech documentation for linux index, original 2D computer art and funny 100 years old photos and articles are there!