
Interfacing digital joysticks to the PC using the parallel port

               Tormod Tjaberg (tjaberg@online.no)

             Copyright (C) 1997-2002 Tormod Tjaberg


intro
=====

Remember the good old ATARI/CBM64/AMIGA joystick? With only
a few resistors and some connectors this type of joystick may
be interfaced to your PC using the parallel port. Actually any
kind of digital joystick may be interfaced in this manner.

advantages
==========

. Much faster response time than an analog joystick
. You don't need a gameport! So it will work on laptops as well.
. You don't have to buy an expensive analog joystick!
. No calibration necessary
. You may use your _original_ arcade joystick with MAME.
. Up to four digital joysticks may be supported on the same PC. (Gauntlet)
  The software provided only supports one port, but this has to do with
  it's inherent design as an 'allegro' replacement function.
. Works under DOS, Win 3.11 and Windows 95 

disadvantages
=============

. If you don't have the source to your game you will need some
  kind of TSR which can translate the joystick signals into 
  keypresses. If someone is competent enough to write a small
  TSR like this please contact me. I have some source for a 
  TSR in C but I've still to make a driver. Just now I've 
  written a driver for MAME.

disclaimer
==========

I take NO responsibility whatsoever for any damage you might 
cause to your hardware by making this cable. 

the interfaces
==============

There are actually three methods of making the interface. Each
method has it's pro's and con's. They are all outlined below.

The one to make depends on your requirements and your parallel port.
The software handles all versions of the cables. To make the interface
you will require a soldering iron, one 25pin D-SUB male and one 9pin
D-SUB male. For the "intermediate" & "advanced" interface you will
need 5-8 4.7K resistors as well.

Read the entire document before rushing off to get the soldering iron!

Note:
You only need the 9pin D-SUB male if you want to interface
to an ATARI joystick. If you want to use a real arcade joystick
you will have to sort out the connections yourself. 

Warning:
If your joystick has an auto fire feature do not try to enable
this feature by using 5V from the parallel port. Use an external 5V
source instead.

the "beginner"
==============

Pros:
. Requires only a few wires therefore it's easy to make.
. Directly compatible with the ATARI joystick.

Cons:
. Does not work on all parallel ports. Run the program "beginner".
  to determine if your parallel port can support the "beginner" interface.
. Only supports one fire button.

ASCIIMatic:

  ATARI Joystick                       PC Parallel port

  pin 1 (UP)     --------------------- pin 10  (-ACK)
  pin 6 (FIRE_1) --------------------- pin 11  (BUSY)
  pin 2 (DOWN)   --------------------- pin 12  (PE)
  pin 3 (LEFT)   --------------------- pin 13  (SLCT)
  pin 4 (RIGHT)  --------------------- pin 15  (-ERROR)
  pin 8 (GND)    --------------------- pin 18  (GND)

the "intermediate"
==================

Pros:
. Works on all parallel ports.
. Directly compatible with the ATARI joystick.

Cons:
. Requires 5 pull up resistors which means more soldering.
. Only supports one fire button.

ASCIIMatic:

  ATARI Joystick                       PC Parallel port

                     +---------------- pin 3   (Data bit 1)
                     |  +------------- pin 6   (Data bit 4)
                     |  |  +---------- pin 7   (Data bit 5)
                     |  |  |  +------- pin 8   (Data bit 6)
                     |  |  |  |  +---- pin 9   (Data bit 7)
                     |  |  |  |  |
                     @  @  @  @  @     (resistors)
                     @  @  @  @  @
                     |  |  |  |  |
  pin 1 (UP)     ----|--|--|--|--+---- pin 10  (-ACK)
  pin 6 (FIRE_1) ----|--|--|--+------- pin 11  (BUSY)
  pin 2 (DOWN)   ----|--|--+---------- pin 12  (PE)
  pin 3 (LEFT)   ----|--+------------- pin 13  (SLCT)
  pin 4 (RIGHT)  ----+---------------- pin 15  (-ERROR)
  pin 8 (GND)    --------------------- pin 18  (GND)


the "advanced"
==============

Pros:
. Works on all parallel ports (provided they're not in EPP or ECP mode)
. Has support for 4 fire buttons.

Cons:
. Requires 8 pull up resistors this means even more soldering.
. The parallel port must be in 'normal' mode i.e. not EPP or ECP to
  support the three extra buttons.
. You will have to create some kind of extra board to get to use
  the three extra buttons on an ATARI joystick.

ASCIIMatic:

  ATARI Joystick                              PC Parallel port
  
                   +------------------------- pin 5   (Data bit 3)
                   |  +---------------------- pin 4   (Data bit 2)
                   |  |  +------------------- pin 3   (Data bit 1)
                   |  |  |  +---------------- pin 2   (Data bit 0)
                   |  |  |  |  +------------- pin 6   (Data bit 4)
                   |  |  |  |  |  +---------- pin 7   (Data bit 5)
                   |  |  |  |  |  |  +------- pin 8   (Data bit 6)
                   |  |  |  |  |  |  |  +---- pin 9   (Data bit 7)
                   |  |  |  |  |  |  |  |
                   @  @  @  @  @  @  @  @     (resistors)
                   @  @  @  @  @  @  @  @
                   |  |  |  |  |  |  |  |
  pin 1 (UP)     --|--|--|--|--|--|--|--+---- pin 10  (-ACK)
  pin 6 (FIRE_1) --|--|--|--|--|--|--+------- pin 11  (BUSY)
  pin 2 (DOWN)   --|--|--|--|--|--+---------- pin 12  (PE)
  pin 3 (LEFT)   --|--|--|--|--+------------- pin 13  (SLCT)
        (FIRE_2) --|--|--|--+---------------- pin 14  (-AUTO FEED)
  pin 4 (RIGHT)  --|--|--+------------------- pin 15  (-ERROR)
        (FIRE_3) --|--+---------------------- pin 16  (-INIT)
        (FIRE_4) --+------------------------- pin 17  (-SLCT IN)
  pin 8 (GND)    ---------------------------- pin 18  (GND)

how does it work
================

The parallel port has 5 input lines. They are read in the status
register of the parallel port. By using a pull-up resistor on these
lines and 5 switches we can read the values from the status register.
 
The three extra inputs are actually outputs in the control register! 
Since the control register is both r/w we can write a value to the 
register and read it back. If we write a one to the line and the 
output is shorted we will read back a 0 (these outputs are open-collector).
Thus we're able to use them as inputs as well. See the example programs
for details. 

troubleshooting
===============

If your interface doesn't work properly:

. Verify that you're testing the correct port.
. Verify your connections and solderings.
. If the 3 extra buttons don't work on the "advanced" interface
  check that your parallel port is NOT in EPP or ECP mode. This
  is usually a BIOS setting.
. Make sure that a dongle is not connected. A dongle sucks 
  current in weird and wonderful ways.
. If your joystick has an auto fire feature make sure it's off.
  (Unless you've provied it with a steady 5V source)

the code
========

The code supplied should compile under most compilers. It was
specifically developed for djgpp. But I've tested it under
Zortech, Watcom, Symantec and Turbo C. Running under
DOS, Win 3.11 and Windows 95.

credits
=======

. Jakob Frandsen (jfrandsen@ite.dk). For putting me onto this
  idea with his Bombjack emulator.
. Richard Steven Walz rstevew@armory.com. For verifying my designs.
. The MAME project for the trips down memory lane.
. Annette and Alexander for being.

contacting the author
=====================

. tjaberg@online.no
. http://home.online.no/~tjaberg

