Tuesday, May 21, 2013
Text Size

How does the NES Gun work?

nes_gunLots of home video games and arcade games use some sort of gun as an input device. You point the gun at the screen and pull the trigger, and if you hit the target on the screen, the target explodes.

To create this effect, the gun contains a photodiode (or a phototransistor) in the barrel. The photodiode is able to sense light coming from the screen. The gun also contains a trigger switch. The output of the photodiode and the switch are fed to the computer controlling the game.

At the same time, the computer is getting signals from the screen driver electronics. If you have read How Television Works, you know about the horizontal retrace and vertical retrace signals used to align the picture on the screen. The screen driver electronics send pulses to the computer at the start of the horizontal and vertical retrace signals, so the computer knows where on the screen the electron beam is located during each frame.

The computer normally uses one of two different techniques to figure out whether or not the gun is pointed at the target when the user pulls the trigger:

  • The computer blanks the screen and then paints just the target object white. If the photodiode senses darkness after one vertical retrace signal and then light after the next, the computer assumes that the gun is pointed at the target and scores a hit.
  • The computer blanks the screen and then paints the entire screen white. It takes time for the electron beam to trace the entire screen while painting it white. By comparing the signal coming from the photodiode with the horizontal and vertical retrace signals, the computer can detect where the electron beam is on the screen when the photodiode first senses its light. The computer counts the number of microseconds that pass between the time the horizontal and vertical retrace signals start and the time the photodiode first senses light. The number of microseconds tells the computer exactly where on the screen the gun is pointing. If the calculated position and the position of the target match, the computer scores a hit.

These links will help you learn more:


AddThis

Comic Strips

21.01.11 PhD Comic - Intro

Piled Higher and Deeper" (PhD) is the comic strip about life (or the lack thereof) in academia. Jorge Cham got his PhD in Mechanical Engineering at Stanford University.

Check back every few weeks for new comic! :)

22.08.11 PhD - Comic 38

phd042707s

Provided By: "Piled Higher and Deeper" by Jorge Cham www.phdcomics.com

30.08.11 PhD - Comic 39

phd043007s

Provided By: "Piled Higher and Deeper" by Jorge Cham www.phdcomics.com

07.09.11 PhD - Comic 40

phd050207s

Provided By: "Piled Higher and Deeper" by Jorge Cham www.phdcomics.com

26.09.11 PhD - Comic 41

phd050407s

Provided By: "Piled Higher and Deeper" by Jorge Cham www.phdcomics.com

05.10.11 PhD - Comic 42

phd050707s

Provided By: "Piled Higher and Deeper" by Jorge Cham www.phdcomics.com

03.01.11 No Clue

"No Clue"

is by Maya KC and describes the life of a college student making her way through life.

Check back every few weeks for new comic! :)

09.03.11 No Clue 10

No_Clue_10b

14.03.11 No Clue 11

No_Clue_11

14.03.11 No Clue 12

No_Clue_12

25.04.11 No Clue 13

No_Clue_13

05.05.11 No Clue 14

No_Clue_14

04.01.11 XKCD - Intro

Check back every few weeks for new comic! :)

XKCD (xkcd.com) by Randall Munroe, a CNU graduate with a degree in physics

22.08.11 XKCD - Comic 22

mac_pc

XKCD (xkcd.com) by Randall Munroe, a CNU graduate with a degree in physics

30.08.11 XKCD - Comic 23

lanes

XKCD (xkcd.com) by Randall Munroe, a CNU graduate with a degree in physics

07.09.11 XKCD - Comic 24

fight_club

XKCD (xkcd.com) by Randall Munroe, a CNU graduate with a degree in physics

26.09.11 XKCD - Comic 25

cell_phones

XKCD (xkcd.com) by Randall Munroe, a CNU graduate with a degree in physics

05.10.11 XKCD - Comic 26

arrow

XKCD (xkcd.com) by Randall Munroe, a CNU graduate with a degree in physics

14.03.11 Joy of Tech Intro

The Joy of Tech looks at life with our little e-friends.

Check back every few months for new comics.

22.08.11 Joy of Tech 15

1562

30.08.11 Joy of Tech 16

1564

26.09.11 Joy of Tech 17

1565

05.10.11 Joy of Tech 18

1567