💾 Archived View for mirrors.apple2.org.za › archive › apple.cabi.net › FAQs.and.INFO › CPUandMore › … captured on 2023-01-29 at 07:43:34.
-=-=-=-=-=-=-
Newsgroups: comp.sys.apple2.programmer Path: news.uiowa.edu!uunet!usc!elroy.jpl.nasa.gov!decwrl!waikato!comp.vuw.ac.nz!actrix.gen.nz!dempson From: dempson@atlantis.actrix.gen.nz (David Empson) Subject: Re: Joystick and stuff Message-ID: <D5JGFJ.Bp7@actrix.gen.nz> Sender: news@actrix.gen.nz (News Administrator) Organization: Actrix Information Exchange Date: Thu, 16 Mar 1995 15:02:06 GMT References: <pU26uow.sjc@delphi.com> X-Nntp-Posting-Host: atlantis.actrix.gen.nz Lines: 138 In article <pU26uow.sjc@delphi.com>, Stephen Carpenter <sjc@delphi.com> wrote: > I am on a GS and was wondering how I can read the Joystick > I am using Orca/c (if that helps any) It certainly affects how you will go about reading the joystick. There is no firmware or toolbox support provided for reading the joystick from GS/OS. Apart from writing your own assembly language code to read it, the easiest way is to use the FWEntry tool call in the Miscellaneous toolset to call the old PREAD routine in the monitor. This will allow one axis of the joystick to be read. You can then call it again with different parameters to read the other axis. Note: you have to ensure each axis has timed out before trying to read it. If you try to read the X and Y values immediately after each other, you will probably get a false reading on the second one. A delay of at least three milliseconds is recommended. One commonly used solution is to separate the reading of the X and Y values and do several other operations between them. Reading the buttons is easier: it is just a matter of reading the appropriate I/O locations directly. Now for the details: First, a very major warning: the FWEntry toolbox call has been implemented incorrectly in all versions of ORCA/C: its parameters are in a different order than they are listed in the toolbox reference. Even worse, the parameter order varies depending on which compiler version you have (all of them are wrong). The official definition of FWEntry is: regs = FWEntry(aReg, xReg, yReg, entryPt); With ORCA/C 1.0 to 2.0.0, you must reverse the parameters: regs = FWEntry(entryPt, yReg, xReg, aReg); With ORCA/C 2.0.1 to 2.0.3, you must swap the first and last parameters: regs = FWEntry(entryPt, xReg, yReg, aReg); This will probably be fixed in a future version of the compiler (it is actually a bug in the library code), so the correct parameter order will be used (a, x, y, entryPt). [Yes, Mike does know about this one.] If you change compiler versions, make sure you check your FWEntry calls are correct for the new version. Having got that out of the way, here is the code required to read either axis of the joystick from ORCA/C. I've used inline assembly language to read I/O ports directly, to avoid possible hickups with ORCA/C reading the following byte as well. #include <misctool.h> /* Set the FWENTRY_BUG macro according to the compiler version you are using: 1 ORCA/C 1.x, or ORCA/C 2.0.0 2 ORCA/C 2.0.1 through 2.0.3, or future versions that still have the same bug. 0 Future versions of ORCA/C that have the bug fixed.