[comp.sys.ibm.pc] Game ports

warren@psu-cs.UUCP (Warren Harrison) (01/17/89)

Has anyone out there had any experience reading the PC/XT/AT game port?
Does teh game port have a fixed port number (if so, what is it)? Do I
need to use interrupts to read it, or can I just poll the port to see
what is happening to the joystick?

Many thanks in advance.  Warren
-- 
-------------------------------------------------------------------------------
Warren Harrison                 CSNET: warren@pdx.edu
Department of Computer Science  UUCP:  {ucbvax,decvax}!tektronix!psu-cs!warren
Portland State University       Internet: warren%pdx.edu@relay.cs.net
Portland, OR 97207-0751

paradis@maxzilla.Encore.COM (Jim Paradis) (01/18/89)

>Has anyone out there had any experience reading the PC/XT/AT game port?
>Does teh game port have a fixed port number (if so, what is it)? Do I
>need to use interrupts to read it, or can I just poll the port to see
>what is happening to the joystick?

The PC/AT BIOS has an entry point for reading the game port; if you
can get your hands on a PC/AT BIOS listing, it has all the details
you need (it's been a while since I looked at it; I remember how it's
done, but I don't remember the addresses or the details...).  Anyhow,
on an AT all you have to do is call the BIOS.  On an XT, you have to do
it yourself.  Basically each axis of the joystick operates by controlling 
the frequency of a pulse generator, and counting the resulting pulses over
a time interval.  To "read" an axis of the joystick, you have to reset
the counter to zero, start it counting, then come back a fixed time interval
later (e.g. by spinning on the system clock or by posting a clock
interrupt) and read the counter.

This whole scheme accounts for two particular behaviors of the joystick;
first of all, since no two potentiometers are ever QUITE the same, the
joystick has to be re-calibrated every time you use it (that's why Flight
Simulator has the "center joystick" command).  And second, that's why
the joystick somtimes exhibits "jumpiness" even when you're not touching
it -- depending on when the first pulse occurs after the timing interval
starts, you may end up with a difference of one pulse between successive
readings of the joystick...

This also explains why joysticks won't work on some high-speed machines:
if the timing interval is dependent on the CPU speed (e.g. spinning in a
NOP loop) then using a shorter interval reduces the difference in the
number of pulses between the extremes of the joystick's travel.  When
this happens, the program may report the joystick at "full left" for quite
a while, and then report "full right" with nothing in between.  I myself
have to drop my AT-clone down to 6MHz in order to use the joystick...

Jim Paradis (paradis@encore.UUCP) 508-460-0500
Devout Secular Humanist and Worshipper of Bacchus in Vintage Years

ewa@silvlis.com (Ernest Adams) (01/31/89)

I don't want to beat the joystick issue to death, but I wonder if anyone out
there can help me.  I'm a hardware novice and phrases such as "...you have to
program the 5558 timer, then wait 25 microseconds..." give me the blue creevles.

[Doubtless this will inspire flaming about how programmers should know
*everything* about their machines, etc.  I'm getting there, it just takes
me longer than most.]

Anyway:  Is someone willing to write me an assembly-language routine,
linkable (or "in-line-able") with Turbo or Microsoft C or Pascal, which
will simply return two numbers, each 0 <= N <= 255, which give a joystick
position?  I'm willing to ask my users to center the joystick and then move
it to some extreme, in order to get the bounds; I just want numbers.

Also, how about something that tells me whether button 0 or 1 is pressed
or not when I ask it?  I haven't seen anything here telling how to find out
if a button is pressed.

Thanks very much.

				Ernest Adams

fargo@pawl.rpi.edu (Ethan M. Young) (01/31/89)

I am also interested in programming the game-ports on an IBM AT compatible
machine.

I have seen programs that allow one to emulate a joystick as a mouse,  But
only to move the cursor.  I am looking for or want to know how to write, a
program that will allow a joystick to emulate a mouse on the hardware level.
eg. Make my $15 joystick act as a Microsoft Bus Mouse in all respects.  Even
to the point that the Microsoft Mouse driver says there's a mouse installed.

If someone can provide me with any information concerning this, I would be
very grateful.

Thank you and happy hunting!   Internet: fargo@pawl.rpi.edu
    ____    [> SB <]                     fargo@{paraguay|uruguay}.acm.rpi.edu
   /__      -=>??<=-        Bitnet (??): usergac0@rpitsmts.bitnet
  /   ARGO : 3000 years of regression from the year 4990

fargo@pawl.rpi.edu (Ethan M. Young) (02/12/89)

I have asked this question before, but the only responses I have gotten all
amount to the phrase: "It can't be done."  But I know it can be done.

I own a Zenith-248.  Installed in the Zenith is a Vista Screen Enlargement 
Adapter.  This is a card with takes the output from the standard video card
, enlarges it using hardware, and then outputs it to my monitor.   

In order to control the size of enlarged letters on my screen, the Vista uses
a Logitech mouse.  The problem is that this mouse is completely dedicated to
Vista.  It cannot be used for any other applications.  I need a second mouse,
but do not have the finance (or the slots in my machine) for another mouse.
I do, however, have a joystick.  I have in my possession two programs which
claim to allow one to use one's joystick as a mouse.  In actuality, though, all
these programs let me do is use the joystick to move the hardware cursor.  I
need a program that will allow the joystick to be used such that I have a sec-
ond mouse installed,  (Preferrably a Microsoft Bus mouse)  If someone can pro-
vide me with a program of this nature, or would be willing to write one for me,
I would be willing to pay for it.  If that is not possible, I would dearly ap-
preciate any input on how to read input from the game port (namely a joystick)
and how the Microsoft Bus Mouse Driver interfaces with the hardware adapter.

Send responses through e-mail or on comp.sys.ibm.pc.  I ask that people who
have nothing to say other than "it can't be done" to please not respond as I
am not looking for that kind of response.
   Thank you.

Thank you and happy hunting!   Internet: fargo@pawl.rpi.edu
    ____    [> SB <]                     fargo@{paraguay|uruguay}.acm.rpi.edu
   /__      -=>??<=-        Bitnet (??): usergac0@rpitsmts.bitnet
  /   ARGO : 3000 years of regression from the year 4990

fargo@pawl.rpi.edu (Ethan M. Young) (02/21/89)

My technical manual makes a very abrupt blurb on reading input from a joy-
stick, so could anyone please send me information on how to input from a jpy-
stick on an AT?

Thanks in advance.

Thank you and happy hunting!   Internet: fargo@pawl.rpi.edu
    ____    [> SB <]                     fargo@{paraguay|uruguay}.acm.rpi.edu
   /__      -=>??<=-        Bitnet (??): usergac0@rpitsmts.bitnet
  /   ARGO : 3000 years of regression from the year 4990

fargo@pawl.rpi.edu (Ethan M. Young) (02/28/89)

Sorry to keep bringing this up, but some of my files got clobbered for no
apparent reason.

Could the people who sent me information on reading the game ports on an AT
compatible computer please re-send the information?

Many thanks and apologies in advance.  (And some later on...)

Thank you and happy hunting!   Internet: fargo@pawl.rpi.edu
    ____    [> SB <]                     fargo@{paraguay|uruguay}.acm.rpi.edu
   /__      -=>??<=-        Bitnet (??): usergac0@rpitsmts.bitnet
  /   ARGO : 3000 years of regression from the year 4990