Yes, You Can Use Lightguns on LCDs-- Sometimes
Old-school cathode ray tube TVs have become de rigeur in the retro scene as the true way to experience retro games “the way they were designed”. But there’s a lot of benefits to modern TVs; they’re lighter, usually bigger, and there are a lot of upscalers that give really good pictures. But then you give up peripherals like light guns, that are permanently tied to the television’s timing. Or are they?
The humble lightgun
For the purposes of this blog post, let’s set out some ground rules.
- When I say “lightgun”, I mean the guns that were shipped for the Famicom and the Nintendo Entertainment System. Different guns worked different ways.
- When I say “LCDs”, I pretty much mean all modern television screens. In fact, even the short-lived generation of HD widescreen CRT TVs share this problem.
But what problem? Well, I’m getting ahead of myself.
The Zapper was the western packaging of the Famicom Gun. Either way they work the same inside, just one looks like a raygun and is fondly remembered, and one looks like a realistic gun and doesn’t seem to have been nearly as popular. Make your own cultural assumptions.
This is one case where Nintendo drew on their history. They had actually been making light gun games since 1973’s Laser Clay Shooting System and toys before that. The exact details of each system they’ve used varied a bit, but the basic concept doesn’t differ too much.
The Zapper gun consists of a trigger and a photodiode, basically a simple light sensor. When the trigger is pulled (on the NES and Famicom, this is a falling edge from 5V to 0V), the game reads the signals from the photodiode to determine what happened. (Interestingly, on the NES and Famicom, the Zapper trigger and photodiode have their own pins, and aren’t read serially like the controller is)
The thing to stress is, the photodiode is literally one bit of information. All the game can figure out from that is whether there’s light going into it at any particular time.
Let’s use a concrete example– Hogan’s Alley.
Game mode “A” is a simple shooting gallery. You are given three figures, and have to make a split-second decision which of the three you should shoot.
So there’s your problem. The photodiode gives you one bit of information; that’s not nearly enough to distinguish the three characters. After all, they all use similarly colored pixels, not that the photodiode even has color information.
Well, you might already know the answer. The photodiode only provides one bit… at a time. By setting a clever number of frames, you can extract more information.
First, a black frame. This helps prevent cheating; at this point, it knows that your gun is pointed at a TV which is turned off. Then, a succession of frames that are mostly black, with white targets. Each one corresponds to one of the figures on screen. Since this all happened so fast, your gun is still pointing at the same place it was when you pulled the trigger.
Why does it only check two? It thinks it figured out who I shot. And there’s the problem; I was pointing the gun at an LCD TV; a small widescreen monitor I keep next to my desktop alongside a CRT as a test setup.
The problem is, a CRT TV draws frames in real time. The Nintendo knows that when it draws a frame, that frame drawing is corresponding with the moving electron beam of the television in real time. In fact, NESdev claims that the photodiodes use have their signal die in as short as 10 scanlines, so the game needs to check more frequently than the 60Hz clock that usually governs an NES game.
What the Famicom doesn’t expect is that the screen could be late.
Resolutions and frequencies
Pretty much all analog video signals, RGB or otherwise, are imitating the raster of a television. That is to say, it assumes there is only a dot being drawn on screen at a time, and it provides signals that are timed as that dot moves across the screen.
This works perfectly fine for a CRT television that’s tuned to expect a line frequency of 15kHz and field rate of 60Hz, like most standard-definition televisions in Japan or here in North America. However, this assumption breaks down very fast. Those 60Hz monitors almost certainly can’t even handle PAL video, with the same line frequency. For example, here’s a 60Hz Monitor /// failing to handle a 50Hz signal coming out of an SC-3000.
The same issue applies to VGA CRTs and HD CRT televisions, whose native line frequencies are much higher. Non-CRT televisions don’t even draw the screen in the same way! And oftentimes even a digital input signal won’t be at the same resolution as the panel in the screen.
So every single modern TV has a scaler inside. These can be particularly bad at handling 240p, but pretty much every signal that comes into a television will need some processing to match how it works inside.
And that’s why your lightgun won’t work on an LCD television. By the time the screen shows the white frames, the game already thinks you lost and went out to do something else. This is true even the Framemeister scaler I’m using here; as its very name implies, it’s a frame-buffer, so before even the TV has seen the signal it’s a frame behind.
Note that even “Game Modes” can’t get the lag down to the zero it needs to be here. The signal just isn’t suitable for your television. It must be processed.
So… that’s it?
Obviously not, didn’t you read the title of the post? You can still play Wild Gunman! The GAME A mode, anyways. It turns out this doesn’t actually go through the dance above; there’s only one thing on screen. It just checks your timing. But be warned; you can still lose!
But what if you want to play a better different lightgun game? Even the other game modes on Wild Gunman won’t work like this.
Here’s the clever thing. While your television is definitely displaying the screen late, if it’s a decent scaler, the lag is going to be constant. If it’s constant, it can be predicted. If it can be predicted, the game can be reprogrammed to wait that long.
Now, you might say, that seems like a lot of work! And it is. But thankfully, I don’t have to do it– the folks at LCDMOD already have. Unfortunately, this is a pretty considerable mod, so patches are mostly limited to the earlier titles.
Tools of the trade
It’s worth noting that Nintendo, which had been making light toys for awhile, was already wise to ways people cheated. One way they got around that was to use a photodiode that was most sensitive to the 15kHz light of a CRT television electron beam. That way, in addition to the black frame check above, it wouldn’t work to just point the gun at a lightbulb or other light source.
Of course, an LCD TV doesn’t put off a 15kHz light. Thankfully, the solution to this is pretty simple. Just use a third-party light gun– Duck Hunt is legendary enough that they still make these things. You don’t need to buy Hyperkin’s model; I used a “Tomee” branded one and it also had a compatible photodiode. In this case being cheap is better.
Note that I’m not sure if these modern guns are made for the Famicom, where, as I noted, the light gun seems to have been a lot less popular. (Gumshoe, a first-party Nintendo light-gun game, was only released in the west; a rare case of Nintendo ignoring its own home market.) Personally, I’m using an adapter from MiSTer Addons; make sure to use the controller 2 position. (Also not sponsored)
And, well, that’s it. Well, you need a way to play modded ROMs on your console, too, and dump the original ROMs so you can patch them. But I’m assuming most people who read this blog can figure that out?
It just works?
Yep! At least it did for me.
Note that generally, the title screens of the supported games have been modded to add a system to detect when the gun is pressed, and figure out the particular lag time for your particular TV; after all, this can vary considerably from television to television. (The 0.0 earlier was from when I ran it on a CRT)
All of these screenshots were taken from my composite-modded (and stereo-modded) Famicom connected through the RGB Blaster through the Framemeister, but my actual goal was to use the RetroUSB AVS, which forms part of my living room setup. Its slightly-different framerate didn’t matter at all, thankfully.
Can Sega do what Nintendoes?
Now, you might wonder, does this apply to the Sega Light Phaser as well? After all, the Master System had a great many games using this light gun, generally reported to be more advanced and more accurate than the Nintendo counterpart.
Well, uh, I don’t have a Light Phaser. But I’m pretty sure that it won’t work. Now, the light phaser is a photodiode and a trigger, much like the NES Zapper, Famicom Gun, or its clones. The big difference is the sensitivity of the photodiode– essentially, while the Zapper’s takes 10-25 scanlines to go from “on” to “off” after it stops seeing light, the Light Phaser is fast enough that, from the perspective of the 3.5MHz Z80, more or less instant. If the photodiode is on, the Phaser sees light. If it’s not, then it doesn’t.
Here’s Gangster Town. Now as I said, I don’t have a light phaser. But here’s something interesting about the light phaser: it doesn’t use extra pins. The trigger of the light phaser is also button 1 on the joypad. So even though I can’t successfully shoot something, I can see what the game does when it tries to detect if I shot something.
The game starts with a feature that I have to assume Sega added mostly to show off how accurate the phaser is; you write in your name by using the phaser to shoot the letters. This would take a lot of frames to check every single letter if this worked the same way as the Zapper.
The Light Phaser doesn’t draw any boxes; it just turns the screen entirely white for several frames. This is made possible by two things. First, that faster photodiode. But also, the Sega Master System has some features the NES doesn’t: horizontal and vertical counters.
A Master System game can read two IO registers to determine exactly what horizontal pixel (HCounter) and what scanline (VCounter) is being drawn. Even better, because horizontal beam timing is hard (ask any Atari 2600 programmer), it latches the HCounter. While the photodiode is active, the HCounter won’t change, so it will appear “stuck” at the value of the first horizontal position where the gun saw the screen. Vertical timing is more forgiving, so no latch is needed.
Of course, the gun will be pointing (the photodiode will “see”) an area on the screen larger than one pixel, so some processing of these signals is necessary; the Sega official documentation recommends doing some averaging across frames to get a good signal. But in theory this is much more accurate than the Zapper, and doesn’t require the white boxes.
But look at what we’ve done here: the Master System is literally reading in-line with the electron beam. This means that for this to work, you really do need an electron beam that moves in sync with the VDP. An LCD just won’t give you that moving dot, no matter how much delay you add.
While you could fall back to the white boxes with delays approach if you were writing Master System Light Phaser homebrew for HDTVs, it would be harder to implement than the NES, because it would require much stricter timing. After all, the photodiode is going to go out much sooner; the slower photodiode on the Zapper gives some leeway. I doubt anyone will bother. The town can keep its gangsters one more day.
Note that there are more elaborate ways to play lightgun games on modern TVs, including one, the LightGunVerter, which promises Master System support, and uses a Wiimote as a gun and internally fakes the signal timing to match what the console might expect. This device is no longer manufactured, but it is an open source project, so perhaps I might take a future look at it.
A series on: Lightguns!
Focusing on the classic Duck Hunt and other Nintendo titles, with a look at how to play them without the original CRT hardware.
- Yes, You Can Use Lightguns on LCDs-- Sometimes — If your 8-bit lightgun nostalgia is only for the Master System, feel free to sit this one out.
- Yes, You Can Play Duck Hunt Without a Television (but I can't) — For those willing to take the definition of 'original hardware' way too far. And can help me fix a 1970's children's toy.