Path: utzoo!attcan!uunet!lll-winken!ncis.llnl.gov!ncis!helios.ee.lbl.gov!pasteur!ucbvax!decwrl!purdue!bu-cs!encore!maxzilla!paradis From: paradis@maxzilla.Encore.COM (Jim Paradis) Newsgroups: comp.sys.ibm.pc Subject: Re: GamePorts Message-ID: <4691@xenna.Encore.COM> Date: 17 Jan 89 21:22:05 GMT References: <1515@psu-cs.UUCP> Sender: news@Encore.COM Reply-To: paradis@maxzilla.UUCP (Jim Paradis) Organization: Encore Computer Corp, Marlboro, MA Lines: 36 >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