fork download
  1. On entry, PPUMask is #%00011110, all backgrounds set rendering. And PPUCtrl is 88, NMI enabled and sprites from 0x1000 area.
  2.  
  3. ;ADDED CODE
  4. TestZapperMode:
  5. BIT PPUStatus
  6. LDA #$3F
  7. STA PPUAddr
  8. LDA #$00
  9. STA PPUAddr
  10. LDA #$0F
  11. TAX
  12. .LoopClearPalette:
  13. STA $2007
  14. DEX
  15. BPL .LoopClearPalette
  16. JSR WaitForNMI
  17. LDX #$00
  18. LDA #$08
  19. BIT $4016 ;0=Detected; 1=Not detected.
  20. BEQ .Check1Failed ;No zapper, high/light detected.
  21. INX
  22. .Check1Failed:
  23. BIT $4017 ;0=Detected; 1=Not detected.
  24. BEQ .SeeIfZappers ;No zapper, high/light detected.
  25. INX
  26. INX
  27. .SeeIfZappers:
  28. TXA
  29. BEQ NoZapperGame ;No zapper used ATM.
  30. TAY;Y=Which conrollers to check for white. 0000 0021
  31. BIT PPUStatus ;Reset latch.
  32. LDA #$3F
  33. STA PPUAddr
  34. LDX #$00
  35. STX PPUAddr
  36. LDA #$30
  37. STA PPUData ;Write 30 to first palette space, making whole screen white.
  38. STX PPUScroll
  39. STX PPUScroll
  40. STY Frame ;Frame=Controllers possibly light guns.
  41.  
  42. .KeepPollingZapper:
  43. TYA ;Put value of possibly zappers in A. Bits=0000 0021
  44. LSR A ;See if 1 slot is.
  45. BCC .CheckPlayer2 ;Nope.
  46. PHA ;Save other bit for now.
  47. LDA #$08
  48. LDX #$00
  49. BIT $4016 ;Test bit.
  50. BEQ .JumpZapperGame-1 ;If true, PLA and put the zapper slot to X and jump to the game mode.
  51. PLA ;Retrieve P2 possibly zapper bit.
  52. .CheckPlayer2
  53. LSR A ;Test P2 possible bit.
  54. BCC .CheckLoopAgain ;Nope, see if frame has ended now. If not, loop again and keep checking.
  55. LDA #$08 ;Test bit.
  56. LDX #$01 ;Zapper value.
  57. BIT $4017 ;Test
  58. BNE .CheckLoopAgain ;Nope, no zapper.
  59. 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.
  60. .JumpZapperGame:
  61. JMP ZapperGame ;Jump to zapper stuff.
  62.  
  63. .CheckLoopAgain:
  64. CPY Frame ;See if frame is still equal.
  65. BEQ .KeepPollingZapper ;Yes, keep on going. If not, continue to main game.
  66.  
  67.  
  68. NoZapperGame:
  69. ;ADDED CODE
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty