Slashdot Mirror


How do TV-Based Video Game Guns Work?

mark juncosa asks: "It is a mystery to me how Nintendo's Duck Hunt gun works. I have thought about it for a long time and have not been able to come up with any kind of good solution." Come to think of it, I wouldn't mind knowing this one myself. On a guess, I'd say that the system is entirely active and all the work being done by the gun and the TV remaining the display device that it always has been. Am I close? Or completely off base?

21 comments

  1. Video Game Guns by Draco · · Score: 1

    It was explained to me like this:

    The stuff on the screen flash faster than the eye can pick up, and in a unique patern per section of a grid on a screen. When you pull the trigger, it registers the flash patern of the part of the screen that the gun is aimed at. The gun then sends the info about which section of the screen it "hit" back to the console system, which then reflects said "hit" on the screen.

    This explanation made sense to me... I'm sure there's a whitepaper somewhere explaining it much better than I can.

  2. TV game guns by Anonymous Coward · · Score: 0

    I asked myself(and a friend) the same question about how TV video game guns work.In short neither of us kow, but my suspicision after thinking about it was that perhaps there is some invisible or near invisible pattern os seris of patterns embedded in the images, which the gun can "see" and deduce its position from.

  3. Like a light pen, I believe by The+Famous+Brett+Wat · · Score: 2
    I'm not in a position to give an authoritative answer, since I've never fiddled with the electronics of such a device or seen a specification, but since nobody else seems to have replied yet, here's my two cents worth.

    Duck Hunt is actually one of the simpler variations on the theme. The arcade games (Virtua Cop, The Lost World, etc) have a more impressive system. In Duck Hunt, when you pull the trigger, the targets (ducks) are replaced with solid white squares and a black background. (This is assuming you mean the original Duck Hunt and not some more recent release of which I'm unaware.) The gun then acts as a light detector, and the game measures the light input on the gun at that instant and judges whether you hit or not. If the game is particularly clever, it will have a full frame of black before and/or after the frame with the white squares to measure the difference between the two. This reduces the chance of false triggering.

    The smarter guns are probably rather more sensitive and well focused. It's possible to detect which part of the screen the gun is pointing at by causing the gun to trigger a latch on a raster beam counter when it reaches a certain light threshold. At the end of frame, read the value out of the raster beam counter register, and that provides your gun coordinates. If the gun is not pointing at the screen, then the register will not have latched, and the value will be some unreasonably high value. Alternatively, if the gun is pointing at some bright object other than the screen, then the latch will trigger immediately, and you will get a zero result in your register.

    This second "precise" mode means that you must output a minimum level of light at all points on your screen that you wish to be able to target. If the light output at any point on the screen falls below your trigger threshold, then the register will not be latched when the gun is pointing at that part of the screen, and it will look as though the gun is not pointing at the screen at all.

    I suppose I should take a little side-track into television theory here, just in case. Your screen is painted by an electron beam in a left to right and top to bottom manner, like the way English text is written. When the electron beam hits the phosphorous coating inside the glass, the phosphorous glows momentarily, emitting a characteristic spectrum of light (primarily red, green, or blue in the case of a colour monitor). This glow is actually quite brief, and if you saw the light output level of any particular point on the screen expressed as a graph, you'd wonder why the screen doesn't look like it's flashing. A trick of the eye and mind, known as Persistence of Vision, causes the image to look solid. In fact it is not solid, but flashing rapidly and unevenly, and this is what allows a light-sensor to be used to detect your aim. Other display technologies, such as LCD displays, may not be amenable to this kind of technique, depending on whether they use a measurable form of display refreshing.

    As a side note, the late lamented Amiga actually had the required hardware to support this behaviour for the purposes of using a light pen, so I'm not making this up entirely. The Amiga also had the necessary raster beam counter register and latching facility, of course, although it only resolved to the equivalent of "lo-res" pixels. I never saw an actual device that utilised this hardware, unfortunately.

    --
    proof, n. A demonstration that a conclusion is implied by certain premises and axioms.
    1. Re:Like a light pen, I believe by Oarsman · · Score: 1

      The Commodore 64 had a light pen too and I used several programs that used it. Primarily cad software, but also had some games for the kids that used it too.

  4. Not quite faster than the eye by stile · · Score: 2

    Well, first of all, you can see, if you shoot the gun, that the display flashes white squares where possible targets are. I haven't played for ages, maybe I should break out my nintendo. Now, the problem of detecting a hit is simple, based on the white-square-flash. It's a matter of contrasting colors.
    But that brings up a good point. I was thinking perhaps that the color of light might be used to detect which out of several possible targets was hit. But you have to think about this, they had to make the nintendo/gun to work on the widest range of technologies possible. I don't think they would have gone with the raster-timing method, for the simple reason of LCD screens. I don't know if lcd screens were OUT then, but they had to be thinking about possible technologies for which this wouldn't work.
    That brings up another point: You can easily change the colors on your television set. The set can be black/white or color, and especially if it's color, you could make that nice pearly "white" show up as greenish, bluish, or reddish. So it has to be done by contrasting colors.
    Ah, idea just occurred. You pull the trigger, the game flashes black, whites out _ONE_ location of an object, blacks that, lights the second, blacks that, etc. All the while reading input from the gun. If the gun can detect simple contrasting colors, this'll work. Furthermore, the chances of shooting at a light and hitting it at the right instant (think 60 hz bulbs, or different, people) makes it unlikely to register a hit. And if it does? So what. Easy win. D'oh. Play fair, dorks :)

    1. Re:Not quite faster than the eye by stile · · Score: 1

      That's a good point. Perhaps we should look at hogan's alley, and other shooting games, see if they do the same. One thing though.
      Shooting away from the screen is how you select the game, and shooting the screen is how you start it. How's it going to tell the difference? Now, my guess has to be that it just gets a brightish color. Someone should try with weird colorization on their TV, see what the game does. Furthermore, think from a design point of view, specifically from the view of "What can the user do to screw this up?" Once it's calibrated, they could easily just change the colors. Especially if it had to be a different color for their favorite TV show, but they decided that reddish brown hills didn't look good for clay pigeon shooting. So, though I had thought briefly of the fact that it could calibrate, I think it doesn't.

      BTW, note that the gun itself has a little lens in it. I think it looks at a VERY narrow part of the screen in doing its calculations.

    2. Re:Not quite faster than the eye by Anonymous Coward · · Score: 0

      Actulay the whole pointing at a light works. When I was younger I wondered how they worked and what could fool them. Incandescants don't work because they don't flicker because they don't cool down (dim) enough per cycle... Florescants are the trick... And yes like most cheats this grew lame quickly and I went back to watching that anoying dog laugh at me on occasion

    3. Re:Not quite faster than the eye by Mr2001 · · Score: 1

      The Duck Hunt system is fairly different from others.. for example, with Sega's Menacer gun or many arcade guns, there's a cursor on screen that constantly shows where you're aiming, so the gun has to be able to get a reading all the time without a flashing screen.

      --
      Visual IRC: Fast. Powerful. Free.
    4. Re:Not quite faster than the eye by Anonymous Coward · · Score: 0

      If you've ever played Duck Hunt, you'll notice that you need to shoot the screen to start the game. The screen flashes entirely white when you shoot it here. It's possible that this is used to calibrate the gun to your TV's color. Try aiming at the light bulb when you start the game, and you may have better luck (you can't just shoot anything - it needs to be at least close to white, or the game won't start).

    5. Re:Not quite faster than the eye by stile · · Score: 1

      Alright, I was attempting to cover both bases by saying that either it won't work on lights, or it would but it'd be boring. That's interesting that it CAN be fooled like that.

  5. like this? by Anonymous Coward · · Score: 0

    i'm pretty sure they work like this: you have a gun with a light detector behind a lens that is focused on (ideally) one pixel on the screen. when you pull the trigger the next frame to be shown by the console is a blank white one. the frame is drawn top left to bottom right and takes a well defined amount of time to complete, for each line, and for each frame. the console simply measures the time between the pixel the lens is focused on going from black to white (when the white frame is drawn). this can then be used to calculate where in the drawing process the screen was when the detector in the gun picked up the frame being drawn. e.g. if it takes 64us to draw a line and white is picked up by the gun after 160us then the tv was half way through drawing the third line down (2x64us + 32us). this is why the screen flashes white every time you pull the trigger! i know my timings may be a little off (not including blanking and flyback) but they should give you an idea..?

    1. Re:like this? by stile · · Score: 1

      No, I don't think that's how it works. Remember, Nintendo has to be able to make their product REALLY SUPER compatible with everything out there; you can't patch a cartridged game. I don't even think it has to do with rastering, because lcd's might be used, and quite definitely, EVERY different brand/make of TV has different synchronization rates (I think? I mean, this sounds quite logical to me.) Furthermore, tv sets can be different. I doubt it has to do with the rendering of pixels and the time it takes to get to a certain one.

    2. Re:like this? by IntlHarvester · · Score: 1


      Actually, the video game gun dates far further back than the Nintendo -- pong systems had them in the late 70s, so the technology used must be very simple.
      --

      --
      Business. Numbers. Money. People. Computer World.
    3. Re:like this? by Anonymous Coward · · Score: 0

      Ok, how many LCDs do you know were available at the time of dunk hunt? I HIGHLY doubt Nintendo had considered LCD displays for duck hunt. Why?

      1.) Who's going to hook up the nintendo to their "luggable" computer? (Remember, most of them were still super heavy, black & {orange, green, white} displays.

      2.) No one had a flat screen monitor/TV at home, so that's not really an option.

      It's probably more like a light pen, but due to the distance it's pixels have to be much larger, hence why the screen flashes to black & white squares. (Big honking pixels.)

    4. Re:like this? by inburito · · Score: 1
      Every different brand/make, as long as they are used for the same standard(pal/secam/ntsc) actually have exactly same synchronization rates. Only exceptions I'm aware of are the 100hz tv's, which tend to redraw their picture twice as many times per second as regular pal, and those new widescreen tv's(although these probably when used in the 'compatibility'-mode will have standard synchronization rates). For every computer monitor the synchronization rates do differ but even in that case you could probably somehow extract the information from the graphics card.

      Reason for this is the way video signals are encoded. There are synchronization signals inserted into the picture information to keep the picture from "running" - horizontal and vertical (line and frame). The hardware that generates the video signals has to insert the correct sync signals so that the device used to display the information can do it correctly. Now, when the tv-set starts to decode the signal sent to it it has to use this synchronization signals to lock on to the picture and it is restricted to the synchronization rates that it is provided with - which for obvious reasons have to be standardized (for a certain set of standardized synchronization rates you get a tv-standard, such as ntsc or pal - of course there is other stuff involved too).

      Several years ago, when amiga 500 was a new computer and C64's where still widely used, I recall reading from a computer hardware magazine instructions on how to make your own gun. It worked by tracking the electron beam and it did so very easily. I recall that it was for C64 and used very few lines of code to determine the position it was pointed at.

      If you start to think about nintendos. There have been guns from the very beginning of the original nintendo. When that thing came out about 99.999% of the tv's used were regular cathode ray tube tv's. Now the percentage of regular tv's may have shrinked to 99.9% but that is still certainly enough to keep the good old way of doing things still adequate. Most likely this feature is hardcoded into the actual console so that the game makers don't have to worry about different tv-standards. Console itself knows which standard it is displaying on and can read the correct values accordingly.

      Yes this thing doesn't work on lcd's or projectors or (maybe) on widescreens, but how big a percentage of the people using nintendos would actually use an lcd or projector to play their shoot them up games? Probably not big enough to worry about. Maybe someone has one of these and a nintendo with a gun at their disposal and could actually check whether or not it works. It'd also be interesting to know what'll happen if you point at a different tv-set than the one you're playing the game with. I don't have my playstation anymore(used to have a gun for that thing).

  6. Alright, I brought the dang thing out. by stile · · Score: 1

    Actually, it seems I already had my nintendo out to play dr. mario, you know, when you get nostalgic for the old 8bit days ;) So, I dug up my gun and gave it a try. I saw that yes, the white squares do flash. I tried fiddling with my controls to no avail, I can't confuse it. I guess my tv set's not fancy enough ;) And by the way, you CAN select which game you want with the first-player controller and your gun in the second controller slot. So it's not calibrating.
    I couldn't fool it with average incandescent lights (and by the way, I was wrong, incandescents are the ones that don't blink, fluorescents do, but I imagine it has to do with the color.)
    So, I set out to scientifically (?) test the theory that it flashes each target in succession. I figured that if I blinked fast enough, I could catch it when just one was lit and the other wasn't, and that would prove my theory that the target hit is decided by lighting each seperately. If I _COULDN'T_ see only one square, though, that wouldn't mean I was wrong, it would mean I hadn't proven the hypothesis.
    It took several tries, but I _DID_ manage to have my eyes open at one point just long enough to see only one square. Only once, mind you, but I think that that, coupled with the fact that this is the simplest and "most portable" solution, means I'm probably right. Ideas? How many of you are going to go try this now? ;)

  7. tracking the electron beam by inburito · · Score: 2
    I recall reading that all of the tv-based video game guns work essentially according to the same principles. You have a highly focused light detector attached to the end of the gun. It will track sudden changes in light intensity and report them back to the computer.

    In a normal tv-screen there is an electron beam sweeping the screen starting from the top left corner progressing to the right and after reaching the end of the line moving down to the next one. On a normal tv-screen this is done for every line on the screen exactly 50 times / second(60 if you live in us).

    Now, when the electron beam hits the phosphorous coating on the screen it flashes briefly. Having this done 50(60) times per second creates an illusion of a continuosly lighted surface.

    It is these brief flashes that your gun tracks and dutifully reports to the computer. Computer, responsible for drawing the picture, is always aware of the pixel it is currently drawing(at least most of the video game hardware is built with this feature) and can extract the location the electron beam is pointing when it receives a signal from the gun. And if you happen to be pressing the trigger then maybe something should happen at that location.

    This technology is rather limited though. For instance, it doesn't work on lcd's (maybe by varying the intensity of pixels thus simulating the effect of the electron beam lighting up individual pixels, don't know of anyone actually trying this though). I can also imagine this thing having a hard time with 100hz tv's that are getting more popular in europe. Then again, how many of us actually use a cheapo game console on a tv that doesn't comply to the normal requirements.

  8. Try a VCR by billh · · Score: 2

    For what is is worth, my brother and I used to cheat at Duck Hunt by taping the game, then hooking up another monitor and playing the tape back until we found where we had shot. Using freeze frame, you could then play the game on the original monitor and hit everytime.

    It has been a long time, but I seem to remember that when you shot, the screen would go black and the ducks would show up as white blocks. Anyone with a Nintendo, a VCR, and too much time on their hands could easily verify this...

    1. Re:Try a VCR by Anonymous Coward · · Score: 0

      ok ok.. i remember playing this game for hours or the crapiest TV i have ever seen in my life.. i still have it :) ever since i was a kid i remember those white blocks and i thought about that immediatly when i read this.. so as the person with a tv, vcr and too much time on his hands i went and recorded a game using my old nintendo i had to search for. ( i found my atari too! LOOK OUT PONG!) and yes there are the white blocks.. but also what i noticed is that the blocks are quite large.. and mad me wonder why i missed when i was a kid thinking hell that seems big enough.. was i retarted? heh.. just thought id be the only one to actually tape myself playing duck hunt when i could be doing something better like having a beer and watching cartoons :)

  9. Clever hardware watching the raster by Lazdark · · Score: 1
    Years ago I dissasembled a tandy colour computer game that had a light gun. I stole the routines that got the gun x,y and made my own game.

    I know I could get the gun x,y, but I had to flash the whole screen white, then call this code. There was also some variation between samples. (about 5 pixels in both axis)

    I think the code did some stuff with the vertical retrace flag. I also believe the code did the vertical by counting from the vertical retrace, and the hardware did the horizontal, maybe with a phased locked loop watching the raster. If I still had all that stuff, I'd get a hardware dude at work to analyse it with a cro etc.

    BTW It was a Sega 'light phaser' with some custom box the game company (diecom) made. A very cool looking gun!

  10. Comment removed by account_deleted · · Score: 2

    Comment removed based on user account deletion