Phone SNES

Last weekend I became distressed that the 500 MHz processor in my cell phone (i-mate Jasjar) was going to waste for most of the day, so I decided to do something about it. I searched around a bit and came across PocketSNES, a Super Nintendo emulator for Pocket PCs (in a strange twist of fate, PocketSNES is maintained by somebody who works for the same company I do). When I was a kid, I was (still am?) a huge SNES fan, so this sounded perfect.

Unfortunately PocketSNES was built for PocketPC 2003 (not 2005), and was hard-coded everywhere for portrait-mode 240x320 screens. After fixing a lot of bugs and recompiling with the latest SDK, I was able to get it to work in 480x640 mode:

Legend of Zelda

Now it was more or less usable, but it was very slow. I debugged it and discovered that Windows Mobile 5.0 was using an emulated framebuffer for GAPI games, which was slowing everything down considerably. After poking various memory addresses (and crashing the phone several times - so much for Windows CE memory protection..), I found that the video memory for the Intel PXA embedded video begins at virtual address 0xA87AA000, and is laid out linearly (480x640x16). Replacing the GAPI code with direct video memory access and turning on compiler optimization made PocketSNES run quite fast (even the sound worked pretty well).

Now the only problem was that it was a huge pain to play using the little on-screen keypad. Using the phone's keyboard didn't work too well either since it had a hard time accepting multiple simultaneous button presses. After some more searching, I came across the Chainpus BGP100 Bluetooth gamepad (yeah, they need a new name for it):

Bluetooth Controller

It looks hideous because it's designed to fit around a cell phone (my phone was too big). It was surprisingly easy to set up and associate it with the phone using Bluetooth. The software for it, on the other hand, was very poorly implemented and translated. It had also not been recompiled for Windows Mobile 5.0 either. As a result, there was almost a 1-second delay between a button press on the gamepad and when it was recognized by the game (this was mainly because PocketSNES was using 100% of the CPU). Unfortunately the source code was not available, so I had to re-implement its functionality by hand in order to fix that problem. The gamepad implements the Bluetooth Serial Port Profile (SPP), and it sends sequences of 3 bytes for each button press & release event, so it was actually extremely easy to work with. I just had to create a virtual COM port using the Bluetooth control panel, open the 'file' COM3 and read bytes from it when it was input time.

When that was all done, I was able to play at a comfortable distance from the phone:

Super Mario World

This should be very useful for boring meetings at work 🙂

Here's a video:

Posted on May 31, 2006
Comments (4) Trackbacks (0)
  1. will you be posting a download link for this recompiled version?

  2. Just stumbled across this blog posting through massive google-ing.

    Would it be possible to use your findings to author a simple driver that would enable the Chainpus/Freedom/Brando BT gamepad to function on any WM5 device?

    Totally fascinating, BTW.

  3. Sure, I guess that would work. I don’t know what goes into writing a WM 5 driver, but it is probably similar to writing normal application code like I did.

No trackbacks yet.

Me

Apps

CubeCheater Piratizer

Search

Archives

Site Tasks