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.
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:
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.
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
- FIFA International Soccer (5P) (Menu detection glitchy but gameplay look fine)
- FIFA Soccer 96 (5P) (Menu detection glitchy but gameplay look fine)
- FIFA Soccer 97 (5P) (Menu detection glitchy but gameplay look fine)
- FIFA Road to World Cup 98 (5P) (Menu detection glitchy but gameplay look fine)
- Golf Daisuki! O.B. Club (4P) [BSX]
- Micro Machines (4P)
- Micro Machines 2 (4P)
- Muscle Bomber - The Body Explosion (4P)
- NBA Give 'n Go (4P)
- NBA Hang Time (4P)
- NBA Jam (4P)
- NBA Jam - Tournament Edition (4P)
- NBA Live 95 (5P) (Menu detection glitchy but gameplay look fine)
- NBA Live 96 (5P) (Menu detection glitchy but gameplay look fine)
- NBA Live 97 (5P) (Menu detection glitchy but gameplay look fine)
- NBA Live 98 (5P) (Menu detection glitchy but gameplay look fine)
- NHL 94 (5P)
- NHL 98 (5P)
- Smash Tennis (4P)
- Street Racer (4P)
- Super Bomberman (4P)
- Super Bomberman 2 (4P)
- Super Bomberman 3 (5P)
- Super Bomberman 4 (5P)
- Super Bomberman 5 (5P)
- Super Bomberman - Panic Bomber W (4P)
- Super Tetris 3 (4P)
- Top Gear 3000 (4P)
Tested not-working games
- N-Warp Daisakusen (8P) [Homebrew]
- Super Formation Soccer II (4P) (4th controller CLK too fast (4 us cycle) (Fine for 3P)
- Super Formation Soccer 94 (4P) (4th controller CLK too fast (4 us cycle) (Fine for 3P)
- Super Formation Soccer 95 (4P) (4th controller CLK too fast (4 us cycle) (Fine for 3P)
- Super Formation Soccer 96 (4P) (4th controller CLK too fast (4 us cycle) (Fine for 3P)