Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Yuzu (Nintendo Switch Emulator) Progress Report January 2021 (yuzu-emu.org)
369 points by Parseus on Feb 10, 2021 | hide | past | favorite | 89 comments


For someone that's been following Dolphin's progress for so long it's really amazing that there's already a pretty well done Nintendo Switch emulator.


It shouldn't be. The hardware and software development toolsets used by modern game systems get ever-so-closer to commodity PC hardware with every market cycle. Older hardware is actually harder to emulate than newer. NES cartridges had their memory controllers built into the cartridge. The newer ones used by games such as Castlevania 3 are imperfectly understood and many games still have crash glitches. Only roughly half of these controllers were made by Nintendo and not all of the ones that weren't were licensed. The situation with the SNES is in some ways better and some ways worse.


bsnes is the gold standard in accurate emulation.


The wii and gamecube had only CDs for storage so it doesn't run in to that issue.


They have their own very special requirements. For instance their equivalent of shaders are able to be changed much more quickly than PC architectures's GPUs generally allow.


But dolphin emulator enthusiasts mitigated that by creating huge shader caches by playing the games for hours, and then saving the shaders.


I don’t think they use shader caches anymore? Unless something changed since 2017?

https://dolphin-emu.org/blog/2017/07/30/ubershaders/


Great story, I enjoyed reading this, thanks for sharing.

> Mali on Android: Not tested. We can safely say it wouldn't end well, though.

This brings memories; my canvas webpage had a number of problems with android mali devices.


The gamecube used mini-dvd and the wii used dvd


There are even two actually! Yuzu and Ryujinx. They are both unique codebases and both support games to differing degrees.


Does anyone have any links to blog posts they consider good descriptions of what goes into making a game console emulator?

I am super impressed by the content of this post, but I bet there is also a lot that is going over my head that I am not even aware of.


I’ve recently been working on a Gameboy Color emulator in Rust[1], mostly as a learning project, and it has been an absolute blast! I’ve never enjoyed working on a project this much to be honest - it’s very satisfying to gradually see your emulator run games developed for another system, especially if it’s a system you’ve personally used in the past.

In my opinion, the best way to learn how an emulator works is to start writing one. /r/emudev and the emudev Discord (see subreddit sidebar) are a great place to start. The Discord in particular is great: it’s split into channels for each system, and there are a ton of pointers to resources for all systems in the main channel.

As far as consoles go, the typical recommendation is to start with CHIP-8. It’s a straightforward system with a very simple design, which makes it relatively easy to emulate.

[1] For the curious: https://github.com/aksiksi/gbc


There must be hundreds of Gameboy emulators now. I guess it's the equivalent of "Hello World" for emulators.


I think CHIP-8 is a better candidate for that title. But yes, Gameboy emulators are quite common.


Infocom Z-Machine? Probably even simpler to implement since it was designed to be emulated.


Pretty sure the word "emulation" doesn't apply. The Z-Machine never had hardware to be emulated, only a virtual machine to be implemented. Ditto CHIP-8 though.

For emulating a real system, the Gigatron would be relatively simple. The hard part would be the display because it is bit-banged into NTSC.


Been there, done that!

And it was a blast.


I agree for older machines this is a great approach. A lot of the challenge is being organized and persistent, powering through all the opcodes and making sure they're accurately implemented. I made a Sega Master System emulator many years ago and it was a fun project.

I do wonder how one takes on modern machines though. It seems like it'd be a completely different ball of wax.


Modern game consoles have a lot of common library / OS system calls that instead of emulating you re-create those calls and make your own implementation with the expected return values. The low level stuff and shader translation aspects are very complicated though.


Oh definitely, writing an emulator for a modern system is an entirely different ballgame. I truly respect the dedication and skill of the people behind large emulator projects like PCSX2 and Dolphin.


> it’s very satisfying to gradually see your emulator run

This does sound like fun. I feel like I’ve had a similar experience in porting and refactoring legacy code, and each successive step forward unlocks more and more cool stuff


https://cturt.github.io/cinoop.html

Basic overview of a GameBoy emulator. Far cry from the complexities of a Switch, but still a great writeup by cturt.


