[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reading Joystick Position
"Simon Williams" <DONTemail@luddite.ca> wrote in message
1118189.CMKYXGAG@news.telusplanet.net">news:1118189.CMKYXGAG@news.telusplanet.net...
> I'm having some problems figuring this out:
>
> In Applesoft PDL(0) and PDL(1) are the X & Y coordinates of the
> joystick, but I can't figure out the actual memory locations for these.
> According to most of the information I have available I should be able
> PEEK somewhere between 49252-49255, but these locations do not return
> the same values and don't seem to be related at all to the joystick.
> FWIW the joystick I'm using is a QuickShot which has an Apple setting
> switch, and works perfectly for all games and programs I've tried (which
> is why I assume the problem is with me and not the hardware).
>
> Any help with this would be much appreciated.
You have the right addresses, but the wrong technique.
Accessing $C070 (49266) starts a quad timer (all four Paddle inputs).
The paddles provide the R in an RC time constant.
The timer outputs show up as the hi bit of those 4 addresses.
After the timers time out, the hi bit goes from high to low.
A software timing loop determines the PDL value.
It's fast (12 microseconds per tic), so you can't duplicate this with Peeks
from Applesoft.
Here's the routine.
$FB1E
PREAD LDA $C070 start timers, enter with paddle # in X
LDY #0
NOP
NOP
PREAD2 LDA $C064,X
BPL RTS2D
INY
BNE PREAD2
DEY ; 255 max
RTS2D RTS