$4016 D3 and D4 ports on Famicom

Discuss hardware-related topics, such as development cartridges, CopyNES, PowerPak, EPROMs, or whatever.

Moderator: Moderators

Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

$4016 D3 and D4 ports on Famicom

Post by Pokun »

The $4017 bit 3 and 4 are used by things like light guns and paddles, and these bits are somehow connected to I/O ports on the CPU. But what about the same bits on port $4016? On NES these are accessible from controller port 1 (which makes it possible to use a Zapper in that port if the game allows it) but on Famicom they are not accessible at all (unlike $4017). All schematics that I've seen are of a Famicom so I have no idea how they are laid out on a NES.

Anyone knows how this looks like on a NES, and if it's possible to add them to a Famicom?
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: $4016 D3 and D4 ports on Famicom

Post by lidnariq »

Pokun wrote:All schematics that I've seen are of a Famicom so I have no idea how they are laid out on a NES.
The Electronix corp reverse-engineered schematics are close enough - https://console5.com/wiki/Nintendo_NES-001 (Note that the mainboard sheet has some errors, I've fixed them in a copy here)
Anyone knows how this looks like on a NES, and if it's possible to add them to a Famicom?
You certainly could add another three-state-able inverting buffer, like the 74'368 that's already used.

The 74'368 is divided into a group of four and a group of two; in the NES, they're used together in a group of six; in the Famicom that's only true of the inverter associated with $4017. The one associated with $4016 only uses the group of four, while the group of two are permanently enabled and used for two inverters to invert PPU A13 (for nametables) and as the audio amplifier.

The NES adds a full hex inverter (74HCU04) for those two inverters (the remaining four are related to the CIC).

So there's a variety of ways you could do this, but without a way to connect something to them, what for?
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: $4016 D3 and D4 ports on Famicom

Post by Pokun »

Thanks for the explanation and NES schematics!
I see, so there's a bunch of extra circuitry needed at least. I'm very much a novice when it comes to hardware, so I'll need time to study this stuff a bit.
lidnariq wrote:...but without a way to connect something to them, what for?
Well it's about adding things the Famicom is missing and are required by certain games. There was talk about adding a Four Score to a Famicom, which would require it to connect to the internal controller ports on the PCB, or it wouldn't work with Four Score games (unless you use magic like the Hori multitap that seems to be able to access D0 via the expansion port). Some people add NES ports to their Famicom, which I think should work with a Four Score. I just wanted to know what was required for adding all NES controller pins, so that for example games with two Zappers could be played, or games that otherwise requires the Zapper or similar accessories to use NES controller port 1.

