From 72b61c1b0e9d101f46ffd3307f691bd67487e7bd Mon Sep 17 00:00:00 2001 From: William McBrine Date: Mon, 1 Jan 2007 21:04:27 +0000 Subject: [PATCH] Better check for rollover. --- dos/pdcutil.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/dos/pdcutil.c b/dos/pdcutil.c index dc2b6ba5..1c7b2899 100644 --- a/dos/pdcutil.c +++ b/dos/pdcutil.c @@ -19,7 +19,7 @@ #include -RCSID("$Id: pdcutil.c,v 1.18 2007/01/01 20:40:24 wmcbrine Exp $"); +RCSID("$Id: pdcutil.c,v 1.19 2007/01/01 21:04:27 wmcbrine Exp $"); void PDC_beep(void) { @@ -43,7 +43,7 @@ void PDC_beep(void) void PDC_napms(int ms) { PDCREGS regs; - PDCCLOCK_T goal; + PDCCLOCK_T goal, start, current; PDC_LOG(("PDC_napms() - called: ms=%d\n", ms)); @@ -55,10 +55,15 @@ void PDC_napms(int ms) if (!goal) goal++; - goal += PDCCLOCK(); + start = PDCCLOCK(); - while (goal > PDCCLOCK()) + goal += start; + + while (goal > (current = PDCCLOCK())) { + if (current < start) /* in case of midnight reset */ + return; + regs.W.ax = 0x1680; PDCINT(0x2f, regs); PDCINT(0x28, regs);