Creating a Built in 4 Score device

Started by lifewithmatthew, September 14, 2021, 11:57:14 am

Previous topic - Next topic

lifewithmatthew

I'm having fun messing around with the expansion slot connector on the bottom of the front loader NES and wanted to make my own 4 score adapter using the exposed pins rather than just plugging into the two front controller ports.

I have an original Four Score that uses the Hori FPA-92-S01 9109 U chip that I'm using as a reference and am working on making a circuit diagram of.  So far I've mapped out the circuit and figured out the pinout of the main FPA-92-S01 chip and the 7 pin connector that goes to the two controller ports:

                             ,---v---.                 
                    J2 CLK ->|01   22|-- +5v         
                     J2 D0 ->|02   21|-- 2 Controller Mode Selected on +5v / 4 Controller on Ground
                    J3 CLK ->|03   20|<- J1 CLK         
                     J3 D0 ->|04   19|<- J1 D0         
                    J4 CLK ->|05   18|<- Latch/Strobe All
                     J4 D0 ->|06   17|<- CN5 Pin 1 (Latch/Strobe)
 Turbo B (Selected on +5v) --|07   16|-> CN5 Pin 2 (D0 Controller 1)
 Turbo A (Selected on +5v) --|08   15|-> CN5 Pin 5 (CLK Controller 2)
     Voltage Divider to 10 --|09   14|-> CN5 Pin 4 (D0 Controller 2)
     Voltage Divider to 09 --|10   13|-> CN5 Pin 3 (CLK Controller 1)
                       GND --|11   12|-- GND  
                             +-------+             
                             FPA-92-S01
                             ,-V-.
         FPA-92-S01 Pin 17 <-|01 |<- Latch/Strobe Controller 1 Only
         FPA-92-S01 Pin 16 ->|02 |-> Controller 1 D0
         FPA-92-S01 Pin 13 ->|03 |-> CLK Controller 1
         FPA-92-S01 Pin 14 ->|04 |-> Controller 2 D0
         FPA-92-S01 Pin 15 ->|05 |-> CLK Controller 2
                       GND --|06 |-- GND Controller 1 Only
                       +5v --|07 |-- +5v Controller 1 Only
                             +---+
              CN5

So I have two questions I was hoping y'all could help me out with.

First off, if I'm understanding the schematic of the expansion port then I can use pin 43 (Latch/Strobe Controller 1) pin 35 (Controller 1 D0), pin 37 (CLK Controller 1?), pin 19 (Controller 2 D0), pin 11 (CLK Controller 2?), pin 1 and 48 for +5v, and pin 2 and 47 for ground.  Am I right about Pin 37 and 11 of the expansion port being the Clock pulse for Controller 1 and 2? The diagram I'm referencing  has pin 37 and 11 listed as
/OE for joypad 1 ($4016 read strobe) and ($4017 read strobe) /OE for joypad 2 respectively

Second, I was reading on NesDev that if I wanted to duplicate the effects of the Hori chip you just need chip that has six total shift registers acting in parallel.  Does anyone know of a good option for that?  I'm a bit lost as anytime I search for a shift register that can handle 8 elements per channel I get results for a chip that have 64 pins, so I know I'm missing a crucial concept.

Thanks for any pointers you can provide!

lifewithmatthew

For those interested I mapped out the circuitry on my board, here's the wiring diagram.  Just as a note, I have no idea what diode is being used on this board.  It has no marking, but it is clearly and purposeful being used in reverse.

If anyone could help me figure out an appropriate substitute for the main chip I'd really appreciate it!

Also I currently have zero idea what's going on with the pins I've labeled as "Volt_Div".  I named it when I thought it was split between two resistors and only later realized one of them was a radial capacitor.  The rest of it I'm confident about


P

Cool project there. :) I've been hoping someone would make a home-made Four Score some day. If you support the signature used by the Hori 4 Players Adapter (which is basically the Famicom version of the Four Score) as well and add $4016.D1 and 4017.D1 to the mix you could increase compatibility with games.

I'm not the right person to answer but I will answer what I know.

Quote from: lifewithmatthew on September 14, 2021, 11:57:14 amFirst off, if I'm understanding the schematic of the expansion port then I can use pin 43 (Latch/Strobe Controller 1) pin 35 (Controller 1 D0), pin 37 (CLK Controller 1?), pin 19 (Controller 2 D0), pin 11 (CLK Controller 2?), pin 1 and 48 for +5v, and pin 2 and 47 for ground.  Am I right about Pin 37 and 11 of the expansion port being the Clock pulse for Controller 1 and 2? The diagram I'm referencing  has pin 37 and 11 listed as
/OE for joypad 1 ($4016 read strobe) and ($4017 read strobe) /OE for joypad 2 respectively
Yes that is my understanding of it too, and it matches the Famicom expansion port pin 9 and 14 which are also called /OE, they are indeed what clocks $4016 and $4017 respectively and are usually called CLK.

