Homebrew WIP melonDS for Switch

Hydr8gon

Dragon Trainer
OP
Developer
Joined
Dec 15, 2014
Messages
316
Trophies
1
Website
hydr8gon.github.io
XP
2,580
Country
Canada
I don't get why emulators on the Switch aren't built for ARM, everything is painfully slow even though the system has a lot of potential. Drastic is by far my favorite emulator, it runs DS games at full speed even on a 100€ android phone from 2013. Maybe I'm too dumb to understand that, but isn't the effort worth it ? With all the power the Switch has, why don't make the best HD DS experience ever made ?
Emulators on the Switch are built for the ARM64 architecture. The problem is, most emulators don't have a JIT (Just-In-Time compiler) for ARM64. Some have one for ARM, but ARM instructions aren't directly compatible with ARM64. Some sort of compatibility layer might be possible, like how 64-bit Windows allows running 32-bit applications, but it would probably require more work than it's worth. ARM64 is faster and it would be better to just write a JIT specifically for ARM64. Easier said than done, though; even with the huge bounty on the N64 JIT, it hasn't happened yet. Without a JIT, we're forced to run with an interpreter; this is very slow. With DraStic though, none of this matters. It's closed source, which means it's impossible for anyone except the original developers to port it. Unless Exophase himself decides to program and release a Switch port, it's not happening. DeSmuME and melonDS are our only options. Hopefully I've explained it clear enough!

Just tried this build. Still no sound. I haven't tried v0.2 though.
That's really weird. I probably won't be able to do much about it until I fix my SD card problems... but as soon as I do I'll be right on it!
 

Hydr8gon

Dragon Trainer
OP
Developer
Joined
Dec 15, 2014
Messages
316
Trophies
1
Website
hydr8gon.github.io
XP
2,580
Country
Canada
No problem, thank you for your work. I'm gonna make a NSP forwarder too; if you want, I can share it later for you to use.
Sure! I'd prefer to not install any NSPs on my Switch to keep it clean, but I'm sure others would appreciate it. I'll link it in the OP when you have it ready.

Also, update on my SD situation. I decided to pull the SD out of my 3DS (I was reluctant to because I hate having to take off the back cover!) but I popped it in my computer and was able to write to it just fine. I've got my Switch running melonDS again using that card and can confirm the missing audio. Now that I can debug it myself though, it'll be much easier to fix.
 

OkazakiTheOtaku

no thanks, I don't want a custom title
Member
Joined
Jul 20, 2016
Messages
1,461
Trophies
1
Location
127.0.0.1
XP
3,114
Country
Japan
Sure! I'd prefer to not install any NSPs on my Switch to keep it clean, but I'm sure others would appreciate it. I'll link it in the OP when you have it ready.

Also, update on my SD situation. I decided to pull the SD out of my 3DS (I was reluctant to because I hate having to take off the back cover!) but I popped it in my computer and was able to write to it just fine. I've got my Switch running melonDS again using that card and can confirm the missing audio. Now that I can debug it myself though, it'll be much easier to fix.
Here you go! Made with 0 SDK tools so it's perfectly fine to distribute. It redirects to SD:/switch/melonds.nro
Tested myself, works 100%.
 

Attachments

  • MelonDS_01000A00064BC000.zip
    378.5 KB · Views: 228
  • Like
Reactions: Hydr8gon

Hydr8gon

