
How SNES emulators got a few pixels from complete perfection - turbohz
https://arstechnica.com/gaming/2020/04/how-snes-emulators-got-a-few-pixels-from-complete-perfection/
======
byuu
Hi all, thank you for sharing this article here! It is technically a
"laymen's" version of [https://byuu.org/articles/edge-of-
emulation](https://byuu.org/articles/edge-of-emulation) (submitted here
earlier), meant for a wider audience, but it does elaborate on some new
discoveries such as the digital video output testing mode.

In the off chance anyone is able to help with this, I've set up a Discord
channel (#ars) for coordination here:
[https://discord.gg/Fx7TfKh](https://discord.gg/Fx7TfKh)

Every member of the bsnes-emu project is on said server.

Thanks so much!

~~~
greggh
I'm sure the answer is no, but I emailed a few people at NERD (Nintendo
European Research & Development). Asked the obvious question about the
documentation even existing anymore, and if there were any possibilities of it
ever being made public.

You've probably done that already, but I figured it was worth a shot. I'll
update if I actually get a response.

~~~
NobodyNada
Nintendo's official development manual is available at archive.org [0].
However, AFAICT it is rather low-quality and incomplete, and it pales in
comparison to the wealth of documentation created by years of reverse-
engineering effort from hobbyists like byuu.

I imagine that the official documentation was leaked rather than publicly
released. Nintendo wants to make money selling re-releases of classic games,
so they are extremely unfriendly towards emulator developers. Just look at the
all the propaganda on their corporate website: "The introduction of emulators
created to play illegally copied Nintendo software represents the greatest
threat to date to the intellectual property rights of video game developers
[...] Such emulators have the potential to significantly damage a worldwide
entertainment software industry which generates over $15 billion annually, and
tens of thousands of jobs." [1]

[0]:
[https://archive.org/details/SNESDevManual/mode/2up](https://archive.org/details/SNESDevManual/mode/2up)
[1]:
[https://www.nintendo.com/corp/legal.jsp](https://www.nintendo.com/corp/legal.jsp)

~~~
tgsovlerkhgsel
I would assume that from a practical standpoint, the SNES emulation 'war' is
lost for all practical definitions of it - pirates can run everything they
want in more than sufficient quality using any of multiple options.

So Nintendo doesn't have much to lose by letting the few geeks that want
perfection for perfection's sake have it.

~~~
naniwaduni
Third-party SNES emulator are _more accurate_ than Virtual Console.

~~~
lostgame
Wasn't Sony caught using an open-source PS1 emulator for their recently-
released(ish) Playstation Mini?

~~~
DCKing
I don't think "caught" really is the proper word to use, when they credited
the PCSX-Rearmed project in the menu of the Playstation Classic. It might be
considered somewhat embarrassing they didn't make their own better emulator (I
guess?), but it's not as if they were actively hiding it either.

~~~
lostgame
Yeah, I meant 'caught' as in they were caught in that they couldn't do better.

~~~
rcfox
Shouldn't this fact be celebrated rather than shamed? PCSX-Rearmed gets
immense validation, and Sony doesn't waste years of engineering time
reinventing the wheel.

------
FillardMillmore
Interesting tangent from the article:

>Today, SNES emulation is in a very good place. Barring unusual peripherals
that are resistant to emulation (such as a light-sensor based golf club, an
exercise bike, or a dial-up modem used to place real-money bets on live horse
races in Japan), every officially licensed SNES title is fully playable

I had to look up the 'dial-up modem' reference - apparently it's a Japan-only
peripheral called the "Famicom Network System" that did in fact have software
available that allowed for bets to be placed on live horse races.

[https://en.wikipedia.org/wiki/Family_Computer_Network_System](https://en.wikipedia.org/wiki/Family_Computer_Network_System)

[http://niwanetwork.org/wiki/JRA-PAT](http://niwanetwork.org/wiki/JRA-PAT)

~~~
matheusmoreira
A brazilian bank released software for the Mega Drive. Looks like it could
display the accounts as well as manage investments and credit cards. Wonder
how many people actually used this...

[https://segaretro.org/Telebradesco_Residência](https://segaretro.org/Telebradesco_Residência)

[https://www.sega-
brasil.com.br/Tectoy/Telebradesco_Residenci...](https://www.sega-
brasil.com.br/Tectoy/Telebradesco_Residencia_para_Mega_Drive)

[https://www1.folha.uol.com.br/fsp/1995/3/22/dinheiro/26.html](https://www1.folha.uol.com.br/fsp/1995/3/22/dinheiro/26.html)

~~~
kzrdude
I wonder what the security solution was, assuming this didn't use SSL/TLS

~~~
cesarb
The security solution was probably that the user had to type the account's
PIN, and that it uses the phone line instead of the Internet. It's from 1995
(check the date of the Folha de São Paulo article above), not using encryption
at all was very common back then; and even today, phone lines are still
considered reliable enough that one can type the account PIN on it without any
encryption (for instance: if I want to solve any issue with my credit card
through the phone, I _must_ type the full number on the card _and_ the credit
card PIN before the URA will connect me to an operator).

~~~
flatiron
Faxes are unencrypted and send medical crap all the time today.

~~~
shakna
Most fax machines today aren't actually sending faxes - they're sending
emails, using SSL.

~~~
wolrah
As someone who works in the telecom industry and has to deal with faxes in
medical facilities all the time, no they're not. I fucking wish they were.

I beg people to use e-fax solutions if they insist on using fax at all, but
there are so many damn human macros out there who learned how to do something
one way and totally break down if you try to make them do something different.

Annoyingly while most modern fax machines are also network printers and
support email in both directions, the majority do not provide any way to
configure a mapping so that a user can type in a number like a normal fax
machine and the machine will convert it to the required email format for an
e-fax service. This would be so easy and solve so many problems.

------
geofft
The linked story about Higan's NEC uPD772x emulation being used by Stephen
Hawking is pretty amazing, both as a story in its own right and as a parable
about the value of open source and code getting used in wildly different
contexts from what it was originally designed for:
[https://www.sfchronicle.com/bayarea/article/The-Silicon-
Vall...](https://www.sfchronicle.com/bayarea/article/The-Silicon-Valley-quest-
to-preserve-Stephen-12759775.php)

------
nullc
It's sad that Nintendo doesn't seem to see this as an opportunity to earn free
press and goodwill by simply releasing all the design documents, mask images,
etc.

The community is going to get there eventually without their help, but they
could probably make it much faster and cheaper to get there.

Doubly so because they sell products which almost certainly benefit from these
open source emulation efforts.

~~~
kingbirdy
Nintendo is still actively selling SNES games via Nintendo Switch Online, and
as far as I know rolls their own emulator(s) for this rather than using
existing open source ones as Sony did for the PS Classic, so I doubt this will
happen any time soon.

~~~
scrooched_moose
Tangentially related, there's some evidence the ROMs Nintendo was selling a
couple years ago were ones they downloaded. Not bulletproof, but more likely
than not.

[https://www.eurogamer.net/articles/2017-01-18-did-
nintendo-d...](https://www.eurogamer.net/articles/2017-01-18-did-nintendo-
download-a-mario-rom-and-sell-it-back-to-us)

~~~
aikinai
I can almost guarantee Nintendo did not use a downloaded ROM. I don’t have
direct experience with how the ROMs are sourced, so it’s not 100%, but I
worked on a team handling emulation at Nintendo and can say the processes are
incredibly careful and strict.

The company is extremely micromanaged and pedantic, and this is not the kind
of thing that could possibly be overlooked at Nintendo.

~~~
monocasa
It's just weird then that they put a header originally defined by pirates, and
now otherwise only used by third party emulators. Including matching the even
more informal parts of the header byte for byte with the most common dump of
the ROM on the high seas.

~~~
derefr
I mean, you'd want to use a file format that would allow you to cross-test
your emulator's behavior on the same ROM files against existing emulators'
behavior on those ROM files. So you'd format your ROMs (which you dumped
yourself) the way that existing emulators would expect them to be formatted.

~~~
monocasa
Sorry, I was being a bit coy when I said the "more informal parts of the
header". It literally still has the dumper's signature in the unused portion
of the header. Traceability as to who gets props for the first good dump
drives a lot of decisions in that scene.

~~~
hcs
Could you be more specific? I've heard this mentioned before but not seen an
example. Something like one of those Diskdude! strings? What game?

~~~
NobodyNada
[http://wiki.nesdev.com/w/index.php/INES#Flags_10](http://wiki.nesdev.com/w/index.php/INES#Flags_10):

> Older versions of the iNES emulator ignored bytes 7-15, and several ROM
> management tools wrote messages in there. Commonly, these will be filled
> with "DiskDude!", which results in 64 being added to the mapper number.

~~~
hcs
That would surely be a giveaway, but I haven't seen any evidence that tagged
headers like this were actually used in official Nintendo releases.

------
userbinator
_And so the final, most extreme approach, would be to expand upon our
decapping efforts. We have 20x die scans, but the resolution is not enough to
make out and reconstruct individual logic circuits from them, such as was done
with the Visual 6502 project._

That was done with the NES too:

[https://github.com/SourMesen/VisualNes](https://github.com/SourMesen/VisualNes)

~~~
Cyberdog
> It combines both simulators into a single simulation and allows the
> simulation to run NES roms (albeit at roughly 1/1000th of the speed of a
> real NES)

What is this emulator doing that causes it to emulate so slowly? Even if it's
doing perfect emulation, are modern processors still so slow that they can't
emulate a couple 35-year-old processors at something closer to real time?

~~~
zeta0134
Visual 6502 emulates the CPU not just at a logical level (performing
equivalent instructions) but at a _silicon_ level, simulating each transistor
in the original chip at an electrical level as closely and as accurately as
possible. This is _far_ more intensive, as there's a whole bunch of state to
maintain and thousands upon thousands of tiny components that need to remain
in perfect sync. Of course the goal here is not to run the processor at
anything resembling real-time speeds. Quite the opposite; the developers have
created a marvelous way to slow down the components so that humans can observe
each tiny step, which normally takes a fraction of a fraction of a fraction of
a second on the physical chip.

------
kingbirdy
If you found this interesting, the author's website has a number of
informative, in-depth articles about emulator development & console
architectures: [https://byuu.net/](https://byuu.net/)

------
Razengan
I just want to say that some of the most fun I’ve ever had on the PC has been
in a SNES emulator. The sheer variety, depth, hours of content, ease of
accessibility, and great music has been nearly unmatched on most other
platforms.

I highly recommend anyone with an interest in games to grab a bunch of ROM
packs (including Japanese exclusive games and fan translation hacks) and spend
some of your quarantine on the SNES.

~~~
smabie
Especially Chrono Trigger! That game is amazing!

~~~
scandinavegan
I really want it on the Switch! I played the emulated version on PC, and I
know it's now available on both Steam (I heard that they fixed the broken
early version) and mobile, but it would be very convenient to have it on the
Switch. I read that due to licensing it's unlikely to show up in SNES Online,
but I don't see why they don't release it as a separate game.

They don't need to remaster or remake anything, just release it as is, and I'm
sure it would sell well. I would anyway prefer the original with original
graphics and soundtrack to a 3D remake or similar.

~~~
scott_s
The DS version is an excellent port - much better than the Final Fantasy ports
to the GBA, because they didn't have to compromise on the resolution. It's
selling for about $55 now.

(Yes, I know this is quite different than having it on the Switch, but I
mentioned it in case you have a DS and wasn't aware.)

------
ilaksh
On the last extreme idea, it seems one thing to do for starters is to get the
100x magnification of the PPUs from someone and put it in the GitHub repo.

Then anyone who has the ability to start converting that to VHDL or any sort
of identification of components can start on part of it and contribute to the
repo.

With some started, it may be possible for less expert people who have a little
bit of VHDL or whatever to contribute to some degree with expert supervision.

------
terrycody
Admiration to those people like byuu write emulators with their devotion, if
without them, we have no today's splendid retro culture.

------
jancsika
Is there any SNES emulator that runs on arm?

I've got retroarch v1.3.6 on Stretch on aarch64. It has crashed with a "file
not found" and "bus error" for bsnes. Higan segfaults when I try to run it.

~~~
rm445
Not helpful to you except as an existence proof, but you can install Retropie
on a Raspberry Pi and it will play SNES ROMs fine. I believe the emulator is a
variant of SNES9x.

------
knorker
Error in the article: 32x32bit multiply (i.e. 2^64 bits) is not a "heat death
of the universe" thing.

It's a lot, yes. Not practical for these purposes. But there's a reason we
don't use 64bit encryption.

64bit encryption is easily brute forced.

If you want to keep it in a table, sure that's 18 exabytes (multiplied by
element size in bytes), but that's _before_ compression. I imagine multiply
output compresses _very_ well. And that's a lot of RAM. But not anywhere near
"heat death of the universe" amounts.

I bet FAANG easily have that much RAM. Each of them.

~~~
nullc
Performing those 2^64 operations on the original SNES hardware as would be
required to profile its unknown behavior, on the other hand...

~~~
knorker
Ah, yeah I see now.

------
smprather
Has Nintendo released officially, or leaked, the RTL for any of the processors
in the SNES? If someone could get their hands on that, then the emulation
authors should be able to achieve perfection.

~~~
smprather
Looks like some people are trying to re-create it at least.
[https://github.com/srg320/FpgaSnes](https://github.com/srg320/FpgaSnes)

------
intellix
I'm sure that I was playing Zelda Link to the Past and Super Metroid without
any problems about 20 years ago. What's changed since then? I thought this was
already solved :) apologies for my ignorance

------
TAForObvReasons
Nintendo Switch Online subscription includes an "official" SNES emulator. How
does it compare to BSNES, and would a decompilation of the emulator help with
resolving the PPU issues?

~~~
delroth
Nintendo's emulators are usually equivalent to what the state of the art was
15-20 years ago. They have plenty of bugs, usually fixed with duct tape and
game specific hacks. They are designed to run the set of games they sell and
nothing else -- once you get out of what the QA team has explicitly tested,
it's not uncommon to find unemulated or badly emulated hardware features.

~~~
derefr
Also, when you think about it, if a game behaves differently when run in an
emulator, as part of an emulator-and-ROM bundled software product released by
Nintendo... then that behavior is just how that particular _release_ of the
game has been _canonically chosen to behave_. Any bugs in the emulation of a
Virtual Console title, or a SNES Classic title, or a SNES Online title, are
just "how that version of the game _is_." Much like any typos in a particular
printing of a book are "just how that release of the book is." They're now
part of the _authorial intent_ of that release; part of the _text_. If you
later ported _that_ game, you'd seek to be bug-for-bug compatible with the
bugs introduced by that emulator, because those bugs are what Nintendo
released, and so those bugs are now, in part, what it means to play _that_
game.

Or, to put that another way: there's no real difference between a bug
introduced by wrapping a game in an imperfect emulator, and a bug introduced
during recompilation/porting/remastering of the game. Either way, you now have
a new "variant" of the game with its own bugs, but one which is also a
canonical, supported release of the game.

Interestingly, sometimes—because of one of these slight variances—the fastest
[and so preferred] version of a game to speedrun, is a Nintendo-sanctioned
emulated (e.g. Virtual Console) release of the game. It says something
important, I think, that these releases of the game aren't automatically
shunned by the speedrunning community, the way that runs of the game under an
arbitrary emulator on someone's PC would be; but rather are just treated as
their own separate category-set, in the same way the speedrunning community
differentiates different region releases, or version releases, or
port/remaster releases.

~~~
sjwright
I don’t agree. Canonical status is bestowed by the artist/author, not the
publisher, and certainly not a republisher. If Lord of the Rings is
republished with page 527 arbitrarily missing, that omission doesn’t become
canon.

~~~
willis936
Yes but if there was a second edition released by Tolkien, that would be
canon. There could have been changes in page 527, such as Sam and Frodo run
away to start a domestic life together, and it would be official. It would
also cause quite a stirring and fracture the community. You see smaller scale
scandals of the same variety everytime nintendo rereleases a poorly emulated
title. Copyright needs to be fixed.

~~~
ulucs
Canon is whatever your heart (or in the case of roms, the speedrunning
community) declares it to be. I'd previously be arguing for authorial intent,
but JK Rowling ruined it for everyone.

~~~
willis936
I agree that the community decides on what is canon. However, I don't think
anything can become canon. Fanfiction will always be splintered from canon
until it gets adopted and published by the IP owners. So, "Goat Simulator"
speedruns will always be performed on a version released by Coffee Stain
Studios, or whoever owns the game in the future. You could rip up the source
code, mod the game, whatever, and do speedruns. If it's popular then it's a
new category, but it won't be a "Goat Simulator" speedrun, it will be a "Goat
Simulator++" speedrun. What official version of the game the community decides
to use for the "Goat Simulator" category can be contentious, as the developer
could have a range of releases that change things significantly. Just look at
half life 2. The most popular category is the release version of the game
because you can fly around at mach 1.

------
xwdv
Can original SNES hardware play ROMs somehow?

~~~
montecarl
Yes! These are called flash carts (short for cartridge). Here is a popular one
for SNES:
[https://www.amazon.com/dp/B0052URJKM](https://www.amazon.com/dp/B0052URJKM)

Many people who stream older console games on twitch seem to use them as well
as people who like to play romhacks.

~~~
0xcde4c3db
Back when SNES was still current and flash memory chips were still relatively
small and expensive, there were "copiers", which a few SNES enthusiasts still
collect just like other vintage peripherals. These are larger devices that
contain a floppy drive, DRAM, save RAM, and the necessary logic to provide the
most common cartridge mappings. You would dump a cartridge to floppies and
then load it into the DRAM to play it. Well-known models include the Game
Doctor SF7 and Super Wild Card DX2.

~~~
jldugger
Also nintendo just straight up sold people carts you could flash with new
games at Seven-Eleven:
[https://en.wikipedia.org/wiki/Nintendo_Power_(cartridge)](https://en.wikipedia.org/wiki/Nintendo_Power_\(cartridge\))

------
lidHanteyk
It is interesting to me how some systems are easier to emulate than others,
and the ease of emulation seems to correlate somewhat with ease of programming
model. The infamous example which comes to mind even far beyond the SNES is of
course the Sega Saturn, while on the other end of the spectrum, Dolphin has
support for multiple consoles at once.

~~~
sprayk
Dolphin has support for two consoles: Gamecube and Wii. It supports both of
them because the architectures are extremely similar. I don't get what you
mean by "ease of programming model". Saturn/Playstation/N64 were the first to
have games programmed primarily in C with libraries provided by the system
developers. This generation is harder to emulate simply because the system
architectures contain more chips connected with wider buses running at much
higher clock speeds. All of those factors make low level analysis, like with a
logic analyzer, impractical. Another factor is the popularity of the system
and level of interest in emulation of the system. The original XBox is a good
example of this. Gamecube and PS2 have much more polished emulators because
they have more titles that interest people, while little effort is spent on
emulating the original Xbox (despite being essentially a PC) arguably due to
the lack of exclusive titles to make it worth it.

~~~
Polylactic_acid
Nintendo consoles seem to always have the best emulators, likely due to being
almost all exclusive games. Every nintendo console recently has had a working
emulator before the end of the consoles life. I remember nintendo ds emulators
adding support for games that had only just come out.

~~~
thristian
The other reason Nintendo consoles have the best emulators is because Nintendo
generally avoids cutting-edge technology, or at least they prioritise "simple"
and "cheap" over CPU and GPU performance.

Apart from the latest consoles (the Wii U and the Switch), the worst-emulated
Nintendo console is the Nintendo 64, which also had the strangest hardware
(RAMBUS RAM, a general-purpose GPU, etc.)

~~~
ridv
On that note about the N64, there is a project (created by a friend of mine in
college) that is looking to go down the cycle accurate route that the Byuu has
gone down with higan.

It's called CEN 64 and can be found at
[https://github.com/n64dev/cen64](https://github.com/n64dev/cen64)

Lots of work that still needs to be done but it's quite impressive!