The other pins also looks right, but one thing to be aware of is that you are using duplicates of the controller port pins (the "xx" pins on Nesdev wiki). The latch (pin 43) and clock pins are not a problem but D0 of both controllers would conflict with any controllers connected to the controller ports in front at the same time. The Famicom has a similar problem with expansion port pin 8 which is controller II D0 and controller II is normally permanently plugged in on a Famicom.


Unfortunately I can't answer the question about shift registers (I would like to know too). It's too bad that Nesdev forums are still down.

lifewithmatthew

Quote from: P on September 16, 2021, 02:20:47 pmUnfortunately I can't answer the question about shift registers (I would like to know too). It's too bad that Nesdev forums are still down.

Thanks for the response!  As I've been looking over it the past couple of days I realized that it's probably not a shift register being used in the four score at all, but a very basic micro processor.  It has no external clock or relays or anything, and yet it can provide a turbo mode?  After sending data for ports 1/3 it can send a signature?  Where does that signature even get generated without the the physical inputs going into a shift register?

It has to be mirco processor!  I've got some controller extension cords coming in that I plan to cut up and use to test this theory with an arduino.  We'll see how close to the mark I am with my developing theories.

P

September 18, 2021, 03:22:28 pm #4 Last Edit: September 25, 2021, 10:14:52 am by P
Yeah it might be a custom microcontroller, I think I remember someone thinking it was that on Nesdev but I can't remember for sure. I'm sure it can be reproduced just using logic chips and discrete components though.

Yes there is a signature in two parts in the bitstream coming in after the controller 3 and the controller 4 data respectively. It's %00010000 and %00100000 respectively with bits in order coming in from the most significant bit to the least one in both cases. The Famicom variant uses the same signature but swaps the two parts, but otherwise it works exactly the same as the Four-Score/Nes-Satelite, except that it connects to the expansion port and thus uses $4016.D1 and 4017.D1 for all controllers instead of $4016.D0 and 4017.D0 like the Four-Score does. All this should be explained on the wiki.

If you build a Four-Score you need to make sure the signature is wired or games won't detect it as connected.
I made a test program for both the Four-Score and Famicom expansion controllers (the "Simple" method in the wiki). I've yet to add Hori's Famicom multitap though.

Here is the program: You cannot see attachments on this board., it's in NROM and FDS so it can be played on a flashcart, FDSStick or an emulator. Rename the file extension ".txt" to ".7z" to open and extract it.

Edit: A read-only mirror of the Nesdev forum is back up. Here is the link to my program.

lifewithmatthew

Thanks I'll have to give that a look as I work this out.  Currently I'm waiting on some NES controller expansion cords that I can cut up to wire it into my arduino and up to my NES.  The basic theory of it seems straight forward, I look forward to finding out how wrong I am in that assumption 🤣

lifewithmatthew

September 22, 2021, 01:03:33 pm #6 Last Edit: September 23, 2021, 12:33:32 pm by lifewithmatthew
So I'm working on understanding (electrically) how the controllers are read.

I understand that:
1) the NES sends out a latch by writing high state followed by a low state.  This enables all button inputs to be read  (on the high state) and then stored (on the low state) in the shift register
2) The NES sends eight clock pulses, with each pulse the next bit is send out of the shift register.

So that's player one, but what about player 2? 
Does the NES send all 8 pulses for player 1 followed by all 8 pulses for player 2 I.e.:

1) Set latch to high then low
2) Send all 8 pulses for controller 1
3) Send all 8 pulses for controller 2
4) wait until next cycle

Or do the pulses alternate between each controller? I.e.

1) Set latch to high then low
2) Send first pulse for controller 1
3) Send first pulse for controller 2
4) Repeat until 8 pulses are sent for both controllers
5) Wait until the next cycle.

When the 4 score is put into the mix, I'm assuming that the scan cycle is reduced to 1/3rd it's normal speed when in 4 player mode i.e.

1) Set latch to high then low
2) Send all 8 pulses for controller 1
3) Send all 8 pulses for controller 2
4) next cycle set Latch to high then low
5) Send all 8 pulses for controller 3
6) Send all 8 pulses for controller 4
7) Next cycle set Latch to high then low
8 ) Send 0,0,0,1,0,0,0,0
9) Send 0,0,1,0,0,0,0,0
10) Wait for next cycle to repeat

