Categories

Archive pour la catégorie ‘Nintendo DS’

Some fun with the Nintendo DS

What’s more fun than playing the Nintendo DS ? Brewing home-made software for the Nintendo DS !

First of all, some starting points. Here they are, dynamically extracted from my Yoono account using the Javascript builder :

Using devkitpro is quite straightforward, you’ve got all the power of GCC (including C++ templates) on the Nintendo DS !

My first project was a kind of Pong without purpose. You could just grab and launch the ball with the pen and watch it bounce against the walls. Pretty basic, but it’s amazing how interacting with the pen gives a true feeling of the ball. Try it here.

My second project is a Mandelbrot set explorer. It’s pretty simple, but the trick is that I’m using both CPUs. Yes, the Nintendo DS has two CPUs, an ARM9 which is the main CPU and a less powerful ARM7 which is somewhat dedicated to I/O. Nevertheless, you can really write two programs that run concurrently on both CPUs and exchange data through shared memory.

Therefore, my program divides the work between the two CPUs, giving one line to compute to the ARM7 while the ARM9 computes two lines. Eventually, the whole image is computed 33% faster using both CPUs than what I would get using only the ARM9.

Another fun thing was that the ARM7 doesn’t have any floating point operation support. Therefore, I had to switch my initial naive floating point code to an integer version, implementing the peculiar arithmetic in a C++ class with operator overloading. For once operator overloading is actually useful !

You can scroll in the set using the directional pad, zoom in using the L button, zoom out using the R button, and fiddle with the color palette using the A, B, X and Y buttons. You can also scroll in the set using the pen, and if you press L or R while holding down the pen, the zoom is centered on the pen, instead of being centered on the center of the screen.

You can download the program here. Unfortunately, by using advanced features like communication between the two CPUs, this program cannot be run under any current emulator. You have to download and run it into real hardware.

If someone is interested, I’ll release the source code as soon as I’ve done a bit of formatting.