Is NES/Famicom detection possible?

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
User avatar
orlaisadog
Posts: 166
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Is NES/Famicom detection possible?

Post by orlaisadog »

Is it possible to programmatically tell the difference between a NES and a Famicom?
User avatar
orlaisadog
Posts: 166
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: Is NES/Famicom detection possible?

Post by orlaisadog »

I have no idea what any of that means.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Is NES/Famicom detection possible?

Post by tokumaru »

Yes. Ask player 2 to press all buttons on the controller, if start and select are missing, it's a Famicom. :lol:

Seriously though, there are a few characteristics that can only be found in Famicoms, such as the inability to read from OAM, but that's just because the Famicom is older and the earlier units used older revisions of the PPU and CPU, but after the NES was introduced, they probably shared the exact same chips.

Another difference between the NES and the Famicom is that the Famicom doesn't reset the PPU when the console resets... Not sure how that could be used, but asking players to reset the console isn't much better than asking player 2 to press all the buttons...
User avatar
orlaisadog
Posts: 166
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: Is NES/Famicom detection possible?

Post by orlaisadog »

What about what lidnariq said?
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Is NES/Famicom detection possible?

Post by rainwarrior »

That link described polling the controller devices and other things to detect the connected buttons/hardware etc. in a similar way, just without user input.

There is a caveat to this in that there are a lot of clone devices out there. If your software is trying to do something differently based on "NES" or "Famicom" you can probably with some effort identify those two machines specifically, but it gets a whole lot harder to cover all the bases. (Also... didn't Everdrive or PowerPak end up messing with the results of these tests in some way too?)
User avatar
orlaisadog
Posts: 166
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: Is NES/Famicom detection possible?

Post by orlaisadog »

Well, considering
A) We can't include every clone
and
B) Most people wouldn't have clones
I think this is fine to use for default language settings and controller pictures.
User avatar
orlaisadog
Posts: 166
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: Is NES/Famicom detection possible?

Post by orlaisadog »

Also, can someone explain that post simply please?
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Is NES/Famicom detection possible?

Post by rainwarrior »

orlaisadog wrote:Also, can someone explain that post simply please?
This isn't like translating a sentence from one language to another. It's a complex technical topic, and there's a whole lot of required knowledge. I made an attempt to simplify it for you in my last post, but apparently you were unsatisfied because I removed too much in that simplification. Sorry that's not good enough, but explaining it in the way you need is probably far too much work for you to reasonably request all at once.

Like, the simple answer to your question is more or less "yes", though a better answer might be "it's probably a good idea to have the user choose directly, instead". If you want to learn the prerequisites for the "how" part, maybe start by learning something small first. Small questions are easier to answer.
orlaisadog wrote:Most people wouldn't have clones
I think there's far more clones than original systems out there at this point. This forum, though, does tend to be slightly biased toward the official Nintendo hardware, though there is a notable Dendy faction here too.
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Is NES/Famicom detection possible?

Post by koitsu »

I'll make it simple: the answer is yes, it can be done with accuracy for detecting a true NES vs. a true Famicom, with user involvement (asking the player to press buttons on controllers).

However: this may not work correctly (read: the detection may not be accurate) on some clone consoles (i.e. not true Nintendo-made NES or Famicoms).

Simple enough?
User avatar
pubby
Posts: 583
Joined: Thu Mar 31, 2016 11:15 am

Re: Is NES/Famicom detection possible?

Post by pubby »

It isn't a very useful thing to do because Famicom and NES cartridges don't fit into each other's slots...
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Is NES/Famicom detection possible?

Post by tokumaru »

orlaisadog wrote:Most people wouldn't have clones
Even though clones didn't use to be particularly prevalent in most developed countries, they were in several parts of the world. Brazil, Russia and many other countries had Famiclones almost exclusively. But nowadays, even in the US, the old hardware is constantly failing, and since the patents for the console already expired, several companies are coming up with their own take on the system and cashing in on nostalgia.
pubby wrote:It isn't a very useful thing to do because Famicom and NES cartridges don't fit into each other's slots...
Unless designs like this become more common. Double-ended carts were normally used to put two games on the same cartridge, but it'd be really cool if someone decided to make dual NES-Famicom carts.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Is NES/Famicom detection possible?

Post by tepples »

The pressing Start on controller 2 method won't distinguish an NES from an AV Famicom. The technique used by allpads will.
rainwarrior wrote:There is a caveat to this in that there are a lot of clone devices out there. If your software is trying to do something differently based on "NES" or "Famicom" you can probably with some effort identify those two machines specifically, but it gets a whole lot harder to cover all the bases.
If it's just setting the default value for language selection so that the user doesn't have to go to Options as often, the stakes aren't quite that high.
rainwarrior wrote:(Also... didn't Everdrive or PowerPak end up messing with the results of these tests in some way too?)
PowerPak has pullups on data lines, while the NES grounds the lines in question. This can be detected and worked around. EverDrive behaves more like an authentic cartridge with respect to open bus behavior.
User avatar
Fisher
Posts: 1249
Joined: Sat Jul 04, 2015 9:58 am
Location: -29.794229 -55.795374

Re: Is NES/Famicom detection possible?

Post by Fisher »

tokumaru wrote:it'd be really cool if someone decided to make dual NES-Famicom carts.
Do you mean something similar to the "almighthy" Hydron?
Hydron
Hydron
It's a little bizarre and kind of messy...
But works fine! :mrgreen:
cartucho-duplo-slot-72-e-60-pinos-roger-rabbit-original-nes-D_NQ_NP_667582-MLB26596058497_012018-F.jpg
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Is NES/Famicom detection possible?

Post by tepples »

Untested code, condensing the results of Riding the open bus:

Code: Select all

  ; The PPU is mapped at $2000-$3FFF.  (Addresses $2000-$2007 are
  ; unique; $2008-$3FFF are mirrors.)  The PPU contains a dynamic
  ; latch called "io_db" in Visual 2C02 and "PPUGenLatch" in FCEUX,
  ; which holds the last value written to any PPU port.  Reading a
  ; write-only PPU port, such as the VRAM address ($2006), returns
  ; the value of io_db.
  lda #$FF
  sta $3F16  ; Fill $3F16 (i.e. $2006) and io_db
  sta $3F16  ; write twice because that's conventional for $2006
  cmp $3F16  ; read io_db
  bne io_db_not_supported  ; NOAC clones may implement io_db wrong

  ; The next read is tricky.  When doing an indexed read that crosses
  ; a 256-byte boundary, 6502 adds the index to the low byte mod 256
  ; and then fixes it up next cycle if there was a carry.
  ; Thus $3FF6 + $20 reads $3F16 then $4016.  The $3F16 read
  ; precharges the data bus with io_db.  Then the $4016 read changes
  ; only those controller port bits that are connected to something.
  ; CAUTION: Open bus works differently on some flash cartridges.
  ; The PowerPak has pull-up resistors that continuously precharge
  ; the data bus with $FF.  But because this is the same value we
  ; stored in io_db, it will not change the test result.
  ldx #$20
  lda $3FF6,x  ; reads $3F16 then $4016

  ; Bits 3-4 are open bus on a Famicom but driven on an NES based
  ; on two wires of controller port 1, and usually driven low.
  ; They probably won't both be true on an NES unless a Zapper is
  ; plugged into port 1 and the trigger is half-pulled.
  and #$18
  cmp #$18
  beq is_famicom
is_nes:

Post Reply