Sunday, June 21, 2009

Porting Ren'Py to iPhone project

Ren'Py is a visual novel framework written in C and Python which conveniently compiles Win32, OS X and Linux targets for you. For those of you old enough to remember "Choose Your Own Adventure" books, visual novels are basically the same idea.

One platform Ren'Py does not support is iPhone, likely due to these factors:

  1. The Ren'Py developer community's doubts about the viability of the iPhone app economy (commercial visual novels cost more than most iPhone apps) compounded by recent dustups concerning App Store authors not being paid in a timely fashion
  2. Apple's public stance against App Store apps with code interpreters. Under the terms of clause 3.3.2 of the iPhone 3.0 SDK, it would seem to be impossible to develop any kind of software with a code interpreter that uses its own frameworks. And yet this is being debated endlessly across forums ever since the 3.0 SDK came out. I suspect the more hardline Apple tries to be on this point, the harder developers will push to create better toolchains of their own, leaving Apple in the unenviable position of trying to add EULA language prohibiting you the end user from choosing what kind of software you want to run on a device you outright own (they had the choice not to port the iPhone to the iPod Touch).
Despite these obstacles, we have to remember that the iPhone platform was designed for a very specific purpose: to waste as much time as humanly possible. And to this end, visual novels are IMO a killer pocket app.
Just to make it all fun, I have zero experience with Python or XCode and limited experience with C-based languages -- but then, most of my learning new stuff has been to build real-world projects.
So, let's enumerate what has to be done to accomplish this particular project:

Goalposts:

  • Learn Ren'Py/Python
  • Learn SDL framework
  • Learn enough Objective-C/C++
  • Learn enough iPhone dev process/XCode/alternate toolchains

Ren'Py main dependencies:

  • PyGame
    • Python (found, available from Cydia)
    • libsdl (found)
    • ffmpeg (proven, on Cydia)
    • libogg (proven, on Cydia)

Possible final product distribution:

  1. unjailbroken app distributed via ad hoc (ad hoc is limited to 100 users)
  2. jailbroken app distributed via Cydia
  3. self-distributed manually installed .ipa package (potential path, not enjoyable yet for end users)

Possible packaging:

  1. Standalone package (possibly a compile option for Ren'Py main)
  2. Shell app to be fed game files from existing games (i.e. jailbroken app)

Issues/obstacles:

  • Licensing for Python / SDL incompatible with AppStore (irrelevant) and not necessarily free for commercial products
  • This suggests a shell app feature which can load Ren'Py /game
  • Performance hits from multiple software abstraction layers and interpreters (could be serious)

Recently discovered resource:

haXe for iPhone (iPhone port takes care of SDL wrapper, among other things)

6.28: found libsdl for iPhone
6.29: iPhone 3.0 SDK installed
6.30: Looking into open source toolchains to bypass iPhone 3.0 SDK licensing issues

Saturday, June 13, 2009

Uploading Lucida Grande to your iPhone

Preface: this would not be possible without Tukulesto's sparse tutorial. Recommended software: TouchTerm Lite and FontViewer on your iPhone.
Amazingly, Apple chose not to put OS X's signature font on their mobile platform. This can be corrected if you have a Mac handy and your iPhone is jailbroken.
For starters, have an sftp client on your Mac (Cyberduck is good). Log in and navigate to /System/Library/Fonts. There should be two things in it: CGFontCache.plist and the Cache directory (where the fonts actually live). Since 10.4, OS X has stored its property list files in binary rather than XML format: this can be converted using the plutil command line utility. The astute among you will notice that the OS on the iPhone itself has a plutil utility, but beware: the converters were stripped out by Apple.
The basic procedure is as follows: sftp into your iPhone, drag the fonts you want added into the Cache folder, then convert-edit-convert the CGFontCache property list to add the font's metadata, then shutdown/restart your iPhone to make the change take effect.
Why would you bother doing this? In my case, I wanted to see the Apple website rendered more faithfully, and to add more diversity of sans-serif fonts to Stanza's ebook reader (many of the defaults are derivatives of the same Grotesk gothic family). It's also good practice for hacking your iPhone.


-- Post From My iPod touch

The 21st century inflight

I generally avoid flying since the TSA decided an insulin pump was grounds for unpacking all my luggage, but I really like my in-laws and they live across the country in North Carolina (not too far from where Ruth and I used to live before we moved to Arizona).
We've both got 8Gb iPod Touches and we planned to keep ours stocked with entertainment media for the long drives and flights. Archive.org is a good source of public domain MP4 content including vintage cartoons. Ruth found smoking deals on some childrens' classics in audiobook format as well as the large free assortment from vox libris. Stanza connects to the Gutenberg Project where much is there to be downloaded.
Aboard our flight, I was surprised how many laptops, netbooks and iPods popped out.


-- Post From My iPod touch