Dragon Trainer
OP
Developer
Joined
Dec 15, 2014
Messages
316
Trophies
1
Website
hydr8gon.github.io
XP
2,580
Country
Canada
Alright, v0.3.1. As always, grab it on GitHub, notes below.
This release fixes sound output. It was a really strange bug, but basically, there was nothing wrong with my code; I suspect Atmosphère or Horizon itself to be at fault here. To fix it I've moved the audio process to a different core and it magically works again. This release also completely removes the audio toggle from the settings. I've determined that it has absolutely no impact on performance, so what's the point? If you still want to mute the emulator, the Switch has volume buttons. There's also one last little fix in this build that makes sure the B button can't back you completely out of the SD card. Hopefully I didn't miss anything this time!
To elaborate on the bug, it seems that for whatever reason any thread I create on the Switch's fourth core doesn't run at all. Since this is where I was running the audio code, of course it stopped working. The bug even affects the original release! This can only mean that it's a problem with some external factor; most likely Atmosphère or Horizon. Anyways, the audio now runs on the first core. It shouldn't affect performance because melonDS is run on the second core and the threaded 3D renderer is on the third. The only reason I avoided the main core before is because that's where the system is running and there are less resources there. It should be fine for just the audio though. Well, I guess input processing and framebuffer drawing are on there too, but it'll still be fine. Nothing intensive.

Anyways, lesson learned: test on an actual system before releasing.

@OkazakiTheOtaku I'll add your forwarder to the OP, thanks!
 

OkazakiTheOtaku

no thanks, I don't want a custom title
Member
Joined
Jul 20, 2016
Messages
1,461
Trophies
1
Location
127.0.0.1
XP
3,114
Country
Japan
Alright, v0.3.1. As always, grab it on GitHub, notes below.

To elaborate on the bug, it seems that for whatever reason any thread I create on the Switch's fourth core doesn't run at all. Since this is where I was running the audio code, of course it stopped working. The bug even affects the original release! This can only mean that it's a problem with some external factor; most likely Atmosphère or Horizon. Anyways, the audio now runs on the first core. It shouldn't affect performance because melonDS is run on the second core and the threaded 3D renderer is on the third. The only reason I avoided the main core before is because that's where the system is running and there are less resources there. It should be fine for just the audio though. Well, I guess input processing and framebuffer drawing are on there too, but it'll still be fine. Nothing intensive.

Anyways, lesson learned: test on an actual system before releasing.

@OkazakiTheOtaku I'll add your forwarder to the OP, thanks!
Thank you for the update! Also, when in a game, is there a way to back out to the MelonDS menu?

EDIT: Also thanks for the NSP post and credit
 
Last edited by OkazakiTheOtaku,

Nerdtendo

Your friendly neighborhood idiot
Member
Joined
Sep 29, 2016
Messages
1,770
Trophies
1
XP
4,644
Country
United States
So yeah, I'm unable to set this up rn but I keep seeing this thread so what's the SparkNotes status on this? How well does it run most games at this point?
 

MK73DS

Non-commutative algebra
Member
Joined
Feb 23, 2015
Messages
575
Trophies
0
Age
25
Location
France
Website
www.youtube.com
XP
1,536
Country
France
Emulators on the Switch are built for the ARM64 architecture. The problem is, most emulators don't have a JIT (Just-In-Time compiler) for ARM64. Some have one for ARM, but ARM instructions aren't directly compatible with ARM64. Some sort of compatibility layer might be possible, like how 64-bit Windows allows running 32-bit applications, but it would probably require more work than it's worth. ARM64 is faster and it would be better to just write a JIT specifically for ARM64. Easier said than done, though; even with the huge bounty on the N64 JIT, it hasn't happened yet. Without a JIT, we're forced to run with an interpreter; this is very slow. With DraStic though, none of this matters. It's closed source, which means it's impossible for anyone except the original developers to port it. Unless Exophase himself decides to program and release a Switch port, it's not happening. DeSmuME and melonDS are our only options. Hopefully I've explained it clear enough!

Thank you for your explanation :)
However, the fact that Exophase was able to make a very decent JIT for ARM shows that this is not impossible. I know Drastic is a paid app so he is very well supported in his work, but still, a single man made it. I'm sure there are very talented people here who can work on it too :)

I didn't want to criticize your work (and other dev's work) because I know, or at least I can imagine, how huge and difficult it is. However, the fact that there is no JIT available for ARM frustrates me a bit xD I'm so sad I can't help for it
 

Arisotura

rise of melonism
Member
Joined
Dec 5, 2009
Messages
839
Trophies
1
Age
30
Location
center of the Sun
Website
kuribo64.net
XP
2,498
Country
France
melonDS author here

