Friday, August 30, 2013

How The NES Zapper Works



I have professed my undying love for the light gun peripheral elsewhere on this blog. To me, it remains one of the most natural and immersive ways to interact with a video game, despite its decline in popularity. Though nearly every game console from the mid 80s to the mid 90s had one, the NES Zapper is probably the one most gamers are familiar with.

Nintendo's involvement with light gun games actually predates the NES by over a decade. In 1973, Nintendo turned several old Japanese bowling alleys into light gun-based skeet shooting parlors.  A year later, Nintendo introduced its first arcade game, Wild Gunman. The purely electro-mechanical Wild Gunman used a couple of 16mm film projectors to show footage of various Old West bad guys ready to draw and fire on you, the player. Your goal was to wait until their eyes 'flashed', then draw your own pistol & shoot. If you were quick enough, "YOU WON" would be projected on the screen over a shot of the bad guy clutching his chest & crumpling, Sergio Leone-style, to the ground. 

The NES wasn't the first home console to sport a light gun, (that honor belongs to the Odyssey) but it was the first to couple one with complex games, and it has by far the largest library of supported titles. The Zapper is based on the Famicom's light gun, a very convincing-looking black revolver which was itself modeled after the one featured in Wild Gunman. Fearing a potential rise in cases of police-perforated eight-year-olds, Nintendo of America redesigned the Zapper to look more futuristic, and less lethal. The earliest Zappers have a dark gray body, light gray accents, and a red trigger, mimicking the NES' color scheme. Later models have a bright orange body, light gray accents and a black trigger, again in an attempt to make them look even less like real firearms. 


Opening up a Zapper reveals that there's not much to it. A small lens in the barrel focuses light from the TV screen onto a photodiode, a device which generates a small electrical current when exposed to light. An amplifier boosts the current and sends it to the NES console to be processed as input for the game. As simple as it is, the Zapper can't tell if the light it detected came from a TV screen or another source, like a light bulb, so it's up to the NES game to make that determination. The more well-written games use a multi-step process to determine which target on screen has been hit:

Here, we have two Duck Hunt ducks flying around:


When the Zapper's trigger is pulled, the NES blanks the entire screen for one frame of video, or roughly 1/30th of a second. This establishes a baseline that the NES uses to make sure the player's not just aiming the Zapper at a lamp. 


Next, the NES draws a white box around the first duck on the screen for one frame:


The first box is then removed and another one is drawn over the second duck:


Finally, the NES resumes drawing the game's normal graphics. If the Zapper picked up light from one box or the other, the NES registers a hit and the game murders the targeted duck accordingly.



This entire process takes a fraction of a second to complete, and is nearly imperceptible to the human eye. You can watch the whole process unfold in this slow-motion footage from Hogan's Alley:



When the trigger is pulled for the first time, the NES blanks the screen and puts a white box in place of the cop first, the professor second and the bad guy third. The NES registers a hit with the bad guy, so he is removes from play. When the trigger is pulled for the second time, only the cop and the professor are left as valid targets, and the NES replaces just those two characters with white boxes.

It's a simple and effective technique, but it's not fool-proof. The television has to be adjusted so that the image is not too bright or too dark, as either will screw up the baseline or keep the Zapper from picking any light up at all. The targets have to be large enough so their white box can be picked up by the Zapper, and the number of targets on screen are limited to no more than three or four to keep the TV screen from going black too long. The process is also extremely time-sensitive; if there's any significant delay between the time the NES sends the image to the television, and the time that image appears on-screen, the NES won't correctly register hits. This isn't a problem for old-school analog CRT televisions, as they respond pretty much instantaneously. However, digital HDTVs spend a lot of time (relatively speaking) converting the analog signal from the NES into a digital image, and then rendering it on screen, causing a phenomenon known as input lag. In some HDTVs, this lag can be as bad a 1/10th of a second, which is much longer than the 1/30th the NES is expecting to wait. As a result, Zapper games work only spottily with the handful of tube-based HDTVs in existence, and they won't work at all with LCDs, plasmas or projectors. All the more reason to hang on to your old Radiation King, in my opinion.




















1 comment:

  1. Yo man, I loved this post when it came out. Thought you might be interested in this related article on Unwinnable: http://www.unwinnable.com/2014/01/23/gamings-greatest-forgotten-technical-innovation/#.UuUJW7SIapo. Theirs doesn't feature the Radiation King, tho.

    ReplyDelete