Light gun input?

Topics regarding the Uzebox hardware/AVCore/BaseBoard (i.e: PCB, resistors, connectors, part list, schematics, hardware issues, etc.) should go here.
Post Reply
havok1919
Posts: 474
Joined: Thu Aug 28, 2008 9:44 pm
Location: Vancouver, WA
Contact:

Light gun input?

Post by havok1919 » Fri Aug 29, 2008 9:31 am

Yeah, more random suggestions. ;)

If you have a spare counter that can be clocked at something close to the pixel clock (even a half or a quarter the pixel clock rate) we could connect a light gun (or two) to the hardwired external IRQ inputs. (INT0/1)

Start the counter at the beginning of each scan line. If an interrupt is detected (falling edge), the gun is pointing at the (CRT) screen and sensed a 'hit'. Stop the counter-- that's your 'X' position, the line count at the time is your 'Y' position. You then need to apply a calibration procedure (aim at the center of the screen, etc) to compensate for the (relatively) slow turn-on time for the photodiode in the gun and effects of the lense and stuff. It works though...

After the first interrupt I just mask off the interrupt until the start of VSYNC for the next frame (otherwise you can get multiple interrupts because of the focal distance of the gun). Not sure if that'd mess up your on the fly pixel shifting too much though! (might tear the line? could be OK in some applications depending on the background I suppose) I really need to read the kernal and see how you're generating sync. ;)

-Clay

User avatar
uze6666
Site Admin
Posts: 4483
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Light gun input?

Post by uze6666 » Fri Aug 29, 2008 9:30 pm

Hi Clay, thats a neat idea.

Unless there's a hardware way to stop a timer on interrupt, its impossible to detect X position during rendering without screwing up the picture. That's mainly because 100% of cycles are used during rendering scanlines and the unpredictability of the interrupts latency. However, if I'm not mistaken, the Zapper would blank the screen for a single frame, overlaying white squares atop of targets for the sensor to pick up. IF interrupt only happens during that frame, that's not too bad. All timers are already taken, though timer0 could be used since it runs at 14.3Mhz to clock the AD725. Having NES connectors is a good thing since you can plug in all the stuff ever made for them. I'll add the idea to the incubator for others to tinker.

Sync code is all asm and pretty sensitive. I always wanted to go back and make it better, but there was always more interesting stuff to do. :mrgreen:

Cheers,

Uze

havok1919
Posts: 474
Joined: Thu Aug 28, 2008 9:44 pm
Location: Vancouver, WA
Contact:

Re: Light gun input?

Post by havok1919 » Fri Aug 29, 2008 10:27 pm

Coming from the "arcade" side of things I was thinking more of a Happ-style optical gun (about $50 on sale), but you're right, the Zapper would probably be a whole lot cheaper for most people. The upside on the Happ guns is that they're sensitive, so you don't have to do the "white screen flash" (or white-up on the targets) for a frame.

If timer0 if just free running I suppose the sync code could save off a copy of the timer at the start of the line, then when a (gun) interrupt occurs capture the current timer count... A-B = offset into scanline. But yeah, that's still require the IRQ to fire-mid scanline which would hose your video.

Maybe there's a way to do it using one of the input captures? I seem to recall that those can stop a counter on an edge?

OTOH, if you *did* just push white for one frame, only when the trigger on the gun is detected... You could just latch 0xff out to the video outputs and poll during the horizontal scanline paint time (since you don't need to fetch/render tiles). I bet that'd work! (That's the 'full screen flash' you see on older gun games like Lethal Enforcers, etc.)

-Clay

User avatar
Janka
Posts: 213
Joined: Fri Sep 21, 2012 10:46 pm
Location: inside Out

Re: Light gun input?

Post by Janka » Mon Jan 14, 2013 11:29 am

chubskee wrote:ahm... Light guns were most widely used with early console gaming systems such as the NES Zapper light gun, Using this gun the player could play games where they were required to point the gun at the screen and shoot targets, such as ducks in the popular Duck Hunt game.
^_^
The above discussed light guns won't work with TFT screens as they have not a single moving pixel but steady light coming from them. As CRTs are dying out a proposed uzebox lightgun should depend on motion sensors like a wiimote.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest