|C64 Lightguns/Stack light rifle|
How to use
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).
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 lightrifle becomes a practical and handy lightgun. Unfortunately... this that can be removed often break or simply get lost over time.
The stock for instance. Thefore 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.
|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.
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
position values more then once. This because the X-position measurement
contains some jitter. This isn't emulated by VICE because it
caused by the gun and the person holding it. Also make sure
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
values, then you can determine the error/offset. Subtract this
offset from your
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)
|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: <click here to go to the download location>|