Zapper
From NESdev Wiki
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:
- Each frame, check if the player has pulled the trigger. Remain in this step until the trigger is pulled.
- 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.
- 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.
- Restore the screen to its original state.