I wrote up a series [0] documenting a CHIP-8 emulator I wrote that I hope explains how to get something like this working from the ground up, albeit for a much simpler system.

[0] https://river.codes/emulating-a-computer-part-1/


If you want to get into writing emulators yourself, I'd recommend starting with the CHIP-8. I just wrote one in C# and it was pretty easy, still need to properly handle input and rendering though (I'm currently saving the display output to a bitmap after every draw call)


If you’ve got a bitmap you’re almost there, you can stream that bad boy over the bus to SDL for rendering.


Dolphin (wii / gc emulator) blog is great: https://dolphin-emu.org/blog/



There are some pretty good YouTube videos on the subject, worth a search


Apparently, a lot of indie developers do well on switch for some reason. Breaking even is so hard for most indies that it sort of made me sympathize with the console model at least a little bit more


It was a gold rush at the start due to lack of market saturation (I remember having my new Switch and being able to peruse the entire store in 15 minutes). It's now approaching Steam levels of saturation / shovelware.


I'm not sure it's that bad -- every game I've seen on Switch has been, at the very least, a functional game with effort put in. I think it's simply that there are too many games.


While a lot of games on Steam (I don't know about Switch) are shovelware, at the same time we live in a golden age of (indie) game development, with so many great titles coming out every year - some of which only get discovered years after the initial release (like last year's Among Us).


The golden age were the 8 and 16 bit days, where game genres were yet to be invented and publishers were keen to take anything that came their way, and we were creating stuff that were told the hardware wasn't capable of.

Modern games, in whatever form, most of the time are just watching yet another x-men remake.


> The golden age were the 8 and 16 bit days, where game genres were yet to be invented and publishers were keen to take anything that came their way, and we were creating stuff that were told the hardware wasn't capable of.

None of that is true though. It's just the rose tinted glasses one wears when looking back at the games one grew up with and loved.

> where game genres were yet to be invented

Actually by the 16-bit era quite a number of genres were already really well defined. This was even true for the 8-bit era for some genres (like platformers, maze games, etc).

> publishers were keen to take anything that came their way

That very much depended on the publisher -- just the same as it does now (some publishers will buy any old indie crap and others are more selective). And it wasn't just publishers who were known to reject games, Sega Japan were famously strict about the titles they'd allow to be licensed on the Mega Drive. It was Sega America who allowed any old release to be licensed.

> and we were creating stuff that were told the hardware wasn't capable of.

That's selection bias. There was a lot of mediocre titles around too. Many of which didn't push the hardware or was less creative about the use of hardware resources. But people tend to remember the more impressive titles, in part because they have aged better, but also literally because they had that "wow" factor.

> Modern games, in whatever form, most of the time are just watching yet another x-men remake.

