← All projects
Project record1 mention
Originally shared on Hacker News

NES cartridge multi-controller input rewrite

An input handling rewrite for an NES cartridge project that adds support for original NES controllers, SNES controllers, and the Power Pad dance mat. The cartridge tracks CPU parity to work around a hardware bug where input reads on even cycles become corrupted while a sound channel is playing, carefully cycle-timing reads and writes so reads land on safe cycles.

Last shared
01 / The problem

What it addresses

Reading the NES input ports on even cycles while a sound channel is playing corrupts the data; the same read on an odd cycle works, requiring the cartridge to track CPU parity and precisely cycle-time the routine.

02 / Source history

Shared over time

Each entry reflects what was shared on that date. Details may have changed since then.

  1. NES cartridge multi-controller input rewrite

    An input handling rewrite for an NES cartridge project that adds support for original NES controllers, SNES controllers, and the Power Pad dance mat. The cartridge tracks CPU parity to work around a hardware bug where input reads on even cycles become corrupted while a sound channel is playing, carefully cycle-timing reads and writes so reads land on safe cycles.

    Problem: Reading the NES input ports on even cycles while a sound channel is playing corrupts the data; the same read on an odd cycle works, requiring the cartridge to track CPU parity and precisely cycle-time the routine.

    Posted by @zeta0134 · Original source ↗

    Source text · @zeta0134 · · Source ↗

    Now that I can finally test on hardware, I completely rewrote input handling. I can now support original NES controllers, but also SNES and the Power Pad dance mat, for anyone crazy enough to try that.