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

Re: Joystick Devices



In article <4u86b1$pko@nyx10.cs.du.edu>, wbaguhn@nyx10.cs.du.edu (Will
Baguhn) wrote:

>In article <dempson-0608960110480001@dempson.actrix.gen.nz>,
>David Empson <dempson@actrix.gen.nz> wrote:
>>The problem with the Apple II version of the TouchWindow is that it
>>requires a lot of intensive polling.  To get reasonable results means
>>disabling interrupts, slowing the machine down to 1 MHz, and sitting in a
>>loop polling it for up to three milliseconds, preferably twice to get
>>decent readings for X and Y.  This should be done as often as possible.
>
>Would it be impossible to build a routine that doesn't require
>interrupt lockout, doesn't require slowing the machine to 1 MHz,
>and still gets fairly accurate readings?

Not likely.  If you don't lock out interrupts, then your code may be
interrupted for a considerable period of time while you are waiting for
the paddle circuit to time out.  This would prevent an accurate reading,
because your code would think the paddle took a lot less time than it
actually did, assuming the timing was being done by counting in a loop. 
If you were using a very high resolution external timer, then you would
think the paddle took a lot more time than usual, because you would also
be timing the interrupt routine's execution.

Running the machine in "fast" mode is a possible method of getting a
higher resolution count, but only if you can disable any accelerator that
may be installed (or the accelerator is configured to run at the standard
speed of the computer while the paddle circuits are being polled).

In any case, you would still have to lock out interrupts, so all you would
gain would be a higher resolution count.


I can only think of three ways of improving the behaviour of the
paddles/joystick:

1. Use a different hardware interface, e.g. an analog-to-digital
converter, or a hardware timer.

2. Use add-on hardware which can poll the existing paddle circuitry using
DMA, while allowing the computer to run normally (though at a slower
speed, because of the extra cycles required for DMA accesses).  This is
not feasible on the IIgs, because background DMA will clash with any other
DMA devices that are present.  It is also dubious on a IIe, dependent on
all DMA devices implementing the DMA priority chain correctly, and the DMA
cards being in adjacent slots.

3. Use a high resolution timer (e.g. the horizontal or vertical scan
counts) in conjunction with a modified paddle circuit which times out much
faster than the current one.  It wouldn't have so much impact on the
computer's execution if it didn't take so long to poll the paddle
circuits, but you would need to be able to measure the timeout with a
resolution of around one microsecond.

(A poll paddle/increment count loop running at 1 MHz has a resolution of
about 8 microseconds per sample.)

-- 
David Empson
dempson@actrix.gen.nz
Snail Mail: P.O. Box 27-103, Wellington, New Zealand