The internal controller connectors are apparently "standard 2.54 mm male headers" (which I haven't been able to find in my local parts store) one 5-pin and one 6-pin (extra pin is for mic), so it should be possible to build an adapter using NES extension cables and avoid modding the Famicom too much (not sure if increased resistance from all the required adapters including the Four Score would be a problem though). For D3 and D4 pins on the controller II port I guess it's enough to connect them to pin 4 and 5 respective on the expansion port inside, but for controller I D3 and D4 pins the discussed circuit would need to be built. Sounds like a lot of work if everything should be detachable.

Another question:
Would it be possible to add a 3.5 mm mono port to the NES controller adapter so that any microphone can be used? From schematics it looks like there are a few extra components in controller II that's also needed besides the mic, but I don't know what a 3.5 mm mono port would require. Famicom microphones tends to go bad over time.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: $4016 D3 and D4 ports on Famicom

Post by rainwarrior »

Pokun wrote:unless you use magic like the Hori multitap that seems to be able to access D0 via the expansion port
Do you actually have one, or some knowledge of it actually working that way?

I think the conclusion reached before was that it never really did what it says it does.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: $4016 D3 and D4 ports on Famicom

Post by lidnariq »

Pokun wrote:unless you use magic like the Hori multitap that seems to be able to access D0 via the expansion port
My informed guess is that the Hori Multitap is either a total lie and players 1 and 2 on it just don't work, or it invokes a novel protocol that no games ever used.
Pokun wrote:Well it's about adding things the Famicom is missing and are required by certain games.
I mean, if you start with an AV Famicom - which already has the ports in the front - and just want to make $4016d3 and $4016d4 work, that's easy enough. There were several parts that do same right thing, beyond the 74'368 already used. (any "three-state inverting buffer with active low enable", e.g. 74'210, 74'240, 74'310, 74'340, 74'366, 74'4305, 74'540.)
The internal controller connectors are apparently "standard 2.54 mm male headers" (which I haven't been able to find in my local parts store) one 5-pin and one 6-pin (extra pin is for mic)
You can't find standard pin header? I mean, those connectors aren't simple pin header; at the very least there's a retaining clip...
For D3 and D4 pins on the controller II port I guess it's enough to connect them to pin 4 and 5 respective on the expansion port inside
You can find instances of people modifying their AV Famicoms in this way.
but for controller I D3 and D4 pins the discussed circuit would need to be built. Sounds like a lot of work if everything should be detachable.
I personally think it would be too much effort to keep the original case if you wanted to make it compatible with NES Four Score games.
Would it be possible to add a 3.5 mm mono port to the NES controller adapter so that any microphone can be used? From schematics it looks like there are a few extra components in controller II that's also needed besides the mic
There's a bunch of different parts here... here's a spliced segment of Enri's reversed engineered schematics showing the full microphone pathway, from electret to CPU data bus interface-
Enri-famicom-microphone-digital-path.png
Enri-famicom-microphone-digital-path.png (1.59 KiB) Viewed 15370 times
I guess you could just put a 1/8" jack in lieu of the electret microphone in the above schematic. And I have no idea how one would want to handle the volume knob (120k pot)
Famicom microphones tends to go bad over time.
You can buy new form and fit compatible electret microphones.
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: $4016 D3 and D4 ports on Famicom

Post by Pokun »

rainwarrior wrote:
Pokun wrote:unless you use magic like the Hori multitap that seems to be able to access D0 via the expansion port
Do you actually have one, or some knowledge of it actually working that way?

I think the conclusion reached before was that it never really did what it says it does.
No I never had one, Lidnariq is the one who told me that it uses magic. Maybe it just uses D1 serially like the Four Score does with D0. But yeah if no games uses it, it's pretty useless. Micro Mages claims to support it besides the Four Score, but I wonder how they did that if no one knows how it works and no games are known to support it. Maybe they just meant that they support standard expansion port controllers though and read Wikipedia's misinformation about the adapter.
lidnariq wrote:I mean, if you start with an AV Famicom - which already has the ports in the front - and just want to make $4016d3 and $4016d4 work, that's easy enough. There were several parts that do same right thing, beyond the 74'368 already used. (any "three-state inverting buffer with active low enable", e.g. 74'210, 74'240, 74'310, 74'340, 74'366, 74'4305, 74'540.)
I see, on the other hand the AV Famicom requires more work to get the microphone working.
lidnariq wrote:You can't find standard pin header? I mean, those connectors aren't simple pin header; at the very least there's a retaining clip...
Well I can find breakable header rows with 2.54 mm pitch, but I mean one that looks like the controller connector with clip. I'm not sure what to search for.
I personally think it would be too much effort to keep the original case if you wanted to make it compatible with NES Four Score games.
If it was just the Four Score you could just add two NES-Famicom controller adapters sticking out in the back (might look ugly though), but for adding $4016-D3 and $4016-D4 and also retaining the microphone there's indeed a bit too much work. I would personally not be willing to mod my case.
I guess you could just put a 1/8" jack in lieu of the electret microphone in the above schematic. And I have no idea how one would want to handle the volume knob (120k pot)
I see, thanks.
You can buy new form and fit compatible electret microphones.
Yeah I plan to do that and see if it fixes the microphone in my own controller. If one is to make an adapter for NES controllers I thought adding a microphone port to it made sense instead of adding a microphone to the adapter.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: $4016 D3 and D4 ports on Famicom

Post by lidnariq »

Pokun wrote:Maybe it just uses D1 serially like the Four Score does with D0.
The "standard" 4 player mode on the Famicom is: the two built-in controllers on both D0, and two more controllers on both D1. Several companies made controllers that specifically connected to 4016d1 (e.g. HAL JoyBall) and also released adapters (e.g. HAL JoyPair) that allowed a second expansion port controller to instead send data via 4017d1.

The problem is that the Hori 4-Players Adapter has four DA15 connectors, implying that it adds four more controllers, but it's impossible for it to replace the two that are built in to the Famicom.

For some inscrutable reason, the Famicom expansion port includes access to 4017d0, which can't be overridden without getting in a fight with the player 2 controller. But that does mean that on the AV Famicom, if nothing's plugged in to the front, it could be possible to supply three of the controllers data.

If someone ever gets their hands on a 4-Players Adapter - which I understand are rare and comparatively expensive - I'd love to see a picture of its PCB. Maybe it's genuinely a 6-players adapter, and the other two players are made available on other bits of $4017.

Or maybe it's like Naki's Tribal Tap, which added five SNES controller ports but one was simply nonfunctional.
Pokun wrote:I see, on the other hand the AV Famicom requires more work to get the microphone working
Specifically because the ASIC used in the AV Famicom leaves 4016d2 open bus. The only real difference is that this person had to add another 74'368 to drive it.
Pokun wrote:Well I can find breakable header rows with 2.54 mm pitch, but I mean one that looks like the controller connector with clip. I'm not sure what to search for.
I mean, DigiKey's the wrong distributor to use in Europe, but I just searched there for 0.1" pitch, 1 row, 5 or 6 position, and the first thing I found that wasn't breakable pin header had the retaining clip.

I don't know if it's fully geometry compatible. I'd need to look more closely inside a Famicom. All the pictures I found are only of the mainboard.
If one is to make an adapter for NES controllers I thought adding a microphone port to it made sense instead of adding a microphone to the adapter.
Certainly on the NES 4016d2 is already accessible via the expansion port.
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: $4016 D3 and D4 ports on Famicom

Post by Pokun »

lidnariq wrote:
Pokun wrote:Maybe it just uses D1 serially like the Four Score does with D0.
The "standard" 4 player mode on the Famicom is: the two built-in controllers on both D0, and two more controllers on both D1. Several companies made controllers that specifically connected to 4016d1 (e.g. HAL JoyBall) and also released adapters (e.g. HAL JoyPair) that allowed a second expansion port controller to instead send data via 4017d1.

The problem is that the Hori 4-Players Adapter has four DA15 connectors, implying that it adds four more controllers, but it's impossible for it to replace the two that are built in to the Famicom.

For some inscrutable reason, the Famicom expansion port includes access to 4017d0, which can't be overridden without getting in a fight with the player 2 controller. But that does mean that on the AV Famicom, if nothing's plugged in to the front, it could be possible to supply three of the controllers data.

If someone ever gets their hands on a 4-Players Adapter - which I understand are rare and comparatively expensive - I'd love to see a picture of its PCB. Maybe it's genuinely a 6-players adapter, and the other two players are made available on other bits of $4017.
I meant that the Hori adapter might be using $4016/$4017-D1 for all four controller ports serially just like the Four Score uses $4016/$4017-D0 serially for four controllers on the NES. The Four Score's PCB seems to be marked "HORI", so I thought it wouldn't be too surprising if they used a similar protocol for both adapters. But yeah it could simply be using two of the other input pins for the two extra controllers.
I have almost never seen the adapter in the wild so I assume it's quite rare, but if I ever get it I will document it.

Oh I found an old thread with SeanOrange of Famicom Dojo video series do some simple testing with the Hori adapter. From the sound of this, it seems like the first two ports always simply works as normal expansion controllers ($4016/$4017-D1) no matter the 2P/4P-switch's setting. And the two other ports are using this unknown protocol and are only enabled by the 2P/4P-switch. Athena's Wit's, US Championship V'Ball and Downtown Nekketsu Koshinkyoku seems to be three games that do support this unknown protocol (I heard US Championship V'Ball also supports the Four Score). So yes it is probably a 6 controller multitap only that all games that supports it, merges the first two ports' data with the hardwired controllers' data so that no more than 4 players are supported. Maybe someone interpreted this in a strange way which started the false rumour that it can actually be read from $4016/$4017-D0.
Getting this straight might fix things like the Wikipedia misconception that the Hori adapter is the only way to use four controllers on Famicoms.
I just searched there for 0.1" pitch, 1 row, 5 or 6 position, and the first thing I found that wasn't breakable pin header had the retaining clip.

I don't know if it's fully geometry compatible. I'd need to look more closely inside a Famicom. All the pictures I found are only of the mainboard.
OK I will try search a bit harder before complaining again. For pictures, you can see the mainboard with controller connectors (marked P4 and P5) here and some smaller pictures here. Spare controllers often show up on ebay sometimes with good pictures of the connector heads. Here is one quite good.
lidnariq wrote:
If one is to make an adapter for NES controllers I thought adding a microphone port to it made sense instead of adding a microphone to the adapter.
Certainly on the NES 4016d2 is already accessible via the expansion port.
I was talking about the NES->Famicom controller adapter for Four Score and more controller options on the red & white and Twin Famicoms. Since the NES ports won't have the microphone pin the microphone would have a separate connection. Some people use one of the D3 or D4 pins for the microphone which breaks Zappers and accessories but then adds a switch so you have to choose either microphone or Zapper but not both at the same time.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: $4016 D3 and D4 ports on Famicom

Post by lidnariq »

Pokun wrote:Athena's Wit's
Ok, looking in the code here. Starting at $FE29
After asserting and then de-asserting OUT0
It reads 8 times from $4017, combines the 2s and 1s bits and stores that in $6D
It reads 8 times from $4016, combines the 2s and 1s bits and stores that in $6C
It reads 8 times from $4017, stores the 1s bit in $73 and the 2s bit in $71
It reads 8 times from $4016, stores the 1s bit in $72 and the 2s bit in $70
It reads 8 times from $4017, stores the 1s bit in $77 and the 2s bit in $75
It reads 8 times from $4016, stores the 1s bit in $76 and the 2s bit in $74.
It clears $78.
If $74 holds #$20, it sets the $80s bit in $78 - checking for the 4-Player Adapter's different signature
If $75 holds #$10, it sets the $40s bit in $78 - ditto
If $76 holds #$10, it sets the $20s bit in $78 - checking for Four Score signature
if $77 holds #$20, it sets the $10s bit in $78 - ditto
If $78 holds exactly #$C0, it copies $71 over $6F and $70 over $6E - using the data from the 4-Player Adapter
If $78 holds exactly #$30, it copies $73 over $6F and $72 over $6E - using the data from the Four Score.

So - good intuition. That's exactly what Wit's expects.
Maybe someone interpreted this in a strange way which started the false rumour that it can actually be read from $4016/$4017-D0.
I think the problem is that it's misleadingly named. Before it came out, there already was a convention for four simultaneous players. The labels on the toggle maybe should have been 4/6 instead of 2/4.
OK I will try search a bit harder before complaining again. For pictures, you can see [...] good pictures of the connector heads
Ok, that's shrouded on all four sides. I admit I didn't see any like that, but a single retaining clip is probably good enough to mate to the existing connector. Digi-Key doesn't have anything that's shrouded on more than one side.

edit: or maybe you're looking for something more like this?.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: $4016 D3 and D4 ports on Famicom

Post by rainwarrior »

So, from the way it's used in Micro Mages with the assertion that that's mode "4"...

$4016 D1
0-7 = Port 1
8-15 = Port 3
16-23 = Signature $20

$4017 D1
0-7 = Port 2
8-15 = Port 4
16-23 = Signature $10

So what does mode "2" do? Does this just disconnect ports 3 and 4 and the signature, and now 8-23 will be an extended report from ports 1 and 2? (That's what the Four Score does in mode "2" as well, right?)
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: $4016 D3 and D4 ports on Famicom

Post by lidnariq »

Given that the protocol sounds like the same ASIC as in the Four Score, I'd bet your guess is correct.
... and maybe given that the part number for the Four Score (both inside and on the ASIC inside) starts with "FPA" = Four Player Adapter?
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: $4016 D3 and D4 ports on Famicom

Post by Pokun »

Yeah sounds plausible.

So even the signature is identical to the Four Score's?
Edit: Oh it's reversed. The Four Score gets $10 from $4016 and $20 from $4017.
pfwld81
Posts: 2
Joined: Sun Aug 12, 2018 6:26 am

Re: $4016 D3 and D4 ports on Famicom

Post by pfwld81 »

Hori 4 players has been described on this page.
http://forum.contrabanda.eu/index.php?topic=817.0

The method of connecting the asic and which signals were used were copied.
Image
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: $4016 D3 and D4 ports on Famicom

Post by tepples »

Would it be accurate to sum it up as a Four Score connected to D1 with $4017 and $4016 swapped at both the input and output?
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: $4016 D3 and D4 ports on Famicom

Post by lidnariq »

Sure sounds like it.

If we can trust that image of monospaced text (reproduced below), it's the same label on the ASIC as in the Four Score, anyway.

Code: Select all

            HORI FPA-92-S01
                ___  ___
CLK player2 <- | 01\/22 | -- +5V
  D player2 -> | 02  21 | <- selector(+5v-2players, GND-4players)
CLK player3 <- | 03  20 | -> CLK player1
  D player3 -> | 04  19 | <- D player 1
CLK player4 <- | 05  18 | -> OUT player1, player2, player3, player4
  G player4 -> | 06  17 | <- OUT0
        GND ?? | 07  16 | -> $4016 D1
        GND ?? | 08  15 | <- CLK1
         RA -> | 09  14 | -> $4017 D1
         RB <- | 10  13 | <- CLK2
        GND -- | 11  12 | ?? +5V
                --------
... ok I couldn't quite bring myself to reproduce it verbatim. I added arrows.

OUT0, CLK1, CLK2, and all four "D player" lines are pulled high with a 7x10k resistor SIP.

RA and RB (100kΩ resistor between; 250pF capacitor from RA to ground) form a retriggerable one-shot with time constant 25µs - I assume this is how it detects when the game is done reading the report.
Post Reply