Zapper

From NESdev Wiki
Revision as of 05:55, 12 June 2009 by Banshaku (talk | contribs) (Created page with 'The '''Zapper''' is a light gun, often associated with the game "Duck Hunt". The Zapper can be used in either controller port, though most games will only allo...')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

The Zapper is a light gun, often associated with the game "Duck Hunt".

The Zapper can be used in either controller port, though most games will only allow you to use it in controller port #2, leaving port #1 for a standard controller used for navigating through options.

Output ($4016/$4017 read)

7  bit  0
---- ----
xxxT Wxxx
   | |
   | +---- Light sense (0: detected; 1: not detected)
   +------ Trigger (0: released; 1: pulled)

The proper way to implement zapper support in a game is as follows:

  1. Each frame, check if the player has pulled the trigger. Remain in this step until the trigger is pulled.
  2. Display a completely black screen and verify that the light gun does NOT detect white for the entire frame, to ensure that the player is actually pointing the gun at the screen.
  3. For each target the player may hit, display a black screen with a single white box at the target's location. Wait the entire frame to check if white is ever detected - if it is, register a 'hit' within the game; if not, move on to the next target or, if there are no additional targets, register a 'miss' within the game.
  4. Restore the screen to its original state.