Close

2020-08-04 Progress update - SFC/SNES support

A project log for BlueRetro

Multiplayer Bluetooth controllers adapter for retro video game consoles

jacques-gagnonJacques Gagnon 08/02/2020 at 01:180 Comments

Finished basic SNES 2P support and some experimental 5P Super Multitap support. Multitap can be configured by setting multitap config to Slot 2 in the Web Bluetooth interface. I also fixed a config corruption bug that impacted mostly PS3 & PS4 controllers. See release v0.5 on GitHub.

See schematic for SNES support. Most SNES extension cable only includes 5 cables inside so I had to hack the cables to add the missing 2 pins the multitap require. I simply used a third extension cable as a pin donor for the other one and used an 8-lines cable from a PSX extension.

The Super Famicom/Nintendo use the same type of shift register protocol used previously on the Famicom & NES. While previously the software had to do the polling of the controller now, the SFC/SNES support a hardware base option to do the polling.

The result is a very clean waveform for the clock with 50% duty cycle. Also this allows to poll both controller slot simultaneously. Controller looks to be detected by reading the data line (low) on the 17th clock cycle after latch.

SNES Mouse

The first two bytes are polled by hardware and then the last two bytes are polled via software. The delay between the first two bytes and the last ones is over ~2 ms!

The first byte is always 0xFF. On the second byte, bit 7 is the Right button, bit 6 the left button and bits 5-4 are the current  inverted speed setting (non-inverted value: 0 = slow, 1 = medium, 2 = fast). The lower nibble is fixed to 0xE. The third byte is the Y axis and the fourth one the X axis. Value are inverted. Bit 7 is the direction (non-inverted 0: Down/Right 1: Up/Left) and bits 6-0 are the absolute value of movement counter since last poll. (Value are no two's complement!!)

The mouse can cycle through 3 speed always starting with slow (0). The change the speed the software need to cycle the clock line while the latch is set:

Multiple consecutive clock cycle while latch is high
Zoom on first

The Super Multitap

The Super Multitap allows to use 4 controllers via a single port. Two could be used simultaneously for up to 8 players technically but commercial games released only supported a maximum of five by plugging the multitap in the second port.

The multitap work a bit like the Famicom 4P adapter by using two data lines simultaneously to output controller data. An additional output from system allow to select between the first and second pairs of controllers.

Detecting the multitap is done by looking at the D0 and D1 output while the Latch is set. When select is set, the D1 output will be low as long the latch is set. D0 will maintain its value until clocked, 9 us pass or if latch goes low, at that point B button value is loaded on D0. The controllers themselves on the multitap are detected on the 17th clock cycle after latch if their respective data line is low just like regular controllers.

The multitap need to be polled by software and games implement it mostly the same way but with small timing difference. This made the BlueRetro implementation a bit more complex than NES & Saturn multitap and required testing with various games. Some Latch for a very short time while others like EA Sports games sometimes double Latch in a very short interval.

Glitch on Latch from NHL 98

Adding the fact the ESP32 is a bit on the slow side with GPIO, this made the implementation a bit hackish. The timing at which B is polled following SEL line getting low if often too quick for the ESP32 and the main hack is to set B value when the clock line is trigger for controller detection on the 17th clock cycle of the previous pair of controllers.

One homebrew game, N-Warp Daisakusen, support 8 players but the polling pattern is very different than any commercial games and the timing are quite brutal everywhere.

Since the sources are available, I'll probably try to make the polling pattern more like original games one day.

Tested working games

Tested not-working games

Discussions