The 8-bit and 16-bit era had their fair share of copy cat games. When Mario Bros was a hit everyone seemed to jump on the bandwagon to make a Mario clone. There were hundreds of Pac-Man inspired games (and Pac-Man itself wasn't the first game of that style). Not to mention all the side scrolling shooters, JRPGs that are almost identical from one another, etc. Even popular games like Galaxian was themselves a knock off (eg Space Invaders). And don't get me started on the number of Space Harrier and Outrun clones on the Famicom.

Even copy cat games aside, most successful games saw sequals (and even many unsuccessful ones). Alex Kid had 4 games. Wonderboy had 3. There are around a dozen 8/16-bit Sonic games that are 2D platformers (ie not counting Sonic 3D Blast and Sonic Pinball) and Mario has even more titles to it's name.

Don't get me wrong, I do love that era of gaming. In fact I'm a massive collector of the original hardware and have ~20 consoles (including some obscure ones) still hooked up in a spare room...all of which still get regularly played. You could say this is a big passion of mine. But with that it does mean I also see my fair share of shelf fillers -- and they do outnumber the classic titles despite what your fond memories of the era tell you.

As for what the golden age was, well that's subjective and likely whoever you ask will say it's the era they grew up in. Each new generation of gamers have seen a new paradigm in gaming and that's what they'll remember fondly.


> Sega Japan were famously strict about the titles they'd allow to be licensed on the Mega Drive. It was Sega America who allowed any old release to be licensed.

I didn't know that about Sega in Japan; usually when I think of strict licensing I think of Nintendo of America, the 10NES chip and Atari v. Nintendo [0].

> When Mario Bros was a hit everyone seemed to jump on the bandwagon to make a Mario clone.

You're on the money here. I'd argue this pattern repeats through a number of industries; some clear examples in automotive are the 'Pony car', Minivans, and the Grill style of the Aston Martin DB9 (okay, last one's a stretch).

[0] - https://en.wikipedia.org/wiki/Atari_Games_Corp._v._Nintendo_....


> None of that is true for the 16 bit era.

It surely was, if you were attending Assembly, Breakout or any variant of them.

You seemed to only have lived through game consoles.


> You seemed to only have lived through game consoles.

Why are you always so presumptuous and obtuse in your responses? It's needless and unproductive.

No I haven't just lived through games consoles. However I focused my point on games consoles because we're talking about the "golden era of gaming" on a thread about a games console emulator. Clearly focusing my point on games consoles was the logical response contextually speaking. However I'm happy to debunk your bullshit with a dozen counterexamples on 8-bit microcomputers, 16-bit personal computers or IBM-clone PCs. As it happens 70s and 80's home computers was the golden era for me as a games developer and I converted to games consoles later in life. Or maybe you want counterexamples of games written on main frames, programmable calculators, or 70's kit computers?


Atari ST and Amiga would do, if you are so kind.

Maybe with some bonus points for Arcades.


You could copy and paste most of my post and apply it to both of those contexts too quite easily. They weren't mutually exclusive industries. Quite the opposite in fact.

Take the Atari ST and Amiga for example, the amount of crossover games between consoles and those two computers is so big that many gamers considered those computers to be consoles in their own right (I know they're technically not correct but it does illustrate just how big the crossover library was).

As for arcades, they were often the worst for milking genres. How many Street Fighter clones were released after SF2's success? The Galaxian/Space Invaders example I made previously are arcade titles. Same with Space Harrier and Outrun...massive arcade titles who's formula got copied over and over (to be fair, Outrun wasn't even the first arcade racing game of its ilk to hit the arcades either). Then there's Streets of Rage / Double Dragon / Turtles in Time / etc. All pretty formulaic brawlers and there were hundreds others just like them. NeoGeo is another example of a publisher releasing a library of similar arcade titles. All of these are massive names too, so just think about how many similar games made it into arcades but weren't so successful that you still remember them these days.

That all said, one thing the Atari ST and Amiga were better at was innovative early 3D titles. There were a few really interesting mouse controlled 3D games that wouldn't have been possible on your traditional 80s/90s console. But those titles were far far far outnumbered by generic games (and "generic" here doesn't mean "bad").


There are some pretty awful games on there too. If picked up a couple of retro-inspired games that were on sale for ~£1. Turned out their sale price was about all they were worth.

There was also a glut of mobile games that were ported to the Switch quite early on.

That all said, I have generally been happy with the quality of the games on that platform. Initially the best titles were Nintendo's own IP (to be expected) and RPGs with a few good indie titles. But now there's a real plethora of good games ranging from shorter indie titles through to AA-quality games (albeit not on the same scale of Playstation 4 / Xbox One -- but that's to be expected given the different hardware platforms). Plus more than enough older titles re-released to keep your average retro-gamer happy.


That's an impressively good and interesting writeup.

It's even written in a way that non-technical users will understand, even when it does get technical.

I'd call this the gold standard of patch/update breakdowns.


Dolphin started this tradition years ago and now many emulator projects are doing it


If curious see also

Related from 2018 https://news.ycombinator.com/item?id=16150777

A bit from a few weeks ago https://news.ycombinator.com/item?id=25522454


It's really impressive how quickly new devices get emulated these days.


The Switch also benefits from a nearly complete open-source reimplementation of the full operating system and kernel.

https://github.com/Atmosphere-NX/Atmosphere


I am more annoyed than I should be that the accents faces in a different direction for fusée…


To be fair it's not the same sound


That's a patch set for an official OS, not a "nearly complete open-source reimplementation of the full operating system and kernel".


No, it's a nearly complete open-source reimplementation of the full operating system and kernel. I don't know where you're getting the idea that it's a patch set - you can take a look at the roadmap and design docs here (or just browse the source) if you'd like.

https://github.com/Atmosphere-NX/Atmosphere/blob/master/docs...


The readme literally lists a couple driver changes to make CFWs easier, breaks in the boot and crypto chain of trust, and "Application-level Horizon OS patches, used to implement desirable CFW features".

That's not a "nearly complete reimplementation".

A bunch of not started work in a planned features doc doesn't change that.


If you scroll down in the document you'll find the completed section, which includes the Kernel.


It's a very ascetic ukernel, which is a very tiny piece of a horizon derived OS. Like, single digit percentages from a LOC perspective.


The switch was actually a special case, most of the APIs (the nvidia ones) where already decently well understood and the OS was based on the 3DS OS. The yuzu dev team still did an amazing job.


Also, it has hardware specs that make it reasonable to emulate. You're very unlikely to see a PS5 or Xbox Series X emulator anytime soon.


Would you even need to emulate PS5/XSX games? AFAIK, they are already x86 - you would just need provide the library APIs and break the security.


This is a pretty common and old idea, dating back to the original xbox, which was basically "just" a normal pentium processor with an nvidia gpu.

For various reasons, though, this sort of emulation has a lot of pitfalls. Either you directly run a lot of the console's firmware and e.g. try to implement the hardware devices in QEMU, or you try to recreate the console OS/firmware at a higher level, mimicking the underlying APIs. Neither are easy tasks. Take a look at the original xbox -- the emulators available aren't really great, even after nearly 2 decades of hard work.

Of course, any complex emulator is hard -- just pointing out this isn't really as much of a shortcut as it may seem. The biggest upside is just (potentially) performance, as you don't need to interpret or translate CPU instructions.


I don't think your statement about 2 decades of hard work on OG Xbox emulators is totally correct - the real focus on emulation only began in the mid 2010s. It's lack of exclusives also results in a lack of emulator developers.


That's fair -- development has been off-and-on, and there's not much of a desire for xbox emulation.

Still, I think it's a good example of how just because the xbox is basically a regular Pentium III system with a modified GeForce 3 GPU, doesn't mean it's easy to make an emulator for. And the original xbox was more "PC-like" than the PS4/5 or current xbox lineup, I'd wager.


There's more to hardware architecture than just "x86". The PS4 memory bus is completely shared between CPU and GPU, meaning that addresses on one are valid on the other. Emulating that on a general-purpose system with PCIe would be astonishingly ridiculous.


>Emulating that on a general-purpose system with PCIe would be astonishingly ridiculous. Even official PC ports suffer from that. For example Horizon Zero Dawn looses up to 20% of performance if ran on 8x PCIe 3.0 lanes.


These consoles have A LOT of custom hardware(e.g. PS5 kraken hardware decoder, with which they can have ridiculously high SSD bandwidth, at peak levels much higher than anything on the consumer market right now). Brute-force approach won't work on modern PCs.


People said the Xbox one was just a Windows PC with a proprietary UI as well, but you really have to understand what went into making it before you determine if that’s true:

https://youtu.be/U7VwtOrwceo

But yes, if you could break the security and implement the (many) private APIs, you wouldn’t necessarily need to emulate (although it might be legally and technologically easier to emulate a ps5 than re-implement everything).


Nice talk, thanks for linking!


Do both Nintendo 3DS and Nintendo Switch use an ARM processor?


Yes, but different feature sets


Different instructions sets? Where can I read more about this?


They’re entirely different ISAs, for the most part. 3DS uses a 32-bit ARMv11 core (and an ARMv9 for compatibility) and Switch uses a 64-bit Tegra X1 based on ARMv8-A.


The "v" is confusing - the 3DS used ARM11 and ARM9E core designs, which implemented the ARMv6 and ARMv5 ISAs respectively.


Oops, I didn't mean to do that! Thanks for catching it.


Yes, and the Switch OS is based on the 3DS OS.


It's not that easy. I read somewhere the graphics pipeline of the Switch OS is a derivative work from Android's.

It's not clear HOW much of it comes from the 3DS OS, how much comes from FreeBSD and how much comes from Android.


Where was the Nvidia APIs documented from?


The Switch GPU is basically just an Nvidia Tegra, and the work on the open source Noveau driver for Nvidia cards made it easy to figure out the Switch's Tegra


Nintendo Switch used the Tegra X1 model T210 SoC, also used in the Nvidia Shield and Pixel C. There's plenty of public information as well as support code in the Linux kernel


Ahh, I guess the emulator is not emulating the switch "API" but the GPU itself right? Because AFAIK, the Switch NVidia API is not avaliable anywhere publicly.


Like most consoles, the switch graphics API (NVN) is a very thin veneer over the hardware. Understanding the hardware tells you a lot about the API.


The Nintendo Switch turns 4 next month.


Exactly. I remember UltraHLE was less than 4 years after the N64.... and it was a more alien architecture...


Was something like 2.5 years!

In this era where convenience is super important it's less of a deal but when a not especially powerful PC could emulate the key N64 games and the games were both downloadable via dialup (Mario 64 was like an hour long download iirc?) at a point when they were $70 in shops... Just absolutely mindblowing stuff for the time really, especially if you were from a place like me where you'd have to get a long train journey to the nearest city to get these games.

That being said, I was far too into SNES games at the time and found the analogue controls painful via keyboard to ever look into it that much.


I once chopped and moved an Ocarina of time rom via 24 3.5floppies to move it to a system with a beefier video card in the days before I had access to a CD burner.


Yes, but this would not have been something common for the era. Very late 90s I already had a 32MB flash card and PCs were starting to lose the floppy drive.


I had a diamond rio with 16mb internal with an 8mb expansion from an older digital camera. 32MB flash back then was $$$$.


Doubt I even seen a flash card until 2002 or so. Floppy disks were still being used in my school up into the middle of the decade.

CD burners only seriously ramped up in ubiquity in 2000 or so too; they very quickly became common place


Switch is a 4 core 2GHz cpu and a gpu. What techniques do they use for realtime emulation of games for this machine? JIT compilation?


A sidepoint, obviously irrelevant to the technical feats of Yuzu, is that one of the main draws for me about the Switch is that it allows me to leave the computer and desk at which I sit 90% of my waking life, especially these days. That alone is worth using the real hardware and not emulating it.


Check out the GPD Win devices, they are basically handheld x86 PCs running Windows 10 (you can install Linux too). The third one was announced recently (i'm not sure if it is yet available) and is quite good (also has a more Switch-like design while the others are more like tiny laptops) - here is a video of Linus from Linus Tech Tips gushing over it: https://www.youtube.com/watch?v=3LclRTo2YnQ

One issue they have is that they're expensive (the earlier ones can be found for cheap, note however that the first one might have some battery issues) compared to the Switch, but on the other hand they are not susceptible to planned obsolescence and extreme locked down environments like pretty much all consoles are: you can run any game of the gigantic PC game library there (assuming the specs are met... of course :-P) and new games will be released for pretty much as long as the hardware can function.

Here is me using mine with an unfinished version of an MS-DOS game jam game (i had to put my tablet between me and the handheld to record it hence the awful controlling): https://www.youtube.com/watch?v=BF8WqllGKg8

(yeah they're also neat demo devices :-P)


Yep, the separation from the rest of your stuff is probably the main draw of a Switch if I were to get one right now. Similarly to how I rarely use the Oculus Link functionality on my Quest 2, it's just nice to have a device that feels independent of my work station.

Was just messing about with CEMU yday and found I could play BOTW in 4K at 60fps on my computer, it looked absolutely beautiful compaired to playing on my Wii U but I can't see myself being able to settle down and play on that machine.

I also think having access to so much stuff has made the hassle of tinkering not worth it for most people. Can remember back as a kid with dial up how I would relentlessly fine tune configurations to get some emulated games to a playable state, the slightly bit of lag on an emulation now and I'm like "crap, is this gonna keep happening? can I be bothered enduring this??"


Get a good controller and use the Steam Link app as a cheap and easy way to extend your PC to wherever you have good wifi. I have a Razer Kishi and it delivers a very good switch-like experience.


I don't have a smart phone though.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: