Author |
Message |
- Joined: 28 Mar 2002
- Posts: 180
- Location: Toronto, Canada
|
LightPhaser
Posted: Sat Aug 09, 2003 2:00 pm
|
Hello Guys!
I'm implementing lightgun support but i'm in trouble.
As far as i know, when the trigger is pressed, button 1 (pin TR) is activated and then the Z80 CPU starts rendering white patterns to determine the exact shot location huh?
So when the light gun see the "white light" it changes the state of pin TH to latch the H Counter.
When debugging, i can see the CPU reading both V and H Counters
and then nothing happens. Other thing that i've noticed, is that the game sets pin TH of PortB as output when i shoot.
Bock, Maxim, Charles? Any ideas?
|
|
|
- Joined: 28 Mar 2002
- Posts: 180
- Location: Toronto, Canada
|
LightPhaser .......... Any?
Posted: Thu Aug 14, 2003 10:01 pm
|
Ideas?
|
|
|
- Joined: 28 Sep 1999
- Posts: 1198
|
My idea
Posted: Sat Aug 16, 2003 10:40 pm
|
Quote > As far as i know, when the trigger is pressed, button 1 (pin TR) is activated and then the Z80 CPU starts rendering white patterns to determine the exact shot location huh?
> So when the light gun see the "white light" it changes the state of pin TH to latch the H Counter.
Maybe not quite like that. I noticed something interesting about the lightgun when I was running some tests on it. The program I wrote waited in a loop for the TH pin to change. When it did, it read the H and V counters, then displayed a sprite at that location on the screen and waited again.
With a black background and a dark sprite, but with the brightness turned up on the monitor, the sprite would track the gun position anywhere on the screen.
This would seem to indicate that the lightgun can see the raster beam itself (the current point on the display it's scanning across) and uses TH to indicate that, otherwise it hasn't seen it.
Reading the H and V counters would return the position of the beam at the time it was seen.
While I have never heard any technical descriptions of how light guns work in general, I think this makes sense. And the test programs I've written would seem to confirm things.
If you wanted to emulate this using (for example) a mouse, I would read the mouse coordinates, then at the start of a new frame wait until the Z80 had executed enough cycles so that the virtual display would have reached the current point the mouse was at. Then, I'd toggle TH and latch the H counter, and run the CPU emulation for a few cycles so the program would notice TH and read the latched H counter and V counter accordingly.
Quote > When debugging, i can see the CPU reading both V and H Counters
> and then nothing happens. Other thing that i've noticed, is that the game sets pin TH of PortB as output when i shoot.
What game are you testing? Maybe I can look at it.
|
|
|
- Joined: 28 Mar 2002
- Posts: 180
- Location: Toronto, Canada
|
Re: My idea
Posted: Sun Aug 17, 2003 12:26 am
|
Quote > If you wanted to emulate this using (for example) a mouse, I > would read the mouse coordinates, ....
> so the program would notice TH and read the latched H counter > and V counter accordingly.
Yes, that's exactly what i did. It seems that the games uses different algorithms to use the gun.
In fact, i was having problems on Gangster Town. When i clicked the screen, the program activated the fire button and when the raster point reached the "clicked line", i triggered the pin TH. After that, Gangster Town read the counters (H then V) one time. Missile Defense 3D read those counters more than 10 times!! My emulation worked with Missile Defense but not with Gangster Town.
Quote > > When debugging, i can see the CPU reading both V and H Counters
> > and then nothing happens. Other thing that i've noticed, is that the game sets pin TH of PortB as output when i shoot.
> What game are you testing? Maybe I can look at it.
|
|
|
Greg
|
long idstance
Posted: Sun Dec 21, 2003 12:15 am
|
Quote > > If you wanted to emulate this using (for example) a mouse, I > would read the mouse coordinates, ....
> > so the program would notice TH and read the latched H counter > and V counter accordingly.
> Yes, that's exactly what i did. It seems that the games uses different algorithmslong idstance to use the gun.
> In fact, i was having problems on Gangster Town. When i clicked the screen, the program activated the fire button and when the raster point reached the "clicked line", i triggered the pin TH. After that, Gangster Town read the counters (H then V) one time. Missile Defense 3D read those counters more than 10 times!! My emulation worked with Missile Defense but not with Gangster Town.
> > > When debugging, i can see the CPU reading both V and H Counters
> > > and then nothing happens. Other thing that i've noticed, is that the game sets pin TH of PortB as output when i shoot.
> > What game are you testing? Maybe I can look at it.
|
|
|