WIP melonDS for Switch

Discussion in 'Switch - Emulation, Homebrew & Software Projects' started by Hydr8gon, Sep 17, 2018.

  1. ShadowOne333

    ShadowOne333 GBAtemp Guru

    Member
    19
    Jan 17, 2013
    Mexico
    Fucking finally.
    Guess they couldn't comply with Google's new policies then? (can't open the link btw but it's on my end)

    If at all, this would only help to maybe port Drastic to other devices, and perhaps even make it a core on RetroArch.
    Out of that, I doubt it could be of much help outside of looking at it's dynarec and some very specific code.
    Each emu is drastically different code-wise to just take other code and rebase the already existing code to match it.
     
  2. Rahkeesh

    Rahkeesh GBAtemp Maniac

    Member
    7
    Apr 3, 2018
    United States
    They are complying actually. They have an arm64 dynarec now, just need to optimize a few more elements for 64-bit. Claim that it may run a bit slower than 32-bit but it's basically there.

    Open source is pending them finishing their stated dev goals, less a sign of giving up than moving on once their task is done.
     
  3. catlover007

    catlover007 Developer

    pip Developer
    8
    Oct 23, 2015
    Germany
    I am sorry that I have to say this, but this is still the thread for a melonDS on switch, not about Drastic on switch or nds emulation on the switch in general. Maybe it's time to move the more concrete questions out into it's own one, esp. with android on switch coming at some point?

    Anyways to give this post atleast some substance, during the last weeks, the x64 JIT progressed well and though it still needs testing, it's mostly done. In the meanwhile I took a break from the CPU and tried optimising the 2d rendering of melonDS. Some progress was made, though I'm not sure if it's worth continuing the effort, with drastic around the corner.
     
  4. ShadowOne333

    ShadowOne333 GBAtemp Guru

    Member
    19
    Jan 17, 2013
    Mexico
    Don't feel discouraged by Drastic.
    If at all it's always nice to see the development of a dynarec and more so for the complex system that the DS is.
    Besides, it's always nice to have options, and for sure having melon around for multiple platforms would be neat too :P
     
    lutyj likes this.
  5. Billy Acuña

    Billy Acuña GBAtemp Addict

    Member
    11
    Oct 10, 2015
    Mexico
    Drastic is cool and all, but melonDS is superior when it comes to features (with DSi emulation in the works) so I will stick on melonDS whatever if it uses @catlover007's dynarec or a copypasta from drastic :)
     
    azoreseuropa likes this.
  6. StapleButter

    StapleButter 'New Member' registered since 2009. Fuck yea.

    Member
    10
    Dec 5, 2009
    France
    can't tell how shit will go on the Switch, but as far as desktop is concerned, melonDS will remain a serious option, y'know

    if we get DraStic as an option for lower-end hardware, or just for people who want speed in general, that's good

    but melonDS is the only one implementing melonism with class :P

    more seriously, tho:

    https://drastic-ds.com/viewtopic.php?f=5&t=4391&p=18970&hilit=hacks#p18962

    DraStic relies on several game-specific hacks. this approach is good for lower-end hardware where the extra accuracy needed would be too costly. but, as history has shown multiple times, any emulation solution that isn't accurate will keep running into issues. which is why melonDS's approach is to avoid game-specific hacks at all costs. the extra accuracy needs higher-end hardware, but also means that you're less likely to run into issues when playing obscure games.

    as an example, several of the games listed in that post, run in melonDS without requiring any game-specific hack.

    some others don't. what I want to know is how far we can get, without requiring absurd hardware of course. (I sure as hell hope we don't have to emulate the ARM9 caches)

    for all I know, CPU timing is still vastly wrong in melonDS.

    one common problem is that of badly-programmed games that have a race condition or whatever. on an environment like PC, those would quickly be caught and fixed due to the nondeterministic timing of those platforms. but, on the DS, games run on the bare metal, and all consoles have the same timing characteristics. so, basically, such bugs tend to go unnoticed, because it works out of sheer luck. but when you run it on an emulator with different timings, it explodes.

    we had the same issue with GX timings and Spellbound for example. the game sends GX display lists via DMA, but here's the catch:
    * it transfers a certain amount of words, then sets up an IRQ handler to continue the transfer once the GX FIFO is less-than-half-full, and so on until everything is transferred
    * after setting up the first transfer, it immediately sends a SWAP_BUFFERS command, without waiting for the transfer to be actually finished

    so how that works is that every time a DMA is finished, the GX FIFO must be less-than-half-full already, or nearly. otherwise, the time interval will cause the game to send a SWAP_BUFFERS command in the middle of the display list, which you guess doesn't go well.

    while working out GX timings, we found out a lot of fun things. did you know that the GX is capable of parallel execution, to some extent? furthermore the timings are different if polygons pass or fail culling/clipping/etc. and so on. melonDS attempts to emulate all that, but it's still not perfect.

    you can see from code comments that DeSmuME ran into similar issues in the past, and they took the easy route of making their GX commands artificially fast. measurements show that NO$GBA adopted a similar approach.

    and yet, the GX is lame compared to a full-fledged CPU (hi, ARM9).
     
    Flame, xeyatan, Billy Acuña and 3 others like this.
  7. MK73DS

    MK73DS Non-commutative algebra

    Member
    6
    Feb 23, 2015
    France
    France
    It uses only 13 game-specific hacks though. Which means that 99% of the games will run fine on low-end devices even without any hacks. I hope melonDS will be able to reach this level of performance in the future !
     
  8. StapleButter

    StapleButter 'New Member' registered since 2009. Fuck yea.

    Member
    10
    Dec 5, 2009
    France
    we're trying, and we're getting a JIT recompiler. but, we're committed to running games without hacks, so we might not reach the level of DraStic.
     
    Csmrcc, Bitsoft, Mouser X and 2 others like this.
  9. doctorgoat

    doctorgoat GBAtemp Advanced Fan

    Member
    4
    Jun 3, 2015
    United States
    Are there non-harmful speedhacks? I remember at least one emulator for PSP that had detection for certain loop types as a feature, but someone had to actually find said loops on a PC emulator before they could be added as patches. Wait loops? I don't remember.

    I booted up SaGa 2 hoping it wouldn't be too rough, and it looks to be visually as complex as FFIV. There didn't seem to be any difference at all between OpenGL and software, except OpenGL was constantly artifacting.
     
  10. StapleButter

    StapleButter 'New Member' registered since 2009. Fuck yea.

    Member
    10
    Dec 5, 2009
    France
    speedhacks don't serve a lot of purpose in a DS emulator, except for the occasional game that has a stupid-ass idle loop pegging the CPU, but 99% of the DS games out there use proper IRQ waits
     
  11. Billy Acuña

    Billy Acuña GBAtemp Addict

    Member
    11
    Oct 10, 2015
    Mexico
    That's good to know, so melonDS may eventually be almost on pair to DraStic in terms of performance with only a few of exceptions of games, right?

    Enviado desde mi SM-G950F mediante Tapatalk
     
    ShadowOne333 likes this.
  12. Rahkeesh

    Rahkeesh GBAtemp Maniac

    Member
    7
    Apr 3, 2018
    United States
    Well Drastic tells me its locked at 60 FPS but I can see what feels like missed frames in Portrait of Ruin, so yeah corners are being cut. Still it was targeted at devices with far less power than the Switch so.
     
    ShadowOne333 likes this.
  13. MK73DS

    MK73DS Non-commutative algebra

    Member
    6
    Feb 23, 2015
    France
    France
    You can disable frameskip, I never experienced any kind of missed frames in any game
     
  14. mattyxarope

    mattyxarope Advanced Member

    Newcomer
    3
    Jan 15, 2019
    United States
    Any chance of a new port of MelonDS with the JIT renderer?
     
    Ka_Ninja likes this.
  15. Hydr8gon
    OP

    Hydr8gon Dragon Trainer

    Member
    8
    Dec 15, 2014
    Canada
    Nope. The JIT was written for x86-64 processors, so it won't work on the Switch's ARM64 processor.
     
  16. mattyxarope

    mattyxarope Advanced Member

    Newcomer
    3
    Jan 15, 2019
    United States
    Ah ok. Thanks.
     
  17. catlover007

    catlover007 Developer

    pip Developer
    8
    Oct 23, 2015
    Germany
    The x64 JIT more or less ready (except some extra optimisations and who knows what bugs arrive), so I started working on the A64 JIT compiler, but it still needs some time. Currently almost all ALU instructions are compiled, but everything's else still interpreted.
     
    notimp, ber71, DogParty and 7 others like this.
  18. catlover007

    catlover007 Developer

    pip Developer
    8
    Oct 23, 2015
    Germany
    progress!

    Green Joy-Con D-Pad Shells for Nintendo Switch


    like the x64 JIT (which has been merged btw!) the ARM64 JIT is now in a state where it's roughly complete, with still (hopefully very few or no:D) bugs to be found and optimisations to be made.

    Unfortunately the speed gained by the dynarec wasn't enough, it ran almost full speed. In most situations the 2D GPU was the bottleneck now (3-4ms spent emulating the CPU while 9ms per frame spent emulating the 2D GPU). Fortunately I had already experimented with some optimisations in the past and here we are. It's running barely at full speed, but there's also still enough optimisation potential there.

    EDIT: this is of course without overclocking
     
    Last edited by catlover007, Aug 17, 2019
    JJTapia19, hausa51, Rickyman and 7 others like this.
  19. seanp2500
    This message by seanp2500 has been removed from public view by x65943, Aug 18, 2019, Reason: Video only post.
    Aug 17, 2019
  20. StapleButter

    StapleButter 'New Member' registered since 2009. Fuck yea.

    Member
    10
    Dec 5, 2009
    France
    it also runs flawlessly on an actual DS, if you're going to pull that kind of response >_>

    either way, this thread isn't about DraStic, so can you and your friends please get out of here and go wank over DraStic's amazing performance elsewhere? thank you.
     
    Coreyosaur, hausa51, Csmrcc and 4 others like this.
  21. seanp2500
    This message by seanp2500 has been removed from public view by porkiewpyne, Aug 18, 2019, Reason: Thread cleanup.
    Aug 18, 2019
  22. tabnk

    tabnk GBAtemp Regular

    Member
    5
    Jan 20, 2016
    United States
    Nice. Looking forward to this.

     
  23. Hydr8gon
    This message by Hydr8gon has been removed from public view by porkiewpyne, Aug 18, 2019, Reason: Thread cleanup.
    Aug 18, 2019
Quick Reply
Draft saved Draft deleted
Loading...