This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Light Zapper

Light Zapper
by on (#13706)
Who is the Light Zapper research? You can write a simple demonstration of the procedure for me?

by on (#13726)
I think all the zapper does is detect the presence of white... So, to check if it hit anything on the screen, you have to paint it all black (when the trigger is pressed), and have a white square in the area that you are checking for a hit. If the gun detects white, the target was hit.

Objects you can hit must be checked one at a time, so that you know wich one was hit.

You may want to avoid cheating, when someone points the gun to a white light and pulls the trigger, meaning he'll alway get a hit. To avoid that, you first make the screen all black before checking for the individual hits. If you get a hit with a black screen, the person is cheating, and you can ignore that shot.

I don't have any code though, sorry.

by on (#13730)
tokumaru wrote:
I think all the zapper does is detect the presence of white

It may be sensitive to other colors, but nobody has studied this in depth.

Quote:
Objects you can hit must be checked one at a time, so that you know wich one was hit.

Almost. If you light up a group of objects at once, then you know that the object that is hit is either inside the group (if the gun registers light) or outside the group (if the gun registers dark).

by on (#13731)
tepples wrote:
Almost. If you light up a group of objects at once, then you know that the object that is hit is either inside the group (if the gun registers light) or outside the group (if the gun registers dark).

Yeah, like a binary search you say? You narrow down until you reach the one object that was hit... That would be good for a big number of objects. But do you think the number of objects the NES can display at once would justify a binary search? I don't know...

by on (#13747)
Binary search means less frames of a dark screen.

by on (#13754)
Dwedit wrote:
Binary search means less frames of a dark screen.


It is also only useful if you have 4 or more targets on the screen at once. There's also the fact that even with 6 targets, the overall delay (1/10th of a second) when doing one at a time is still very short.

by on (#13755)
I have a zapper demo here:

http://www.parodius.com/~memblers/nes/zappa.zip

It's really simple though, it doesn't check the trigger and it displays an all-white screen. It changes the pitch of the sound depending on where on the screen it's pointed.

To read the zapper, you have to poll it constantly. Like every scanline (114 cpu cycles or so), reading it only during vblank like a controller won't work. The good part of that is that you can narrow down the target by counting the scanlines, but the bad part is that it keeps the CPU busy for most of the frame.

by on (#14034)
I understand the basic principles, but I have never made a successful demonstration of the procedure.
I write the nes have not appeared in the simulator gun sights.
Zappa.nes I have read, it is not a complete zapper demonstration procedures.

by on (#14264)
a zapper demo :
http://zgh3000.ik8.com/fc/zapper.zip

by on (#14266)
zgh4000 wrote:


I'm not quite sure what it's supposed do, but I don't think it's working properly. When it starts up on my CopyNES, it displays a bunch of junk on the screen (probably due to writing to VRAM while rendering is turned on), then displays a blue semicircle moving diagonally across the screen. When I fire at it, it flashes white for 1 frame but does nothing else, whether I hit it or not.

It might aid in the debugging process if you included the ASM sources with the demo.

by on (#14283)
Quote:
It might aid in the debugging process if you included the ASM sources with the demo.

OK.
http://zgh3000.ik8.com/fc/zapperdemo.rar

Image

by on (#14284)
Taking a look, I can now see why it was getting graphical glitches on powerup - you must do the...
Code:
   lda #%10000000      
   sta $2000
   lda #%00011110
   sta $2001

...after the "jsr load_palette". Also, you should really be doing...
Code:
   lda #0
   sta $2000
   sta $2001

...immediately after the SEI/CLD at the top of your reset routine.

The reason it doesn't actually detect anything properly is because the Zapper only detects white as it is rendered - in other words, you need to constantly poll $4017 for the entire duration of the frame (and give up if another NMI comes along) and wait if it ever senses white. Evidently, NNNesterJ does not emulate the Zapper with correct timing - the latest build of my emulator (over at http://nintendulator.sourceforge.net/) has reasonably correct behavior (verified against actual hardware) if you want to perform additional testing.

by on (#14285)
Quietust wrote:
the Zapper only detects white as it is rendered - in other words, you need to constantly poll $4017 for the entire duration of the frame (and give up if another NMI comes along) and wait if it ever senses white.

Constantly meaning that it fades after how many cycles? Is polling once a scanline enough, or should I unroll the loop to poll once every 6 CPU clocks for a scanline at a time? And does "only detects white" mean that it will return false for lighter colors such as $10 and $31-$3C?

by on (#14287)
1. Once a scanline should be enough, since that's approximately how often the Zapper updates the read signal.
2. Light colors will also trigger it, but for a shorter period of time (normally, if you aim the zapper at a solid white screen, it will register a hit for about 25 scanlines or so).

by on (#15406)
No wrong-ray gun demonstration

http://zgh3000.ik8.com/fc/new_zapper.zip

Nintendulator
Nestopia

by on (#15417)
zgh4000 wrote:
http://zgh3000.ik8.com/fc/new_zapper.zip


Something's wrong with that site - all connections are timing out.

by on (#15423)
The link works for me. In the demo though I can't notice any difference between a hit or miss. I tried it in Nintendulator and FCEU (FCEU always shows an 'A' on the screen for some reason).

by on (#15428)
Memblers wrote:
The link works for me. In the demo though I can't notice any difference between a hit or miss. I tried it in Nintendulator and FCEU (FCEU always shows an 'A' on the screen for some reason).


Either it's only up during certain times of the day, or the Great Firewall doesn't like me...

by on (#15430)
zgh4000 wrote:
No wrong-ray gun demonstration

http://zgh3000.ik8.com/fc/new_zapper.zip

Nintendulator
Nestopia

Please try posting the file to RapidShare (http://rapidshare.de/).

by on (#15432)
Your Download-Link: http://rapidshare.de/files/26062585/new_zapper.zip.html

http://zgh3000.ik8.com/fc/new_zapper2.zip

Nintendulator
Nestopia
FCEU

by on (#15457)
So it seems that the Great Firewall has no problems with RapidShare...? :)

Oh BTW, the non-RapidShare link seems to be working for me now. :roll: