Playing tads intfiction on linux without X11 (moble)

Is anyone familiar with the source code for tads2 ?

I’ve been wanting to play interactive fiction on mobile devices for a while, and noticed that many devices really run linux underneath and almost all of them support the linux framebuffer. So I finally broke down and rooted my sony PRS900, down to native Linux, wrote a morse code keyboard for it along with a VT52 terminal emulator for e-ink displays so I could play all things UNIX terminal oriented: eg: run frotz and frob on it for z-machine and tads interactive fiction games respectively.

source code for linux frob is here:

My programs work!!! and at very decent speeds!!! (It’s a 250MHz processor, with native C compiled files) and I’m getting fast enough at morse code to be contented. (It takes about a week of practice to get proficient at it and to learn gnu readline shortcuts…)

However, I’m a perfectionist and want to go further – I would love to at least be able to see the illustrations that come with some games like “escape from the crazy place”… It’s part of the fun; There’s no QT or X11 on the Sony, and they’re too big and difficult to install. So , sadly I cant run QTADS.

But: If I could just get the resource files for the images to extract from the tads2 game files, at the appropriate time, I could easily modify the VT52 terminal to display those images; but I got stuck:

I figured out this much, in the source code: frobtads-1.2.3/tads2/output.c – the HTML code is parsed and stripped when being passed to the unix terminal; and I can add a few lines of source code to make it tell me the url of multimedia resources when they would normally be used: eg: (add this to ~line 2192)

				else if (!stricmp(attrname, "src")
								&& !stream->html_in_ignore
								&& stream->html_allow_alt)
							outstring_stream(stream, "(<" );
							/* Write out the image URL */
							outstring_stream(stream, attrval );
							outstring_stream(stream,">)" );


So, when playing escape from the crazy place, in the middle of the text, where the image should have been displayed – it will print (<Pics/Donald.jpg>) which says that the picture has a file name of Pics/Donald.jpg , and it is embedded inside the Escape.gam file somewhere. Therefore, if instead of printing the name – I could write a short bit of code to extract the resource to a temporary file, or at least run a C progarm on it inside “output.c”, I could easily send a binay bimap image escape sequence and have my VT52 terminal emulator print the picture on the linux framebuffer; or I could play .wav soundfiles, etc.

This should be very easy to do – but I’m just not familiar enough with the code/coding style to figure out how to do it:

There is supposed to be a function called osfiledef* (*find_resource)( *appctxdat, *resname, renamelen, ulong *res_size ) which is supposed to open resources that the interpreter has opened, and seek out the place in the resource file where a particular image or sound is stored.

However, as you can see – it’s defined as a dynamic function – and I can’t find any source code or initialization of that dynamic function, and I don’t see a single example of it in use in the source code…

Can anyone point me to a working example of it?
Or does anyone know of source code which is capable of extracting resources given the name of the resource?

It’s not that simple. If you enable HTML mode, the VM will generate full HTML for everything, not just for resources. You will be getting HTML for everything, including text, fonts and font styles.

You should probalby be looking at Qt for embedded instead (which doesn’t need X11 and runs on the Linux framebuffer.)

But if you still want to try it with frob, you should be looking at the QTads sources to see how the functions you’re looking for are implemented. Frob doesn’t implement any of that.


I definitely didn’t know there was a QT for linux framebuffer; I’ll have to try that out; although I only have keyboard support – not mouse, as I was only able to figure out what the keycodes were by examining a hexdump of the sony keyboard device driver’s output at /dev/ttymxc1 – but the mouse codes that come through there are 8 byte nightmares that don’t really seem to correlate to screen position in a clear way.

Does QT play nice with keyboard only operation, or does it require a mouse ?

Also – There’s no need to enable full HTML for what I want to do, although you’re partially right – as I discovered the code in Qtads that wraps the missing functions in C++ in the html only directory (which is not included in frobtabs).

I already isolated the place in the non-html source code of frobtads where the text terminal driver mode removes the tag for and . So I can already get the name of the resource with html tags turned off. The only thing I need to make this all work is an example of how to locate the byte offset of a resource in the .gam file – and the program uses some of those resources whether or not html mode is turned on or not.

If you look at the file frobtabs-1.2.3.tar.gz , file: /frobtads/tads2/fio.c with no html mode supported,
. … ource.html, on about line 101, there is a C routine to locate all entries in a .gam’s internal HTML resources directory.

That alone, and the two routines which call it (in the same file) are all I need to solve the problem.

What I don’t know is just how the errror context definition, filedefinition, and application context variables are being used in the main program – So I can’t call this function because I don’t know the variable names/global variables, and expected behavior. And I don’t know how to extract the output from the context variable, once the function has been run because of missing dynamic functions…

Without that knowledge I have to go to a little extra work to circumvent the problem…

One way to solve the problem would be to just write an external helper program which scan’s the .gam file for all instances of the text string, “HTMLRES”, and have it then run a re-implementation of the above function on all possibilities; but re-implemented without either the error or main file context structures as call parameters…

IT would be crude, and simply call exit() if there was an error – but I could have it print out the name of the resource, it’s file byte pointer, and the resources size in bytes – and save these to another file.
With just that much information – I can get the VT52 terminal driver to do the rest… printing pictures whenever a resource identifier gets printed in the output stream. eg: I used “(<” in my example in the opening post.

It just would be easier if someone already knew how to use the built in fio.c functions and I could call them from inside frobtabs rather than write an external helper program.

It requires neither, but it all depends on the underlying platform. And I don’t know much about embedded stuff. I only knew that Qt runs on such systems.

You should create your own appctxdef and pass that. You’d need to set the relevant function pointers that are called in it to functions that you’ve written yourself. add_resource and set_resmap_seek are what are called by fiordhtml() and are used to communicate to your application context where the resources inside a file. These functions are documented here: … 2/appctx.h

As for the error context, this is how one is created: … trd.c#L785

osfildef is just a FILE typedef: … ads.h#L244