FAQ: Can NESmaker do Zapper games?

A question I saw popping up from time to time, both in the Discord and on the forum, is if NESmaker supports the Zapper. That’s what prompted me to write up a tutorial on how to add Zapper support to a NESmaker game on the forums. This post is more or less a mirror of the existing forum topic.

You can read the original forum topic here: [4.5.9] Adding zapper support

In short, yes – NESmaker can support the Zapper. In fact, NESmaker supports anything a NES can do, although some things will need a lot more programming work than others. By default, there are no NESmaker scripts available to support the Zapper. Luckily, it’s not terribly complex to add this. Follow these steps and you’re good to go.

1) Add a variable called zapped (1 byte) to Zero Page RAM.
2) Add a variable called palBackup (17 bytes) to Overflow RAM
3) Add a constant ZAP_WHITE_TILE with a value of 126* to User Constants.
4) Draw an 8×8 blue square in GameObjectTiles.bmp in the next-to-last tile*.

5) Download the attached txt script file, rename it to nm_zapper.asm, and put it somewhere in the GameEngineData/Routines folder.
6) In Script Settings, add a script define.
Name: Zapper handler (or whatever name you find suiting)
Define: SCR_ZAPPER
Script: Routines\nm_zapper.asm (or wherever you saved it after downloading)

7) In Project Labels, under Monster Bits, edit the value of Bit-7 and change it into Zappable (this is optional, but makes things more clear UI-wise).

8) In Routines\BASE_4_5\Game\MainGameLoop.asm, find the line that says dontSkipNormalGameLoop:, and directly below, add:

ifdef ZAP_WHITE_TILE
    .include SCR_ZAPPER
endif

9) In Routines\BASE_4_5\System\NMI.asm, find the lines that say…

doPaletteUpdates:
    .include SCR_LOAD_PALETTES
    JMP skipScreenUpdates
+

…and remove the JMP skipScreenUpdates line (or add a semicolon in front).

10) In Routines\BASE_4_5\Game\LoadAllSubroutines.asm, at the very end, add…

MonsterBits:
   .include "ScreenData\ObjectData\MonsterBits.dat"
ifdef ZAP_WHITE_TILE
    doHandleZap:
        JMP RESET
        RTS
endif

…and replace JMP RESET with whatever you want a successful zap to do. Destroy the object, add points to your score, warp to a winner screen… anything goes.

11) From the Monster Graphics Banks, open the monster you want to zap, click Object Details, click the Details tab, and select the checkbox that says Zappable (or Bit-7 if you skipped step 7).

12) Build and test the ROM. In Mesen, go to Options > Input and select Zapper for Player 2.

Happy zapping!

* 126 (or $7E) corresponds with the next-to-last tile in GameObjectTiles.bmp. If you cannot use this tile (e.g. because it is already in use), you can pick a different tile, and then count/calculate the corresponding tile number, or look it up in Mesen’s PPU viewer.