Like many geeky programmer types, I can't own a games console for too long without becoming curious about how to write my own software for it. Console manufacturers don't exactly go out of their way to make it easy for you to do this, though, because in general any method of playing your own home-made program can also be used to play pirated games.

Luckily, my Nintendo DSi is one of the easier consoles to develop for. You can buy a special cartridge that accepts a memory card, which is how you trick the console into running your code. There are even Software Development Kits and Tutorials that show you how to make simple programs. Unfortunately the libraries are written mainly for the DS rather than the DSi, so there isn't support for any DSi-specific features like the cameras.

Still, this is a much better situation than with other consoles like the Sony "you will have what we give you and you will like it" PlayStation 3. This xkcd comic appears to hold true for developer accessibility as well.

Anyway, having received the necessary equipment earlier this week, and studied the various tutorials, today I've finished a simple game.

Yes. It's Snake. Not the most difficult game to write, but complex enough to learn the basics of how to draw things on the screen. At the simplest level you can put the graphics engine in a mode that gives you a frame buffer, which is a 256 by 192 array of two-byte pixel values — the dimensions of one of the two screens — and your program can scribble all over that how it likes.

My Snake implementation, however, uses a slightly more involved means of drawing the graphics: a map of tiles. You define all the 8x8-pixel tiles that could be used (corner of snake, horizontal bit of tail, vertical bit of tail, head at various angles, apple, and so on), put them in a certain area of memory, put the map of which tiles you want where in another area of memory, set a few registers to tell the DS where these places are, and all the tiling and drawing is done for you in hardware. All you have to do is update the "map" area of memory to reflect the current state of the game. The set of hardware-implemented graphics features is much richer than that, of course, as with any modern games console, but that's the extent to which they get used in Snake.

There are a great many homebrew applications for the DS. Someone has even written a ZX Spectrum emulator for it, which helpfully serves as a reminder of a long-departed age when getting your machine to a point where you could run your own programs was literally a matter of turning it on.