Input device signature bits

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Input device signature bits
by on (#72712)
I've been trying to fix a lot of games that have been broken in my emulation code, and recently tracked down another hard-to-find bug that I'd like to make a note of in case anyone else encounters a similar problem.

Back ~8 years ago when I wrote my input handling code for the standard controllers, I based it off of koitsu's document that stated that the 4 bytes read for a given controller after the first 8 bytes encode a 4-bit device signature - 1 for controller 1, 2 for controller 2, etc. This code worked for the vast majority of games, however Monster Truck Rally would fail to read my "Start" button presses on the title screen. (I also saw similar failures in the SMB + Duck Hunt + XXX games)

A lot has changed since then and after taking a look at the wiki I now see that reads after the first 8 bytes should always return 1 (or 0 in the case of an inauthentic controller.) When I changed my code to always return 1 when $4016/$4017 are queried beyond 8 bytes Monster Truck Rally worked just fine. Always returning 0 made it work as well; something about returning a combination of 0's and 1's made the game fail.

Long story short: Monster Truck Rally reads more than 8 bytes from $4016/$4017 after clearing the input strobe, and will fail if an emulator does not handle these reads properly.

That being said, having finally had a chance to play Monster Truck Rally I promptly reverted my changes and left the bug in, to spare anyone else the misfortune of playing such an awful game. :lol:

by on (#72713)
The standard controllers have no signature, but as I understand it, the 4-player adapters (Four Score and Satellite) use one so that the game knows that 1. the adapter is connected and turned on and 2. reads haven't lost a bit due to DMC DMA double clocking.

by on (#95153)
In #nesdev several days ago, someone experienced frustration at figuring out how to compensate for the DMC's habit of bit deletions on the NES Four Score hub. So I bought a Four Score and two extra controllers and made a little demo of reading all four controllers on a Four Score while ignoring glitched reads. It works in FCEUX and on my NES with a PowerPak, but it won't work with Famicom expansion controllers.

Download Eighty (source and binary)

PROTIP: Droid does what iDon't. Select wisely.