Why doesn’t my NES Zapper work?

When I was around 4-5 years old I remember playing on a NES while over at friends’ of my parents. Growing up, the classic NES titles like Super Mario Bros., Duck Hunt, Super Mario Bros. 3, etc., and now that I’m “an adult” I have my very own NES. The only problem is that I recently discovered that I couldn’t play Duck Hunt! The game cartridge works perfectly fine and I even have an old analogue CRT TV that is compatible with the NES Zapper, but for some reason (as you will learn as I did) the gun didn’t work when I would fire up a Duck Hunt session.


The first thing I did was check Google to see if anyone else encountered this problem. Most of the results pertained to issues with getting the Zapper to work with LCD TVs, (not my problem, but to understand why it doesn’t work with LCDs, you can checkout out the Wikipedia article) so I disassembled the Zapper’s connector and connected a multimeter to monitor the voltage levels when the Zapper was connected to the NES.

 nes nes_zapper

The measurements revealed that when the trigger was pulled, the voltage on pin D4 (bottom left pin of the picture where I’m holding the connector) of the NES controller connector didn’t rise to 5V from 0V; instead, the voltage would stay at 5V and very slowly decay. I decided to take apart the Zapper to see if it was the problem (and because I wanted to see how it worked!).

 nes_connector4 nes_connector
nes_connector3 nes_connector2

If you have ever used a Zapper, you may have noticed (or maybe not) how well balanced the controller feels in your hand. As you can see in the picture, the Zapper has a metal weight in the handle that helps balance the controller. There is also a lens and metal collimator in the barrel of the Zapper. Well actually the whole barrel is really a collimator and the metal collimator probably acts as another weight to help balance the controller.  Finally there is the trigger mechanism and the Zapper circuit. The Zapper circuit handles detection of trigger pulling and whether or not the user has “hit” the target in Duck Hunt.


I mapped out the circuit (very roughly…) and found that the circuit is really two circuits in one: 1) a trigger circuit with a 10uF de-bouncing capacitor, and 2) some kind of circuit that decodes input from a PD 43Pi photodiode, used to detect if a duck has been hit or not, using an IR3T07A chip (couldn’t find the datasheet!), and the output from this chip is inverted using a 2SC458 NPN transistor. This output is sent to the NES through the D3 pin.

inside_zapper zapper_circuit
zapper_circuit3 zapper_circuit2

Testing of the Zapper circuit determined that it was working. I checked the capacitors and resistors and they all seemed to be ok. I also checked to see if varying the intensity (brightness) of light on the photodiode varied the voltage output on pin D3 (the pin right above D4) and it did change as expected; the brighter the light, the larger the voltage. These results suggested that there must be a problem with the NES, so I put the Zapper back together and connected it to the player 1 port on the NES. Pulling the trigger showed that the voltage on D4 would jump from 0V to 5V to 0V as it should! So the problem was with the player 2 port on the NES. At this point, I also found a website with a nice circuit diagram and description of the Zapper gun.

The Fix


When I opened up the NES, the problem was immediately obvious. As you can see in the picture, for some reason, one of the wires wasn’t connected to the player 2 port on the NES! As you might expect, after connecting this wire to the port and re-assembling the NES the Zapper gun worked!

Now I can relive my childhood nostalgia and contribute to virtual duck murder unabated!



Using Photoshop and Netflix on Ubuntu 13.04 *Updated*

Update: The following also works on Ubuntu 14.04.

My favourite operating system to use is Ubuntu. Like most people, I grew up using Windows, but seven years ago I started experimenting with Linux while trying to build a webserver. I had an old machine that could manage Debian 3.0 or 3.1 (can’t remember which) and set up Apache on it without the ability to use a GUI. Since building the webserver, I have been moving closer and closer to independence from Windows.

My laptop and desktop computers currently dual boot Windows 7 and Ubuntu 13.04, but I only really logged in to Windows to use Photoshop or to watch Netflix. Recently, thanks to the wonderful work of some excellent people in the Linux community, it is possible to  completely switch from Windows to Linux without sacrificing the use of Photoshop or Netflix!

Netflix on Ubuntu/Debian

This is actually very easy to do so I won’t elaborate much here. Basically you can just go here and follow the instructions. TL;DR installation amounts to:

sudo apt-add-repository ppa:ehoover/compholio
sudo apt-get update
sudo apt-get install netflix-desktop

and then you are done! Wooo!

Photoshop CS6

There are a number of resources online that explain how to install Photoshop in Linux, but my experience trying to install a legitimate copy of CS6 was difficult at best. After a few hours of fiddling, I managed to get it to work. Hopefully my guide will save some time for someone else. Before we start keep in mind that I have only tried this on Ubuntu 13.04 and I will be assuming that you have not installed wine before. I am also assuming that all commands are executed in your home directory.

Installing Wine

First we must install wine. You can do this on the command line via the commands:

sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update
sudo apt-get install wine1.5

This should also install a little handy tool called winetricks. You can double check with a:

sudo apt-get install winetricks

Configuring Wine

Next we need to configure wine to emulate Windows XP in 32 bit mode. We do this by running the command:

WINEARCH=win32 WINEPREFIX=~/.wine winecfg

and then change the windows version to “Windows XP”.

Change the windows version to "Windows XP".Make sure that the dnsapi library is set to "Builtin then Native".


Next we must use winetricks to install many different libraries and programs required to run Photoshop. Use the following commands on the command line:

winetricks -q amstream cc580 directx9 d3dx11_42 d3dx9_43 d3dx11_43 dinput dinput8 gecko vcrun2005 vcrun2008 vcrun2010 xact
winetricks -q atmlib gdiplus ie6 vcrun2005sp1 vcrun2008 fontsmooth-rgb corefonts msxml3 msxml6 winhttp wininet

odbc32.dll and odbcint.dll

Next we need to place 2 .dll files in the system32 folder of our wine installation. The .dll files can be downloaded here. Assuming we are in the home directory, we use the following two commands:

cp ~/odbc32.dll ~/.wine/drive_c/windows/system32/
cp ~/odbcint.dll ~/.wine/drive_c/windows/system32/


After copying the .dll files, the next thing to do is the make sure that the correct version of dnsapi.dll is used. To do this we must once again enter the wine config:


Navigate to the “Libraries” tab and look for “*dnsapi”  in the list of libraries. Once found, click edit and then make sure to set the “Builtin then Native” radio button.

Installing Photoshop

Finally, we can now install Photoshop. Insert your CD and then execute the “Set-up.exe” file on the CD. Follow along the instructions on the installer window. Once you get to the installing process, it should fail, but have no fear, because for some strange reason, Photoshop will still install in the background in spite of the error window. Do not close the error window until you are absolutely sure Photoshop has had enough time to install (for me this took almost 10 minutes). You have not installed Photoshop on Ubuntu!

This is the first post

This is the first post for my blog. I will update this later…

And I am now. This blog space will be used for sharing photos, code snippets, and whatever else I feel would be useful to share. For a start, here’s a useful little python script for resizing a directory of images:

def resizeAll(files,maxDim):
    from wand import image
    if isinstance(files,str): files=[files]
    for f in files:
        print "Resizing " + f

The script requires a list of files and the size of the largest dimension to resize the images to. It preserves aspect ratio and saves the resized images to the same directory as the original image was in. Resized images have the same name plus a “_resized” added to the name. This script of course requires the ImageMagick library and the wand python library.