Monday, May 05, 2008

iFrodo - porting C64 emulator to the iPhone / iPod Touch

As an Objective-C / Objective-C++ / XCode / iPhone development learning experience, I have began porting the Frodo C64 emulator to the mobile OS X platform. I chose Frodo, as I have experience with this code-base, and there is a certain satisfaction of seeing the READY prompt for the first time.

What will some of the challenges be?
  • The iPhone screen is 320x480 pixels. The C64 had a 320x200 pixel display, so ideally the top of the screen will represent the C64's virtual display, without the need to scale.
  • The C64 had a keyboard and games were typically played with a joystick. We have 280 pixels left to represent these devices. I'm not sure if I can display the iPhone's virtual keyboard, and it is unlikely I can reconfigure the keys. Therefore, I'm probably going to have to design my own virtual keyboard image.
  • For the joystick, I'll probably model something off the NES emulator, with a virtual D-Pad and fire button.
Where are we today?
I have reached my first milestone, which was to create an XCode project and compile the basic Frodo engine for the iPhone platform.

What is next?
An emulator typically virtualises numerous devices of the original hardware, so the first I will tackle is the display, as this provides the most immediate rewards. We need an in-memory buffer to write the output of the virtual display device, which finally is rendered to host screen. I experimented with the OpenGL ES API, but found that Core Graphics / CGImage will do the job just fine.

Last night I achieved my goal of writing to an in-memory buffer and rendering this to the iPhone screen. Next is to incorporate this test code into the Frodo engine, to get a C64 running. Screenshots will follow.

No comments: