Making Light gun for LCD TV

For hardware talk only (please avoid ROM dumper stuff)
User avatar
KanedaFr
Administrateur
Posts: 1116
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Making Light gun for LCD TV

Post by KanedaFr » Thu Jul 08, 2010 8:49 am

Hi,

From what I understood (thanks Eke for the docs), Justifier won't work on LCD TV because they don't "see" the lightbeam ...correct ?

My question is 'how could we fix that on the hardware way' (ie not patching the original ROM of a game) ?

Since light gun position is mainly related to int2 and HV counter, which is triggered by the HL, the goal is the change HL state at the right moment.
For this, I'll need to read the HVCounter, compare it to the wanted XY and change HL state when I want.

I wonder if this could be done adding a 'special' card on the CD port.
For this, it mean a program could run at the time of Lethal Enforcers, look at HVcounter (on HInt) and change HL state through DB9 cable itself.
I don't KNOW if hardware allow that, I'm only starting to work on this CD port :
I know a cart could access CD port...but not if the "CD cart" could work by itself, even on a limited way
I also know a CD cart could access the cart so perhaps a "CD cart" could launch the game cart and still run, reacting to HInt.
Unfortunaly, it will lock the CD port...and so now way to use a light gun on MegaCD game :(

I'm only looking this as a possible way to do that.
I know how to make a new lightgun (Wiimote power!) but not how to control the int2/HVCounter from 'elsewhere'.

If you have any other ideas, i'm here! ;)

EDIT : bad understanding of the int2/hvc/HL

Graz
Very interested
Posts: 81
Joined: Thu Aug 23, 2007 12:36 am
Location: Orlando, FL

Post by Graz » Thu Jul 08, 2010 11:39 am

Maybe you could intercept the video signal and use a sync separator to extract hsync and vsync. If you synchronize an internal counter to the TV's beam, you would know where the HV counter was. Then, when you get the trigger signal from the light gun, you would wait until the HV counter reaches the right position before asserting HL. The gadget would plug in to the controller port and to the video output.

User avatar
KanedaFr
Administrateur
Posts: 1116
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Thu Jul 08, 2010 12:06 pm

Graz wrote:Then, when you get the trigger signal from the light gun, you would wait until the HV counter reaches the right position before asserting HL.
I think it's the main idea...I don't see how it could be possible another way.
The main problem is how :)

Thanks for the input, it's another idea....


