diff options
author | jmz <jmz@FreeBSD.org> | 1995-01-28 21:54:37 +0000 |
---|---|---|
committer | jmz <jmz@FreeBSD.org> | 1995-01-28 21:54:37 +0000 |
commit | e3426906a343032da48990bb566d7acd95dec4cd (patch) | |
tree | 04f34008f13b4055ec05da57d0461b9cd860ff87 /sys/dev/joy | |
parent | afd6259b6034dbc8f916327de82df8d2336f1f8d (diff) | |
download | FreeBSD-src-e3426906a343032da48990bb566d7acd95dec4cd.zip FreeBSD-src-e3426906a343032da48990bb566d7acd95dec4cd.tar.gz |
Do not recompute TIMER0's maximum count, since it is in timer0_max_count.
Use a simpler formula to convert usecs to ticks.
Output is in microseconds instead of ticks, so that values do not depend
on the timer frequency.
Diffstat (limited to 'sys/dev/joy')
-rw-r--r-- | sys/dev/joy/joy.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/sys/dev/joy/joy.c b/sys/dev/joy/joy.c index df3f780..83ff11a 100644 --- a/sys/dev/joy/joy.c +++ b/sys/dev/joy/joy.c @@ -49,14 +49,11 @@ * wait until the corresponding bit returns to 0. */ -/* #defines below taken from clock.c */ -#ifndef TIMER_FREQ -#define TIMER_FREQ 1193182 -#endif -#define usec2ticks(u) (u) * (TIMER_FREQ / 1000000) \ - + (u) * ((TIMER_FREQ % 1000000) / 1000) / 1000 \ - + (u) * (TIMER_FREQ % 1000) / 1000000 +/* the formulae below only work if u is ``not too large''. See also + * the discussion in microtime.s */ +#define usec2ticks(u) ((u) * 19549)>>14 +#define ticks2usec(u) ((u) * 3433)>>12 #define joypart(d) minor(d)&1 @@ -72,7 +69,7 @@ static struct { } joy[NJOY]; -extern int hz; +extern int timer0_max_count; int joyprobe (struct isa_device *), joyattach (struct isa_device *); @@ -145,7 +142,7 @@ joyread (dev_t dev, struct uio *uio, int flag) state >>= 2; t1 = get_tick (); if (t1 > t0) - t1 -= TIMER_FREQ/hz; + t1 -= timer0_max_count; if (!x && !(state & 0x01)) x = t1; if (!y && !(state & 0x02)) @@ -154,8 +151,8 @@ joyread (dev_t dev, struct uio *uio, int flag) break; } enable_intr (); - c[0] = x ? joy[unit].x_off[joypart(dev)] + (t0-x) : 0x80000000; - c[1] = y ? joy[unit].y_off[joypart(dev)] + (t0-y) : 0x80000000; + c[0] = x ? joy[unit].x_off[joypart(dev)] + ticks2usec(t0-x) : 0x80000000; + c[1] = y ? joy[unit].y_off[joypart(dev)] + ticks2usec(t0-y) : 0x80000000; state >>= 4; c[2] = ~state & 1; c[3] = ~(state >> 1) & 1; |