Port-amiga archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Timer issues?



Michael L. Hitch wrote:

> [...]
>   I don't think your change is in the right place. You put it in
> clk_gettick(), which I think is supposed to return the current interval
> from the CIA counter with no change. It's also used in delay(), which
> specifically handles the case of the timer wrap. I think the proper place
> would be in clk_getcounter() where the return value depends upon
> hardclock_ticks incrementing on the hardclock interrupt.

Agreed. How about the following patch?

--- clock.c     6 Jan 2008 18:50:31 -0000       1.47
+++ clock.c     17 Aug 2009 21:34:21 -0000
@@ -326,6 +326,8 @@
 static u_int
 clk_getcounter(struct timecounter *tc)
 {
+       static int last_hardclock_ticks;
+       static u_int last_clock_tick = 0;
        int old_hardclock_ticks;
        u_int clock_tick;
 
@@ -334,6 +336,12 @@
                clock_tick = clk_gettick();
        } while (old_hardclock_ticks != hardclock_ticks);
 
+       if (clock_tick < last_clock_tick &&
+           old_hardclock_ticks == last_hardclock_ticks)
+               old_hardclock_ticks++;
+       last_hardclock_ticks = old_hardclock_ticks;
+       last_clock_tick = clock_tick;
+
        return old_hardclock_ticks * amiga_clk_interval + clock_tick;
 }


It works fine for me.

-- 
Frank Wille



Home | Main Index | Thread Index | Old Index