On entry, PPUMask is #%00011110, all backgrounds set rendering. And PPUCtrl is 88, NMI enabled and sprites from 0x1000 area.
;ADDED CODE
TestZapperMode:
BIT PPUStatus
LDA #$3F
STA PPUAddr
LDA #$00
STA PPUAddr
LDA #$0F
TAX
.LoopClearPalette:
STA $2007
DEX
BPL .LoopClearPalette
JSR WaitForNMI
LDX #$00
LDA #$08
BIT $4016;0=Detected;1=Not detected.
BEQ .Check1Failed;No zapper, high/light detected.
INX
.Check1Failed:
BIT $4017;0=Detected;1=Not detected.
BEQ .SeeIfZappers;No zapper, high/light detected.
INX
INX
.SeeIfZappers:
TXA
BEQ NoZapperGame ;No zapper used ATM.
TAY;Y=Which conrollers to check for white. 00000021
BIT PPUStatus ;Reset latch.
LDA#$3F
STA PPUAddr
LDX #$00
STX PPUAddr
LDA #$30
STA PPUData ;Write 30 to first palette space, making whole screen white.
STX PPUScroll
STX PPUScroll
STY Frame ;Frame=Controllers possibly light guns.
.KeepPollingZapper:
TYA ;Put value of possibly zappers in A. Bits=00000021
LSR A ;See if1 slot is.
BCC .CheckPlayer2;Nope.
PHA;Save other bit for now.
LDA#$08
LDX #$00
BIT $4016;Test bit.
BEQ .JumpZapperGame-1;If true, PLA and put the zapper slot to X and jump to the game mode.
PLA;Retrieve P2 possibly zapper bit.
.CheckPlayer2
LSR A ;Test P2 possible bit.
BCC .CheckLoopAgain;Nope, see if frame has ended now. If not, loop again and keep checking.
LDA#$08 ;Test bit.
LDX #$01 ;Zapper value.
BIT $4017;Test
BNE .CheckLoopAgain;Nope, no zapper.
LDA#$68 ;68 is loaded for a PLA instruction, but LDA doesn't hurt this program if it runs anyway, so that's why it's used to PLA in certain circumstances above.
.JumpZapperGame:
JMP ZapperGame ;Jump to zapper stuff.
.CheckLoopAgain:
CPY Frame ;See if frame is still equal.
BEQ .KeepPollingZapper;Yes, keep on going. If not,continue to main game.