Classic Computer Magazine Archive ANTIC VOL. 7, NO. 8 / DECEMBER 1988

Type-In Software

XG-1 Light Gun Finder

No more plugging and unplugging

by Matthew Ratcliff

It's awkward to plug your joystick or light gun into the Atari XE Game System because of the way that the ports are positioned. This short routine, when inserted in your games, makes it possible to keep your joystick and light gun plugged in constantly. This BASIC program is meant for use by owners of the Atari XEGS computer and XG-1 light gun. However, it will work on all 8-bit Atari computers of any memory size, with disk or cassette.

I am sure that just about all owners of the Atari XE Game System have been frustrated by the juggling of joystick and light gun cables needed when you play light gun games such as Barnyard Blaster and Bug Hunt. The XE Game System's controller port are beneath the case overhang and they slant forward at a very awkward angle.

But all that cable switching shouldn't be necessary. The right software could automatically detect which port the XG-1 light gun is being used from. This would allow active gamers to leave their joystick and light gun cables plugged in virtually all the time. You'd need to change cables only for games that require two joysticks, a paddle, etc.

Software detection of the Atari XG-1 light gun is actually quite simple. I studied some Atari technical documentation and found that regardless of which joystick port the gun is attached to, memory locations LPENV (565) and LPENH (564) are always updated by the operating system.

In fact, both Barnyard Blaster and Bug Hunt could have been just a bit smarter using a routine similar to Gun Finder. If the games had used such a routine, then the light gun could always be plugged into port 1 and a joystick always connected to port 0.

Whenever the light gun is plugged into any port, that port's joystick reading will be 14 instead of 15. Whenever the gun's trigger button is pressed, the joystick reading for that port goes to 15.

As a simple test, plug your light gun into port 1 and a joystick stick into port 0. Now fire up Bug Hunt or Barnyard Blaster. Pressing the trigger on the gun does nothing, but pulling back and releasing the joystick does. Notice that when firing with the joystick handle in port 0, the light gun positions on the display are accurate, even though it is plugged into port 1.

Listing 1 is the BASIC sample program for detecting and reading the light gun. Type in Listing 1, GUNDET.BAS, check it with TYPO II and SAVE a copy before you RUN it.

Listing 2, GUNDET.M65 is a MAC/65 assembly language source code example with the gun detect and read routines. You don't need to type Listing 2 in order to use the Gun Finder routine.

St. Louis engineer Matthew Ratcliff is a Contributing Editor to Antic.

Listing 1:GUNDET.BAS Download

Listing 2:GUNDET.M65 Download / View