SaturnDave (Sega Saturn, SHIRO!)

‘DEVASTAR’ Open Source IR Light Gun Project

A new Open Source IR Light Gun project by Greg Gallardo called Devastar, is in the works and looks to support numerous consoles. While the project apparently got it’s start back in 2019 and has remained pretty quiet despite steady progress, it’s now caught our attention as just a few months ago, Greg decided to add Saturn support by building a simple circuit that replicates the timings for the SEGA Stunner/Virtua Gun…

Here is the official GitHub Page, and here’s Greg’s Blog with updates on this and various projects.

Devastar started as an attempt to create a flat-screen light-gun that would work with a Sega Menacer game that Greg was writing, but it soon expanded into an ambitious open-source project with potential to support several other consoles and games.

The project is still quite early in development, and Greg believes the latency and hardware may be improved by moving to a different microcontroller. Either way, many changes are expected before the project gets an official release, however, it definitely shows a lot of promise!

Here are examples of receivers in the works for a various consoles…

Much like the Sinden Light Gun, the Devastar appears to use 4 coordinates in order to determine the location of the light gun regardless of any change in position. However, where the Sinden basically uses a camera focusing on a border (essentially 4 corners), the Devastar implements 4 individual IR emitters placed on each corner of the display.


SHIRO! caught up with Greg to find out more about how the project came together and how it all works…

DEVELOPER INTERVIEW:

SHIRO!: So Greg, what’s the background behind this project? How did it come about?

GREG: Devstar is just a project I’m doing for fun, really. I’ve been working with multiple-camera systems at my day job, and I got the idea to make a light gun back in 2019 while looking for a way to automatically get the positions of each camera relative to each other. I made a program that used ArUco markers to calibrate the camera system.

After getting that working I realized it’d be pretty easy to position a camera in space relative to a set of known points. I never got around to it, because I was working crazy hours.

After the pandemic hit, work slowed and I stayed home a lot. I got interested in retro-consoles again. I was a big Sega fan in the 1990s. So I bought a Sega Genesis off eBay and started learning to program it with SGDK. I noticed it had built in light-gun support, so I decided to write a game for the Menacer. It’s far from finished because I’ve been busy, but here’s a look:

Earlier this year, I decided to try to make an LCD light gun to use with a Genesis emulator for development. I wasn’t going to use IR LEDs. I was going to have an emulator running in 4:3 mode in the center of the display and use ArUco markers to define the 4 points for camera positioning.

I changed my mind after reading more about how light guns worked, I realized it wouldn’t be that hard to make something work with a real console. Since I don’t (yet) know how to overlay markers or lines onto a composite signal, IR LEDS seemed like the fastest way to get started.

SHIRO!: Just from watching your videos, it seems that your setup uses 4 IR emitters mounted to the corners of your display, which would account for where you are positioned at all times. Is this correct?

GREG: You’re right. It’s 4 IR emitters. I’m using Perspective-n-Point to get the camera
pose relative to the IR emitters, though, I’m currently looking into other algorithms to see how they compare speed-wise.

SHIRO!: Is this current setup just subject to change, and do you plan on streamlining this as a single device for multiple consoles?

GREG: I consider what I have right now to be a starting point. I’ve just been using hardware I already had on hand. Partially due to supply chain constraints, but mostly because I just wanted to see if I could make something work before I start worrying about an ‘optimal’ implementation.

SHIRO!: Do you have this setup working on real and unmodified console hardware? If so, how is that possible? Would you not have to rewrite the code so that it uses coordinates instead (basically patching the game image)?

GREG: This is indeed working on real hardware. The YouTube is video shown is of a real SEGA Saturn connected to an LCD monitor with unmodified versions of Virtua Cop and House of the Dead. The code doesn’t have to be rewritten because I’m using a microcontroller to simulate the timing of a real Saturn STUNNER. As far as the game is concerned, it thinks a real STUNNER is connected to my Saturn… Here’s a picture of the Saturn Stunner circuit connected to my Saturn:

SHIRO!: Can you go into a bit more detail on how that microcontroller works?

GREG: I plan on making a video about it, but here’s a somewhat brief explanation of how it all works.

Basically, light guns like the Virtua Gun/Stunner and Menacer don’t actually send X/Y locations to the console. They detect the electron beam of a CRT and pull a pin low on the console. The electron beam moves top-to-bottom, left-to-right on the screen. The console counts the time it took for the pin to be pulled low for a given frame. This time is converted to an X/Y location by the console/game. This is oversimplified, but it’s all about timing. If I simulate the timing correctly [using a simple circuit], I can fake a Stunner or Menacer.

