## Input/Output Device Driver Reference

[prev][next][parent][TOC]

### Understanding How the IBM PC Game-Port Adapter Works

The IBM PC game-port adapter provides a simple interface to joysticks and other similar analog devices. The status of up to four analog and four digital signals is read through I/O port address 201h. Two analog and two digital signals are commonly grouped together in the form of a dual-axis joystick with two "fire" buttons. Some modern joysticks use two axes for movement and an additional axis for throttle.

Each analog and digital signal is assigned one bit in the game adapter port . A low (binary zero) value for a bit connected to a joystick button is returned when that button is depressed. Bits representing analog signals are implemented as one-shot outputs. All one-shots are fired when the I/O port is written to and remain high until an RC timing circuit decays. The variable position of each joystick axis provides the necessary resistance for this delay circuit. If a joystick axis is not connected, the infinite resistance across that signal holds the one-shot high indefinitely.

Determining the position of each joystick axis is done by measuring the duration of the high state for each one-shot. Two methods are commonly used to measure this duration: counting loop iterations and reading the hardware timer. Although the iterative method is dependant on the speed of the processor, this limitation becomes irrelevant with proper calibration of each axis. This is the method chosen to sample the game-port adapter in this device driver.