C64 Lightguns/Stack light rifle
HOME CONTACT


This lightgun may not look as real as the gun included in the "Magnavox Odyssey Shooting Gallery" pack, it sure looks nice. It has games for the C64 and the VIC20. Due to the long barrel it claims to be a very accurate gun. Considering the difficulty of the available games you'll certainly need that accuracy. The most interesting part of this is the ability to configure it to your own taste. If you whish you can use it with or without the sholder piece or barrel. There were also versions with a scope and a longer barrel. The gun really feels comfortable when holding it and contributes largely to the gameplay. This gun design also exists under different names for different systems. Below you'll see that my own modified lightgun is build into such a gun.

How to use

The stack light rifle for the C64 of VIC20 is a little strange in how it should be connected to the computer. Because this system seems to come with 2 connectors. Although the C64 and VIC20 have all available signals in the joystick port connector, somehow this is not enough for the stack light rifle. The stack requires a power supply that has a higher voltage then the available 5V. Therefore it requires a connection to the userport of the C64 and VIC20. The userport has a 9V AC power supply. This isn't used by many devices but the stack light rifle uses it to generate a voltage of 12V (please correct me if I'm wrong). The 9V AC signal is rectified by a simple 4 diode bridge and a large capacitor. I hope to learn more about the circuitry soon which is from a technical point of view quite interesting.

Below you can see a photo of the manual (if somebody has the full manual and wants to scan it, please send me a message, so I can put it on this website).


Mechanical

The stack light rifle is a very customizable lightgun. The barrel and stock can be removed, which is practical for shipment in the box, but also allows users to use it a a gun or as a rifle.
Just remove the stock and barrel and suddenly your intimidating light rifle becomes a practical and handy lightgun. Unfortunately... this that can be removed often break or simply get lost over time.
The stock for instance. Below some detailed pictures of the stock and the mechanism to attach it to the gun. For those of you who are handy with wood and plastic... perhaps you can make the missing part based on these photo's.
You may click on the images to download a larger version to get a better view of the details.

Electrical

Trigger switch is connected between pin 3 (LEFT) and pin 8 (GND)
Light sensor (active low) is connected to pin 6
Light sensor circuit power is connected to pin 7 (+5V) and pin 8 (GND)

SLR_circuit.PDF This is the complete circuit of the PCB and cables of the stack light rifle in one handy PDF.

Programming

The X and Y coordinates of the lightpen use the same coordinates as sprites; thus the very first pixel at the left edge of the text screen would have an X coordinate of 24 on a PAL machine (read as half the value, i.e. 12, from the VIC address). See the programmers reference guide for more detailed information. Make sure you sampe the lightgun position values more then once. This because the X-position measurement contains some jitter. This isn't emulated by VICE because it is caused by the gun and the person holding it. Also make sure that you offer the option of calibrating the gun, that is to remove the offset from the position values. Request the user to point to the center of the screen (place a target there) and read the lightgun position values, then you can determine the error/offset. Subtract this offset from your measured positions during the game and you're done.

C64 register $D013 (X coordinate): Holds the X coordinate divided by two. In order to obtain the actual X coordinate (a 9-bit figure), you have to multiply by 2, or do an ASL on the byte obtained from this register, to get the actual X coordinate.
C64 register $D014 (Y coordinate): Holds the Y coordinate.
C64 register $D019 (VIC interrupt reg): Bit 3: LPIRQ, 1 = lightpen has captured a new value and indicates that D013 and D014 are updated (you do not need to use this register, you may read the D013 and D014 at any time and as much as you like)
C64 register $D01A (VIC interrupt enable reg): Bit 3: MLPI, 1 = enables lightpen interrupts (interrupt enable register is used for en/disabling lightpen interrupt in $D019)

Reading the trigger is possible with the following code:
;This routine will check the trigger, it will exit with the carry set when the trigger is pulled (and released)
CHECK_TRIGGER LDA $DC01 ;
AND #%00000100 ;check for fire button of Stack Light Rifle
BEQ CHECK_TR_STACK ;trigger of Stack light rifle detected
CLC ;clear carry to indicate that the trigger has not been pulled
RTS ;no trigger pulled, exit routine

CHECK_TR_STACK
LDA $DC01 ;
AND #%00000100 ;check for fire button of Stack Light Rifle
BEQ CHECK_TR_STACK ;keep looping until released
SEC ;set carry to indicate that the trigger has been pulled
RTS ;return to the calling routine

Adapter (SLR-to-MLP)

Now the Stack Light Rifle is a great piece of hardware... but it lacks software, so if we could only use it to play games that were written for other types of guns, we could at least increase its usability. So in order to make Magnum Light Phaser games work with the Stack Light Rifle an small adapter needs to be made. It requires 2 resistors, one transistor, a sub-d 9 pole male and a sub-d 9 pole female connector and some wires. Also some screws to hold it all together would certainly help.
Below is a photo of such an adapter, which as you can see, is very simply to build.



Here is the schematic of the adapter. As you can see it converts the trigger signal. The trigger signal of the SLR pull pin 3 (which is "joystick left" of the C64's joystick port) down to ground.
While the MLP requires pin 5 (which is "Pot-Y" of the C64's joystick port) to be pulled high.



It is to be advised to cast the whole converter into some hotglue to protect the components and wires, so that they wouldn't be damaged when thrown into a box of C64 parts.
Although the whole construction is relatively strong, casting it into hotglue would make it even stronger AND prevent direct access to the wires components and pins, reducing the risk of damages due to static electricity. Now this doesn't make it any prettier but it is a whole lot safer.




Downloads:

Knowing how difficult it can be to find information about Commodore related lightguns (and the games), I've made all information that I have available for download: C64_lightgun_games_and_info.zip