If memory serves, the Namco GunCon is different. It actually sends X/Y locations to the PSX. I have one, but haven’t gotten around to making a receiver for it. I prefer SEGA, so I’ll probably get a Dreamcast gun working before the PSX.

SHIRO!: In it’s current state, what does this setup consist of altogether?

GREG: Here’s a list of everything this setup currently entails:

  • Four 850nm IR LEDs are mounted at the corners of my LCD display.
    They don’t have to be at the corners, but that’s what I’m doing for now. (I think using a square could make things more efficient but haven’t tested this yet)
  • One NoIR (no-IR filter) Raspberry PI compatible camera with longpass IR filter is used to find the IR LEDs.
    The longpass IR filter simplifies the image processing needed.
  • I wrote a special code script with OpenCV on a Raspberry Pi 4.
    The code pulls camera frames, does some minor image processing, finds the IR blobs, and calculates the position of the camera relative to the IR points. I use the camera axis and an rectangle defined by the IR points to determine an X,Y location
  • I send the X,Y location and button states to an Arduino Leonardo over Serial or Bluetooth.
    The Arduino is connected to a LM1881 sync separator chip that figures when the vertical and horizontal syncs occur. I split the composite signal from the console to the HDMI adapter and to the LM1881. The Arduino uses interrupts to detect the vertical and horizontal syncs. It simulates the electron beam timing by counting out the number of horizontal lines drawn for the Y position and waiting a certain amount of time to set the X location. After the wait, it pulses the console pin low.
  • The Saturn console detects the pin pulse and computes the X/Y location as if a real light gun was used.

SHIRO!: So this is still very much in a WIP phase. Do you have any plans to consolidate this into something that either you or others could build and sell?

GREG: I don’t consider it “ready” yet. It works, but needs improvement. The latency isn’t great. I haven’t spent any time optimizing it, and I think I need to update my LM1881 circuit a bit to get cleaner VSYNC/HSYNC signals. I’m planning on upgrading the hardware I’m using. I think an ESP32 for the microcontroller and a faster camera and/or a DFRobot IR camera to replace my current NoIR camera.

I plan on making this fairly modular. So the camera could be an IR camera detecting IR LEDS, or a visible light camera looking for markers on-screen. The different cameras will work with different receivers. So far I have receivers for Sega Menacer, Sega Phaser, Atari XG-1, USB Mice, SNES SuperScope, and the Sega Stunner/VirtuaGun.

There’s an upper and lower component to the “gun”. The current body is pretty large, but I will be making smaller bodies and different handles.

I want to look into adding an optional recoil mechanism to it. Maybe an optional thumb controller.


To replicate the SEGA Stunner, specifically, Greg took some pictures and made a rough, partial schematic of the Sega Stunner circuit board while working on a receiver for Devastar. The Sega Stunner is a relatively simple light-gun circuit. The heavy lifting is done by a pair of ICs. The top of the board has a 74HC14N Hex inverting Schmitt trigger and a LM359N Op-AMP.

The bottom of the board has most of the other components.

He traced out the circuit around the 74HC14N because that’s the only part that was needed.

Here’s a video of Greg’s ‘fake stunner circuit’ working with a Japanese Saturn.

SATURN STUNNER CIRCUIT:

This video demonstrates a simple circuit (via Arduino Leonardo) that replicates the Sega Stunner/Virtua Gun. Since the Stunner has only one more button than the Sega ‘Light Phaser’ and grounds DATA0 and DATA1 to identify itself to the Sega Saturn as a Stunner, it’s a fairly simple circuit to replicate. The plan here is to integrate the circuit with the IR light gun, using timings provided by the calibration screen built into Virtua Cop.

IR CAMERA:

This video demonstrates the circuit and test code built months prior, working with an IR camera. House of the Dead and Virtua Cop have built in calibration routines that allow the firing of test shots, whose timings can be used to tune the IR camera’s calibration.

Devastar: IR Light Gun – Progress Updates Video Playlist


A massive Saturn fan since Christmas ’96, Dave is enthusiastic about growing the community and spreading Saturn love and knowledge to fans old and new. Co-founding the SEGA SATURN, SHIRO! podcast back in 2017 and creating the SHIRO! SHOW in 2020, he seeks to create interesting and engaging Saturn-related content for the community. Dave’s interests circle around game preservation, and he is a huge fan of game magazines and developer interviews.

Liked it? Take a second to support SaturnDave (Sega Saturn, SHIRO!) on Patreon!