just letting you fine folks know that the OpenGL renderer will become a reality. it's in early brainstorming phases right now. it's going to need multiple rendering passes to emulate the DS 3D quirks correctly, but the DS is limited to 2048 polygons per frame, so I'm confident this will work.
 

Xandrid

Well-Known Member
Member
Joined
Mar 27, 2016
Messages
1,034
Trophies
0
XP
1,795
Country
Nigeria
melonDS author here

just letting you fine folks know that the OpenGL renderer will become a reality. it's in early brainstorming phases right now. it's going to need multiple rendering passes to emulate the DS 3D quirks correctly, but the DS is limited to 2048 polygons per frame, so I'm confident this will work.
Awesome news, We're with you all the way
 
  • Like
Reactions: CatmanFan

Csmrcc

Well-Known Member
Member
Joined
Sep 13, 2018
Messages
412
Trophies
0
Age
37
XP
905
Country
Spain
melonDS author here

just letting you fine folks know that the OpenGL renderer will become a reality. it's in early brainstorming phases right now. it's going to need multiple rendering passes to emulate the DS 3D quirks correctly, but the DS is limited to 2048 polygons per frame, so I'm confident this will work.
Nicest new this week. Thank you for the invested time.
 

MK73DS

Non-commutative algebra
Member
Joined
Feb 23, 2015
Messages
575
Trophies
0
Age
25
Location
France
Website
www.youtube.com
XP
1,536
Country
France
Drastic will be opensource soon™ according to Exophase : https://drastic-ds.com/viewtopic.php?f=5&t=5501

The next major task, and the big one that I want to complete before open sourcing the emulator, is going to be 64-bit support.

Will it's JIT compiler be useful for other emulators as well as DS ? (Like N64, GC, Wii and 3DS ?)
 
  • Like
Reactions: Csmrcc

Hydr8gon

Dragon Trainer
OP
Developer
Joined
Dec 15, 2014
Messages
316
Trophies
1
Website
hydr8gon.github.io
XP
2,580
Country
Canada
Hey guys, quick update released. Grab it on GitHub! I had a little fun with this one. First of all, having V-sync on is now just as fast as having it off! As such, I've removed the V-sync option. The settings menu is getting pretty bare, but don't worry! Here's the fun part of this release: OpenGL. Now don't get excited just yet. I'm only drawing the software renderer's output to the screen using OpenGL. This means there is NO performance boost! It was actually making V-sync mode a bit slower, which is why I went and found a way to optimize that. What this does mean is that the port will be more ready for the actual OpenGL renderer when it comes. It also means I can more easily do screen layouts, which will probably be the next update. I've tested for a bit and haven't run into any issues, but I'm super new to OpenGL and was honestly kind of amazed when I got it displaying the emulator's framebuffer! Let me know if you have any issues.

Drastic will be opensource soon™ according to Exophase : https://drastic-ds.com/viewtopic.php?f=5&t=5501



Will it's JIT compiler be useful for other emulators as well as DS ? (Like N64, GC, Wii and 3DS ?)
He says he will consider open sourcing. Still, this is exciting news. If DraStic gets an ARM64 JIT, it would surely run full speed on the Switch. Also, no, a DS JIT won't help with any other systems, unfortunately. Dolphin already has an ARM64 JIT by the way.
 

spotanjo3

Well-Known Member
Member
Joined
Nov 6, 2002
Messages
11,145
Trophies
3
XP
6,211
Country
United States
Its great but I don't need it because I finished my DS favourite games a long time ago before Nintendo Switch existed so I don't need to replay it but I would test it just for fun, thought. :)
 

FanNintendo

Well-Known Member
Member
Joined
Apr 16, 2018
Messages
1,583
Trophies
0
Age
51
XP
2,524
Country
United States
i have tried all bios and bins and roms for firmware for melons will not work and it is in melonds folder and can u upload the bins folder or attachment to melonds
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    OctoAori20 @ OctoAori20: Nice nice-