PC Hardware in a Nutshell, 3nd Edition Free Open Book

PC Hardware in a Nutshell, 3nd Edition

Previous Section Next Section

21.2 Gameport Interface

A standard PC gameport is actually a simple general-purpose analog data-acquisition port that supports four simple switched inputs and four variable-voltage inputs. A game controller connected to this interface uses one or more of the switched inputs to support buttons and one or more of the variable inputs to support a joystick, steering wheel, or similar device.

A paddle (originally used for Pong) is the simplest game controller. It uses only one switched input for a button and one variable input for a knob that controls movement in one direction. Accordingly, a gameport can support up to four paddles. A joystick uses one or two switched inputs for buttons and two variable inputs for a central stick that controls movement in both the horizontal (x-axis) and vertical (y-axis) directions. Accordingly, a gameport can support one or two joysticks. More complex game controllers use more of the switched inputs for additional buttons, and more of the variable inputs to control a third (z-axis) direction or for other purposes. This means that a gameport can support only one such controller.

Gameports do not require an IRQ, a DMA channel, or mapped memory, and occupy only one I/O base address. The downside of this small resource footprint is that gameports are not interrupt-driven, so the CPU must constantly poll the gameport to detect when a button is pressed or a stick is moved. Polling can require as much as 10% of the CPU, which degrades performance when you least want the performance hit—as you're playing a shoot-'em-up or trying to land a crippled fighter. The gameport connector on the PC is a DB-15F, shown in Figure 21-1.

Figure 21-1. The Gameport connector (on the computer)
figs/pcn3_2101.gif

Table 21-1 describes the gameport interface and pinouts. On MIDI-capable gameports (usually those on sound cards), Pin 12 is MIDI data out and Pin 15 is MIDI data in.

Table 21-1. Gameport interface signals and pinout

Pin

Name

Joystick function

Paddle function

Direction

1

+5VDC

Joystick 1 power

Paddle A coordinate high

Out

2

Button 4

Joystick 1 button 1

Paddle A button high

In

3

Position 0

Joystick 1 x-coordinate

Paddle A coordinate wiper

In

4

Ground

Joystick 1 button 1 ground

Paddle A button ground

-

5

Ground

Joystick 1 button 2 ground

Paddle B button ground

-

6

Position 1

Joystick 1 y-coordinate

Paddle B coordinate wiper

In

7

Button 5

Joystick 1 button 2

Paddle B button high

In

8

+5VDC

(unused)

Paddle B coordinate high

Out

9

+5VDC

Joystick 2 power

Paddle C coordinate high

Out

10

Button 6

Joystick 2 button 1

Paddle C button high

In

11

Position 2

Joystick 2 x-coordinate

Paddle C coordinate wiper

In

12

Ground

Joystick 2 button 1/2 ground

Paddle C/D button return

-

13

Position 3

Joystick 2 y-coordinate

Paddle D coordinate wiper

In

14

Button 7

Joystick 2 button 2

Paddle D button high

In

15

+5VDC

(unused)

Paddle D coordinate high

Out

There are two types of gameport, single- and dual-port. Table 21-1 describes the dual-port type. The single-port type uses the same connector, but does not support the Joystick 2 functions. In short, rather than supporting four switched inputs and four variable inputs, a single-port gameport supports only two of each, and can therefore support only one two-button, two-axis game controller. All current sound cards and most older sound cards provide dual-port gameports. Only a few very old models are single-port devices.

Joystick coordinate signals are analog inputs. Pins 3 and 6 report the x- and y-coordinates, respectively, for Joystick 1. Pins 11 and 13 do the same for Joystick 2. Moving the joystick alters the position of the slider on a 0 to 100 kW potentiometer, altering resistance, which in turn alters the voltage present on the pin. The gameport periodically samples the voltage on each coordinate pin using a monostable multivibrator. The gameport uses a base address of 201h. Writing to that address resets the monostable multivibrators and begins position measurement. Each byte subsequently read from 201h reports the status of the coordinate and button pins, as shown in Table 21-2.

Table 21-2. Gameport 201h byte

201h byte bitmask

  

7

6

5

4

3

2

1

0

Description

Pin

1

0

0

0

0

0

0

0

Joystick 2, button 2 (0=closed, 1=open)

14

0

1

0

0

0

0

0

0

Joystick 2, button 1 (0=closed, 1=open)

10

0

0

1

