FC64 is a side project of ours that, like the cobbler's kids who never get shoes, never seems to get the attention it deserves. The TODO list hasn't been chipped away at in a long time, and there are still some glaring omissions (the most obvious being sound emulation). There's a nagging decimal mode bug in the CPU that still needs to be fixed. The code has been lost, found, moved around a few places, survived a hard drive failure, but eventually made it's way to http://github.com/claus/fc64
where it's been dormant for, well... a long time.
However, all of that changed this weekend when my Nexus One arrived.
So far I've been doing all of my Android development with the native Java SDK testing on a Motorola Droid, but the Nexus One gave me a chance to install Android 2.2 and the AIR runtime. This provided me an opportunity to take a deep, hands-on dive with with the AIR for Android beta
Naturally, the very first thing I did with it was to try and get FC64 running on the device. I tweeted about it quickly on Saturday and included a very poor screenshot
, and Scott Janousek picked up on it and relayed the news around on his weblog
. I was a little embarrassed that not only did I have a typo in the tweet that was going around (as an aside, Twitter as a stream-of-thought medium for me tends to be much more raw than an article/post/entry), but that the screenshot was such poor quality. It literally was the very first build though, and I was excited to at least get that far.
Since then I've had the chance to bring FC64 to a point where I would officially call it "working" on Android 2.2 via AIR. Here are a few screenshots that illustrate the current progress of version 0.0.1 (click images for larger versions):
These two images show FC64 loaded in portrait mode using the native on-screen keyboard to enter commands. This shows the result of running a simple POKE command.
Here we have a game running in landscape mode with the virtual keyboard hidden.
For the most part it was straightforward and easy to port our 4-year-old ActionScript project to Android via AIR. Here is the short list of things that needed to be done:
- Installing the AIR runtime on my Nexus One
- Creation of a separate AIR project in FlashBuilder with a device-specific main runner class
- Addition of code to handle screen orientation changes
- Refactoring of code to handle keyboard input
- Added support for trackball to act as a joystick
- Creation of a build script to compile, package, and install the application on my phone
Everything else worked out of the box without modification. I did make a few minor changes to the base code in order to improve performance just a little. For example, we were originally dispatching a lot of events for tracking frames per second, but new Event() at short intervals has a lot of overhead on mobile and was slowing down the emulation. This will probably be refactored again into a conditional compilation directive.
I also took some time to wire up the Nexus One trackball so that it can be used as a joystick. In Galaga, for example, scrolling the trackpad will move your ship left and right, and pressing the button down will fire. It's a nice addition and fun for games.
There is still a lot that needs to be done, both for the Android application and for FC64 in general, but I was pleasantly surprised at how quickly I was able to get an initial port of the code base running on my device.
A short Android-specific TODO list for FC64:
- Load ROMs from SD card. Currently I've hard-coded the public domain game Galaga into the application. Pressing the Android "back" button will load the ROM and start it automatically, or, if the ROM has already been loaded, it will reset the CPU.
- Further optimizations such as using Joa's TDSI and Memory class to improve performance (both for mobile and in general).
- Update the visual display. Currently we're scaling the renderer to match the width or height, but it degrades the C64 text. We might remove the scale and just center the renderer for a crisper display.
- Proper key mapping. This wasn't so apparent on the desktop version, but the virtual keyboard on mobile doesn't allow you to press "shift + 2" which is required for entering the " symbol (the original C64 keyboard had " as shift + 2) so BASIC commands are hard to enter.
I plan on pushing the source for this into my GitHub repository at http://github.com/darronschall/fc64
in the next day or so, and I'll propagate the changes upstream to the master repository.