We've got Glulx running on Android, finally.

Hello everyone,

Some folks may remember an Android app called “Twisty” – it’s still up in the Play store, and in fact it’s the oldest z-machine interpreter out there for Android. Marius Milner and I (two Google engineers) slapped it together in 2008 just before the first Android phone launched.

Over the last 6 years, Twisty (as an open source project) has waxed and waned and attracted a bunch of drive-by developers; but it’s never really advanced much. The thing up on the Play store is covered with cobwebs at this point. And what really irks me is that there still no Glulx interpreter for Android – the half-dozen IF apps in the store only play z-code. This means that basically any large, popular I7 game written in the last decade is still unplayable on Android devices (!)

But I wanted folks to know that things are getting exciting again.

Thanks to the contributions of many folks, we now have a partial implementation of GLK for Android. We’ve hooked up this GLK java front-end to two different interpreters written in C: nitfol and git. Nitfol is a z-machine, and git is a lightning-fast Glulx interpreter. They both talk to our GLK implementation via JNI, and the thing is actually sort of usable.

That is: we can now load and begin playing a majority of I7 Glulx games written over the last few years.

Of course it’s nowhere near usable by the general public. There are many parts of the GLK implementation to finish. But I wanted to share the good news with the community that there’s light at the end of the tunnel, and a clear path to filling this huge gap in Glulx playablity.

The open source project is still over at

code.google.com/p/twisty

…and discussion still happens on googlegroup twisty-dev@googlegroups.com.

I’ve attached a screenshot of one my own games (Rover’s Day Out) running on my Moto X.

Super!

If I’m going to be able to run Kerkerkruip on Android at some point, I’ll be extremely happy.

Brilliant!

I don’t own an Android myself, but I don’t care, this is still fantastic news! Well done! Do keep working on it, Glulx is a fantastic format and you’ve unlocked the possibility of playing a huge number of quality games on a mobile device!

w00t! When will there be a downloadable apk with Glulx support?

cool

hope Twisty also gets Swype input-method support. nobody types on touchscreens…

and BTW, Son of Hunk Punk is an app that plays both z-machine and TADS. It’s the most complete terp for Android I know.

Nice work!

+1000

Thanks so much for doing this. One of the most worrying trends of the IF community development-wise lately has been its tendency to become Apple-centric by default and relinquish by degrees what should be IF’s greatest strength: cross-platform robustness.

I wouldn’t say Apple-centric. Speaking as someone who bought an iPod almost specifically for playing IF, iFrotz was the best available tool (I believe it currently still is, from reports I hear from the android interpreters - no mobile interpreter is perfect, yet, but iFrotz seems to come closest), and I made my decision based on that.

Also, porting interpreters to iOS is part of “cross-platform robustness”.

Finally, where have you been? :slight_smile: We were having a discussion about King, copyright and The Banner Saga on another thread and I’d have thought you’d have loved to join in.

I miss discussing things with you too Peter. Sorry for my absences but I am not great at commitment at the best of times, and anyway I have never felt ‘at home’ in highly moderated spaces. I am sure I’ll wander back now and again however due to my foundational interest in IF and the crossover with my mud/ hobby projects. Take care!

That’s funny, I never felt this place was highly moderated. But to each his own, it’s good to see you back even for a while. :wink:

Could this turn into a Android Gargoyle port? Please? :smiley:

Gargoyle can’t be ported to Android in any obvious way, because it’s a GLK implementation written in C. Android apps are Java, which means a proper “Android GLK” implementation needs to be in Java too.

But you’re using C terps… I’m imagining some kind of C bridge between the Java front end and a garglk compatible backend.

I understand they’re crosscompiling the Glulx engine from C to Java using… whatever that’s called… but the Java front end is Glk. I’m not sure it would mean to port garglk; you need code that displays using the Java/Android display toolkit.

Cross compiling C to Java shouldn’t be necessary, don’t lots of Android apps have C backends?

A port in my mind would be something that presents the same interface as garglk.so, but displays using whatever Android displays with.

I’m already in over my head, but I understand there is a Gargoyle “plugin” for SCUMMVM, which has an Android version. Could Gargoyle functionality be compiled into the Android SCUMMVM?

I know there’s a “Native Development Kit” that allows C apps.

[Now in ‘verbose’ mode]

Android apps are java, pure and simple. There is no choice about that.

Yes, you can run C code on Android, but only in the form of the main java application making a JNI call to a bundled C library. The C library can only do abstract computational stuff, not interesting app-ish stuff like draw on the screen or make the device vibrate. The user interface can only be manipulated by the original calling java application.

(And yes, you cross-compile the C library for ARM using the Native Development Kit, and the library gets bundled into your Java app’s resources.)

So the architecture we have going here is straightforward: Twisty is a regular Android java app. It includes its own java implementation of the GLK interface which knows how to draw android windows, print text to them, etc. It comes bundled with a C library containing the ‘nitfol’ and ‘git’ interpreters. The main java app launches a game by invoking either nitfol or git from the C library using JNI. Both interpreters are doing abstract computational stuff (executing z-machine or glulx opcodes), and making GLK calls back “up” to the main java app via JNI: “hey java, draw a window”, “hey java, put some text in it”. The GLK implementation in Twisty then draws the windows and text as requested.

Gargoyle has a similar architecture. It’s a GLK implementation written in C, talking to a bunch of C-language backend interpreters – not just nitfol and git, but interpreters for whole other systems like TADS. All those backends use GLK to draw the UI. The nice thing about Gargoyle’s GLK implementation is that it’s sort-of-portable C, and it knows how to draw windows and text on Windows, Mac, and Linux. That makes the whole Gargoyle “app” pretty portable to those three operating systems.

Gargoyle isn’t portable to Android, however, because it’s impossible for a C-language GLK implementation to work there. In Android, only java code can make windows and draw in them, not C code. So Android needs its own, standalone, java-based GLK implementation.

The good news, however, is that all of those different C-language interpreters used by Gargoyle can easily be bundled up into Twisty too. They only need a GLK to talk to. It means Twisty will also be able to play TADS games, Alan, Hugo, etc. someday. And hopefully that’s what you really meant when you hoped this would turn into a Gargoyle port, yes? :slight_smile:

Sounds good!

Note that Garglk has a few custom things going on that make some of the terps nicer (colours etc.) If you could include them too, all the better! You’d probably need to define a garglk constant to tell the terps to use them.

I wrote up notes on how I support quote boxes: eblong.com/zarf/glk/quote-box.html