0

0

0

0

0

Joystick 1, button 2 (0=closed, 1=open)

7

0

0

0

1

0

0

0

0

Joystick 1, button 1 (0=closed, 1=open)

2

0

0

0

0

1

0

0

0

Joystick 2, y-coordinate (0=timed-out, 1=timing)

13

0

0

0

0

0

1

0

0

Joystick 2, x-coordinate (0=timed-out, 1=timing)

11

0

0

0

0

0

0

1

0

Joystick 1, y-coordinate (0=timed-out, 1=timing)

6

0

0

0

0

0

0

0

1

Joystick 1, x-coordinate (0=timed-out, 1=timing)

3

Most game controllers introduced since mid-1999 use USB instead of or in addition to the legacy gameport interface. Because USB is a general-purpose digital interface, game controller designers can implement whatever custom functions they wish in the controller hardware and define support for those functions in the driver.

    Previous Section Next Section
    Index: [SYMBOL][A][B][C][D][E][F][G][H][I][J][K][L][M][N][O][P][Q][R][S][T][U][V][W][Y][Z]


         Main Menu
    Main Page
    Table of content
    Dedication
    Copyright
    Foreword
    Preface
    Chapter 1. Fundamentals
    Chapter 2. Working on PCs
    Chapter 3. Motherboards
    Chapter 4. Processors
    Chapter 5. Memory
    Chapter 6. Floppy Disk Drives
    Chapter 7. High-Capacity Floppy Disk Drives
    Chapter 8. Removable Hard Disk Drives
    Chapter 9. Tape Drives
    Chapter 10. CD-ROM Drives
    Chapter 11. CD Writers
    Chapter 12. DVD Drives
    Chapter 13. Hard Disk Interfaces
    Chapter 14. Hard Disk Drives
    Chapter 15. Video Adapters
    Chapter 16. Displays
    Chapter 17. Sound Adapters
    Chapter 18. Speakers and Headphones
    Chapter 19. Keyboards
    Chapter 20. Mice and Trackballs
    Chapter 21. Game Controllers
    21.1 Game Controller Characteristics
    21.2 Gameport Interface
    21.3 Choosing a Game Controller
    21.4 Installing a Game Controller
    21.5 Troubleshooting Game Controllers
    21.6 Our Picks
    Chapter 22. Serial Communications
    Chapter 23. Parallel Communications
    Chapter 24. USB Communications
    Chapter 25. Cases
    Chapter 26. Power Supplies
    Chapter 27. Backup Power Supplies
    Chapter 28. Building a PC
    Colophon
    Index


    More Books
    PHP Hacks
    Processing Xml With Java - A Guide To Sax, Dom, Jdom, Jaxp, And Trax
    The Koran (Holy Qur'an)
    Macromedia Flash 8 Bible
    Search Engine Optimization for Dummies
    YouTube Traffic
    PHP 5 for Dummies
    Harry Potter and The Chamber of Secrets
    Harry Potter and the Sorcerer's Stone
    The Pilgrim's Progress
    Wireless Hacks
    Flash Hacks. 100 Industrial-Strength Tips & Tools
    PayPal Hacks. 100 Industrial-Strength Tips and Tools
    Amazon Hacks
    Pdf Hacks
    The Da Vinci Code
    Google Hacks
    The Holy Bible
    Windows XP For Dummies
    Harry Potter and the Half-Blood Prince
    Seo Book
    Upgrading and Repairing Networks
    Macromedia Dreamweaver 8 UNLEASHED
    Windows XP Annoyances
    Windows XP Hacks
    Microsoft Windows XP Power Toolkit
    Teach Yourself MS Office In 24Hours
    iPod & iTunes Missing Manual
    PC Hacks 100 Industrial-Strength Tips and Tools
    PC Overclocking, Optimization, and Tuning - 2th Edition
    PC Hardware In A Nutshell 3rd Edition
    PC Hardware in a Nutshell, 2nd Edition
    Upgrading and Repairing PCs
    Google for Dummies
    MySQL Cookbook
    Teach Yourself Macromedia Flash 8 In 24 Hours
    PHP CookBook
    Sams Teach Yourself JavaScript in 24 Hours
    PHP5 Manual
    Free Games Paper Airplanes
    500 Juegos Gratis 500 Giochi Gratis 500 Jeux Gratuits 500 Jogos Gratis 500 Kostenlose Spiele