Zapper hit detection

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

3gengames
Formerly 65024U
Posts: 2276
Joined: Sat Mar 27, 2010 12:57 pm

Re: Zapper hit detection

Post by 3gengames » Tue Mar 05, 2013 11:29 am

You never had it happen because you never tried a zapper game in which it allowed you to do that.

Do we really need a "Is there light?" zapper test? If so, who's gonna pony up and write it? :P I will if somebody wants it.

tepples
Posts: 22014
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Zapper hit detection

Post by tepples » Tue Mar 05, 2013 12:34 pm

A Zapper seeing constant light will look like an unplugged Zapper. In Zap Ruder's test screens, it'll leave the arrows at the top of the screen. ZapPing, also in Zap Ruder, does a more sophisticated check: try to detect light a few lines into vblank. Any light detected in that case represents a Zapper pointed at something other than the TV, at which point it assumes the Zapper is unplugged and falls back to controller play.

User avatar
Dafydd
Posts: 114
Joined: Sun Mar 16, 2008 1:45 am
Location: Uppsala, Sweden

Re: Zapper hit detection

Post by Dafydd » Tue Mar 05, 2013 12:37 pm

The code I asked you to help me with earlier in this thread shows a constant, white area that, now that the code works, makes the game display "HIT!" whenever the zapper is aimed at said white area, and "MISS!" whenever aiming anywhere else. No light I've tried other than that coming from the TV makes the game display "HIT!".

User avatar
Dafydd
Posts: 114
Joined: Sun Mar 16, 2008 1:45 am
Location: Uppsala, Sweden

Re: Zapper hit detection

Post by Dafydd » Tue Mar 05, 2013 12:45 pm

Well, a halogen lamp did the job for a single frame when moving the zapper past it quickly. It only stays displaying "HIT!", however, when aiming at the white area of the TV, or aiming at the black area of the TV from within 20 cm or so away. I guess even the "black" (which is really a dark grey) is registered by the Zapper as the cathode ray sweeps past. Still, I really doubt my quick sweep of the Zapper in front of a halogen lamp could have fooled the however-many-kHz filter in the IC, so it was probably just the trigger firing despite not being pulled (it's a little loose).

EDIT: Nope, it wasn't the trigger (I removed that code to make sure). Also tested with an LED - the Zapper registers for one frame on other bright light if sufficiently brief in time. I don't think anyone could use this for cheating in a game though, unless they could move their arm at 50 or 60 Hz (or however fast you'd need to be), as you'd need pretty precise timing. I suppose a stroboscope might do the job though.

This MIGHT all be happening, of course, because my code counts the first occurence of $4017.3 being 0 outside of vblank as a hit... but since the Zapper does report bit 3 as being 0, this means the IC has been tricked to think it's seeing light at some 15.7 kHz, while in fact, it didn't. Perhaps someone brighter than I could... illuminate me on this subject?

Post Reply