This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Confirming Four Score Info

Confirming Four Score Info
by on (#121676)
My game supports four players and I just added a really basic menu so that I can have players join and leave instead of me having to reassemble the game to change the number of players. :o

Right now, I just read $4016 8 times for player 1, then another 8 times for player 3. I read $4017 8 times for player 2, then another 8 times for player 4.

I don't check for the four score signature or anything like that. This works on a real NES with both official standard controllers and the NES advantage whether the four score is attached or not, whether all controllers are attached or none are or anything in between.

Lots of emulators seem to not like this, and behave as if player 3 and 4 are holding all the buttons down when the four score isn't set as attached.

So, reading the wiki, I'm gathering that certain controllers return 1 rather than 0 past the first 8 reads. So basically, I need to read $4016/$4017 8 more times, than zero player 3/player 4's controller is the result is $FF? Would I need to specifically check for $10 and $20 (four score signature), or is the $FF itself a big enough hint?

Could I get away with zeroing any controller who ends up with a value of $FF for its 8 reads instead of doing an additional 8 reads for the $FF/signature, or would that break some hypothetical behavior in some controllers/emulators?

Is there anything else I need to be aware of when supporting four players? (I'm not using DMC!) I'm asking all this because I'm bummed I have to do more stuff to make emulators happy, and for all I know some actual controllers people might be using might have behavior different than the ones I own and I can't test that and don't want to hope I'm understanding the wiki correctly.
Re: Confirming Four Score Info
by on (#121677)
On hardware, my (authentic) NES controller returns 1 for the ninth and later reads, not 0, by which I mean "serial in is connected to Gnd, and the 74'368 on the mainboard inverts that". So I have no idea why yours is giving you different results...

In any case, a few possibilities come to mind:
* Only read the first 5 bits of the four score signature, rather than all 8
* Discard input from controllers where both L+R or U+D are pressed.
* Your more narrow and specific "if inputs are all 1, treat as all 0"

But, yes, your read of the wiki is consistent with my understanding of how things work.

Also, pay attention to clones that use a SNES controller in a NES.

(You might also consider adding support for the Famicom multitap.)
Re: Confirming Four Score Info
by on (#121678)
Kasumi wrote:
Lots of emulators seem to not like this, and behave as if player 3 and 4 are holding all the buttons down when the four score isn't set as attached.

My official controller on my NTSC NES behaves the same way. Perhaps some batches are wired to return 1 after the report, and some are wired to return 0. I know the PAL controllers/consoles differ slightly, and you didn't fill in your Location, so I can't tell if that's part of it.

Quote:
So, reading the wiki, I'm gathering that certain controllers return 1 rather than 0 past the first 8 reads.

The Super NES controller returns a 16-bit report, and famiclones allowing play of Super NES games with an NES will return 00000001 after the 8 main buttons. The Four Score returns all 1 after its 24-bit report, and I seem to remember the Super NES Mouse returns all 1 after its 32-bit report. Some third-party controllers may return 0 instead of 1.

Quote:
So basically, I need to read $4016/$4017 8 more times, than zero player 3/player 4's controller is the result is $FF? Would I need to specifically check for $10 and $20 (four score signature), or is the $FF itself a big enough hint?

The $10 and $20 are there largely so that you can 1. distinguish a Four Score where player 3 or 4 is holding Right from a Super NES controller and 2. distinguish a correct read from a DPCM glitch-corrupted read.

Quote:
Could I get away with zeroing any controller who ends up with a value of $FF for its 8 reads

You can do that, so long as you don't rely solely on it.

Or you could use two controller read routines: one for the title screen that autodetects the Four Score's presence and one for gameplay.
Re: Confirming Four Score Info
by on (#121680)
lidnariq wrote:
On hardware, my (authentic) NES controller returns 1 for the ninth and later reads, not 0, by which I mean "serial in is connected to Gnd, and the 74'368 on the mainboard inverts that". So I have no idea why yours is giving you different results...

Okay, you both made me double check, and now I feel crazy because it's doing exactly that. I guess it's good to know I'm not doing extra work just for emulators. :? I swear I just tried it before I made the post, and got a different thing. I uh... wouldn't have made the post at all otherwise. ("Broken on NES, must fix!" rather than "Broken on emulators eh...") I'm NTSC.

If $FF to $00 will work with a four score or without on an American NES/emulators without weird options set, it sounds good at least for now. I already set left+right to neither left nor right and up+down to neither up nor down, but I figure a keyboard user might notice if I drop ALL input in those cases, rather than just the directions in question. It'd be rare, but I don't want change direction+jump with A to possibly ignore the jump. (Yes, yes, keyboard ghosting exists too. That's not a problem for me to solve.)
The Standard Controller Talk Page wrote:
After the first eight bits, the Super NES controller returns A, X, L, R, four zero bits, then all 1

So if I'm understanding correctly from the talk page on the wiki, an SNES controller connected to an NES is (8 buttons), (4 buttons, 4 zeroes), then 1s. I'm not sure how terribly much I care about R/L etc giving input to players 3 and 4 since it's not like they'll be non zero if the person wasn't pressing them.
Tepples wrote:
famiclones allowing play of Super NES games with an NES will return 00000001 after the 8 main buttons.

That's lousy... So an SNES controller on a famiclone might be (8 buttons), (7 zeroes, a 1), (Then what?). I'm very close to not caring about clones with SNES controllers. Depends on what happens for "Then what?".
Quote:
(You might also consider adding support for the Famicom multitap.)

I already sort of support it for one to two players. (Player 3 also controls Player 1, Player 4 also controls Player 2).

For four player it's as easy as:
Code:
lda $4016
ror
rol p1buttons
ror
rol p3buttons

Right?

Ay, so I guess at some point I just need to make another menu that lets the person choose the input type.

Four Score style ($FF controllers to $00, player 3 controls player 1 on famicom) would be the default.
Famicom Multitap (Code above, maybe $FF controllers to $00 for consistency)
SNES (would just read the first 8 bytes of both controllers, or possibly use those buttons for something... I had considered supporting the extra buttons for the hell of it anyway)

Let's say only Players 1/2 can control the menus. (I hate to do that, but it ignores the one stupid case of a famiclone's player 3 right key constantly held down provided the "Then what?" answer isn't favorable.)

With the above plan, is there is no way for undesired input to happen (other than SNES controllers doing stuff if they press the extra buttons in Four Score Mode), and no way get stuck? That is, you have the option set one way, and try to play the game on different setup that will interfere with you changing the options.

Getting into super hypothetical territory, is there an already existing way to support 4 SNES controllers? Doesn't seem like a thing that you could do with the fourscore, but maybe the famicom multitap? I know nothing of hardware, but I guess if I'm supporting every other setup under the sun I may as well see if this possible.

Tepples wrote:
Or you could use two controller read routines:

At this point it's looking like I need at least 3...
Re: Confirming Four Score Info
by on (#121682)
Anything with an NES controller port could also take a Super NES controller through an adapter that infiniteneslives knows how to make and may start selling in quantity after the next compo. He made it so that I could add Super NES Mouse support to Thwaite between the compo version and the final version on the cart, but NES games work fine with my asciiPad.

When dealing with D0 devices such as the NES controller, there are essentially three shapes that you have to worry about:
  1. Original Famicom and Sharp's Twin Famicom (FC with built-in FDS) have two hardwired controllers, plus a DA15 expansion port. This port has a Y adapter with a DA15 plug and two NES controller ports. The hardwired controllers show up as FC player 3 and FC player 4.
  2. NES (whether front- or top-loading) has two NES controller ports. Expansion past this is through the Four Score accessory, which transmits only the first 8 buttons of the connected controller's report. The Four Score ignores Super NES controllers' AXLR.
  3. AV Famicom has two NES controller ports and one DA15 expansion port.
  4. FC Twin (an NES/Super NES clone) has two Super NES controller ports. I don't know how the Super Multitap connects, and I can't buy one and run test ROMs because these clones don't like the PowerPak.
Famiclones may implement any of these.

This leads to the following scenarios:
  • FC or AVFC + DA15 controllers (2 player, where FC players 1 and 3 are combined and players 2 and 4 are combined)
  • FC or AVFC + DA15 controllers (4 player)
  • NES or AVFC + Four Score (4 player)
  • AVFC + Four Score + DA15 controllers (6 player)
Do any licensed games even support both the DA15 controllers and the Four Score for 4-player mode?

If you plan on translating game text, you could support DA15 controllers in the Japanese language version and Four Score in the English language version.
Re: Confirming Four Score Info
by on (#121683)
tepples wrote:
Do any licensed games even support both the DA15 controllers and the Four Score for 4-player mode?


I seem to remember reading somewhere that Super Spike V'Ball/US Championship Volleyball supported both the Famicom's expansion port and Four Score, but I can't find where that info is, nor have I actually looked into the code to see how it's done.
Re: Confirming Four Score Info
by on (#121684)
Kasumi wrote:
For four player it's as easy as:
Code:
lda $4016
ror
rol p1buttons
ror
rol p3buttons
Right?
Looks right to me.

Quote:
Ay, so I guess at some point I just need to make another menu that lets the person choose the input type.
I wonder if this is why Super PakPak (nesdevwiki, pou√ęt) makes everyone hit A to start? You should be able to detect which mode it's running in at the time.

Quote:
Getting into super hypothetical territory, is there an already existing way to support 4 SNES controllers? Doesn't seem like a thing that you could do with the fourscore, but maybe the famicom multitap?
Yes, with caveats. P1/P2 on the original Famicom are tethered, so you can't swap them out. But P3/P4 could be SNES controllers. Or on the AV Famicom, all four could be.

tepples wrote:
Do any licensed games even support both the DA15 controllers and the Four Score for 4-player mode?
Only Technos's sports games (Nintendo World Cup, Super Spike V'ball) and this version of Tennis (US, Japan) were released with four player support in both Japan and elsewhere.
Re: Confirming Four Score Info
by on (#121685)
Quote:
If you plan on translating game text, you could support DA15 controllers in the Japanese language version and Four Score in the English language version.

Haha, no... no no no... I don't plan to make room for all the tiles a Japanese font requires when I'm displaying text, and I'm not using CHR-RAM for doing things the Super Bat Puncher Way. I'd love to have one build support everything, though poor PAL people... I can support different input, but I can't make the game run at 60 FPS for them...
lidnariq wrote:
everyone hit A to start? You should be able to detect which mode it's running in at the time.

Maybe that's best.

So...
1. Read 8 times, shift the low two bits into separate bytes of RAM. (The first bit for a definitely player 1 byte, the next bit for a maybe player 3 byte.)
2. Read 8 more times, shift the lowest bit into a new separate byte of RAM.
3. Read 8 more times, if four score signature is found, the last byte created is player 3's, else the maybe player 3 byte becomes player 3.
(Same thing for players two and 4)

Detect a press of A button to sign a player in. (Actually, doesn't the above ensure all players can even navigate all the menus? Weird stuff like SNES extra buttons/famiclone SNES holding right would get killed by failing the Four Score signature check, right?)

I'd still need a code or something if I want to support SNES controllers for the regular 1 or 2 player campaign, but are there issues with the above that I'm not seeing? Seems like it'd work with SNES controllers (famiclone and not), NES controllers (four score and not), Famicom controllers (multitap and not) which is pretty much all the scenarios that aren't crazy.

Also, thanks everyone!