Glk/glkote Level9 javascript


I’m adapting some if games to Ubuntu Touch. It’s very simple to anything that can be run in a html5 (specially to great works as Parchment and Quixe).

But, as the first if games I played were the ones from Level 9 I wanted to give it a go, even the C interpreter is a bit old, I could compile the glk code (even I succeeded through emscripten) but trying to run it produces no result.

Now, you can guess I’m not a programmer, and I’m lost. I’m probably confused with concepts.

My idea is to be able to run Level 9 games in a html and it looks it’s possible through glk/glkote but I have no idea what’s the strategy or were to start.
Could someone show me the way? Or confirm that it is possible?

Thank you

Incidentally Emscripten is the approach I took with the recently released JavaScript Hugo interpreter. It’s a custom JavaScript frontend with the engine compiled from C to JavaScript.

What you’d need to do is write C functions described in the porting instructions that would in turn call the JavaScript functions in the frontend. You could use preferably Glkote or the HugoJS frontend. You can look at how HugoJS does it for an example (the relevant bits start at line 275 or so.) You’ll also have to compile with the -s ASYNCIFY=1 option and make the player input methods asynchronous in the C code (e.g. lines 330-355 in the aforementioned file.)

It’s not a simple task, especially if you’re not a programmer. It took me about 70 hours to make the Hugo interpreter and I’ve been a JavaScript developer for almost 10 years. A simpler solution would be to have the games run on a server and pass the input and output between the device and the server, the downside being that you’d need your own server, a constant Internet connection and it’d be text-only. I think there are ready made solutions that would be easy to adapt, although I don’t know much anything about them. Good luck!

Thanks Juhana for answering.

This is interesting for porting to Ubuntu Touch also.

I was looking in the glk port of the Level 9 interpreter and I thought that was already done.
So, I didn’t understand how this port works. What it does then? Convert the interpreter into a standard form?

I imagined that it will be not easy, but maybe I can do a little step closer for someone else.

You can’t use the standard Glk library because it uses an IO system that isn’t compatible with browsers/Emscripten. You need to make your own or use the JavaScript version of Glk (GlkOte). The Glk port isn’t directly compatible with GlkOte.

It should be possible to glue them together; this is why we have a dispatch-layer abstraction. However, I haven’t looked at it.

(I expect it would be an ugly piece of code… as ugly as gi_dispa.c and gi_dispa.js put together. Sorry.)

In the best case you could just have the Glk port call the equivalent GlkOte functions, but I don’t know how realistic that scenario is.

I have written JavaScript implementations for two interactive-fiction VMs, specifically Z-machine and OASYS. You will need to write the front-end yourself though. I didn’t include one for Level9 yet, nor TAVERN or various others (if I find documentation and they are simple enough to implement then I might do so).

I was afraid of this. If it would be so easy it would had already been done by someone.

Maybe this is a good point of start?

There’s not much about the A-code that I could find.
Only code from garglk and the included code from glk port

A port/wrap to .net

And the main source code of the interpreter.

And I could make a dumb of some games. Colossal.dat for example.

If I had information of the Level 9 A-code I could write the implementation (and also the assembler too perhaps). I would hope eventually it can find.

The closest I am is:
Paul David Doherty did righta disassembler,he assures he sends the code to anyone that asks:
h0142kdd (at)
pdd (at)

Ok. I come back because I might have a better picture now.

What is “there” done:

Interpreter ©

Glk implementation ©

Glk/Glkote api (javascript)

That would be the main parts, right?

There’s an Android app that uses a vm

I think I found part of the A-Code specifications!
[edit] Nope. It’s not. Different «A-code»

[rant]A-Code spec 2000 (Thanks to WayBack Machine)

In the ifarchive there is the A-code for Advent and some tools (ther’s a A-Code to C translator here).[/rant]

[Updated]«Wrong» A-code. This is from Platt / Arnautov implementation.
[rant]Oooh! I found the updated website with a javascript implementation of an A-Code parser (I think).

All A-code info updated.


An interesting work in progress. For now, only some specific versions works.
Worth to take a look at.

I manage to get C code into javascript with Emscripten. It’s not playable but it is a start point.
The code is available.