Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

1: No code table for op: ++post


devel / comp.os.msdos.programmer / Re: I Need a millesecond Timer under DOS ?

SubjectAuthor
o Re: I Need a millesecond Timer under DOS ?Game Corner Playthroughs

1
Re: I Need a millesecond Timer under DOS ?

<4700d23a-3315-4fe9-bb86-5f1cfa681b61n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=216&group=comp.os.msdos.programmer#216

  copy link   Newsgroups: comp.os.msdos.programmer
X-Received: by 2002:ac8:4a0e:: with SMTP id x14mr3713946qtq.345.1640117324662;
Tue, 21 Dec 2021 12:08:44 -0800 (PST)
X-Received: by 2002:a05:622a:3c7:: with SMTP id k7mr3721786qtx.307.1640117324503;
Tue, 21 Dec 2021 12:08:44 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.os.msdos.programmer
Date: Tue, 21 Dec 2021 12:08:44 -0800 (PST)
In-Reply-To: <3625769A.794B@gallagher.cipic.ucdavis.edu>#1/1>
Injection-Info: google-groups.googlegroups.com; posting-host=96.231.98.16; posting-account=wbMaQgoAAAAUlkwoHUJpAUaR3JzhfcpE
NNTP-Posting-Host: 96.231.98.16
References: <3624c43e.0@news1.mweb.co.za> <36255DEC.9DA34F4D@mindspring.com> <3625769A.794B@gallagher.cipic.ucdavis.edu>#1/1>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4700d23a-3315-4fe9-bb86-5f1cfa681b61n@googlegroups.com>
Subject: Re: I Need a millesecond Timer under DOS ?
From: phasershow@gmail.com (Game Corner Playthroughs)
Injection-Date: Tue, 21 Dec 2021 20:08:44 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 82
 by: Game Corner Playthro - Tue, 21 Dec 2021 20:08 UTC

On Wednesday, October 14, 1998 at 3:00:00 AM UTC-4, Oliver Kreylos wrote:
> device wrote:
> >
> > I think there are ways to reprogram the clock to generate more higher
> > resolution tics.
> >
> > Dave
> Yes, there are. I am using a custom timer resolution in my game, here's
> what you have to do to
> a) set the timer to 1ms resolution
> b) keep the DOS clock going correctly nonetheless
> Just reprogramming the timer chip without some book-keeping would let
> the DOS clock run 18 times as fast. We don't want that...
> --8<------------------------------------------------------------
> typedef void (__interrupt __far* INTFUNCPTR)(void);
> INTFUNCPTR oldTimerInterrupt; // Original interrupt handler
> volatile long int milliseconds; // Elapsed time in milliseconds
> void __interrupt __far timerHandler(void)
> {
> static unsigned long count=0; // To keep track of original timer ticks
> ++milliseconds;
> count+=1103;
> if(count>=65536) // It is now time to call the original handler
> {
> count-=65536;
> _chain_intr(oldTimerInterrupt);
> }
> else
> outp(0x20,0x20); // Acknowledge interrupt
> }
> void installInterrupt(void)
> {
> union REGS r;
> struct SREGS s;
> _disable();
> segread(&s);
> /* Save old interrupt vector: */
> r.h.al=0x08;
> r.h.ah=0x35;
> int386x(0x21,&r,&r,&s);
> oldTimerInterrupt=(INTFUNCPTR)MK_FP(s.es,r.x.ebx);
> /* Install new interrupt handler: */
> milliseconds=0;
> r.h.al=0x08;
> r.h.ah=0x25;
> s.ds=FP_SEG(timerHandler);
> r.x.edx=FP_OFF(timerHandler);
> int386x(0x21,&r,&r,&s);
> /* Set resolution of timer chip to 1ms: */
> outp(0x43,0x36);
> outp(0x40,(unsigned char)(1103&0xff));
> outp(0x40,(unsigned char)((1103>>8)&0xff));
> _enable();
> }
> void removeInterrupt(void)
> {
> union REGS r;
> struct SREGS s;
> _disable();
> segread(&s);
> /* Re-install original interrupt handler: */
> r.h.al=0x08;
> r.h.ah=0x25;
> s.ds=FP_SEG(oldTimerInterrupt);
> r.x.edx=FP_OFF(oldTimerInterrupt);
> int386x(0x21,&r,&r,&s);
> /* Reset timer chip resolution to 18.2...ms: */
> outp(0x43,0x36);
> outp(0x40,0x00);
> outp(0x40,0x00);
> _enable();
> }
> --8<------------------------------------------------------------
> To query the elapsed time in ms, just read the variable milliseconds.
> A note: This program is for Watcom C. For other compilers, some
> structures and functions (like _enable) might have different names.
> Refer to your compiler's manual.
> A second note: This program is for Protected Mode using DOS/4G. To
> compile it for real mode, just replace all int386 by int86, and all wide
> registers (like edx) with their short counterparts (like dx). The
> program should work fine then.
> I hope this helps a bit,
> Oliver

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor