events, and nds4droid 22/23

As some of you may have noticed there were two nds4droid releases last night, release 22 and release 23. In just a fantastic coincidence of timing, my website host decided to lock me out of updating the site right when I made the release, so I couldn’t keep you guys up to date.

Release 22 contains many performance enhancements, the main one being the inclusion of a new ARM execution engines from gechdcb (of desmume-fork). There are two new engines: a “threaded” version of the interpreter, and a JIT that uses tinycc to dynamically generate code. You can change these under the “Execution engine” option in the Settings menu; the old original engine is the regular interpreter (if you’re having issues try switching back to this).

Release 23 was a hotfix for release 22 — release 22 was using too much memory so on devices with low RAM availability the emulator would crash when loading ROMs. The obligatory Google Play and sourceforge links.

Finally, big shoutout to Alexander P. for his winning submission for OUYA logo contest!

Design the OUYA nds4droid image

The OUYA people have rejected nds4droid 4 (!) times already because of various problems with screenshots including the copyrighted Nintendo name, etc. The latest rejection was because the game’s icon (really a large image) contains a picture of a DS, which is apparently also copyrighted (fair use anyone?!).

SO, I’m reaching out to you, the nds4droid community, to develop the launcher image for nds4droid on the OUYA. This will be the image that represents the app on the console and that people select when they want to start it up. It is also the featured image on the store. Requirements:

  • 732×412 PNG (transparency okay)
  • Cannot contain any references/images/etc. to Nintendo

Post your submissions in the comments or e-mail/tweet them to me and the best one will be the face of nds4droid on the OUYA!

nds4droid release 20

Time for another nds4droid update, both on Google Play and sourceforge. This is mainly a feature update, here’s what you get:

  • Support for the OUYA console
  • Better defaults for game pad key mappings
  • Save/load menus now show the last modified time of save states
  • ROM picker now remembers the last path a ROM was loaded from
  • Fixes a bug where the emulator could crash the very first time it was run on a new device
  • Fixes a bug were some touch buttons weren’t working on certain aspect ratios

As mentioned above this release supports the OUYA console and has been submitted to their store for approval. I don’t have an OUYA (yet) but given it’s specs I expect it to run nds4droid quite nicely 🙂

nds4droid release 19

Believe it or not there’s a new version of nds4doid up on Google Play and sourceforge. Here’s what you get:

  • Performance enhancements (most users should see a 7-10% FPS increase)

On a somewhat related note, I’ve gone to the last two Google I/O conferences, but unfortunately this year because of a bug in the site when it came time to buy tickets I wasn’t able to get a ticket. If anyone knows of someone willing to sell their ticket to me please let me know!

nds4droid release 18 and dynarec beta

First and foremost there is a new version of nds4droid up on Google Play and sourceforge. The changes are:

  • Increased game compatibility, especially for Pokemon series games (thanks Sean)
  • Added option to show only the touch screen (under “Select screens” in settings)

Also, I have been working on merging in the Exophase dynarec into nds4droid (thanks @sShake69). I have the build up and running but I’m not 100% comfortable making it the official build until I have some more time to test it out. Maybe you can help me! If you’re feeling adventurous, you can download the dynarec beta here from sourceforge. Let me know your experience with it! The beta is ARM-v7 (newer phones) only, fyi.

A word on multithreading

A lot of people have asked why nds4droid only takes 50% of their CPU on quad core devices. The reason is generally straightforward: nds4droid has two main threads, one that does the actual emulation and one that does all drawing/compositing/input processing. The actual “main” emulation thread is bottleneck and why the emulator can be slow; we’re only doing the “heavy lifting” using one core. When emulating the DS we have to emulate the CPU instruction per instruction, and doing this on several threads is an extremely complicated (if not an impossible proposition). However, there is some low hanging fruit for parallelization: the DS actually is made up of 2 CPUS, the main ARM9 as well as an auxiliary ARM7 (the same CPU as in the GBA, this is how backwards compatibility was achieved). The ARM7 does sound processing and some 2D graphics work. Currently on the main thread we emulate a few ARM9 instructions, then a few ARM7, and back and forth. In theory we could emulate each of these CPUs on their own thread, giving more time on the main thread for the ARM9 emulation which is our current bottleneck. The problem is that these threads still require lots of synchronization; we often have to “halt” the instruction emulation to process the rest of the DS machinery (graphics, interrupts, etc). I have code that does this, the problem is that my synchronization mechanism is too slow… we lose more than we gain.

In my experiments, I spawn a new thread for each CPU. These then sit in a “wait state”, waiting to be told to emulate instructions. They’re then signaled to execute, and then halt again when they detect some other work needs to be done (usually about 6-12 instructions are emulated before we need to halt again). The problem is that my signaling mechanism is too slow: I’ve tried the standard model of pthread mutexes, but these are way too slow. From my understanding pthread mutexes involve kernel syscalls, and yield the thread timeslice (which is way too long, we need to execute again quickly). Spinlocks are also very slow (although I suppose I’m not 100% sure why). If anyone knows of/can suggest some better thread synchronization models, or maybe some libraries that do intelligent user mode synchronization it’d be greatly appreciated!

nds4droid release 16

Presented for your approval, another nds4droid release! As usual it’s up on Google Play as well as sourceforge. Changelog? Changelog:

  • New setting (on by default) to maintain aspect ratio of original game (turns off “stretching”)
  • New setting (off by default) to show only the main game screen
  • Ability to fake shutting the DS lid (in menu), which is needed by some games like Phantom Hourglass
  • Performance improvements
  • Increased game compatbility

I upgraded to a Note II a few days ago and main screen only in landscape mode looks awesome on it :D.