
Apple II Computer Info
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.
*/
#define FWENTRY_BUG 2 /* I'm assuming ORCA/C 2.0.1 to 2.0.3 */
#define PRead 0xFB1E /* Paddle read routine entry point */
Word read_paddle(Word n) {
/* Get the current reading from a paddle. Paddle 0 is the
joystick X axis, paddle 1 is the joystick Y axis. If a second
joystick is connected, it corresponds to paddles 2 (X) and 3 (Y). */
FWRec regs;
#if FWENTRY_BUG == 2
regs = FWEntry(PRead, n, 0, 0);
#elif FWENTRY_BUG == 1
regs = FWEntry(PRead, 0, n, 0);
#else
regs = FWEntry(0, n, 0, PRead);
#endif
return regs.yRegExit & 0xFF;
}
Boolean test_paddle(Word n) {
/* Test if a paddle has timed out since the last read. This routine
can be used to check whether it is safe to call read_paddle again.
The return value is TRUE if the specified paddle has timed out
and can be read again, FALSE if it is still timing out (this may
indicate that the paddle/joystick has not been connected if it
continues long enough). */
Byte paddle_flag;
Apple II Computer Technical Information : Apple II Family Hardware Info
ftp://ground.ecn.uiowa.edu/2/apple2/miscinfo/hardware : May 2001 : 229 of 572
Comentários a estes Manuais