Port-amiga archive

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

Re: Timer issues?



Michael L. Hitch wrote:

On 15.08.09 02:45:49 you wrote:

> [...]
>   My guess at this time is that the interval counter on both machines has
> wrapped (and generated an interrupt), but the hardclock() routine hasn't
> been called yet.

Indeed, that would explain it!

To verify your assumption I did the following hack to amiga/dev/clock.c:

 #endif
        {
+               static int old_hardclock_ticks = 0;
+               static u_int old_interval = 0;
+               int current_hardclock_ticks;
+
                hi  = clockcia->tahi;
                lo  = clockcia->talo;
                hi2 = clockcia->tahi;
@@ -311,8 +315,14 @@
                        hi = hi2;
                }
 
+               current_hardclock_ticks = hardclock_ticks;
                interval = (amiga_clk_interval - 1) - ((hi<<8) | lo);
+               if (interval < old_interval &&
+                   old_hardclock_ticks == current_hardclock_ticks)
+                       interval += amiga_clk_interval;
 
+               old_hardclock_ticks = current_hardclock_ticks;
+               old_interval = interval;
                /*
                 * should read ICR and if there's an int pending, adjust
                 * interval. However, since reading ICR clears the interrupt,

As we cannot read ICR, the only possibility is to compare with the
hardclock_ticks and interval of the last call and add the amiga_clk_interval
as an offset when an underflow occurs.

This seems to work for me. No more "running backwards" warnings appear.

I would have hoped there is a nicer solution, but when nobody objects I
could commit the change.

-- 
Frank Wille



Home | Main Index | Thread Index | Old Index