I also thought about a game genie clone with hardware dedicated to light gun (like Codemaster's JCart but for lightgun) linked to joy2 port.
so a mix between hardware and (patch) software solution....

User avatar
HardWareMan
Very interested
Posts: 710
Joined: Sat Dec 15, 2007 7:49 am
Location: Kazakhstan, Pavlodar

Post by HardWareMan » Thu Jul 08, 2010 12:28 pm

No. You both wrong. Lightgun works only with CRT (100Hz/120Hz TV's draws image at twice speed, LCD TV's draws all image at once, and those TV's use own image memory, so "input lag" is present) TV's. Becouse, CRT beam draw every frame from top-left corner to bottom-right corner. Ofcourse, old image get blanked before new trace done by beam. So, optical element just "see" this different of brightness. And change logical 0 (black) to logical 1 (white). And becouse raster deliver from VDP to TV line by line, VDP always known, where beam is. And it's own H/W counter stores correct X/Y value of beam position.

So, you must trigger "HL" in right raster line and right position in line. That's not difficult. Just as said Graz. But, how did you will know, where position on TV screen lightgun pointed? That's difficult. Becouse lightgun holds by man and not necessarily in front of screen. So, the whole problem is the development of tracking device, wich will be return correct X/Y coordinates of "beam" pointed from lightgun barrel to TV's srcreen (or whatever, you know, you can use screen of light projector for bigger picture size :3). And then, those coordinates easy to convert to right "HL" change timings.

I hope you are understand me, with my terrible english. :3
Last edited by HardWareMan on Thu Jul 08, 2010 12:42 pm, edited 1 time in total.

User avatar
TmEE co.(TM)
Very interested
Posts: 2316
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Thu Jul 08, 2010 12:39 pm

for LCD you'd need some 3 sensors that triangulate the position of your gun and to simulate the beams position.

I once experimented with lightguns on MD... I made a motion sensor from a clone NES zapper, lol
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

User avatar
KanedaFr
Administrateur
Posts: 1116
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Thu Jul 08, 2010 12:46 pm

HardWareMan wrote:No. You both wrong. Lightgun works only with CRT (non 100/120Hz!) TV's. Becouse, CRT beam draw every frame from top-left corner to bottom-right corner. Ofcourse, old image get blanked before new trace done by beam. So, optical element just "see" this different of brightness. And change logical 0 (black) to logical 1 (white). And becouse raster deliver from VDP to TV line by line, VDP always known, where beam is. And it's own H/W counter stores correct X/Y value of beam position.
err....it's why I want to make a lightgun not dependent on beam...
So, you must trigger "HL" in right raster line and right position in line. That's not difficult. Just as said Graz.
hoo...
About video signal, I'm lost :(
But, how did you will know, where position on TV screen lightgun pointed? That's difficult.
I think it's not difficult. I'm almost finish my experiment with a wiimote.
Let say I could define X/Y
My problem is really WHEN trigger HL...
You seem to say it would be possible using video signal...
I have to dig into it so....
projector for bigger picture size :3). And then, those coordinates easy to convert to right "HL" change timings.
Wow...so, it seems it's doable....

I hope you are understand me, with my terrible english. :3
Don't forget I'm french, so no problem with any kind of english LOL

User avatar
HardWareMan
Very interested
Posts: 710
Joined: Sat Dec 15, 2007 7:49 am
Location: Kazakhstan, Pavlodar

Post by HardWareMan » Thu Jul 08, 2010 1:05 pm

KanedaFr wrote:
But, how did you will know, where position on TV screen lightgun pointed? That's difficult.
I think it's not difficult. I'm almost finish my experiment with a wiimote.
Let say I could define X/Y
My problem is really WHEN trigger HL...
You seem to say it would be possible using video signal...
I have to dig into it so....
So, you want to use wiimote to get right X/Y coordinates on screen? This will work.
OK. Now, you must make device, wich will take those X/Y coordinates, HSync/VSync from MD (we have TTL signals in system: separate on slot B14 and B13 and as mixed from PAL/NTSC coder), count scanlines from VSync as Y coordinate and then calculate offset of changing "HL" in right video scanline as X coordinate.

And one more thing: in interleave mode there can be a problem.
KanedaFr wrote:
I hope you are understand me, with my terrible english. :3
Don't forget I'm french, so no problem with any kind of english LOL
I'll keep this in mind.

User avatar
KanedaFr
Administrateur
Posts: 1116
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Thu Jul 08, 2010 1:26 pm

HardWareMan wrote: So, you want to use wiimote to get right X/Y coordinates on screen? This will work.
Cool :D
OK. Now, you must make device, wich will take those X/Y coordinates, HSync/VSync from MD (we have TTL signals in system: separate on slot B14 and B13 and as mixed from PAL/NTSC coder), count scanlines from VSync as Y coordinate and then calculate offset of changing "HL" in right video scanline as X coordinate.
Ok, some question on this:
1/ I see how to get the Y, but what about the X ? you have to know how much 'time' is take to draw a pixel to calculte the time to get to the correct X ? This 'time' is different from NTSC and PAL, no ?
2/ if I borrow the vsync & hsync from the cart bus (which is cool since it will work on MCD too!) using an adapter, it won't alterate the signal ?
something like :
B14--------->B14 original card
|----zener-->my device
And one more thing: in interleave mode there can be a problem.
need to check if light gun games use interleave mode or not....
I don't think so, Eke doesn't talk about it on his doc

Eke
Very interested
Posts: 822
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Thu Jul 08, 2010 1:35 pm

Don't forget about EDCLK :wink:

We know that out of /HSYNC, it's exactly running at twice the pixel clock (in 40-cell mode at least) so I imagine you could use that to count the number of pixels once you are on the right line and /HSYNC is high again. With some adjustements (you have to account front porch + border area, all of this have been measured by Jorge Nuno on this forum), it could be used to trigger the /TH line on the I/O port at the right moment (forget about triggering IRQ or /HL, all of this is already handled by software & original hardware).

PS: there are only 2 games using interlaced mode on the Mega Drive, and none of them support the lightgun ; I think I verified that all lightgun games use 40-cell mode but don't quote me on that :oops:

Also, don't forget that most likely, original lightguns would see a number of lines around the aimed position, at least games do some averaging with the HCounte rvalue being read and expect the interrupt to be triggered on multiple successive lines to average Y position.

DOing this with hardware is neat but as last solution (the easiest one), since you have a Wii, I strongly suggest you try these games in Genesis Plus GX , lightgun emulation via wiimote should be quite accurate, it even ouputs the original non-interlaced video signal :wink:
Last edited by Eke on Thu Jul 08, 2010 1:53 pm, edited 1 time in total.

User avatar
KanedaFr
Administrateur
Posts: 1116
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Thu Jul 08, 2010 1:49 pm

Eke wrote: (forget about triggering IRQ or /HL, all of this is already handled by software & original hardware).
shhhhut, it's what i first wrote but it was a misundertstanding ;)
PS: there are only 2 games using interlaced mode on the Mega Drive, and none of them support the lightgun :wink:
so....no problem..at least on this point ;)
Also, don't forget that most likely, original lightguns would see a number of lines around the aimed position, at least games do some averaging with the HCounte rvalue being read and expect the interrupt to be triggered on multiple successive lines to average Y position.
yeah, I read about it on your menacer doc (not on justifier part)
so it's needed to trigger HL from Y-4 to Y+4 ?

