Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PC game port questions

73 views
Skip to first unread message

Pat Niemeyer

unread,
Nov 10, 1993, 12:08:01 PM11/10/93
to

Can someone tell me briefly how to read the PC game (joystick) port hardware?
I would like to use the potentiometer inputs to monitor some things.

I know that there is at least one register at 0x201, but I can't find
any specifics.


Thanks,
Pat

Pat Niemeyer

unread,
Nov 10, 1993, 2:57:07 PM11/10/93
to
[ I previously posted ]

Just to clarify, I am planning on writing a Unix device driver. So I
will not have access to any DOS bios routines.

I am really just looking for a description of where to write to start the pot
timers, where to read them back, and what kind of times would be involved.

Any info would be greatly appreciated.

Thanks,
Pat

Edgar Perez

unread,
Nov 10, 1993, 5:31:38 PM11/10/93
to
Pat Niemeyer (p...@fegmania.wustl.edu) wrote:

: I am really just looking for a description of where to write to start the pot


: timers, where to read them back, and what kind of times would be involved.

: Any info would be greatly appreciated.

although it is a most unlikely place, you will find what you
need in the Joystick section of the "flight of fantasy" book.
This book explain how to write a flight simulator using C++.
(I have the book at home, so can't give ISBN now,
email me if you don't find other reference and will look it up).

Edgar

Anssi Saari

unread,
Nov 10, 1993, 6:06:40 PM11/10/93
to

That's the only port it uses, I think. There's a bios call read
the values:

INT 15,84 - Joy-Stick Support


AH = 84h
DX = 0 to read the current switch settings
= 1 to read the joystick position (resistive inputs)


on return (DX=0, read switch setting):
CF = 0 if successful
= 1 if error
AH = 80h error code if CF set on PC
= 86h error code if CF set on XT before 11/8/82
AL = switch settings in bits 7-4 (if read switch function)

on return (DX=1, read joystick position):
AX = A(X)
BX = A(Y)
CX = B(X)
DX = B(Y)


Anssi
--
Anssi Saari s10...@ee.tut.fi
Tampere University of Technology
Finland, Europe

PDP11 Hacker .....

unread,
Nov 11, 1993, 8:32:00 AM11/11/93
to
In article <pat.75...@fegmania.wustl.edu>, p...@fegmania.wustl.edu writes...

>[ I previously posted ]
>
>>Can someone tell me briefly how to read the PC game (joystick) port hardware?
>>I would like to use the potentiometer inputs to monitor some things.
>
>>I know that there is at least one register at 0x201, but I can't find
>>any specifics.

Yes, 1 I/O port, at hex 201 only. Write to port 201 to start the timers. Read
port 201 for the status - the bits are :
7 - 4 Digital inputs (MSB = button 3 etc)
3 - 0 Outputs of the timers (3 = Y2, 2 = X2, 1 = Y1, 0 = X1)
Writing to port 201 will set the timer outputs to logic 1. They then go back to
logic 0 after a time determined by the value of pot.

>
>Just to clarify, I am planning on writing a Unix device driver. So I
>will not have access to any DOS bios routines.
>
>I am really just looking for a description of where to write to start the pot
>timers, where to read them back, and what kind of times would be involved.

Write to port 201 to start the timers. Read them back at the same port. Pots
are normally 0-150k variable resistors (0-100k sometimes), and according to the
IBM techref, the time is given by
Time = 24.2e-6s + 0.011e-6s * R/Ohms

>
>Any info would be greatly appreciated.

Hope this helps.

>
>Thanks,
>Pat

-tony

eva...@uspif.if.usp.br

unread,
Nov 11, 1993, 9:18:35 AM11/11/93
to

I did used the PC game port as an analog input, and I think I can help you..

To reset the timer , send 0 to port 0x201 and then implement an loop that
increment an variable while port is not high.

function bellow reads an value from horizontal pot of game port A.

int readgame(void)
{
int j,k;

k=0;
j=0;
outportb(0x201,0);
j=inportb(0x201)&1;

while (j)
{
k++;
j=inportb(0x201)&1;
}

return (k);
}

You can implement up to four analog inputs and four switch inputs with PC game
port.

I hope this reply can help you....
Good luck.. :)

/* Evandro - Computer Engineering Student */
/* Universidade de Sao Paulo - USP */

Richard Steven Walz

unread,
Nov 13, 1993, 3:14:11 AM11/13/93
to
In article <pat.75...@fegmania.wustl.edu>,
--------------------------
When you write to port 201 hex, you start the clocks. It doesn't matter
what you write, it goes nowhere, the address selector and write line
trigger it. Then you read it till the pot inputs change state back to their
original state. They are either the high or low nybble of the data at 201
hex when you read it. The longer they stay in their timing state, the
greater the pot resistance. They use 100K ohm pots. The other nibble is the
state of the push buttons, two from each joystick, a primary and a
secondary. Read it any time. Look in the IBM hardwar manual for the pinout
and circuitry.
-Steve Walz rst...@armory.com this was just published a week ago!

Feldman / Mark Jeffrey (ISE)

unread,
Nov 13, 1993, 12:51:09 AM11/13/93
to
In article <s106275....@ee.tut.fi> s10...@ee.tut.fi (Anssi Saari) writes:
>
>That's the only port it uses, I think. There's a bios call read
>the values:
>
> INT 15,84 - Joy-Stick Support

Just a word of caution, I've come across several machines which don't have
this in their BIOS. My 286 Pheonix for example reported the button's
status but didn't return the position values. Seeing as my joystick has
worked on every game I've tried it on I think it's safe to assume that
most commercial games don't use this interrupt.

Mark

Michael Covington

unread,
Nov 15, 1993, 11:33:39 PM11/15/93
to

I've been looking into this. Phoenix *claims* their BIOS supports it,
and IBM has supported it since the PC AT (but not the PC, PCjr, or PC XT).
Maybe your joystick resistance is too high for your particular machine.

The problem is, the behavior of the BIOS interrupt is not very reproducible
from machine to machine. A normal 0-200k joystick resistance gives very
different readings on different machines.

For the best reproducibility, write your programs in BASIC. The joystick
reading routines in BASICA, GWBASIC, QBASIC, and QuickBASIC are very
reproducible from machine to machine -- they number they give you is very
close to the resistance in kilohms, and is unaffected by CPU speed.
Microsoft did something right.

--
< Michael A. Covington, Assc Rsch Scientist, Artificial Intelligence Programs >
< The University of Georgia, Athens, GA 30606-7415 USA mcov...@ai.uga.edu >
<>< ----------------------------------------------------------------------- ><>
< For info about U.Ga. degree programs, email GRA...@UGA.CC.UGA.EDU (not me) >

0 new messages