13 ms·
Experimental Nintendo Switch Emulator written in C#
- nicetryguy 6y agoIt's really coming along! It took Dolphin a few years to nail it but i'd imagine a near-perfectly emulated 4k switch in a couple years time.
- caslon 6y agoRyujinx isn't actually the only Switch emulator; between Ryujinx and Yuzu, you can emulate basically everything the Switch can do and play most of the games it can.
- Cyph0n 6y agoImpressive! Is this the first modern console emulator written in a GCed language, or even a language other than C++?
- pjmlp 6y agoNope, https://hackaday.com/2018/08/07/even-the-playstation-2-cant-escape-java/ https://hackaday.com/2018/08/07/even-the-playstation-2-cant-...
- whoisthemachine 6y agoThat's Java running on a console, not Java emulating a console.
- monocasa 6y agoThere were a slew of older JITing PSP emulators when it came out using C# that had modern architectures. It's a cute technique to bootstrap a JIT, using a JIT runime that people already can be expected to have. pspplayer might have been the first? I could be wrong there
- Orphis 6y agoI worked on Jpcsp a long time ago, PSP emulator in Java. It was the first emulator to manage to run a large amount of games. We had some crazy devs on it who even wrote a MIPS to Java bytecode JIT. It worked great... sometimes. We ended up running into lots of JIT issues as some patterns were unusual and not always properly handled by hotspot. Fun times!
- anthk 6y agoWould graalvm give a speed boost?
- p1necone 6y agoThe problems with GC'd languages are very exaggerated. I'm not surprised at all that this is performant in C#.
- userbinator 6y agoIt's mainly the horrible "enterprise" culture around them, which leads to ridiculous abstraction bloat and the associated increase in resource consumption.
- Cyph0n 6y agoFor game dev (and emulators!), the non-deterministic behavior of GCs can cause a lot of trouble, mainly because you have a fixed frame budget. That’s why it’s usually easier to just use a language where you can finely control when and where allocations take place. I’m sure there are techniques to work around this, but you’d then usually have to leave behind the “idiomatic” area of the language you’re using.
- rafaelvasco 6y agoYes, In C# you have to leave the idiomatic side somewhat to get the most performance. Though this is getting better in latter versions of C#, in which you get more low level coding features. But for me the fun part is doing exactly that. Coding as close to the metal as possible, leaving the "safe" side of C# but still using the Quality of Life features that C# offers compared to C++. That for me makes C# my favorite language ever.
- Const-me 6y agoI like C# and use it a lot, but for performance sensitive apps I need SIMD. Microsoft is making improvements, but not enough, still a long way to be comparable to C++. Currently, they don't support NEON on 32-bit ARM, and have performance issues in the JIT: https://github.com/dotnet/runtime/issues/13811 https://github.com/dotnet/runtime/issues/13811
- astrange 6y agoC# is one of the most popular languages to write games in (with Unity), so it can't be that bad. I'd expect it to perform well if you only allocate short-term objects, since it can do escape analysis and figure out they can all go on a stack, but I don't know how Mono's GC works.
- molticrystal 6y agoThis emulator currently has the most complete guest audio renderer implementations, as they just finished a project of doing an in depth reversing of that portion of the firmware. [0] Getting it to work with the host os(windows usually) can have minor issues with output in rare circumstances, or when a game is still not running the proper speed, but they've ironed out the major ones. ----------------------- This is my requiem, I present to you Amadeus, a complete reimplementation of the Audio Renderer! This reimplementation is based on my reversing of every version of the audio system module that I carried for the past 10 months. This supports every revision (at the time of writing REV1 to REV8 included) and all features proposed by the Audio Renderer on real hardware. [0] https://github.com/Ryujinx/Ryujinx/pull/1481 https://github.com/Ryujinx/Ryujinx/pull/1481
- dt3ft 6y agoAwe inspiring. 10 months of work and 250 changed files! Respect!
- DC1350 6y agoThis is great to see. It would be nice to play switch games on something at least as powerful as a modern phone
- barbazoo 6y agoAre you implying that the Switch hardware isn't good enough for its games? I have yet to play a game that doesn't run well. Maybe I should try Witcher 3.
- oogetyboogety 6y agoIt appears that many beg to differ with you https://www.reddit.com/r/NintendoSwitch/comments/lm5cvh/super_mario_3d_world_fps_issues_lag/ https://www.reddit.com/r/NintendoSwitch/comments/lm5cvh/supe... https://youtu.be/8FKUJaBCWdU https://youtu.be/8FKUJaBCWdU
- genewitch 6y agoall of the people were having issues with a patched game (version 1.1) - no idea if it ever got fixed or not, i don't have that game to test. Other than some weirdness on 3rd party games i've never noticed any slowdown on any games i've played.
- Grazester 6y agoThere are lots of Switch games that have had to have serious compromises made to run them. You need to checkout the youtube channel DFRetro that does a thorough analysis of the games between their various console releases. The switch is slow and old hardware but Nintendo was never going for state of the art and it serves its function well
- foobar33333 6y agoMario kart in 4 player mode can only run at 30 fps which looks horrific compared to the 60fps 2 player mode. Most games also seem to suffer from massive load times. Crash team racing and Animal Crossing clock in at literal minutes to load.
- politelemon 6y agoI wanted to say dupe, but I can't really... my submission got no attention. Is it just matter of timing? https://news.ycombinator.com/item?id=26445101 https://news.ycombinator.com/item?id=26445101
- brundolf 6y agoTiming makes a huge difference in my experience
- geswit2x 6y agoHow is possible to post duplicate links in HN? I think when you do that, you get redirect to the duplicate one, and upvote the old post...
- grzm 6y agoI believe it depends on the duration between submissions and maybe some other factors, such as votes and comments.
- brundolf 6y agoI have mixed feelings about emulating current-gen consoles. I think there's a very strong ethical case for emulating consoles whose games are no longer made (despite Nintendo's best efforts to shut that down too). But emulating something whose games can still be bought new would tend to encourage piracy, I expect. Edit: "cracking" -> "piracy", for clarity
- andy_ppp 6y agoIf people who wouldn’t have bought a Switch end up playing those games on PC who has lost out here?
- MaximumYComb 6y agoIt's ignorant at best to argue that this is only going to be used by those who wouldn't have purchased a Switch. Once something is free then a lot of people won't spend hundreds of dollars on it.
- capsulecorp 6y agoRight. Now lets ask ourselves why one would need to spend hundreds to play a particular game. The answer you will come across most commonly is platform exclusivity deals. I am happy to pay for a game, but not buy the hardware for a system I don't want, just because they leveraged their business clout to prohibit games from releasing on other platforms. In this case, I could care less about the bottom line of the console company or the game company who agreed to what I view as a corrupt collaboration.
- witherk 6y agoAs someone who uses yuzu to play games at 4k, I have bought 2 switches and purchased the grand majority of the games that I have played on emulator. While I think it's true that devs lose some customers this way, most people who are playing BOTW on their pc (requiring a pretty good computer) pay more money into the nintendo ecosystem than many people imagine. If anything the way nintendo treats it's competitive communities makes me feel bad for giving them too much money. But on the other hand they are one of the only devs who consistently ships quality finished games, so that should be rewarded.
- miguelmurca 6y agoStarting a betting pool as to how long this makes it before being DMCAd
- mdgrech23 6y agowhat's that mean?
- dev-tacular 6y ago[DMCA](https://en.wikipedia.org/wiki/Digital_Millennium_Copyright_Act#:~:text=The%20Digital%20Millennium%20Copyright%20Act,Intellectual%20Property%20Organization%20(WIPO) https://en.wikipedia.org/wiki/Digital_Millennium_Copyright_A....) It could allow Nintendo to take action against this emulator.
- bri3d 6y agoWhy would you see this emulator in particular getting DMCAed? There's not really good precedent for this that I'm aware of - Nintendo did DMCA the repo for a GBA emulator a while ago, but it came with Nintendo game ROMs in the browser.
- miguelmurca 6y ago> Why would you see this emulator in particular getting DMCAed? Nothing in particular, I was thinking about it from the other end. Seeing as the Switch is Nintendo's latest gen console I'd say it's different to something like Dolphin in terms of how much it might bother Nintendo. That plus the fact that when you want something off the internet nowadays a DMCA is typically the legal path, makes me think that Nintendo would love to find something to DMCA the repository for. Whether there's anything to be DMCA'd I can't say (and from the replies I see probably not).
- mappu 6y agoEmulators are legal (see Sony v Bleem). Copyright infringement is a civil offense, but there's none here.
- azinman2 6y agoConsidering this is emulating an ARM processor, I wonder how such software might perform if written specifically for the new M1 macs?
- zapzupnz 6y agoI don't anticipate it would make much real difference. The trick with console emulators is usually making the graphics, audio, and game-specific quirks sing well on commodity hardware rather than the specialised hardware the console has. Getting ARM code to run on Intel isn't the hard bit — so getting ARM code to run on ARM may well be more performant than running it on Intel – but rather the trick is getting all the other precise console-specific hardware to sing with available cross-platform frameworks for audio and video.
- whoisthemachine 6y ago> The CPU emulator, ARMeilleure, emulates an ARMv8 CPU and currently has support for most 64-bit ARMv8 and some of the ARMv7 (and older) instructions, including partial 32-bit support. It translates the ARM code to a custom IR, performs a few optimizations, and turns that into x86 code. Interesting... since .Net is cross-platform and can run on ARM, if it's running on an ARM processor does it just run the instructions directly?
- calaphos 6y agoThe current ARMeilleure seems to emit x86 instructions directly and execute them, so never really using the intermediate representation of Jit compiler of the .Net runtime. However the previous cpu emulator apparently emitted .Net byte code and used RyuJIT (the .Net jit) to emit the final native code. > if it's running on an ARM processor does it just run the instructions directly? So maybe? There are some passes in between but one would think it would at least result in very similar instructions.
- worewood 6y ago> However the previous cpu emulator apparently emitted .Net byte code and used RyuJIT (the .Net jit) to emit the final native code. This seems like a good use case for using .Net. Why did they move away from it?
- astrange 6y agoThe .NET and Java VMs probably aren't optimized for the incoming bytecode also being JIT generated, never needing to allocate memory, wanting to be register-based, etc. Also, I haven't tried JITting them but I've always found their bytecodes to be pretty inexpressive compared to a real CPU (or even LLVM).
- grishka 6y ago> if it's running on an ARM processor does it just run the instructions directly? You can't just run random instructions like that. That code is compiled with the assumption that there's the Switch's OS and hardware underneath, which means it will do all kinds of things, like calling directly into the kernel and assuming a particular address space layout, that would crash it under a different OS. ARM has hardware virtualization. If the host OS supports it, you should be able to make use of it.
- edoceo 6y agoWhy wouldn't one create and emulator for this using QEMU? Couldn't that be possible? Doesn't a bunch of hardware faking have to be rebuilt in C# that QEMU already does (well¿)? Or is it too hard to introduce custom hardware/firmware (like this audio stuff) into QEMU?
- zapzupnz 6y agoFor emulators that intend to run games at full speed, the sorts of shortcuts and tricks needed to achieve high level emulation (which can sometimes fall short of emulation in a strict sense) are often incompatible with writing a plugin or extension to an emulation framework that focuses on accuracy. In the case of the Switch, it's not necessary to emulate the whole device or even processor, especially if the intention is to run Switch games on a computer. Rather, high level emulation is more than sufficient — anticipate what the software depends on the actual hardware to do and redirect it to do the same using what the computer has available.
- landr0id 6y ago>In the case of the Switch, it's not necessary to emulate the whole device or even processor, especially if the intention is to run Switch games on a computer Switch has an ARM processor so it's definitely a requirement to emulate that, which QEMU is well-suited for. But to your point, Windows has great graphics APIs that would make it easier to pipe the graphic stack from the Switch OS into rather than writing your own implementation. The processor can be taken care of via JIT as well, but it still needs to be lifted.
- orra 6y ago> Couldn't that be possible? I mena, in principle, presumably. > that QEMU already does Potentially a couple devices. But for most of the hardware, probably not. Regardless they might—I would—find QEMU harder to hack on, harder to extend, because it is written in C. C is of course the lowest level of all high level languages.
- IntelMiner 6y agoThere is one emulator currently that does do that, the "XQEMU" emulator for the original Xbox https://xqemu.com/ https://xqemu.com/ It's in its infant stages at the moment according to the "Emulation General" wiki and focuses heavily on "accuracy" over performance Other emulators such as CXBX-Reloaded have made larger strides, currently emulating roughly 10% of the software library It's also worth stating, while the Xbox seems like an "easy" target, being based on an ia-32 (Pentium III) PC with an Nvidia GeForce chip (somewhere between a Geforce 2 and 3 at the time) it is an absolutely monstrous beast with minimal documentation about its hardware and numerous "gotchas" It also has a very small library of 'exclusive' content which detracts from gaining many developers
- edflsafoiewq 6y agoWhat made C# a good choice for this?
- tester756 6y agoSometimes people just pick the languages they're most proficent in so they can move fast maybe that's the case here
- bitexploder 6y agoOr as a “Look, you can do X in language Y, a lot of people assumed this was not possible.” Situation. Seen that a few times.
- DoctorOW 6y agoIn my opinion this is the exact reason C# was picked. Almost everything C# is either Windows-only or Console/Server app. This is neither and that's what's interesting to me.
- moonchild 6y agoMany video games are written in c#. This includes pretty much all games written using unity (the most popular 3d game engine) and fna (a very popular 2d framework).
- danhau 6y agoBut that's an apples/oranges comparison, isn't it? C# code in Unity games is predominantly high-level game behaviour / scripting. Most of the heavy lifting is done by Unity behind the scenes. So to me it's even more impressive that an emulator for a modern games console can be written in a 'managed' language.
- tmitchel2 6y agoThe heavy lifting bit of unity is also written in C#. C# has a rep for being slow which is undeserved these days.
- deleted 6y ago[deleted]
- MegaDeKay 6y agoThe other popular Switch emulator, Yuzu, recently released their progress report for February in case you are interested in how far along the state of Switch emulation is these days. Yuzu is C++ and roughly comparable to Ryujinx, feature-wise. https://yuzu-emu.org/entry/yuzu-progress-report-feb-2021/ https://yuzu-emu.org/entry/yuzu-progress-report-feb-2021/
- huachimingo 6y agoCheck out MelonDS, looks very promising and faster than Desmume. They managed to put a JIT for the emulation.
- saagarjha 6y agoDeSmuME has a JIT backend.
- jb775 6y agoIs there a way to intercept data between the Switch and online Fortnite services? I recently bought a Switch and have been playing Fortnite online...noticed more and more "online gamers" have been behaving like bots, so I'd like to take a look at the data if possible (to see if I'm playing against actual people)
- emodendroket 6y agoSeems like you could intercept the traffic with your router.
- klyrs 6y agohttps://www.nintendolife.com/news/2019/09/epic_is_adding_bots_to_fortnite_to_help_players_grow_in_skill https://www.nintendolife.com/news/2019/09/epic_is_adding_bot... It looks like that might be deliberate?
- 177tcca 6y agoWireshark and alternatives.
- royalghost 6y agoI am basically trying to learn c# after many years of working in JVM languages. This project looks like a good hack to learn C# and .NET.
- andi999 6y agoDid GC lead to any problems?
- yc-kraln 6y agoThe one thing I used to really enjoy about developing for Nintendo platforms once they've aged a bit is being able to have fast test-play cycles without hardware; for Gameboy Advance or Nintendo DS the emulators were very good and fully-featured (debuggers, memory inspection, etc.) Unfortunately with Switch we're not there, and I don't think we ever will be. These emulators target, in order of priority, Cracked/Dumped Retail Games, then Homebrew games. I can't use them as part of my game development stack because they won't run binaries if they haven't been submitted to Nintendo to be signed (and subsequently cracked).
- smaudet 6y agoRegarding all the positions that piracy is bad vs freedom of intellectual property, isn't this a bit a red herring? I'm sure neither this nor Yuzu are 100% working - but if let's say work was done regarding allowing legal ripping, i.e. a license system whereby Nintendo grants sale or other rights to hobbyist runningthe express purpose of runnin their games on some emulator. I think a lot of the people drawn to emulator, work, are drawn by the cool factor. Working on homebrew games is a way to learn and express passion about embedded platforms, game dev and coding. They say 'piracy is stealing', but locking down platforms is also stealing. We should enforce universal IP monetary attribution - keep a low standard rate of mandatory fees which must be paid out while at the same time make it illegal for companies to entirely hide their designs.