But by any chance do you know exactly how the reading for the 4 score works?

P

September 23, 2021, 06:57:57 am #7 Last Edit: September 23, 2021, 08:31:15 am by P
For controller II your second theory is correct, pulses alternates. Setting the latch high then low will latch all controllers including both expansion controllers 3 and 4 and Four Score controllers 3 and 4. The latch pin in each controller port and both NES and Famicom EXP ports are all connected to one of the Famicom's three output pins (output port $4016.D0 or sometimes just called OUT0). Each controller internally connects this pin to pin 9 of the 4021 shift-register which then starts putting the button data on its output port for the Famicom/NES to read.

After latching, the game can read the data for any and all controllers. Controller I is read from input port 4016.D0 and controller II is read from input port 4017.D0, so they are read alternating pulses but from different data pins. Expansion port controller III and IV are read from two other pins in the expansion port (input port 4016.D1 and input port 4017.D1 respectively).
The Four Score's Controller III and VI however are read from the same data pin as controller I and II respectively (input port 4016.D0/4017.D0) and comes sequentially after the 8 controller I and II reads for a total of 16 pulses for each of those ports. So you can think of it like two 16-button controllers instead of four 8-button controllers. Likewise, the signature is just another 8 reads from both ports. No need to latch again there either. Actually you shouldn't latch again, if you do the controller will just send data from the beginning again.

lifewithmatthew

Thank you so much for the explanation!  That clarifies thing so nicely and raises another set of questions  ;D

You mentioned that on the expansion ports controller 3 and 4 are read from 4016.D1 and 4017.D1, whereas the 4 score still used the same location as controller 1 and 2 (so it would send a latch signal followed by 24 pulses to get Controller 1/3 and signature or Controllers 2/4 and signature).

For the four score this should mean that even in 2 player mode it would send the data for any controller connected, eight "1s" for any controller not connected and the appropriate signature.  This should work with any non four player game as the latch pulse would reset the pointer back to 0 and I would just send the data for player 1 or 2.  Okay, no worries.

So how did the game know to ask for 24 bits from player 1/2 controller ports to support the four score, or 4016.D1/4017.D1 for the expansion ports?  Was it only Japanese games that used the 4017/4016 D1?

emerson

This page on nesdev details how to detect which peripherals are connected.

As 4016.D1/4017.D1 are not present on the US NES controller ports and no official hardware used the US expansion port, it's probably safe to say that only japanese games used them.

In regards to R1 and C2 and the "Volt_Div" inputs, I suspect these are used as the clock source for the turbo function via the RC time constant. With this in mind, let's assume U1 pin 9 is an output and pin 10 is an input. Let's start by asserting pin 9 high. This will charge C2 through R1 and eventually bring pin 10 to a logic high state. Once pin 10 reaches logic high this would internally toggle the state of pin 9 causing it to go low, thus discharging the capacitor through R1, causing pin 10 to go low, and the cycle repeats itself. The state of pin 9 would be controlled by the formula "pin 9 = (pin 10) XOR (turbo A OR turbo B)".

As for the controller port diodes, these are what's known as signal or switching diodes. Two reasons to have these diodes are to assert a known logic state or to protect the internal circuitry from external ESD. A suitable part for this would be either 1N4148 or 1N914 as these are both popular and inexpensive switching diodes. For the record, the diodes used in the schematic are 7 amp power rectifier diodes you would find in an AC->DC power adapter. The 1N400x family of diodes are probably just as popular as the 1N4148 and 1N914, just for different use cases.

We can rule out that U1 is a micro processor as processors are typically controlled by an external device via address and data busses and would either have a boot rom or receive instructions from an external rom like a game cartridge. A microcontroller would be a more appropriate assumption as they have the instructing device built in and can be programmed to interact with the outside world when necessary, much like U1 is doing here. With that being said I doubt U1 is a microcontroller for a few reasons. The main reason being there is no synchronizing system clock between U1 and the console itself, nor is there an external timing device like an oscillator or resonator. Assuming it's a microcontroller, this would imply that U1 would have an internal clock fast enough to cope with the asynchronous pulses (relative to its internal clock) of the Latch, CLK1 and CLK2 signals, calculate whatever it needs to do, and return the appropriate data. I doubt the cost of such a part in the early 90s (assuming that 9109 value is a date code) is justified in this use case.

I would assume that U1 is an ASIC, or Application Specific Integrated Circuit. In simple terms, it is a microchip designed specifically for the required job and nothing else. In this case it's a bunch of glue logic rolled up into one chip. It's an inexpensive and common solution for tasks such as this. Finding a drop in replacement will be next to impossible.

Essentially what you need for each channel is a multiplexer that can switch between a total of 3 inputs every 8 clocks, and everything be reset by the latch pulse. The 8-bit signatures for each channel could be 4021 shift registers (the chip used in NES controllers) with the data lines soldered to VCC or GND to generate the binary signature. Additionally, 4021 ICs could be used for the 8 clock counters by tying D0-D7 to GND and the serial input to VCC. This would provide a logic high on the data output line only after 8 clocks, and would remain high until the next latch pulse. The 4021 data outputs from the counters would control the multiplexer channel select bits, and a bit of glue logic would use these to control when each counter/controller pair receives the clock pulses. The data outputs from the controllers would be tied to the multiplexer data inputs, and the multiplexer data output would feed the console. In total you would need six shift registers, two 3->1 multiplexers, and a small bit of glue logic. A minimum 10-12 chip solution if using basic parts. Adding turbo functionality will require more logic.

Once the logic is known it could then be programmed into a GAL, CPLD or similar logic programmable device for a one chip solution. A modern day microcontroller could probably do the task as well but my preference is to weed out the potential for error and use pure logic, but again that's just my preference.

emerson

I opened my four score this morning to have a look and noticed that my diodes in fact have markings! Each diode is labelled "Z6.2" which suggests they are 6.2v zener diodes. I desoldered D1 for a bench test which revealed a silkscreen image of a zener diode beneath it (note the lines coming off either end of the cathode stripe). The bench test also proved that these are in fact zener diodes.

I will ask that you double check your circuit as I am noticing a small difference between your schematic and my pcb. Every D0 resistor/diode combination on my pcb has them in series between VCC and GND, with the junction tied to D0 of its respective controller port. My pcb is labelled "HORI FPA-NES-02", "NTSC", and "FPA-92-S01". The date code on my FPA is 9139, so just a few months older than yours. I guess that also raises the question, although it shouldn't make much difference, but is your adapter PAL or NTSC?

Here is some crude ascii art of what I am seeing on my pcb:

    VCC
     |
     |
    ---
   |   |
   |   | 10K
   |   |
    ---
     |
     |
     +---------<< D0
     |
     |    /
  ___|___/
 /  / \
/  /___\  Z6.2
     |
     |
     |
    GND


P

Quote from: lifewithmatthew on September 23, 2021, 12:33:17 pmSo how did the game know to ask for 24 bits from player 1/2 controller ports to support the four score, or 4016.D1/4017.D1 for the expansion ports?  Was it only Japanese games that used the 4017/4016 D1?
The game just needs to read 24 bits of both ports and compare the last 8 bits with the Four Score signature. If the signature is wrong, only the first 8 bits contains meaningful data as the Four Score isn't connected (or is in 2-player mode).

Normal controllers can't really be detected reliably, so I don't think games try to detect the 4016/4017.D1 expansion port controllers with the "simple" method. "Simple" expansion port controllers are supported by most Japanese games, even 1- and 2-player games, as alternative controller I and II so people can use external controllers instead of the built-in ones. There are many games that doesn't support the "simple" method though (which is pretty annoying). Localized games generally don't remove "simple" expansion port support, but Super Mario USA does remove it from Yume Koujou Doki Doki Panic for reasons only Nintendo knows. Western-made games generally don't support the expansion port at all, but some Rare games actually do support it (NES Battletoads doesn't but R.C. Pro-Am II does).

The Nesdev wiki page you linked to has a nice list of games and what controller methods they support, there is also a list here on the forum somewhere.
Bomberman II for example is a 3-player game and only supports a third controller in the expansion port ("simple") but no multitaps. Player 1 and 2 has to use the built-in controllers. Downtown Nekketsu Koushinkyoku is 4-player and supports all three methods (simple, Hori multitap and Four Score) despite the game not being released on the NES and the Four Score not available on the Famicom. To connect two controllers to the expansion port the simple way you need one of those controllers with a daisy chained expansion port or build a custom adapter that splits the port appropriately (there are those using NES ports as well so that NES controllers can be used).

lifewithmatthew

Quote from: emerson on September 24, 2021, 07:26:30 pmIn regards to R1 and C2 and the "Volt_Div" inputs, I suspect these are used as the clock source for the turbo function via the RC time constant.

That makes sense

Quote from: emerson on September 24, 2021, 07:26:30 pmWe can rule out that U1 is a micro processor

Microprocessor/microcontroller, I was just referring to whatever an Arduino is based on the addition of the signature after the controller 1/3 or 2/4 reads and to control the turbo and 2/4 player selection.  I suppose it's possible that it has some internal circuitry to allow it to load in the signature values


Quote from: emerson on September 24, 2021, 07:26:30 pmI would assume that U1 is an ASIC, or Application Specific Integrated Circuit. In simple terms, it is a microchip designed specifically for the required job and nothing else. In this case it's a bunch of glue logic rolled up into one chip. It's an inexpensive and common solution for tasks such as this. Finding a drop in replacement will be next to impossible.

That's true, considering when this came out, hardwired logic gates would be the most likely solution.

Quote from: emerson on September 24, 2021, 07:26:30 pmA minimum 10-12 chip solution if using basic parts. Adding turbo functionality will require more logic.

I think you would be able to do it with far less parts if turbo functionality was excluded.  All that is needed is the chip to combine the data from the controllers and 2 additional sift registers (such as the SN74HC165 from TI).  The additional sift registers would have the inputs tied to voltage/ground as appropriate to create the signature.  Then all 4 controllers and 2 signature creating shift registers would feed into the single chip to combine it all. 3 ICs and you could have a very basic solutions using just ICs.


Quote from: emerson on September 24, 2021, 07:26:30 pmA modern day microcontroller could probably do the task as well

Indeed it can.  I just got it all working with an Arduino Mega (it uses an ATMega2560).  I have a Nano Every on the way that uses the ATMega4809 to see if I can make the whole thing for dirt cheap.  I'll let you know how it goes.

lifewithmatthew

Quote from: emerson on September 25, 2021, 05:05:50 amI opened my four score this morning to have a look and noticed that my diodes in fact have markings! Each diode is labelled "Z6.2" which suggests they are 6.2v zener diodes. I desoldered D1 for a bench test which revealed a silkscreen image of a zener diode beneath it (note the lines coming off either end of the cathode stripe). The bench test also proved that these are in fact zener diodes.

Excellent!  As I said in my initial post I had no idea what was used so I just threw a random diode as place holder in my schematic to show that a diode existed at that location, but I didn't want to desolder anything off my 4 score.

Quote from: emerson on September 25, 2021, 05:05:50 amI will ask that you double check your circuit as I am noticing a small difference between your schematic and my pcb. Every D0 resistor/diode combination on my pcb has them in series between VCC and GND, with the junction tied to D0 of its respective controller port. My pcb is labelled "HORI FPA-NES-02", "NTSC", and "FPA-92-S01". The date code on my FPA is 9139, so just a few months older than yours. I guess that also raises the question, although it shouldn't make much difference, but is your adapter PAL or NTSC?

Sure!  So for mine I have the following markings "HORI FPA-NES-002" "CMK-54x" "FPA-92-S01" and "NTSC/PAL" with PAL marked out (so mine is NTSC)

As for the way the diodes are connected... I mean your drawing isn't wrong.  For controllers 2 and 3 that is how they're wired, but for ports 1 and 4 the diode and resistor are right next to each other.  Here's a picture I just took showing the PCB and the PCB with markups.





The blue lines are my diodes and the red lines are resistors. (The diodes are placed such that the flow would go from ground to voltage). There is also a jumper that is between 2 diodes and to the right of a diode resistor pair that I didn't mark that is being used as a jumper for the ground plane.

More than everything being in series or parallel my translation of the layout was the resistor is a pull up resistor for the data line and the diode was to assert a known data state (as you previously mentioned as well :) ) The fact that in some cases this gives the appearance of everything being in series and in some cases being in parallel is coincidental.  I believe the focus was just on saving money and making the circuit work out for only being one layer.

lifewithmatthew

Quote from: P on September 25, 2021, 10:08:41 amThe Nesdev wiki page you linked to has a nice list of games and what controller methods they support, there is also a list here on the forum somewhere.
Bomberman II for example is a 3-player game and only supports a third controller in the expansion port ("simple") but no multitaps. Player 1 and 2 has to use the built-in controllers. Downtown Nekketsu Koushinkyoku is 4-player and supports all three methods (simple, Hori multitap and Four Score) despite the game not being released on the NES and the Four Score not available on the Famicom. To connect two controllers to the expansion port the simple way you need one of those controllers with a daisy chained expansion port or build a custom adapter that splits the port appropriately (there are those using NES ports as well so that NES controllers can be used).

Hmmm... the reason I'm asking is I'm trying to think of ways to maximize compatibility.  Like if I could use a switching IC to change what I'm connected to and how the data is processed (Position 1 using the four score method, position 2 send data to 4016.D1/4017.D1)