Joystick Programming Help

6 posts / 0 new
Last post
shiftkey's picture
Offline
Last seen: 8 years 5 months ago
Joined: Feb 10 2005 - 18:52
Posts: 51
Joystick Programming Help

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.

woogie's picture
Offline
Last seen: 7 years 1 month ago
Joined: Dec 20 2003 - 10:38
Posts: 267
Joystick

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).

Tom Owad's picture
Offline
Last seen: 10 hours 39 min ago
Joined: Dec 16 2003 - 15:14
Posts: 3349
PEEK

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.

Offline
Last seen: 8 months 3 weeks ago
Joined: Dec 19 2003 - 18:53
Posts: 906
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
Offline
Last seen: 8 years 5 months ago
Joined: Feb 10 2005 - 18:52
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.

Offline
Last seen: 18 years 11 months ago
Joined: Apr 15 2005 - 14:17
Posts: 2
And for the joystick button(s

And for the joystick button(s)...from: http://apple2.org.za/gswv/USA2WUG/A2.LOST.N.FOUND.CLASSICS/A2.BB.PEEKS.POKES.CALLS.html

$C061+P.......-16287+P............N=PEEK(49249+P)-128
..(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:

5 REM READ JOYSTICK BUTTON 0
10 A=PEEK(-16287)

Log in or register to post comments