Joystick Programming Help

5 replies [Last post]
shiftkey's picture
Joined: Feb 10 2005
Posts: 51

I just got a Kraft Joystick from eBay for my Apple ][e, and I was wondering if anyone knew how to program with it in Applesoft. Thanks.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
woogie's picture
Joined: Dec 20 2003
Posts: 267

What exactly are you trying to do with it? I have
several "generic" joysticks that mate to Apple II
computers and they work seamlessly with the soft-
ware that used joysticks. The programming is already
there. Are you trying to write custom programs?
Use it in place of a mouse? (I think someone here
has been able to do that with a little rewriting).


Cats rule! Member since 8/01

Tom Owad's picture
Joined: Dec 16 2003
Posts: 2460

If I recall, there are two locations in memory, one for horizontal and one for vertical, which will return a value between-255 and 255, depending on the joystick's position. You can do a PEEK(X), where X is the memory location, to get the value.



Joined: Dec 19 2003
Posts: 832
How to read the joystick in Applesoft Basic

"The Hand Controls

If you have a set of hand controls connected to your computer, you can use the PDL function to read their dial settings. The Apple II series of computers can accommodate as many as four hand controls, numbered 0 to 3, connected either through the 9-pin hand control connector on the computer's back panel or, in those models where accessible, the GAME I/O connector inside the casse on the main logic board. However, the standard Apple hand control set consists of only two controls, numbered 0 and 1.

The PDL function takes one argument, the number of the hand control to be read, and yields an integer from 0 to 255 representing the current position of the dial on that control. For exammple,

10 LET X = PDL (0) -reads hand control 0
20 LET P% = X * 40 /256 + 1
-reduces to number from 1 to 40
30 HTAB (P%) -moves cursor to indicated position on current line
40 PRINT "<" -displays the character <
50 LET Y = PDL (1) -reads hand control 1
60 LET Q% = Y * 40 / 256 + 1
-reduces to a number from 1 to 40
70 HTAB (Q%) -moves curso to indicated position on current line
80 PRINT "." -displays the character >
90 IF X = 0 AND Y = 0 THEN END
-ends program when oth hand controls read 0
100 GOTOTO 10 -otherwise repeats the process

If the argument given to PDL is less than 0 or greater than 255, the program halts with the message ?ILLEGAL QUANTITY ERROR. If the argument is between 4 and 255, or if no hand control of the designated number is connected, the results are unpredictable.

Consecutive Readings: If your program reads two hand controls in consecutive statements, the reading from the first hand control may affect the reading from the second. To obtain more accurate readings, allow several program lines between calls to PDL or use a short delay loop such as

FOR X = 1 TO 10 : NEXT X

between PDL calls.

shiftkey's picture
Joined: Feb 10 2005
Posts: 51
Well, just for now

Well, just for now, I want to make like yunno, a game where you're a little aterisk (*) at the bottom of the screen, and things, like little rocks fall from above, and you catch them by moving yourself with the joystick. Thanks again.



Joined: Apr 15 2005
Posts: 2
And for the joystick button(s

And for the joystick button(s)...from:

..(P can be 0, 1, or 2) If N>127 then paddle button #P is being pressed or is not connected (paddle button #0 = Open Apple key; #1 = Solid Apple key; #2 = Shift key)

So, from Applesoft, it would be something like:

10 A=PEEK(-16287)