User avatar
HardWareMan
Very interested
Posts: 710
Joined: Sat Dec 15, 2007 7:49 am
Location: Kazakhstan, Pavlodar

Post by HardWareMan » Thu Jul 08, 2010 1:52 pm

MD cartriges don't use B13 and B14 (not sure about cartriges with DSP chips). About 32x I don't know, but it's doesn't matter: B13 and B13 (wich is HSync and VSync) are TTL output from VDP. So, you can just connect input of TTL logic.

About X coordinate. Yes, it's can be a problem. For example, we know, PAL whole scanline (with synchro and flyback) take 64 microseconds, and active raster 48 microseconds with offset 8 microseconds from end of synchronization impulse. And those 48 microseconds we must divide by horizontal resolution (256 or 320 pixels).

But, not so bad! We can use "percentage" term for operate as X coordinate, right? 0% for left border and 100% for rigth border. And of course, we can (and I think must) use calibration procedure for both X and Y coordinates.
Eke wrote:Don't forget about EDCLK :wink:
We can use EDCLK. Or measure scanline time and calculate position of /TH triggering.
Eke wrote:We know that out of /HSYNC, it's exactly running at twice the pixel clock (in 40-cell mode at least) so I imagine you could use that to count the number of pixels once you are on the right line and /HSYNC is high again. With some adjustements (you have to account front porch + border area, all of this have been measured by Jorge Nuno on this forum), it could be used to trigger the /TH line on the I/O port at the right moment (forget about triggering IRQ or /HL, all of this is already handled by software & original hardware).
Yeah. By "HL" in my post I mean "/TH" line on port. :3
Last edited by HardWareMan on Thu Jul 08, 2010 2:05 pm, edited 1 time in total.

Eke
Very interested
Posts: 822
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Thu Jul 08, 2010 1:58 pm

a passthrough device on the cartridge port that intercepts HSYNC, VSYNC and EDCLK signal and is also connected to the controller port would indeed be the best solution 8)

But I still have trouble figuring how you think you can send wiimote position to that device ? Are you thinking about some kind of bluetooth receiver ? It woudl need to operate in real-time, very fast, seems hard to me at first glance :?:
so it's needed to trigger HL from Y-4 to Y+4 ?
should be adjustable in my opinion, just like X positionning

User avatar
TmEE co.(TM)
Very interested
Posts: 2316
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Thu Jul 08, 2010 2:19 pm

32X uses both H and Vsync, and it is extremely picky about Hsync... if the signal is slightly lower or deformed then you'll get scrolling or deformation and/or dislocation in the 32X image :/
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

User avatar
KanedaFr
Administrateur
Posts: 1116
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Thu Jul 08, 2010 2:22 pm

HardWareMan wrote:About X coordinate. Yes, it's can be a problem. For example, we know, PAL whole scanline (with synchro and flyback) take 64 microseconds, and active raster 48 microseconds with offset 8 microseconds from end of synchronization impulse. And those 48 microseconds we must divide by horizontal resolution (256 or 320 pixels).

But, not so bad! We can use "percentage" term for operate as X coordinate, right? 0% for left border and 100% for rigth border. And of course, we can (and I think must) use calibration procedure for both X and Y coordinates.
sure, calibration is a must need!

you made a perfect (technical) resume of what I thought about "calculate" x coordinate :)

a passthrough device on the cartridge port that intercepts HSYNC, VSYNC and EDCLK signal and is also connected to the controller port would indeed be the best solution
I now think so too
But I still have trouble figuring how you think you can send wiimote position to that device ? Are you thinking about some kind of bluetooth receiver ? It woudl need to operate in real-time, very fast, seems hard to me at first glance
Yeah, I knew it has to be fast but now I realize how MUCH (since related to video sync!)

My first proto was about
Wiimote-(BT)->PC-(USB)->Teensy-(wire)->Joyport
because a BT enabled hardware is expensive...
the cheapest solution is serial so low(?) speed
It will be 'stupid' to make something which cost 100$ !!!

I wish to be able to hack somethink like this :
http://www.hkems.com/product/xbox/EMSTopGun2.htm

User avatar
KanedaFr
Administrateur
Posts: 1116
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Thu Jul 08, 2010 2:23 pm

TmEE co.(TM) wrote:32X uses both H and Vsync, and it is extremely picky about Hsync... if the signal is slightly lower or deformed then you'll get scrolling or deformation and/or dislocation in the 32X image :/
Is there any 32X light gun game ?

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest