💾 Archived View for mirrors.apple2.org.za › archive › ground.icaen.uiowa.edu › MiscInfo › Empson › p… captured on 2023-01-29 at 09:42:44.
-=-=-=-=-=-=-
Newsgroups: comp.sys.apple2 Path: news.uiowa.edu!chi-news.cic.net!newsxfer2.itd.umich.edu!gatech!news.mathworks.com!uunet!in2.uu.net!usc!elroy.jpl.nasa.gov!lll-winken.llnl.gov!ames!waikato!comp.vuw.ac.nz!actrix.gen.nz!dempson From: dempson@atlantis.actrix.gen.nz (David Empson) Subject: Re: Looking for BASIC program to center joystick Message-ID: <DLGp0n.Gz@actrix.gen.nz> Sender: news@actrix.gen.nz (News Administrator) Organization: Actrix - Internet Services Date: Sat, 20 Jan 1996 04:12:22 GMT References: <4dn2vaINNci3@portugal.cis.ohio-state.edu> X-Nntp-Posting-Host: atlantis.actrix.gen.nz Lines: 40 In article <4dn2vaINNci3@portugal.cis.ohio-state.edu>, Forest Hursey <forest@cis.ohio-state.edu> wrote: > > I am looking for a short BASIC program to use to center my joystick > with. Let's see here... 10 X = PDL(0): FOR I = 1 TO 100: NEXT: Y = PDL(1) 20 B0 = PEEK(49249) > 127: B1 = BEEK(49250) > 127 30 PRINT X; TAB(10); Y; TAB(20); B0; TAB(3); B1 40 GOTO 10 You might need to increase the duration of the FOR loop, especially if you have an accelerated machine - there needs to be a reasonable gap between reading the X and Y coordinates. You might also need to add a similar loop before the GOTO 10. Another solution is to use a WAIT instruction to make sure each paddle has timed out before reading it. This is more reliable, but will cause the program to hang if you don't have a joystick plugged in. To use this method, replace the first line with the following: 10 WAIT 49252,128,128: X = PDL(0): WAIT 49253,128,128: Y = PDL(1) You can make this method safe by using a long timeout on both paddles first, to check that it is plugged in, e.g. 5 X = PDL(0): FOR I = 1 TO 100000: NEXT: IF PEEK(49252) > 127 OR PEEK(49253) > 127 THEN PRINT "No joystick connected": END The joystick positions are displayed as a value from 0 to 255, with 127 being half way. The buttons are displayed as 0 for not pressed or 1 for pressed. -- David Empson dempson@actrix.gen.nz Snail mail: P.O. Box 27-103, Wellington, New Zealand