The paddles and joysticks on the Apple work by charging a capacitor through a variable resistance (potentiometer). For the first joystick, the X-axis corresponds to paddle 0, and the Y-axis to paddle 1, and similarly for the second joystick.
Accessing address $C070 discharges all capacitors, so they can now charge with a speed that is determined by the resistance. Addresses $C064 to $C067 can be read to check if the capacitor is fully charged (MSB set). BASIC is too slow to do that accurately, so you can use the inbuilt
PDL(x) commands, which call the monitor routine
The 3 buttons can be read by checking the MSB of addresses $C061 to $C063. In BASIC, you can use the following PEEK commands to get the values.
- PEEK 49249 - PADDLE 0 BUTTON (>127 IF BUTTON PRESSED)
- PEEK 49250 - PADDLE 1 BUTTON (>127 IF BUTTON PRESSED)
- PEEK 49251 - PADDLE 2 BUTTON (>127 IF BUTTON PRESSED)
Here is a simple program:
10 LET X = PDL(0)
20 LET Y = PDL(1)
30 PRINT "X=";X;" Y=";Y
40 GOTO 10
I've just tested that in AppleWin using the mouse as the joystick and it works fine.
More details about reading the paddles can be found in the appnote here, which explains some of the quirks you'll need to be aware of.